From 43de621a24df111cfe89111362a67fb255ed7256 Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Wed, 27 Oct 2021 15:11:14 -0700 Subject: [PATCH 001/119] Get latest release of PEGTL --- PEGTL | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PEGTL b/PEGTL index 7d039707..1643777c 160000 --- a/PEGTL +++ b/PEGTL @@ -1 +1 @@ -Subproject commit 7d039707cf835cea63daa78a717e18fcc5bcf95b +Subproject commit 1643777c2d8cfe01668e217aa7d4cbd6b9f173ba From 710052e8d8b34227c1c9bfc19abf246a9f64eb7c Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Thu, 28 Oct 2021 15:36:58 -0700 Subject: [PATCH 002/119] Enable C++20 with target_compile_features --- CMakeLists.txt | 2 -- src/CMakeLists.txt | 8 ++++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8a24b3b6..f5202523 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,8 +33,6 @@ endif() project(cppgraphqlgen VERSION ${LATEST_VERSION}) -set(CMAKE_CXX_STANDARD 17) - set(GRAPHQL_INSTALL_INCLUDE_DIR include CACHE PATH "Header file install directory") set(GRAPHQL_INSTALL_TOOLS_DIR bin CACHE PATH "schemagen install directory") set(GRAPHQL_INSTALL_CMAKE_DIR lib/cmake CACHE PATH "CMake config files install directory") diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 1160763d..855a3cb8 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -65,6 +65,7 @@ endfunction() add_library(graphqlpeg SyntaxTree.cpp) add_library(cppgraphqlgen::graphqlpeg ALIAS graphqlpeg) target_link_libraries(graphqlpeg PUBLIC taocpp::pegtl) +target_compile_features(graphqlpeg PUBLIC cxx_std_20) target_include_directories(graphqlpeg PUBLIC $ $ @@ -88,6 +89,7 @@ add_library(graphqlresponse Base64.cpp GraphQLResponse.cpp) add_library(cppgraphqlgen::graphqlresponse ALIAS graphqlresponse) +target_compile_features(graphqlresponse PUBLIC cxx_std_20) target_include_directories(graphqlresponse PUBLIC $ $) @@ -122,6 +124,7 @@ if(GRAPHQL_BUILD_CLIENTGEN) ClientGenerator.cpp RequestLoader.cpp) add_executable(cppgraphqlgen::clientgen ALIAS clientgen) + target_compile_features(clientgen PRIVATE cxx_std_20) target_link_libraries(clientgen PRIVATE generator_util) add_bigobj_flag(clientgen) @@ -161,6 +164,7 @@ endif() if(GRAPHQL_BUILD_SCHEMAGEN) add_executable(schemagen SchemaGenerator.cpp) add_executable(cppgraphqlgen::schemagen ALIAS schemagen) + target_compile_features(schemagen PRIVATE cxx_std_20) target_link_libraries(schemagen PRIVATE generator_util) add_bigobj_flag(schemagen) @@ -299,6 +303,7 @@ add_library(graphqlservice Schema.cpp Validation.cpp) add_library(cppgraphqlgen::graphqlservice ALIAS graphqlservice) +target_compile_features(graphqlservice PUBLIC cxx_std_20) target_link_libraries(graphqlservice PUBLIC graphqlpeg graphqlresponse @@ -327,6 +332,7 @@ add_library(graphqlintrospection Introspection.cpp IntrospectionSchema.cpp) add_library(cppgraphqlgen::graphqlintrospection ALIAS graphqlintrospection) +target_compile_features(graphqlintrospection PUBLIC cxx_std_20) target_link_libraries(graphqlintrospection PUBLIC graphqlservice) if(GRAPHQL_UPDATE_VERSION) @@ -348,6 +354,7 @@ endif() # graphqlclient add_library(graphqlclient GraphQLClient.cpp) add_library(cppgraphqlgen::graphqlclient ALIAS graphqlclient) +target_compile_features(graphqlclient PUBLIC cxx_std_20) target_link_libraries(graphqlclient PUBLIC graphqlpeg graphqlresponse) @@ -378,6 +385,7 @@ if(GRAPHQL_USE_RAPIDJSON) set(BUILD_GRAPHQLJSON ON) add_library(graphqljson JSONResponse.cpp) add_library(cppgraphqlgen::graphqljson ALIAS graphqljson) + target_compile_features(graphqljson PUBLIC cxx_std_20) target_link_libraries(graphqljson PUBLIC graphqlresponse) target_include_directories(graphqljson SYSTEM PRIVATE ${RAPIDJSON_INCLUDE_DIRS}) From 91949b90313acaa230246fa7b15a38661723e388 Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Thu, 28 Oct 2021 17:14:42 -0700 Subject: [PATCH 003/119] Bump major version for breaking changes --- cmake/version.txt | 2 +- include/graphqlservice/internal/Version.h | 6 +++--- include/graphqlservice/introspection/IntrospectionSchema.h | 6 +++--- res/ClientGen.rc | 4 ++-- res/SchemaGen.rc | 4 ++-- res/graphqlclient_version.rc | 4 ++-- res/graphqlintrospection_version.rc | 4 ++-- res/graphqljson_version.rc | 4 ++-- res/graphqlpeg_version.rc | 4 ++-- res/graphqlresponse_version.rc | 4 ++-- res/graphqlservice_version.rc | 4 ++-- samples/client/BenchmarkClient.h | 6 +++--- samples/client/MutateClient.h | 6 +++--- samples/client/QueryClient.h | 6 +++--- samples/client/SubscribeClient.h | 6 +++--- samples/separate/TodaySchema.h | 6 +++--- samples/separate_nointrospection/TodaySchema.h | 6 +++--- samples/unified/TodaySchema.h | 6 +++--- samples/unified_nointrospection/TodaySchema.h | 6 +++--- samples/validation/ValidationSchema.h | 6 +++--- 20 files changed, 50 insertions(+), 50 deletions(-) diff --git a/cmake/version.txt b/cmake/version.txt index 084e244c..0c89fc92 100644 --- a/cmake/version.txt +++ b/cmake/version.txt @@ -1 +1 @@ -3.6.0 \ No newline at end of file +4.0.0 \ No newline at end of file diff --git a/include/graphqlservice/internal/Version.h b/include/graphqlservice/internal/Version.h index 1c3b8993..c4ac8f96 100644 --- a/include/graphqlservice/internal/Version.h +++ b/include/graphqlservice/internal/Version.h @@ -10,10 +10,10 @@ namespace graphql::internal { -constexpr std::string_view FullVersion { "3.6.0" }; +constexpr std::string_view FullVersion { "4.0.0" }; -constexpr size_t MajorVersion = 3; -constexpr size_t MinorVersion = 6; +constexpr size_t MajorVersion = 4; +constexpr size_t MinorVersion = 0; constexpr size_t PatchVersion = 0; } // namespace graphql::internal diff --git a/include/graphqlservice/introspection/IntrospectionSchema.h b/include/graphqlservice/introspection/IntrospectionSchema.h index 6eaf1eb6..4225c6e7 100644 --- a/include/graphqlservice/introspection/IntrospectionSchema.h +++ b/include/graphqlservice/introspection/IntrospectionSchema.h @@ -10,9 +10,9 @@ #include "graphqlservice/internal/Schema.h" -// Check if the library version is compatible with schemagen 3.6.0 -static_assert(graphql::internal::MajorVersion == 3, "regenerate with schemagen: major version mismatch"); -static_assert(graphql::internal::MinorVersion == 6, "regenerate with schemagen: minor version mismatch"); +// Check if the library version is compatible with schemagen 4.0.0 +static_assert(graphql::internal::MajorVersion == 4, "regenerate with schemagen: major version mismatch"); +static_assert(graphql::internal::MinorVersion == 0, "regenerate with schemagen: minor version mismatch"); // clang-format off #ifdef GRAPHQL_DLLEXPORTS diff --git a/res/ClientGen.rc b/res/ClientGen.rc index 61b529c6..f291dfb8 100644 --- a/res/ClientGen.rc +++ b/res/ClientGen.rc @@ -3,8 +3,8 @@ #include -#define CLIENTGEN_RC_VERSION 3,6,0,0 -#define CLIENTGEN_RC_VERSION_STR "3.6.0" +#define CLIENTGEN_RC_VERSION 4,0,0,0 +#define CLIENTGEN_RC_VERSION_STR "4.0.0" #ifndef DEBUG #define VER_DEBUG 0 diff --git a/res/SchemaGen.rc b/res/SchemaGen.rc index de39f745..9ad9eea0 100644 --- a/res/SchemaGen.rc +++ b/res/SchemaGen.rc @@ -3,8 +3,8 @@ #include -#define SCHEMAGEN_RC_VERSION 3,6,0,0 -#define SCHEMAGEN_RC_VERSION_STR "3.6.0" +#define SCHEMAGEN_RC_VERSION 4,0,0,0 +#define SCHEMAGEN_RC_VERSION_STR "4.0.0" #ifndef DEBUG #define VER_DEBUG 0 diff --git a/res/graphqlclient_version.rc b/res/graphqlclient_version.rc index 1aa12516..135ce4ad 100644 --- a/res/graphqlclient_version.rc +++ b/res/graphqlclient_version.rc @@ -3,8 +3,8 @@ #include -#define GRAPHQL_RC_VERSION 3,6,0,0 -#define GRAPHQL_RC_VERSION_STR "3.6.0" +#define GRAPHQL_RC_VERSION 4,0,0,0 +#define GRAPHQL_RC_VERSION_STR "4.0.0" #ifndef DEBUG #define VER_DEBUG 0 diff --git a/res/graphqlintrospection_version.rc b/res/graphqlintrospection_version.rc index 2638d8fe..3ac6cbc2 100644 --- a/res/graphqlintrospection_version.rc +++ b/res/graphqlintrospection_version.rc @@ -3,8 +3,8 @@ #include -#define GRAPHQL_RC_VERSION 3,6,0,0 -#define GRAPHQL_RC_VERSION_STR "3.6.0" +#define GRAPHQL_RC_VERSION 4,0,0,0 +#define GRAPHQL_RC_VERSION_STR "4.0.0" #ifndef DEBUG #define VER_DEBUG 0 diff --git a/res/graphqljson_version.rc b/res/graphqljson_version.rc index b3d82a4c..7f07d762 100644 --- a/res/graphqljson_version.rc +++ b/res/graphqljson_version.rc @@ -3,8 +3,8 @@ #include -#define GRAPHQL_RC_VERSION 3,6,0,0 -#define GRAPHQL_RC_VERSION_STR "3.6.0" +#define GRAPHQL_RC_VERSION 4,0,0,0 +#define GRAPHQL_RC_VERSION_STR "4.0.0" #ifndef DEBUG #define VER_DEBUG 0 diff --git a/res/graphqlpeg_version.rc b/res/graphqlpeg_version.rc index f4f730cd..8de47acc 100644 --- a/res/graphqlpeg_version.rc +++ b/res/graphqlpeg_version.rc @@ -3,8 +3,8 @@ #include -#define GRAPHQL_RC_VERSION 3,6,0,0 -#define GRAPHQL_RC_VERSION_STR "3.6.0" +#define GRAPHQL_RC_VERSION 4,0,0,0 +#define GRAPHQL_RC_VERSION_STR "4.0.0" #ifndef DEBUG #define VER_DEBUG 0 diff --git a/res/graphqlresponse_version.rc b/res/graphqlresponse_version.rc index f7bf80e6..d2dd6df0 100644 --- a/res/graphqlresponse_version.rc +++ b/res/graphqlresponse_version.rc @@ -3,8 +3,8 @@ #include -#define GRAPHQL_RC_VERSION 3,6,0,0 -#define GRAPHQL_RC_VERSION_STR "3.6.0" +#define GRAPHQL_RC_VERSION 4,0,0,0 +#define GRAPHQL_RC_VERSION_STR "4.0.0" #ifndef DEBUG #define VER_DEBUG 0 diff --git a/res/graphqlservice_version.rc b/res/graphqlservice_version.rc index 462e91ae..da4609f0 100644 --- a/res/graphqlservice_version.rc +++ b/res/graphqlservice_version.rc @@ -3,8 +3,8 @@ #include -#define GRAPHQL_RC_VERSION 3,6,0,0 -#define GRAPHQL_RC_VERSION_STR "3.6.0" +#define GRAPHQL_RC_VERSION 4,0,0,0 +#define GRAPHQL_RC_VERSION_STR "4.0.0" #ifndef DEBUG #define VER_DEBUG 0 diff --git a/samples/client/BenchmarkClient.h b/samples/client/BenchmarkClient.h index 520eeead..5130226c 100644 --- a/samples/client/BenchmarkClient.h +++ b/samples/client/BenchmarkClient.h @@ -14,9 +14,9 @@ #include "graphqlservice/internal/Version.h" -// Check if the library version is compatible with clientgen 3.6.0 -static_assert(graphql::internal::MajorVersion == 3, "regenerate with clientgen: major version mismatch"); -static_assert(graphql::internal::MinorVersion == 6, "regenerate with clientgen: minor version mismatch"); +// Check if the library version is compatible with clientgen 4.0.0 +static_assert(graphql::internal::MajorVersion == 4, "regenerate with clientgen: major version mismatch"); +static_assert(graphql::internal::MinorVersion == 0, "regenerate with clientgen: minor version mismatch"); #include #include diff --git a/samples/client/MutateClient.h b/samples/client/MutateClient.h index 046a90d7..9d250fb0 100644 --- a/samples/client/MutateClient.h +++ b/samples/client/MutateClient.h @@ -14,9 +14,9 @@ #include "graphqlservice/internal/Version.h" -// Check if the library version is compatible with clientgen 3.6.0 -static_assert(graphql::internal::MajorVersion == 3, "regenerate with clientgen: major version mismatch"); -static_assert(graphql::internal::MinorVersion == 6, "regenerate with clientgen: minor version mismatch"); +// Check if the library version is compatible with clientgen 4.0.0 +static_assert(graphql::internal::MajorVersion == 4, "regenerate with clientgen: major version mismatch"); +static_assert(graphql::internal::MinorVersion == 0, "regenerate with clientgen: minor version mismatch"); #include #include diff --git a/samples/client/QueryClient.h b/samples/client/QueryClient.h index d7b58d7a..78d9fa45 100644 --- a/samples/client/QueryClient.h +++ b/samples/client/QueryClient.h @@ -14,9 +14,9 @@ #include "graphqlservice/internal/Version.h" -// Check if the library version is compatible with clientgen 3.6.0 -static_assert(graphql::internal::MajorVersion == 3, "regenerate with clientgen: major version mismatch"); -static_assert(graphql::internal::MinorVersion == 6, "regenerate with clientgen: minor version mismatch"); +// Check if the library version is compatible with clientgen 4.0.0 +static_assert(graphql::internal::MajorVersion == 4, "regenerate with clientgen: major version mismatch"); +static_assert(graphql::internal::MinorVersion == 0, "regenerate with clientgen: minor version mismatch"); #include #include diff --git a/samples/client/SubscribeClient.h b/samples/client/SubscribeClient.h index 11dc1575..7ddeb0e9 100644 --- a/samples/client/SubscribeClient.h +++ b/samples/client/SubscribeClient.h @@ -14,9 +14,9 @@ #include "graphqlservice/internal/Version.h" -// Check if the library version is compatible with clientgen 3.6.0 -static_assert(graphql::internal::MajorVersion == 3, "regenerate with clientgen: major version mismatch"); -static_assert(graphql::internal::MinorVersion == 6, "regenerate with clientgen: minor version mismatch"); +// Check if the library version is compatible with clientgen 4.0.0 +static_assert(graphql::internal::MajorVersion == 4, "regenerate with clientgen: major version mismatch"); +static_assert(graphql::internal::MinorVersion == 0, "regenerate with clientgen: minor version mismatch"); #include #include diff --git a/samples/separate/TodaySchema.h b/samples/separate/TodaySchema.h index a85a43c7..69514331 100644 --- a/samples/separate/TodaySchema.h +++ b/samples/separate/TodaySchema.h @@ -10,9 +10,9 @@ #include "graphqlservice/internal/Schema.h" -// Check if the library version is compatible with schemagen 3.6.0 -static_assert(graphql::internal::MajorVersion == 3, "regenerate with schemagen: major version mismatch"); -static_assert(graphql::internal::MinorVersion == 6, "regenerate with schemagen: minor version mismatch"); +// Check if the library version is compatible with schemagen 4.0.0 +static_assert(graphql::internal::MajorVersion == 4, "regenerate with schemagen: major version mismatch"); +static_assert(graphql::internal::MinorVersion == 0, "regenerate with schemagen: minor version mismatch"); #include #include diff --git a/samples/separate_nointrospection/TodaySchema.h b/samples/separate_nointrospection/TodaySchema.h index a85a43c7..69514331 100644 --- a/samples/separate_nointrospection/TodaySchema.h +++ b/samples/separate_nointrospection/TodaySchema.h @@ -10,9 +10,9 @@ #include "graphqlservice/internal/Schema.h" -// Check if the library version is compatible with schemagen 3.6.0 -static_assert(graphql::internal::MajorVersion == 3, "regenerate with schemagen: major version mismatch"); -static_assert(graphql::internal::MinorVersion == 6, "regenerate with schemagen: minor version mismatch"); +// Check if the library version is compatible with schemagen 4.0.0 +static_assert(graphql::internal::MajorVersion == 4, "regenerate with schemagen: major version mismatch"); +static_assert(graphql::internal::MinorVersion == 0, "regenerate with schemagen: minor version mismatch"); #include #include diff --git a/samples/unified/TodaySchema.h b/samples/unified/TodaySchema.h index 8eac4e5f..9ee34f37 100644 --- a/samples/unified/TodaySchema.h +++ b/samples/unified/TodaySchema.h @@ -10,9 +10,9 @@ #include "graphqlservice/internal/Schema.h" -// Check if the library version is compatible with schemagen 3.6.0 -static_assert(graphql::internal::MajorVersion == 3, "regenerate with schemagen: major version mismatch"); -static_assert(graphql::internal::MinorVersion == 6, "regenerate with schemagen: minor version mismatch"); +// Check if the library version is compatible with schemagen 4.0.0 +static_assert(graphql::internal::MajorVersion == 4, "regenerate with schemagen: major version mismatch"); +static_assert(graphql::internal::MinorVersion == 0, "regenerate with schemagen: minor version mismatch"); #include #include diff --git a/samples/unified_nointrospection/TodaySchema.h b/samples/unified_nointrospection/TodaySchema.h index cd45ef6e..8210c768 100644 --- a/samples/unified_nointrospection/TodaySchema.h +++ b/samples/unified_nointrospection/TodaySchema.h @@ -10,9 +10,9 @@ #include "graphqlservice/internal/Schema.h" -// Check if the library version is compatible with schemagen 3.6.0 -static_assert(graphql::internal::MajorVersion == 3, "regenerate with schemagen: major version mismatch"); -static_assert(graphql::internal::MinorVersion == 6, "regenerate with schemagen: minor version mismatch"); +// Check if the library version is compatible with schemagen 4.0.0 +static_assert(graphql::internal::MajorVersion == 4, "regenerate with schemagen: major version mismatch"); +static_assert(graphql::internal::MinorVersion == 0, "regenerate with schemagen: minor version mismatch"); #include #include diff --git a/samples/validation/ValidationSchema.h b/samples/validation/ValidationSchema.h index 66b73292..24565a6e 100644 --- a/samples/validation/ValidationSchema.h +++ b/samples/validation/ValidationSchema.h @@ -10,9 +10,9 @@ #include "graphqlservice/internal/Schema.h" -// Check if the library version is compatible with schemagen 3.6.0 -static_assert(graphql::internal::MajorVersion == 3, "regenerate with schemagen: major version mismatch"); -static_assert(graphql::internal::MinorVersion == 6, "regenerate with schemagen: minor version mismatch"); +// Check if the library version is compatible with schemagen 4.0.0 +static_assert(graphql::internal::MajorVersion == 4, "regenerate with schemagen: major version mismatch"); +static_assert(graphql::internal::MinorVersion == 0, "regenerate with schemagen: minor version mismatch"); #include #include From 4aa162cfedd45815ca9b114761a2c1b7e5115a99 Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Fri, 29 Oct 2021 17:47:27 -0700 Subject: [PATCH 004/119] Pick up new version in new sample --- samples/learn/StarWarsSchema.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/samples/learn/StarWarsSchema.h b/samples/learn/StarWarsSchema.h index 1bc92081..09520c4a 100644 --- a/samples/learn/StarWarsSchema.h +++ b/samples/learn/StarWarsSchema.h @@ -10,9 +10,9 @@ #include "graphqlservice/internal/Schema.h" -// Check if the library version is compatible with schemagen 3.6.0 -static_assert(graphql::internal::MajorVersion == 3, "regenerate with schemagen: major version mismatch"); -static_assert(graphql::internal::MinorVersion == 6, "regenerate with schemagen: minor version mismatch"); +// Check if the library version is compatible with schemagen 4.0.0 +static_assert(graphql::internal::MajorVersion == 4, "regenerate with schemagen: major version mismatch"); +static_assert(graphql::internal::MinorVersion == 0, "regenerate with schemagen: minor version mismatch"); #include #include From 8c872b849a1980c11fa278791508a6a3923779a4 Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Mon, 1 Nov 2021 08:57:24 -0700 Subject: [PATCH 005/119] Remove deprecated methods --- include/graphqlservice/GraphQLResponse.h | 21 --- include/graphqlservice/GraphQLService.h | 28 ---- src/GraphQLService.cpp | 160 ----------------------- 3 files changed, 209 deletions(-) diff --git a/include/graphqlservice/GraphQLResponse.h b/include/graphqlservice/GraphQLResponse.h index c9cf580f..11edc093 100644 --- a/include/graphqlservice/GraphQLResponse.h +++ b/include/graphqlservice/GraphQLResponse.h @@ -175,27 +175,6 @@ struct Value template typename ValueTypeTraits::release_type release(); - // Compatibility wrappers - template - [[deprecated("Use the unqualified Value::set<> specialization instead of specializing on the " - "r-value reference.")]] void - set(typename std::enable_if_t, ReferenceType> value) - { - set>(std::move(value)); - } - - template - [[deprecated("Use the unqualified Value::get<> specialization instead of specializing on the " - "const reference.")]] - typename std::enable_if_t< - std::is_lvalue_reference_v< - ReferenceType> && std::is_const_v>, - ReferenceType> - get() const - { - return get>(); - } - private: // Type::Map struct MapData diff --git a/include/graphqlservice/GraphQLService.h b/include/graphqlservice/GraphQLService.h index 285686e1..56e43439 100644 --- a/include/graphqlservice/GraphQLService.h +++ b/include/graphqlservice/GraphQLService.h @@ -178,12 +178,6 @@ struct FieldParams : SelectionSetParams GRAPHQLSERVICE_EXPORT explicit FieldParams( SelectionSetParams&& selectionSetParams, response::Value&& directives); - [[deprecated( - "Use the FieldParams constructor overload which takes a SelectionSet r-value " - "reference instead.")]] GRAPHQLSERVICE_EXPORT explicit FieldParams(const SelectionSetParams& - selectionSetParams, - response::Value&& directives); - // Each field owns its own field-specific directives. Once the accessor returns it will be // destroyed, but you can move it into another instance of response::Value to keep it alive // longer. @@ -936,29 +930,7 @@ class Request : public std::enable_shared_from_this const SubscriptionFilterCallback& applyDirectives, const std::shared_ptr& subscriptionObject) const; - [[deprecated( - "Use the Request::findOperationDefinition overload which takes a peg::ast reference and " - "string_view instead.")]] GRAPHQLSERVICE_EXPORT std::pair - findOperationDefinition(const peg::ast_node& root, const std::string& operationName) const; - - [[deprecated("Use the Request::resolve overload which takes a peg::ast reference " - "instead.")]] GRAPHQLSERVICE_EXPORT std::future - resolve(const std::shared_ptr& state, const peg::ast_node& root, - const std::string& operationName, response::Value&& variables) const; - [[deprecated("Use the Request::resolve overload which takes a peg::ast reference " - "instead.")]] GRAPHQLSERVICE_EXPORT std::future - resolve(std::launch launch, const std::shared_ptr& state, - const peg::ast_node& root, const std::string& operationName, - response::Value&& variables) const; - private: - std::pair findUnvalidatedOperationDefinition( - const peg::ast_node& root, const std::string& operationName) const; - - std::future resolveUnvalidated(std::launch launch, - const std::shared_ptr& state, const peg::ast_node& root, - const std::string& operationName, response::Value&& variables) const; - const TypeMap _operations; std::unique_ptr _validation; internal::sorted_map> _subscriptions; diff --git a/src/GraphQLService.cpp b/src/GraphQLService.cpp index e1c409a6..5fd59095 100644 --- a/src/GraphQLService.cpp +++ b/src/GraphQLService.cpp @@ -170,12 +170,6 @@ FieldParams::FieldParams(SelectionSetParams&& selectionSetParams, response::Valu { } -FieldParams::FieldParams(const SelectionSetParams& selectionSetParams, response::Value&& directives) - : SelectionSetParams(selectionSetParams) - , fieldDirectives(std::move(directives)) -{ -} - // ValueVisitor visits the AST and builds a response::Value representation of any value // hardcoded or referencing a variable in an operation. class ValueVisitor @@ -1775,160 +1769,6 @@ std::future Request::resolve(std::launch launch, } } -std::pair Request::findOperationDefinition( - const peg::ast_node& root, const std::string& operationName) const -{ - return findUnvalidatedOperationDefinition(root, operationName); -} - -std::pair Request::findUnvalidatedOperationDefinition( - const peg::ast_node& root, const std::string& operationName) const -{ - std::pair result = { {}, nullptr }; - - peg::on_first_child_if(root, - [&operationName, &result](const peg::ast_node& operationDefinition) { - auto operationType = strQuery; - - peg::on_first_child(operationDefinition, - [&operationType](const peg::ast_node& child) { - operationType = child.string_view(); - }); - - std::string_view name; - - peg::on_first_child(operationDefinition, - [&name](const peg::ast_node& child) { - name = child.string_view(); - }); - - if (operationName.empty() || name == operationName) - { - result = { std::string { operationType }, &operationDefinition }; - return true; - } - - return false; - }); - - return result; -} - -std::future Request::resolve(const std::shared_ptr& state, - const peg::ast_node& root, const std::string& operationName, response::Value&& variables) const -{ - return resolveUnvalidated(std::launch::deferred, - state, - root, - operationName, - std::move(variables)); -} - -std::future Request::resolve(std::launch launch, - const std::shared_ptr& state, const peg::ast_node& root, - const std::string& operationName, response::Value&& variables) const -{ - return resolveUnvalidated(launch, state, root, operationName, std::move(variables)); -} - -std::future Request::resolveUnvalidated(std::launch launch, - const std::shared_ptr& state, const peg::ast_node& root, - const std::string& operationName, response::Value&& variables) const -{ - try - { - FragmentDefinitionVisitor fragmentVisitor(variables); - - peg::for_each_child(root, - [&fragmentVisitor](const peg::ast_node& child) { - fragmentVisitor.visit(child); - }); - - auto fragments = fragmentVisitor.getFragments(); - auto operationDefinition = findUnvalidatedOperationDefinition(root, operationName); - - if (!operationDefinition.second) - { - std::ostringstream message; - - message << "Missing operation"; - - if (!operationName.empty()) - { - message << " name: " << operationName; - } - - throw schema_exception { { message.str() } }; - } - else if (operationDefinition.first == strSubscription) - { - auto position = operationDefinition.second->begin(); - std::ostringstream message; - - message << "Unexpected subscription"; - - if (!operationName.empty()) - { - message << " name: " << operationName; - } - - throw schema_exception { - { schema_error { message.str(), { position.line, position.column } } } - }; - } - - const bool isMutation = (operationDefinition.first == strMutation); - - // http://spec.graphql.org/June2018/#sec-Normal-and-Serial-Execution - if (isMutation) - { - // Force mutations to perform serial execution - launch = std::launch::deferred; - } - - const auto resolverContext = - isMutation ? ResolverContext::Mutation : ResolverContext::Query; - - OperationDefinitionVisitor operationVisitor(resolverContext, - launch, - state, - _operations, - std::move(variables), - std::move(fragments)); - - operationVisitor.visit(operationDefinition.first, *operationDefinition.second); - - return std::async( - launch, - [](std::future&& operationFuture) { - auto result = operationFuture.get(); - response::Value document { response::Type::Map }; - - document.emplace_back(std::string { strData }, std::move(result.data)); - - if (!result.errors.empty()) - { - document.emplace_back(std::string { strErrors }, - buildErrorValues(std::move(result.errors))); - } - - return document; - }, - operationVisitor.getValue()); - } - catch (schema_exception& ex) - { - std::promise promise; - response::Value document(response::Type::Map); - - document.emplace_back(std::string { strData }, response::Value()); - document.emplace_back(std::string { strErrors }, ex.getErrors()); - promise.set_value(std::move(document)); - - return promise.get_future(); - } -} - SubscriptionKey Request::subscribe(SubscriptionParams&& params, SubscriptionCallback&& callback) { auto errors = validate(params.query); From 0217ee8bc90304e0add2671fa6b9dfef82de9612 Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Mon, 1 Nov 2021 09:45:46 -0700 Subject: [PATCH 006/119] Fix double std::move(variables) in tests --- test/ClientTests.cpp | 2 +- test/TodayTests.cpp | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/test/ClientTests.cpp b/test/ClientTests.cpp index eacbae0f..368b2373 100644 --- a/test/ClientTests.cpp +++ b/test/ClientTests.cpp @@ -241,7 +241,7 @@ TEST_F(ClientCase, SubscribeNextAppointmentChangeDefault) auto key = _service->subscribe(service::SubscriptionParams { state, std::move(query), "TestSubscription", - std::move(std::move(variables)) }, + std::move(variables) }, [&result](std::future response) { result = response.get(); }); diff --git a/test/TodayTests.cpp b/test/TodayTests.cpp index 246f9579..9e629850 100644 --- a/test/TodayTests.cpp +++ b/test/TodayTests.cpp @@ -610,7 +610,7 @@ TEST_F(TodayServiceCase, SubscribeNextAppointmentChangeDefault) auto key = _service->subscribe(service::SubscriptionParams { state, std::move(query), "TestSubscription", - std::move(std::move(variables)) }, + std::move(variables) }, [&result](std::future response) { result = response.get(); }); @@ -670,7 +670,7 @@ TEST_F(TodayServiceCase, SubscribeNextAppointmentChangeOverride) auto key = _service->subscribe(service::SubscriptionParams { state, std::move(query), "TestSubscription", - std::move(std::move(variables)) }, + std::move(variables) }, [&result](std::future response) { result = response.get(); }); @@ -1203,7 +1203,7 @@ TEST_F(TodayServiceCase, SubscribeNodeChangeMatchingId) auto key = _service->subscribe(service::SubscriptionParams { state, std::move(query), "TestSubscription", - std::move(std::move(variables)) }, + std::move(variables) }, [&result](std::future response) { result = response.get(); }); @@ -1259,7 +1259,7 @@ TEST_F(TodayServiceCase, SubscribeNodeChangeMismatchedId) auto key = _service->subscribe(service::SubscriptionParams { nullptr, std::move(query), "TestSubscription", - std::move(std::move(variables)) }, + std::move(variables) }, [&calledGet](std::future) { calledGet = true; }); @@ -1316,7 +1316,7 @@ TEST_F(TodayServiceCase, SubscribeNodeChangeFuzzyComparator) auto key = _service->subscribe(service::SubscriptionParams { state, std::move(query), "TestSubscription", - std::move(std::move(variables)) }, + std::move(variables) }, [&result](std::future response) { result = response.get(); }); @@ -1382,7 +1382,7 @@ TEST_F(TodayServiceCase, SubscribeNodeChangeFuzzyMismatch) auto key = _service->subscribe(service::SubscriptionParams { nullptr, std::move(query), "TestSubscription", - std::move(std::move(variables)) }, + std::move(variables) }, [&calledGet](std::future) { calledGet = true; }); @@ -1430,7 +1430,7 @@ TEST_F(TodayServiceCase, SubscribeNodeChangeMatchingVariable) auto key = _service->subscribe(service::SubscriptionParams { state, std::move(query), "TestSubscription", - std::move(std::move(variables)) }, + std::move(variables) }, [&result](std::future response) { result = response.get(); }); @@ -1636,7 +1636,7 @@ TEST_F(TodayServiceCase, SubscribeNextAppointmentChangeAsync) auto key = _service->subscribe(service::SubscriptionParams { state, std::move(query), "TestSubscription", - std::move(std::move(variables)) }, + std::move(variables) }, [&result](std::future response) { result = response.get(); }); @@ -1837,7 +1837,7 @@ TEST_F(TodayServiceCase, SubscribeUnsubscribeNotificationsAsync) service::SubscriptionParams { state, std::move(query), "TestSubscription", - std::move(std::move(variables)) }, + std::move(variables) }, [&calledCallback](std::future response) { calledCallback = true; }); @@ -1887,7 +1887,7 @@ TEST_F(TodayServiceCase, SubscribeUnsubscribeNotificationsDeferred) service::SubscriptionParams { state, std::move(query), "TestSubscription", - std::move(std::move(variables)) }, + std::move(variables) }, [&calledCallback](std::future response) { calledCallback = true; }); From 1745a66156a0643b64cd781ac560116861a3908a Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Mon, 1 Nov 2021 17:13:32 -0700 Subject: [PATCH 007/119] Make FieldResult awaitable for coroutine support --- include/graphqlservice/GraphQLService.h | 66 +++++++++++++++++++++++-- samples/today/TodayMock.cpp | 13 ++--- 2 files changed, 66 insertions(+), 13 deletions(-) diff --git a/include/graphqlservice/GraphQLService.h b/include/graphqlservice/GraphQLService.h index 56e43439..8d353a77 100644 --- a/include/graphqlservice/GraphQLService.h +++ b/include/graphqlservice/GraphQLService.h @@ -24,6 +24,8 @@ #include "graphqlservice/internal/SortedMap.h" #include "graphqlservice/internal/Version.h" +#include +#include #include #include #include @@ -35,8 +37,8 @@ #include #include #include -#include #include +#include #include #include @@ -197,9 +199,14 @@ class FieldResult { } + bool is_future() const noexcept + { + return std::holds_alternative>(_value); + } + T get() { - if (std::holds_alternative>(_value)) + if (is_future()) { return std::get>(std::move(_value)).get(); } @@ -207,9 +214,60 @@ class FieldResult return std::get(std::move(_value)); } - bool is_future() const noexcept + struct promise_type { - return std::holds_alternative>(_value); + FieldResult get_return_object() noexcept + { + return { _promise.get_future() }; + } + + std::suspend_always initial_suspend() const noexcept + { + return {}; + } + + std::suspend_never final_suspend() const noexcept + { + return {}; + } + + void return_value(const T& value) noexcept(std::is_nothrow_copy_constructible_v) + { + _promise.set_value(value); + } + + void return_value(T&& value) noexcept(std::is_nothrow_move_constructible_v) + { + _promise.set_value(std::move(value)); + } + + void unhandled_exception() noexcept + { + _promise.set_exception(std::current_exception()); + } + + private: + std::promise _promise; + }; + + bool await_ready() const noexcept + { + using namespace std::literals; + + return (std::get>(_value).wait_for(0s) != std::future_status::timeout); + } + + void await_suspend(std::coroutine_handle<> h) const + { + std::thread([this, h] { + std::get>(_value).wait(); + h.resume(); + }).detach(); + } + + T await_resume() + { + return std::get>(_value).get(); } private: diff --git a/samples/today/TodayMock.cpp b/samples/today/TodayMock.cpp index 6bb29dc2..e903e221 100644 --- a/samples/today/TodayMock.cpp +++ b/samples/today/TodayMock.cpp @@ -141,33 +141,28 @@ std::shared_ptr Query::findUnreadCount( service::FieldResult> Query::getNode( service::FieldParams&& params, response::IdType&& id) const { - std::promise> promise; auto appointment = findAppointment(params, id); if (appointment) { - promise.set_value(appointment); - return promise.get_future(); + co_return appointment; } auto task = findTask(params, id); if (task) { - promise.set_value(task); - return promise.get_future(); + co_return task; } auto folder = findUnreadCount(params, id); if (folder) { - promise.set_value(folder); - return promise.get_future(); + co_return folder; } - promise.set_value(nullptr); - return promise.get_future(); + co_return nullptr; } template From 4bfb1d8fb7e09018dcb32e6e1e8ab0951d6fffd6 Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Mon, 1 Nov 2021 20:58:37 -0700 Subject: [PATCH 008/119] Fallback to std::experimental for coroutines --- cmake/test_coroutine.cpp.in | 59 +++++++++++++++++++++++++ include/graphqlservice/GraphQLService.h | 25 ++++++++--- samples/today/TodayMock.cpp | 24 ++++++++++ src/CMakeLists.txt | 27 ++++++++++- 4 files changed, 129 insertions(+), 6 deletions(-) create mode 100644 cmake/test_coroutine.cpp.in diff --git a/cmake/test_coroutine.cpp.in b/cmake/test_coroutine.cpp.in new file mode 100644 index 00000000..9ea6c5ac --- /dev/null +++ b/cmake/test_coroutine.cpp.in @@ -0,0 +1,59 @@ +// This is a dummy program that just needs to compile and link to tell us if +// the C++20 coroutine API is available. Use CMake's configure_file command +// to replace the COROUTINE_HEADER and COROUTINE_NAMESPACE tokens for each +// combination of headers and namespaces which we want to pass to the CMake +// try_compile command. + +#include <@COROUTINE_HEADER@> +#include + +struct task +{ + struct promise_type + { + task get_return_object() noexcept + { + return {}; + } + + @COROUTINE_NAMESPACE@::suspend_never initial_suspend() noexcept + { + return {}; + } + + @COROUTINE_NAMESPACE@::suspend_never final_suspend() noexcept + { + return {}; + } + + void return_void() noexcept + { + promise.set_value(); + } + + void unhandled_exception() + { + promise.set_exception(std::current_exception()); + } + + std::promise promise; + }; + + constexpr bool await_ready() const noexcept + { + return true; + } + + std::future future; +}; + +task test_co_return() +{ + co_return; +} + +int main() +{ + test_co_return().future.get(); + return 0; +} \ No newline at end of file diff --git a/include/graphqlservice/GraphQLService.h b/include/graphqlservice/GraphQLService.h index 8d353a77..a8ebba6e 100644 --- a/include/graphqlservice/GraphQLService.h +++ b/include/graphqlservice/GraphQLService.h @@ -24,8 +24,21 @@ #include "graphqlservice/internal/SortedMap.h" #include "graphqlservice/internal/Version.h" +// clang-format off +#ifdef USE_STD_COROUTINE + #include + namespace coro = std; +#else // !USE_STD_COROUTINE + #ifdef USE_STD_EXPERIMENTAL_COROUTINE + #include + namespace coro = std::experimental; + #else // !USE_STD_EXPERIMENTAL_COROUTINE + #define GRAPHQLSERVICE_NO_COROUTINE + #endif +#endif +// clang-format on + #include -#include #include #include #include @@ -214,6 +227,7 @@ class FieldResult return std::get(std::move(_value)); } +#ifndef GRAPHQLSERVICE_NO_COROUTINE struct promise_type { FieldResult get_return_object() noexcept @@ -221,12 +235,12 @@ class FieldResult return { _promise.get_future() }; } - std::suspend_always initial_suspend() const noexcept + coro::suspend_always initial_suspend() const noexcept { return {}; } - std::suspend_never final_suspend() const noexcept + coro::suspend_never final_suspend() const noexcept { return {}; } @@ -257,9 +271,9 @@ class FieldResult return (std::get>(_value).wait_for(0s) != std::future_status::timeout); } - void await_suspend(std::coroutine_handle<> h) const + void await_suspend(coro::coroutine_handle<> h) const { - std::thread([this, h] { + std::thread([this, h]() mutable { std::get>(_value).wait(); h.resume(); }).detach(); @@ -269,6 +283,7 @@ class FieldResult { return std::get>(_value).get(); } +#endif // !GRAPHQLSERVICE_NO_COROUTINE private: std::variant> _value; diff --git a/samples/today/TodayMock.cpp b/samples/today/TodayMock.cpp index e903e221..39c6883b 100644 --- a/samples/today/TodayMock.cpp +++ b/samples/today/TodayMock.cpp @@ -145,24 +145,48 @@ service::FieldResult> Query::getNode( if (appointment) { +#ifdef GRAPHQLSERVICE_NO_COROUTINE + std::promise> promise; + promise.set_value(appointment); + return promise.get_future(); +#else // !GRAPHQLSERVICE_NO_COROUTINE co_return appointment; +#endif } auto task = findTask(params, id); if (task) { +#ifdef GRAPHQLSERVICE_NO_COROUTINE + std::promise> promise; + promise.set_value(task); + return promise.get_future(); +#else // !GRAPHQLSERVICE_NO_COROUTINE co_return task; +#endif } auto folder = findUnreadCount(params, id); if (folder) { +#ifdef GRAPHQLSERVICE_NO_COROUTINE + std::promise> promise; + promise.set_value(folder); + return promise.get_future(); +#else // !GRAPHQLSERVICE_NO_COROUTINE co_return folder; +#endif } +#ifdef GRAPHQLSERVICE_NO_COROUTINE + std::promise> promise; + promise.set_value(nullptr); + return promise.get_future(); +#else // !GRAPHQLSERVICE_NO_COROUTINE co_return nullptr; +#endif } template diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 855a3cb8..da8c6ef3 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -106,7 +106,6 @@ if(WIN32 AND BUILD_SHARED_LIBS) add_version_rc(graphqlresponse) endif() - # Common schemagen and clientgen dependencies if(GRAPHQL_BUILD_SCHEMAGEN OR GRAPHQL_BUILD_CLIENTGEN) add_library(generator_util STATIC @@ -309,6 +308,32 @@ target_link_libraries(graphqlservice PUBLIC graphqlresponse Threads::Threads) +function(check_coroutine_impl COROUTINE_HEADER COROUTINE_NAMESPACE OUT_RESULT) + set(TEST_FILE "test_${OUT_RESULT}.cpp") + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/../cmake/test_coroutine.cpp.in ${TEST_FILE} @ONLY) + + try_compile(TEST_RESULT + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_BINARY_DIR}/${TEST_FILE} + CXX_STANDARD 20) + + set(${OUT_RESULT} ${TEST_RESULT} PARENT_SCOPE) +endfunction() + +check_coroutine_impl("coroutine" "std" STD_COROUTINE) +if(STD_COROUTINE) + message(STATUS "Using std coroutine") + target_compile_definitions(graphqlservice PUBLIC USE_STD_COROUTINE) +else() + check_coroutine_impl("experimental/coroutine" "std::experimental" STD_EXPERIMENTAL_COROUTINE) + if(STD_EXPERIMENTAL_COROUTINE) + message(STATUS "Using std::experimental coroutine") + target_compile_definitions(graphqlservice PUBLIC USE_STD_EXPERIMENTAL_COROUTINE) + else() + message(STATUS "Missing coroutine support") + endif() +endif() + if(GRAPHQL_UPDATE_SAMPLES) # Even though this target doesn't build IntrospectionSchema.cpp, it still # depends on IntrospectionSchema.h for some enum definitions. From 2a27aa5700b974890d74294d8132eb18e878152c Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Mon, 1 Nov 2021 21:18:43 -0700 Subject: [PATCH 009/119] Remove the fallback all the way to no coroutines --- include/graphqlservice/GraphQLService.h | 14 ++++---------- samples/today/TodayMock.cpp | 24 ------------------------ src/CMakeLists.txt | 25 +++++++++++++++++++++---- 3 files changed, 25 insertions(+), 38 deletions(-) diff --git a/include/graphqlservice/GraphQLService.h b/include/graphqlservice/GraphQLService.h index a8ebba6e..db3b53de 100644 --- a/include/graphqlservice/GraphQLService.h +++ b/include/graphqlservice/GraphQLService.h @@ -25,16 +25,12 @@ #include "graphqlservice/internal/Version.h" // clang-format off -#ifdef USE_STD_COROUTINE +#ifdef USE_STD_EXPERIMENTAL_COROUTINE + #include + namespace coro = std::experimental; +#else // !USE_STD_EXPERIMENTAL_COROUTINE #include namespace coro = std; -#else // !USE_STD_COROUTINE - #ifdef USE_STD_EXPERIMENTAL_COROUTINE - #include - namespace coro = std::experimental; - #else // !USE_STD_EXPERIMENTAL_COROUTINE - #define GRAPHQLSERVICE_NO_COROUTINE - #endif #endif // clang-format on @@ -227,7 +223,6 @@ class FieldResult return std::get(std::move(_value)); } -#ifndef GRAPHQLSERVICE_NO_COROUTINE struct promise_type { FieldResult get_return_object() noexcept @@ -283,7 +278,6 @@ class FieldResult { return std::get>(_value).get(); } -#endif // !GRAPHQLSERVICE_NO_COROUTINE private: std::variant> _value; diff --git a/samples/today/TodayMock.cpp b/samples/today/TodayMock.cpp index 39c6883b..e903e221 100644 --- a/samples/today/TodayMock.cpp +++ b/samples/today/TodayMock.cpp @@ -145,48 +145,24 @@ service::FieldResult> Query::getNode( if (appointment) { -#ifdef GRAPHQLSERVICE_NO_COROUTINE - std::promise> promise; - promise.set_value(appointment); - return promise.get_future(); -#else // !GRAPHQLSERVICE_NO_COROUTINE co_return appointment; -#endif } auto task = findTask(params, id); if (task) { -#ifdef GRAPHQLSERVICE_NO_COROUTINE - std::promise> promise; - promise.set_value(task); - return promise.get_future(); -#else // !GRAPHQLSERVICE_NO_COROUTINE co_return task; -#endif } auto folder = findUnreadCount(params, id); if (folder) { -#ifdef GRAPHQLSERVICE_NO_COROUTINE - std::promise> promise; - promise.set_value(folder); - return promise.get_future(); -#else // !GRAPHQLSERVICE_NO_COROUTINE co_return folder; -#endif } -#ifdef GRAPHQLSERVICE_NO_COROUTINE - std::promise> promise; - promise.set_value(nullptr); - return promise.get_future(); -#else // !GRAPHQLSERVICE_NO_COROUTINE co_return nullptr; -#endif } template diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index da8c6ef3..7e7a2eae 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -308,7 +308,7 @@ target_link_libraries(graphqlservice PUBLIC graphqlresponse Threads::Threads) -function(check_coroutine_impl COROUTINE_HEADER COROUTINE_NAMESPACE OUT_RESULT) +function(check_coroutine_impl COROUTINE_HEADER COROUTINE_NAMESPACE OPTIONAL_FLAGS OUT_RESULT) set(TEST_FILE "test_${OUT_RESULT}.cpp") configure_file(${CMAKE_CURRENT_SOURCE_DIR}/../cmake/test_coroutine.cpp.in ${TEST_FILE} @ONLY) @@ -317,20 +317,37 @@ function(check_coroutine_impl COROUTINE_HEADER COROUTINE_NAMESPACE OUT_RESULT) ${CMAKE_CURRENT_BINARY_DIR}/${TEST_FILE} CXX_STANDARD 20) + if(NOT TEST_RESULT) + # Retry with each of the optional libraries. + foreach(OPTIONAL_FLAG IN LISTS OPTIONAL_FLAGS) + try_compile(TEST_RESULT + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_BINARY_DIR}/${TEST_FILE} + CMAKE_FLAGS "-DCMAKE_CXX_FLAGS=${OPTIONAL_FLAG}" + CXX_STANDARD 20) + + if(TEST_RESULT) + # Looks like the optional flag was required, go ahead and add it to the compile options. + target_compile_options(graphqlservice PUBLIC ${OPTIONAL_FLAG}) + break() + endif() + endforeach(OPTIONAL_FLAG) + endif() + set(${OUT_RESULT} ${TEST_RESULT} PARENT_SCOPE) endfunction() -check_coroutine_impl("coroutine" "std" STD_COROUTINE) +check_coroutine_impl("coroutine" "std" "" STD_COROUTINE) if(STD_COROUTINE) message(STATUS "Using std coroutine") target_compile_definitions(graphqlservice PUBLIC USE_STD_COROUTINE) else() - check_coroutine_impl("experimental/coroutine" "std::experimental" STD_EXPERIMENTAL_COROUTINE) + check_coroutine_impl("experimental/coroutine" "std::experimental" "-fcoroutines" STD_EXPERIMENTAL_COROUTINE) if(STD_EXPERIMENTAL_COROUTINE) message(STATUS "Using std::experimental coroutine") target_compile_definitions(graphqlservice PUBLIC USE_STD_EXPERIMENTAL_COROUTINE) else() - message(STATUS "Missing coroutine support") + message(FATAL_ERROR "Missing coroutine support") endif() endif() From 9d1af8d491e77bc091756bf0b1fea5b6973fd209 Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Mon, 1 Nov 2021 21:51:09 -0700 Subject: [PATCH 010/119] Move coroutine options to graphqlpeg target --- src/CMakeLists.txt | 85 +++++++++++++++++++++++----------------------- 1 file changed, 42 insertions(+), 43 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7e7a2eae..8f7542ba 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -84,6 +84,48 @@ if(WIN32 AND BUILD_SHARED_LIBS) add_version_rc(graphqlpeg) endif() +function(check_coroutine_impl COROUTINE_HEADER COROUTINE_NAMESPACE OPTIONAL_FLAGS OUT_RESULT) + set(TEST_FILE "test_${OUT_RESULT}.cpp") + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/../cmake/test_coroutine.cpp.in ${TEST_FILE} @ONLY) + + try_compile(TEST_RESULT + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_BINARY_DIR}/${TEST_FILE} + CXX_STANDARD 20) + + if(NOT TEST_RESULT) + # Retry with each of the optional libraries. + foreach(OPTIONAL_FLAG IN LISTS OPTIONAL_FLAGS) + try_compile(TEST_RESULT + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_BINARY_DIR}/${TEST_FILE} + CMAKE_FLAGS "-DCOMPILE_DEFINITIONS:STRING=${OPTIONAL_FLAG}" + CXX_STANDARD 20) + + if(TEST_RESULT) + # Looks like the optional flag was required, go ahead and add it to the compile options. + target_compile_options(graphqlpeg PUBLIC ${OPTIONAL_FLAG}) + break() + endif() + endforeach(OPTIONAL_FLAG) + endif() + + set(${OUT_RESULT} ${TEST_RESULT} PARENT_SCOPE) +endfunction() + +check_coroutine_impl("coroutine" "std" "-fcoroutines" STD_COROUTINE) +if(STD_COROUTINE) + message(STATUS "Using std coroutine") +else() + check_coroutine_impl("experimental/coroutine" "std::experimental" "" STD_EXPERIMENTAL_COROUTINE) + if(STD_EXPERIMENTAL_COROUTINE) + message(STATUS "Using std::experimental coroutine") + target_compile_definitions(graphqlpeg PUBLIC USE_STD_EXPERIMENTAL_COROUTINE) + else() + message(FATAL_ERROR "Missing coroutine support") + endif() +endif() + # graphqlresponse add_library(graphqlresponse Base64.cpp @@ -308,49 +350,6 @@ target_link_libraries(graphqlservice PUBLIC graphqlresponse Threads::Threads) -function(check_coroutine_impl COROUTINE_HEADER COROUTINE_NAMESPACE OPTIONAL_FLAGS OUT_RESULT) - set(TEST_FILE "test_${OUT_RESULT}.cpp") - configure_file(${CMAKE_CURRENT_SOURCE_DIR}/../cmake/test_coroutine.cpp.in ${TEST_FILE} @ONLY) - - try_compile(TEST_RESULT - ${CMAKE_CURRENT_BINARY_DIR} - ${CMAKE_CURRENT_BINARY_DIR}/${TEST_FILE} - CXX_STANDARD 20) - - if(NOT TEST_RESULT) - # Retry with each of the optional libraries. - foreach(OPTIONAL_FLAG IN LISTS OPTIONAL_FLAGS) - try_compile(TEST_RESULT - ${CMAKE_CURRENT_BINARY_DIR} - ${CMAKE_CURRENT_BINARY_DIR}/${TEST_FILE} - CMAKE_FLAGS "-DCMAKE_CXX_FLAGS=${OPTIONAL_FLAG}" - CXX_STANDARD 20) - - if(TEST_RESULT) - # Looks like the optional flag was required, go ahead and add it to the compile options. - target_compile_options(graphqlservice PUBLIC ${OPTIONAL_FLAG}) - break() - endif() - endforeach(OPTIONAL_FLAG) - endif() - - set(${OUT_RESULT} ${TEST_RESULT} PARENT_SCOPE) -endfunction() - -check_coroutine_impl("coroutine" "std" "" STD_COROUTINE) -if(STD_COROUTINE) - message(STATUS "Using std coroutine") - target_compile_definitions(graphqlservice PUBLIC USE_STD_COROUTINE) -else() - check_coroutine_impl("experimental/coroutine" "std::experimental" "-fcoroutines" STD_EXPERIMENTAL_COROUTINE) - if(STD_EXPERIMENTAL_COROUTINE) - message(STATUS "Using std::experimental coroutine") - target_compile_definitions(graphqlservice PUBLIC USE_STD_EXPERIMENTAL_COROUTINE) - else() - message(FATAL_ERROR "Missing coroutine support") - endif() -endif() - if(GRAPHQL_UPDATE_SAMPLES) # Even though this target doesn't build IntrospectionSchema.cpp, it still # depends on IntrospectionSchema.h for some enum definitions. From b3146996e98b26940f6a6277c860ed653846195d Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Mon, 1 Nov 2021 21:51:37 -0700 Subject: [PATCH 011/119] Use GCC 10 on Linux for coroutines --- .github/workflows/linux.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 691b237d..a01ec8fa 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -3,7 +3,7 @@ name: Linux on: [push, pull_request] jobs: - gcc7: + gcc10: strategy: fail-fast: false matrix: @@ -19,7 +19,7 @@ jobs: - name: Install Dependencies run: | sudo apt-get update - sudo apt-get install -yq libgtest-dev libboost-program-options-dev rapidjson-dev ninja-build + sudo apt-get install -yq libgtest-dev libboost-program-options-dev rapidjson-dev ninja-build gcc-10 g++-10 - name: Build GTest run: | @@ -34,6 +34,9 @@ jobs: - name: Configure CMake shell: pwsh + env: + CC: gcc-10 + CXX: g++-10 working-directory: build/ run: | $cmakeBuildType = '${{ matrix.config }}' From f0e4a2d3b10ff8c63039ce9695caf4c728f071fa Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Tue, 2 Nov 2021 07:15:45 -0700 Subject: [PATCH 012/119] Put coroutine detection in interface lib --- src/CMakeLists.txt | 55 +++++++++++++++++++++++++--------------------- 1 file changed, 30 insertions(+), 25 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8f7542ba..6d93f0f2 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -61,28 +61,7 @@ function(add_bigobj_flag target) endif() endfunction() -# graphqlpeg -add_library(graphqlpeg SyntaxTree.cpp) -add_library(cppgraphqlgen::graphqlpeg ALIAS graphqlpeg) -target_link_libraries(graphqlpeg PUBLIC taocpp::pegtl) -target_compile_features(graphqlpeg PUBLIC cxx_std_20) -target_include_directories(graphqlpeg PUBLIC - $ - $ - $) -add_bigobj_flag(graphqlpeg) - -if(GRAPHQL_UPDATE_VERSION) - update_version_rc(graphqlpeg) -endif() - -if(WIN32 AND BUILD_SHARED_LIBS) - target_compile_definitions(graphqlpeg - PUBLIC GRAPHQL_DLLEXPORTS - PRIVATE IMPL_GRAPHQLPEG_DLL) - - add_version_rc(graphqlpeg) -endif() +add_library(graphqlcoro INTERFACE) function(check_coroutine_impl COROUTINE_HEADER COROUTINE_NAMESPACE OPTIONAL_FLAGS OUT_RESULT) set(TEST_FILE "test_${OUT_RESULT}.cpp") @@ -104,7 +83,7 @@ function(check_coroutine_impl COROUTINE_HEADER COROUTINE_NAMESPACE OPTIONAL_FLAG if(TEST_RESULT) # Looks like the optional flag was required, go ahead and add it to the compile options. - target_compile_options(graphqlpeg PUBLIC ${OPTIONAL_FLAG}) + target_compile_options(graphqlcoro INTERFACE ${OPTIONAL_FLAG}) break() endif() endforeach(OPTIONAL_FLAG) @@ -120,12 +99,35 @@ else() check_coroutine_impl("experimental/coroutine" "std::experimental" "" STD_EXPERIMENTAL_COROUTINE) if(STD_EXPERIMENTAL_COROUTINE) message(STATUS "Using std::experimental coroutine") - target_compile_definitions(graphqlpeg PUBLIC USE_STD_EXPERIMENTAL_COROUTINE) + target_compile_definitions(graphqlcoro INTERFACE USE_STD_EXPERIMENTAL_COROUTINE) else() message(FATAL_ERROR "Missing coroutine support") endif() endif() +# graphqlpeg +add_library(graphqlpeg SyntaxTree.cpp) +add_library(cppgraphqlgen::graphqlpeg ALIAS graphqlpeg) +target_link_libraries(graphqlpeg PUBLIC taocpp::pegtl) +target_compile_features(graphqlpeg PUBLIC cxx_std_20) +target_include_directories(graphqlpeg PUBLIC + $ + $ + $) +add_bigobj_flag(graphqlpeg) + +if(GRAPHQL_UPDATE_VERSION) + update_version_rc(graphqlpeg) +endif() + +if(WIN32 AND BUILD_SHARED_LIBS) + target_compile_definitions(graphqlpeg + PUBLIC GRAPHQL_DLLEXPORTS + PRIVATE IMPL_GRAPHQLPEG_DLL) + + add_version_rc(graphqlpeg) +endif() + # graphqlresponse add_library(graphqlresponse Base64.cpp @@ -156,7 +158,8 @@ if(GRAPHQL_BUILD_SCHEMAGEN OR GRAPHQL_BUILD_CLIENTGEN) GeneratorUtil.cpp) target_link_libraries(generator_util PUBLIC graphqlpeg - graphqlresponse) + graphqlresponse + graphqlcoro) endif() # clientgen @@ -348,6 +351,7 @@ target_compile_features(graphqlservice PUBLIC cxx_std_20) target_link_libraries(graphqlservice PUBLIC graphqlpeg graphqlresponse + graphqlcoro Threads::Threads) if(GRAPHQL_UPDATE_SAMPLES) @@ -449,6 +453,7 @@ install(TARGETS graphqlpeg graphqlresponse graphqlservice + graphqlcoro EXPORT cppgraphqlgen-targets RUNTIME DESTINATION bin ARCHIVE DESTINATION lib From 5468cc4025854b541e02607d19d7c4b29b2f4968 Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Tue, 2 Nov 2021 16:20:11 -0700 Subject: [PATCH 013/119] WIP coroutine support --- doc/resolvers.md | 4 +- doc/subscriptions.md | 2 +- include/graphqlservice/GraphQLResponse.h | 4 + include/graphqlservice/GraphQLService.h | 361 ++++++-------- .../graphqlservice/internal/AwaitableFuture.h | 198 ++++++++ .../introspection/IntrospectionSchema.h | 84 ++-- samples/learn/DroidObject.cpp | 12 +- samples/learn/DroidObject.h | 12 +- samples/learn/HumanObject.cpp | 12 +- samples/learn/HumanObject.h | 12 +- samples/learn/MutationObject.cpp | 4 +- samples/learn/MutationObject.h | 4 +- samples/learn/QueryObject.cpp | 12 +- samples/learn/QueryObject.h | 12 +- samples/learn/ReviewObject.cpp | 6 +- samples/learn/ReviewObject.h | 6 +- samples/learn/StarWarsSchema.cpp | 2 +- .../separate/AppointmentConnectionObject.cpp | 6 +- .../separate/AppointmentConnectionObject.h | 6 +- samples/separate/AppointmentEdgeObject.cpp | 6 +- samples/separate/AppointmentEdgeObject.h | 6 +- samples/separate/AppointmentObject.cpp | 12 +- samples/separate/AppointmentObject.h | 12 +- .../separate/CompleteTaskPayloadObject.cpp | 6 +- samples/separate/CompleteTaskPayloadObject.h | 6 +- samples/separate/ExpensiveObject.cpp | 4 +- samples/separate/ExpensiveObject.h | 4 +- samples/separate/FolderConnectionObject.cpp | 6 +- samples/separate/FolderConnectionObject.h | 6 +- samples/separate/FolderEdgeObject.cpp | 6 +- samples/separate/FolderEdgeObject.h | 6 +- samples/separate/FolderObject.cpp | 8 +- samples/separate/FolderObject.h | 8 +- samples/separate/MutationObject.cpp | 6 +- samples/separate/MutationObject.h | 6 +- samples/separate/NestedTypeObject.cpp | 6 +- samples/separate/NestedTypeObject.h | 6 +- samples/separate/PageInfoObject.cpp | 6 +- samples/separate/PageInfoObject.h | 6 +- samples/separate/QueryObject.cpp | 30 +- samples/separate/QueryObject.h | 32 +- samples/separate/SubscriptionObject.cpp | 6 +- samples/separate/SubscriptionObject.h | 6 +- samples/separate/TaskConnectionObject.cpp | 6 +- samples/separate/TaskConnectionObject.h | 6 +- samples/separate/TaskEdgeObject.cpp | 6 +- samples/separate/TaskEdgeObject.h | 6 +- samples/separate/TaskObject.cpp | 8 +- samples/separate/TaskObject.h | 8 +- samples/separate/TodaySchema.cpp | 2 +- .../AppointmentConnectionObject.cpp | 6 +- .../AppointmentConnectionObject.h | 6 +- .../AppointmentEdgeObject.cpp | 6 +- .../AppointmentEdgeObject.h | 6 +- .../AppointmentObject.cpp | 12 +- .../AppointmentObject.h | 12 +- .../CompleteTaskPayloadObject.cpp | 6 +- .../CompleteTaskPayloadObject.h | 6 +- .../ExpensiveObject.cpp | 4 +- .../ExpensiveObject.h | 4 +- .../FolderConnectionObject.cpp | 6 +- .../FolderConnectionObject.h | 6 +- .../FolderEdgeObject.cpp | 6 +- .../FolderEdgeObject.h | 6 +- .../separate_nointrospection/FolderObject.cpp | 8 +- .../separate_nointrospection/FolderObject.h | 8 +- .../MutationObject.cpp | 6 +- .../separate_nointrospection/MutationObject.h | 6 +- .../NestedTypeObject.cpp | 6 +- .../NestedTypeObject.h | 6 +- .../PageInfoObject.cpp | 6 +- .../separate_nointrospection/PageInfoObject.h | 6 +- .../separate_nointrospection/QueryObject.cpp | 26 +- .../separate_nointrospection/QueryObject.h | 28 +- .../SubscriptionObject.cpp | 6 +- .../SubscriptionObject.h | 6 +- .../TaskConnectionObject.cpp | 6 +- .../TaskConnectionObject.h | 6 +- .../TaskEdgeObject.cpp | 6 +- .../separate_nointrospection/TaskEdgeObject.h | 6 +- .../separate_nointrospection/TaskObject.cpp | 8 +- samples/separate_nointrospection/TaskObject.h | 8 +- .../separate_nointrospection/TodaySchema.cpp | 2 +- samples/today/TodayMock.cpp | 43 ++ samples/today/TodayMock.h | 6 +- samples/unified/TodaySchema.cpp | 130 ++--- samples/unified/TodaySchema.h | 130 ++--- .../unified_nointrospection/TodaySchema.cpp | 126 ++--- samples/unified_nointrospection/TodaySchema.h | 126 ++--- samples/validation/ValidationSchema.cpp | 98 ++-- samples/validation/ValidationSchema.h | 100 ++-- src/CMakeLists.txt | 21 +- src/GraphQLService.cpp | 446 ++++++++---------- src/IntrospectionSchema.cpp | 80 ++-- src/SchemaGenerator.cpp | 20 +- test/ClientTests.cpp | 4 +- test/NoIntrospectionTests.cpp | 155 +++--- test/TodayTests.cpp | 115 +++-- 98 files changed, 1511 insertions(+), 1348 deletions(-) create mode 100644 include/graphqlservice/internal/AwaitableFuture.h diff --git a/doc/resolvers.md b/doc/resolvers.md index c43fe36d..b5cc4c68 100644 --- a/doc/resolvers.md +++ b/doc/resolvers.md @@ -34,7 +34,7 @@ schema { Executing a query or mutation starts by calling `Request::resolve` from [GraphQLService.h](../include/graphqlservice/GraphQLService.h): ```cpp -GRAPHQLSERVICE_EXPORT std::future resolve( +GRAPHQLSERVICE_EXPORT response::AwaitableValue resolve( const std::shared_ptr& state, peg::ast& query, const std::string& operationName, response::Value&& variables) const; ``` @@ -44,7 +44,7 @@ an override of `Request::resolve` which lets you substitute the `std::launch::async` option to begin executing the query on multiple threads in parallel: ```cpp -GRAPHQLSERVICE_EXPORT std::future resolve(std::launch launch, +GRAPHQLSERVICE_EXPORT response::AwaitableValue resolve(std::launch launch, const std::shared_ptr& state, peg::ast& query, const std::string& operationName, response::Value&& variables) const; ``` diff --git a/doc/subscriptions.md b/doc/subscriptions.md index 7dd3e9bb..21b9da36 100644 --- a/doc/subscriptions.md +++ b/doc/subscriptions.md @@ -39,7 +39,7 @@ The `SubscriptionCallback` signature is: ```cpp // Subscription callbacks receive the response::Value representing the result of evaluating the // SelectionSet against the payload. -using SubscriptionCallback = std::function)>; +using SubscriptionCallback = std::function; ``` ## `ResolverContext::NotifySubscribe` and `ResolverContext::NotifyUnsubscribe` diff --git a/include/graphqlservice/GraphQLResponse.h b/include/graphqlservice/GraphQLResponse.h index 11edc093..8dec58ab 100644 --- a/include/graphqlservice/GraphQLResponse.h +++ b/include/graphqlservice/GraphQLResponse.h @@ -18,6 +18,8 @@ #endif // !GRAPHQL_DLLEXPORTS // clang-format on +#include "graphqlservice/internal/AwaitableFuture.h" + #include #include #include @@ -259,6 +261,8 @@ template <> GRAPHQLRESPONSE_EXPORT IdType Value::release(); #endif // GRAPHQL_DLLEXPORTS +using AwaitableValue = internal::AwaitableFuture; + } // namespace graphql::response #endif // GRAPHQLRESPONSE_H diff --git a/include/graphqlservice/GraphQLService.h b/include/graphqlservice/GraphQLService.h index db3b53de..077f7b64 100644 --- a/include/graphqlservice/GraphQLService.h +++ b/include/graphqlservice/GraphQLService.h @@ -21,19 +21,10 @@ #include "graphqlservice/GraphQLParse.h" #include "graphqlservice/GraphQLResponse.h" +#include "graphqlservice/internal/AwaitableFuture.h" #include "graphqlservice/internal/SortedMap.h" #include "graphqlservice/internal/Version.h" -// clang-format off -#ifdef USE_STD_EXPERIMENTAL_COROUTINE - #include - namespace coro = std::experimental; -#else // !USE_STD_EXPERIMENTAL_COROUTINE - #include - namespace coro = std; -#endif -// clang-format on - #include #include #include @@ -195,9 +186,9 @@ struct FieldParams : SelectionSetParams response::Value fieldDirectives; }; -// Field accessors may return either a result of T or a std::future, so at runtime the -// implementer may choose to return by value or defer/parallelize expensive operations by returning -// an async future. +// Field accessors may return either a result of T, an awaitable of T, or a std::future, so at +// runtime the implementer may choose to return by value or defer/parallelize expensive operations +// by returning an async future or an awaitable coroutine. template class FieldResult { @@ -213,16 +204,6 @@ class FieldResult return std::holds_alternative>(_value); } - T get() - { - if (is_future()) - { - return std::get>(std::move(_value)).get(); - } - - return std::get(std::move(_value)); - } - struct promise_type { FieldResult get_return_object() noexcept @@ -230,7 +211,7 @@ class FieldResult return { _promise.get_future() }; } - coro::suspend_always initial_suspend() const noexcept + coro::suspend_never initial_suspend() const noexcept { return {}; } @@ -263,20 +244,25 @@ class FieldResult { using namespace std::literals; - return (std::get>(_value).wait_for(0s) != std::future_status::timeout); + return (!is_future() + || std::get>(_value).wait_for(0s) != std::future_status::timeout); } void await_suspend(coro::coroutine_handle<> h) const { - std::thread([this, h]() mutable { - std::get>(_value).wait(); - h.resume(); - }).detach(); + if (is_future()) + { + std::thread([this, h]() mutable { + std::get>(_value).wait(); + h.resume(); + }).detach(); + } } T await_resume() { - return std::get>(_value).get(); + return is_future() ? std::get>(_value).get() + : T { std::move(std::get(_value)) }; } private: @@ -339,7 +325,8 @@ struct ResolverResult std::list errors; }; -using Resolver = std::function(ResolverParams&&)>; +using AwaitableResolver = internal::AwaitableFuture; +using Resolver = std::function; using ResolverMap = internal::string_view_map; // GraphQL types are nullable by default, but they may be wrapped with non-null or list types. @@ -531,9 +518,9 @@ class Object : public std::enable_shared_from_this GRAPHQLSERVICE_EXPORT explicit Object(TypeNames&& typeNames, ResolverMap&& resolvers); GRAPHQLSERVICE_EXPORT virtual ~Object() = default; - GRAPHQLSERVICE_EXPORT std::future resolve( - const SelectionSetParams& selectionSetParams, const peg::ast_node& selection, - const FragmentMap& fragments, const response::Value& variables) const; + GRAPHQLSERVICE_EXPORT AwaitableResolver resolve(const SelectionSetParams& selectionSetParams, + const peg::ast_node& selection, const FragmentMap& fragments, + const response::Value& variables) const; GRAPHQLSERVICE_EXPORT bool matchesType(std::string_view typeName) const; @@ -586,35 +573,32 @@ struct ModifiedResult }; // Convert a single value of the specified type to JSON. - static std::future convert( + static AwaitableResolver convert( typename ResultTraits::future_type result, ResolverParams&& params); // Peel off the none modifier. If it's included, it should always be last in the list. template static typename std::enable_if_t && std::is_base_of_v, - std::future> + AwaitableResolver> convert(FieldResult::type>&& result, ResolverParams&& params) { // Call through to the Object specialization with a static_pointer_cast for subclasses of // Object. static_assert(std::is_same_v, typename ResultTraits::type>, "this is the derived object type"); - auto resultFuture = std::async( - std::launch::deferred, - [](auto&& objectType) { - return std::static_pointer_cast(objectType.get()); - }, - std::move(result)); - - return ModifiedResult::convert(std::move(resultFuture), std::move(params)); + auto awaitedResult = co_await ModifiedResult::convert( + std::static_pointer_cast(co_await result), + std::move(params)); + + co_return std::move(awaitedResult); } // Peel off the none modifier. If it's included, it should always be last in the list. template static typename std::enable_if_t || !std::is_base_of_v), - std::future> + AwaitableResolver> convert(typename ResultTraits::future_type result, ResolverParams&& params) { // Just call through to the partial specialization without the modifier. @@ -625,37 +609,28 @@ struct ModifiedResult template static typename std::enable_if_t, typename ResultTraits::type>, - std::future> + AwaitableResolver> convert(typename ResultTraits::future_type result, ResolverParams&& params) { - return std::async( - std::launch::deferred, - [](auto&& wrappedFuture, ResolverParams&& wrappedParams) { - auto wrappedResult = wrappedFuture.get(); - - if (!wrappedResult) - { - return ResolverResult {}; - } + auto awaitedResult = co_await result; - std::promise::type> promise; + if (!awaitedResult) + { + co_return ResolverResult {}; + } - promise.set_value(std::move(wrappedResult)); + auto modifiedResult = + co_await ModifiedResult::convert(std::move(awaitedResult), std::move(params)); - return ModifiedResult::convert(promise.get_future(), - std::move(wrappedParams)) - .get(); - }, - std::move(result), - std::move(params)); + co_return modifiedResult; } // Peel off nullable modifiers for anything else, which should all be std::optional. template static typename std::enable_if_t, typename ResultTraits::type>, - std::future> + AwaitableResolver> convert(typename ResultTraits::future_type result, ResolverParams&& params) { @@ -663,137 +638,76 @@ struct ModifiedResult typename ResultTraits::type>, "this is the optional version"); - return std::async( - std::launch::deferred, - [](auto&& wrappedFuture, ResolverParams&& wrappedParams) { - auto wrappedResult = wrappedFuture.get(); + auto awaitedResult = co_await result; - if (!wrappedResult) - { - return ResolverResult {}; - } - - std::promise::type> promise; - - promise.set_value(std::move(*wrappedResult)); + if (!awaitedResult) + { + co_return ResolverResult {}; + } - return ModifiedResult::convert(promise.get_future(), - std::move(wrappedParams)) - .get(); - }, - std::move(result), + auto modifiedResult = co_await ModifiedResult::convert(std::move(*awaitedResult), std::move(params)); + + co_return modifiedResult; } // Peel off list modifiers. template - static typename std::enable_if_t> - convert(typename ResultTraits::future_type result, + static typename std::enable_if_t convert( + typename ResultTraits::future_type result, ResolverParams&& params) { - return std::async( - params.launch, - [](auto&& wrappedFuture, ResolverParams&& wrappedParams) { - auto wrappedResult = wrappedFuture.get(); - std::vector> children; - const auto parentPath = wrappedParams.errorPath; - - children.reserve(wrappedResult.size()); - wrappedParams.errorPath = std::make_optional(field_path { - parentPath ? std::make_optional(std::cref(*parentPath)) : std::nullopt, - path_segment { size_t { 0 } } }); - - using vector_type = std::decay_t; - - if constexpr (!std::is_same_v, - typename vector_type::value_type>) - { - // Special handling for std::vector<> specializations which don't return a - // reference to the underlying type, i.e. std::vector on many platforms. - // Copy the values from the std::vector<> rather than moving them. - for (typename vector_type::value_type entry : wrappedResult) - { - children.push_back(ModifiedResult::convert(std::move(entry), - ResolverParams(wrappedParams))); - ++std::get(wrappedParams.errorPath->segment); - } - } - else - { - for (auto& entry : wrappedResult) - { - children.push_back(ModifiedResult::convert(std::move(entry), - ResolverParams(wrappedParams))); - ++std::get(wrappedParams.errorPath->segment); - } - } - - ResolverResult document { response::Value { response::Type::List } }; + std::vector children; + const auto parentPath = params.errorPath; + auto awaitedResult = co_await result; - document.data.reserve(children.size()); - std::get(wrappedParams.errorPath->segment) = 0; - - for (auto& child : children) - { - try - { - auto value = child.get(); - - document.data.emplace_back(std::move(value.data)); - - if (!value.errors.empty()) - { - document.errors.splice(document.errors.end(), value.errors); - } - } - catch (schema_exception& scx) - { - auto errors = scx.getStructuredErrors(); - - if (!errors.empty()) - { - document.errors.splice(document.errors.end(), errors); - } - } - catch (const std::exception& ex) - { - std::ostringstream message; - - message << "Field error name: " << wrappedParams.fieldName - << " unknown error: " << ex.what(); - - document.errors.emplace_back(schema_error { message.str(), - wrappedParams.getLocation(), - buildErrorPath(wrappedParams.errorPath) }); - } - - ++std::get(wrappedParams.errorPath->segment); - } + children.reserve(awaitedResult.size()); + params.errorPath = std::make_optional( + field_path { parentPath ? std::make_optional(std::cref(*parentPath)) : std::nullopt, + path_segment { size_t { 0 } } }); - return document; - }, - std::move(result), - std::move(params)); - } + using vector_type = std::decay_t; -private: - using ResolverCallback = - std::function::type&&, const ResolverParams&)>; + if constexpr (!std::is_same_v, + typename vector_type::value_type>) + { + // Special handling for std::vector<> specializations which don't return a + // reference to the underlying type, i.e. std::vector on many platforms. + // Copy the values from the std::vector<> rather than moving them. + for (typename vector_type::value_type entry : awaitedResult) + { + children.push_back( + ModifiedResult::convert(std::move(entry), ResolverParams(params))); + ++std::get(params.errorPath->segment); + } + } + else + { + for (auto& entry : awaitedResult) + { + children.push_back( + ModifiedResult::convert(std::move(entry), ResolverParams(params))); + ++std::get(params.errorPath->segment); + } + } - static std::future resolve(typename ResultTraits::future_type result, - ResolverParams&& params, ResolverCallback&& resolver) - { - static_assert(!std::is_base_of_v, - "ModfiedResult needs special handling"); + ResolverResult document { response::Value { response::Type::List } }; - auto buildResult = [](auto&& resultFuture, - ResolverParams&& paramsFuture, - ResolverCallback&& resolverFuture) noexcept { - ResolverResult document; + document.data.reserve(children.size()); + std::get(params.errorPath->segment) = 0; + for (auto& child : children) + { try { - document.data = resolverFuture(resultFuture.get(), paramsFuture); + auto value = co_await child; + + document.data.emplace_back(std::move(value.data)); + + if (!value.errors.empty()) + { + document.errors.splice(document.errors.end(), value.errors); + } } catch (schema_exception& scx) { @@ -808,31 +722,57 @@ struct ModifiedResult { std::ostringstream message; - message << "Field name: " << paramsFuture.fieldName + message << "Field error name: " << params.fieldName << " unknown error: " << ex.what(); document.errors.emplace_back(schema_error { message.str(), - paramsFuture.getLocation(), - buildErrorPath(paramsFuture.errorPath) }); + params.getLocation(), + buildErrorPath(params.errorPath) }); } - return document; - }; + ++std::get(params.errorPath->segment); + } + + co_return document; + } + +private: + using ResolverCallback = + std::function::type&&, const ResolverParams&)>; + + static AwaitableResolver resolve(typename ResultTraits::future_type&& result, + ResolverParams&& params, ResolverCallback&& resolver) + { + static_assert(!std::is_base_of_v, + "ModfiedResult needs special handling"); - if (result.is_future()) + ResolverResult document; + + try { - return std::async(std::launch::deferred, - std::move(buildResult), - std::move(result), - std::move(params), - std::move(resolver)); + document.data = resolver(co_await result, params); + } + catch (schema_exception& scx) + { + auto errors = scx.getStructuredErrors(); + + if (!errors.empty()) + { + document.errors.splice(document.errors.end(), errors); + } } + catch (const std::exception& ex) + { + std::ostringstream message; - std::promise promise; + message << "Field name: " << params.fieldName << " unknown error: " << ex.what(); - promise.set_value(buildResult(std::move(result), std::move(params), std::move(resolver))); + document.errors.emplace_back(schema_error { message.str(), + params.getLocation(), + buildErrorPath(params.errorPath) }); + } - return promise.get_future(); + co_return document; } }; @@ -850,25 +790,25 @@ using ObjectResult = ModifiedResult; #ifdef GRAPHQL_DLLEXPORTS // Export all of the built-in converters template <> -GRAPHQLSERVICE_EXPORT std::future ModifiedResult::convert( +GRAPHQLSERVICE_EXPORT AwaitableResolver ModifiedResult::convert( FieldResult&& result, ResolverParams&& params); template <> -GRAPHQLSERVICE_EXPORT std::future ModifiedResult::convert( +GRAPHQLSERVICE_EXPORT AwaitableResolver ModifiedResult::convert( FieldResult&& result, ResolverParams&& params); template <> -GRAPHQLSERVICE_EXPORT std::future ModifiedResult::convert( +GRAPHQLSERVICE_EXPORT AwaitableResolver ModifiedResult::convert( FieldResult&& result, ResolverParams&& params); template <> -GRAPHQLSERVICE_EXPORT std::future ModifiedResult::convert( +GRAPHQLSERVICE_EXPORT AwaitableResolver ModifiedResult::convert( FieldResult&& result, ResolverParams&& params); template <> -GRAPHQLSERVICE_EXPORT std::future ModifiedResult::convert( +GRAPHQLSERVICE_EXPORT AwaitableResolver ModifiedResult::convert( FieldResult&& result, ResolverParams&& params); template <> -GRAPHQLSERVICE_EXPORT std::future ModifiedResult::convert( +GRAPHQLSERVICE_EXPORT AwaitableResolver ModifiedResult::convert( FieldResult&& result, ResolverParams&& params); template <> -GRAPHQLSERVICE_EXPORT std::future ModifiedResult::convert( +GRAPHQLSERVICE_EXPORT AwaitableResolver ModifiedResult::convert( FieldResult>&& result, ResolverParams&& params); #endif // GRAPHQL_DLLEXPORTS @@ -904,7 +844,7 @@ struct OperationData : std::enable_shared_from_this // Subscription callbacks receive the response::Value representing the result of evaluating the // SelectionSet against the payload. -using SubscriptionCallback = std::function)>; +using SubscriptionCallback = std::function; using SubscriptionArguments = std::map; using SubscriptionFilterCallback = std::function; @@ -912,6 +852,9 @@ using SubscriptionFilterCallback = std::function; +using internal::AwaitableVoid; + // Registration information for subscription, cached in the Request::subscribe call. struct SubscriptionData : std::enable_shared_from_this { @@ -950,20 +893,20 @@ class Request : public std::enable_shared_from_this GRAPHQLSERVICE_EXPORT std::pair findOperationDefinition( peg::ast& query, std::string_view operationName) const; - GRAPHQLSERVICE_EXPORT std::future resolve( + GRAPHQLSERVICE_EXPORT response::AwaitableValue resolve( const std::shared_ptr& state, peg::ast& query, const std::string& operationName, response::Value&& variables) const; - GRAPHQLSERVICE_EXPORT std::future resolve(std::launch launch, + GRAPHQLSERVICE_EXPORT response::AwaitableValue resolve(std::launch launch, const std::shared_ptr& state, peg::ast& query, const std::string& operationName, response::Value&& variables) const; GRAPHQLSERVICE_EXPORT SubscriptionKey subscribe( SubscriptionParams&& params, SubscriptionCallback&& callback); - GRAPHQLSERVICE_EXPORT std::future subscribe( + GRAPHQLSERVICE_EXPORT AwaitableSubscriptionKey subscribe( std::launch launch, SubscriptionParams&& params, SubscriptionCallback&& callback); GRAPHQLSERVICE_EXPORT void unsubscribe(SubscriptionKey key); - GRAPHQLSERVICE_EXPORT std::future unsubscribe(std::launch launch, SubscriptionKey key); + GRAPHQLSERVICE_EXPORT AwaitableVoid unsubscribe(std::launch launch, SubscriptionKey key); GRAPHQLSERVICE_EXPORT void deliver( const SubscriptionName& name, const std::shared_ptr& subscriptionObject) const; @@ -981,18 +924,18 @@ class Request : public std::enable_shared_from_this const SubscriptionFilterCallback& applyDirectives, const std::shared_ptr& subscriptionObject) const; - GRAPHQLSERVICE_EXPORT void deliver(std::launch launch, const SubscriptionName& name, + GRAPHQLSERVICE_EXPORT AwaitableVoid deliver(std::launch launch, const SubscriptionName& name, const std::shared_ptr& subscriptionObject) const; - GRAPHQLSERVICE_EXPORT void deliver(std::launch launch, const SubscriptionName& name, + GRAPHQLSERVICE_EXPORT AwaitableVoid deliver(std::launch launch, const SubscriptionName& name, const SubscriptionArguments& arguments, const std::shared_ptr& subscriptionObject) const; - GRAPHQLSERVICE_EXPORT void deliver(std::launch launch, const SubscriptionName& name, + GRAPHQLSERVICE_EXPORT AwaitableVoid deliver(std::launch launch, const SubscriptionName& name, const SubscriptionArguments& arguments, const SubscriptionArguments& directives, const std::shared_ptr& subscriptionObject) const; - GRAPHQLSERVICE_EXPORT void deliver(std::launch launch, const SubscriptionName& name, + GRAPHQLSERVICE_EXPORT AwaitableVoid deliver(std::launch launch, const SubscriptionName& name, const SubscriptionFilterCallback& applyArguments, const std::shared_ptr& subscriptionObject) const; - GRAPHQLSERVICE_EXPORT void deliver(std::launch launch, const SubscriptionName& name, + GRAPHQLSERVICE_EXPORT AwaitableVoid deliver(std::launch launch, const SubscriptionName& name, const SubscriptionFilterCallback& applyArguments, const SubscriptionFilterCallback& applyDirectives, const std::shared_ptr& subscriptionObject) const; diff --git a/include/graphqlservice/internal/AwaitableFuture.h b/include/graphqlservice/internal/AwaitableFuture.h new file mode 100644 index 00000000..2c72edb3 --- /dev/null +++ b/include/graphqlservice/internal/AwaitableFuture.h @@ -0,0 +1,198 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +#pragma once + +#ifndef AWAITABLEFUTURE_H +#define AWAITABLEFUTURE_H + +// clang-format off +#ifdef USE_STD_EXPERIMENTAL_COROUTINE + #include + namespace coro = std::experimental; +#else // !USE_STD_EXPERIMENTAL_COROUTINE + #include + namespace coro = std; +#endif +// clang-format on + +#include +#include +#include + +namespace graphql::internal { + +class AwaitableVoid +{ +public: + AwaitableVoid(std::future&& value) + : _value { std::move(value) } + { + } + + void get() + { + using namespace std::literals; + + if (_value.wait_for(0s) != std::future_status::timeout) + { + _value.get(); + } + + std::promise promise; + auto future = promise.get_future(); + + std::thread([&promise, self = std::move(*this)]() mutable -> AwaitableVoid { + co_await self; + promise.set_value(); + }).detach(); + + return future.get(); + } + + struct promise_type + { + AwaitableVoid get_return_object() noexcept + { + return { _promise.get_future() }; + } + + coro::suspend_never initial_suspend() const noexcept + { + return {}; + } + + coro::suspend_never final_suspend() const noexcept + { + return {}; + } + + void return_void() noexcept + { + _promise.set_value(); + } + + void unhandled_exception() noexcept + { + _promise.set_exception(std::current_exception()); + } + + private: + std::promise _promise; + }; + + bool await_ready() const noexcept + { + using namespace std::literals; + + return (_value.wait_for(0s) != std::future_status::timeout); + } + + void await_suspend(coro::coroutine_handle<> h) const + { + std::thread([this, h]() mutable { + _value.wait(); + h.resume(); + }).detach(); + } + + void await_resume() + { + _value.get(); + } + +private: + std::future _value; +}; + +template +class AwaitableFuture +{ +public: + AwaitableFuture(std::future&& value) + : _value { std::move(value) } + { + } + + T get() + { + using namespace std::literals; + + if (_value.wait_for(0s) != std::future_status::timeout) + { + return _value.get(); + } + + std::promise promise; + auto future = promise.get_future(); + + std::thread([&promise, self = std::move(*this)]() mutable -> AwaitableVoid { + promise.set_value(co_await self); + }).detach(); + + return future.get(); + } + + struct promise_type + { + AwaitableFuture get_return_object() noexcept + { + return { _promise.get_future() }; + } + + coro::suspend_never initial_suspend() const noexcept + { + return {}; + } + + coro::suspend_never final_suspend() const noexcept + { + return {}; + } + + void return_value(const T& value) noexcept(std::is_nothrow_copy_constructible_v) + { + _promise.set_value(value); + } + + void return_value(T&& value) noexcept(std::is_nothrow_move_constructible_v) + { + _promise.set_value(std::move(value)); + } + + void unhandled_exception() noexcept + { + _promise.set_exception(std::current_exception()); + } + + private: + std::promise _promise; + }; + + bool await_ready() const noexcept + { + using namespace std::literals; + + return (_value.wait_for(0s) != std::future_status::timeout); + } + + void await_suspend(coro::coroutine_handle<> h) const + { + std::thread([this, h]() mutable { + _value.wait(); + h.resume(); + }).detach(); + } + + T await_resume() + { + return _value.get(); + } + +private: + std::future _value; +}; + +} // namespace graphql::internal + +#endif // AWAITABLEFUTURE_H diff --git a/include/graphqlservice/introspection/IntrospectionSchema.h b/include/graphqlservice/introspection/IntrospectionSchema.h index 4225c6e7..6dd72834 100644 --- a/include/graphqlservice/introspection/IntrospectionSchema.h +++ b/include/graphqlservice/introspection/IntrospectionSchema.h @@ -90,13 +90,13 @@ class Schema virtual service::FieldResult>> getDirectives(service::FieldParams&& params) const = 0; private: - std::future resolveTypes(service::ResolverParams&& params); - std::future resolveQueryType(service::ResolverParams&& params); - std::future resolveMutationType(service::ResolverParams&& params); - std::future resolveSubscriptionType(service::ResolverParams&& params); - std::future resolveDirectives(service::ResolverParams&& params); + service::AwaitableResolver resolveTypes(service::ResolverParams&& params); + service::AwaitableResolver resolveQueryType(service::ResolverParams&& params); + service::AwaitableResolver resolveMutationType(service::ResolverParams&& params); + service::AwaitableResolver resolveSubscriptionType(service::ResolverParams&& params); + service::AwaitableResolver resolveDirectives(service::ResolverParams&& params); - std::future resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params); }; class Type @@ -117,17 +117,17 @@ class Type virtual service::FieldResult> getOfType(service::FieldParams&& params) const = 0; private: - std::future resolveKind(service::ResolverParams&& params); - std::future resolveName(service::ResolverParams&& params); - std::future resolveDescription(service::ResolverParams&& params); - std::future resolveFields(service::ResolverParams&& params); - std::future resolveInterfaces(service::ResolverParams&& params); - std::future resolvePossibleTypes(service::ResolverParams&& params); - std::future resolveEnumValues(service::ResolverParams&& params); - std::future resolveInputFields(service::ResolverParams&& params); - std::future resolveOfType(service::ResolverParams&& params); - - std::future resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolveKind(service::ResolverParams&& params); + service::AwaitableResolver resolveName(service::ResolverParams&& params); + service::AwaitableResolver resolveDescription(service::ResolverParams&& params); + service::AwaitableResolver resolveFields(service::ResolverParams&& params); + service::AwaitableResolver resolveInterfaces(service::ResolverParams&& params); + service::AwaitableResolver resolvePossibleTypes(service::ResolverParams&& params); + service::AwaitableResolver resolveEnumValues(service::ResolverParams&& params); + service::AwaitableResolver resolveInputFields(service::ResolverParams&& params); + service::AwaitableResolver resolveOfType(service::ResolverParams&& params); + + service::AwaitableResolver resolve_typename(service::ResolverParams&& params); }; class Field @@ -145,14 +145,14 @@ class Field virtual service::FieldResult> getDeprecationReason(service::FieldParams&& params) const = 0; private: - std::future resolveName(service::ResolverParams&& params); - std::future resolveDescription(service::ResolverParams&& params); - std::future resolveArgs(service::ResolverParams&& params); - std::future resolveType(service::ResolverParams&& params); - std::future resolveIsDeprecated(service::ResolverParams&& params); - std::future resolveDeprecationReason(service::ResolverParams&& params); - - std::future resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolveName(service::ResolverParams&& params); + service::AwaitableResolver resolveDescription(service::ResolverParams&& params); + service::AwaitableResolver resolveArgs(service::ResolverParams&& params); + service::AwaitableResolver resolveType(service::ResolverParams&& params); + service::AwaitableResolver resolveIsDeprecated(service::ResolverParams&& params); + service::AwaitableResolver resolveDeprecationReason(service::ResolverParams&& params); + + service::AwaitableResolver resolve_typename(service::ResolverParams&& params); }; class InputValue @@ -168,12 +168,12 @@ class InputValue virtual service::FieldResult> getDefaultValue(service::FieldParams&& params) const = 0; private: - std::future resolveName(service::ResolverParams&& params); - std::future resolveDescription(service::ResolverParams&& params); - std::future resolveType(service::ResolverParams&& params); - std::future resolveDefaultValue(service::ResolverParams&& params); + service::AwaitableResolver resolveName(service::ResolverParams&& params); + service::AwaitableResolver resolveDescription(service::ResolverParams&& params); + service::AwaitableResolver resolveType(service::ResolverParams&& params); + service::AwaitableResolver resolveDefaultValue(service::ResolverParams&& params); - std::future resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params); }; class EnumValue @@ -189,12 +189,12 @@ class EnumValue virtual service::FieldResult> getDeprecationReason(service::FieldParams&& params) const = 0; private: - std::future resolveName(service::ResolverParams&& params); - std::future resolveDescription(service::ResolverParams&& params); - std::future resolveIsDeprecated(service::ResolverParams&& params); - std::future resolveDeprecationReason(service::ResolverParams&& params); + service::AwaitableResolver resolveName(service::ResolverParams&& params); + service::AwaitableResolver resolveDescription(service::ResolverParams&& params); + service::AwaitableResolver resolveIsDeprecated(service::ResolverParams&& params); + service::AwaitableResolver resolveDeprecationReason(service::ResolverParams&& params); - std::future resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params); }; class Directive @@ -210,12 +210,12 @@ class Directive virtual service::FieldResult>> getArgs(service::FieldParams&& params) const = 0; private: - std::future resolveName(service::ResolverParams&& params); - std::future resolveDescription(service::ResolverParams&& params); - std::future resolveLocations(service::ResolverParams&& params); - std::future resolveArgs(service::ResolverParams&& params); + service::AwaitableResolver resolveName(service::ResolverParams&& params); + service::AwaitableResolver resolveDescription(service::ResolverParams&& params); + service::AwaitableResolver resolveLocations(service::ResolverParams&& params); + service::AwaitableResolver resolveArgs(service::ResolverParams&& params); - std::future resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params); }; } // namespace object @@ -232,13 +232,13 @@ template <> GRAPHQLINTROSPECTION_EXPORT introspection::TypeKind ModifiedArgument::convert( const response::Value& value); template <> -GRAPHQLINTROSPECTION_EXPORT std::future ModifiedResult::convert( +GRAPHQLINTROSPECTION_EXPORT AwaitableResolver ModifiedResult::convert( FieldResult&& result, ResolverParams&& params); template <> GRAPHQLINTROSPECTION_EXPORT introspection::DirectiveLocation ModifiedArgument::convert( const response::Value& value); template <> -GRAPHQLINTROSPECTION_EXPORT std::future ModifiedResult::convert( +GRAPHQLINTROSPECTION_EXPORT AwaitableResolver ModifiedResult::convert( FieldResult&& result, ResolverParams&& params); #endif // GRAPHQL_DLLEXPORTS diff --git a/samples/learn/DroidObject.cpp b/samples/learn/DroidObject.cpp index b12ce167..001dc819 100644 --- a/samples/learn/DroidObject.cpp +++ b/samples/learn/DroidObject.cpp @@ -38,7 +38,7 @@ service::FieldResult Droid::getId(service::FieldParams&&) throw std::runtime_error(R"ex(Droid::getId is not implemented)ex"); } -std::future Droid::resolveId(service::ResolverParams&& params) +service::AwaitableResolver Droid::resolveId(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -53,7 +53,7 @@ service::FieldResult> Droid::getName(service throw std::runtime_error(R"ex(Droid::getName is not implemented)ex"); } -std::future Droid::resolveName(service::ResolverParams&& params) +service::AwaitableResolver Droid::resolveName(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -68,7 +68,7 @@ service::FieldResult> throw std::runtime_error(R"ex(Droid::getFriends is not implemented)ex"); } -std::future Droid::resolveFriends(service::ResolverParams&& params) +service::AwaitableResolver Droid::resolveFriends(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -83,7 +83,7 @@ service::FieldResult>>> Droid:: throw std::runtime_error(R"ex(Droid::getAppearsIn is not implemented)ex"); } -std::future Droid::resolveAppearsIn(service::ResolverParams&& params) +service::AwaitableResolver Droid::resolveAppearsIn(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -98,7 +98,7 @@ service::FieldResult> Droid::getPrimaryFunct throw std::runtime_error(R"ex(Droid::getPrimaryFunction is not implemented)ex"); } -std::future Droid::resolvePrimaryFunction(service::ResolverParams&& params) +service::AwaitableResolver Droid::resolvePrimaryFunction(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -108,7 +108,7 @@ std::future Droid::resolvePrimaryFunction(service::Reso return service::ModifiedResult::convert(std::move(result), std::move(params)); } -std::future Droid::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver Droid::resolve_typename(service::ResolverParams&& params) { return service::ModifiedResult::convert(response::StringType{ R"gql(Droid)gql" }, std::move(params)); } diff --git a/samples/learn/DroidObject.h b/samples/learn/DroidObject.h index 0c79a9ea..30d52501 100644 --- a/samples/learn/DroidObject.h +++ b/samples/learn/DroidObject.h @@ -27,13 +27,13 @@ class Droid virtual service::FieldResult> getPrimaryFunction(service::FieldParams&& params) const; private: - std::future resolveId(service::ResolverParams&& params); - std::future resolveName(service::ResolverParams&& params); - std::future resolveFriends(service::ResolverParams&& params); - std::future resolveAppearsIn(service::ResolverParams&& params); - std::future resolvePrimaryFunction(service::ResolverParams&& params); + service::AwaitableResolver resolveId(service::ResolverParams&& params); + service::AwaitableResolver resolveName(service::ResolverParams&& params); + service::AwaitableResolver resolveFriends(service::ResolverParams&& params); + service::AwaitableResolver resolveAppearsIn(service::ResolverParams&& params); + service::AwaitableResolver resolvePrimaryFunction(service::ResolverParams&& params); - std::future resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params); }; } // namespace graphql::learn::object diff --git a/samples/learn/HumanObject.cpp b/samples/learn/HumanObject.cpp index 4769437c..25a6e93d 100644 --- a/samples/learn/HumanObject.cpp +++ b/samples/learn/HumanObject.cpp @@ -38,7 +38,7 @@ service::FieldResult Human::getId(service::FieldParams&&) throw std::runtime_error(R"ex(Human::getId is not implemented)ex"); } -std::future Human::resolveId(service::ResolverParams&& params) +service::AwaitableResolver Human::resolveId(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -53,7 +53,7 @@ service::FieldResult> Human::getName(service throw std::runtime_error(R"ex(Human::getName is not implemented)ex"); } -std::future Human::resolveName(service::ResolverParams&& params) +service::AwaitableResolver Human::resolveName(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -68,7 +68,7 @@ service::FieldResult> throw std::runtime_error(R"ex(Human::getFriends is not implemented)ex"); } -std::future Human::resolveFriends(service::ResolverParams&& params) +service::AwaitableResolver Human::resolveFriends(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -83,7 +83,7 @@ service::FieldResult>>> Human:: throw std::runtime_error(R"ex(Human::getAppearsIn is not implemented)ex"); } -std::future Human::resolveAppearsIn(service::ResolverParams&& params) +service::AwaitableResolver Human::resolveAppearsIn(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -98,7 +98,7 @@ service::FieldResult> Human::getHomePlanet(s throw std::runtime_error(R"ex(Human::getHomePlanet is not implemented)ex"); } -std::future Human::resolveHomePlanet(service::ResolverParams&& params) +service::AwaitableResolver Human::resolveHomePlanet(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -108,7 +108,7 @@ std::future Human::resolveHomePlanet(service::ResolverP return service::ModifiedResult::convert(std::move(result), std::move(params)); } -std::future Human::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver Human::resolve_typename(service::ResolverParams&& params) { return service::ModifiedResult::convert(response::StringType{ R"gql(Human)gql" }, std::move(params)); } diff --git a/samples/learn/HumanObject.h b/samples/learn/HumanObject.h index 3836df6a..9555a004 100644 --- a/samples/learn/HumanObject.h +++ b/samples/learn/HumanObject.h @@ -27,13 +27,13 @@ class Human virtual service::FieldResult> getHomePlanet(service::FieldParams&& params) const; private: - std::future resolveId(service::ResolverParams&& params); - std::future resolveName(service::ResolverParams&& params); - std::future resolveFriends(service::ResolverParams&& params); - std::future resolveAppearsIn(service::ResolverParams&& params); - std::future resolveHomePlanet(service::ResolverParams&& params); + service::AwaitableResolver resolveId(service::ResolverParams&& params); + service::AwaitableResolver resolveName(service::ResolverParams&& params); + service::AwaitableResolver resolveFriends(service::ResolverParams&& params); + service::AwaitableResolver resolveAppearsIn(service::ResolverParams&& params); + service::AwaitableResolver resolveHomePlanet(service::ResolverParams&& params); - std::future resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params); }; } // namespace graphql::learn::object diff --git a/samples/learn/MutationObject.cpp b/samples/learn/MutationObject.cpp index 56582b09..1a8cfdb6 100644 --- a/samples/learn/MutationObject.cpp +++ b/samples/learn/MutationObject.cpp @@ -33,7 +33,7 @@ service::FieldResult> Mutation::applyCreateReview(servic throw std::runtime_error(R"ex(Mutation::applyCreateReview is not implemented)ex"); } -std::future Mutation::resolveCreateReview(service::ResolverParams&& params) +service::AwaitableResolver Mutation::resolveCreateReview(service::ResolverParams&& params) { auto argEp = service::ModifiedArgument::require("ep", params.arguments); auto argReview = service::ModifiedArgument::require("review", params.arguments); @@ -45,7 +45,7 @@ std::future Mutation::resolveCreateReview(service::Reso return service::ModifiedResult::convert(std::move(result), std::move(params)); } -std::future Mutation::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver Mutation::resolve_typename(service::ResolverParams&& params) { return service::ModifiedResult::convert(response::StringType{ R"gql(Mutation)gql" }, std::move(params)); } diff --git a/samples/learn/MutationObject.h b/samples/learn/MutationObject.h index 53f5b0a0..e2265cce 100644 --- a/samples/learn/MutationObject.h +++ b/samples/learn/MutationObject.h @@ -22,9 +22,9 @@ class Mutation virtual service::FieldResult> applyCreateReview(service::FieldParams&& params, Episode&& epArg, ReviewInput&& reviewArg) const; private: - std::future resolveCreateReview(service::ResolverParams&& params); + service::AwaitableResolver resolveCreateReview(service::ResolverParams&& params); - std::future resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params); }; } // namespace graphql::learn::object diff --git a/samples/learn/QueryObject.cpp b/samples/learn/QueryObject.cpp index 75e50c1b..5c9e491d 100644 --- a/samples/learn/QueryObject.cpp +++ b/samples/learn/QueryObject.cpp @@ -38,7 +38,7 @@ service::FieldResult> Query::getHero(service::F throw std::runtime_error(R"ex(Query::getHero is not implemented)ex"); } -std::future Query::resolveHero(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveHero(service::ResolverParams&& params) { auto argEpisode = service::ModifiedArgument::require("episode", params.arguments); std::unique_lock resolverLock(_resolverMutex); @@ -54,7 +54,7 @@ service::FieldResult> Query::getHuman(service::FieldParam throw std::runtime_error(R"ex(Query::getHuman is not implemented)ex"); } -std::future Query::resolveHuman(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveHuman(service::ResolverParams&& params) { auto argId = service::ModifiedArgument::require("id", params.arguments); std::unique_lock resolverLock(_resolverMutex); @@ -70,7 +70,7 @@ service::FieldResult> Query::getDroid(service::FieldParam throw std::runtime_error(R"ex(Query::getDroid is not implemented)ex"); } -std::future Query::resolveDroid(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveDroid(service::ResolverParams&& params) { auto argId = service::ModifiedArgument::require("id", params.arguments); std::unique_lock resolverLock(_resolverMutex); @@ -81,17 +81,17 @@ std::future Query::resolveDroid(service::ResolverParams return service::ModifiedResult::convert(std::move(result), std::move(params)); } -std::future Query::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver Query::resolve_typename(service::ResolverParams&& params) { return service::ModifiedResult::convert(response::StringType{ R"gql(Query)gql" }, std::move(params)); } -std::future Query::resolve_schema(service::ResolverParams&& params) +service::AwaitableResolver Query::resolve_schema(service::ResolverParams&& params) { return service::ModifiedResult::convert(std::static_pointer_cast(std::make_shared(_schema)), std::move(params)); } -std::future Query::resolve_type(service::ResolverParams&& params) +service::AwaitableResolver Query::resolve_type(service::ResolverParams&& params) { auto argName = service::ModifiedArgument::require("name", params.arguments); const auto& baseType = _schema->LookupType(argName); diff --git a/samples/learn/QueryObject.h b/samples/learn/QueryObject.h index dc45c748..707c9176 100644 --- a/samples/learn/QueryObject.h +++ b/samples/learn/QueryObject.h @@ -24,13 +24,13 @@ class Query virtual service::FieldResult> getDroid(service::FieldParams&& params, response::StringType&& idArg) const; private: - std::future resolveHero(service::ResolverParams&& params); - std::future resolveHuman(service::ResolverParams&& params); - std::future resolveDroid(service::ResolverParams&& params); + service::AwaitableResolver resolveHero(service::ResolverParams&& params); + service::AwaitableResolver resolveHuman(service::ResolverParams&& params); + service::AwaitableResolver resolveDroid(service::ResolverParams&& params); - std::future resolve_typename(service::ResolverParams&& params); - std::future resolve_schema(service::ResolverParams&& params); - std::future resolve_type(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_schema(service::ResolverParams&& params); + service::AwaitableResolver resolve_type(service::ResolverParams&& params); std::shared_ptr _schema; }; diff --git a/samples/learn/ReviewObject.cpp b/samples/learn/ReviewObject.cpp index 82451ea8..1214509a 100644 --- a/samples/learn/ReviewObject.cpp +++ b/samples/learn/ReviewObject.cpp @@ -34,7 +34,7 @@ service::FieldResult Review::getStars(service::FieldParams&&) throw std::runtime_error(R"ex(Review::getStars is not implemented)ex"); } -std::future Review::resolveStars(service::ResolverParams&& params) +service::AwaitableResolver Review::resolveStars(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -49,7 +49,7 @@ service::FieldResult> Review::getCommentary( throw std::runtime_error(R"ex(Review::getCommentary is not implemented)ex"); } -std::future Review::resolveCommentary(service::ResolverParams&& params) +service::AwaitableResolver Review::resolveCommentary(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -59,7 +59,7 @@ std::future Review::resolveCommentary(service::Resolver return service::ModifiedResult::convert(std::move(result), std::move(params)); } -std::future Review::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver Review::resolve_typename(service::ResolverParams&& params) { return service::ModifiedResult::convert(response::StringType{ R"gql(Review)gql" }, std::move(params)); } diff --git a/samples/learn/ReviewObject.h b/samples/learn/ReviewObject.h index 7cb80abe..3272d903 100644 --- a/samples/learn/ReviewObject.h +++ b/samples/learn/ReviewObject.h @@ -23,10 +23,10 @@ class Review virtual service::FieldResult> getCommentary(service::FieldParams&& params) const; private: - std::future resolveStars(service::ResolverParams&& params); - std::future resolveCommentary(service::ResolverParams&& params); + service::AwaitableResolver resolveStars(service::ResolverParams&& params); + service::AwaitableResolver resolveCommentary(service::ResolverParams&& params); - std::future resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params); }; } // namespace graphql::learn::object diff --git a/samples/learn/StarWarsSchema.cpp b/samples/learn/StarWarsSchema.cpp index 25e1b8ad..77de5726 100644 --- a/samples/learn/StarWarsSchema.cpp +++ b/samples/learn/StarWarsSchema.cpp @@ -46,7 +46,7 @@ learn::Episode ModifiedArgument::convert(const response::Value& } template <> -std::future ModifiedResult::convert(service::FieldResult&& result, ResolverParams&& params) +service::AwaitableResolver ModifiedResult::convert(service::FieldResult&& result, ResolverParams&& params) { return resolve(std::move(result), std::move(params), [](learn::Episode value, const ResolverParams&) diff --git a/samples/separate/AppointmentConnectionObject.cpp b/samples/separate/AppointmentConnectionObject.cpp index 59001226..0fa13769 100644 --- a/samples/separate/AppointmentConnectionObject.cpp +++ b/samples/separate/AppointmentConnectionObject.cpp @@ -34,7 +34,7 @@ service::FieldResult> AppointmentConnection::getPageIn throw std::runtime_error(R"ex(AppointmentConnection::getPageInfo is not implemented)ex"); } -std::future AppointmentConnection::resolvePageInfo(service::ResolverParams&& params) +service::AwaitableResolver AppointmentConnection::resolvePageInfo(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -49,7 +49,7 @@ service::FieldResult> throw std::runtime_error(R"ex(AppointmentConnection::getEdges is not implemented)ex"); } -std::future AppointmentConnection::resolveEdges(service::ResolverParams&& params) +service::AwaitableResolver AppointmentConnection::resolveEdges(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -59,7 +59,7 @@ std::future AppointmentConnection::resolveEdges(service return service::ModifiedResult::convert(std::move(result), std::move(params)); } -std::future AppointmentConnection::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver AppointmentConnection::resolve_typename(service::ResolverParams&& params) { return service::ModifiedResult::convert(response::StringType{ R"gql(AppointmentConnection)gql" }, std::move(params)); } diff --git a/samples/separate/AppointmentConnectionObject.h b/samples/separate/AppointmentConnectionObject.h index 76886da5..ff7a67a3 100644 --- a/samples/separate/AppointmentConnectionObject.h +++ b/samples/separate/AppointmentConnectionObject.h @@ -23,10 +23,10 @@ class AppointmentConnection virtual service::FieldResult>>> getEdges(service::FieldParams&& params) const; private: - std::future resolvePageInfo(service::ResolverParams&& params); - std::future resolveEdges(service::ResolverParams&& params); + service::AwaitableResolver resolvePageInfo(service::ResolverParams&& params); + service::AwaitableResolver resolveEdges(service::ResolverParams&& params); - std::future resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params); }; } // namespace graphql::today::object diff --git a/samples/separate/AppointmentEdgeObject.cpp b/samples/separate/AppointmentEdgeObject.cpp index 3fc6c5af..588dfeb0 100644 --- a/samples/separate/AppointmentEdgeObject.cpp +++ b/samples/separate/AppointmentEdgeObject.cpp @@ -34,7 +34,7 @@ service::FieldResult> AppointmentEdge::getNode(serv throw std::runtime_error(R"ex(AppointmentEdge::getNode is not implemented)ex"); } -std::future AppointmentEdge::resolveNode(service::ResolverParams&& params) +service::AwaitableResolver AppointmentEdge::resolveNode(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -49,7 +49,7 @@ service::FieldResult AppointmentEdge::getCursor(service::FieldP throw std::runtime_error(R"ex(AppointmentEdge::getCursor is not implemented)ex"); } -std::future AppointmentEdge::resolveCursor(service::ResolverParams&& params) +service::AwaitableResolver AppointmentEdge::resolveCursor(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -59,7 +59,7 @@ std::future AppointmentEdge::resolveCursor(service::Res return service::ModifiedResult::convert(std::move(result), std::move(params)); } -std::future AppointmentEdge::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver AppointmentEdge::resolve_typename(service::ResolverParams&& params) { return service::ModifiedResult::convert(response::StringType{ R"gql(AppointmentEdge)gql" }, std::move(params)); } diff --git a/samples/separate/AppointmentEdgeObject.h b/samples/separate/AppointmentEdgeObject.h index 6b939423..f8a5236e 100644 --- a/samples/separate/AppointmentEdgeObject.h +++ b/samples/separate/AppointmentEdgeObject.h @@ -23,10 +23,10 @@ class AppointmentEdge virtual service::FieldResult getCursor(service::FieldParams&& params) const; private: - std::future resolveNode(service::ResolverParams&& params); - std::future resolveCursor(service::ResolverParams&& params); + service::AwaitableResolver resolveNode(service::ResolverParams&& params); + service::AwaitableResolver resolveCursor(service::ResolverParams&& params); - std::future resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params); }; } // namespace graphql::today::object diff --git a/samples/separate/AppointmentObject.cpp b/samples/separate/AppointmentObject.cpp index 9cc0282a..7b156a39 100644 --- a/samples/separate/AppointmentObject.cpp +++ b/samples/separate/AppointmentObject.cpp @@ -39,7 +39,7 @@ service::FieldResult Appointment::getId(service::FieldParams&& throw std::runtime_error(R"ex(Appointment::getId is not implemented)ex"); } -std::future Appointment::resolveId(service::ResolverParams&& params) +service::AwaitableResolver Appointment::resolveId(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -54,7 +54,7 @@ service::FieldResult> Appointment::getWhen(servic throw std::runtime_error(R"ex(Appointment::getWhen is not implemented)ex"); } -std::future Appointment::resolveWhen(service::ResolverParams&& params) +service::AwaitableResolver Appointment::resolveWhen(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -69,7 +69,7 @@ service::FieldResult> Appointment::getSubjec throw std::runtime_error(R"ex(Appointment::getSubject is not implemented)ex"); } -std::future Appointment::resolveSubject(service::ResolverParams&& params) +service::AwaitableResolver Appointment::resolveSubject(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -84,7 +84,7 @@ service::FieldResult Appointment::getIsNow(service::Field throw std::runtime_error(R"ex(Appointment::getIsNow is not implemented)ex"); } -std::future Appointment::resolveIsNow(service::ResolverParams&& params) +service::AwaitableResolver Appointment::resolveIsNow(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -99,7 +99,7 @@ service::FieldResult> Appointment::getForceE throw std::runtime_error(R"ex(Appointment::getForceError is not implemented)ex"); } -std::future Appointment::resolveForceError(service::ResolverParams&& params) +service::AwaitableResolver Appointment::resolveForceError(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -109,7 +109,7 @@ std::future Appointment::resolveForceError(service::Res return service::ModifiedResult::convert(std::move(result), std::move(params)); } -std::future Appointment::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver Appointment::resolve_typename(service::ResolverParams&& params) { return service::ModifiedResult::convert(response::StringType{ R"gql(Appointment)gql" }, std::move(params)); } diff --git a/samples/separate/AppointmentObject.h b/samples/separate/AppointmentObject.h index 58c7763b..e7f710ac 100644 --- a/samples/separate/AppointmentObject.h +++ b/samples/separate/AppointmentObject.h @@ -27,13 +27,13 @@ class Appointment virtual service::FieldResult> getForceError(service::FieldParams&& params) const; private: - std::future resolveId(service::ResolverParams&& params); - std::future resolveWhen(service::ResolverParams&& params); - std::future resolveSubject(service::ResolverParams&& params); - std::future resolveIsNow(service::ResolverParams&& params); - std::future resolveForceError(service::ResolverParams&& params); + service::AwaitableResolver resolveId(service::ResolverParams&& params); + service::AwaitableResolver resolveWhen(service::ResolverParams&& params); + service::AwaitableResolver resolveSubject(service::ResolverParams&& params); + service::AwaitableResolver resolveIsNow(service::ResolverParams&& params); + service::AwaitableResolver resolveForceError(service::ResolverParams&& params); - std::future resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params); }; } // namespace graphql::today::object diff --git a/samples/separate/CompleteTaskPayloadObject.cpp b/samples/separate/CompleteTaskPayloadObject.cpp index 130d0075..d3a742ac 100644 --- a/samples/separate/CompleteTaskPayloadObject.cpp +++ b/samples/separate/CompleteTaskPayloadObject.cpp @@ -34,7 +34,7 @@ service::FieldResult> CompleteTaskPayload::getTask(service throw std::runtime_error(R"ex(CompleteTaskPayload::getTask is not implemented)ex"); } -std::future CompleteTaskPayload::resolveTask(service::ResolverParams&& params) +service::AwaitableResolver CompleteTaskPayload::resolveTask(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -49,7 +49,7 @@ service::FieldResult> CompleteTaskPayload::g throw std::runtime_error(R"ex(CompleteTaskPayload::getClientMutationId is not implemented)ex"); } -std::future CompleteTaskPayload::resolveClientMutationId(service::ResolverParams&& params) +service::AwaitableResolver CompleteTaskPayload::resolveClientMutationId(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -59,7 +59,7 @@ std::future CompleteTaskPayload::resolveClientMutationI return service::ModifiedResult::convert(std::move(result), std::move(params)); } -std::future CompleteTaskPayload::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver CompleteTaskPayload::resolve_typename(service::ResolverParams&& params) { return service::ModifiedResult::convert(response::StringType{ R"gql(CompleteTaskPayload)gql" }, std::move(params)); } diff --git a/samples/separate/CompleteTaskPayloadObject.h b/samples/separate/CompleteTaskPayloadObject.h index a88b53a3..c44afd16 100644 --- a/samples/separate/CompleteTaskPayloadObject.h +++ b/samples/separate/CompleteTaskPayloadObject.h @@ -23,10 +23,10 @@ class CompleteTaskPayload virtual service::FieldResult> getClientMutationId(service::FieldParams&& params) const; private: - std::future resolveTask(service::ResolverParams&& params); - std::future resolveClientMutationId(service::ResolverParams&& params); + service::AwaitableResolver resolveTask(service::ResolverParams&& params); + service::AwaitableResolver resolveClientMutationId(service::ResolverParams&& params); - std::future resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params); }; } // namespace graphql::today::object diff --git a/samples/separate/ExpensiveObject.cpp b/samples/separate/ExpensiveObject.cpp index 7785d77f..2bc006c6 100644 --- a/samples/separate/ExpensiveObject.cpp +++ b/samples/separate/ExpensiveObject.cpp @@ -33,7 +33,7 @@ service::FieldResult Expensive::getOrder(service::FieldParams throw std::runtime_error(R"ex(Expensive::getOrder is not implemented)ex"); } -std::future Expensive::resolveOrder(service::ResolverParams&& params) +service::AwaitableResolver Expensive::resolveOrder(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -43,7 +43,7 @@ std::future Expensive::resolveOrder(service::ResolverPa return service::ModifiedResult::convert(std::move(result), std::move(params)); } -std::future Expensive::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver Expensive::resolve_typename(service::ResolverParams&& params) { return service::ModifiedResult::convert(response::StringType{ R"gql(Expensive)gql" }, std::move(params)); } diff --git a/samples/separate/ExpensiveObject.h b/samples/separate/ExpensiveObject.h index 791b4292..4c30bba0 100644 --- a/samples/separate/ExpensiveObject.h +++ b/samples/separate/ExpensiveObject.h @@ -22,9 +22,9 @@ class Expensive virtual service::FieldResult getOrder(service::FieldParams&& params) const; private: - std::future resolveOrder(service::ResolverParams&& params); + service::AwaitableResolver resolveOrder(service::ResolverParams&& params); - std::future resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params); }; } // namespace graphql::today::object diff --git a/samples/separate/FolderConnectionObject.cpp b/samples/separate/FolderConnectionObject.cpp index 3380f997..2d7ac269 100644 --- a/samples/separate/FolderConnectionObject.cpp +++ b/samples/separate/FolderConnectionObject.cpp @@ -34,7 +34,7 @@ service::FieldResult> FolderConnection::getPageInfo(se throw std::runtime_error(R"ex(FolderConnection::getPageInfo is not implemented)ex"); } -std::future FolderConnection::resolvePageInfo(service::ResolverParams&& params) +service::AwaitableResolver FolderConnection::resolvePageInfo(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -49,7 +49,7 @@ service::FieldResult>>> Fo throw std::runtime_error(R"ex(FolderConnection::getEdges is not implemented)ex"); } -std::future FolderConnection::resolveEdges(service::ResolverParams&& params) +service::AwaitableResolver FolderConnection::resolveEdges(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -59,7 +59,7 @@ std::future FolderConnection::resolveEdges(service::Res return service::ModifiedResult::convert(std::move(result), std::move(params)); } -std::future FolderConnection::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver FolderConnection::resolve_typename(service::ResolverParams&& params) { return service::ModifiedResult::convert(response::StringType{ R"gql(FolderConnection)gql" }, std::move(params)); } diff --git a/samples/separate/FolderConnectionObject.h b/samples/separate/FolderConnectionObject.h index aec397d4..74477723 100644 --- a/samples/separate/FolderConnectionObject.h +++ b/samples/separate/FolderConnectionObject.h @@ -23,10 +23,10 @@ class FolderConnection virtual service::FieldResult>>> getEdges(service::FieldParams&& params) const; private: - std::future resolvePageInfo(service::ResolverParams&& params); - std::future resolveEdges(service::ResolverParams&& params); + service::AwaitableResolver resolvePageInfo(service::ResolverParams&& params); + service::AwaitableResolver resolveEdges(service::ResolverParams&& params); - std::future resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params); }; } // namespace graphql::today::object diff --git a/samples/separate/FolderEdgeObject.cpp b/samples/separate/FolderEdgeObject.cpp index 7c641ce5..06672e4b 100644 --- a/samples/separate/FolderEdgeObject.cpp +++ b/samples/separate/FolderEdgeObject.cpp @@ -34,7 +34,7 @@ service::FieldResult> FolderEdge::getNode(service::Field throw std::runtime_error(R"ex(FolderEdge::getNode is not implemented)ex"); } -std::future FolderEdge::resolveNode(service::ResolverParams&& params) +service::AwaitableResolver FolderEdge::resolveNode(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -49,7 +49,7 @@ service::FieldResult FolderEdge::getCursor(service::FieldParams throw std::runtime_error(R"ex(FolderEdge::getCursor is not implemented)ex"); } -std::future FolderEdge::resolveCursor(service::ResolverParams&& params) +service::AwaitableResolver FolderEdge::resolveCursor(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -59,7 +59,7 @@ std::future FolderEdge::resolveCursor(service::Resolver return service::ModifiedResult::convert(std::move(result), std::move(params)); } -std::future FolderEdge::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver FolderEdge::resolve_typename(service::ResolverParams&& params) { return service::ModifiedResult::convert(response::StringType{ R"gql(FolderEdge)gql" }, std::move(params)); } diff --git a/samples/separate/FolderEdgeObject.h b/samples/separate/FolderEdgeObject.h index 00fbd677..52ab2627 100644 --- a/samples/separate/FolderEdgeObject.h +++ b/samples/separate/FolderEdgeObject.h @@ -23,10 +23,10 @@ class FolderEdge virtual service::FieldResult getCursor(service::FieldParams&& params) const; private: - std::future resolveNode(service::ResolverParams&& params); - std::future resolveCursor(service::ResolverParams&& params); + service::AwaitableResolver resolveNode(service::ResolverParams&& params); + service::AwaitableResolver resolveCursor(service::ResolverParams&& params); - std::future resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params); }; } // namespace graphql::today::object diff --git a/samples/separate/FolderObject.cpp b/samples/separate/FolderObject.cpp index d5c6b517..3fadea37 100644 --- a/samples/separate/FolderObject.cpp +++ b/samples/separate/FolderObject.cpp @@ -37,7 +37,7 @@ service::FieldResult Folder::getId(service::FieldParams&&) con throw std::runtime_error(R"ex(Folder::getId is not implemented)ex"); } -std::future Folder::resolveId(service::ResolverParams&& params) +service::AwaitableResolver Folder::resolveId(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -52,7 +52,7 @@ service::FieldResult> Folder::getName(servic throw std::runtime_error(R"ex(Folder::getName is not implemented)ex"); } -std::future Folder::resolveName(service::ResolverParams&& params) +service::AwaitableResolver Folder::resolveName(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -67,7 +67,7 @@ service::FieldResult Folder::getUnreadCount(service::FieldPar throw std::runtime_error(R"ex(Folder::getUnreadCount is not implemented)ex"); } -std::future Folder::resolveUnreadCount(service::ResolverParams&& params) +service::AwaitableResolver Folder::resolveUnreadCount(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -77,7 +77,7 @@ std::future Folder::resolveUnreadCount(service::Resolve return service::ModifiedResult::convert(std::move(result), std::move(params)); } -std::future Folder::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver Folder::resolve_typename(service::ResolverParams&& params) { return service::ModifiedResult::convert(response::StringType{ R"gql(Folder)gql" }, std::move(params)); } diff --git a/samples/separate/FolderObject.h b/samples/separate/FolderObject.h index e11053bf..abd48918 100644 --- a/samples/separate/FolderObject.h +++ b/samples/separate/FolderObject.h @@ -25,11 +25,11 @@ class Folder virtual service::FieldResult getUnreadCount(service::FieldParams&& params) const; private: - std::future resolveId(service::ResolverParams&& params); - std::future resolveName(service::ResolverParams&& params); - std::future resolveUnreadCount(service::ResolverParams&& params); + service::AwaitableResolver resolveId(service::ResolverParams&& params); + service::AwaitableResolver resolveName(service::ResolverParams&& params); + service::AwaitableResolver resolveUnreadCount(service::ResolverParams&& params); - std::future resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params); }; } // namespace graphql::today::object diff --git a/samples/separate/MutationObject.cpp b/samples/separate/MutationObject.cpp index c5f9d236..aa8d858b 100644 --- a/samples/separate/MutationObject.cpp +++ b/samples/separate/MutationObject.cpp @@ -34,7 +34,7 @@ service::FieldResult> Mutation::applyComple throw std::runtime_error(R"ex(Mutation::applyCompleteTask is not implemented)ex"); } -std::future Mutation::resolveCompleteTask(service::ResolverParams&& params) +service::AwaitableResolver Mutation::resolveCompleteTask(service::ResolverParams&& params) { auto argInput = service::ModifiedArgument::require("input", params.arguments); std::unique_lock resolverLock(_resolverMutex); @@ -50,7 +50,7 @@ service::FieldResult Mutation::applySetFloat(service::Field throw std::runtime_error(R"ex(Mutation::applySetFloat is not implemented)ex"); } -std::future Mutation::resolveSetFloat(service::ResolverParams&& params) +service::AwaitableResolver Mutation::resolveSetFloat(service::ResolverParams&& params) { auto argValue = service::ModifiedArgument::require("value", params.arguments); std::unique_lock resolverLock(_resolverMutex); @@ -61,7 +61,7 @@ std::future Mutation::resolveSetFloat(service::Resolver return service::ModifiedResult::convert(std::move(result), std::move(params)); } -std::future Mutation::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver Mutation::resolve_typename(service::ResolverParams&& params) { return service::ModifiedResult::convert(response::StringType{ R"gql(Mutation)gql" }, std::move(params)); } diff --git a/samples/separate/MutationObject.h b/samples/separate/MutationObject.h index c5ab3977..b72577ea 100644 --- a/samples/separate/MutationObject.h +++ b/samples/separate/MutationObject.h @@ -23,10 +23,10 @@ class Mutation virtual service::FieldResult applySetFloat(service::FieldParams&& params, response::FloatType&& valueArg) const; private: - std::future resolveCompleteTask(service::ResolverParams&& params); - std::future resolveSetFloat(service::ResolverParams&& params); + service::AwaitableResolver resolveCompleteTask(service::ResolverParams&& params); + service::AwaitableResolver resolveSetFloat(service::ResolverParams&& params); - std::future resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params); }; } // namespace graphql::today::object diff --git a/samples/separate/NestedTypeObject.cpp b/samples/separate/NestedTypeObject.cpp index 285cfd11..3117d57c 100644 --- a/samples/separate/NestedTypeObject.cpp +++ b/samples/separate/NestedTypeObject.cpp @@ -34,7 +34,7 @@ service::FieldResult NestedType::getDepth(service::FieldParam throw std::runtime_error(R"ex(NestedType::getDepth is not implemented)ex"); } -std::future NestedType::resolveDepth(service::ResolverParams&& params) +service::AwaitableResolver NestedType::resolveDepth(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -49,7 +49,7 @@ service::FieldResult> NestedType::getNested(service: throw std::runtime_error(R"ex(NestedType::getNested is not implemented)ex"); } -std::future NestedType::resolveNested(service::ResolverParams&& params) +service::AwaitableResolver NestedType::resolveNested(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -59,7 +59,7 @@ std::future NestedType::resolveNested(service::Resolver return service::ModifiedResult::convert(std::move(result), std::move(params)); } -std::future NestedType::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver NestedType::resolve_typename(service::ResolverParams&& params) { return service::ModifiedResult::convert(response::StringType{ R"gql(NestedType)gql" }, std::move(params)); } diff --git a/samples/separate/NestedTypeObject.h b/samples/separate/NestedTypeObject.h index 94cb2418..eb06cf04 100644 --- a/samples/separate/NestedTypeObject.h +++ b/samples/separate/NestedTypeObject.h @@ -23,10 +23,10 @@ class NestedType virtual service::FieldResult> getNested(service::FieldParams&& params) const; private: - std::future resolveDepth(service::ResolverParams&& params); - std::future resolveNested(service::ResolverParams&& params); + service::AwaitableResolver resolveDepth(service::ResolverParams&& params); + service::AwaitableResolver resolveNested(service::ResolverParams&& params); - std::future resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params); }; } // namespace graphql::today::object diff --git a/samples/separate/PageInfoObject.cpp b/samples/separate/PageInfoObject.cpp index 8c27b393..900d73a5 100644 --- a/samples/separate/PageInfoObject.cpp +++ b/samples/separate/PageInfoObject.cpp @@ -34,7 +34,7 @@ service::FieldResult PageInfo::getHasNextPage(service::Fi throw std::runtime_error(R"ex(PageInfo::getHasNextPage is not implemented)ex"); } -std::future PageInfo::resolveHasNextPage(service::ResolverParams&& params) +service::AwaitableResolver PageInfo::resolveHasNextPage(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -49,7 +49,7 @@ service::FieldResult PageInfo::getHasPreviousPage(service throw std::runtime_error(R"ex(PageInfo::getHasPreviousPage is not implemented)ex"); } -std::future PageInfo::resolveHasPreviousPage(service::ResolverParams&& params) +service::AwaitableResolver PageInfo::resolveHasPreviousPage(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -59,7 +59,7 @@ std::future PageInfo::resolveHasPreviousPage(service::R return service::ModifiedResult::convert(std::move(result), std::move(params)); } -std::future PageInfo::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver PageInfo::resolve_typename(service::ResolverParams&& params) { return service::ModifiedResult::convert(response::StringType{ R"gql(PageInfo)gql" }, std::move(params)); } diff --git a/samples/separate/PageInfoObject.h b/samples/separate/PageInfoObject.h index 337cbd4a..b2d3a844 100644 --- a/samples/separate/PageInfoObject.h +++ b/samples/separate/PageInfoObject.h @@ -23,10 +23,10 @@ class PageInfo virtual service::FieldResult getHasPreviousPage(service::FieldParams&& params) const; private: - std::future resolveHasNextPage(service::ResolverParams&& params); - std::future resolveHasPreviousPage(service::ResolverParams&& params); + service::AwaitableResolver resolveHasNextPage(service::ResolverParams&& params); + service::AwaitableResolver resolveHasPreviousPage(service::ResolverParams&& params); - std::future resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params); }; } // namespace graphql::today::object diff --git a/samples/separate/QueryObject.cpp b/samples/separate/QueryObject.cpp index 5cfca835..6df521bc 100644 --- a/samples/separate/QueryObject.cpp +++ b/samples/separate/QueryObject.cpp @@ -47,7 +47,7 @@ service::FieldResult> Query::getNode(service::F throw std::runtime_error(R"ex(Query::getNode is not implemented)ex"); } -std::future Query::resolveNode(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveNode(service::ResolverParams&& params) { auto argId = service::ModifiedArgument::require("id", params.arguments); std::unique_lock resolverLock(_resolverMutex); @@ -63,7 +63,7 @@ service::FieldResult> Query::getAppointme throw std::runtime_error(R"ex(Query::getAppointments is not implemented)ex"); } -std::future Query::resolveAppointments(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveAppointments(service::ResolverParams&& params) { auto argFirst = service::ModifiedArgument::require("first", params.arguments); auto argAfter = service::ModifiedArgument::require("after", params.arguments); @@ -82,7 +82,7 @@ service::FieldResult> Query::getTasks(service::F throw std::runtime_error(R"ex(Query::getTasks is not implemented)ex"); } -std::future Query::resolveTasks(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveTasks(service::ResolverParams&& params) { auto argFirst = service::ModifiedArgument::require("first", params.arguments); auto argAfter = service::ModifiedArgument::require("after", params.arguments); @@ -101,7 +101,7 @@ service::FieldResult> Query::getUnreadCounts(s throw std::runtime_error(R"ex(Query::getUnreadCounts is not implemented)ex"); } -std::future Query::resolveUnreadCounts(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveUnreadCounts(service::ResolverParams&& params) { auto argFirst = service::ModifiedArgument::require("first", params.arguments); auto argAfter = service::ModifiedArgument::require("after", params.arguments); @@ -120,7 +120,7 @@ service::FieldResult>> Query::getAppoin throw std::runtime_error(R"ex(Query::getAppointmentsById is not implemented)ex"); } -std::future Query::resolveAppointmentsById(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveAppointmentsById(service::ResolverParams&& params) { const auto defaultArguments = []() { @@ -158,7 +158,7 @@ service::FieldResult>> Query::getTasksById(ser throw std::runtime_error(R"ex(Query::getTasksById is not implemented)ex"); } -std::future Query::resolveTasksById(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveTasksById(service::ResolverParams&& params) { auto argIds = service::ModifiedArgument::require("ids", params.arguments); std::unique_lock resolverLock(_resolverMutex); @@ -174,7 +174,7 @@ service::FieldResult>> Query::getUnreadCount throw std::runtime_error(R"ex(Query::getUnreadCountsById is not implemented)ex"); } -std::future Query::resolveUnreadCountsById(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveUnreadCountsById(service::ResolverParams&& params) { auto argIds = service::ModifiedArgument::require("ids", params.arguments); std::unique_lock resolverLock(_resolverMutex); @@ -190,7 +190,7 @@ service::FieldResult> Query::getNested(service::Fiel throw std::runtime_error(R"ex(Query::getNested is not implemented)ex"); } -std::future Query::resolveNested(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveNested(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -205,7 +205,7 @@ service::FieldResult Query::getUnimplemented(service::Fiel throw std::runtime_error(R"ex(Query::getUnimplemented is not implemented)ex"); } -std::future Query::resolveUnimplemented(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveUnimplemented(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -220,7 +220,7 @@ service::FieldResult>> Query::getExpensiv throw std::runtime_error(R"ex(Query::getExpensive is not implemented)ex"); } -std::future Query::resolveExpensive(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveExpensive(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -235,7 +235,7 @@ service::FieldResult Query::getTestTaskState(service::FieldParams&&) throw std::runtime_error(R"ex(Query::getTestTaskState is not implemented)ex"); } -std::future Query::resolveTestTaskState(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveTestTaskState(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -250,7 +250,7 @@ service::FieldResult>> Query::getAn throw std::runtime_error(R"ex(Query::getAnyType is not implemented)ex"); } -std::future Query::resolveAnyType(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveAnyType(service::ResolverParams&& params) { auto argIds = service::ModifiedArgument::require("ids", params.arguments); std::unique_lock resolverLock(_resolverMutex); @@ -261,17 +261,17 @@ std::future Query::resolveAnyType(service::ResolverPara return service::ModifiedResult::convert(std::move(result), std::move(params)); } -std::future Query::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver Query::resolve_typename(service::ResolverParams&& params) { return service::ModifiedResult::convert(response::StringType{ R"gql(Query)gql" }, std::move(params)); } -std::future Query::resolve_schema(service::ResolverParams&& params) +service::AwaitableResolver Query::resolve_schema(service::ResolverParams&& params) { return service::ModifiedResult::convert(std::static_pointer_cast(std::make_shared(_schema)), std::move(params)); } -std::future Query::resolve_type(service::ResolverParams&& params) +service::AwaitableResolver Query::resolve_type(service::ResolverParams&& params) { auto argName = service::ModifiedArgument::require("name", params.arguments); const auto& baseType = _schema->LookupType(argName); diff --git a/samples/separate/QueryObject.h b/samples/separate/QueryObject.h index 55de9b70..9518caf3 100644 --- a/samples/separate/QueryObject.h +++ b/samples/separate/QueryObject.h @@ -33,22 +33,22 @@ class Query virtual service::FieldResult>> getAnyType(service::FieldParams&& params, std::vector&& idsArg) const; private: - std::future resolveNode(service::ResolverParams&& params); - std::future resolveAppointments(service::ResolverParams&& params); - std::future resolveTasks(service::ResolverParams&& params); - std::future resolveUnreadCounts(service::ResolverParams&& params); - std::future resolveAppointmentsById(service::ResolverParams&& params); - std::future resolveTasksById(service::ResolverParams&& params); - std::future resolveUnreadCountsById(service::ResolverParams&& params); - std::future resolveNested(service::ResolverParams&& params); - std::future resolveUnimplemented(service::ResolverParams&& params); - std::future resolveExpensive(service::ResolverParams&& params); - std::future resolveTestTaskState(service::ResolverParams&& params); - std::future resolveAnyType(service::ResolverParams&& params); - - std::future resolve_typename(service::ResolverParams&& params); - std::future resolve_schema(service::ResolverParams&& params); - std::future resolve_type(service::ResolverParams&& params); + service::AwaitableResolver resolveNode(service::ResolverParams&& params); + service::AwaitableResolver resolveAppointments(service::ResolverParams&& params); + service::AwaitableResolver resolveTasks(service::ResolverParams&& params); + service::AwaitableResolver resolveUnreadCounts(service::ResolverParams&& params); + service::AwaitableResolver resolveAppointmentsById(service::ResolverParams&& params); + service::AwaitableResolver resolveTasksById(service::ResolverParams&& params); + service::AwaitableResolver resolveUnreadCountsById(service::ResolverParams&& params); + service::AwaitableResolver resolveNested(service::ResolverParams&& params); + service::AwaitableResolver resolveUnimplemented(service::ResolverParams&& params); + service::AwaitableResolver resolveExpensive(service::ResolverParams&& params); + service::AwaitableResolver resolveTestTaskState(service::ResolverParams&& params); + service::AwaitableResolver resolveAnyType(service::ResolverParams&& params); + + service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_schema(service::ResolverParams&& params); + service::AwaitableResolver resolve_type(service::ResolverParams&& params); std::shared_ptr _schema; }; diff --git a/samples/separate/SubscriptionObject.cpp b/samples/separate/SubscriptionObject.cpp index 21b477be..746a6e7e 100644 --- a/samples/separate/SubscriptionObject.cpp +++ b/samples/separate/SubscriptionObject.cpp @@ -34,7 +34,7 @@ service::FieldResult> Subscription::getNextAppointm throw std::runtime_error(R"ex(Subscription::getNextAppointmentChange is not implemented)ex"); } -std::future Subscription::resolveNextAppointmentChange(service::ResolverParams&& params) +service::AwaitableResolver Subscription::resolveNextAppointmentChange(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -49,7 +49,7 @@ service::FieldResult> Subscription::getNodeChan throw std::runtime_error(R"ex(Subscription::getNodeChange is not implemented)ex"); } -std::future Subscription::resolveNodeChange(service::ResolverParams&& params) +service::AwaitableResolver Subscription::resolveNodeChange(service::ResolverParams&& params) { auto argId = service::ModifiedArgument::require("id", params.arguments); std::unique_lock resolverLock(_resolverMutex); @@ -60,7 +60,7 @@ std::future Subscription::resolveNodeChange(service::Re return service::ModifiedResult::convert(std::move(result), std::move(params)); } -std::future Subscription::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver Subscription::resolve_typename(service::ResolverParams&& params) { return service::ModifiedResult::convert(response::StringType{ R"gql(Subscription)gql" }, std::move(params)); } diff --git a/samples/separate/SubscriptionObject.h b/samples/separate/SubscriptionObject.h index b3aa3aa0..819ebc7a 100644 --- a/samples/separate/SubscriptionObject.h +++ b/samples/separate/SubscriptionObject.h @@ -23,10 +23,10 @@ class Subscription virtual service::FieldResult> getNodeChange(service::FieldParams&& params, response::IdType&& idArg) const; private: - std::future resolveNextAppointmentChange(service::ResolverParams&& params); - std::future resolveNodeChange(service::ResolverParams&& params); + service::AwaitableResolver resolveNextAppointmentChange(service::ResolverParams&& params); + service::AwaitableResolver resolveNodeChange(service::ResolverParams&& params); - std::future resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params); }; } // namespace graphql::today::object diff --git a/samples/separate/TaskConnectionObject.cpp b/samples/separate/TaskConnectionObject.cpp index e1eee585..e5da2c67 100644 --- a/samples/separate/TaskConnectionObject.cpp +++ b/samples/separate/TaskConnectionObject.cpp @@ -34,7 +34,7 @@ service::FieldResult> TaskConnection::getPageInfo(serv throw std::runtime_error(R"ex(TaskConnection::getPageInfo is not implemented)ex"); } -std::future TaskConnection::resolvePageInfo(service::ResolverParams&& params) +service::AwaitableResolver TaskConnection::resolvePageInfo(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -49,7 +49,7 @@ service::FieldResult>>> Task throw std::runtime_error(R"ex(TaskConnection::getEdges is not implemented)ex"); } -std::future TaskConnection::resolveEdges(service::ResolverParams&& params) +service::AwaitableResolver TaskConnection::resolveEdges(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -59,7 +59,7 @@ std::future TaskConnection::resolveEdges(service::Resol return service::ModifiedResult::convert(std::move(result), std::move(params)); } -std::future TaskConnection::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver TaskConnection::resolve_typename(service::ResolverParams&& params) { return service::ModifiedResult::convert(response::StringType{ R"gql(TaskConnection)gql" }, std::move(params)); } diff --git a/samples/separate/TaskConnectionObject.h b/samples/separate/TaskConnectionObject.h index d40a1e73..c8a79517 100644 --- a/samples/separate/TaskConnectionObject.h +++ b/samples/separate/TaskConnectionObject.h @@ -23,10 +23,10 @@ class TaskConnection virtual service::FieldResult>>> getEdges(service::FieldParams&& params) const; private: - std::future resolvePageInfo(service::ResolverParams&& params); - std::future resolveEdges(service::ResolverParams&& params); + service::AwaitableResolver resolvePageInfo(service::ResolverParams&& params); + service::AwaitableResolver resolveEdges(service::ResolverParams&& params); - std::future resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params); }; } // namespace graphql::today::object diff --git a/samples/separate/TaskEdgeObject.cpp b/samples/separate/TaskEdgeObject.cpp index 631aaad4..9cdb491f 100644 --- a/samples/separate/TaskEdgeObject.cpp +++ b/samples/separate/TaskEdgeObject.cpp @@ -34,7 +34,7 @@ service::FieldResult> TaskEdge::getNode(service::FieldPara throw std::runtime_error(R"ex(TaskEdge::getNode is not implemented)ex"); } -std::future TaskEdge::resolveNode(service::ResolverParams&& params) +service::AwaitableResolver TaskEdge::resolveNode(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -49,7 +49,7 @@ service::FieldResult TaskEdge::getCursor(service::FieldParams&& throw std::runtime_error(R"ex(TaskEdge::getCursor is not implemented)ex"); } -std::future TaskEdge::resolveCursor(service::ResolverParams&& params) +service::AwaitableResolver TaskEdge::resolveCursor(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -59,7 +59,7 @@ std::future TaskEdge::resolveCursor(service::ResolverPa return service::ModifiedResult::convert(std::move(result), std::move(params)); } -std::future TaskEdge::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver TaskEdge::resolve_typename(service::ResolverParams&& params) { return service::ModifiedResult::convert(response::StringType{ R"gql(TaskEdge)gql" }, std::move(params)); } diff --git a/samples/separate/TaskEdgeObject.h b/samples/separate/TaskEdgeObject.h index f14b4227..903ff369 100644 --- a/samples/separate/TaskEdgeObject.h +++ b/samples/separate/TaskEdgeObject.h @@ -23,10 +23,10 @@ class TaskEdge virtual service::FieldResult getCursor(service::FieldParams&& params) const; private: - std::future resolveNode(service::ResolverParams&& params); - std::future resolveCursor(service::ResolverParams&& params); + service::AwaitableResolver resolveNode(service::ResolverParams&& params); + service::AwaitableResolver resolveCursor(service::ResolverParams&& params); - std::future resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params); }; } // namespace graphql::today::object diff --git a/samples/separate/TaskObject.cpp b/samples/separate/TaskObject.cpp index 06e9492d..c65cbf0e 100644 --- a/samples/separate/TaskObject.cpp +++ b/samples/separate/TaskObject.cpp @@ -37,7 +37,7 @@ service::FieldResult Task::getId(service::FieldParams&&) const throw std::runtime_error(R"ex(Task::getId is not implemented)ex"); } -std::future Task::resolveId(service::ResolverParams&& params) +service::AwaitableResolver Task::resolveId(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -52,7 +52,7 @@ service::FieldResult> Task::getTitle(service throw std::runtime_error(R"ex(Task::getTitle is not implemented)ex"); } -std::future Task::resolveTitle(service::ResolverParams&& params) +service::AwaitableResolver Task::resolveTitle(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -67,7 +67,7 @@ service::FieldResult Task::getIsComplete(service::FieldPa throw std::runtime_error(R"ex(Task::getIsComplete is not implemented)ex"); } -std::future Task::resolveIsComplete(service::ResolverParams&& params) +service::AwaitableResolver Task::resolveIsComplete(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -77,7 +77,7 @@ std::future Task::resolveIsComplete(service::ResolverPa return service::ModifiedResult::convert(std::move(result), std::move(params)); } -std::future Task::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver Task::resolve_typename(service::ResolverParams&& params) { return service::ModifiedResult::convert(response::StringType{ R"gql(Task)gql" }, std::move(params)); } diff --git a/samples/separate/TaskObject.h b/samples/separate/TaskObject.h index f98c21ac..c6a52bd7 100644 --- a/samples/separate/TaskObject.h +++ b/samples/separate/TaskObject.h @@ -25,11 +25,11 @@ class Task virtual service::FieldResult getIsComplete(service::FieldParams&& params) const; private: - std::future resolveId(service::ResolverParams&& params); - std::future resolveTitle(service::ResolverParams&& params); - std::future resolveIsComplete(service::ResolverParams&& params); + service::AwaitableResolver resolveId(service::ResolverParams&& params); + service::AwaitableResolver resolveTitle(service::ResolverParams&& params); + service::AwaitableResolver resolveIsComplete(service::ResolverParams&& params); - std::future resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params); }; } // namespace graphql::today::object diff --git a/samples/separate/TodaySchema.cpp b/samples/separate/TodaySchema.cpp index 07b69b6f..2c9edbac 100644 --- a/samples/separate/TodaySchema.cpp +++ b/samples/separate/TodaySchema.cpp @@ -47,7 +47,7 @@ today::TaskState ModifiedArgument::convert(const response::Val } template <> -std::future ModifiedResult::convert(service::FieldResult&& result, ResolverParams&& params) +service::AwaitableResolver ModifiedResult::convert(service::FieldResult&& result, ResolverParams&& params) { return resolve(std::move(result), std::move(params), [](today::TaskState value, const ResolverParams&) diff --git a/samples/separate_nointrospection/AppointmentConnectionObject.cpp b/samples/separate_nointrospection/AppointmentConnectionObject.cpp index 59001226..0fa13769 100644 --- a/samples/separate_nointrospection/AppointmentConnectionObject.cpp +++ b/samples/separate_nointrospection/AppointmentConnectionObject.cpp @@ -34,7 +34,7 @@ service::FieldResult> AppointmentConnection::getPageIn throw std::runtime_error(R"ex(AppointmentConnection::getPageInfo is not implemented)ex"); } -std::future AppointmentConnection::resolvePageInfo(service::ResolverParams&& params) +service::AwaitableResolver AppointmentConnection::resolvePageInfo(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -49,7 +49,7 @@ service::FieldResult> throw std::runtime_error(R"ex(AppointmentConnection::getEdges is not implemented)ex"); } -std::future AppointmentConnection::resolveEdges(service::ResolverParams&& params) +service::AwaitableResolver AppointmentConnection::resolveEdges(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -59,7 +59,7 @@ std::future AppointmentConnection::resolveEdges(service return service::ModifiedResult::convert(std::move(result), std::move(params)); } -std::future AppointmentConnection::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver AppointmentConnection::resolve_typename(service::ResolverParams&& params) { return service::ModifiedResult::convert(response::StringType{ R"gql(AppointmentConnection)gql" }, std::move(params)); } diff --git a/samples/separate_nointrospection/AppointmentConnectionObject.h b/samples/separate_nointrospection/AppointmentConnectionObject.h index 76886da5..ff7a67a3 100644 --- a/samples/separate_nointrospection/AppointmentConnectionObject.h +++ b/samples/separate_nointrospection/AppointmentConnectionObject.h @@ -23,10 +23,10 @@ class AppointmentConnection virtual service::FieldResult>>> getEdges(service::FieldParams&& params) const; private: - std::future resolvePageInfo(service::ResolverParams&& params); - std::future resolveEdges(service::ResolverParams&& params); + service::AwaitableResolver resolvePageInfo(service::ResolverParams&& params); + service::AwaitableResolver resolveEdges(service::ResolverParams&& params); - std::future resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params); }; } // namespace graphql::today::object diff --git a/samples/separate_nointrospection/AppointmentEdgeObject.cpp b/samples/separate_nointrospection/AppointmentEdgeObject.cpp index 3fc6c5af..588dfeb0 100644 --- a/samples/separate_nointrospection/AppointmentEdgeObject.cpp +++ b/samples/separate_nointrospection/AppointmentEdgeObject.cpp @@ -34,7 +34,7 @@ service::FieldResult> AppointmentEdge::getNode(serv throw std::runtime_error(R"ex(AppointmentEdge::getNode is not implemented)ex"); } -std::future AppointmentEdge::resolveNode(service::ResolverParams&& params) +service::AwaitableResolver AppointmentEdge::resolveNode(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -49,7 +49,7 @@ service::FieldResult AppointmentEdge::getCursor(service::FieldP throw std::runtime_error(R"ex(AppointmentEdge::getCursor is not implemented)ex"); } -std::future AppointmentEdge::resolveCursor(service::ResolverParams&& params) +service::AwaitableResolver AppointmentEdge::resolveCursor(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -59,7 +59,7 @@ std::future AppointmentEdge::resolveCursor(service::Res return service::ModifiedResult::convert(std::move(result), std::move(params)); } -std::future AppointmentEdge::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver AppointmentEdge::resolve_typename(service::ResolverParams&& params) { return service::ModifiedResult::convert(response::StringType{ R"gql(AppointmentEdge)gql" }, std::move(params)); } diff --git a/samples/separate_nointrospection/AppointmentEdgeObject.h b/samples/separate_nointrospection/AppointmentEdgeObject.h index 6b939423..f8a5236e 100644 --- a/samples/separate_nointrospection/AppointmentEdgeObject.h +++ b/samples/separate_nointrospection/AppointmentEdgeObject.h @@ -23,10 +23,10 @@ class AppointmentEdge virtual service::FieldResult getCursor(service::FieldParams&& params) const; private: - std::future resolveNode(service::ResolverParams&& params); - std::future resolveCursor(service::ResolverParams&& params); + service::AwaitableResolver resolveNode(service::ResolverParams&& params); + service::AwaitableResolver resolveCursor(service::ResolverParams&& params); - std::future resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params); }; } // namespace graphql::today::object diff --git a/samples/separate_nointrospection/AppointmentObject.cpp b/samples/separate_nointrospection/AppointmentObject.cpp index 9cc0282a..7b156a39 100644 --- a/samples/separate_nointrospection/AppointmentObject.cpp +++ b/samples/separate_nointrospection/AppointmentObject.cpp @@ -39,7 +39,7 @@ service::FieldResult Appointment::getId(service::FieldParams&& throw std::runtime_error(R"ex(Appointment::getId is not implemented)ex"); } -std::future Appointment::resolveId(service::ResolverParams&& params) +service::AwaitableResolver Appointment::resolveId(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -54,7 +54,7 @@ service::FieldResult> Appointment::getWhen(servic throw std::runtime_error(R"ex(Appointment::getWhen is not implemented)ex"); } -std::future Appointment::resolveWhen(service::ResolverParams&& params) +service::AwaitableResolver Appointment::resolveWhen(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -69,7 +69,7 @@ service::FieldResult> Appointment::getSubjec throw std::runtime_error(R"ex(Appointment::getSubject is not implemented)ex"); } -std::future Appointment::resolveSubject(service::ResolverParams&& params) +service::AwaitableResolver Appointment::resolveSubject(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -84,7 +84,7 @@ service::FieldResult Appointment::getIsNow(service::Field throw std::runtime_error(R"ex(Appointment::getIsNow is not implemented)ex"); } -std::future Appointment::resolveIsNow(service::ResolverParams&& params) +service::AwaitableResolver Appointment::resolveIsNow(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -99,7 +99,7 @@ service::FieldResult> Appointment::getForceE throw std::runtime_error(R"ex(Appointment::getForceError is not implemented)ex"); } -std::future Appointment::resolveForceError(service::ResolverParams&& params) +service::AwaitableResolver Appointment::resolveForceError(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -109,7 +109,7 @@ std::future Appointment::resolveForceError(service::Res return service::ModifiedResult::convert(std::move(result), std::move(params)); } -std::future Appointment::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver Appointment::resolve_typename(service::ResolverParams&& params) { return service::ModifiedResult::convert(response::StringType{ R"gql(Appointment)gql" }, std::move(params)); } diff --git a/samples/separate_nointrospection/AppointmentObject.h b/samples/separate_nointrospection/AppointmentObject.h index 58c7763b..e7f710ac 100644 --- a/samples/separate_nointrospection/AppointmentObject.h +++ b/samples/separate_nointrospection/AppointmentObject.h @@ -27,13 +27,13 @@ class Appointment virtual service::FieldResult> getForceError(service::FieldParams&& params) const; private: - std::future resolveId(service::ResolverParams&& params); - std::future resolveWhen(service::ResolverParams&& params); - std::future resolveSubject(service::ResolverParams&& params); - std::future resolveIsNow(service::ResolverParams&& params); - std::future resolveForceError(service::ResolverParams&& params); + service::AwaitableResolver resolveId(service::ResolverParams&& params); + service::AwaitableResolver resolveWhen(service::ResolverParams&& params); + service::AwaitableResolver resolveSubject(service::ResolverParams&& params); + service::AwaitableResolver resolveIsNow(service::ResolverParams&& params); + service::AwaitableResolver resolveForceError(service::ResolverParams&& params); - std::future resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params); }; } // namespace graphql::today::object diff --git a/samples/separate_nointrospection/CompleteTaskPayloadObject.cpp b/samples/separate_nointrospection/CompleteTaskPayloadObject.cpp index 130d0075..d3a742ac 100644 --- a/samples/separate_nointrospection/CompleteTaskPayloadObject.cpp +++ b/samples/separate_nointrospection/CompleteTaskPayloadObject.cpp @@ -34,7 +34,7 @@ service::FieldResult> CompleteTaskPayload::getTask(service throw std::runtime_error(R"ex(CompleteTaskPayload::getTask is not implemented)ex"); } -std::future CompleteTaskPayload::resolveTask(service::ResolverParams&& params) +service::AwaitableResolver CompleteTaskPayload::resolveTask(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -49,7 +49,7 @@ service::FieldResult> CompleteTaskPayload::g throw std::runtime_error(R"ex(CompleteTaskPayload::getClientMutationId is not implemented)ex"); } -std::future CompleteTaskPayload::resolveClientMutationId(service::ResolverParams&& params) +service::AwaitableResolver CompleteTaskPayload::resolveClientMutationId(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -59,7 +59,7 @@ std::future CompleteTaskPayload::resolveClientMutationI return service::ModifiedResult::convert(std::move(result), std::move(params)); } -std::future CompleteTaskPayload::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver CompleteTaskPayload::resolve_typename(service::ResolverParams&& params) { return service::ModifiedResult::convert(response::StringType{ R"gql(CompleteTaskPayload)gql" }, std::move(params)); } diff --git a/samples/separate_nointrospection/CompleteTaskPayloadObject.h b/samples/separate_nointrospection/CompleteTaskPayloadObject.h index a88b53a3..c44afd16 100644 --- a/samples/separate_nointrospection/CompleteTaskPayloadObject.h +++ b/samples/separate_nointrospection/CompleteTaskPayloadObject.h @@ -23,10 +23,10 @@ class CompleteTaskPayload virtual service::FieldResult> getClientMutationId(service::FieldParams&& params) const; private: - std::future resolveTask(service::ResolverParams&& params); - std::future resolveClientMutationId(service::ResolverParams&& params); + service::AwaitableResolver resolveTask(service::ResolverParams&& params); + service::AwaitableResolver resolveClientMutationId(service::ResolverParams&& params); - std::future resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params); }; } // namespace graphql::today::object diff --git a/samples/separate_nointrospection/ExpensiveObject.cpp b/samples/separate_nointrospection/ExpensiveObject.cpp index 7785d77f..2bc006c6 100644 --- a/samples/separate_nointrospection/ExpensiveObject.cpp +++ b/samples/separate_nointrospection/ExpensiveObject.cpp @@ -33,7 +33,7 @@ service::FieldResult Expensive::getOrder(service::FieldParams throw std::runtime_error(R"ex(Expensive::getOrder is not implemented)ex"); } -std::future Expensive::resolveOrder(service::ResolverParams&& params) +service::AwaitableResolver Expensive::resolveOrder(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -43,7 +43,7 @@ std::future Expensive::resolveOrder(service::ResolverPa return service::ModifiedResult::convert(std::move(result), std::move(params)); } -std::future Expensive::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver Expensive::resolve_typename(service::ResolverParams&& params) { return service::ModifiedResult::convert(response::StringType{ R"gql(Expensive)gql" }, std::move(params)); } diff --git a/samples/separate_nointrospection/ExpensiveObject.h b/samples/separate_nointrospection/ExpensiveObject.h index 791b4292..4c30bba0 100644 --- a/samples/separate_nointrospection/ExpensiveObject.h +++ b/samples/separate_nointrospection/ExpensiveObject.h @@ -22,9 +22,9 @@ class Expensive virtual service::FieldResult getOrder(service::FieldParams&& params) const; private: - std::future resolveOrder(service::ResolverParams&& params); + service::AwaitableResolver resolveOrder(service::ResolverParams&& params); - std::future resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params); }; } // namespace graphql::today::object diff --git a/samples/separate_nointrospection/FolderConnectionObject.cpp b/samples/separate_nointrospection/FolderConnectionObject.cpp index 3380f997..2d7ac269 100644 --- a/samples/separate_nointrospection/FolderConnectionObject.cpp +++ b/samples/separate_nointrospection/FolderConnectionObject.cpp @@ -34,7 +34,7 @@ service::FieldResult> FolderConnection::getPageInfo(se throw std::runtime_error(R"ex(FolderConnection::getPageInfo is not implemented)ex"); } -std::future FolderConnection::resolvePageInfo(service::ResolverParams&& params) +service::AwaitableResolver FolderConnection::resolvePageInfo(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -49,7 +49,7 @@ service::FieldResult>>> Fo throw std::runtime_error(R"ex(FolderConnection::getEdges is not implemented)ex"); } -std::future FolderConnection::resolveEdges(service::ResolverParams&& params) +service::AwaitableResolver FolderConnection::resolveEdges(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -59,7 +59,7 @@ std::future FolderConnection::resolveEdges(service::Res return service::ModifiedResult::convert(std::move(result), std::move(params)); } -std::future FolderConnection::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver FolderConnection::resolve_typename(service::ResolverParams&& params) { return service::ModifiedResult::convert(response::StringType{ R"gql(FolderConnection)gql" }, std::move(params)); } diff --git a/samples/separate_nointrospection/FolderConnectionObject.h b/samples/separate_nointrospection/FolderConnectionObject.h index aec397d4..74477723 100644 --- a/samples/separate_nointrospection/FolderConnectionObject.h +++ b/samples/separate_nointrospection/FolderConnectionObject.h @@ -23,10 +23,10 @@ class FolderConnection virtual service::FieldResult>>> getEdges(service::FieldParams&& params) const; private: - std::future resolvePageInfo(service::ResolverParams&& params); - std::future resolveEdges(service::ResolverParams&& params); + service::AwaitableResolver resolvePageInfo(service::ResolverParams&& params); + service::AwaitableResolver resolveEdges(service::ResolverParams&& params); - std::future resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params); }; } // namespace graphql::today::object diff --git a/samples/separate_nointrospection/FolderEdgeObject.cpp b/samples/separate_nointrospection/FolderEdgeObject.cpp index 7c641ce5..06672e4b 100644 --- a/samples/separate_nointrospection/FolderEdgeObject.cpp +++ b/samples/separate_nointrospection/FolderEdgeObject.cpp @@ -34,7 +34,7 @@ service::FieldResult> FolderEdge::getNode(service::Field throw std::runtime_error(R"ex(FolderEdge::getNode is not implemented)ex"); } -std::future FolderEdge::resolveNode(service::ResolverParams&& params) +service::AwaitableResolver FolderEdge::resolveNode(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -49,7 +49,7 @@ service::FieldResult FolderEdge::getCursor(service::FieldParams throw std::runtime_error(R"ex(FolderEdge::getCursor is not implemented)ex"); } -std::future FolderEdge::resolveCursor(service::ResolverParams&& params) +service::AwaitableResolver FolderEdge::resolveCursor(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -59,7 +59,7 @@ std::future FolderEdge::resolveCursor(service::Resolver return service::ModifiedResult::convert(std::move(result), std::move(params)); } -std::future FolderEdge::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver FolderEdge::resolve_typename(service::ResolverParams&& params) { return service::ModifiedResult::convert(response::StringType{ R"gql(FolderEdge)gql" }, std::move(params)); } diff --git a/samples/separate_nointrospection/FolderEdgeObject.h b/samples/separate_nointrospection/FolderEdgeObject.h index 00fbd677..52ab2627 100644 --- a/samples/separate_nointrospection/FolderEdgeObject.h +++ b/samples/separate_nointrospection/FolderEdgeObject.h @@ -23,10 +23,10 @@ class FolderEdge virtual service::FieldResult getCursor(service::FieldParams&& params) const; private: - std::future resolveNode(service::ResolverParams&& params); - std::future resolveCursor(service::ResolverParams&& params); + service::AwaitableResolver resolveNode(service::ResolverParams&& params); + service::AwaitableResolver resolveCursor(service::ResolverParams&& params); - std::future resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params); }; } // namespace graphql::today::object diff --git a/samples/separate_nointrospection/FolderObject.cpp b/samples/separate_nointrospection/FolderObject.cpp index d5c6b517..3fadea37 100644 --- a/samples/separate_nointrospection/FolderObject.cpp +++ b/samples/separate_nointrospection/FolderObject.cpp @@ -37,7 +37,7 @@ service::FieldResult Folder::getId(service::FieldParams&&) con throw std::runtime_error(R"ex(Folder::getId is not implemented)ex"); } -std::future Folder::resolveId(service::ResolverParams&& params) +service::AwaitableResolver Folder::resolveId(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -52,7 +52,7 @@ service::FieldResult> Folder::getName(servic throw std::runtime_error(R"ex(Folder::getName is not implemented)ex"); } -std::future Folder::resolveName(service::ResolverParams&& params) +service::AwaitableResolver Folder::resolveName(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -67,7 +67,7 @@ service::FieldResult Folder::getUnreadCount(service::FieldPar throw std::runtime_error(R"ex(Folder::getUnreadCount is not implemented)ex"); } -std::future Folder::resolveUnreadCount(service::ResolverParams&& params) +service::AwaitableResolver Folder::resolveUnreadCount(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -77,7 +77,7 @@ std::future Folder::resolveUnreadCount(service::Resolve return service::ModifiedResult::convert(std::move(result), std::move(params)); } -std::future Folder::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver Folder::resolve_typename(service::ResolverParams&& params) { return service::ModifiedResult::convert(response::StringType{ R"gql(Folder)gql" }, std::move(params)); } diff --git a/samples/separate_nointrospection/FolderObject.h b/samples/separate_nointrospection/FolderObject.h index e11053bf..abd48918 100644 --- a/samples/separate_nointrospection/FolderObject.h +++ b/samples/separate_nointrospection/FolderObject.h @@ -25,11 +25,11 @@ class Folder virtual service::FieldResult getUnreadCount(service::FieldParams&& params) const; private: - std::future resolveId(service::ResolverParams&& params); - std::future resolveName(service::ResolverParams&& params); - std::future resolveUnreadCount(service::ResolverParams&& params); + service::AwaitableResolver resolveId(service::ResolverParams&& params); + service::AwaitableResolver resolveName(service::ResolverParams&& params); + service::AwaitableResolver resolveUnreadCount(service::ResolverParams&& params); - std::future resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params); }; } // namespace graphql::today::object diff --git a/samples/separate_nointrospection/MutationObject.cpp b/samples/separate_nointrospection/MutationObject.cpp index c5f9d236..aa8d858b 100644 --- a/samples/separate_nointrospection/MutationObject.cpp +++ b/samples/separate_nointrospection/MutationObject.cpp @@ -34,7 +34,7 @@ service::FieldResult> Mutation::applyComple throw std::runtime_error(R"ex(Mutation::applyCompleteTask is not implemented)ex"); } -std::future Mutation::resolveCompleteTask(service::ResolverParams&& params) +service::AwaitableResolver Mutation::resolveCompleteTask(service::ResolverParams&& params) { auto argInput = service::ModifiedArgument::require("input", params.arguments); std::unique_lock resolverLock(_resolverMutex); @@ -50,7 +50,7 @@ service::FieldResult Mutation::applySetFloat(service::Field throw std::runtime_error(R"ex(Mutation::applySetFloat is not implemented)ex"); } -std::future Mutation::resolveSetFloat(service::ResolverParams&& params) +service::AwaitableResolver Mutation::resolveSetFloat(service::ResolverParams&& params) { auto argValue = service::ModifiedArgument::require("value", params.arguments); std::unique_lock resolverLock(_resolverMutex); @@ -61,7 +61,7 @@ std::future Mutation::resolveSetFloat(service::Resolver return service::ModifiedResult::convert(std::move(result), std::move(params)); } -std::future Mutation::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver Mutation::resolve_typename(service::ResolverParams&& params) { return service::ModifiedResult::convert(response::StringType{ R"gql(Mutation)gql" }, std::move(params)); } diff --git a/samples/separate_nointrospection/MutationObject.h b/samples/separate_nointrospection/MutationObject.h index c5ab3977..b72577ea 100644 --- a/samples/separate_nointrospection/MutationObject.h +++ b/samples/separate_nointrospection/MutationObject.h @@ -23,10 +23,10 @@ class Mutation virtual service::FieldResult applySetFloat(service::FieldParams&& params, response::FloatType&& valueArg) const; private: - std::future resolveCompleteTask(service::ResolverParams&& params); - std::future resolveSetFloat(service::ResolverParams&& params); + service::AwaitableResolver resolveCompleteTask(service::ResolverParams&& params); + service::AwaitableResolver resolveSetFloat(service::ResolverParams&& params); - std::future resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params); }; } // namespace graphql::today::object diff --git a/samples/separate_nointrospection/NestedTypeObject.cpp b/samples/separate_nointrospection/NestedTypeObject.cpp index ffb3d909..be7f9b6a 100644 --- a/samples/separate_nointrospection/NestedTypeObject.cpp +++ b/samples/separate_nointrospection/NestedTypeObject.cpp @@ -34,7 +34,7 @@ service::FieldResult NestedType::getDepth(service::FieldParam throw std::runtime_error(R"ex(NestedType::getDepth is not implemented)ex"); } -std::future NestedType::resolveDepth(service::ResolverParams&& params) +service::AwaitableResolver NestedType::resolveDepth(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -49,7 +49,7 @@ service::FieldResult> NestedType::getNested(service: throw std::runtime_error(R"ex(NestedType::getNested is not implemented)ex"); } -std::future NestedType::resolveNested(service::ResolverParams&& params) +service::AwaitableResolver NestedType::resolveNested(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -59,7 +59,7 @@ std::future NestedType::resolveNested(service::Resolver return service::ModifiedResult::convert(std::move(result), std::move(params)); } -std::future NestedType::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver NestedType::resolve_typename(service::ResolverParams&& params) { return service::ModifiedResult::convert(response::StringType{ R"gql(NestedType)gql" }, std::move(params)); } diff --git a/samples/separate_nointrospection/NestedTypeObject.h b/samples/separate_nointrospection/NestedTypeObject.h index 94cb2418..eb06cf04 100644 --- a/samples/separate_nointrospection/NestedTypeObject.h +++ b/samples/separate_nointrospection/NestedTypeObject.h @@ -23,10 +23,10 @@ class NestedType virtual service::FieldResult> getNested(service::FieldParams&& params) const; private: - std::future resolveDepth(service::ResolverParams&& params); - std::future resolveNested(service::ResolverParams&& params); + service::AwaitableResolver resolveDepth(service::ResolverParams&& params); + service::AwaitableResolver resolveNested(service::ResolverParams&& params); - std::future resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params); }; } // namespace graphql::today::object diff --git a/samples/separate_nointrospection/PageInfoObject.cpp b/samples/separate_nointrospection/PageInfoObject.cpp index 8c27b393..900d73a5 100644 --- a/samples/separate_nointrospection/PageInfoObject.cpp +++ b/samples/separate_nointrospection/PageInfoObject.cpp @@ -34,7 +34,7 @@ service::FieldResult PageInfo::getHasNextPage(service::Fi throw std::runtime_error(R"ex(PageInfo::getHasNextPage is not implemented)ex"); } -std::future PageInfo::resolveHasNextPage(service::ResolverParams&& params) +service::AwaitableResolver PageInfo::resolveHasNextPage(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -49,7 +49,7 @@ service::FieldResult PageInfo::getHasPreviousPage(service throw std::runtime_error(R"ex(PageInfo::getHasPreviousPage is not implemented)ex"); } -std::future PageInfo::resolveHasPreviousPage(service::ResolverParams&& params) +service::AwaitableResolver PageInfo::resolveHasPreviousPage(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -59,7 +59,7 @@ std::future PageInfo::resolveHasPreviousPage(service::R return service::ModifiedResult::convert(std::move(result), std::move(params)); } -std::future PageInfo::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver PageInfo::resolve_typename(service::ResolverParams&& params) { return service::ModifiedResult::convert(response::StringType{ R"gql(PageInfo)gql" }, std::move(params)); } diff --git a/samples/separate_nointrospection/PageInfoObject.h b/samples/separate_nointrospection/PageInfoObject.h index 337cbd4a..b2d3a844 100644 --- a/samples/separate_nointrospection/PageInfoObject.h +++ b/samples/separate_nointrospection/PageInfoObject.h @@ -23,10 +23,10 @@ class PageInfo virtual service::FieldResult getHasPreviousPage(service::FieldParams&& params) const; private: - std::future resolveHasNextPage(service::ResolverParams&& params); - std::future resolveHasPreviousPage(service::ResolverParams&& params); + service::AwaitableResolver resolveHasNextPage(service::ResolverParams&& params); + service::AwaitableResolver resolveHasPreviousPage(service::ResolverParams&& params); - std::future resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params); }; } // namespace graphql::today::object diff --git a/samples/separate_nointrospection/QueryObject.cpp b/samples/separate_nointrospection/QueryObject.cpp index b4c19b3b..d3e98cb7 100644 --- a/samples/separate_nointrospection/QueryObject.cpp +++ b/samples/separate_nointrospection/QueryObject.cpp @@ -44,7 +44,7 @@ service::FieldResult> Query::getNode(service::F throw std::runtime_error(R"ex(Query::getNode is not implemented)ex"); } -std::future Query::resolveNode(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveNode(service::ResolverParams&& params) { auto argId = service::ModifiedArgument::require("id", params.arguments); std::unique_lock resolverLock(_resolverMutex); @@ -60,7 +60,7 @@ service::FieldResult> Query::getAppointme throw std::runtime_error(R"ex(Query::getAppointments is not implemented)ex"); } -std::future Query::resolveAppointments(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveAppointments(service::ResolverParams&& params) { auto argFirst = service::ModifiedArgument::require("first", params.arguments); auto argAfter = service::ModifiedArgument::require("after", params.arguments); @@ -79,7 +79,7 @@ service::FieldResult> Query::getTasks(service::F throw std::runtime_error(R"ex(Query::getTasks is not implemented)ex"); } -std::future Query::resolveTasks(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveTasks(service::ResolverParams&& params) { auto argFirst = service::ModifiedArgument::require("first", params.arguments); auto argAfter = service::ModifiedArgument::require("after", params.arguments); @@ -98,7 +98,7 @@ service::FieldResult> Query::getUnreadCounts(s throw std::runtime_error(R"ex(Query::getUnreadCounts is not implemented)ex"); } -std::future Query::resolveUnreadCounts(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveUnreadCounts(service::ResolverParams&& params) { auto argFirst = service::ModifiedArgument::require("first", params.arguments); auto argAfter = service::ModifiedArgument::require("after", params.arguments); @@ -117,7 +117,7 @@ service::FieldResult>> Query::getAppoin throw std::runtime_error(R"ex(Query::getAppointmentsById is not implemented)ex"); } -std::future Query::resolveAppointmentsById(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveAppointmentsById(service::ResolverParams&& params) { const auto defaultArguments = []() { @@ -155,7 +155,7 @@ service::FieldResult>> Query::getTasksById(ser throw std::runtime_error(R"ex(Query::getTasksById is not implemented)ex"); } -std::future Query::resolveTasksById(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveTasksById(service::ResolverParams&& params) { auto argIds = service::ModifiedArgument::require("ids", params.arguments); std::unique_lock resolverLock(_resolverMutex); @@ -171,7 +171,7 @@ service::FieldResult>> Query::getUnreadCount throw std::runtime_error(R"ex(Query::getUnreadCountsById is not implemented)ex"); } -std::future Query::resolveUnreadCountsById(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveUnreadCountsById(service::ResolverParams&& params) { auto argIds = service::ModifiedArgument::require("ids", params.arguments); std::unique_lock resolverLock(_resolverMutex); @@ -187,7 +187,7 @@ service::FieldResult> Query::getNested(service::Fiel throw std::runtime_error(R"ex(Query::getNested is not implemented)ex"); } -std::future Query::resolveNested(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveNested(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -202,7 +202,7 @@ service::FieldResult Query::getUnimplemented(service::Fiel throw std::runtime_error(R"ex(Query::getUnimplemented is not implemented)ex"); } -std::future Query::resolveUnimplemented(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveUnimplemented(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -217,7 +217,7 @@ service::FieldResult>> Query::getExpensiv throw std::runtime_error(R"ex(Query::getExpensive is not implemented)ex"); } -std::future Query::resolveExpensive(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveExpensive(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -232,7 +232,7 @@ service::FieldResult Query::getTestTaskState(service::FieldParams&&) throw std::runtime_error(R"ex(Query::getTestTaskState is not implemented)ex"); } -std::future Query::resolveTestTaskState(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveTestTaskState(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -247,7 +247,7 @@ service::FieldResult>> Query::getAn throw std::runtime_error(R"ex(Query::getAnyType is not implemented)ex"); } -std::future Query::resolveAnyType(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveAnyType(service::ResolverParams&& params) { auto argIds = service::ModifiedArgument::require("ids", params.arguments); std::unique_lock resolverLock(_resolverMutex); @@ -258,7 +258,7 @@ std::future Query::resolveAnyType(service::ResolverPara return service::ModifiedResult::convert(std::move(result), std::move(params)); } -std::future Query::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver Query::resolve_typename(service::ResolverParams&& params) { return service::ModifiedResult::convert(response::StringType{ R"gql(Query)gql" }, std::move(params)); } diff --git a/samples/separate_nointrospection/QueryObject.h b/samples/separate_nointrospection/QueryObject.h index 91da5182..3390090b 100644 --- a/samples/separate_nointrospection/QueryObject.h +++ b/samples/separate_nointrospection/QueryObject.h @@ -33,20 +33,20 @@ class Query virtual service::FieldResult>> getAnyType(service::FieldParams&& params, std::vector&& idsArg) const; private: - std::future resolveNode(service::ResolverParams&& params); - std::future resolveAppointments(service::ResolverParams&& params); - std::future resolveTasks(service::ResolverParams&& params); - std::future resolveUnreadCounts(service::ResolverParams&& params); - std::future resolveAppointmentsById(service::ResolverParams&& params); - std::future resolveTasksById(service::ResolverParams&& params); - std::future resolveUnreadCountsById(service::ResolverParams&& params); - std::future resolveNested(service::ResolverParams&& params); - std::future resolveUnimplemented(service::ResolverParams&& params); - std::future resolveExpensive(service::ResolverParams&& params); - std::future resolveTestTaskState(service::ResolverParams&& params); - std::future resolveAnyType(service::ResolverParams&& params); - - std::future resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolveNode(service::ResolverParams&& params); + service::AwaitableResolver resolveAppointments(service::ResolverParams&& params); + service::AwaitableResolver resolveTasks(service::ResolverParams&& params); + service::AwaitableResolver resolveUnreadCounts(service::ResolverParams&& params); + service::AwaitableResolver resolveAppointmentsById(service::ResolverParams&& params); + service::AwaitableResolver resolveTasksById(service::ResolverParams&& params); + service::AwaitableResolver resolveUnreadCountsById(service::ResolverParams&& params); + service::AwaitableResolver resolveNested(service::ResolverParams&& params); + service::AwaitableResolver resolveUnimplemented(service::ResolverParams&& params); + service::AwaitableResolver resolveExpensive(service::ResolverParams&& params); + service::AwaitableResolver resolveTestTaskState(service::ResolverParams&& params); + service::AwaitableResolver resolveAnyType(service::ResolverParams&& params); + + service::AwaitableResolver resolve_typename(service::ResolverParams&& params); }; } // namespace graphql::today::object diff --git a/samples/separate_nointrospection/SubscriptionObject.cpp b/samples/separate_nointrospection/SubscriptionObject.cpp index 21b477be..746a6e7e 100644 --- a/samples/separate_nointrospection/SubscriptionObject.cpp +++ b/samples/separate_nointrospection/SubscriptionObject.cpp @@ -34,7 +34,7 @@ service::FieldResult> Subscription::getNextAppointm throw std::runtime_error(R"ex(Subscription::getNextAppointmentChange is not implemented)ex"); } -std::future Subscription::resolveNextAppointmentChange(service::ResolverParams&& params) +service::AwaitableResolver Subscription::resolveNextAppointmentChange(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -49,7 +49,7 @@ service::FieldResult> Subscription::getNodeChan throw std::runtime_error(R"ex(Subscription::getNodeChange is not implemented)ex"); } -std::future Subscription::resolveNodeChange(service::ResolverParams&& params) +service::AwaitableResolver Subscription::resolveNodeChange(service::ResolverParams&& params) { auto argId = service::ModifiedArgument::require("id", params.arguments); std::unique_lock resolverLock(_resolverMutex); @@ -60,7 +60,7 @@ std::future Subscription::resolveNodeChange(service::Re return service::ModifiedResult::convert(std::move(result), std::move(params)); } -std::future Subscription::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver Subscription::resolve_typename(service::ResolverParams&& params) { return service::ModifiedResult::convert(response::StringType{ R"gql(Subscription)gql" }, std::move(params)); } diff --git a/samples/separate_nointrospection/SubscriptionObject.h b/samples/separate_nointrospection/SubscriptionObject.h index b3aa3aa0..819ebc7a 100644 --- a/samples/separate_nointrospection/SubscriptionObject.h +++ b/samples/separate_nointrospection/SubscriptionObject.h @@ -23,10 +23,10 @@ class Subscription virtual service::FieldResult> getNodeChange(service::FieldParams&& params, response::IdType&& idArg) const; private: - std::future resolveNextAppointmentChange(service::ResolverParams&& params); - std::future resolveNodeChange(service::ResolverParams&& params); + service::AwaitableResolver resolveNextAppointmentChange(service::ResolverParams&& params); + service::AwaitableResolver resolveNodeChange(service::ResolverParams&& params); - std::future resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params); }; } // namespace graphql::today::object diff --git a/samples/separate_nointrospection/TaskConnectionObject.cpp b/samples/separate_nointrospection/TaskConnectionObject.cpp index e1eee585..e5da2c67 100644 --- a/samples/separate_nointrospection/TaskConnectionObject.cpp +++ b/samples/separate_nointrospection/TaskConnectionObject.cpp @@ -34,7 +34,7 @@ service::FieldResult> TaskConnection::getPageInfo(serv throw std::runtime_error(R"ex(TaskConnection::getPageInfo is not implemented)ex"); } -std::future TaskConnection::resolvePageInfo(service::ResolverParams&& params) +service::AwaitableResolver TaskConnection::resolvePageInfo(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -49,7 +49,7 @@ service::FieldResult>>> Task throw std::runtime_error(R"ex(TaskConnection::getEdges is not implemented)ex"); } -std::future TaskConnection::resolveEdges(service::ResolverParams&& params) +service::AwaitableResolver TaskConnection::resolveEdges(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -59,7 +59,7 @@ std::future TaskConnection::resolveEdges(service::Resol return service::ModifiedResult::convert(std::move(result), std::move(params)); } -std::future TaskConnection::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver TaskConnection::resolve_typename(service::ResolverParams&& params) { return service::ModifiedResult::convert(response::StringType{ R"gql(TaskConnection)gql" }, std::move(params)); } diff --git a/samples/separate_nointrospection/TaskConnectionObject.h b/samples/separate_nointrospection/TaskConnectionObject.h index d40a1e73..c8a79517 100644 --- a/samples/separate_nointrospection/TaskConnectionObject.h +++ b/samples/separate_nointrospection/TaskConnectionObject.h @@ -23,10 +23,10 @@ class TaskConnection virtual service::FieldResult>>> getEdges(service::FieldParams&& params) const; private: - std::future resolvePageInfo(service::ResolverParams&& params); - std::future resolveEdges(service::ResolverParams&& params); + service::AwaitableResolver resolvePageInfo(service::ResolverParams&& params); + service::AwaitableResolver resolveEdges(service::ResolverParams&& params); - std::future resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params); }; } // namespace graphql::today::object diff --git a/samples/separate_nointrospection/TaskEdgeObject.cpp b/samples/separate_nointrospection/TaskEdgeObject.cpp index 631aaad4..9cdb491f 100644 --- a/samples/separate_nointrospection/TaskEdgeObject.cpp +++ b/samples/separate_nointrospection/TaskEdgeObject.cpp @@ -34,7 +34,7 @@ service::FieldResult> TaskEdge::getNode(service::FieldPara throw std::runtime_error(R"ex(TaskEdge::getNode is not implemented)ex"); } -std::future TaskEdge::resolveNode(service::ResolverParams&& params) +service::AwaitableResolver TaskEdge::resolveNode(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -49,7 +49,7 @@ service::FieldResult TaskEdge::getCursor(service::FieldParams&& throw std::runtime_error(R"ex(TaskEdge::getCursor is not implemented)ex"); } -std::future TaskEdge::resolveCursor(service::ResolverParams&& params) +service::AwaitableResolver TaskEdge::resolveCursor(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -59,7 +59,7 @@ std::future TaskEdge::resolveCursor(service::ResolverPa return service::ModifiedResult::convert(std::move(result), std::move(params)); } -std::future TaskEdge::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver TaskEdge::resolve_typename(service::ResolverParams&& params) { return service::ModifiedResult::convert(response::StringType{ R"gql(TaskEdge)gql" }, std::move(params)); } diff --git a/samples/separate_nointrospection/TaskEdgeObject.h b/samples/separate_nointrospection/TaskEdgeObject.h index f14b4227..903ff369 100644 --- a/samples/separate_nointrospection/TaskEdgeObject.h +++ b/samples/separate_nointrospection/TaskEdgeObject.h @@ -23,10 +23,10 @@ class TaskEdge virtual service::FieldResult getCursor(service::FieldParams&& params) const; private: - std::future resolveNode(service::ResolverParams&& params); - std::future resolveCursor(service::ResolverParams&& params); + service::AwaitableResolver resolveNode(service::ResolverParams&& params); + service::AwaitableResolver resolveCursor(service::ResolverParams&& params); - std::future resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params); }; } // namespace graphql::today::object diff --git a/samples/separate_nointrospection/TaskObject.cpp b/samples/separate_nointrospection/TaskObject.cpp index 06e9492d..c65cbf0e 100644 --- a/samples/separate_nointrospection/TaskObject.cpp +++ b/samples/separate_nointrospection/TaskObject.cpp @@ -37,7 +37,7 @@ service::FieldResult Task::getId(service::FieldParams&&) const throw std::runtime_error(R"ex(Task::getId is not implemented)ex"); } -std::future Task::resolveId(service::ResolverParams&& params) +service::AwaitableResolver Task::resolveId(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -52,7 +52,7 @@ service::FieldResult> Task::getTitle(service throw std::runtime_error(R"ex(Task::getTitle is not implemented)ex"); } -std::future Task::resolveTitle(service::ResolverParams&& params) +service::AwaitableResolver Task::resolveTitle(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -67,7 +67,7 @@ service::FieldResult Task::getIsComplete(service::FieldPa throw std::runtime_error(R"ex(Task::getIsComplete is not implemented)ex"); } -std::future Task::resolveIsComplete(service::ResolverParams&& params) +service::AwaitableResolver Task::resolveIsComplete(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -77,7 +77,7 @@ std::future Task::resolveIsComplete(service::ResolverPa return service::ModifiedResult::convert(std::move(result), std::move(params)); } -std::future Task::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver Task::resolve_typename(service::ResolverParams&& params) { return service::ModifiedResult::convert(response::StringType{ R"gql(Task)gql" }, std::move(params)); } diff --git a/samples/separate_nointrospection/TaskObject.h b/samples/separate_nointrospection/TaskObject.h index f98c21ac..c6a52bd7 100644 --- a/samples/separate_nointrospection/TaskObject.h +++ b/samples/separate_nointrospection/TaskObject.h @@ -25,11 +25,11 @@ class Task virtual service::FieldResult getIsComplete(service::FieldParams&& params) const; private: - std::future resolveId(service::ResolverParams&& params); - std::future resolveTitle(service::ResolverParams&& params); - std::future resolveIsComplete(service::ResolverParams&& params); + service::AwaitableResolver resolveId(service::ResolverParams&& params); + service::AwaitableResolver resolveTitle(service::ResolverParams&& params); + service::AwaitableResolver resolveIsComplete(service::ResolverParams&& params); - std::future resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params); }; } // namespace graphql::today::object diff --git a/samples/separate_nointrospection/TodaySchema.cpp b/samples/separate_nointrospection/TodaySchema.cpp index a80582b6..b68a3f1b 100644 --- a/samples/separate_nointrospection/TodaySchema.cpp +++ b/samples/separate_nointrospection/TodaySchema.cpp @@ -47,7 +47,7 @@ today::TaskState ModifiedArgument::convert(const response::Val } template <> -std::future ModifiedResult::convert(service::FieldResult&& result, ResolverParams&& params) +service::AwaitableResolver ModifiedResult::convert(service::FieldResult&& result, ResolverParams&& params) { return resolve(std::move(result), std::move(params), [](today::TaskState value, const ResolverParams&) diff --git a/samples/today/TodayMock.cpp b/samples/today/TodayMock.cpp index e903e221..f3ffa4e2 100644 --- a/samples/today/TodayMock.cpp +++ b/samples/today/TodayMock.cpp @@ -4,6 +4,8 @@ #include "TodayMock.h" #include +#include +#include #include namespace graphql::today { @@ -138,9 +140,50 @@ std::shared_ptr Query::findUnreadCount( return nullptr; } +template +auto operator co_await(std::chrono::duration<_Rep, _Period> delay) +{ + struct awaiter + { + const std::chrono::duration<_Rep, _Period> delay; + std::promise promise; + + bool await_ready() const + { + std::cerr << "duration awaiter::await_ready" << std::endl; + return false; + } + + void await_suspend(coro::coroutine_handle<> h) noexcept + { + std::cerr << "duration awaiter::await_suspend" << std::endl; + std::thread([this, h]() mutable { + std::this_thread::sleep_for(delay); + promise.set_value(); + std::cerr << "duration awaiter::await_suspend: resuming" << std::endl; + h.resume(); + }).detach(); + } + + void await_resume() + { + std::cerr << "duration awaiter::await_resume: waiting" << std::endl; + promise.get_future().get(); + std::cerr << "duration awaiter::await_resume: resumed" << std::endl; + } + }; + + return awaiter { delay }; +} + service::FieldResult> Query::getNode( service::FieldParams&& params, response::IdType&& id) const { + // {node(id: "ZmFrZVRhc2tJZA=="){...on Task{title}}} + std::cerr << "Query::getNode" << std::endl; + using namespace std::literals; + co_await 100ms; + auto appointment = findAppointment(params, id); if (appointment) diff --git a/samples/today/TodayMock.h b/samples/today/TodayMock.h index c9ccfe83..69d8d7e6 100644 --- a/samples/today/TodayMock.h +++ b/samples/today/TodayMock.h @@ -186,7 +186,7 @@ class AppointmentEdge : public object::AppointmentEdge service::FieldResult getCursor(service::FieldParams&& params) const final { - return response::Value(_appointment->getId(std::move(params)).get()); + co_return response::Value(co_await _appointment->getId(std::move(params))); } private: @@ -279,7 +279,7 @@ class TaskEdge : public object::TaskEdge service::FieldResult getCursor(service::FieldParams&& params) const final { - return response::Value(_task->getId(std::move(params)).get()); + co_return response::Value(co_await _task->getId(std::move(params))); } private: @@ -372,7 +372,7 @@ class FolderEdge : public object::FolderEdge service::FieldResult getCursor(service::FieldParams&& params) const final { - return response::Value(_folder->getId(std::move(params)).get()); + co_return response::Value(co_await _folder->getId(std::move(params))); } private: diff --git a/samples/unified/TodaySchema.cpp b/samples/unified/TodaySchema.cpp index 97858c7a..a513c8ad 100644 --- a/samples/unified/TodaySchema.cpp +++ b/samples/unified/TodaySchema.cpp @@ -47,7 +47,7 @@ today::TaskState ModifiedArgument::convert(const response::Val } template <> -std::future ModifiedResult::convert(service::FieldResult&& result, ResolverParams&& params) +service::AwaitableResolver ModifiedResult::convert(service::FieldResult&& result, ResolverParams&& params) { return resolve(std::move(result), std::move(params), [](today::TaskState value, const ResolverParams&) @@ -170,7 +170,7 @@ service::FieldResult> Query::getNode(service::F throw std::runtime_error(R"ex(Query::getNode is not implemented)ex"); } -std::future Query::resolveNode(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveNode(service::ResolverParams&& params) { auto argId = service::ModifiedArgument::require("id", params.arguments); std::unique_lock resolverLock(_resolverMutex); @@ -186,7 +186,7 @@ service::FieldResult> Query::getAppointme throw std::runtime_error(R"ex(Query::getAppointments is not implemented)ex"); } -std::future Query::resolveAppointments(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveAppointments(service::ResolverParams&& params) { auto argFirst = service::ModifiedArgument::require("first", params.arguments); auto argAfter = service::ModifiedArgument::require("after", params.arguments); @@ -205,7 +205,7 @@ service::FieldResult> Query::getTasks(service::F throw std::runtime_error(R"ex(Query::getTasks is not implemented)ex"); } -std::future Query::resolveTasks(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveTasks(service::ResolverParams&& params) { auto argFirst = service::ModifiedArgument::require("first", params.arguments); auto argAfter = service::ModifiedArgument::require("after", params.arguments); @@ -224,7 +224,7 @@ service::FieldResult> Query::getUnreadCounts(s throw std::runtime_error(R"ex(Query::getUnreadCounts is not implemented)ex"); } -std::future Query::resolveUnreadCounts(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveUnreadCounts(service::ResolverParams&& params) { auto argFirst = service::ModifiedArgument::require("first", params.arguments); auto argAfter = service::ModifiedArgument::require("after", params.arguments); @@ -243,7 +243,7 @@ service::FieldResult>> Query::getAppoin throw std::runtime_error(R"ex(Query::getAppointmentsById is not implemented)ex"); } -std::future Query::resolveAppointmentsById(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveAppointmentsById(service::ResolverParams&& params) { const auto defaultArguments = []() { @@ -281,7 +281,7 @@ service::FieldResult>> Query::getTasksById(ser throw std::runtime_error(R"ex(Query::getTasksById is not implemented)ex"); } -std::future Query::resolveTasksById(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveTasksById(service::ResolverParams&& params) { auto argIds = service::ModifiedArgument::require("ids", params.arguments); std::unique_lock resolverLock(_resolverMutex); @@ -297,7 +297,7 @@ service::FieldResult>> Query::getUnreadCount throw std::runtime_error(R"ex(Query::getUnreadCountsById is not implemented)ex"); } -std::future Query::resolveUnreadCountsById(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveUnreadCountsById(service::ResolverParams&& params) { auto argIds = service::ModifiedArgument::require("ids", params.arguments); std::unique_lock resolverLock(_resolverMutex); @@ -313,7 +313,7 @@ service::FieldResult> Query::getNested(service::Fiel throw std::runtime_error(R"ex(Query::getNested is not implemented)ex"); } -std::future Query::resolveNested(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveNested(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -328,7 +328,7 @@ service::FieldResult Query::getUnimplemented(service::Fiel throw std::runtime_error(R"ex(Query::getUnimplemented is not implemented)ex"); } -std::future Query::resolveUnimplemented(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveUnimplemented(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -343,7 +343,7 @@ service::FieldResult>> Query::getExpensiv throw std::runtime_error(R"ex(Query::getExpensive is not implemented)ex"); } -std::future Query::resolveExpensive(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveExpensive(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -358,7 +358,7 @@ service::FieldResult Query::getTestTaskState(service::FieldParams&&) throw std::runtime_error(R"ex(Query::getTestTaskState is not implemented)ex"); } -std::future Query::resolveTestTaskState(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveTestTaskState(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -373,7 +373,7 @@ service::FieldResult>> Query::getAn throw std::runtime_error(R"ex(Query::getAnyType is not implemented)ex"); } -std::future Query::resolveAnyType(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveAnyType(service::ResolverParams&& params) { auto argIds = service::ModifiedArgument::require("ids", params.arguments); std::unique_lock resolverLock(_resolverMutex); @@ -384,17 +384,17 @@ std::future Query::resolveAnyType(service::ResolverPara return service::ModifiedResult::convert(std::move(result), std::move(params)); } -std::future Query::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver Query::resolve_typename(service::ResolverParams&& params) { return service::ModifiedResult::convert(response::StringType{ R"gql(Query)gql" }, std::move(params)); } -std::future Query::resolve_schema(service::ResolverParams&& params) +service::AwaitableResolver Query::resolve_schema(service::ResolverParams&& params) { return service::ModifiedResult::convert(std::static_pointer_cast(std::make_shared(_schema)), std::move(params)); } -std::future Query::resolve_type(service::ResolverParams&& params) +service::AwaitableResolver Query::resolve_type(service::ResolverParams&& params) { auto argName = service::ModifiedArgument::require("name", params.arguments); const auto& baseType = _schema->LookupType(argName); @@ -419,7 +419,7 @@ service::FieldResult PageInfo::getHasNextPage(service::Fi throw std::runtime_error(R"ex(PageInfo::getHasNextPage is not implemented)ex"); } -std::future PageInfo::resolveHasNextPage(service::ResolverParams&& params) +service::AwaitableResolver PageInfo::resolveHasNextPage(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -434,7 +434,7 @@ service::FieldResult PageInfo::getHasPreviousPage(service throw std::runtime_error(R"ex(PageInfo::getHasPreviousPage is not implemented)ex"); } -std::future PageInfo::resolveHasPreviousPage(service::ResolverParams&& params) +service::AwaitableResolver PageInfo::resolveHasPreviousPage(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -444,7 +444,7 @@ std::future PageInfo::resolveHasPreviousPage(service::R return service::ModifiedResult::convert(std::move(result), std::move(params)); } -std::future PageInfo::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver PageInfo::resolve_typename(service::ResolverParams&& params) { return service::ModifiedResult::convert(response::StringType{ R"gql(PageInfo)gql" }, std::move(params)); } @@ -465,7 +465,7 @@ service::FieldResult> AppointmentEdge::getNode(serv throw std::runtime_error(R"ex(AppointmentEdge::getNode is not implemented)ex"); } -std::future AppointmentEdge::resolveNode(service::ResolverParams&& params) +service::AwaitableResolver AppointmentEdge::resolveNode(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -480,7 +480,7 @@ service::FieldResult AppointmentEdge::getCursor(service::FieldP throw std::runtime_error(R"ex(AppointmentEdge::getCursor is not implemented)ex"); } -std::future AppointmentEdge::resolveCursor(service::ResolverParams&& params) +service::AwaitableResolver AppointmentEdge::resolveCursor(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -490,7 +490,7 @@ std::future AppointmentEdge::resolveCursor(service::Res return service::ModifiedResult::convert(std::move(result), std::move(params)); } -std::future AppointmentEdge::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver AppointmentEdge::resolve_typename(service::ResolverParams&& params) { return service::ModifiedResult::convert(response::StringType{ R"gql(AppointmentEdge)gql" }, std::move(params)); } @@ -511,7 +511,7 @@ service::FieldResult> AppointmentConnection::getPageIn throw std::runtime_error(R"ex(AppointmentConnection::getPageInfo is not implemented)ex"); } -std::future AppointmentConnection::resolvePageInfo(service::ResolverParams&& params) +service::AwaitableResolver AppointmentConnection::resolvePageInfo(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -526,7 +526,7 @@ service::FieldResult> throw std::runtime_error(R"ex(AppointmentConnection::getEdges is not implemented)ex"); } -std::future AppointmentConnection::resolveEdges(service::ResolverParams&& params) +service::AwaitableResolver AppointmentConnection::resolveEdges(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -536,7 +536,7 @@ std::future AppointmentConnection::resolveEdges(service return service::ModifiedResult::convert(std::move(result), std::move(params)); } -std::future AppointmentConnection::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver AppointmentConnection::resolve_typename(service::ResolverParams&& params) { return service::ModifiedResult::convert(response::StringType{ R"gql(AppointmentConnection)gql" }, std::move(params)); } @@ -557,7 +557,7 @@ service::FieldResult> TaskEdge::getNode(service::FieldPara throw std::runtime_error(R"ex(TaskEdge::getNode is not implemented)ex"); } -std::future TaskEdge::resolveNode(service::ResolverParams&& params) +service::AwaitableResolver TaskEdge::resolveNode(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -572,7 +572,7 @@ service::FieldResult TaskEdge::getCursor(service::FieldParams&& throw std::runtime_error(R"ex(TaskEdge::getCursor is not implemented)ex"); } -std::future TaskEdge::resolveCursor(service::ResolverParams&& params) +service::AwaitableResolver TaskEdge::resolveCursor(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -582,7 +582,7 @@ std::future TaskEdge::resolveCursor(service::ResolverPa return service::ModifiedResult::convert(std::move(result), std::move(params)); } -std::future TaskEdge::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver TaskEdge::resolve_typename(service::ResolverParams&& params) { return service::ModifiedResult::convert(response::StringType{ R"gql(TaskEdge)gql" }, std::move(params)); } @@ -603,7 +603,7 @@ service::FieldResult> TaskConnection::getPageInfo(serv throw std::runtime_error(R"ex(TaskConnection::getPageInfo is not implemented)ex"); } -std::future TaskConnection::resolvePageInfo(service::ResolverParams&& params) +service::AwaitableResolver TaskConnection::resolvePageInfo(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -618,7 +618,7 @@ service::FieldResult>>> Task throw std::runtime_error(R"ex(TaskConnection::getEdges is not implemented)ex"); } -std::future TaskConnection::resolveEdges(service::ResolverParams&& params) +service::AwaitableResolver TaskConnection::resolveEdges(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -628,7 +628,7 @@ std::future TaskConnection::resolveEdges(service::Resol return service::ModifiedResult::convert(std::move(result), std::move(params)); } -std::future TaskConnection::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver TaskConnection::resolve_typename(service::ResolverParams&& params) { return service::ModifiedResult::convert(response::StringType{ R"gql(TaskConnection)gql" }, std::move(params)); } @@ -649,7 +649,7 @@ service::FieldResult> FolderEdge::getNode(service::Field throw std::runtime_error(R"ex(FolderEdge::getNode is not implemented)ex"); } -std::future FolderEdge::resolveNode(service::ResolverParams&& params) +service::AwaitableResolver FolderEdge::resolveNode(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -664,7 +664,7 @@ service::FieldResult FolderEdge::getCursor(service::FieldParams throw std::runtime_error(R"ex(FolderEdge::getCursor is not implemented)ex"); } -std::future FolderEdge::resolveCursor(service::ResolverParams&& params) +service::AwaitableResolver FolderEdge::resolveCursor(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -674,7 +674,7 @@ std::future FolderEdge::resolveCursor(service::Resolver return service::ModifiedResult::convert(std::move(result), std::move(params)); } -std::future FolderEdge::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver FolderEdge::resolve_typename(service::ResolverParams&& params) { return service::ModifiedResult::convert(response::StringType{ R"gql(FolderEdge)gql" }, std::move(params)); } @@ -695,7 +695,7 @@ service::FieldResult> FolderConnection::getPageInfo(se throw std::runtime_error(R"ex(FolderConnection::getPageInfo is not implemented)ex"); } -std::future FolderConnection::resolvePageInfo(service::ResolverParams&& params) +service::AwaitableResolver FolderConnection::resolvePageInfo(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -710,7 +710,7 @@ service::FieldResult>>> Fo throw std::runtime_error(R"ex(FolderConnection::getEdges is not implemented)ex"); } -std::future FolderConnection::resolveEdges(service::ResolverParams&& params) +service::AwaitableResolver FolderConnection::resolveEdges(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -720,7 +720,7 @@ std::future FolderConnection::resolveEdges(service::Res return service::ModifiedResult::convert(std::move(result), std::move(params)); } -std::future FolderConnection::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver FolderConnection::resolve_typename(service::ResolverParams&& params) { return service::ModifiedResult::convert(response::StringType{ R"gql(FolderConnection)gql" }, std::move(params)); } @@ -741,7 +741,7 @@ service::FieldResult> CompleteTaskPayload::getTask(service throw std::runtime_error(R"ex(CompleteTaskPayload::getTask is not implemented)ex"); } -std::future CompleteTaskPayload::resolveTask(service::ResolverParams&& params) +service::AwaitableResolver CompleteTaskPayload::resolveTask(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -756,7 +756,7 @@ service::FieldResult> CompleteTaskPayload::g throw std::runtime_error(R"ex(CompleteTaskPayload::getClientMutationId is not implemented)ex"); } -std::future CompleteTaskPayload::resolveClientMutationId(service::ResolverParams&& params) +service::AwaitableResolver CompleteTaskPayload::resolveClientMutationId(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -766,7 +766,7 @@ std::future CompleteTaskPayload::resolveClientMutationI return service::ModifiedResult::convert(std::move(result), std::move(params)); } -std::future CompleteTaskPayload::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver CompleteTaskPayload::resolve_typename(service::ResolverParams&& params) { return service::ModifiedResult::convert(response::StringType{ R"gql(CompleteTaskPayload)gql" }, std::move(params)); } @@ -787,7 +787,7 @@ service::FieldResult> Mutation::applyComple throw std::runtime_error(R"ex(Mutation::applyCompleteTask is not implemented)ex"); } -std::future Mutation::resolveCompleteTask(service::ResolverParams&& params) +service::AwaitableResolver Mutation::resolveCompleteTask(service::ResolverParams&& params) { auto argInput = service::ModifiedArgument::require("input", params.arguments); std::unique_lock resolverLock(_resolverMutex); @@ -803,7 +803,7 @@ service::FieldResult Mutation::applySetFloat(service::Field throw std::runtime_error(R"ex(Mutation::applySetFloat is not implemented)ex"); } -std::future Mutation::resolveSetFloat(service::ResolverParams&& params) +service::AwaitableResolver Mutation::resolveSetFloat(service::ResolverParams&& params) { auto argValue = service::ModifiedArgument::require("value", params.arguments); std::unique_lock resolverLock(_resolverMutex); @@ -814,7 +814,7 @@ std::future Mutation::resolveSetFloat(service::Resolver return service::ModifiedResult::convert(std::move(result), std::move(params)); } -std::future Mutation::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver Mutation::resolve_typename(service::ResolverParams&& params) { return service::ModifiedResult::convert(response::StringType{ R"gql(Mutation)gql" }, std::move(params)); } @@ -835,7 +835,7 @@ service::FieldResult> Subscription::getNextAppointm throw std::runtime_error(R"ex(Subscription::getNextAppointmentChange is not implemented)ex"); } -std::future Subscription::resolveNextAppointmentChange(service::ResolverParams&& params) +service::AwaitableResolver Subscription::resolveNextAppointmentChange(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -850,7 +850,7 @@ service::FieldResult> Subscription::getNodeChan throw std::runtime_error(R"ex(Subscription::getNodeChange is not implemented)ex"); } -std::future Subscription::resolveNodeChange(service::ResolverParams&& params) +service::AwaitableResolver Subscription::resolveNodeChange(service::ResolverParams&& params) { auto argId = service::ModifiedArgument::require("id", params.arguments); std::unique_lock resolverLock(_resolverMutex); @@ -861,7 +861,7 @@ std::future Subscription::resolveNodeChange(service::Re return service::ModifiedResult::convert(std::move(result), std::move(params)); } -std::future Subscription::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver Subscription::resolve_typename(service::ResolverParams&& params) { return service::ModifiedResult::convert(response::StringType{ R"gql(Subscription)gql" }, std::move(params)); } @@ -887,7 +887,7 @@ service::FieldResult Appointment::getId(service::FieldParams&& throw std::runtime_error(R"ex(Appointment::getId is not implemented)ex"); } -std::future Appointment::resolveId(service::ResolverParams&& params) +service::AwaitableResolver Appointment::resolveId(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -902,7 +902,7 @@ service::FieldResult> Appointment::getWhen(servic throw std::runtime_error(R"ex(Appointment::getWhen is not implemented)ex"); } -std::future Appointment::resolveWhen(service::ResolverParams&& params) +service::AwaitableResolver Appointment::resolveWhen(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -917,7 +917,7 @@ service::FieldResult> Appointment::getSubjec throw std::runtime_error(R"ex(Appointment::getSubject is not implemented)ex"); } -std::future Appointment::resolveSubject(service::ResolverParams&& params) +service::AwaitableResolver Appointment::resolveSubject(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -932,7 +932,7 @@ service::FieldResult Appointment::getIsNow(service::Field throw std::runtime_error(R"ex(Appointment::getIsNow is not implemented)ex"); } -std::future Appointment::resolveIsNow(service::ResolverParams&& params) +service::AwaitableResolver Appointment::resolveIsNow(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -947,7 +947,7 @@ service::FieldResult> Appointment::getForceE throw std::runtime_error(R"ex(Appointment::getForceError is not implemented)ex"); } -std::future Appointment::resolveForceError(service::ResolverParams&& params) +service::AwaitableResolver Appointment::resolveForceError(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -957,7 +957,7 @@ std::future Appointment::resolveForceError(service::Res return service::ModifiedResult::convert(std::move(result), std::move(params)); } -std::future Appointment::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver Appointment::resolve_typename(service::ResolverParams&& params) { return service::ModifiedResult::convert(response::StringType{ R"gql(Appointment)gql" }, std::move(params)); } @@ -981,7 +981,7 @@ service::FieldResult Task::getId(service::FieldParams&&) const throw std::runtime_error(R"ex(Task::getId is not implemented)ex"); } -std::future Task::resolveId(service::ResolverParams&& params) +service::AwaitableResolver Task::resolveId(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -996,7 +996,7 @@ service::FieldResult> Task::getTitle(service throw std::runtime_error(R"ex(Task::getTitle is not implemented)ex"); } -std::future Task::resolveTitle(service::ResolverParams&& params) +service::AwaitableResolver Task::resolveTitle(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -1011,7 +1011,7 @@ service::FieldResult Task::getIsComplete(service::FieldPa throw std::runtime_error(R"ex(Task::getIsComplete is not implemented)ex"); } -std::future Task::resolveIsComplete(service::ResolverParams&& params) +service::AwaitableResolver Task::resolveIsComplete(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -1021,7 +1021,7 @@ std::future Task::resolveIsComplete(service::ResolverPa return service::ModifiedResult::convert(std::move(result), std::move(params)); } -std::future Task::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver Task::resolve_typename(service::ResolverParams&& params) { return service::ModifiedResult::convert(response::StringType{ R"gql(Task)gql" }, std::move(params)); } @@ -1045,7 +1045,7 @@ service::FieldResult Folder::getId(service::FieldParams&&) con throw std::runtime_error(R"ex(Folder::getId is not implemented)ex"); } -std::future Folder::resolveId(service::ResolverParams&& params) +service::AwaitableResolver Folder::resolveId(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -1060,7 +1060,7 @@ service::FieldResult> Folder::getName(servic throw std::runtime_error(R"ex(Folder::getName is not implemented)ex"); } -std::future Folder::resolveName(service::ResolverParams&& params) +service::AwaitableResolver Folder::resolveName(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -1075,7 +1075,7 @@ service::FieldResult Folder::getUnreadCount(service::FieldPar throw std::runtime_error(R"ex(Folder::getUnreadCount is not implemented)ex"); } -std::future Folder::resolveUnreadCount(service::ResolverParams&& params) +service::AwaitableResolver Folder::resolveUnreadCount(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -1085,7 +1085,7 @@ std::future Folder::resolveUnreadCount(service::Resolve return service::ModifiedResult::convert(std::move(result), std::move(params)); } -std::future Folder::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver Folder::resolve_typename(service::ResolverParams&& params) { return service::ModifiedResult::convert(response::StringType{ R"gql(Folder)gql" }, std::move(params)); } @@ -1106,7 +1106,7 @@ service::FieldResult NestedType::getDepth(service::FieldParam throw std::runtime_error(R"ex(NestedType::getDepth is not implemented)ex"); } -std::future NestedType::resolveDepth(service::ResolverParams&& params) +service::AwaitableResolver NestedType::resolveDepth(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -1121,7 +1121,7 @@ service::FieldResult> NestedType::getNested(service: throw std::runtime_error(R"ex(NestedType::getNested is not implemented)ex"); } -std::future NestedType::resolveNested(service::ResolverParams&& params) +service::AwaitableResolver NestedType::resolveNested(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -1131,7 +1131,7 @@ std::future NestedType::resolveNested(service::Resolver return service::ModifiedResult::convert(std::move(result), std::move(params)); } -std::future NestedType::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver NestedType::resolve_typename(service::ResolverParams&& params) { return service::ModifiedResult::convert(response::StringType{ R"gql(NestedType)gql" }, std::move(params)); } @@ -1151,7 +1151,7 @@ service::FieldResult Expensive::getOrder(service::FieldParams throw std::runtime_error(R"ex(Expensive::getOrder is not implemented)ex"); } -std::future Expensive::resolveOrder(service::ResolverParams&& params) +service::AwaitableResolver Expensive::resolveOrder(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -1161,7 +1161,7 @@ std::future Expensive::resolveOrder(service::ResolverPa return service::ModifiedResult::convert(std::move(result), std::move(params)); } -std::future Expensive::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver Expensive::resolve_typename(service::ResolverParams&& params) { return service::ModifiedResult::convert(response::StringType{ R"gql(Expensive)gql" }, std::move(params)); } diff --git a/samples/unified/TodaySchema.h b/samples/unified/TodaySchema.h index 9ee34f37..20a3868f 100644 --- a/samples/unified/TodaySchema.h +++ b/samples/unified/TodaySchema.h @@ -109,22 +109,22 @@ class Query virtual service::FieldResult>> getAnyType(service::FieldParams&& params, std::vector&& idsArg) const; private: - std::future resolveNode(service::ResolverParams&& params); - std::future resolveAppointments(service::ResolverParams&& params); - std::future resolveTasks(service::ResolverParams&& params); - std::future resolveUnreadCounts(service::ResolverParams&& params); - std::future resolveAppointmentsById(service::ResolverParams&& params); - std::future resolveTasksById(service::ResolverParams&& params); - std::future resolveUnreadCountsById(service::ResolverParams&& params); - std::future resolveNested(service::ResolverParams&& params); - std::future resolveUnimplemented(service::ResolverParams&& params); - std::future resolveExpensive(service::ResolverParams&& params); - std::future resolveTestTaskState(service::ResolverParams&& params); - std::future resolveAnyType(service::ResolverParams&& params); - - std::future resolve_typename(service::ResolverParams&& params); - std::future resolve_schema(service::ResolverParams&& params); - std::future resolve_type(service::ResolverParams&& params); + service::AwaitableResolver resolveNode(service::ResolverParams&& params); + service::AwaitableResolver resolveAppointments(service::ResolverParams&& params); + service::AwaitableResolver resolveTasks(service::ResolverParams&& params); + service::AwaitableResolver resolveUnreadCounts(service::ResolverParams&& params); + service::AwaitableResolver resolveAppointmentsById(service::ResolverParams&& params); + service::AwaitableResolver resolveTasksById(service::ResolverParams&& params); + service::AwaitableResolver resolveUnreadCountsById(service::ResolverParams&& params); + service::AwaitableResolver resolveNested(service::ResolverParams&& params); + service::AwaitableResolver resolveUnimplemented(service::ResolverParams&& params); + service::AwaitableResolver resolveExpensive(service::ResolverParams&& params); + service::AwaitableResolver resolveTestTaskState(service::ResolverParams&& params); + service::AwaitableResolver resolveAnyType(service::ResolverParams&& params); + + service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_schema(service::ResolverParams&& params); + service::AwaitableResolver resolve_type(service::ResolverParams&& params); std::shared_ptr _schema; }; @@ -140,10 +140,10 @@ class PageInfo virtual service::FieldResult getHasPreviousPage(service::FieldParams&& params) const; private: - std::future resolveHasNextPage(service::ResolverParams&& params); - std::future resolveHasPreviousPage(service::ResolverParams&& params); + service::AwaitableResolver resolveHasNextPage(service::ResolverParams&& params); + service::AwaitableResolver resolveHasPreviousPage(service::ResolverParams&& params); - std::future resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params); }; class AppointmentEdge @@ -157,10 +157,10 @@ class AppointmentEdge virtual service::FieldResult getCursor(service::FieldParams&& params) const; private: - std::future resolveNode(service::ResolverParams&& params); - std::future resolveCursor(service::ResolverParams&& params); + service::AwaitableResolver resolveNode(service::ResolverParams&& params); + service::AwaitableResolver resolveCursor(service::ResolverParams&& params); - std::future resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params); }; class AppointmentConnection @@ -174,10 +174,10 @@ class AppointmentConnection virtual service::FieldResult>>> getEdges(service::FieldParams&& params) const; private: - std::future resolvePageInfo(service::ResolverParams&& params); - std::future resolveEdges(service::ResolverParams&& params); + service::AwaitableResolver resolvePageInfo(service::ResolverParams&& params); + service::AwaitableResolver resolveEdges(service::ResolverParams&& params); - std::future resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params); }; class TaskEdge @@ -191,10 +191,10 @@ class TaskEdge virtual service::FieldResult getCursor(service::FieldParams&& params) const; private: - std::future resolveNode(service::ResolverParams&& params); - std::future resolveCursor(service::ResolverParams&& params); + service::AwaitableResolver resolveNode(service::ResolverParams&& params); + service::AwaitableResolver resolveCursor(service::ResolverParams&& params); - std::future resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params); }; class TaskConnection @@ -208,10 +208,10 @@ class TaskConnection virtual service::FieldResult>>> getEdges(service::FieldParams&& params) const; private: - std::future resolvePageInfo(service::ResolverParams&& params); - std::future resolveEdges(service::ResolverParams&& params); + service::AwaitableResolver resolvePageInfo(service::ResolverParams&& params); + service::AwaitableResolver resolveEdges(service::ResolverParams&& params); - std::future resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params); }; class FolderEdge @@ -225,10 +225,10 @@ class FolderEdge virtual service::FieldResult getCursor(service::FieldParams&& params) const; private: - std::future resolveNode(service::ResolverParams&& params); - std::future resolveCursor(service::ResolverParams&& params); + service::AwaitableResolver resolveNode(service::ResolverParams&& params); + service::AwaitableResolver resolveCursor(service::ResolverParams&& params); - std::future resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params); }; class FolderConnection @@ -242,10 +242,10 @@ class FolderConnection virtual service::FieldResult>>> getEdges(service::FieldParams&& params) const; private: - std::future resolvePageInfo(service::ResolverParams&& params); - std::future resolveEdges(service::ResolverParams&& params); + service::AwaitableResolver resolvePageInfo(service::ResolverParams&& params); + service::AwaitableResolver resolveEdges(service::ResolverParams&& params); - std::future resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params); }; class CompleteTaskPayload @@ -259,10 +259,10 @@ class CompleteTaskPayload virtual service::FieldResult> getClientMutationId(service::FieldParams&& params) const; private: - std::future resolveTask(service::ResolverParams&& params); - std::future resolveClientMutationId(service::ResolverParams&& params); + service::AwaitableResolver resolveTask(service::ResolverParams&& params); + service::AwaitableResolver resolveClientMutationId(service::ResolverParams&& params); - std::future resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params); }; class Mutation @@ -276,10 +276,10 @@ class Mutation virtual service::FieldResult applySetFloat(service::FieldParams&& params, response::FloatType&& valueArg) const; private: - std::future resolveCompleteTask(service::ResolverParams&& params); - std::future resolveSetFloat(service::ResolverParams&& params); + service::AwaitableResolver resolveCompleteTask(service::ResolverParams&& params); + service::AwaitableResolver resolveSetFloat(service::ResolverParams&& params); - std::future resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params); }; class Subscription @@ -293,10 +293,10 @@ class Subscription virtual service::FieldResult> getNodeChange(service::FieldParams&& params, response::IdType&& idArg) const; private: - std::future resolveNextAppointmentChange(service::ResolverParams&& params); - std::future resolveNodeChange(service::ResolverParams&& params); + service::AwaitableResolver resolveNextAppointmentChange(service::ResolverParams&& params); + service::AwaitableResolver resolveNodeChange(service::ResolverParams&& params); - std::future resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params); }; class Appointment @@ -314,13 +314,13 @@ class Appointment virtual service::FieldResult> getForceError(service::FieldParams&& params) const; private: - std::future resolveId(service::ResolverParams&& params); - std::future resolveWhen(service::ResolverParams&& params); - std::future resolveSubject(service::ResolverParams&& params); - std::future resolveIsNow(service::ResolverParams&& params); - std::future resolveForceError(service::ResolverParams&& params); + service::AwaitableResolver resolveId(service::ResolverParams&& params); + service::AwaitableResolver resolveWhen(service::ResolverParams&& params); + service::AwaitableResolver resolveSubject(service::ResolverParams&& params); + service::AwaitableResolver resolveIsNow(service::ResolverParams&& params); + service::AwaitableResolver resolveForceError(service::ResolverParams&& params); - std::future resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params); }; class Task @@ -336,11 +336,11 @@ class Task virtual service::FieldResult getIsComplete(service::FieldParams&& params) const; private: - std::future resolveId(service::ResolverParams&& params); - std::future resolveTitle(service::ResolverParams&& params); - std::future resolveIsComplete(service::ResolverParams&& params); + service::AwaitableResolver resolveId(service::ResolverParams&& params); + service::AwaitableResolver resolveTitle(service::ResolverParams&& params); + service::AwaitableResolver resolveIsComplete(service::ResolverParams&& params); - std::future resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params); }; class Folder @@ -356,11 +356,11 @@ class Folder virtual service::FieldResult getUnreadCount(service::FieldParams&& params) const; private: - std::future resolveId(service::ResolverParams&& params); - std::future resolveName(service::ResolverParams&& params); - std::future resolveUnreadCount(service::ResolverParams&& params); + service::AwaitableResolver resolveId(service::ResolverParams&& params); + service::AwaitableResolver resolveName(service::ResolverParams&& params); + service::AwaitableResolver resolveUnreadCount(service::ResolverParams&& params); - std::future resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params); }; class NestedType @@ -374,10 +374,10 @@ class NestedType virtual service::FieldResult> getNested(service::FieldParams&& params) const; private: - std::future resolveDepth(service::ResolverParams&& params); - std::future resolveNested(service::ResolverParams&& params); + service::AwaitableResolver resolveDepth(service::ResolverParams&& params); + service::AwaitableResolver resolveNested(service::ResolverParams&& params); - std::future resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params); }; class Expensive @@ -390,9 +390,9 @@ class Expensive virtual service::FieldResult getOrder(service::FieldParams&& params) const; private: - std::future resolveOrder(service::ResolverParams&& params); + service::AwaitableResolver resolveOrder(service::ResolverParams&& params); - std::future resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params); }; } // namespace object diff --git a/samples/unified_nointrospection/TodaySchema.cpp b/samples/unified_nointrospection/TodaySchema.cpp index 8d9464c6..cfcc7118 100644 --- a/samples/unified_nointrospection/TodaySchema.cpp +++ b/samples/unified_nointrospection/TodaySchema.cpp @@ -47,7 +47,7 @@ today::TaskState ModifiedArgument::convert(const response::Val } template <> -std::future ModifiedResult::convert(service::FieldResult&& result, ResolverParams&& params) +service::AwaitableResolver ModifiedResult::convert(service::FieldResult&& result, ResolverParams&& params) { return resolve(std::move(result), std::move(params), [](today::TaskState value, const ResolverParams&) @@ -167,7 +167,7 @@ service::FieldResult> Query::getNode(service::F throw std::runtime_error(R"ex(Query::getNode is not implemented)ex"); } -std::future Query::resolveNode(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveNode(service::ResolverParams&& params) { auto argId = service::ModifiedArgument::require("id", params.arguments); std::unique_lock resolverLock(_resolverMutex); @@ -183,7 +183,7 @@ service::FieldResult> Query::getAppointme throw std::runtime_error(R"ex(Query::getAppointments is not implemented)ex"); } -std::future Query::resolveAppointments(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveAppointments(service::ResolverParams&& params) { auto argFirst = service::ModifiedArgument::require("first", params.arguments); auto argAfter = service::ModifiedArgument::require("after", params.arguments); @@ -202,7 +202,7 @@ service::FieldResult> Query::getTasks(service::F throw std::runtime_error(R"ex(Query::getTasks is not implemented)ex"); } -std::future Query::resolveTasks(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveTasks(service::ResolverParams&& params) { auto argFirst = service::ModifiedArgument::require("first", params.arguments); auto argAfter = service::ModifiedArgument::require("after", params.arguments); @@ -221,7 +221,7 @@ service::FieldResult> Query::getUnreadCounts(s throw std::runtime_error(R"ex(Query::getUnreadCounts is not implemented)ex"); } -std::future Query::resolveUnreadCounts(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveUnreadCounts(service::ResolverParams&& params) { auto argFirst = service::ModifiedArgument::require("first", params.arguments); auto argAfter = service::ModifiedArgument::require("after", params.arguments); @@ -240,7 +240,7 @@ service::FieldResult>> Query::getAppoin throw std::runtime_error(R"ex(Query::getAppointmentsById is not implemented)ex"); } -std::future Query::resolveAppointmentsById(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveAppointmentsById(service::ResolverParams&& params) { const auto defaultArguments = []() { @@ -278,7 +278,7 @@ service::FieldResult>> Query::getTasksById(ser throw std::runtime_error(R"ex(Query::getTasksById is not implemented)ex"); } -std::future Query::resolveTasksById(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveTasksById(service::ResolverParams&& params) { auto argIds = service::ModifiedArgument::require("ids", params.arguments); std::unique_lock resolverLock(_resolverMutex); @@ -294,7 +294,7 @@ service::FieldResult>> Query::getUnreadCount throw std::runtime_error(R"ex(Query::getUnreadCountsById is not implemented)ex"); } -std::future Query::resolveUnreadCountsById(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveUnreadCountsById(service::ResolverParams&& params) { auto argIds = service::ModifiedArgument::require("ids", params.arguments); std::unique_lock resolverLock(_resolverMutex); @@ -310,7 +310,7 @@ service::FieldResult> Query::getNested(service::Fiel throw std::runtime_error(R"ex(Query::getNested is not implemented)ex"); } -std::future Query::resolveNested(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveNested(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -325,7 +325,7 @@ service::FieldResult Query::getUnimplemented(service::Fiel throw std::runtime_error(R"ex(Query::getUnimplemented is not implemented)ex"); } -std::future Query::resolveUnimplemented(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveUnimplemented(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -340,7 +340,7 @@ service::FieldResult>> Query::getExpensiv throw std::runtime_error(R"ex(Query::getExpensive is not implemented)ex"); } -std::future Query::resolveExpensive(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveExpensive(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -355,7 +355,7 @@ service::FieldResult Query::getTestTaskState(service::FieldParams&&) throw std::runtime_error(R"ex(Query::getTestTaskState is not implemented)ex"); } -std::future Query::resolveTestTaskState(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveTestTaskState(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -370,7 +370,7 @@ service::FieldResult>> Query::getAn throw std::runtime_error(R"ex(Query::getAnyType is not implemented)ex"); } -std::future Query::resolveAnyType(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveAnyType(service::ResolverParams&& params) { auto argIds = service::ModifiedArgument::require("ids", params.arguments); std::unique_lock resolverLock(_resolverMutex); @@ -381,7 +381,7 @@ std::future Query::resolveAnyType(service::ResolverPara return service::ModifiedResult::convert(std::move(result), std::move(params)); } -std::future Query::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver Query::resolve_typename(service::ResolverParams&& params) { return service::ModifiedResult::convert(response::StringType{ R"gql(Query)gql" }, std::move(params)); } @@ -402,7 +402,7 @@ service::FieldResult PageInfo::getHasNextPage(service::Fi throw std::runtime_error(R"ex(PageInfo::getHasNextPage is not implemented)ex"); } -std::future PageInfo::resolveHasNextPage(service::ResolverParams&& params) +service::AwaitableResolver PageInfo::resolveHasNextPage(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -417,7 +417,7 @@ service::FieldResult PageInfo::getHasPreviousPage(service throw std::runtime_error(R"ex(PageInfo::getHasPreviousPage is not implemented)ex"); } -std::future PageInfo::resolveHasPreviousPage(service::ResolverParams&& params) +service::AwaitableResolver PageInfo::resolveHasPreviousPage(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -427,7 +427,7 @@ std::future PageInfo::resolveHasPreviousPage(service::R return service::ModifiedResult::convert(std::move(result), std::move(params)); } -std::future PageInfo::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver PageInfo::resolve_typename(service::ResolverParams&& params) { return service::ModifiedResult::convert(response::StringType{ R"gql(PageInfo)gql" }, std::move(params)); } @@ -448,7 +448,7 @@ service::FieldResult> AppointmentEdge::getNode(serv throw std::runtime_error(R"ex(AppointmentEdge::getNode is not implemented)ex"); } -std::future AppointmentEdge::resolveNode(service::ResolverParams&& params) +service::AwaitableResolver AppointmentEdge::resolveNode(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -463,7 +463,7 @@ service::FieldResult AppointmentEdge::getCursor(service::FieldP throw std::runtime_error(R"ex(AppointmentEdge::getCursor is not implemented)ex"); } -std::future AppointmentEdge::resolveCursor(service::ResolverParams&& params) +service::AwaitableResolver AppointmentEdge::resolveCursor(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -473,7 +473,7 @@ std::future AppointmentEdge::resolveCursor(service::Res return service::ModifiedResult::convert(std::move(result), std::move(params)); } -std::future AppointmentEdge::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver AppointmentEdge::resolve_typename(service::ResolverParams&& params) { return service::ModifiedResult::convert(response::StringType{ R"gql(AppointmentEdge)gql" }, std::move(params)); } @@ -494,7 +494,7 @@ service::FieldResult> AppointmentConnection::getPageIn throw std::runtime_error(R"ex(AppointmentConnection::getPageInfo is not implemented)ex"); } -std::future AppointmentConnection::resolvePageInfo(service::ResolverParams&& params) +service::AwaitableResolver AppointmentConnection::resolvePageInfo(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -509,7 +509,7 @@ service::FieldResult> throw std::runtime_error(R"ex(AppointmentConnection::getEdges is not implemented)ex"); } -std::future AppointmentConnection::resolveEdges(service::ResolverParams&& params) +service::AwaitableResolver AppointmentConnection::resolveEdges(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -519,7 +519,7 @@ std::future AppointmentConnection::resolveEdges(service return service::ModifiedResult::convert(std::move(result), std::move(params)); } -std::future AppointmentConnection::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver AppointmentConnection::resolve_typename(service::ResolverParams&& params) { return service::ModifiedResult::convert(response::StringType{ R"gql(AppointmentConnection)gql" }, std::move(params)); } @@ -540,7 +540,7 @@ service::FieldResult> TaskEdge::getNode(service::FieldPara throw std::runtime_error(R"ex(TaskEdge::getNode is not implemented)ex"); } -std::future TaskEdge::resolveNode(service::ResolverParams&& params) +service::AwaitableResolver TaskEdge::resolveNode(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -555,7 +555,7 @@ service::FieldResult TaskEdge::getCursor(service::FieldParams&& throw std::runtime_error(R"ex(TaskEdge::getCursor is not implemented)ex"); } -std::future TaskEdge::resolveCursor(service::ResolverParams&& params) +service::AwaitableResolver TaskEdge::resolveCursor(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -565,7 +565,7 @@ std::future TaskEdge::resolveCursor(service::ResolverPa return service::ModifiedResult::convert(std::move(result), std::move(params)); } -std::future TaskEdge::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver TaskEdge::resolve_typename(service::ResolverParams&& params) { return service::ModifiedResult::convert(response::StringType{ R"gql(TaskEdge)gql" }, std::move(params)); } @@ -586,7 +586,7 @@ service::FieldResult> TaskConnection::getPageInfo(serv throw std::runtime_error(R"ex(TaskConnection::getPageInfo is not implemented)ex"); } -std::future TaskConnection::resolvePageInfo(service::ResolverParams&& params) +service::AwaitableResolver TaskConnection::resolvePageInfo(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -601,7 +601,7 @@ service::FieldResult>>> Task throw std::runtime_error(R"ex(TaskConnection::getEdges is not implemented)ex"); } -std::future TaskConnection::resolveEdges(service::ResolverParams&& params) +service::AwaitableResolver TaskConnection::resolveEdges(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -611,7 +611,7 @@ std::future TaskConnection::resolveEdges(service::Resol return service::ModifiedResult::convert(std::move(result), std::move(params)); } -std::future TaskConnection::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver TaskConnection::resolve_typename(service::ResolverParams&& params) { return service::ModifiedResult::convert(response::StringType{ R"gql(TaskConnection)gql" }, std::move(params)); } @@ -632,7 +632,7 @@ service::FieldResult> FolderEdge::getNode(service::Field throw std::runtime_error(R"ex(FolderEdge::getNode is not implemented)ex"); } -std::future FolderEdge::resolveNode(service::ResolverParams&& params) +service::AwaitableResolver FolderEdge::resolveNode(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -647,7 +647,7 @@ service::FieldResult FolderEdge::getCursor(service::FieldParams throw std::runtime_error(R"ex(FolderEdge::getCursor is not implemented)ex"); } -std::future FolderEdge::resolveCursor(service::ResolverParams&& params) +service::AwaitableResolver FolderEdge::resolveCursor(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -657,7 +657,7 @@ std::future FolderEdge::resolveCursor(service::Resolver return service::ModifiedResult::convert(std::move(result), std::move(params)); } -std::future FolderEdge::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver FolderEdge::resolve_typename(service::ResolverParams&& params) { return service::ModifiedResult::convert(response::StringType{ R"gql(FolderEdge)gql" }, std::move(params)); } @@ -678,7 +678,7 @@ service::FieldResult> FolderConnection::getPageInfo(se throw std::runtime_error(R"ex(FolderConnection::getPageInfo is not implemented)ex"); } -std::future FolderConnection::resolvePageInfo(service::ResolverParams&& params) +service::AwaitableResolver FolderConnection::resolvePageInfo(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -693,7 +693,7 @@ service::FieldResult>>> Fo throw std::runtime_error(R"ex(FolderConnection::getEdges is not implemented)ex"); } -std::future FolderConnection::resolveEdges(service::ResolverParams&& params) +service::AwaitableResolver FolderConnection::resolveEdges(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -703,7 +703,7 @@ std::future FolderConnection::resolveEdges(service::Res return service::ModifiedResult::convert(std::move(result), std::move(params)); } -std::future FolderConnection::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver FolderConnection::resolve_typename(service::ResolverParams&& params) { return service::ModifiedResult::convert(response::StringType{ R"gql(FolderConnection)gql" }, std::move(params)); } @@ -724,7 +724,7 @@ service::FieldResult> CompleteTaskPayload::getTask(service throw std::runtime_error(R"ex(CompleteTaskPayload::getTask is not implemented)ex"); } -std::future CompleteTaskPayload::resolveTask(service::ResolverParams&& params) +service::AwaitableResolver CompleteTaskPayload::resolveTask(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -739,7 +739,7 @@ service::FieldResult> CompleteTaskPayload::g throw std::runtime_error(R"ex(CompleteTaskPayload::getClientMutationId is not implemented)ex"); } -std::future CompleteTaskPayload::resolveClientMutationId(service::ResolverParams&& params) +service::AwaitableResolver CompleteTaskPayload::resolveClientMutationId(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -749,7 +749,7 @@ std::future CompleteTaskPayload::resolveClientMutationI return service::ModifiedResult::convert(std::move(result), std::move(params)); } -std::future CompleteTaskPayload::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver CompleteTaskPayload::resolve_typename(service::ResolverParams&& params) { return service::ModifiedResult::convert(response::StringType{ R"gql(CompleteTaskPayload)gql" }, std::move(params)); } @@ -770,7 +770,7 @@ service::FieldResult> Mutation::applyComple throw std::runtime_error(R"ex(Mutation::applyCompleteTask is not implemented)ex"); } -std::future Mutation::resolveCompleteTask(service::ResolverParams&& params) +service::AwaitableResolver Mutation::resolveCompleteTask(service::ResolverParams&& params) { auto argInput = service::ModifiedArgument::require("input", params.arguments); std::unique_lock resolverLock(_resolverMutex); @@ -786,7 +786,7 @@ service::FieldResult Mutation::applySetFloat(service::Field throw std::runtime_error(R"ex(Mutation::applySetFloat is not implemented)ex"); } -std::future Mutation::resolveSetFloat(service::ResolverParams&& params) +service::AwaitableResolver Mutation::resolveSetFloat(service::ResolverParams&& params) { auto argValue = service::ModifiedArgument::require("value", params.arguments); std::unique_lock resolverLock(_resolverMutex); @@ -797,7 +797,7 @@ std::future Mutation::resolveSetFloat(service::Resolver return service::ModifiedResult::convert(std::move(result), std::move(params)); } -std::future Mutation::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver Mutation::resolve_typename(service::ResolverParams&& params) { return service::ModifiedResult::convert(response::StringType{ R"gql(Mutation)gql" }, std::move(params)); } @@ -818,7 +818,7 @@ service::FieldResult> Subscription::getNextAppointm throw std::runtime_error(R"ex(Subscription::getNextAppointmentChange is not implemented)ex"); } -std::future Subscription::resolveNextAppointmentChange(service::ResolverParams&& params) +service::AwaitableResolver Subscription::resolveNextAppointmentChange(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -833,7 +833,7 @@ service::FieldResult> Subscription::getNodeChan throw std::runtime_error(R"ex(Subscription::getNodeChange is not implemented)ex"); } -std::future Subscription::resolveNodeChange(service::ResolverParams&& params) +service::AwaitableResolver Subscription::resolveNodeChange(service::ResolverParams&& params) { auto argId = service::ModifiedArgument::require("id", params.arguments); std::unique_lock resolverLock(_resolverMutex); @@ -844,7 +844,7 @@ std::future Subscription::resolveNodeChange(service::Re return service::ModifiedResult::convert(std::move(result), std::move(params)); } -std::future Subscription::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver Subscription::resolve_typename(service::ResolverParams&& params) { return service::ModifiedResult::convert(response::StringType{ R"gql(Subscription)gql" }, std::move(params)); } @@ -870,7 +870,7 @@ service::FieldResult Appointment::getId(service::FieldParams&& throw std::runtime_error(R"ex(Appointment::getId is not implemented)ex"); } -std::future Appointment::resolveId(service::ResolverParams&& params) +service::AwaitableResolver Appointment::resolveId(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -885,7 +885,7 @@ service::FieldResult> Appointment::getWhen(servic throw std::runtime_error(R"ex(Appointment::getWhen is not implemented)ex"); } -std::future Appointment::resolveWhen(service::ResolverParams&& params) +service::AwaitableResolver Appointment::resolveWhen(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -900,7 +900,7 @@ service::FieldResult> Appointment::getSubjec throw std::runtime_error(R"ex(Appointment::getSubject is not implemented)ex"); } -std::future Appointment::resolveSubject(service::ResolverParams&& params) +service::AwaitableResolver Appointment::resolveSubject(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -915,7 +915,7 @@ service::FieldResult Appointment::getIsNow(service::Field throw std::runtime_error(R"ex(Appointment::getIsNow is not implemented)ex"); } -std::future Appointment::resolveIsNow(service::ResolverParams&& params) +service::AwaitableResolver Appointment::resolveIsNow(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -930,7 +930,7 @@ service::FieldResult> Appointment::getForceE throw std::runtime_error(R"ex(Appointment::getForceError is not implemented)ex"); } -std::future Appointment::resolveForceError(service::ResolverParams&& params) +service::AwaitableResolver Appointment::resolveForceError(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -940,7 +940,7 @@ std::future Appointment::resolveForceError(service::Res return service::ModifiedResult::convert(std::move(result), std::move(params)); } -std::future Appointment::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver Appointment::resolve_typename(service::ResolverParams&& params) { return service::ModifiedResult::convert(response::StringType{ R"gql(Appointment)gql" }, std::move(params)); } @@ -964,7 +964,7 @@ service::FieldResult Task::getId(service::FieldParams&&) const throw std::runtime_error(R"ex(Task::getId is not implemented)ex"); } -std::future Task::resolveId(service::ResolverParams&& params) +service::AwaitableResolver Task::resolveId(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -979,7 +979,7 @@ service::FieldResult> Task::getTitle(service throw std::runtime_error(R"ex(Task::getTitle is not implemented)ex"); } -std::future Task::resolveTitle(service::ResolverParams&& params) +service::AwaitableResolver Task::resolveTitle(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -994,7 +994,7 @@ service::FieldResult Task::getIsComplete(service::FieldPa throw std::runtime_error(R"ex(Task::getIsComplete is not implemented)ex"); } -std::future Task::resolveIsComplete(service::ResolverParams&& params) +service::AwaitableResolver Task::resolveIsComplete(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -1004,7 +1004,7 @@ std::future Task::resolveIsComplete(service::ResolverPa return service::ModifiedResult::convert(std::move(result), std::move(params)); } -std::future Task::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver Task::resolve_typename(service::ResolverParams&& params) { return service::ModifiedResult::convert(response::StringType{ R"gql(Task)gql" }, std::move(params)); } @@ -1028,7 +1028,7 @@ service::FieldResult Folder::getId(service::FieldParams&&) con throw std::runtime_error(R"ex(Folder::getId is not implemented)ex"); } -std::future Folder::resolveId(service::ResolverParams&& params) +service::AwaitableResolver Folder::resolveId(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -1043,7 +1043,7 @@ service::FieldResult> Folder::getName(servic throw std::runtime_error(R"ex(Folder::getName is not implemented)ex"); } -std::future Folder::resolveName(service::ResolverParams&& params) +service::AwaitableResolver Folder::resolveName(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -1058,7 +1058,7 @@ service::FieldResult Folder::getUnreadCount(service::FieldPar throw std::runtime_error(R"ex(Folder::getUnreadCount is not implemented)ex"); } -std::future Folder::resolveUnreadCount(service::ResolverParams&& params) +service::AwaitableResolver Folder::resolveUnreadCount(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -1068,7 +1068,7 @@ std::future Folder::resolveUnreadCount(service::Resolve return service::ModifiedResult::convert(std::move(result), std::move(params)); } -std::future Folder::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver Folder::resolve_typename(service::ResolverParams&& params) { return service::ModifiedResult::convert(response::StringType{ R"gql(Folder)gql" }, std::move(params)); } @@ -1089,7 +1089,7 @@ service::FieldResult NestedType::getDepth(service::FieldParam throw std::runtime_error(R"ex(NestedType::getDepth is not implemented)ex"); } -std::future NestedType::resolveDepth(service::ResolverParams&& params) +service::AwaitableResolver NestedType::resolveDepth(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -1104,7 +1104,7 @@ service::FieldResult> NestedType::getNested(service: throw std::runtime_error(R"ex(NestedType::getNested is not implemented)ex"); } -std::future NestedType::resolveNested(service::ResolverParams&& params) +service::AwaitableResolver NestedType::resolveNested(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -1114,7 +1114,7 @@ std::future NestedType::resolveNested(service::Resolver return service::ModifiedResult::convert(std::move(result), std::move(params)); } -std::future NestedType::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver NestedType::resolve_typename(service::ResolverParams&& params) { return service::ModifiedResult::convert(response::StringType{ R"gql(NestedType)gql" }, std::move(params)); } @@ -1134,7 +1134,7 @@ service::FieldResult Expensive::getOrder(service::FieldParams throw std::runtime_error(R"ex(Expensive::getOrder is not implemented)ex"); } -std::future Expensive::resolveOrder(service::ResolverParams&& params) +service::AwaitableResolver Expensive::resolveOrder(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -1144,7 +1144,7 @@ std::future Expensive::resolveOrder(service::ResolverPa return service::ModifiedResult::convert(std::move(result), std::move(params)); } -std::future Expensive::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver Expensive::resolve_typename(service::ResolverParams&& params) { return service::ModifiedResult::convert(response::StringType{ R"gql(Expensive)gql" }, std::move(params)); } diff --git a/samples/unified_nointrospection/TodaySchema.h b/samples/unified_nointrospection/TodaySchema.h index 8210c768..77fc0eab 100644 --- a/samples/unified_nointrospection/TodaySchema.h +++ b/samples/unified_nointrospection/TodaySchema.h @@ -109,20 +109,20 @@ class Query virtual service::FieldResult>> getAnyType(service::FieldParams&& params, std::vector&& idsArg) const; private: - std::future resolveNode(service::ResolverParams&& params); - std::future resolveAppointments(service::ResolverParams&& params); - std::future resolveTasks(service::ResolverParams&& params); - std::future resolveUnreadCounts(service::ResolverParams&& params); - std::future resolveAppointmentsById(service::ResolverParams&& params); - std::future resolveTasksById(service::ResolverParams&& params); - std::future resolveUnreadCountsById(service::ResolverParams&& params); - std::future resolveNested(service::ResolverParams&& params); - std::future resolveUnimplemented(service::ResolverParams&& params); - std::future resolveExpensive(service::ResolverParams&& params); - std::future resolveTestTaskState(service::ResolverParams&& params); - std::future resolveAnyType(service::ResolverParams&& params); - - std::future resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolveNode(service::ResolverParams&& params); + service::AwaitableResolver resolveAppointments(service::ResolverParams&& params); + service::AwaitableResolver resolveTasks(service::ResolverParams&& params); + service::AwaitableResolver resolveUnreadCounts(service::ResolverParams&& params); + service::AwaitableResolver resolveAppointmentsById(service::ResolverParams&& params); + service::AwaitableResolver resolveTasksById(service::ResolverParams&& params); + service::AwaitableResolver resolveUnreadCountsById(service::ResolverParams&& params); + service::AwaitableResolver resolveNested(service::ResolverParams&& params); + service::AwaitableResolver resolveUnimplemented(service::ResolverParams&& params); + service::AwaitableResolver resolveExpensive(service::ResolverParams&& params); + service::AwaitableResolver resolveTestTaskState(service::ResolverParams&& params); + service::AwaitableResolver resolveAnyType(service::ResolverParams&& params); + + service::AwaitableResolver resolve_typename(service::ResolverParams&& params); }; class PageInfo @@ -136,10 +136,10 @@ class PageInfo virtual service::FieldResult getHasPreviousPage(service::FieldParams&& params) const; private: - std::future resolveHasNextPage(service::ResolverParams&& params); - std::future resolveHasPreviousPage(service::ResolverParams&& params); + service::AwaitableResolver resolveHasNextPage(service::ResolverParams&& params); + service::AwaitableResolver resolveHasPreviousPage(service::ResolverParams&& params); - std::future resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params); }; class AppointmentEdge @@ -153,10 +153,10 @@ class AppointmentEdge virtual service::FieldResult getCursor(service::FieldParams&& params) const; private: - std::future resolveNode(service::ResolverParams&& params); - std::future resolveCursor(service::ResolverParams&& params); + service::AwaitableResolver resolveNode(service::ResolverParams&& params); + service::AwaitableResolver resolveCursor(service::ResolverParams&& params); - std::future resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params); }; class AppointmentConnection @@ -170,10 +170,10 @@ class AppointmentConnection virtual service::FieldResult>>> getEdges(service::FieldParams&& params) const; private: - std::future resolvePageInfo(service::ResolverParams&& params); - std::future resolveEdges(service::ResolverParams&& params); + service::AwaitableResolver resolvePageInfo(service::ResolverParams&& params); + service::AwaitableResolver resolveEdges(service::ResolverParams&& params); - std::future resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params); }; class TaskEdge @@ -187,10 +187,10 @@ class TaskEdge virtual service::FieldResult getCursor(service::FieldParams&& params) const; private: - std::future resolveNode(service::ResolverParams&& params); - std::future resolveCursor(service::ResolverParams&& params); + service::AwaitableResolver resolveNode(service::ResolverParams&& params); + service::AwaitableResolver resolveCursor(service::ResolverParams&& params); - std::future resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params); }; class TaskConnection @@ -204,10 +204,10 @@ class TaskConnection virtual service::FieldResult>>> getEdges(service::FieldParams&& params) const; private: - std::future resolvePageInfo(service::ResolverParams&& params); - std::future resolveEdges(service::ResolverParams&& params); + service::AwaitableResolver resolvePageInfo(service::ResolverParams&& params); + service::AwaitableResolver resolveEdges(service::ResolverParams&& params); - std::future resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params); }; class FolderEdge @@ -221,10 +221,10 @@ class FolderEdge virtual service::FieldResult getCursor(service::FieldParams&& params) const; private: - std::future resolveNode(service::ResolverParams&& params); - std::future resolveCursor(service::ResolverParams&& params); + service::AwaitableResolver resolveNode(service::ResolverParams&& params); + service::AwaitableResolver resolveCursor(service::ResolverParams&& params); - std::future resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params); }; class FolderConnection @@ -238,10 +238,10 @@ class FolderConnection virtual service::FieldResult>>> getEdges(service::FieldParams&& params) const; private: - std::future resolvePageInfo(service::ResolverParams&& params); - std::future resolveEdges(service::ResolverParams&& params); + service::AwaitableResolver resolvePageInfo(service::ResolverParams&& params); + service::AwaitableResolver resolveEdges(service::ResolverParams&& params); - std::future resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params); }; class CompleteTaskPayload @@ -255,10 +255,10 @@ class CompleteTaskPayload virtual service::FieldResult> getClientMutationId(service::FieldParams&& params) const; private: - std::future resolveTask(service::ResolverParams&& params); - std::future resolveClientMutationId(service::ResolverParams&& params); + service::AwaitableResolver resolveTask(service::ResolverParams&& params); + service::AwaitableResolver resolveClientMutationId(service::ResolverParams&& params); - std::future resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params); }; class Mutation @@ -272,10 +272,10 @@ class Mutation virtual service::FieldResult applySetFloat(service::FieldParams&& params, response::FloatType&& valueArg) const; private: - std::future resolveCompleteTask(service::ResolverParams&& params); - std::future resolveSetFloat(service::ResolverParams&& params); + service::AwaitableResolver resolveCompleteTask(service::ResolverParams&& params); + service::AwaitableResolver resolveSetFloat(service::ResolverParams&& params); - std::future resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params); }; class Subscription @@ -289,10 +289,10 @@ class Subscription virtual service::FieldResult> getNodeChange(service::FieldParams&& params, response::IdType&& idArg) const; private: - std::future resolveNextAppointmentChange(service::ResolverParams&& params); - std::future resolveNodeChange(service::ResolverParams&& params); + service::AwaitableResolver resolveNextAppointmentChange(service::ResolverParams&& params); + service::AwaitableResolver resolveNodeChange(service::ResolverParams&& params); - std::future resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params); }; class Appointment @@ -310,13 +310,13 @@ class Appointment virtual service::FieldResult> getForceError(service::FieldParams&& params) const; private: - std::future resolveId(service::ResolverParams&& params); - std::future resolveWhen(service::ResolverParams&& params); - std::future resolveSubject(service::ResolverParams&& params); - std::future resolveIsNow(service::ResolverParams&& params); - std::future resolveForceError(service::ResolverParams&& params); + service::AwaitableResolver resolveId(service::ResolverParams&& params); + service::AwaitableResolver resolveWhen(service::ResolverParams&& params); + service::AwaitableResolver resolveSubject(service::ResolverParams&& params); + service::AwaitableResolver resolveIsNow(service::ResolverParams&& params); + service::AwaitableResolver resolveForceError(service::ResolverParams&& params); - std::future resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params); }; class Task @@ -332,11 +332,11 @@ class Task virtual service::FieldResult getIsComplete(service::FieldParams&& params) const; private: - std::future resolveId(service::ResolverParams&& params); - std::future resolveTitle(service::ResolverParams&& params); - std::future resolveIsComplete(service::ResolverParams&& params); + service::AwaitableResolver resolveId(service::ResolverParams&& params); + service::AwaitableResolver resolveTitle(service::ResolverParams&& params); + service::AwaitableResolver resolveIsComplete(service::ResolverParams&& params); - std::future resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params); }; class Folder @@ -352,11 +352,11 @@ class Folder virtual service::FieldResult getUnreadCount(service::FieldParams&& params) const; private: - std::future resolveId(service::ResolverParams&& params); - std::future resolveName(service::ResolverParams&& params); - std::future resolveUnreadCount(service::ResolverParams&& params); + service::AwaitableResolver resolveId(service::ResolverParams&& params); + service::AwaitableResolver resolveName(service::ResolverParams&& params); + service::AwaitableResolver resolveUnreadCount(service::ResolverParams&& params); - std::future resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params); }; class NestedType @@ -370,10 +370,10 @@ class NestedType virtual service::FieldResult> getNested(service::FieldParams&& params) const; private: - std::future resolveDepth(service::ResolverParams&& params); - std::future resolveNested(service::ResolverParams&& params); + service::AwaitableResolver resolveDepth(service::ResolverParams&& params); + service::AwaitableResolver resolveNested(service::ResolverParams&& params); - std::future resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params); }; class Expensive @@ -386,9 +386,9 @@ class Expensive virtual service::FieldResult getOrder(service::FieldParams&& params) const; private: - std::future resolveOrder(service::ResolverParams&& params); + service::AwaitableResolver resolveOrder(service::ResolverParams&& params); - std::future resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params); }; } // namespace object diff --git a/samples/validation/ValidationSchema.cpp b/samples/validation/ValidationSchema.cpp index c4d0fed0..581c8c3e 100644 --- a/samples/validation/ValidationSchema.cpp +++ b/samples/validation/ValidationSchema.cpp @@ -46,7 +46,7 @@ validation::DogCommand ModifiedArgument::convert(const r } template <> -std::future ModifiedResult::convert(service::FieldResult&& result, ResolverParams&& params) +service::AwaitableResolver ModifiedResult::convert(service::FieldResult&& result, ResolverParams&& params) { return resolve(std::move(result), std::move(params), [](validation::DogCommand value, const ResolverParams&) @@ -82,7 +82,7 @@ validation::CatCommand ModifiedArgument::convert(const r } template <> -std::future ModifiedResult::convert(service::FieldResult&& result, ResolverParams&& params) +service::AwaitableResolver ModifiedResult::convert(service::FieldResult&& result, ResolverParams&& params) { return resolve(std::move(result), std::move(params), [](validation::CatCommand value, const ResolverParams&) @@ -136,7 +136,7 @@ service::FieldResult> Query::getDog(service::FieldParams&&) throw std::runtime_error(R"ex(Query::getDog is not implemented)ex"); } -std::future Query::resolveDog(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveDog(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -151,7 +151,7 @@ service::FieldResult> Query::getHuman(service::FieldParam throw std::runtime_error(R"ex(Query::getHuman is not implemented)ex"); } -std::future Query::resolveHuman(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveHuman(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -166,7 +166,7 @@ service::FieldResult> Query::getPet(service::Fi throw std::runtime_error(R"ex(Query::getPet is not implemented)ex"); } -std::future Query::resolvePet(service::ResolverParams&& params) +service::AwaitableResolver Query::resolvePet(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -181,7 +181,7 @@ service::FieldResult> Query::getCatOrDog(servic throw std::runtime_error(R"ex(Query::getCatOrDog is not implemented)ex"); } -std::future Query::resolveCatOrDog(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveCatOrDog(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -196,7 +196,7 @@ service::FieldResult> Query::getArguments(service::Fi throw std::runtime_error(R"ex(Query::getArguments is not implemented)ex"); } -std::future Query::resolveArguments(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveArguments(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -211,7 +211,7 @@ service::FieldResult> Query::getFindDog(service::FieldParam throw std::runtime_error(R"ex(Query::getFindDog is not implemented)ex"); } -std::future Query::resolveFindDog(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveFindDog(service::ResolverParams&& params) { auto argComplex = service::ModifiedArgument::require("complex", params.arguments); std::unique_lock resolverLock(_resolverMutex); @@ -227,7 +227,7 @@ service::FieldResult> Query::getBooleanList throw std::runtime_error(R"ex(Query::getBooleanList is not implemented)ex"); } -std::future Query::resolveBooleanList(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveBooleanList(service::ResolverParams&& params) { auto argBooleanListArg = service::ModifiedArgument::require("booleanListArg", params.arguments); std::unique_lock resolverLock(_resolverMutex); @@ -238,17 +238,17 @@ std::future Query::resolveBooleanList(service::Resolver return service::ModifiedResult::convert(std::move(result), std::move(params)); } -std::future Query::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver Query::resolve_typename(service::ResolverParams&& params) { return service::ModifiedResult::convert(response::StringType{ R"gql(Query)gql" }, std::move(params)); } -std::future Query::resolve_schema(service::ResolverParams&& params) +service::AwaitableResolver Query::resolve_schema(service::ResolverParams&& params) { return service::ModifiedResult::convert(std::static_pointer_cast(std::make_shared(_schema)), std::move(params)); } -std::future Query::resolve_type(service::ResolverParams&& params) +service::AwaitableResolver Query::resolve_type(service::ResolverParams&& params) { auto argName = service::ModifiedArgument::require("name", params.arguments); const auto& baseType = _schema->LookupType(argName); @@ -280,7 +280,7 @@ service::FieldResult Dog::getName(service::FieldParams&&) throw std::runtime_error(R"ex(Dog::getName is not implemented)ex"); } -std::future Dog::resolveName(service::ResolverParams&& params) +service::AwaitableResolver Dog::resolveName(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -295,7 +295,7 @@ service::FieldResult> Dog::getNickname(servi throw std::runtime_error(R"ex(Dog::getNickname is not implemented)ex"); } -std::future Dog::resolveNickname(service::ResolverParams&& params) +service::AwaitableResolver Dog::resolveNickname(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -310,7 +310,7 @@ service::FieldResult> Dog::getBarkVolume(servic throw std::runtime_error(R"ex(Dog::getBarkVolume is not implemented)ex"); } -std::future Dog::resolveBarkVolume(service::ResolverParams&& params) +service::AwaitableResolver Dog::resolveBarkVolume(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -325,7 +325,7 @@ service::FieldResult Dog::getDoesKnowCommand(service::Fie throw std::runtime_error(R"ex(Dog::getDoesKnowCommand is not implemented)ex"); } -std::future Dog::resolveDoesKnowCommand(service::ResolverParams&& params) +service::AwaitableResolver Dog::resolveDoesKnowCommand(service::ResolverParams&& params) { auto argDogCommand = service::ModifiedArgument::require("dogCommand", params.arguments); std::unique_lock resolverLock(_resolverMutex); @@ -341,7 +341,7 @@ service::FieldResult Dog::getIsHousetrained(service::Fiel throw std::runtime_error(R"ex(Dog::getIsHousetrained is not implemented)ex"); } -std::future Dog::resolveIsHousetrained(service::ResolverParams&& params) +service::AwaitableResolver Dog::resolveIsHousetrained(service::ResolverParams&& params) { auto argAtOtherHomes = service::ModifiedArgument::require("atOtherHomes", params.arguments); std::unique_lock resolverLock(_resolverMutex); @@ -357,7 +357,7 @@ service::FieldResult> Dog::getOwner(service::FieldParams& throw std::runtime_error(R"ex(Dog::getOwner is not implemented)ex"); } -std::future Dog::resolveOwner(service::ResolverParams&& params) +service::AwaitableResolver Dog::resolveOwner(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -367,7 +367,7 @@ std::future Dog::resolveOwner(service::ResolverParams&& return service::ModifiedResult::convert(std::move(result), std::move(params)); } -std::future Dog::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver Dog::resolve_typename(service::ResolverParams&& params) { return service::ModifiedResult::convert(response::StringType{ R"gql(Dog)gql" }, std::move(params)); } @@ -390,7 +390,7 @@ service::FieldResult Alien::getName(service::FieldParams&& throw std::runtime_error(R"ex(Alien::getName is not implemented)ex"); } -std::future Alien::resolveName(service::ResolverParams&& params) +service::AwaitableResolver Alien::resolveName(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -405,7 +405,7 @@ service::FieldResult> Alien::getHomePlanet(s throw std::runtime_error(R"ex(Alien::getHomePlanet is not implemented)ex"); } -std::future Alien::resolveHomePlanet(service::ResolverParams&& params) +service::AwaitableResolver Alien::resolveHomePlanet(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -415,7 +415,7 @@ std::future Alien::resolveHomePlanet(service::ResolverP return service::ModifiedResult::convert(std::move(result), std::move(params)); } -std::future Alien::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver Alien::resolve_typename(service::ResolverParams&& params) { return service::ModifiedResult::convert(response::StringType{ R"gql(Alien)gql" }, std::move(params)); } @@ -439,7 +439,7 @@ service::FieldResult Human::getName(service::FieldParams&& throw std::runtime_error(R"ex(Human::getName is not implemented)ex"); } -std::future Human::resolveName(service::ResolverParams&& params) +service::AwaitableResolver Human::resolveName(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -454,7 +454,7 @@ service::FieldResult>> Human::getPe throw std::runtime_error(R"ex(Human::getPets is not implemented)ex"); } -std::future Human::resolvePets(service::ResolverParams&& params) +service::AwaitableResolver Human::resolvePets(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -464,7 +464,7 @@ std::future Human::resolvePets(service::ResolverParams& return service::ModifiedResult::convert(std::move(result), std::move(params)); } -std::future Human::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver Human::resolve_typename(service::ResolverParams&& params) { return service::ModifiedResult::convert(response::StringType{ R"gql(Human)gql" }, std::move(params)); } @@ -489,7 +489,7 @@ service::FieldResult Cat::getName(service::FieldParams&&) throw std::runtime_error(R"ex(Cat::getName is not implemented)ex"); } -std::future Cat::resolveName(service::ResolverParams&& params) +service::AwaitableResolver Cat::resolveName(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -504,7 +504,7 @@ service::FieldResult> Cat::getNickname(servi throw std::runtime_error(R"ex(Cat::getNickname is not implemented)ex"); } -std::future Cat::resolveNickname(service::ResolverParams&& params) +service::AwaitableResolver Cat::resolveNickname(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -519,7 +519,7 @@ service::FieldResult Cat::getDoesKnowCommand(service::Fie throw std::runtime_error(R"ex(Cat::getDoesKnowCommand is not implemented)ex"); } -std::future Cat::resolveDoesKnowCommand(service::ResolverParams&& params) +service::AwaitableResolver Cat::resolveDoesKnowCommand(service::ResolverParams&& params) { auto argCatCommand = service::ModifiedArgument::require("catCommand", params.arguments); std::unique_lock resolverLock(_resolverMutex); @@ -535,7 +535,7 @@ service::FieldResult> Cat::getMeowVolume(servic throw std::runtime_error(R"ex(Cat::getMeowVolume is not implemented)ex"); } -std::future Cat::resolveMeowVolume(service::ResolverParams&& params) +service::AwaitableResolver Cat::resolveMeowVolume(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -545,7 +545,7 @@ std::future Cat::resolveMeowVolume(service::ResolverPar return service::ModifiedResult::convert(std::move(result), std::move(params)); } -std::future Cat::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver Cat::resolve_typename(service::ResolverParams&& params) { return service::ModifiedResult::convert(response::StringType{ R"gql(Cat)gql" }, std::move(params)); } @@ -565,7 +565,7 @@ service::FieldResult> Mutation::applyMutateDog( throw std::runtime_error(R"ex(Mutation::applyMutateDog is not implemented)ex"); } -std::future Mutation::resolveMutateDog(service::ResolverParams&& params) +service::AwaitableResolver Mutation::resolveMutateDog(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -575,7 +575,7 @@ std::future Mutation::resolveMutateDog(service::Resolve return service::ModifiedResult::convert(std::move(result), std::move(params)); } -std::future Mutation::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver Mutation::resolve_typename(service::ResolverParams&& params) { return service::ModifiedResult::convert(response::StringType{ R"gql(Mutation)gql" }, std::move(params)); } @@ -595,7 +595,7 @@ service::FieldResult MutateDogResult::getId(service::FieldPara throw std::runtime_error(R"ex(MutateDogResult::getId is not implemented)ex"); } -std::future MutateDogResult::resolveId(service::ResolverParams&& params) +service::AwaitableResolver MutateDogResult::resolveId(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -605,7 +605,7 @@ std::future MutateDogResult::resolveId(service::Resolve return service::ModifiedResult::convert(std::move(result), std::move(params)); } -std::future MutateDogResult::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver MutateDogResult::resolve_typename(service::ResolverParams&& params) { return service::ModifiedResult::convert(response::StringType{ R"gql(MutateDogResult)gql" }, std::move(params)); } @@ -626,7 +626,7 @@ service::FieldResult> Subscription::getNewMessage(servi throw std::runtime_error(R"ex(Subscription::getNewMessage is not implemented)ex"); } -std::future Subscription::resolveNewMessage(service::ResolverParams&& params) +service::AwaitableResolver Subscription::resolveNewMessage(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -641,7 +641,7 @@ service::FieldResult Subscription::getDisallowedSecondRoo throw std::runtime_error(R"ex(Subscription::getDisallowedSecondRootField is not implemented)ex"); } -std::future Subscription::resolveDisallowedSecondRootField(service::ResolverParams&& params) +service::AwaitableResolver Subscription::resolveDisallowedSecondRootField(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -651,7 +651,7 @@ std::future Subscription::resolveDisallowedSecondRootFi return service::ModifiedResult::convert(std::move(result), std::move(params)); } -std::future Subscription::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver Subscription::resolve_typename(service::ResolverParams&& params) { return service::ModifiedResult::convert(response::StringType{ R"gql(Subscription)gql" }, std::move(params)); } @@ -672,7 +672,7 @@ service::FieldResult> Message::getBody(servi throw std::runtime_error(R"ex(Message::getBody is not implemented)ex"); } -std::future Message::resolveBody(service::ResolverParams&& params) +service::AwaitableResolver Message::resolveBody(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -687,7 +687,7 @@ service::FieldResult Message::getSender(service::FieldParams&& throw std::runtime_error(R"ex(Message::getSender is not implemented)ex"); } -std::future Message::resolveSender(service::ResolverParams&& params) +service::AwaitableResolver Message::resolveSender(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -697,7 +697,7 @@ std::future Message::resolveSender(service::ResolverPar return service::ModifiedResult::convert(std::move(result), std::move(params)); } -std::future Message::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver Message::resolve_typename(service::ResolverParams&& params) { return service::ModifiedResult::convert(response::StringType{ R"gql(Message)gql" }, std::move(params)); } @@ -724,7 +724,7 @@ service::FieldResult Arguments::getMultipleReqs(service::Fiel throw std::runtime_error(R"ex(Arguments::getMultipleReqs is not implemented)ex"); } -std::future Arguments::resolveMultipleReqs(service::ResolverParams&& params) +service::AwaitableResolver Arguments::resolveMultipleReqs(service::ResolverParams&& params) { auto argX = service::ModifiedArgument::require("x", params.arguments); auto argY = service::ModifiedArgument::require("y", params.arguments); @@ -741,7 +741,7 @@ service::FieldResult> Arguments::getBoolean throw std::runtime_error(R"ex(Arguments::getBooleanArgField is not implemented)ex"); } -std::future Arguments::resolveBooleanArgField(service::ResolverParams&& params) +service::AwaitableResolver Arguments::resolveBooleanArgField(service::ResolverParams&& params) { auto argBooleanArg = service::ModifiedArgument::require("booleanArg", params.arguments); std::unique_lock resolverLock(_resolverMutex); @@ -757,7 +757,7 @@ service::FieldResult> Arguments::getFloatArgF throw std::runtime_error(R"ex(Arguments::getFloatArgField is not implemented)ex"); } -std::future Arguments::resolveFloatArgField(service::ResolverParams&& params) +service::AwaitableResolver Arguments::resolveFloatArgField(service::ResolverParams&& params) { auto argFloatArg = service::ModifiedArgument::require("floatArg", params.arguments); std::unique_lock resolverLock(_resolverMutex); @@ -773,7 +773,7 @@ service::FieldResult> Arguments::getIntArgField throw std::runtime_error(R"ex(Arguments::getIntArgField is not implemented)ex"); } -std::future Arguments::resolveIntArgField(service::ResolverParams&& params) +service::AwaitableResolver Arguments::resolveIntArgField(service::ResolverParams&& params) { auto argIntArg = service::ModifiedArgument::require("intArg", params.arguments); std::unique_lock resolverLock(_resolverMutex); @@ -789,7 +789,7 @@ service::FieldResult Arguments::getNonNullBooleanArgField throw std::runtime_error(R"ex(Arguments::getNonNullBooleanArgField is not implemented)ex"); } -std::future Arguments::resolveNonNullBooleanArgField(service::ResolverParams&& params) +service::AwaitableResolver Arguments::resolveNonNullBooleanArgField(service::ResolverParams&& params) { auto argNonNullBooleanArg = service::ModifiedArgument::require("nonNullBooleanArg", params.arguments); std::unique_lock resolverLock(_resolverMutex); @@ -805,7 +805,7 @@ service::FieldResult>> Argument throw std::runtime_error(R"ex(Arguments::getNonNullBooleanListField is not implemented)ex"); } -std::future Arguments::resolveNonNullBooleanListField(service::ResolverParams&& params) +service::AwaitableResolver Arguments::resolveNonNullBooleanListField(service::ResolverParams&& params) { auto argNonNullBooleanListArg = service::ModifiedArgument::require("nonNullBooleanListArg", params.arguments); std::unique_lock resolverLock(_resolverMutex); @@ -821,7 +821,7 @@ service::FieldResult Arguments::resolveBooleanListArgField(service::ResolverParams&& params) +service::AwaitableResolver Arguments::resolveBooleanListArgField(service::ResolverParams&& params) { auto argBooleanListArg = service::ModifiedArgument::require("booleanListArg", params.arguments); std::unique_lock resolverLock(_resolverMutex); @@ -837,7 +837,7 @@ service::FieldResult Arguments::getOptionalNonNullBoolean throw std::runtime_error(R"ex(Arguments::getOptionalNonNullBooleanArgField is not implemented)ex"); } -std::future Arguments::resolveOptionalNonNullBooleanArgField(service::ResolverParams&& params) +service::AwaitableResolver Arguments::resolveOptionalNonNullBooleanArgField(service::ResolverParams&& params) { const auto defaultArguments = []() { @@ -862,7 +862,7 @@ std::future Arguments::resolveOptionalNonNullBooleanArg return service::ModifiedResult::convert(std::move(result), std::move(params)); } -std::future Arguments::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver Arguments::resolve_typename(service::ResolverParams&& params) { return service::ModifiedResult::convert(response::StringType{ R"gql(Arguments)gql" }, std::move(params)); } diff --git a/samples/validation/ValidationSchema.h b/samples/validation/ValidationSchema.h index 24565a6e..691368fe 100644 --- a/samples/validation/ValidationSchema.h +++ b/samples/validation/ValidationSchema.h @@ -85,17 +85,17 @@ class Query virtual service::FieldResult> getBooleanList(service::FieldParams&& params, std::optional>&& booleanListArgArg) const; private: - std::future resolveDog(service::ResolverParams&& params); - std::future resolveHuman(service::ResolverParams&& params); - std::future resolvePet(service::ResolverParams&& params); - std::future resolveCatOrDog(service::ResolverParams&& params); - std::future resolveArguments(service::ResolverParams&& params); - std::future resolveFindDog(service::ResolverParams&& params); - std::future resolveBooleanList(service::ResolverParams&& params); - - std::future resolve_typename(service::ResolverParams&& params); - std::future resolve_schema(service::ResolverParams&& params); - std::future resolve_type(service::ResolverParams&& params); + service::AwaitableResolver resolveDog(service::ResolverParams&& params); + service::AwaitableResolver resolveHuman(service::ResolverParams&& params); + service::AwaitableResolver resolvePet(service::ResolverParams&& params); + service::AwaitableResolver resolveCatOrDog(service::ResolverParams&& params); + service::AwaitableResolver resolveArguments(service::ResolverParams&& params); + service::AwaitableResolver resolveFindDog(service::ResolverParams&& params); + service::AwaitableResolver resolveBooleanList(service::ResolverParams&& params); + + service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_schema(service::ResolverParams&& params); + service::AwaitableResolver resolve_type(service::ResolverParams&& params); std::shared_ptr _schema; }; @@ -116,14 +116,14 @@ class Dog virtual service::FieldResult> getOwner(service::FieldParams&& params) const; private: - std::future resolveName(service::ResolverParams&& params); - std::future resolveNickname(service::ResolverParams&& params); - std::future resolveBarkVolume(service::ResolverParams&& params); - std::future resolveDoesKnowCommand(service::ResolverParams&& params); - std::future resolveIsHousetrained(service::ResolverParams&& params); - std::future resolveOwner(service::ResolverParams&& params); - - std::future resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolveName(service::ResolverParams&& params); + service::AwaitableResolver resolveNickname(service::ResolverParams&& params); + service::AwaitableResolver resolveBarkVolume(service::ResolverParams&& params); + service::AwaitableResolver resolveDoesKnowCommand(service::ResolverParams&& params); + service::AwaitableResolver resolveIsHousetrained(service::ResolverParams&& params); + service::AwaitableResolver resolveOwner(service::ResolverParams&& params); + + service::AwaitableResolver resolve_typename(service::ResolverParams&& params); }; class Alien @@ -138,10 +138,10 @@ class Alien virtual service::FieldResult> getHomePlanet(service::FieldParams&& params) const; private: - std::future resolveName(service::ResolverParams&& params); - std::future resolveHomePlanet(service::ResolverParams&& params); + service::AwaitableResolver resolveName(service::ResolverParams&& params); + service::AwaitableResolver resolveHomePlanet(service::ResolverParams&& params); - std::future resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params); }; class Human @@ -156,10 +156,10 @@ class Human virtual service::FieldResult>> getPets(service::FieldParams&& params) const; private: - std::future resolveName(service::ResolverParams&& params); - std::future resolvePets(service::ResolverParams&& params); + service::AwaitableResolver resolveName(service::ResolverParams&& params); + service::AwaitableResolver resolvePets(service::ResolverParams&& params); - std::future resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params); }; class Cat @@ -176,12 +176,12 @@ class Cat virtual service::FieldResult> getMeowVolume(service::FieldParams&& params) const; private: - std::future resolveName(service::ResolverParams&& params); - std::future resolveNickname(service::ResolverParams&& params); - std::future resolveDoesKnowCommand(service::ResolverParams&& params); - std::future resolveMeowVolume(service::ResolverParams&& params); + service::AwaitableResolver resolveName(service::ResolverParams&& params); + service::AwaitableResolver resolveNickname(service::ResolverParams&& params); + service::AwaitableResolver resolveDoesKnowCommand(service::ResolverParams&& params); + service::AwaitableResolver resolveMeowVolume(service::ResolverParams&& params); - std::future resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params); }; class Mutation @@ -194,9 +194,9 @@ class Mutation virtual service::FieldResult> applyMutateDog(service::FieldParams&& params) const; private: - std::future resolveMutateDog(service::ResolverParams&& params); + service::AwaitableResolver resolveMutateDog(service::ResolverParams&& params); - std::future resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params); }; class MutateDogResult @@ -209,9 +209,9 @@ class MutateDogResult virtual service::FieldResult getId(service::FieldParams&& params) const; private: - std::future resolveId(service::ResolverParams&& params); + service::AwaitableResolver resolveId(service::ResolverParams&& params); - std::future resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params); }; class Subscription @@ -225,10 +225,10 @@ class Subscription virtual service::FieldResult getDisallowedSecondRootField(service::FieldParams&& params) const; private: - std::future resolveNewMessage(service::ResolverParams&& params); - std::future resolveDisallowedSecondRootField(service::ResolverParams&& params); + service::AwaitableResolver resolveNewMessage(service::ResolverParams&& params); + service::AwaitableResolver resolveDisallowedSecondRootField(service::ResolverParams&& params); - std::future resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params); }; class Message @@ -242,10 +242,10 @@ class Message virtual service::FieldResult getSender(service::FieldParams&& params) const; private: - std::future resolveBody(service::ResolverParams&& params); - std::future resolveSender(service::ResolverParams&& params); + service::AwaitableResolver resolveBody(service::ResolverParams&& params); + service::AwaitableResolver resolveSender(service::ResolverParams&& params); - std::future resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params); }; class Arguments @@ -265,16 +265,16 @@ class Arguments virtual service::FieldResult getOptionalNonNullBooleanArgField(service::FieldParams&& params, response::BooleanType&& optionalBooleanArgArg) const; private: - std::future resolveMultipleReqs(service::ResolverParams&& params); - std::future resolveBooleanArgField(service::ResolverParams&& params); - std::future resolveFloatArgField(service::ResolverParams&& params); - std::future resolveIntArgField(service::ResolverParams&& params); - std::future resolveNonNullBooleanArgField(service::ResolverParams&& params); - std::future resolveNonNullBooleanListField(service::ResolverParams&& params); - std::future resolveBooleanListArgField(service::ResolverParams&& params); - std::future resolveOptionalNonNullBooleanArgField(service::ResolverParams&& params); - - std::future resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolveMultipleReqs(service::ResolverParams&& params); + service::AwaitableResolver resolveBooleanArgField(service::ResolverParams&& params); + service::AwaitableResolver resolveFloatArgField(service::ResolverParams&& params); + service::AwaitableResolver resolveIntArgField(service::ResolverParams&& params); + service::AwaitableResolver resolveNonNullBooleanArgField(service::ResolverParams&& params); + service::AwaitableResolver resolveNonNullBooleanListField(service::ResolverParams&& params); + service::AwaitableResolver resolveBooleanListArgField(service::ResolverParams&& params); + service::AwaitableResolver resolveOptionalNonNullBooleanArgField(service::ResolverParams&& params); + + service::AwaitableResolver resolve_typename(service::ResolverParams&& params); }; } // namespace object diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6d93f0f2..46d84361 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -62,6 +62,7 @@ function(add_bigobj_flag target) endfunction() add_library(graphqlcoro INTERFACE) +target_compile_features(graphqlcoro INTERFACE cxx_std_20) function(check_coroutine_impl COROUTINE_HEADER COROUTINE_NAMESPACE OPTIONAL_FLAGS OUT_RESULT) set(TEST_FILE "test_${OUT_RESULT}.cpp") @@ -108,8 +109,9 @@ endif() # graphqlpeg add_library(graphqlpeg SyntaxTree.cpp) add_library(cppgraphqlgen::graphqlpeg ALIAS graphqlpeg) -target_link_libraries(graphqlpeg PUBLIC taocpp::pegtl) -target_compile_features(graphqlpeg PUBLIC cxx_std_20) +target_link_libraries(graphqlpeg PUBLIC + graphqlcoro + taocpp::pegtl) target_include_directories(graphqlpeg PUBLIC $ $ @@ -133,10 +135,10 @@ add_library(graphqlresponse Base64.cpp GraphQLResponse.cpp) add_library(cppgraphqlgen::graphqlresponse ALIAS graphqlresponse) -target_compile_features(graphqlresponse PUBLIC cxx_std_20) target_include_directories(graphqlresponse PUBLIC $ $) +target_link_libraries(graphqlresponse PUBLIC graphqlcoro) if(GRAPHQL_UPDATE_VERSION) update_version_rc(graphqlresponse) @@ -158,8 +160,7 @@ if(GRAPHQL_BUILD_SCHEMAGEN OR GRAPHQL_BUILD_CLIENTGEN) GeneratorUtil.cpp) target_link_libraries(generator_util PUBLIC graphqlpeg - graphqlresponse - graphqlcoro) + graphqlresponse) endif() # clientgen @@ -168,7 +169,6 @@ if(GRAPHQL_BUILD_CLIENTGEN) ClientGenerator.cpp RequestLoader.cpp) add_executable(cppgraphqlgen::clientgen ALIAS clientgen) - target_compile_features(clientgen PRIVATE cxx_std_20) target_link_libraries(clientgen PRIVATE generator_util) add_bigobj_flag(clientgen) @@ -208,7 +208,6 @@ endif() if(GRAPHQL_BUILD_SCHEMAGEN) add_executable(schemagen SchemaGenerator.cpp) add_executable(cppgraphqlgen::schemagen ALIAS schemagen) - target_compile_features(schemagen PRIVATE cxx_std_20) target_link_libraries(schemagen PRIVATE generator_util) add_bigobj_flag(schemagen) @@ -347,11 +346,9 @@ add_library(graphqlservice Schema.cpp Validation.cpp) add_library(cppgraphqlgen::graphqlservice ALIAS graphqlservice) -target_compile_features(graphqlservice PUBLIC cxx_std_20) target_link_libraries(graphqlservice PUBLIC graphqlpeg graphqlresponse - graphqlcoro Threads::Threads) if(GRAPHQL_UPDATE_SAMPLES) @@ -377,7 +374,6 @@ add_library(graphqlintrospection Introspection.cpp IntrospectionSchema.cpp) add_library(cppgraphqlgen::graphqlintrospection ALIAS graphqlintrospection) -target_compile_features(graphqlintrospection PUBLIC cxx_std_20) target_link_libraries(graphqlintrospection PUBLIC graphqlservice) if(GRAPHQL_UPDATE_VERSION) @@ -399,7 +395,6 @@ endif() # graphqlclient add_library(graphqlclient GraphQLClient.cpp) add_library(cppgraphqlgen::graphqlclient ALIAS graphqlclient) -target_compile_features(graphqlclient PUBLIC cxx_std_20) target_link_libraries(graphqlclient PUBLIC graphqlpeg graphqlresponse) @@ -430,7 +425,6 @@ if(GRAPHQL_USE_RAPIDJSON) set(BUILD_GRAPHQLJSON ON) add_library(graphqljson JSONResponse.cpp) add_library(cppgraphqlgen::graphqljson ALIAS graphqljson) - target_compile_features(graphqljson PUBLIC cxx_std_20) target_link_libraries(graphqljson PUBLIC graphqlresponse) target_include_directories(graphqljson SYSTEM PRIVATE ${RAPIDJSON_INCLUDE_DIRS}) @@ -451,9 +445,9 @@ install(TARGETS graphqlclient graphqlintrospection graphqlpeg + graphqlcoro graphqlresponse graphqlservice - graphqlcoro EXPORT cppgraphqlgen-targets RUNTIME DESTINATION bin ARCHIVE DESTINATION lib @@ -468,6 +462,7 @@ install(FILES DESTINATION ${GRAPHQL_INSTALL_INCLUDE_DIR}/graphqlservice) install(FILES + ${CMAKE_CURRENT_SOURCE_DIR}/../include/graphqlservice/internal/AwaitableFuture.h ${CMAKE_CURRENT_SOURCE_DIR}/../include/graphqlservice/internal/Base64.h ${CMAKE_CURRENT_SOURCE_DIR}/../include/graphqlservice/internal/Grammar.h ${CMAKE_CURRENT_SOURCE_DIR}/../include/graphqlservice/internal/Schema.h diff --git a/src/GraphQLService.cpp b/src/GraphQLService.cpp index 5fd59095..d2b355c9 100644 --- a/src/GraphQLService.cpp +++ b/src/GraphQLService.cpp @@ -606,7 +606,7 @@ void blockSubFields(const ResolverParams& params) } template <> -std::future ModifiedResult::convert( +AwaitableResolver ModifiedResult::convert( FieldResult&& result, ResolverParams&& params) { blockSubFields(params); @@ -619,7 +619,7 @@ std::future ModifiedResult::convert( } template <> -std::future ModifiedResult::convert( +AwaitableResolver ModifiedResult::convert( FieldResult&& result, ResolverParams&& params) { blockSubFields(params); @@ -632,7 +632,7 @@ std::future ModifiedResult::convert( } template <> -std::future ModifiedResult::convert( +AwaitableResolver ModifiedResult::convert( FieldResult&& result, ResolverParams&& params) { blockSubFields(params); @@ -645,7 +645,7 @@ std::future ModifiedResult::convert( } template <> -std::future ModifiedResult::convert( +AwaitableResolver ModifiedResult::convert( FieldResult&& result, ResolverParams&& params) { blockSubFields(params); @@ -658,7 +658,7 @@ std::future ModifiedResult::convert( } template <> -std::future ModifiedResult::convert( +AwaitableResolver ModifiedResult::convert( FieldResult&& result, ResolverParams&& params) { blockSubFields(params); @@ -671,7 +671,7 @@ std::future ModifiedResult::convert( } template <> -std::future ModifiedResult::convert( +AwaitableResolver ModifiedResult::convert( FieldResult&& result, ResolverParams&& params) { blockSubFields(params); @@ -700,41 +700,24 @@ void requireSubFields(const ResolverParams& params) } template <> -std::future ModifiedResult::convert( +AwaitableResolver ModifiedResult::convert( FieldResult>&& result, ResolverParams&& params) { requireSubFields(params); - auto buildResult = [](FieldResult>&& resultFuture, - ResolverParams&& paramsFuture) { - auto wrappedResult = resultFuture.get(); + auto awaitedResult = co_await result; - if (!wrappedResult) - { - return ResolverResult {}; - } - - return wrappedResult - ->resolve(paramsFuture, - *paramsFuture.selection, - paramsFuture.fragments, - paramsFuture.variables) - .get(); - }; - - if (result.is_future()) + if (!awaitedResult) { - return std::async(params.launch, - std::move(buildResult), - std::move(result), - std::move(params)); + co_return ResolverResult {}; } - std::promise promise; - - promise.set_value(buildResult(std::move(result), std::move(params))); + auto document = co_await awaitedResult->resolve(params, + *params.selection, + params.fragments, + params.variables); - return promise.get_future(); + co_return std::move(document); } // As we recursively expand fragment spreads and inline fragments, we want to accumulate the @@ -759,7 +742,7 @@ class SelectionVisitor void visit(const peg::ast_node& selection); - std::vector>> getValues(); + std::vector> getValues(); private: void visitField(const peg::ast_node& field); @@ -778,7 +761,7 @@ class SelectionVisitor std::list _fragmentDirectives; internal::string_view_set _names; - std::vector>> _values; + std::vector> _values; }; SelectionVisitor::SelectionVisitor(const SelectionSetParams& selectionSetParams, @@ -804,7 +787,7 @@ SelectionVisitor::SelectionVisitor(const SelectionSetParams& selectionSetParams, _values.reserve(count); } -std::vector>> SelectionVisitor::getValues() +std::vector> SelectionVisitor::getValues() { auto values = std::move(_values); @@ -1114,7 +1097,7 @@ Object::Object(TypeNames&& typeNames, ResolverMap&& resolvers) { } -std::future Object::resolve(const SelectionSetParams& selectionSetParams, +AwaitableResolver Object::resolve(const SelectionSetParams& selectionSetParams, const peg::ast_node& selection, const FragmentMap& fragments, const response::Value& variables) const { @@ -1134,62 +1117,56 @@ std::future Object::resolve(const SelectionSetParams& selectionS endSelectionSet(selectionSetParams); - return std::async( - selectionSetParams.launch, - [](std::vector>>&& children) { - ResolverResult document { response::Value { response::Type::Map } }; + auto children = visitor.getValues(); + ResolverResult document { response::Value { response::Type::Map } }; - document.data.reserve(children.size()); + document.data.reserve(children.size()); - for (auto& child : children) - { - auto name = child.first; + for (auto& child : children) + { + auto name = child.first; - try - { - auto value = child.second.get(); + try + { + auto value = co_await child.second; - if (!document.data.emplace_back(std::string { name }, std::move(value.data))) - { - std::ostringstream message; + if (!document.data.emplace_back(std::string { name }, std::move(value.data))) + { + std::ostringstream message; - message << "Ambiguous field error name: " << name; + message << "Ambiguous field error name: " << name; - document.errors.push_back({ message.str() }); - } + document.errors.push_back({ message.str() }); + } - if (!value.errors.empty()) - { - document.errors.splice(document.errors.end(), value.errors); - } - } - catch (schema_exception& scx) - { - auto errors = scx.getStructuredErrors(); + if (!value.errors.empty()) + { + document.errors.splice(document.errors.end(), value.errors); + } + } + catch (schema_exception& scx) + { + auto errors = scx.getStructuredErrors(); - if (!errors.empty()) - { - std::copy(errors.begin(), - errors.end(), - std::back_inserter(document.errors)); - } + if (!errors.empty()) + { + std::copy(errors.begin(), errors.end(), std::back_inserter(document.errors)); + } - document.data.emplace_back(std::string { name }, {}); - } - catch (const std::exception& ex) - { - std::ostringstream message; + document.data.emplace_back(std::string { name }, {}); + } + catch (const std::exception& ex) + { + std::ostringstream message; - message << "Field error name: " << name << " unknown error: " << ex.what(); + message << "Field error name: " << name << " unknown error: " << ex.what(); - document.errors.push_back({ message.str() }); - document.data.emplace_back(std::string { name }, {}); - } - } + document.errors.push_back({ message.str() }); + document.data.emplace_back(std::string { name }, {}); + } + } - return document; - }, - visitor.getValues()); + co_return std::move(document); } bool Object::matchesType(std::string_view typeName) const @@ -1257,7 +1234,7 @@ class OperationDefinitionVisitor std::shared_ptr state, const TypeMap& operations, response::Value&& variables, FragmentMap&& fragments); - std::future getValue(); + AwaitableResolver getValue(); void visit(std::string_view operationType, const peg::ast_node& operationDefinition); @@ -1266,7 +1243,7 @@ class OperationDefinitionVisitor const std::launch _launch; std::shared_ptr _params; const TypeMap& _operations; - std::future _result; + std::optional _result; }; SubscriptionData::SubscriptionData(std::shared_ptr&& data, SubscriptionName&& field, @@ -1294,11 +1271,16 @@ OperationDefinitionVisitor::OperationDefinitionVisitor(ResolverContext resolverC { } -std::future OperationDefinitionVisitor::getValue() +AwaitableResolver OperationDefinitionVisitor::getValue() { - auto result = std::move(_result); + if (!_result) + { + co_return ResolverResult {}; + } - return result; + auto result = co_await *_result; + + co_return std::move(result); } void OperationDefinitionVisitor::visit( @@ -1354,32 +1336,22 @@ void OperationDefinitionVisitor::visit( _params->directives = std::move(operationDirectives); - // Keep the params alive until the deferred lambda has executed - _result = std::async( + const response::Value emptyFragmentDirectives(response::Type::Map); + const SelectionSetParams selectionSetParams { + _resolverContext, + _params->state, + _params->directives, + emptyFragmentDirectives, + emptyFragmentDirectives, + emptyFragmentDirectives, + std::nullopt, _launch, - [selectionContext = _resolverContext, - selectionLaunch = _launch, - params = std::move(_params), - operation = itr->second](const peg::ast_node& selection) { - // The top level object doesn't come from inside of a fragment, so all of the fragment - // directives are empty. - const response::Value emptyFragmentDirectives(response::Type::Map); - const SelectionSetParams selectionSetParams { - selectionContext, - params->state, - params->directives, - emptyFragmentDirectives, - emptyFragmentDirectives, - emptyFragmentDirectives, - std::nullopt, - selectionLaunch, - }; + }; - return operation - ->resolve(selectionSetParams, selection, params->fragments, params->variables) - .get(); - }, - std::cref(*operationDefinition.children.back())); + _result = std::make_optional(itr->second->resolve(selectionSetParams, + *operationDefinition.children.back(), + _params->fragments, + _params->variables)); } // SubscriptionDefinitionVisitor visits the AST collects the fields referenced in the subscription @@ -1671,13 +1643,13 @@ std::pair Request::findOperationDefiniti return result; } -std::future Request::resolve(const std::shared_ptr& state, +response::AwaitableValue Request::resolve(const std::shared_ptr& state, peg::ast& query, const std::string& operationName, response::Value&& variables) const { return resolve(std::launch::deferred, state, query, operationName, std::move(variables)); } -std::future Request::resolve(std::launch launch, +response::AwaitableValue Request::resolve(std::launch launch, const std::shared_ptr& state, peg::ast& query, const std::string& operationName, response::Value&& variables) const { @@ -1738,34 +1710,27 @@ std::future Request::resolve(std::launch launch, operationVisitor.visit(operationDefinition.first, *operationDefinition.second); - return std::async( - launch, - [](std::future&& operationFuture) { - auto result = operationFuture.get(); - response::Value document { response::Type::Map }; + auto result = co_await operationVisitor.getValue(); + response::Value document { response::Type::Map }; - document.emplace_back(std::string { strData }, std::move(result.data)); + document.emplace_back(std::string { strData }, std::move(result.data)); - if (!result.errors.empty()) - { - document.emplace_back(std::string { strErrors }, - buildErrorValues(std::move(result.errors))); - } + if (!result.errors.empty()) + { + document.emplace_back(std::string { strErrors }, + buildErrorValues(std::move(result.errors))); + } - return document; - }, - operationVisitor.getValue()); + co_return std::move(document); } catch (schema_exception& ex) { - std::promise promise; response::Value document(response::Type::Map); document.emplace_back(std::string { strData }, response::Value()); document.emplace_back(std::string { strErrors }, ex.getErrors()); - promise.set_value(std::move(document)); - return promise.get_future(); + co_return std::move(document); } } @@ -1838,53 +1803,45 @@ SubscriptionKey Request::subscribe(SubscriptionParams&& params, SubscriptionCall return key; } -std::future Request::subscribe( +AwaitableSubscriptionKey Request::subscribe( std::launch launch, SubscriptionParams&& params, SubscriptionCallback&& callback) { - return std::async( - launch, - [spThis = shared_from_this(), launch](SubscriptionParams&& paramsFuture, - SubscriptionCallback&& callbackFuture) { - const auto key = spThis->subscribe(std::move(paramsFuture), std::move(callbackFuture)); - const auto itrOperation = spThis->_operations.find(strSubscription); + const auto spThis = shared_from_this(); + const auto key = spThis->subscribe(std::move(params), std::move(callback)); + const auto itrOperation = spThis->_operations.find(strSubscription); - if (itrOperation != spThis->_operations.end()) - { - const auto& operation = itrOperation->second; - const auto& registration = spThis->_subscriptions.at(key); - response::Value emptyFragmentDirectives(response::Type::Map); - const SelectionSetParams selectionSetParams { - ResolverContext::NotifySubscribe, - registration->data->state, - registration->data->directives, - emptyFragmentDirectives, - emptyFragmentDirectives, - emptyFragmentDirectives, - {}, - launch, - }; - - try - { - operation - ->resolve(selectionSetParams, - registration->selection, - registration->data->fragments, - registration->data->variables) - .get(); - } - catch (const std::exception& ex) - { - // Rethrow the exception, but don't leave it subscribed if the resolver failed. - spThis->unsubscribe(key); - throw ex; - } - } + if (itrOperation != spThis->_operations.end()) + { + const auto& operation = itrOperation->second; + const auto& registration = spThis->_subscriptions.at(key); + response::Value emptyFragmentDirectives(response::Type::Map); + const SelectionSetParams selectionSetParams { + ResolverContext::NotifySubscribe, + registration->data->state, + registration->data->directives, + emptyFragmentDirectives, + emptyFragmentDirectives, + emptyFragmentDirectives, + {}, + launch, + }; - return key; - }, - std::move(params), - std::move(callback)); + try + { + co_await operation->resolve(selectionSetParams, + registration->selection, + registration->data->fragments, + registration->data->variables); + } + catch (const std::exception& ex) + { + // Rethrow the exception, but don't leave it subscribed if the resolver failed. + spThis->unsubscribe(key); + throw ex; + } + } + + co_return key; } void Request::unsubscribe(SubscriptionKey key) @@ -1917,63 +1874,62 @@ void Request::unsubscribe(SubscriptionKey key) } } -std::future Request::unsubscribe(std::launch launch, SubscriptionKey key) +AwaitableVoid Request::unsubscribe(std::launch launch, SubscriptionKey key) { - return std::async(launch, [spThis = shared_from_this(), launch, key]() { - const auto itrOperation = spThis->_operations.find(strSubscription); + const auto spThis = shared_from_this(); + const auto itrOperation = spThis->_operations.find(strSubscription); - if (itrOperation != spThis->_operations.end()) - { - const auto& operation = itrOperation->second; - const auto& registration = spThis->_subscriptions.at(key); - response::Value emptyFragmentDirectives(response::Type::Map); - const SelectionSetParams selectionSetParams { - ResolverContext::NotifyUnsubscribe, - registration->data->state, - registration->data->directives, - emptyFragmentDirectives, - emptyFragmentDirectives, - emptyFragmentDirectives, - {}, - launch, - }; + if (itrOperation != spThis->_operations.end()) + { + const auto& operation = itrOperation->second; + const auto& registration = spThis->_subscriptions.at(key); + response::Value emptyFragmentDirectives(response::Type::Map); + const SelectionSetParams selectionSetParams { + ResolverContext::NotifyUnsubscribe, + registration->data->state, + registration->data->directives, + emptyFragmentDirectives, + emptyFragmentDirectives, + emptyFragmentDirectives, + {}, + launch, + }; - operation - ->resolve(selectionSetParams, - registration->selection, - registration->data->fragments, - registration->data->variables) - .get(); - } + co_await operation->resolve(selectionSetParams, + registration->selection, + registration->data->fragments, + registration->data->variables); + } - spThis->unsubscribe(key); - }); + spThis->unsubscribe(key); + + co_return; } void Request::deliver( const SubscriptionName& name, const std::shared_ptr& subscriptionObject) const { - deliver(std::launch::deferred, name, subscriptionObject); + deliver(std::launch::deferred, name, subscriptionObject).get(); } void Request::deliver(const SubscriptionName& name, const SubscriptionArguments& arguments, const std::shared_ptr& subscriptionObject) const { - deliver(std::launch::deferred, name, arguments, subscriptionObject); + deliver(std::launch::deferred, name, arguments, subscriptionObject).get(); } void Request::deliver(const SubscriptionName& name, const SubscriptionArguments& arguments, const SubscriptionArguments& directives, const std::shared_ptr& subscriptionObject) const { - deliver(std::launch::deferred, name, arguments, directives, subscriptionObject); + deliver(std::launch::deferred, name, arguments, directives, subscriptionObject).get(); } void Request::deliver(const SubscriptionName& name, const SubscriptionFilterCallback& applyArguments, const std::shared_ptr& subscriptionObject) const { - deliver(std::launch::deferred, name, applyArguments, subscriptionObject); + deliver(std::launch::deferred, name, applyArguments, subscriptionObject).get(); } void Request::deliver(const SubscriptionName& name, @@ -1981,22 +1937,26 @@ void Request::deliver(const SubscriptionName& name, const SubscriptionFilterCallback& applyDirectives, const std::shared_ptr& subscriptionObject) const { - deliver(std::launch::deferred, name, applyArguments, applyDirectives, subscriptionObject); + deliver(std::launch::deferred, name, applyArguments, applyDirectives, subscriptionObject).get(); } -void Request::deliver(std::launch launch, const SubscriptionName& name, +AwaitableVoid Request::deliver(std::launch launch, const SubscriptionName& name, const std::shared_ptr& subscriptionObject) const { - deliver(launch, name, SubscriptionArguments {}, SubscriptionArguments {}, subscriptionObject); + return deliver(launch, + name, + SubscriptionArguments {}, + SubscriptionArguments {}, + subscriptionObject); } -void Request::deliver(std::launch launch, const SubscriptionName& name, +AwaitableVoid Request::deliver(std::launch launch, const SubscriptionName& name, const SubscriptionArguments& arguments, const std::shared_ptr& subscriptionObject) const { - deliver(launch, name, arguments, SubscriptionArguments {}, subscriptionObject); + return deliver(launch, name, arguments, SubscriptionArguments {}, subscriptionObject); } -void Request::deliver(std::launch launch, const SubscriptionName& name, +AwaitableVoid Request::deliver(std::launch launch, const SubscriptionName& name, const SubscriptionArguments& arguments, const SubscriptionArguments& directives, const std::shared_ptr& subscriptionObject) const { @@ -2014,14 +1974,14 @@ void Request::deliver(std::launch launch, const SubscriptionName& name, return (itrDirective != directives.end() && itrDirective->second == required.second); }; - deliver(launch, name, argumentsMatch, directivesMatch, subscriptionObject); + return deliver(launch, name, argumentsMatch, directivesMatch, subscriptionObject); } -void Request::deliver(std::launch launch, const SubscriptionName& name, +AwaitableVoid Request::deliver(std::launch launch, const SubscriptionName& name, const SubscriptionFilterCallback& applyArguments, const std::shared_ptr& subscriptionObject) const { - deliver( + return deliver( launch, name, applyArguments, @@ -2031,7 +1991,7 @@ void Request::deliver(std::launch launch, const SubscriptionName& name, subscriptionObject); } -void Request::deliver(std::launch launch, const SubscriptionName& name, +AwaitableVoid Request::deliver(std::launch launch, const SubscriptionName& name, const SubscriptionFilterCallback& applyArguments, const SubscriptionFilterCallback& applyDirectives, const std::shared_ptr& subscriptionObject) const @@ -2045,7 +2005,7 @@ void Request::deliver(std::launch launch, const SubscriptionName& name, throw std::logic_error("Subscriptions not supported"); } - const auto& optionalOrDefaultSubscription = + const auto optionalOrDefaultSubscription = subscriptionObject ? subscriptionObject : itrOperation->second; if (!optionalOrDefaultSubscription) @@ -2059,12 +2019,12 @@ void Request::deliver(std::launch launch, const SubscriptionName& name, if (itrListeners == _listeners.end()) { - return; + co_return; } - std::vector> callbacks; + std::vector> registrations; - callbacks.reserve(itrListeners->second.size()); + registrations.reserve(itrListeners->second.size()); for (const auto& key : itrListeners->second) { auto itrSubscription = _subscriptions.find(key); @@ -2107,7 +2067,11 @@ void Request::deliver(std::launch launch, const SubscriptionName& name, continue; } - std::future result; + registrations.push_back(std::move(registration)); + } + + for (const auto& registration : registrations) + { response::Value emptyFragmentDirectives(response::Type::Map); const SelectionSetParams selectionSetParams { ResolverContext::Subscription, @@ -2120,53 +2084,33 @@ void Request::deliver(std::launch launch, const SubscriptionName& name, launch, }; + response::Value document { response::Type::Map }; + try { - result = std::async( - launch, - [](std::future&& operationFuture) { - auto result = operationFuture.get(); - response::Value document { response::Type::Map }; + auto result = co_await optionalOrDefaultSubscription->resolve(selectionSetParams, + registration->selection, + registration->data->fragments, + registration->data->variables); - document.emplace_back(std::string { strData }, std::move(result.data)); + document.emplace_back(std::string { strData }, std::move(result.data)); - if (!result.errors.empty()) - { - document.emplace_back(std::string { strErrors }, - buildErrorValues(std::move(result.errors))); - } - - return document; - }, - optionalOrDefaultSubscription->resolve(selectionSetParams, - registration->selection, - registration->data->fragments, - registration->data->variables)); + if (!result.errors.empty()) + { + document.emplace_back(std::string { strErrors }, + buildErrorValues(std::move(result.errors))); + } } catch (schema_exception& ex) { - std::promise promise; - response::Value document(response::Type::Map); - document.emplace_back(std::string { strData }, response::Value()); document.emplace_back(std::string { strErrors }, ex.getErrors()); - promise.set_value(std::move(document)); - - result = promise.get_future(); } - callbacks.push_back(std::async( - launch, - [registration](std::future document) { - registration->callback(std::move(document)); - }, - std::move(result))); + registration->callback(std::move(document)); } - for (auto& callback : callbacks) - { - callback.get(); - } + co_return; } } // namespace graphql::service diff --git a/src/IntrospectionSchema.cpp b/src/IntrospectionSchema.cpp index 41a15207..23c73aa0 100644 --- a/src/IntrospectionSchema.cpp +++ b/src/IntrospectionSchema.cpp @@ -49,7 +49,7 @@ introspection::TypeKind ModifiedArgument::convert(const } template <> -std::future ModifiedResult::convert(service::FieldResult&& result, ResolverParams&& params) +service::AwaitableResolver ModifiedResult::convert(service::FieldResult&& result, ResolverParams&& params) { return resolve(std::move(result), std::move(params), [](introspection::TypeKind value, const ResolverParams&) @@ -102,7 +102,7 @@ introspection::DirectiveLocation ModifiedArgument -std::future ModifiedResult::convert(service::FieldResult&& result, ResolverParams&& params) +service::AwaitableResolver ModifiedResult::convert(service::FieldResult&& result, ResolverParams&& params) { return resolve(std::move(result), std::move(params), [](introspection::DirectiveLocation value, const ResolverParams&) @@ -134,7 +134,7 @@ Schema::Schema() { } -std::future Schema::resolveTypes(service::ResolverParams&& params) +service::AwaitableResolver Schema::resolveTypes(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -144,7 +144,7 @@ std::future Schema::resolveTypes(service::ResolverParam return service::ModifiedResult::convert(std::move(result), std::move(params)); } -std::future Schema::resolveQueryType(service::ResolverParams&& params) +service::AwaitableResolver Schema::resolveQueryType(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -154,7 +154,7 @@ std::future Schema::resolveQueryType(service::ResolverP return service::ModifiedResult::convert(std::move(result), std::move(params)); } -std::future Schema::resolveMutationType(service::ResolverParams&& params) +service::AwaitableResolver Schema::resolveMutationType(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -164,7 +164,7 @@ std::future Schema::resolveMutationType(service::Resolv return service::ModifiedResult::convert(std::move(result), std::move(params)); } -std::future Schema::resolveSubscriptionType(service::ResolverParams&& params) +service::AwaitableResolver Schema::resolveSubscriptionType(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -174,7 +174,7 @@ std::future Schema::resolveSubscriptionType(service::Re return service::ModifiedResult::convert(std::move(result), std::move(params)); } -std::future Schema::resolveDirectives(service::ResolverParams&& params) +service::AwaitableResolver Schema::resolveDirectives(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -184,7 +184,7 @@ std::future Schema::resolveDirectives(service::Resolver return service::ModifiedResult::convert(std::move(result), std::move(params)); } -std::future Schema::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver Schema::resolve_typename(service::ResolverParams&& params) { return service::ModifiedResult::convert(response::StringType{ R"gql(__Schema)gql" }, std::move(params)); } @@ -207,7 +207,7 @@ Type::Type() { } -std::future Type::resolveKind(service::ResolverParams&& params) +service::AwaitableResolver Type::resolveKind(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -217,7 +217,7 @@ std::future Type::resolveKind(service::ResolverParams&& return service::ModifiedResult::convert(std::move(result), std::move(params)); } -std::future Type::resolveName(service::ResolverParams&& params) +service::AwaitableResolver Type::resolveName(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -227,7 +227,7 @@ std::future Type::resolveName(service::ResolverParams&& return service::ModifiedResult::convert(std::move(result), std::move(params)); } -std::future Type::resolveDescription(service::ResolverParams&& params) +service::AwaitableResolver Type::resolveDescription(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -237,7 +237,7 @@ std::future Type::resolveDescription(service::ResolverP return service::ModifiedResult::convert(std::move(result), std::move(params)); } -std::future Type::resolveFields(service::ResolverParams&& params) +service::AwaitableResolver Type::resolveFields(service::ResolverParams&& params) { const auto defaultArguments = []() { @@ -262,7 +262,7 @@ std::future Type::resolveFields(service::ResolverParams return service::ModifiedResult::convert(std::move(result), std::move(params)); } -std::future Type::resolveInterfaces(service::ResolverParams&& params) +service::AwaitableResolver Type::resolveInterfaces(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -272,7 +272,7 @@ std::future Type::resolveInterfaces(service::ResolverPa return service::ModifiedResult::convert(std::move(result), std::move(params)); } -std::future Type::resolvePossibleTypes(service::ResolverParams&& params) +service::AwaitableResolver Type::resolvePossibleTypes(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -282,7 +282,7 @@ std::future Type::resolvePossibleTypes(service::Resolve return service::ModifiedResult::convert(std::move(result), std::move(params)); } -std::future Type::resolveEnumValues(service::ResolverParams&& params) +service::AwaitableResolver Type::resolveEnumValues(service::ResolverParams&& params) { const auto defaultArguments = []() { @@ -307,7 +307,7 @@ std::future Type::resolveEnumValues(service::ResolverPa return service::ModifiedResult::convert(std::move(result), std::move(params)); } -std::future Type::resolveInputFields(service::ResolverParams&& params) +service::AwaitableResolver Type::resolveInputFields(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -317,7 +317,7 @@ std::future Type::resolveInputFields(service::ResolverP return service::ModifiedResult::convert(std::move(result), std::move(params)); } -std::future Type::resolveOfType(service::ResolverParams&& params) +service::AwaitableResolver Type::resolveOfType(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -327,7 +327,7 @@ std::future Type::resolveOfType(service::ResolverParams return service::ModifiedResult::convert(std::move(result), std::move(params)); } -std::future Type::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver Type::resolve_typename(service::ResolverParams&& params) { return service::ModifiedResult::convert(response::StringType{ R"gql(__Type)gql" }, std::move(params)); } @@ -347,7 +347,7 @@ Field::Field() { } -std::future Field::resolveName(service::ResolverParams&& params) +service::AwaitableResolver Field::resolveName(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -357,7 +357,7 @@ std::future Field::resolveName(service::ResolverParams& return service::ModifiedResult::convert(std::move(result), std::move(params)); } -std::future Field::resolveDescription(service::ResolverParams&& params) +service::AwaitableResolver Field::resolveDescription(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -367,7 +367,7 @@ std::future Field::resolveDescription(service::Resolver return service::ModifiedResult::convert(std::move(result), std::move(params)); } -std::future Field::resolveArgs(service::ResolverParams&& params) +service::AwaitableResolver Field::resolveArgs(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -377,7 +377,7 @@ std::future Field::resolveArgs(service::ResolverParams& return service::ModifiedResult::convert(std::move(result), std::move(params)); } -std::future Field::resolveType(service::ResolverParams&& params) +service::AwaitableResolver Field::resolveType(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -387,7 +387,7 @@ std::future Field::resolveType(service::ResolverParams& return service::ModifiedResult::convert(std::move(result), std::move(params)); } -std::future Field::resolveIsDeprecated(service::ResolverParams&& params) +service::AwaitableResolver Field::resolveIsDeprecated(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -397,7 +397,7 @@ std::future Field::resolveIsDeprecated(service::Resolve return service::ModifiedResult::convert(std::move(result), std::move(params)); } -std::future Field::resolveDeprecationReason(service::ResolverParams&& params) +service::AwaitableResolver Field::resolveDeprecationReason(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -407,7 +407,7 @@ std::future Field::resolveDeprecationReason(service::Re return service::ModifiedResult::convert(std::move(result), std::move(params)); } -std::future Field::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver Field::resolve_typename(service::ResolverParams&& params) { return service::ModifiedResult::convert(response::StringType{ R"gql(__Field)gql" }, std::move(params)); } @@ -425,7 +425,7 @@ InputValue::InputValue() { } -std::future InputValue::resolveName(service::ResolverParams&& params) +service::AwaitableResolver InputValue::resolveName(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -435,7 +435,7 @@ std::future InputValue::resolveName(service::ResolverPa return service::ModifiedResult::convert(std::move(result), std::move(params)); } -std::future InputValue::resolveDescription(service::ResolverParams&& params) +service::AwaitableResolver InputValue::resolveDescription(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -445,7 +445,7 @@ std::future InputValue::resolveDescription(service::Res return service::ModifiedResult::convert(std::move(result), std::move(params)); } -std::future InputValue::resolveType(service::ResolverParams&& params) +service::AwaitableResolver InputValue::resolveType(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -455,7 +455,7 @@ std::future InputValue::resolveType(service::ResolverPa return service::ModifiedResult::convert(std::move(result), std::move(params)); } -std::future InputValue::resolveDefaultValue(service::ResolverParams&& params) +service::AwaitableResolver InputValue::resolveDefaultValue(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -465,7 +465,7 @@ std::future InputValue::resolveDefaultValue(service::Re return service::ModifiedResult::convert(std::move(result), std::move(params)); } -std::future InputValue::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver InputValue::resolve_typename(service::ResolverParams&& params) { return service::ModifiedResult::convert(response::StringType{ R"gql(__InputValue)gql" }, std::move(params)); } @@ -483,7 +483,7 @@ EnumValue::EnumValue() { } -std::future EnumValue::resolveName(service::ResolverParams&& params) +service::AwaitableResolver EnumValue::resolveName(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -493,7 +493,7 @@ std::future EnumValue::resolveName(service::ResolverPar return service::ModifiedResult::convert(std::move(result), std::move(params)); } -std::future EnumValue::resolveDescription(service::ResolverParams&& params) +service::AwaitableResolver EnumValue::resolveDescription(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -503,7 +503,7 @@ std::future EnumValue::resolveDescription(service::Reso return service::ModifiedResult::convert(std::move(result), std::move(params)); } -std::future EnumValue::resolveIsDeprecated(service::ResolverParams&& params) +service::AwaitableResolver EnumValue::resolveIsDeprecated(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -513,7 +513,7 @@ std::future EnumValue::resolveIsDeprecated(service::Res return service::ModifiedResult::convert(std::move(result), std::move(params)); } -std::future EnumValue::resolveDeprecationReason(service::ResolverParams&& params) +service::AwaitableResolver EnumValue::resolveDeprecationReason(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -523,7 +523,7 @@ std::future EnumValue::resolveDeprecationReason(service return service::ModifiedResult::convert(std::move(result), std::move(params)); } -std::future EnumValue::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver EnumValue::resolve_typename(service::ResolverParams&& params) { return service::ModifiedResult::convert(response::StringType{ R"gql(__EnumValue)gql" }, std::move(params)); } @@ -541,7 +541,7 @@ Directive::Directive() { } -std::future Directive::resolveName(service::ResolverParams&& params) +service::AwaitableResolver Directive::resolveName(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -551,7 +551,7 @@ std::future Directive::resolveName(service::ResolverPar return service::ModifiedResult::convert(std::move(result), std::move(params)); } -std::future Directive::resolveDescription(service::ResolverParams&& params) +service::AwaitableResolver Directive::resolveDescription(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -561,7 +561,7 @@ std::future Directive::resolveDescription(service::Reso return service::ModifiedResult::convert(std::move(result), std::move(params)); } -std::future Directive::resolveLocations(service::ResolverParams&& params) +service::AwaitableResolver Directive::resolveLocations(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -571,7 +571,7 @@ std::future Directive::resolveLocations(service::Resolv return service::ModifiedResult::convert(std::move(result), std::move(params)); } -std::future Directive::resolveArgs(service::ResolverParams&& params) +service::AwaitableResolver Directive::resolveArgs(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -581,7 +581,7 @@ std::future Directive::resolveArgs(service::ResolverPar return service::ModifiedResult::convert(std::move(result), std::move(params)); } -std::future Directive::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver Directive::resolve_typename(service::ResolverParams&& params) { return service::ModifiedResult::convert(response::StringType{ R"gql(__Directive)gql" }, std::move(params)); } diff --git a/src/SchemaGenerator.cpp b/src/SchemaGenerator.cpp index 6234a91e..3eb0ae82 100644 --- a/src/SchemaGenerator.cpp +++ b/src/SchemaGenerator.cpp @@ -405,7 +405,7 @@ GRAPHQLINTROSPECTION_EXPORT )cpp" << R"cpp(::)cpp" << enumType.cppType << R"cpp(>::convert( const response::Value& value); template <> -GRAPHQLINTROSPECTION_EXPORT std::future ModifiedResult<)cpp" +GRAPHQLINTROSPECTION_EXPORT AwaitableResolver ModifiedResult<)cpp" << _loader.getSchemaNamespace() << R"cpp(::)cpp" << enumType.cppType << R"cpp(>::convert( FieldResult<)cpp" << _loader.getSchemaNamespace() @@ -491,14 +491,14 @@ void Generator::outputObjectDeclaration( } headerFile << R"cpp( - std::future resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params); )cpp"; if (!_options.noIntrospection && isQueryType) { headerFile - << R"cpp( std::future resolve_schema(service::ResolverParams&& params); - std::future resolve_type(service::ResolverParams&& params); + << R"cpp( service::AwaitableResolver resolve_schema(service::ResolverParams&& params); + service::AwaitableResolver resolve_type(service::ResolverParams&& params); std::shared_ptr _schema; )cpp"; @@ -555,7 +555,7 @@ std::string Generator::getResolverDeclaration(const OutputField& outputField) co std::string fieldName(outputField.cppName); fieldName[0] = static_cast(std::toupper(static_cast(fieldName[0]))); - output << R"cpp( std::future resolve)cpp" << fieldName + output << R"cpp( service::AwaitableResolver resolve)cpp" << fieldName << R"cpp((service::ResolverParams&& params); )cpp"; @@ -657,7 +657,7 @@ template <> } template <> -std::future ModifiedResult<)cpp" +service::AwaitableResolver ModifiedResult<)cpp" << _loader.getSchemaNamespace() << R"cpp(::)cpp" << enumType.cppType << R"cpp(>::convert(service::FieldResult<)cpp" << _loader.getSchemaNamespace() << R"cpp(::)cpp" << enumType.cppType @@ -1478,7 +1478,7 @@ service::FieldResult<)cpp" } sourceFile << R"cpp( -std::future )cpp" +service::AwaitableResolver )cpp" << objectType.cppType << R"cpp(::resolve)cpp" << fieldName << R"cpp((service::ResolverParams&& params) { @@ -1558,7 +1558,7 @@ std::future )cpp" } sourceFile << R"cpp( -std::future )cpp" +service::AwaitableResolver )cpp" << objectType.cppType << R"cpp(::resolve_typename(service::ResolverParams&& params) { return service::ModifiedResult::convert(response::StringType{ R"gql()cpp" @@ -1570,7 +1570,7 @@ std::future )cpp" { sourceFile << R"cpp( -std::future )cpp" +service::AwaitableResolver )cpp" << objectType.cppType << R"cpp(::resolve_schema(service::ResolverParams&& params) { return service::ModifiedResult::convert(std::static_pointer_cast(std::make_shared<)cpp" @@ -1578,7 +1578,7 @@ std::future )cpp" << R"cpp(::Schema>(_schema)), std::move(params)); } -std::future )cpp" +service::AwaitableResolver )cpp" << objectType.cppType << R"cpp(::resolve_type(service::ResolverParams&& params) { auto argName = service::ModifiedArgument::require("name", params.arguments); diff --git a/test/ClientTests.cpp b/test/ClientTests.cpp index 368b2373..35951bfd 100644 --- a/test/ClientTests.cpp +++ b/test/ClientTests.cpp @@ -242,8 +242,8 @@ TEST_F(ClientCase, SubscribeNextAppointmentChangeDefault) std::move(query), "TestSubscription", std::move(variables) }, - [&result](std::future response) { - result = response.get(); + [&result](response::Value&& response) { + result = std::move(response); }); _service->deliver("nextAppointmentChange", nullptr); _service->unsubscribe(key); diff --git a/test/NoIntrospectionTests.cpp b/test/NoIntrospectionTests.cpp index cc052530..697bc50d 100644 --- a/test/NoIntrospectionTests.cpp +++ b/test/NoIntrospectionTests.cpp @@ -13,7 +13,6 @@ using namespace graphql; using namespace std::literals; - // this is similar to TodayTests, will trust QueryEverything works // and then check if introspection is disabled @@ -35,32 +34,41 @@ class NoIntrospectionServiceCase : public ::testing::Test std::copy(fakeFolderId.cbegin(), fakeFolderId.cend(), _fakeFolderId.begin()); auto query = std::make_shared( - []() -> std::vector> - { - ++_getAppointmentsCount; - return { std::make_shared(response::IdType(_fakeAppointmentId), "tomorrow", "Lunch?", false) }; - }, []() -> std::vector> - { - ++_getTasksCount; - return { std::make_shared(response::IdType(_fakeTaskId), "Don't forget", true) }; - }, []() -> std::vector> - { - ++_getUnreadCountsCount; - return { std::make_shared(response::IdType(_fakeFolderId), "\"Fake\" Inbox", 3) }; - }); + []() -> std::vector> { + ++_getAppointmentsCount; + return { std::make_shared(response::IdType(_fakeAppointmentId), + "tomorrow", + "Lunch?", + false) }; + }, + []() -> std::vector> { + ++_getTasksCount; + return { std::make_shared(response::IdType(_fakeTaskId), + "Don't forget", + true) }; + }, + []() -> std::vector> { + ++_getUnreadCountsCount; + return { std::make_shared(response::IdType(_fakeFolderId), + "\"Fake\" Inbox", + 3) }; + }); auto mutation = std::make_shared( - [](today::CompleteTaskInput&& input) -> std::shared_ptr - { - return std::make_shared( - std::make_shared(std::move(input.id), "Mutated Task!", *(input.isComplete)), - std::move(input.clientMutationId) - ); - }); + [](today::CompleteTaskInput&& input) -> std::shared_ptr { + return std::make_shared( + std::make_shared(std::move(input.id), + "Mutated Task!", + *(input.isComplete)), + std::move(input.clientMutationId)); + }); auto subscription = std::make_shared( - [](const std::shared_ptr&) -> std::shared_ptr - { - return { std::make_shared(response::IdType(_fakeAppointmentId), "tomorrow", "Lunch?", true) }; - }); + [](const std::shared_ptr&) + -> std::shared_ptr { + return { std::make_shared(response::IdType(_fakeAppointmentId), + "tomorrow", + "Lunch?", + true) }; + }); _service = std::make_shared(query, mutation, subscription); } @@ -134,13 +142,20 @@ TEST_F(NoIntrospectionServiceCase, QueryEverything) })"_graphql; response::Value variables(response::Type::Map); auto state = std::make_shared(1); - auto result = _service->resolve(std::launch::async, state, query, "Everything", std::move(variables)).get(); - EXPECT_EQ(size_t(1), _getAppointmentsCount) << "today service lazy loads the appointments and caches the result"; - EXPECT_EQ(size_t(1), _getTasksCount) << "today service lazy loads the tasks and caches the result"; - EXPECT_EQ(size_t(1), _getUnreadCountsCount) << "today service lazy loads the unreadCounts and caches the result"; - EXPECT_EQ(size_t(1), state->appointmentsRequestId) << "today service passed the same RequestState"; + auto result = + _service->resolve(std::launch::async, state, query, "Everything", std::move(variables)) + .get(); + EXPECT_EQ(size_t(1), _getAppointmentsCount) + << "today service lazy loads the appointments and caches the result"; + EXPECT_EQ(size_t(1), _getTasksCount) + << "today service lazy loads the tasks and caches the result"; + EXPECT_EQ(size_t(1), _getUnreadCountsCount) + << "today service lazy loads the unreadCounts and caches the result"; + EXPECT_EQ(size_t(1), state->appointmentsRequestId) + << "today service passed the same RequestState"; EXPECT_EQ(size_t(1), state->tasksRequestId) << "today service passed the same RequestState"; - EXPECT_EQ(size_t(1), state->unreadCountsRequestId) << "today service passed the same RequestState"; + EXPECT_EQ(size_t(1), state->unreadCountsRequestId) + << "today service passed the same RequestState"; EXPECT_EQ(size_t(1), state->loadAppointmentsCount) << "today service called the loader once"; EXPECT_EQ(size_t(1), state->loadTasksCount) << "today service called the loader once"; EXPECT_EQ(size_t(1), state->loadUnreadCountsCount) << "today service called the loader once"; @@ -156,37 +171,55 @@ TEST_F(NoIntrospectionServiceCase, QueryEverything) const auto data = service::ScalarArgument::require("data", result); const auto appointments = service::ScalarArgument::require("appointments", data); - const auto appointmentEdges = service::ScalarArgument::require("edges", appointments); + const auto appointmentEdges = + service::ScalarArgument::require("edges", appointments); ASSERT_EQ(1, appointmentEdges.size()) << "appointments should have 1 entry"; - ASSERT_TRUE(appointmentEdges[0].type() == response::Type::Map) << "appointment should be an object"; + ASSERT_TRUE(appointmentEdges[0].type() == response::Type::Map) + << "appointment should be an object"; const auto appointmentNode = service::ScalarArgument::require("node", appointmentEdges[0]); - EXPECT_EQ(_fakeAppointmentId, service::IdArgument::require("id", appointmentNode)) << "id should match in base64 encoding"; - EXPECT_EQ("Lunch?", service::StringArgument::require("subject", appointmentNode)) << "subject should match"; - EXPECT_EQ("tomorrow", service::StringArgument::require("when", appointmentNode)) << "when should match"; - EXPECT_FALSE(service::BooleanArgument::require("isNow", appointmentNode)) << "isNow should match"; - EXPECT_EQ("Appointment", service::StringArgument::require("__typename", appointmentNode)) << "__typename should match"; + EXPECT_EQ(_fakeAppointmentId, service::IdArgument::require("id", appointmentNode)) + << "id should match in base64 encoding"; + EXPECT_EQ("Lunch?", service::StringArgument::require("subject", appointmentNode)) + << "subject should match"; + EXPECT_EQ("tomorrow", service::StringArgument::require("when", appointmentNode)) + << "when should match"; + EXPECT_FALSE(service::BooleanArgument::require("isNow", appointmentNode)) + << "isNow should match"; + EXPECT_EQ("Appointment", service::StringArgument::require("__typename", appointmentNode)) + << "__typename should match"; const auto tasks = service::ScalarArgument::require("tasks", data); - const auto taskEdges = service::ScalarArgument::require("edges", tasks); + const auto taskEdges = + service::ScalarArgument::require("edges", tasks); ASSERT_EQ(1, taskEdges.size()) << "tasks should have 1 entry"; ASSERT_TRUE(taskEdges[0].type() == response::Type::Map) << "task should be an object"; const auto taskNode = service::ScalarArgument::require("node", taskEdges[0]); - EXPECT_EQ(_fakeTaskId, service::IdArgument::require("id", taskNode)) << "id should match in base64 encoding"; - EXPECT_EQ("Don't forget", service::StringArgument::require("title", taskNode)) << "title should match"; - EXPECT_TRUE(service::BooleanArgument::require("isComplete", taskNode)) << "isComplete should match"; - EXPECT_EQ("Task", service::StringArgument::require("__typename", taskNode)) << "__typename should match"; + EXPECT_EQ(_fakeTaskId, service::IdArgument::require("id", taskNode)) + << "id should match in base64 encoding"; + EXPECT_EQ("Don't forget", service::StringArgument::require("title", taskNode)) + << "title should match"; + EXPECT_TRUE(service::BooleanArgument::require("isComplete", taskNode)) + << "isComplete should match"; + EXPECT_EQ("Task", service::StringArgument::require("__typename", taskNode)) + << "__typename should match"; const auto unreadCounts = service::ScalarArgument::require("unreadCounts", data); - const auto unreadCountEdges = service::ScalarArgument::require("edges", unreadCounts); + const auto unreadCountEdges = + service::ScalarArgument::require("edges", unreadCounts); ASSERT_EQ(1, unreadCountEdges.size()) << "unreadCounts should have 1 entry"; - ASSERT_TRUE(unreadCountEdges[0].type() == response::Type::Map) << "unreadCount should be an object"; + ASSERT_TRUE(unreadCountEdges[0].type() == response::Type::Map) + << "unreadCount should be an object"; const auto unreadCountNode = service::ScalarArgument::require("node", unreadCountEdges[0]); - EXPECT_EQ(_fakeFolderId, service::IdArgument::require("id", unreadCountNode)) << "id should match in base64 encoding"; - EXPECT_EQ("\"Fake\" Inbox", service::StringArgument::require("name", unreadCountNode)) << "name should match"; - EXPECT_EQ(3, service::IntArgument::require("unreadCount", unreadCountNode)) << "unreadCount should match"; - EXPECT_EQ("Folder", service::StringArgument::require("__typename", unreadCountNode)) << "__typename should match"; + EXPECT_EQ(_fakeFolderId, service::IdArgument::require("id", unreadCountNode)) + << "id should match in base64 encoding"; + EXPECT_EQ("\"Fake\" Inbox", service::StringArgument::require("name", unreadCountNode)) + << "name should match"; + EXPECT_EQ(3, service::IntArgument::require("unreadCount", unreadCountNode)) + << "unreadCount should match"; + EXPECT_EQ("Folder", service::StringArgument::require("__typename", unreadCountNode)) + << "__typename should match"; } - catch (service::schema_exception & ex) + catch (service::schema_exception& ex) { FAIL() << response::toJSON(ex.getErrors()); } @@ -200,8 +233,8 @@ TEST_F(NoIntrospectionServiceCase, NoSchema) } })"_graphql; response::Value variables(response::Type::Map); - auto future = _service->resolve(std::launch::deferred, nullptr, query, "", std::move(variables)); - auto result = future.get(); + auto result = + _service->resolve(std::launch::deferred, nullptr, query, "", std::move(variables)).get(); try { @@ -209,9 +242,12 @@ TEST_F(NoIntrospectionServiceCase, NoSchema) auto errorsItr = result.find("errors"); ASSERT_FALSE(errorsItr == result.get().cend()); auto errorsString = response::toJSON(response::Value(errorsItr->second)); - EXPECT_EQ(R"js([{"message":"Undefined field type: Query name: __schema","locations":[{"line":2,"column":4}]}])js", errorsString) << "error should match"; + EXPECT_EQ( + R"js([{"message":"Undefined field type: Query name: __schema","locations":[{"line":2,"column":4}]}])js", + errorsString) + << "error should match"; } - catch (service::schema_exception & ex) + catch (service::schema_exception& ex) { FAIL() << response::toJSON(ex.getErrors()); } @@ -225,8 +261,8 @@ TEST_F(NoIntrospectionServiceCase, NoType) } })"_graphql; response::Value variables(response::Type::Map); - auto future = _service->resolve(std::launch::deferred, nullptr, query, "", std::move(variables)); - auto result = future.get(); + auto result = + _service->resolve(std::launch::deferred, nullptr, query, "", std::move(variables)).get(); try { @@ -234,9 +270,12 @@ TEST_F(NoIntrospectionServiceCase, NoType) auto errorsItr = result.find("errors"); ASSERT_FALSE(errorsItr == result.get().cend()); auto errorsString = response::toJSON(response::Value(errorsItr->second)); - EXPECT_EQ(R"js([{"message":"Undefined field type: Query name: __type","locations":[{"line":2,"column":4}]}])js", errorsString) << "error should match"; + EXPECT_EQ( + R"js([{"message":"Undefined field type: Query name: __type","locations":[{"line":2,"column":4}]}])js", + errorsString) + << "error should match"; } - catch (service::schema_exception & ex) + catch (service::schema_exception& ex) { FAIL() << response::toJSON(ex.getErrors()); } diff --git a/test/TodayTests.cpp b/test/TodayTests.cpp index 9e629850..2737993b 100644 --- a/test/TodayTests.cpp +++ b/test/TodayTests.cpp @@ -611,8 +611,8 @@ TEST_F(TodayServiceCase, SubscribeNextAppointmentChangeDefault) std::move(query), "TestSubscription", std::move(variables) }, - [&result](std::future response) { - result = response.get(); + [&result](response::Value&& response) { + result = std::move(response); }); _service->deliver("nextAppointmentChange", nullptr); _service->unsubscribe(key); @@ -671,8 +671,8 @@ TEST_F(TodayServiceCase, SubscribeNextAppointmentChangeOverride) std::move(query), "TestSubscription", std::move(variables) }, - [&result](std::future response) { - result = response.get(); + [&result](response::Value&& response) { + result = std::move(response); }); _service->deliver("nextAppointmentChange", std::static_pointer_cast(subscriptionObject)); @@ -1204,8 +1204,8 @@ TEST_F(TodayServiceCase, SubscribeNodeChangeMatchingId) std::move(query), "TestSubscription", std::move(variables) }, - [&result](std::future response) { - result = response.get(); + [&result](response::Value&& response) { + result = std::move(response); }); _service->deliver("nodeChange", { { "id", response::Value(std::string("ZmFrZVRhc2tJZA==")) } }, @@ -1260,7 +1260,7 @@ TEST_F(TodayServiceCase, SubscribeNodeChangeMismatchedId) std::move(query), "TestSubscription", std::move(variables) }, - [&calledGet](std::future) { + [&calledGet](response::Value&&) { calledGet = true; }); _service->deliver("nodeChange", @@ -1317,8 +1317,8 @@ TEST_F(TodayServiceCase, SubscribeNodeChangeFuzzyComparator) std::move(query), "TestSubscription", std::move(variables) }, - [&result](std::future response) { - result = response.get(); + [&result](response::Value&& response) { + result = std::move(response); }); _service->deliver("nodeChange", filterCallback, @@ -1383,7 +1383,7 @@ TEST_F(TodayServiceCase, SubscribeNodeChangeFuzzyMismatch) std::move(query), "TestSubscription", std::move(variables) }, - [&calledGet](std::future) { + [&calledGet](response::Value&&) { calledGet = true; }); _service->deliver("nodeChange", @@ -1431,8 +1431,8 @@ TEST_F(TodayServiceCase, SubscribeNodeChangeMatchingVariable) std::move(query), "TestSubscription", std::move(variables) }, - [&result](std::future response) { - result = response.get(); + [&result](response::Value&& response) { + result = std::move(response); }); _service->deliver("nodeChange", { { "id", response::Value(std::string("ZmFrZVRhc2tJZA==")) } }, @@ -1477,15 +1477,8 @@ TEST_F(TodayServiceCase, DeferredQueryAppointmentsById) variables.emplace_back("appointmentId", response::Value(std::string("ZmFrZUFwcG9pbnRtZW50SWQ="))); auto state = std::make_shared(15); - auto future = _service->resolve(std::launch::deferred, state, query, "", std::move(variables)); - ASSERT_EQ(std::future_status::deferred, future.wait_for(0s)) << "should be deferred"; - EXPECT_EQ(size_t(0), state->loadAppointmentsCount) - << "today service should not call the loader until we block"; - ASSERT_EQ(std::future_status::deferred, future.wait_for(0s)) - << "should stay deferred until we block"; - EXPECT_EQ(size_t(0), state->loadAppointmentsCount) - << "today service should not call the loader until we block"; - auto result = future.get(); + auto result = + _service->resolve(std::launch::deferred, state, query, "", std::move(variables)).get(); EXPECT_EQ(size_t(1), _getAppointmentsCount) << "today service lazy loads the appointments and caches the result"; EXPECT_GE(size_t(1), _getTasksCount) @@ -1544,9 +1537,8 @@ TEST_F(TodayServiceCase, NonBlockingQueryAppointmentsById) variables.emplace_back("appointmentId", response::Value(std::string("ZmFrZUFwcG9pbnRtZW50SWQ="))); auto state = std::make_shared(16); - auto future = _service->resolve(std::launch::async, state, query, "", std::move(variables)); - ASSERT_NE(std::future_status::deferred, future.wait_for(0s)) << "should not start out deferred"; - auto result = future.get(); + auto result = + _service->resolve(std::launch::async, state, query, "", std::move(variables)).get(); EXPECT_EQ(size_t(1), _getAppointmentsCount) << "today service lazy loads the appointments and caches the result"; EXPECT_GE(size_t(1), _getTasksCount) @@ -1599,9 +1591,8 @@ TEST_F(TodayServiceCase, NonExistentTypeIntrospection) } })"_graphql; response::Value variables(response::Type::Map); - auto future = - _service->resolve(std::launch::deferred, nullptr, query, "", std::move(variables)); - auto result = future.get(); + auto result = + _service->resolve(std::launch::deferred, nullptr, query, "", std::move(variables)).get(); try { @@ -1637,8 +1628,8 @@ TEST_F(TodayServiceCase, SubscribeNextAppointmentChangeAsync) std::move(query), "TestSubscription", std::move(variables) }, - [&result](std::future response) { - result = response.get(); + [&result](response::Value&& response) { + result = std::move(response); }); _service->deliver(std::launch::async, "nextAppointmentChange", nullptr); _service->unsubscribe(key); @@ -1680,12 +1671,13 @@ TEST_F(TodayServiceCase, NonblockingDeferredExpensive) response::Value variables(response::Type::Map); auto state = std::make_shared(18); std::unique_lock testLock(today::Expensive::testMutex); - auto future = _service->resolve(std::launch::deferred, - state, - query, - "NonblockingDeferredExpensive", - std::move(variables)); - auto result = future.get(); + auto result = _service + ->resolve(std::launch::deferred, + state, + query, + "NonblockingDeferredExpensive", + std::move(variables)) + .get(); try { @@ -1715,12 +1707,13 @@ TEST_F(TodayServiceCase, BlockingAsyncExpensive) response::Value variables(response::Type::Map); auto state = std::make_shared(19); std::unique_lock testLock(today::Expensive::testMutex); - auto future = _service->resolve(std::launch::async, - state, - query, - "BlockingAsyncExpensive", - std::move(variables)); - auto result = future.get(); + auto result = _service + ->resolve(std::launch::async, + state, + query, + "BlockingAsyncExpensive", + std::move(variables)) + .get(); try { @@ -1833,15 +1826,17 @@ TEST_F(TodayServiceCase, SubscribeUnsubscribeNotificationsAsync) today::NextAppointmentChange::getCount(service::ResolverContext::Subscription); const auto notifyUnsubscribeBegin = today::NextAppointmentChange::getCount(service::ResolverContext::NotifyUnsubscribe); - auto key = _service->subscribe(std::launch::async, - service::SubscriptionParams { state, - std::move(query), - "TestSubscription", - std::move(variables) }, - [&calledCallback](std::future response) { - calledCallback = true; - }); - _service->unsubscribe(std::launch::async, key.get()).get(); + auto key = _service + ->subscribe(std::launch::async, + service::SubscriptionParams { state, + std::move(query), + "TestSubscription", + std::move(variables) }, + [&calledCallback](response::Value&& response) { + calledCallback = true; + }) + .get(); + _service->unsubscribe(std::launch::async, key).get(); const auto notifySubscribeEnd = today::NextAppointmentChange::getCount(service::ResolverContext::NotifySubscribe); const auto subscriptionEnd = @@ -1883,15 +1878,17 @@ TEST_F(TodayServiceCase, SubscribeUnsubscribeNotificationsDeferred) today::NextAppointmentChange::getCount(service::ResolverContext::Subscription); const auto notifyUnsubscribeBegin = today::NextAppointmentChange::getCount(service::ResolverContext::NotifyUnsubscribe); - auto key = _service->subscribe(std::launch::deferred, - service::SubscriptionParams { state, - std::move(query), - "TestSubscription", - std::move(variables) }, - [&calledCallback](std::future response) { - calledCallback = true; - }); - _service->unsubscribe(std::launch::deferred, key.get()).get(); + auto key = _service + ->subscribe(std::launch::deferred, + service::SubscriptionParams { state, + std::move(query), + "TestSubscription", + std::move(variables) }, + [&calledCallback](response::Value&& response) { + calledCallback = true; + }) + .get(); + _service->unsubscribe(std::launch::deferred, key).get(); const auto notifySubscribeEnd = today::NextAppointmentChange::getCount(service::ResolverContext::NotifySubscribe); const auto subscriptionEnd = From 2a27b523aa9ccacbb9ce824a58117a2676215b47 Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Wed, 3 Nov 2021 10:19:24 -0700 Subject: [PATCH 014/119] Simplify awaiters --- include/graphqlservice/GraphQLResponse.h | 4 +- include/graphqlservice/GraphQLService.h | 47 +++++------ .../{AwaitableFuture.h => Awaitable.h} | 78 +++++-------------- samples/today/TodayMock.cpp | 21 ++--- src/CMakeLists.txt | 2 +- src/GraphQLService.cpp | 14 ++-- 6 files changed, 54 insertions(+), 112 deletions(-) rename include/graphqlservice/internal/{AwaitableFuture.h => Awaitable.h} (57%) diff --git a/include/graphqlservice/GraphQLResponse.h b/include/graphqlservice/GraphQLResponse.h index 8dec58ab..6681b7b0 100644 --- a/include/graphqlservice/GraphQLResponse.h +++ b/include/graphqlservice/GraphQLResponse.h @@ -18,7 +18,7 @@ #endif // !GRAPHQL_DLLEXPORTS // clang-format on -#include "graphqlservice/internal/AwaitableFuture.h" +#include "graphqlservice/internal/Awaitable.h" #include #include @@ -261,7 +261,7 @@ template <> GRAPHQLRESPONSE_EXPORT IdType Value::release(); #endif // GRAPHQL_DLLEXPORTS -using AwaitableValue = internal::AwaitableFuture; +using AwaitableValue = internal::Awaitable; } // namespace graphql::response diff --git a/include/graphqlservice/GraphQLService.h b/include/graphqlservice/GraphQLService.h index 077f7b64..d65028de 100644 --- a/include/graphqlservice/GraphQLService.h +++ b/include/graphqlservice/GraphQLService.h @@ -21,11 +21,10 @@ #include "graphqlservice/GraphQLParse.h" #include "graphqlservice/GraphQLResponse.h" -#include "graphqlservice/internal/AwaitableFuture.h" +#include "graphqlservice/internal/Awaitable.h" #include "graphqlservice/internal/SortedMap.h" #include "graphqlservice/internal/Version.h" -#include #include #include #include @@ -242,21 +241,12 @@ class FieldResult bool await_ready() const noexcept { - using namespace std::literals; - - return (!is_future() - || std::get>(_value).wait_for(0s) != std::future_status::timeout); + return true; } void await_suspend(coro::coroutine_handle<> h) const { - if (is_future()) - { - std::thread([this, h]() mutable { - std::get>(_value).wait(); - h.resume(); - }).detach(); - } + h.resume(); } T await_resume() @@ -325,7 +315,7 @@ struct ResolverResult std::list errors; }; -using AwaitableResolver = internal::AwaitableFuture; +using AwaitableResolver = internal::Awaitable; using Resolver = std::function; using ResolverMap = internal::string_view_map; @@ -852,9 +842,6 @@ using SubscriptionFilterCallback = std::function; -using internal::AwaitableVoid; - // Registration information for subscription, cached in the Request::subscribe call. struct SubscriptionData : std::enable_shared_from_this { @@ -902,11 +889,12 @@ class Request : public std::enable_shared_from_this GRAPHQLSERVICE_EXPORT SubscriptionKey subscribe( SubscriptionParams&& params, SubscriptionCallback&& callback); - GRAPHQLSERVICE_EXPORT AwaitableSubscriptionKey subscribe( + GRAPHQLSERVICE_EXPORT internal::Awaitable subscribe( std::launch launch, SubscriptionParams&& params, SubscriptionCallback&& callback); GRAPHQLSERVICE_EXPORT void unsubscribe(SubscriptionKey key); - GRAPHQLSERVICE_EXPORT AwaitableVoid unsubscribe(std::launch launch, SubscriptionKey key); + GRAPHQLSERVICE_EXPORT internal::Awaitable unsubscribe( + std::launch launch, SubscriptionKey key); GRAPHQLSERVICE_EXPORT void deliver( const SubscriptionName& name, const std::shared_ptr& subscriptionObject) const; @@ -924,19 +912,20 @@ class Request : public std::enable_shared_from_this const SubscriptionFilterCallback& applyDirectives, const std::shared_ptr& subscriptionObject) const; - GRAPHQLSERVICE_EXPORT AwaitableVoid deliver(std::launch launch, const SubscriptionName& name, - const std::shared_ptr& subscriptionObject) const; - GRAPHQLSERVICE_EXPORT AwaitableVoid deliver(std::launch launch, const SubscriptionName& name, - const SubscriptionArguments& arguments, + GRAPHQLSERVICE_EXPORT internal::Awaitable deliver(std::launch launch, + const SubscriptionName& name, const std::shared_ptr& subscriptionObject) const; + GRAPHQLSERVICE_EXPORT internal::Awaitable deliver(std::launch launch, + const SubscriptionName& name, const SubscriptionArguments& arguments, const std::shared_ptr& subscriptionObject) const; - GRAPHQLSERVICE_EXPORT AwaitableVoid deliver(std::launch launch, const SubscriptionName& name, - const SubscriptionArguments& arguments, const SubscriptionArguments& directives, + GRAPHQLSERVICE_EXPORT internal::Awaitable deliver(std::launch launch, + const SubscriptionName& name, const SubscriptionArguments& arguments, + const SubscriptionArguments& directives, const std::shared_ptr& subscriptionObject) const; - GRAPHQLSERVICE_EXPORT AwaitableVoid deliver(std::launch launch, const SubscriptionName& name, - const SubscriptionFilterCallback& applyArguments, + GRAPHQLSERVICE_EXPORT internal::Awaitable deliver(std::launch launch, + const SubscriptionName& name, const SubscriptionFilterCallback& applyArguments, const std::shared_ptr& subscriptionObject) const; - GRAPHQLSERVICE_EXPORT AwaitableVoid deliver(std::launch launch, const SubscriptionName& name, - const SubscriptionFilterCallback& applyArguments, + GRAPHQLSERVICE_EXPORT internal::Awaitable deliver(std::launch launch, + const SubscriptionName& name, const SubscriptionFilterCallback& applyArguments, const SubscriptionFilterCallback& applyDirectives, const std::shared_ptr& subscriptionObject) const; diff --git a/include/graphqlservice/internal/AwaitableFuture.h b/include/graphqlservice/internal/Awaitable.h similarity index 57% rename from include/graphqlservice/internal/AwaitableFuture.h rename to include/graphqlservice/internal/Awaitable.h index 2c72edb3..b9dadede 100644 --- a/include/graphqlservice/internal/AwaitableFuture.h +++ b/include/graphqlservice/internal/Awaitable.h @@ -3,8 +3,8 @@ #pragma once -#ifndef AWAITABLEFUTURE_H -#define AWAITABLEFUTURE_H +#ifndef Awaitable_H +#define Awaitable_H // clang-format off #ifdef USE_STD_EXPERIMENTAL_COROUTINE @@ -17,42 +17,30 @@ // clang-format on #include -#include #include namespace graphql::internal { -class AwaitableVoid +template +class Awaitable; + +template<> +class Awaitable { public: - AwaitableVoid(std::future&& value) + Awaitable(std::future&& value) : _value { std::move(value) } { } void get() { - using namespace std::literals; - - if (_value.wait_for(0s) != std::future_status::timeout) - { - _value.get(); - } - - std::promise promise; - auto future = promise.get_future(); - - std::thread([&promise, self = std::move(*this)]() mutable -> AwaitableVoid { - co_await self; - promise.set_value(); - }).detach(); - - return future.get(); + _value.get(); } struct promise_type { - AwaitableVoid get_return_object() noexcept + Awaitable get_return_object() noexcept { return { _promise.get_future() }; } @@ -81,19 +69,14 @@ class AwaitableVoid std::promise _promise; }; - bool await_ready() const noexcept + constexpr bool await_ready() const noexcept { - using namespace std::literals; - - return (_value.wait_for(0s) != std::future_status::timeout); + return true; } void await_suspend(coro::coroutine_handle<> h) const { - std::thread([this, h]() mutable { - _value.wait(); - h.resume(); - }).detach(); + h.resume(); } void await_resume() @@ -106,36 +89,22 @@ class AwaitableVoid }; template -class AwaitableFuture +class Awaitable { public: - AwaitableFuture(std::future&& value) + Awaitable(std::future&& value) : _value { std::move(value) } { } T get() { - using namespace std::literals; - - if (_value.wait_for(0s) != std::future_status::timeout) - { - return _value.get(); - } - - std::promise promise; - auto future = promise.get_future(); - - std::thread([&promise, self = std::move(*this)]() mutable -> AwaitableVoid { - promise.set_value(co_await self); - }).detach(); - - return future.get(); + return _value.get(); } struct promise_type { - AwaitableFuture get_return_object() noexcept + Awaitable get_return_object() noexcept { return { _promise.get_future() }; } @@ -169,19 +138,14 @@ class AwaitableFuture std::promise _promise; }; - bool await_ready() const noexcept + constexpr bool await_ready() const noexcept { - using namespace std::literals; - - return (_value.wait_for(0s) != std::future_status::timeout); + return true; } void await_suspend(coro::coroutine_handle<> h) const { - std::thread([this, h]() mutable { - _value.wait(); - h.resume(); - }).detach(); + h.resume(); } T await_resume() @@ -195,4 +159,4 @@ class AwaitableFuture } // namespace graphql::internal -#endif // AWAITABLEFUTURE_H +#endif // Awaitable_H diff --git a/samples/today/TodayMock.cpp b/samples/today/TodayMock.cpp index f3ffa4e2..37b8d52b 100644 --- a/samples/today/TodayMock.cpp +++ b/samples/today/TodayMock.cpp @@ -146,30 +146,20 @@ auto operator co_await(std::chrono::duration<_Rep, _Period> delay) struct awaiter { const std::chrono::duration<_Rep, _Period> delay; - std::promise promise; - bool await_ready() const + constexpr bool await_ready() const { - std::cerr << "duration awaiter::await_ready" << std::endl; - return false; + return true; } void await_suspend(coro::coroutine_handle<> h) noexcept { - std::cerr << "duration awaiter::await_suspend" << std::endl; - std::thread([this, h]() mutable { - std::this_thread::sleep_for(delay); - promise.set_value(); - std::cerr << "duration awaiter::await_suspend: resuming" << std::endl; - h.resume(); - }).detach(); + h.resume(); } void await_resume() { - std::cerr << "duration awaiter::await_resume: waiting" << std::endl; - promise.get_future().get(); - std::cerr << "duration awaiter::await_resume: resumed" << std::endl; + std::this_thread::sleep_for(delay); } }; @@ -179,8 +169,7 @@ auto operator co_await(std::chrono::duration<_Rep, _Period> delay) service::FieldResult> Query::getNode( service::FieldParams&& params, response::IdType&& id) const { - // {node(id: "ZmFrZVRhc2tJZA=="){...on Task{title}}} - std::cerr << "Query::getNode" << std::endl; + // query { node(id: "ZmFrZVRhc2tJZA==") { ...on Task { title } } } using namespace std::literals; co_await 100ms; diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 46d84361..00830ba9 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -462,7 +462,7 @@ install(FILES DESTINATION ${GRAPHQL_INSTALL_INCLUDE_DIR}/graphqlservice) install(FILES - ${CMAKE_CURRENT_SOURCE_DIR}/../include/graphqlservice/internal/AwaitableFuture.h + ${CMAKE_CURRENT_SOURCE_DIR}/../include/graphqlservice/internal/Awaitable.h ${CMAKE_CURRENT_SOURCE_DIR}/../include/graphqlservice/internal/Base64.h ${CMAKE_CURRENT_SOURCE_DIR}/../include/graphqlservice/internal/Grammar.h ${CMAKE_CURRENT_SOURCE_DIR}/../include/graphqlservice/internal/Schema.h diff --git a/src/GraphQLService.cpp b/src/GraphQLService.cpp index d2b355c9..2beb7cd1 100644 --- a/src/GraphQLService.cpp +++ b/src/GraphQLService.cpp @@ -1803,7 +1803,7 @@ SubscriptionKey Request::subscribe(SubscriptionParams&& params, SubscriptionCall return key; } -AwaitableSubscriptionKey Request::subscribe( +internal::Awaitable Request::subscribe( std::launch launch, SubscriptionParams&& params, SubscriptionCallback&& callback) { const auto spThis = shared_from_this(); @@ -1874,7 +1874,7 @@ void Request::unsubscribe(SubscriptionKey key) } } -AwaitableVoid Request::unsubscribe(std::launch launch, SubscriptionKey key) +internal::Awaitable Request::unsubscribe(std::launch launch, SubscriptionKey key) { const auto spThis = shared_from_this(); const auto itrOperation = spThis->_operations.find(strSubscription); @@ -1940,7 +1940,7 @@ void Request::deliver(const SubscriptionName& name, deliver(std::launch::deferred, name, applyArguments, applyDirectives, subscriptionObject).get(); } -AwaitableVoid Request::deliver(std::launch launch, const SubscriptionName& name, +internal::Awaitable Request::deliver(std::launch launch, const SubscriptionName& name, const std::shared_ptr& subscriptionObject) const { return deliver(launch, @@ -1950,13 +1950,13 @@ AwaitableVoid Request::deliver(std::launch launch, const SubscriptionName& name, subscriptionObject); } -AwaitableVoid Request::deliver(std::launch launch, const SubscriptionName& name, +internal::Awaitable Request::deliver(std::launch launch, const SubscriptionName& name, const SubscriptionArguments& arguments, const std::shared_ptr& subscriptionObject) const { return deliver(launch, name, arguments, SubscriptionArguments {}, subscriptionObject); } -AwaitableVoid Request::deliver(std::launch launch, const SubscriptionName& name, +internal::Awaitable Request::deliver(std::launch launch, const SubscriptionName& name, const SubscriptionArguments& arguments, const SubscriptionArguments& directives, const std::shared_ptr& subscriptionObject) const { @@ -1977,7 +1977,7 @@ AwaitableVoid Request::deliver(std::launch launch, const SubscriptionName& name, return deliver(launch, name, argumentsMatch, directivesMatch, subscriptionObject); } -AwaitableVoid Request::deliver(std::launch launch, const SubscriptionName& name, +internal::Awaitable Request::deliver(std::launch launch, const SubscriptionName& name, const SubscriptionFilterCallback& applyArguments, const std::shared_ptr& subscriptionObject) const { @@ -1991,7 +1991,7 @@ AwaitableVoid Request::deliver(std::launch launch, const SubscriptionName& name, subscriptionObject); } -AwaitableVoid Request::deliver(std::launch launch, const SubscriptionName& name, +internal::Awaitable Request::deliver(std::launch launch, const SubscriptionName& name, const SubscriptionFilterCallback& applyArguments, const SubscriptionFilterCallback& applyDirectives, const std::shared_ptr& subscriptionObject) const From 43d4ee3f067b01c016fb88a923e585e32dbc754f Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Wed, 3 Nov 2021 13:48:55 -0700 Subject: [PATCH 015/119] Enable std::launch::async APIs --- include/graphqlservice/GraphQLService.h | 140 +++++++++++++++----- include/graphqlservice/internal/Awaitable.h | 21 ++- src/GraphQLService.cpp | 55 ++++++-- test/TodayTests.cpp | 2 +- 4 files changed, 177 insertions(+), 41 deletions(-) diff --git a/include/graphqlservice/GraphQLService.h b/include/graphqlservice/GraphQLService.h index d65028de..cc482cfe 100644 --- a/include/graphqlservice/GraphQLService.h +++ b/include/graphqlservice/GraphQLService.h @@ -25,6 +25,7 @@ #include "graphqlservice/internal/SortedMap.h" #include "graphqlservice/internal/Version.h" +#include #include #include #include @@ -198,11 +199,6 @@ class FieldResult { } - bool is_future() const noexcept - { - return std::holds_alternative>(_value); - } - struct promise_type { FieldResult get_return_object() noexcept @@ -241,18 +237,54 @@ class FieldResult bool await_ready() const noexcept { - return true; + return std::visit( + [](const auto& value) noexcept { + using value_type = std::decay_t; + + if constexpr (std::is_same_v) + { + return true; + } + else if constexpr (std::is_same_v>) + { + using namespace std::literals; + + return value.wait_for(0s) != std::future_status::timeout; + } + }, + _value); } void await_suspend(coro::coroutine_handle<> h) const { - h.resume(); + using namespace std::literals; + + std::async( + std::launch::async, + [this](auto h) { + std::get>(_value).wait(); + h.resume(); + }, + std::move(h)) + .wait_for(0s); } T await_resume() { - return is_future() ? std::get>(_value).get() - : T { std::move(std::get(_value)) }; + return std::visit( + [](auto&& value) { + using value_type = std::decay_t; + + if constexpr (std::is_same_v) + { + return value; + } + else if constexpr (std::is_same_v>) + { + return value.get(); + } + }, + std::move(_value)); } private: @@ -577,9 +609,18 @@ struct ModifiedResult // Object. static_assert(std::is_same_v, typename ResultTraits::type>, "this is the derived object type"); + + auto pendingResult = std::move(result); + auto pendingParams = std::move(params); + + if (pendingParams.launch == std::launch::async) + { + co_await internal::await_async(); + } + auto awaitedResult = co_await ModifiedResult::convert( - std::static_pointer_cast(co_await result), - std::move(params)); + std::static_pointer_cast(co_await pendingResult), + std::move(pendingParams)); co_return std::move(awaitedResult); } @@ -603,15 +644,23 @@ struct ModifiedResult convert(typename ResultTraits::future_type result, ResolverParams&& params) { - auto awaitedResult = co_await result; + auto pendingResult = std::move(result); + auto pendingParams = std::move(params); + + if (pendingParams.launch == std::launch::async) + { + co_await internal::await_async(); + } + + auto awaitedResult = co_await pendingResult; if (!awaitedResult) { co_return ResolverResult {}; } - auto modifiedResult = - co_await ModifiedResult::convert(std::move(awaitedResult), std::move(params)); + auto modifiedResult = co_await ModifiedResult::convert(std::move(awaitedResult), + std::move(pendingParams)); co_return modifiedResult; } @@ -628,7 +677,15 @@ struct ModifiedResult typename ResultTraits::type>, "this is the optional version"); - auto awaitedResult = co_await result; + auto pendingResult = std::move(result); + auto pendingParams = std::move(params); + + if (pendingParams.launch == std::launch::async) + { + co_await internal::await_async(); + } + + auto awaitedResult = co_await pendingResult; if (!awaitedResult) { @@ -636,7 +693,7 @@ struct ModifiedResult } auto modifiedResult = co_await ModifiedResult::convert(std::move(*awaitedResult), - std::move(params)); + std::move(pendingParams)); co_return modifiedResult; } @@ -647,12 +704,20 @@ struct ModifiedResult typename ResultTraits::future_type result, ResolverParams&& params) { + auto pendingResult = std::move(result); + auto pendingParams = std::move(params); std::vector children; - const auto parentPath = params.errorPath; - auto awaitedResult = co_await result; + const auto parentPath = pendingParams.errorPath; + + if (pendingParams.launch == std::launch::async) + { + co_await internal::await_async(); + } + + auto awaitedResult = co_await pendingResult; children.reserve(awaitedResult.size()); - params.errorPath = std::make_optional( + pendingParams.errorPath = std::make_optional( field_path { parentPath ? std::make_optional(std::cref(*parentPath)) : std::nullopt, path_segment { size_t { 0 } } }); @@ -666,30 +731,35 @@ struct ModifiedResult // Copy the values from the std::vector<> rather than moving them. for (typename vector_type::value_type entry : awaitedResult) { - children.push_back( - ModifiedResult::convert(std::move(entry), ResolverParams(params))); - ++std::get(params.errorPath->segment); + children.push_back(ModifiedResult::convert(std::move(entry), + ResolverParams(pendingParams))); + ++std::get(pendingParams.errorPath->segment); } } else { for (auto& entry : awaitedResult) { - children.push_back( - ModifiedResult::convert(std::move(entry), ResolverParams(params))); - ++std::get(params.errorPath->segment); + children.push_back(ModifiedResult::convert(std::move(entry), + ResolverParams(pendingParams))); + ++std::get(pendingParams.errorPath->segment); } } ResolverResult document { response::Value { response::Type::List } }; document.data.reserve(children.size()); - std::get(params.errorPath->segment) = 0; + std::get(pendingParams.errorPath->segment) = 0; for (auto& child : children) { try { + if (pendingParams.launch == std::launch::async) + { + co_await internal::await_async(); + } + auto value = co_await child; document.data.emplace_back(std::move(value.data)); @@ -712,15 +782,15 @@ struct ModifiedResult { std::ostringstream message; - message << "Field error name: " << params.fieldName + message << "Field error name: " << pendingParams.fieldName << " unknown error: " << ex.what(); document.errors.emplace_back(schema_error { message.str(), - params.getLocation(), - buildErrorPath(params.errorPath) }); + pendingParams.getLocation(), + buildErrorPath(pendingParams.errorPath) }); } - ++std::get(params.errorPath->segment); + ++std::get(pendingParams.errorPath->segment); } co_return document; @@ -736,11 +806,19 @@ struct ModifiedResult static_assert(!std::is_base_of_v, "ModfiedResult needs special handling"); + auto pendingResult = std::move(result); + auto pendingParams = std::move(params); + auto pendingResolver = std::move(resolver); ResolverResult document; try { - document.data = resolver(co_await result, params); + if (pendingParams.launch == std::launch::async) + { + co_await internal::await_async(); + } + + document.data = pendingResolver(co_await pendingResult, pendingParams); } catch (schema_exception& scx) { diff --git a/include/graphqlservice/internal/Awaitable.h b/include/graphqlservice/internal/Awaitable.h index b9dadede..0904f583 100644 --- a/include/graphqlservice/internal/Awaitable.h +++ b/include/graphqlservice/internal/Awaitable.h @@ -17,6 +17,7 @@ // clang-format on #include +#include #include namespace graphql::internal { @@ -24,7 +25,7 @@ namespace graphql::internal { template class Awaitable; -template<> +template <> class Awaitable { public: @@ -157,6 +158,24 @@ class Awaitable std::future _value; }; +auto await_async() noexcept +{ + struct awaitable : coro::suspend_always + { + void await_suspend(coro::coroutine_handle<> h) const + { + std::thread( + [](coro::coroutine_handle<>&& h) noexcept { + h.resume(); + }, + std::move(h)) + .detach(); + } + }; + + return awaitable {}; +} + } // namespace graphql::internal #endif // Awaitable_H diff --git a/src/GraphQLService.cpp b/src/GraphQLService.cpp index 2beb7cd1..62aa4d3b 100644 --- a/src/GraphQLService.cpp +++ b/src/GraphQLService.cpp @@ -703,19 +703,27 @@ template <> AwaitableResolver ModifiedResult::convert( FieldResult>&& result, ResolverParams&& params) { - requireSubFields(params); + auto pendingResult = std::move(result); + auto pendingParams = std::move(params); - auto awaitedResult = co_await result; + requireSubFields(pendingParams); + + if (pendingParams.launch == std::launch::async) + { + co_await internal::await_async(); + } + + auto awaitedResult = co_await pendingResult; if (!awaitedResult) { co_return ResolverResult {}; } - auto document = co_await awaitedResult->resolve(params, - *params.selection, - params.fragments, - params.variables); + auto document = co_await awaitedResult->resolve(pendingParams, + *pendingParams.selection, + pendingParams.fragments, + pendingParams.variables); co_return std::move(document); } @@ -1118,6 +1126,7 @@ AwaitableResolver Object::resolve(const SelectionSetParams& selectionSetParams, endSelectionSet(selectionSetParams); auto children = visitor.getValues(); + const auto launch = selectionSetParams.launch; ResolverResult document { response::Value { response::Type::Map } }; document.data.reserve(children.size()); @@ -1128,6 +1137,11 @@ AwaitableResolver Object::resolve(const SelectionSetParams& selectionSetParams, try { + if (launch == std::launch::async) + { + co_await internal::await_async(); + } + auto value = co_await child.second; if (!document.data.emplace_back(std::string { name }, std::move(value.data))) @@ -1278,9 +1292,14 @@ AwaitableResolver OperationDefinitionVisitor::getValue() co_return ResolverResult {}; } - auto result = co_await *_result; + auto result = std::move(*_result); - co_return std::move(result); + if (_launch == std::launch::async) + { + co_await internal::await_async(); + } + + co_return co_await result; } void OperationDefinitionVisitor::visit( @@ -1710,6 +1729,11 @@ response::AwaitableValue Request::resolve(std::launch launch, operationVisitor.visit(operationDefinition.first, *operationDefinition.second); + if (launch == std::launch::async) + { + co_await internal::await_async(); + } + auto result = co_await operationVisitor.getValue(); response::Value document { response::Type::Map }; @@ -1828,6 +1852,11 @@ internal::Awaitable Request::subscribe( try { + if (launch == std::launch::async) + { + co_await internal::await_async(); + } + co_await operation->resolve(selectionSetParams, registration->selection, registration->data->fragments, @@ -1895,6 +1924,11 @@ internal::Awaitable Request::unsubscribe(std::launch launch, SubscriptionK launch, }; + if (launch == std::launch::async) + { + co_await internal::await_async(); + } + co_await operation->resolve(selectionSetParams, registration->selection, registration->data->fragments, @@ -2088,6 +2122,11 @@ internal::Awaitable Request::deliver(std::launch launch, const Subscriptio try { + if (launch == std::launch::async) + { + co_await internal::await_async(); + } + auto result = co_await optionalOrDefaultSubscription->resolve(selectionSetParams, registration->selection, registration->data->fragments, diff --git a/test/TodayTests.cpp b/test/TodayTests.cpp index 2737993b..5ebdd92a 100644 --- a/test/TodayTests.cpp +++ b/test/TodayTests.cpp @@ -1631,7 +1631,7 @@ TEST_F(TodayServiceCase, SubscribeNextAppointmentChangeAsync) [&result](response::Value&& response) { result = std::move(response); }); - _service->deliver(std::launch::async, "nextAppointmentChange", nullptr); + _service->deliver(std::launch::async, "nextAppointmentChange", nullptr).get(); _service->unsubscribe(key); try From 2c87c1c9cc9a55fa82d5909737dc8309b484a68a Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Wed, 3 Nov 2021 14:33:54 -0700 Subject: [PATCH 016/119] Move await_async from header to GraphQLService.* --- include/graphqlservice/GraphQLService.h | 33 ++++++++++------- include/graphqlservice/internal/Awaitable.h | 19 ---------- src/GraphQLService.cpp | 39 +++++++++++++-------- 3 files changed, 46 insertions(+), 45 deletions(-) diff --git a/include/graphqlservice/GraphQLService.h b/include/graphqlservice/GraphQLService.h index cc482cfe..14b51339 100644 --- a/include/graphqlservice/GraphQLService.h +++ b/include/graphqlservice/GraphQLService.h @@ -563,6 +563,15 @@ class Object : public std::enable_shared_from_this ResolverMap _resolvers; }; +// Resume coroutine execution on a worker thread. This is used internally to implement the APIs +// which can take std::launch::async as a parameter. +struct await_async : coro::suspend_always +{ + GRAPHQLSERVICE_EXPORT explicit await_async() noexcept = default; + + GRAPHQLSERVICE_EXPORT void await_suspend(coro::coroutine_handle<> h) const; +}; + // Convert the result of a resolver function with chained type modifiers that add nullable or // list wrappers. This is the inverse of ModifiedArgument for output types instead of input types. template @@ -613,9 +622,9 @@ struct ModifiedResult auto pendingResult = std::move(result); auto pendingParams = std::move(params); - if (pendingParams.launch == std::launch::async) + if ((pendingParams.launch & std::launch::async) == std::launch::async) { - co_await internal::await_async(); + co_await await_async {}; } auto awaitedResult = co_await ModifiedResult::convert( @@ -647,9 +656,9 @@ struct ModifiedResult auto pendingResult = std::move(result); auto pendingParams = std::move(params); - if (pendingParams.launch == std::launch::async) + if ((pendingParams.launch & std::launch::async) == std::launch::async) { - co_await internal::await_async(); + co_await await_async {}; } auto awaitedResult = co_await pendingResult; @@ -680,9 +689,9 @@ struct ModifiedResult auto pendingResult = std::move(result); auto pendingParams = std::move(params); - if (pendingParams.launch == std::launch::async) + if ((pendingParams.launch & std::launch::async) == std::launch::async) { - co_await internal::await_async(); + co_await await_async {}; } auto awaitedResult = co_await pendingResult; @@ -709,9 +718,9 @@ struct ModifiedResult std::vector children; const auto parentPath = pendingParams.errorPath; - if (pendingParams.launch == std::launch::async) + if ((pendingParams.launch & std::launch::async) == std::launch::async) { - co_await internal::await_async(); + co_await await_async {}; } auto awaitedResult = co_await pendingResult; @@ -755,9 +764,9 @@ struct ModifiedResult { try { - if (pendingParams.launch == std::launch::async) + if ((pendingParams.launch & std::launch::async) == std::launch::async) { - co_await internal::await_async(); + co_await await_async {}; } auto value = co_await child; @@ -813,9 +822,9 @@ struct ModifiedResult try { - if (pendingParams.launch == std::launch::async) + if ((pendingParams.launch & std::launch::async) == std::launch::async) { - co_await internal::await_async(); + co_await await_async {}; } document.data = pendingResolver(co_await pendingResult, pendingParams); diff --git a/include/graphqlservice/internal/Awaitable.h b/include/graphqlservice/internal/Awaitable.h index 0904f583..f3230743 100644 --- a/include/graphqlservice/internal/Awaitable.h +++ b/include/graphqlservice/internal/Awaitable.h @@ -17,7 +17,6 @@ // clang-format on #include -#include #include namespace graphql::internal { @@ -158,24 +157,6 @@ class Awaitable std::future _value; }; -auto await_async() noexcept -{ - struct awaitable : coro::suspend_always - { - void await_suspend(coro::coroutine_handle<> h) const - { - std::thread( - [](coro::coroutine_handle<>&& h) noexcept { - h.resume(); - }, - std::move(h)) - .detach(); - } - }; - - return awaitable {}; -} - } // namespace graphql::internal #endif // Awaitable_H diff --git a/src/GraphQLService.cpp b/src/GraphQLService.cpp index 62aa4d3b..615a4028 100644 --- a/src/GraphQLService.cpp +++ b/src/GraphQLService.cpp @@ -10,6 +10,7 @@ #include #include #include +#include namespace graphql::service { @@ -589,6 +590,16 @@ response::IdType ModifiedArgument::convert(const response::Val return result; } +void await_async::await_suspend(coro::coroutine_handle<> h) const +{ + std::thread( + [](coro::coroutine_handle<>&& h) noexcept { + h.resume(); + }, + std::move(h)) + .detach(); +} + void blockSubFields(const ResolverParams& params) { // http://spec.graphql.org/June2018/#sec-Leaf-Field-Selections @@ -708,9 +719,9 @@ AwaitableResolver ModifiedResult::convert( requireSubFields(pendingParams); - if (pendingParams.launch == std::launch::async) + if ((pendingParams.launch & std::launch::async) == std::launch::async) { - co_await internal::await_async(); + co_await await_async {}; } auto awaitedResult = co_await pendingResult; @@ -1137,9 +1148,9 @@ AwaitableResolver Object::resolve(const SelectionSetParams& selectionSetParams, try { - if (launch == std::launch::async) + if ((launch & std::launch::async) == std::launch::async) { - co_await internal::await_async(); + co_await await_async {}; } auto value = co_await child.second; @@ -1294,9 +1305,9 @@ AwaitableResolver OperationDefinitionVisitor::getValue() auto result = std::move(*_result); - if (_launch == std::launch::async) + if ((_launch & std::launch::async) == std::launch::async) { - co_await internal::await_async(); + co_await await_async {}; } co_return co_await result; @@ -1729,9 +1740,9 @@ response::AwaitableValue Request::resolve(std::launch launch, operationVisitor.visit(operationDefinition.first, *operationDefinition.second); - if (launch == std::launch::async) + if ((launch & std::launch::async) == std::launch::async) { - co_await internal::await_async(); + co_await await_async {}; } auto result = co_await operationVisitor.getValue(); @@ -1852,9 +1863,9 @@ internal::Awaitable Request::subscribe( try { - if (launch == std::launch::async) + if ((launch & std::launch::async) == std::launch::async) { - co_await internal::await_async(); + co_await await_async {}; } co_await operation->resolve(selectionSetParams, @@ -1924,9 +1935,9 @@ internal::Awaitable Request::unsubscribe(std::launch launch, SubscriptionK launch, }; - if (launch == std::launch::async) + if ((launch & std::launch::async) == std::launch::async) { - co_await internal::await_async(); + co_await await_async {}; } co_await operation->resolve(selectionSetParams, @@ -2122,9 +2133,9 @@ internal::Awaitable Request::deliver(std::launch launch, const Subscriptio try { - if (launch == std::launch::async) + if ((launch & std::launch::async) == std::launch::async) { - co_await internal::await_async(); + co_await await_async {}; } auto result = co_await optionalOrDefaultSubscription->resolve(selectionSetParams, From 117a96650a91997eb6a0f4e6ccb0df3e1ad76f1c Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Wed, 3 Nov 2021 14:49:56 -0700 Subject: [PATCH 017/119] Explicitly construct a return value from the r-value reference --- include/graphqlservice/GraphQLService.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/graphqlservice/GraphQLService.h b/include/graphqlservice/GraphQLService.h index 14b51339..d4a89435 100644 --- a/include/graphqlservice/GraphQLService.h +++ b/include/graphqlservice/GraphQLService.h @@ -277,7 +277,7 @@ class FieldResult if constexpr (std::is_same_v) { - return value; + return T { std::move(value) }; } else if constexpr (std::is_same_v>) { From 66ac160e766e8045c6d0e780ec6023aba5e10438 Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Wed, 3 Nov 2021 15:15:46 -0700 Subject: [PATCH 018/119] Add std::move for gcc --- include/graphqlservice/GraphQLService.h | 8 ++++---- src/GraphQLService.cpp | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/graphqlservice/GraphQLService.h b/include/graphqlservice/GraphQLService.h index d4a89435..b854b5ad 100644 --- a/include/graphqlservice/GraphQLService.h +++ b/include/graphqlservice/GraphQLService.h @@ -661,7 +661,7 @@ struct ModifiedResult co_await await_async {}; } - auto awaitedResult = co_await pendingResult; + auto awaitedResult = co_await std::move(pendingResult); if (!awaitedResult) { @@ -694,7 +694,7 @@ struct ModifiedResult co_await await_async {}; } - auto awaitedResult = co_await pendingResult; + auto awaitedResult = co_await std::move(pendingResult); if (!awaitedResult) { @@ -723,7 +723,7 @@ struct ModifiedResult co_await await_async {}; } - auto awaitedResult = co_await pendingResult; + auto awaitedResult = co_await std::move(pendingResult); children.reserve(awaitedResult.size()); pendingParams.errorPath = std::make_optional( @@ -769,7 +769,7 @@ struct ModifiedResult co_await await_async {}; } - auto value = co_await child; + auto value = co_await std::move(child); document.data.emplace_back(std::move(value.data)); diff --git a/src/GraphQLService.cpp b/src/GraphQLService.cpp index 615a4028..ed829fbd 100644 --- a/src/GraphQLService.cpp +++ b/src/GraphQLService.cpp @@ -724,7 +724,7 @@ AwaitableResolver ModifiedResult::convert( co_await await_async {}; } - auto awaitedResult = co_await pendingResult; + auto awaitedResult = co_await std::move(pendingResult); if (!awaitedResult) { @@ -1153,7 +1153,7 @@ AwaitableResolver Object::resolve(const SelectionSetParams& selectionSetParams, co_await await_async {}; } - auto value = co_await child.second; + auto value = co_await std::move(child.second); if (!document.data.emplace_back(std::string { name }, std::move(value.data))) { From 2454d7b6aa2c798ee5c8bb65921c7809bb0323f4 Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Wed, 3 Nov 2021 15:44:14 -0700 Subject: [PATCH 019/119] Replace std::async with more straightforward std::thread usage --- include/graphqlservice/GraphQLService.h | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/include/graphqlservice/GraphQLService.h b/include/graphqlservice/GraphQLService.h index b854b5ad..623258f8 100644 --- a/include/graphqlservice/GraphQLService.h +++ b/include/graphqlservice/GraphQLService.h @@ -257,16 +257,13 @@ class FieldResult void await_suspend(coro::coroutine_handle<> h) const { - using namespace std::literals; - - std::async( - std::launch::async, - [this](auto h) { + std::thread( + [this](coro::coroutine_handle<>&& h) noexcept { std::get>(_value).wait(); h.resume(); }, std::move(h)) - .wait_for(0s); + .detach(); } T await_resume() From 50be8b3c045731b18016774c894e6697678e44fc Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Wed, 3 Nov 2021 15:44:22 -0700 Subject: [PATCH 020/119] Update docs --- doc/resolvers.md | 11 +++++------ doc/subscriptions.md | 37 +++++++++++++++++++------------------ 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/doc/resolvers.md b/doc/resolvers.md index b5cc4c68..cf328e64 100644 --- a/doc/resolvers.md +++ b/doc/resolvers.md @@ -38,11 +38,10 @@ GRAPHQLSERVICE_EXPORT response::AwaitableValue resolve( const std::shared_ptr& state, peg::ast& query, const std::string& operationName, response::Value&& variables) const; ``` -By default, the `std::future` results are resolved on-demand but synchronously, -using `std::launch::deferred` with the `std::async` function. You can also use -an override of `Request::resolve` which lets you substitute the -`std::launch::async` option to begin executing the query on multiple threads -in parallel: +By default, the `std::future` results are resolved on-demand but synchronously. +You can also use an override of `Request::resolve` which lets you substitute +the `std::launch::async` option to begin executing the query on multiple +threads in parallel: ```cpp GRAPHQLSERVICE_EXPORT response::AwaitableValue resolve(std::launch launch, const std::shared_ptr& state, peg::ast& query, @@ -70,7 +69,7 @@ recursively call the `resolvers` for each of the `fields` in the nested `graphql::today::object::Appointment` object from the `today` sample in [AppointmentObject.h](../samples/separate/AppointmentObject.h). ```cpp -std::future resolveId(service::ResolverParams&& params); +service::AwaitableResolver resolveId(service::ResolverParams&& params); ``` In this example, the `resolveId` method invokes `getId`: ```cpp diff --git a/doc/subscriptions.md b/doc/subscriptions.md index 21b9da36..2af34d1d 100644 --- a/doc/subscriptions.md +++ b/doc/subscriptions.md @@ -15,11 +15,12 @@ and `Request::unsubscribe` methods in [GraphQLService.h](../include/graphqlservi ```cpp GRAPHQLSERVICE_EXPORT SubscriptionKey subscribe( SubscriptionParams&& params, SubscriptionCallback&& callback); -GRAPHQLSERVICE_EXPORT std::future subscribe( +GRAPHQLSERVICE_EXPORT internal::Awaitable subscribe( std::launch launch, SubscriptionParams&& params, SubscriptionCallback&& callback); GRAPHQLSERVICE_EXPORT void unsubscribe(SubscriptionKey key); -GRAPHQLSERVICE_EXPORT std::future unsubscribe(std::launch launch, SubscriptionKey key); +GRAPHQLSERVICE_EXPORT internal::Awaitable unsubscribe( + std::launch launch, SubscriptionKey key); ``` You need to fill in a `SubscriptionParams` struct with the [parsed](./parsing.md) query and any other relevant operation parameters: @@ -39,7 +40,7 @@ The `SubscriptionCallback` signature is: ```cpp // Subscription callbacks receive the response::Value representing the result of evaluating the // SelectionSet against the payload. -using SubscriptionCallback = std::function; +using SubscriptionCallback = std::function; ``` ## `ResolverContext::NotifySubscribe` and `ResolverContext::NotifyUnsubscribe` @@ -114,25 +115,25 @@ GRAPHQLSERVICE_EXPORT void deliver(const SubscriptionName& name, ``` By default, `deliver` invokes all of the `SubscriptionCallback` listeners with -`std::future` payloads which are resolved on-demand but synchronously, using -`std::launch::deferred` with the `std::async` function. There's also a version -of each overload which lets you substitute the `std::launch::async` option to -begin executing the queries and invoke the callbacks on multiple threads in -parallel: +`std::future` payloads which are resolved on-demand but synchronously. You can +also use an override of `Request::resolve` which lets you substitute the +`std::launch::async` option to begin executing the queries and invoke the +callbacks on multiple threads in parallel: ```cpp -GRAPHQLSERVICE_EXPORT void deliver(std::launch launch, const SubscriptionName& name, - const std::shared_ptr& subscriptionObject) const; -GRAPHQLSERVICE_EXPORT void deliver(std::launch launch, const SubscriptionName& name, - const SubscriptionArguments& arguments, +GRAPHQLSERVICE_EXPORT internal::Awaitable deliver(std::launch launch, + const SubscriptionName& name, const std::shared_ptr& subscriptionObject) const; +GRAPHQLSERVICE_EXPORT internal::Awaitable deliver(std::launch launch, + const SubscriptionName& name, const SubscriptionArguments& arguments, const std::shared_ptr& subscriptionObject) const; -GRAPHQLSERVICE_EXPORT void deliver(std::launch launch, const SubscriptionName& name, - const SubscriptionArguments& arguments, const SubscriptionArguments& directives, +GRAPHQLSERVICE_EXPORT internal::Awaitable deliver(std::launch launch, + const SubscriptionName& name, const SubscriptionArguments& arguments, + const SubscriptionArguments& directives, const std::shared_ptr& subscriptionObject) const; -GRAPHQLSERVICE_EXPORT void deliver(std::launch launch, const SubscriptionName& name, - const SubscriptionFilterCallback& applyArguments, +GRAPHQLSERVICE_EXPORT internal::Awaitable deliver(std::launch launch, + const SubscriptionName& name, const SubscriptionFilterCallback& applyArguments, const std::shared_ptr& subscriptionObject) const; -GRAPHQLSERVICE_EXPORT void deliver(std::launch launch, const SubscriptionName& name, - const SubscriptionFilterCallback& applyArguments, +GRAPHQLSERVICE_EXPORT internal::Awaitable deliver(std::launch launch, + const SubscriptionName& name, const SubscriptionFilterCallback& applyArguments, const SubscriptionFilterCallback& applyDirectives, const std::shared_ptr& subscriptionObject) const; ``` From 5b66883399d2ff0f29329551f24ffac3c8ce8ed9 Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Wed, 3 Nov 2021 15:59:15 -0700 Subject: [PATCH 021/119] Make await_async test the launch flags instead of call sites --- include/graphqlservice/GraphQLService.h | 44 +++++++++-------------- src/GraphQLService.cpp | 48 +++++++++---------------- 2 files changed, 34 insertions(+), 58 deletions(-) diff --git a/include/graphqlservice/GraphQLService.h b/include/graphqlservice/GraphQLService.h index 623258f8..a04e75f3 100644 --- a/include/graphqlservice/GraphQLService.h +++ b/include/graphqlservice/GraphQLService.h @@ -562,11 +562,20 @@ class Object : public std::enable_shared_from_this // Resume coroutine execution on a worker thread. This is used internally to implement the APIs // which can take std::launch::async as a parameter. -struct await_async : coro::suspend_always +class await_async { - GRAPHQLSERVICE_EXPORT explicit await_async() noexcept = default; +public: + GRAPHQLSERVICE_EXPORT explicit await_async(std::launch launch) noexcept; + GRAPHQLSERVICE_EXPORT bool await_ready() const noexcept; GRAPHQLSERVICE_EXPORT void await_suspend(coro::coroutine_handle<> h) const; + + constexpr void await_resume() const noexcept + { + } + +private: + const std::launch _launch; }; // Convert the result of a resolver function with chained type modifiers that add nullable or @@ -619,10 +628,7 @@ struct ModifiedResult auto pendingResult = std::move(result); auto pendingParams = std::move(params); - if ((pendingParams.launch & std::launch::async) == std::launch::async) - { - co_await await_async {}; - } + co_await await_async { pendingParams.launch }; auto awaitedResult = co_await ModifiedResult::convert( std::static_pointer_cast(co_await pendingResult), @@ -653,10 +659,7 @@ struct ModifiedResult auto pendingResult = std::move(result); auto pendingParams = std::move(params); - if ((pendingParams.launch & std::launch::async) == std::launch::async) - { - co_await await_async {}; - } + co_await await_async { pendingParams.launch }; auto awaitedResult = co_await std::move(pendingResult); @@ -686,10 +689,7 @@ struct ModifiedResult auto pendingResult = std::move(result); auto pendingParams = std::move(params); - if ((pendingParams.launch & std::launch::async) == std::launch::async) - { - co_await await_async {}; - } + co_await await_async { pendingParams.launch }; auto awaitedResult = co_await std::move(pendingResult); @@ -715,10 +715,7 @@ struct ModifiedResult std::vector children; const auto parentPath = pendingParams.errorPath; - if ((pendingParams.launch & std::launch::async) == std::launch::async) - { - co_await await_async {}; - } + co_await await_async { pendingParams.launch }; auto awaitedResult = co_await std::move(pendingResult); @@ -761,10 +758,7 @@ struct ModifiedResult { try { - if ((pendingParams.launch & std::launch::async) == std::launch::async) - { - co_await await_async {}; - } + co_await await_async { pendingParams.launch }; auto value = co_await std::move(child); @@ -819,11 +813,7 @@ struct ModifiedResult try { - if ((pendingParams.launch & std::launch::async) == std::launch::async) - { - co_await await_async {}; - } - + co_await await_async { pendingParams.launch }; document.data = pendingResolver(co_await pendingResult, pendingParams); } catch (schema_exception& scx) diff --git a/src/GraphQLService.cpp b/src/GraphQLService.cpp index ed829fbd..49a649f1 100644 --- a/src/GraphQLService.cpp +++ b/src/GraphQLService.cpp @@ -590,6 +590,16 @@ response::IdType ModifiedArgument::convert(const response::Val return result; } +await_async::await_async(std::launch launch) noexcept + : _launch { launch } +{ +} + +bool await_async::await_ready() const noexcept +{ + return (_launch & std::launch::async) != std::launch::async; +} + void await_async::await_suspend(coro::coroutine_handle<> h) const { std::thread( @@ -719,10 +729,7 @@ AwaitableResolver ModifiedResult::convert( requireSubFields(pendingParams); - if ((pendingParams.launch & std::launch::async) == std::launch::async) - { - co_await await_async {}; - } + co_await await_async { pendingParams.launch }; auto awaitedResult = co_await std::move(pendingResult); @@ -1148,10 +1155,7 @@ AwaitableResolver Object::resolve(const SelectionSetParams& selectionSetParams, try { - if ((launch & std::launch::async) == std::launch::async) - { - co_await await_async {}; - } + co_await await_async { launch }; auto value = co_await std::move(child.second); @@ -1305,11 +1309,7 @@ AwaitableResolver OperationDefinitionVisitor::getValue() auto result = std::move(*_result); - if ((_launch & std::launch::async) == std::launch::async) - { - co_await await_async {}; - } - + co_await await_async { _launch }; co_return co_await result; } @@ -1740,10 +1740,7 @@ response::AwaitableValue Request::resolve(std::launch launch, operationVisitor.visit(operationDefinition.first, *operationDefinition.second); - if ((launch & std::launch::async) == std::launch::async) - { - co_await await_async {}; - } + co_await await_async { launch }; auto result = co_await operationVisitor.getValue(); response::Value document { response::Type::Map }; @@ -1863,11 +1860,7 @@ internal::Awaitable Request::subscribe( try { - if ((launch & std::launch::async) == std::launch::async) - { - co_await await_async {}; - } - + co_await await_async { launch }; co_await operation->resolve(selectionSetParams, registration->selection, registration->data->fragments, @@ -1935,11 +1928,7 @@ internal::Awaitable Request::unsubscribe(std::launch launch, SubscriptionK launch, }; - if ((launch & std::launch::async) == std::launch::async) - { - co_await await_async {}; - } - + co_await await_async { launch }; co_await operation->resolve(selectionSetParams, registration->selection, registration->data->fragments, @@ -2133,10 +2122,7 @@ internal::Awaitable Request::deliver(std::launch launch, const Subscriptio try { - if ((launch & std::launch::async) == std::launch::async) - { - co_await await_async {}; - } + co_await await_async { launch }; auto result = co_await optionalOrDefaultSubscription->resolve(selectionSetParams, registration->selection, From 5c11779cb3425dd62ae089fdccd8e669e573e94c Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Thu, 4 Nov 2021 11:42:16 -0700 Subject: [PATCH 022/119] Pass by value instead of r-value ref to simplify --- include/Validation.h | 2 +- include/graphqlservice/GraphQLClient.h | 22 +-- include/graphqlservice/GraphQLService.h | 169 ++++++++---------- include/graphqlservice/internal/Awaitable.h | 4 +- .../introspection/Introspection.h | 68 ++++--- .../introspection/IntrospectionSchema.h | 4 +- samples/client/BenchmarkClient.cpp | 10 +- samples/client/BenchmarkClient.h | 2 +- samples/client/MutateClient.cpp | 8 +- samples/client/MutateClient.h | 2 +- samples/client/QueryClient.cpp | 24 +-- samples/client/QueryClient.h | 2 +- samples/client/SubscribeClient.cpp | 4 +- samples/client/SubscribeClient.h | 2 +- samples/learn/StarWarsSchema.cpp | 2 +- samples/separate/TodaySchema.cpp | 2 +- .../separate_nointrospection/TodaySchema.cpp | 2 +- samples/unified/TodaySchema.cpp | 2 +- .../unified_nointrospection/TodaySchema.cpp | 2 +- samples/validation/ValidationSchema.cpp | 4 +- src/ClientGenerator.cpp | 8 +- src/GraphQLClient.cpp | 16 +- src/GraphQLService.cpp | 111 ++++++------ src/IntrospectionSchema.cpp | 4 +- src/SchemaGenerator.cpp | 4 +- src/Validation.cpp | 2 +- 26 files changed, 236 insertions(+), 246 deletions(-) diff --git a/include/Validation.h b/include/Validation.h index 692d2f6e..8adeb579 100644 --- a/include/Validation.h +++ b/include/Validation.h @@ -170,7 +170,7 @@ class ValidateVariableTypeVisitor class ValidateExecutableVisitor { public: - GRAPHQLSERVICE_EXPORT ValidateExecutableVisitor(const std::shared_ptr& schema); + GRAPHQLSERVICE_EXPORT ValidateExecutableVisitor(std::shared_ptr schema); GRAPHQLSERVICE_EXPORT void visit(const peg::ast_node& root); diff --git a/include/graphqlservice/GraphQLClient.h b/include/graphqlservice/GraphQLClient.h index 48933811..1b2e46e7 100644 --- a/include/graphqlservice/GraphQLClient.h +++ b/include/graphqlservice/GraphQLClient.h @@ -59,7 +59,7 @@ struct ServiceResponse }; // Split a service response into separate ServiceResponse data and errors members. -GRAPHQLCLIENT_EXPORT ServiceResponse parseServiceResponse(response::Value&& response); +GRAPHQLCLIENT_EXPORT ServiceResponse parseServiceResponse(response::Value response); // GraphQL types are nullable by default, but they may be wrapped with non-null or list types. // Since nullability is a more special case in C++, we invert the default and apply that modifier @@ -192,12 +192,12 @@ struct ModifiedResponse }; // Parse a single value of the response document. - static Type parse(response::Value&& response); + static Type parse(response::Value response); // Peel off the none modifier. If it's included, it should always be last in the list. template static typename std::enable_if_t - parse(response::Value&& response) + parse(response::Value response) { return parse(std::move(response)); } @@ -206,7 +206,7 @@ struct ModifiedResponse template static typename std::enable_if_t::type>> - parse(response::Value&& response) + parse(response::Value response) { if (response.type() == response::Type::Null) { @@ -221,7 +221,7 @@ struct ModifiedResponse template static typename std::enable_if_t::type>> - parse(response::Value&& response) + parse(response::Value response) { std::vector::type> result; @@ -256,22 +256,22 @@ using ScalarResponse = ModifiedResponse; // Export all of the built-in converters template <> GRAPHQLCLIENT_EXPORT response::IntType ModifiedResponse::parse( - response::Value&& response); + response::Value response); template <> GRAPHQLCLIENT_EXPORT response::FloatType ModifiedResponse::parse( - response::Value&& response); + response::Value response); template <> GRAPHQLCLIENT_EXPORT response::StringType ModifiedResponse::parse( - response::Value&& response); + response::Value response); template <> GRAPHQLCLIENT_EXPORT response::BooleanType ModifiedResponse::parse( - response::Value&& response); + response::Value response); template <> GRAPHQLCLIENT_EXPORT response::IdType ModifiedResponse::parse( - response::Value&& response); + response::Value response); template <> GRAPHQLCLIENT_EXPORT response::Value ModifiedResponse::parse( - response::Value&& response); + response::Value response); #endif // GRAPHQL_DLLEXPORTS } // namespace graphql::client diff --git a/include/graphqlservice/GraphQLService.h b/include/graphqlservice/GraphQLService.h index a04e75f3..cb25338b 100644 --- a/include/graphqlservice/GraphQLService.h +++ b/include/graphqlservice/GraphQLService.h @@ -178,7 +178,7 @@ struct SelectionSetParams struct FieldParams : SelectionSetParams { GRAPHQLSERVICE_EXPORT explicit FieldParams( - SelectionSetParams&& selectionSetParams, response::Value&& directives); + SelectionSetParams&& selectionSetParams, response::Value directives); // Each field owns its own field-specific directives. Once the accessor returns it will be // destroyed, but you can move it into another instance of response::Value to keep it alive @@ -258,7 +258,7 @@ class FieldResult void await_suspend(coro::coroutine_handle<> h) const { std::thread( - [this](coro::coroutine_handle<>&& h) noexcept { + [this](coro::coroutine_handle<> h) noexcept { std::get>(_value).wait(); h.resume(); }, @@ -317,8 +317,8 @@ using FragmentMap = internal::string_view_map; struct ResolverParams : SelectionSetParams { GRAPHQLSERVICE_EXPORT explicit ResolverParams(const SelectionSetParams& selectionSetParams, - const peg::ast_node& field, std::string&& fieldName, response::Value&& arguments, - response::Value&& fieldDirectives, const peg::ast_node* selection, + const peg::ast_node& field, std::string&& fieldName, response::Value arguments, + response::Value fieldDirectives, const peg::ast_node* selection, const FragmentMap& fragments, const response::Value& variables); GRAPHQLSERVICE_EXPORT schema_location getLocation() const; @@ -386,7 +386,7 @@ struct ModifiedArgument static Type convert(const response::Value& value); // Call convert on this type without any modifiers. - static Type require(const std::string& name, const response::Value& arguments) + static Type require(std::string_view name, const response::Value& arguments) { try { @@ -426,7 +426,7 @@ struct ModifiedArgument // Peel off the none modifier. If it's included, it should always be last in the list. template static typename std::enable_if_t - require(const std::string& name, const response::Value& arguments) + require(std::string_view name, const response::Value& arguments) { // Just call through to the non-template method without the modifiers. return require(name, arguments); @@ -436,7 +436,7 @@ struct ModifiedArgument template static typename std::enable_if_t::type> - require(const std::string& name, const response::Value& arguments) + require(std::string_view name, const response::Value& arguments) { const auto& valueItr = arguments.find(name); @@ -455,7 +455,7 @@ struct ModifiedArgument template static typename std::enable_if_t::type> - require(const std::string& name, const response::Value& arguments) + require(std::string_view name, const response::Value& arguments) { const auto& values = arguments[name]; typename ArgumentTraits::type result(values.size()); @@ -464,7 +464,7 @@ struct ModifiedArgument std::transform(elements.cbegin(), elements.cend(), result.begin(), - [&name](const response::Value& element) { + [name](const response::Value& element) { response::Value single(response::Type::Map); single.emplace_back(std::string { name }, response::Value(element)); @@ -478,7 +478,7 @@ struct ModifiedArgument // Wrap require with modifiers in a try/catch block. template static std::pair::type, bool> find( - const std::string& name, const response::Value& arguments) noexcept + std::string_view name, const response::Value& arguments) noexcept { try { @@ -596,7 +596,7 @@ struct ModifiedResult std::vector::type>, typename std::conditional_t, std::shared_ptr, U>>>; - using future_type = FieldResult&&; + using future_type = FieldResult; }; template @@ -606,33 +606,30 @@ struct ModifiedResult typename std::conditional_t, std::shared_ptr, U>; using future_type = typename std::conditional_t, - FieldResult>, FieldResult>&&; + FieldResult>, FieldResult>; }; // Convert a single value of the specified type to JSON. static AwaitableResolver convert( - typename ResultTraits::future_type result, ResolverParams&& params); + typename ResultTraits::future_type result, ResolverParams params); // Peel off the none modifier. If it's included, it should always be last in the list. template static typename std::enable_if_t && std::is_base_of_v, AwaitableResolver> - convert(FieldResult::type>&& result, ResolverParams&& params) + convert(FieldResult::type> result, ResolverParams params) { // Call through to the Object specialization with a static_pointer_cast for subclasses of // Object. static_assert(std::is_same_v, typename ResultTraits::type>, "this is the derived object type"); - auto pendingResult = std::move(result); - auto pendingParams = std::move(params); - - co_await await_async { pendingParams.launch }; + co_await await_async { params.launch }; auto awaitedResult = co_await ModifiedResult::convert( - std::static_pointer_cast(co_await pendingResult), - std::move(pendingParams)); + std::static_pointer_cast(co_await result), + std::move(params)); co_return std::move(awaitedResult); } @@ -642,7 +639,7 @@ struct ModifiedResult static typename std::enable_if_t || !std::is_base_of_v), AwaitableResolver> - convert(typename ResultTraits::future_type result, ResolverParams&& params) + convert(typename ResultTraits::future_type result, ResolverParams params) { // Just call through to the partial specialization without the modifier. return convert(std::move(result), std::move(params)); @@ -653,23 +650,20 @@ struct ModifiedResult static typename std::enable_if_t, typename ResultTraits::type>, AwaitableResolver> - convert(typename ResultTraits::future_type result, - ResolverParams&& params) + convert( + typename ResultTraits::future_type result, ResolverParams params) { - auto pendingResult = std::move(result); - auto pendingParams = std::move(params); - - co_await await_async { pendingParams.launch }; + co_await await_async { params.launch }; - auto awaitedResult = co_await std::move(pendingResult); + auto awaitedResult = co_await std::move(result); if (!awaitedResult) { co_return ResolverResult {}; } - auto modifiedResult = co_await ModifiedResult::convert(std::move(awaitedResult), - std::move(pendingParams)); + auto modifiedResult = + co_await ModifiedResult::convert(std::move(awaitedResult), std::move(params)); co_return modifiedResult; } @@ -679,19 +673,16 @@ struct ModifiedResult static typename std::enable_if_t, typename ResultTraits::type>, AwaitableResolver> - convert(typename ResultTraits::future_type result, - ResolverParams&& params) + convert( + typename ResultTraits::future_type result, ResolverParams params) { static_assert(std::is_same_v::type>, typename ResultTraits::type>, "this is the optional version"); - auto pendingResult = std::move(result); - auto pendingParams = std::move(params); + co_await await_async { params.launch }; - co_await await_async { pendingParams.launch }; - - auto awaitedResult = co_await std::move(pendingResult); + auto awaitedResult = co_await std::move(result); if (!awaitedResult) { @@ -699,7 +690,7 @@ struct ModifiedResult } auto modifiedResult = co_await ModifiedResult::convert(std::move(*awaitedResult), - std::move(pendingParams)); + std::move(params)); co_return modifiedResult; } @@ -707,20 +698,17 @@ struct ModifiedResult // Peel off list modifiers. template static typename std::enable_if_t convert( - typename ResultTraits::future_type result, - ResolverParams&& params) + typename ResultTraits::future_type result, ResolverParams params) { - auto pendingResult = std::move(result); - auto pendingParams = std::move(params); std::vector children; - const auto parentPath = pendingParams.errorPath; + const auto parentPath = params.errorPath; - co_await await_async { pendingParams.launch }; + co_await await_async { params.launch }; - auto awaitedResult = co_await std::move(pendingResult); + auto awaitedResult = co_await std::move(result); children.reserve(awaitedResult.size()); - pendingParams.errorPath = std::make_optional( + params.errorPath = std::make_optional( field_path { parentPath ? std::make_optional(std::cref(*parentPath)) : std::nullopt, path_segment { size_t { 0 } } }); @@ -734,31 +722,31 @@ struct ModifiedResult // Copy the values from the std::vector<> rather than moving them. for (typename vector_type::value_type entry : awaitedResult) { - children.push_back(ModifiedResult::convert(std::move(entry), - ResolverParams(pendingParams))); - ++std::get(pendingParams.errorPath->segment); + children.push_back( + ModifiedResult::convert(std::move(entry), ResolverParams(params))); + ++std::get(params.errorPath->segment); } } else { for (auto& entry : awaitedResult) { - children.push_back(ModifiedResult::convert(std::move(entry), - ResolverParams(pendingParams))); - ++std::get(pendingParams.errorPath->segment); + children.push_back( + ModifiedResult::convert(std::move(entry), ResolverParams(params))); + ++std::get(params.errorPath->segment); } } ResolverResult document { response::Value { response::Type::List } }; document.data.reserve(children.size()); - std::get(pendingParams.errorPath->segment) = 0; + std::get(params.errorPath->segment) = 0; for (auto& child : children) { try { - co_await await_async { pendingParams.launch }; + co_await await_async { params.launch }; auto value = co_await std::move(child); @@ -782,15 +770,15 @@ struct ModifiedResult { std::ostringstream message; - message << "Field error name: " << pendingParams.fieldName + message << "Field error name: " << params.fieldName << " unknown error: " << ex.what(); document.errors.emplace_back(schema_error { message.str(), - pendingParams.getLocation(), - buildErrorPath(pendingParams.errorPath) }); + params.getLocation(), + buildErrorPath(params.errorPath) }); } - ++std::get(pendingParams.errorPath->segment); + ++std::get(params.errorPath->segment); } co_return document; @@ -798,23 +786,21 @@ struct ModifiedResult private: using ResolverCallback = - std::function::type&&, const ResolverParams&)>; + std::function::type, const ResolverParams&)>; - static AwaitableResolver resolve(typename ResultTraits::future_type&& result, - ResolverParams&& params, ResolverCallback&& resolver) + static AwaitableResolver resolve(typename ResultTraits::future_type result, + ResolverParams params, ResolverCallback&& resolver) { static_assert(!std::is_base_of_v, "ModfiedResult needs special handling"); - auto pendingResult = std::move(result); - auto pendingParams = std::move(params); auto pendingResolver = std::move(resolver); ResolverResult document; try { - co_await await_async { pendingParams.launch }; - document.data = pendingResolver(co_await pendingResult, pendingParams); + co_await await_async { params.launch }; + document.data = pendingResolver(co_await result, params); } catch (schema_exception& scx) { @@ -855,25 +841,25 @@ using ObjectResult = ModifiedResult; // Export all of the built-in converters template <> GRAPHQLSERVICE_EXPORT AwaitableResolver ModifiedResult::convert( - FieldResult&& result, ResolverParams&& params); + FieldResult result, ResolverParams params); template <> GRAPHQLSERVICE_EXPORT AwaitableResolver ModifiedResult::convert( - FieldResult&& result, ResolverParams&& params); + FieldResult result, ResolverParams params); template <> GRAPHQLSERVICE_EXPORT AwaitableResolver ModifiedResult::convert( - FieldResult&& result, ResolverParams&& params); + FieldResult result, ResolverParams params); template <> GRAPHQLSERVICE_EXPORT AwaitableResolver ModifiedResult::convert( - FieldResult&& result, ResolverParams&& params); + FieldResult result, ResolverParams params); template <> GRAPHQLSERVICE_EXPORT AwaitableResolver ModifiedResult::convert( - FieldResult&& result, ResolverParams&& params); + FieldResult result, ResolverParams params); template <> GRAPHQLSERVICE_EXPORT AwaitableResolver ModifiedResult::convert( - FieldResult&& result, ResolverParams&& params); + FieldResult result, ResolverParams params); template <> GRAPHQLSERVICE_EXPORT AwaitableResolver ModifiedResult::convert( - FieldResult>&& result, ResolverParams&& params); + FieldResult> result, ResolverParams params); #endif // GRAPHQL_DLLEXPORTS using TypeMap = internal::string_view_map>; @@ -897,8 +883,8 @@ struct SubscriptionParams // already tied to the registration and any pending futures passed to callbacks. struct OperationData : std::enable_shared_from_this { - explicit OperationData(std::shared_ptr&& state, response::Value&& variables, - response::Value&& directives, FragmentMap&& fragments); + explicit OperationData(std::shared_ptr state, response::Value variables, + response::Value directives, FragmentMap fragments); std::shared_ptr state; response::Value variables; @@ -908,7 +894,7 @@ struct OperationData : std::enable_shared_from_this // Subscription callbacks receive the response::Value representing the result of evaluating the // SelectionSet against the payload. -using SubscriptionCallback = std::function; +using SubscriptionCallback = std::function; using SubscriptionArguments = std::map; using SubscriptionFilterCallback = std::function; @@ -919,8 +905,8 @@ using SubscriptionName = std::string; // Registration information for subscription, cached in the Request::subscribe call. struct SubscriptionData : std::enable_shared_from_this { - explicit SubscriptionData(std::shared_ptr&& data, SubscriptionName&& field, - response::Value&& arguments, response::Value&& fieldDirectives, peg::ast&& query, + explicit SubscriptionData(std::shared_ptr data, SubscriptionName&& field, + response::Value arguments, response::Value fieldDirectives, peg::ast&& query, std::string&& operationName, SubscriptionCallback&& callback, const peg::ast_node& selection); @@ -945,7 +931,7 @@ class Request : public std::enable_shared_from_this { protected: GRAPHQLSERVICE_EXPORT explicit Request( - TypeMap&& operationTypes, const std::shared_ptr& schema); + TypeMap operationTypes, std::shared_ptr schema); GRAPHQLSERVICE_EXPORT virtual ~Request(); public: @@ -954,12 +940,11 @@ class Request : public std::enable_shared_from_this GRAPHQLSERVICE_EXPORT std::pair findOperationDefinition( peg::ast& query, std::string_view operationName) const; - GRAPHQLSERVICE_EXPORT response::AwaitableValue resolve( - const std::shared_ptr& state, peg::ast& query, - const std::string& operationName, response::Value&& variables) const; + GRAPHQLSERVICE_EXPORT response::AwaitableValue resolve(std::shared_ptr state, + peg::ast& query, std::string_view operationName, response::Value variables) const; GRAPHQLSERVICE_EXPORT response::AwaitableValue resolve(std::launch launch, - const std::shared_ptr& state, peg::ast& query, - const std::string& operationName, response::Value&& variables) const; + std::shared_ptr state, peg::ast& query, std::string_view operationName, + response::Value variables) const; GRAPHQLSERVICE_EXPORT SubscriptionKey subscribe( SubscriptionParams&& params, SubscriptionCallback&& callback); @@ -974,34 +959,34 @@ class Request : public std::enable_shared_from_this const SubscriptionName& name, const std::shared_ptr& subscriptionObject) const; GRAPHQLSERVICE_EXPORT void deliver(const SubscriptionName& name, const SubscriptionArguments& arguments, - const std::shared_ptr& subscriptionObject) const; + std::shared_ptr subscriptionObject) const; GRAPHQLSERVICE_EXPORT void deliver(const SubscriptionName& name, const SubscriptionArguments& arguments, const SubscriptionArguments& directives, - const std::shared_ptr& subscriptionObject) const; + std::shared_ptr subscriptionObject) const; GRAPHQLSERVICE_EXPORT void deliver(const SubscriptionName& name, const SubscriptionFilterCallback& applyArguments, - const std::shared_ptr& subscriptionObject) const; + std::shared_ptr subscriptionObject) const; GRAPHQLSERVICE_EXPORT void deliver(const SubscriptionName& name, const SubscriptionFilterCallback& applyArguments, const SubscriptionFilterCallback& applyDirectives, - const std::shared_ptr& subscriptionObject) const; + std::shared_ptr subscriptionObject) const; GRAPHQLSERVICE_EXPORT internal::Awaitable deliver(std::launch launch, - const SubscriptionName& name, const std::shared_ptr& subscriptionObject) const; + const SubscriptionName& name, std::shared_ptr subscriptionObject) const; GRAPHQLSERVICE_EXPORT internal::Awaitable deliver(std::launch launch, const SubscriptionName& name, const SubscriptionArguments& arguments, - const std::shared_ptr& subscriptionObject) const; + std::shared_ptr subscriptionObject) const; GRAPHQLSERVICE_EXPORT internal::Awaitable deliver(std::launch launch, const SubscriptionName& name, const SubscriptionArguments& arguments, const SubscriptionArguments& directives, - const std::shared_ptr& subscriptionObject) const; + std::shared_ptr subscriptionObject) const; GRAPHQLSERVICE_EXPORT internal::Awaitable deliver(std::launch launch, const SubscriptionName& name, const SubscriptionFilterCallback& applyArguments, - const std::shared_ptr& subscriptionObject) const; + std::shared_ptr subscriptionObject) const; GRAPHQLSERVICE_EXPORT internal::Awaitable deliver(std::launch launch, const SubscriptionName& name, const SubscriptionFilterCallback& applyArguments, const SubscriptionFilterCallback& applyDirectives, - const std::shared_ptr& subscriptionObject) const; + std::shared_ptr subscriptionObject) const; private: const TypeMap _operations; diff --git a/include/graphqlservice/internal/Awaitable.h b/include/graphqlservice/internal/Awaitable.h index f3230743..1abca33d 100644 --- a/include/graphqlservice/internal/Awaitable.h +++ b/include/graphqlservice/internal/Awaitable.h @@ -28,7 +28,7 @@ template <> class Awaitable { public: - Awaitable(std::future&& value) + Awaitable(std::future value) : _value { std::move(value) } { } @@ -92,7 +92,7 @@ template class Awaitable { public: - Awaitable(std::future&& value) + Awaitable(std::future value) : _value { std::move(value) } { } diff --git a/include/graphqlservice/introspection/Introspection.h b/include/graphqlservice/introspection/Introspection.h index d0352a7a..bc7e038c 100644 --- a/include/graphqlservice/introspection/Introspection.h +++ b/include/graphqlservice/introspection/Introspection.h @@ -26,15 +26,15 @@ class Schema : public object::Schema // Accessors service::FieldResult>> getTypes( - service::FieldParams&& params) const override; + service::FieldParams&& params) const final; service::FieldResult> getQueryType( - service::FieldParams&& params) const override; + service::FieldParams&& params) const final; service::FieldResult> getMutationType( - service::FieldParams&& params) const override; + service::FieldParams&& params) const final; service::FieldResult> getSubscriptionType( - service::FieldParams&& params) const override; + service::FieldParams&& params) const final; service::FieldResult>> getDirectives( - service::FieldParams&& params) const override; + service::FieldParams&& params) const final; private: const std::shared_ptr _schema; @@ -46,25 +46,25 @@ class Type : public object::Type GRAPHQLINTROSPECTION_EXPORT explicit Type(const std::shared_ptr& type); // Accessors - service::FieldResult getKind(service::FieldParams&&) const override; + service::FieldResult getKind(service::FieldParams&&) const final; service::FieldResult> getName( - service::FieldParams&& params) const override; + service::FieldParams&& params) const final; service::FieldResult> getDescription( - service::FieldParams&& params) const override; + service::FieldParams&& params) const final; service::FieldResult>>> getFields( service::FieldParams&& params, - std::optional&& includeDeprecatedArg) const override; + std::optional&& includeDeprecatedArg) const final; service::FieldResult>>> getInterfaces( - service::FieldParams&& params) const override; + service::FieldParams&& params) const final; service::FieldResult>>> - getPossibleTypes(service::FieldParams&& params) const override; + getPossibleTypes(service::FieldParams&& params) const final; service::FieldResult>>> getEnumValues(service::FieldParams&& params, - std::optional&& includeDeprecatedArg) const override; + std::optional&& includeDeprecatedArg) const final; service::FieldResult>>> - getInputFields(service::FieldParams&& params) const override; + getInputFields(service::FieldParams&& params) const final; service::FieldResult> getOfType( - service::FieldParams&& params) const override; + service::FieldParams&& params) const final; private: const std::shared_ptr _type; @@ -76,18 +76,17 @@ class Field : public object::Field GRAPHQLINTROSPECTION_EXPORT explicit Field(const std::shared_ptr& field); // Accessors - service::FieldResult getName( - service::FieldParams&& params) const override; + service::FieldResult getName(service::FieldParams&& params) const final; service::FieldResult> getDescription( - service::FieldParams&& params) const override; + service::FieldParams&& params) const final; service::FieldResult>> getArgs( - service::FieldParams&& params) const override; + service::FieldParams&& params) const final; service::FieldResult> getType( - service::FieldParams&& params) const override; + service::FieldParams&& params) const final; service::FieldResult getIsDeprecated( - service::FieldParams&& params) const override; + service::FieldParams&& params) const final; service::FieldResult> getDeprecationReason( - service::FieldParams&& params) const override; + service::FieldParams&& params) const final; private: const std::shared_ptr _field; @@ -100,14 +99,13 @@ class InputValue : public object::InputValue const std::shared_ptr& inputValue); // Accessors - service::FieldResult getName( - service::FieldParams&& params) const override; + service::FieldResult getName(service::FieldParams&& params) const final; service::FieldResult> getDescription( - service::FieldParams&& params) const override; + service::FieldParams&& params) const final; service::FieldResult> getType( - service::FieldParams&& params) const override; + service::FieldParams&& params) const final; service::FieldResult> getDefaultValue( - service::FieldParams&& params) const override; + service::FieldParams&& params) const final; private: const std::shared_ptr _inputValue; @@ -120,14 +118,13 @@ class EnumValue : public object::EnumValue const std::shared_ptr& enumValue); // Accessors - service::FieldResult getName( - service::FieldParams&& params) const override; + service::FieldResult getName(service::FieldParams&& params) const final; service::FieldResult> getDescription( - service::FieldParams&& params) const override; + service::FieldParams&& params) const final; service::FieldResult getIsDeprecated( - service::FieldParams&& params) const override; + service::FieldParams&& params) const final; service::FieldResult> getDeprecationReason( - service::FieldParams&& params) const override; + service::FieldParams&& params) const final; private: const std::shared_ptr _enumValue; @@ -140,14 +137,13 @@ class Directive : public object::Directive const std::shared_ptr& directive); // Accessors - service::FieldResult getName( - service::FieldParams&& params) const override; + service::FieldResult getName(service::FieldParams&& params) const final; service::FieldResult> getDescription( - service::FieldParams&& params) const override; + service::FieldParams&& params) const final; service::FieldResult> getLocations( - service::FieldParams&& params) const override; + service::FieldParams&& params) const final; service::FieldResult>> getArgs( - service::FieldParams&& params) const override; + service::FieldParams&& params) const final; private: const std::shared_ptr _directive; diff --git a/include/graphqlservice/introspection/IntrospectionSchema.h b/include/graphqlservice/introspection/IntrospectionSchema.h index 6dd72834..594a4ca4 100644 --- a/include/graphqlservice/introspection/IntrospectionSchema.h +++ b/include/graphqlservice/introspection/IntrospectionSchema.h @@ -233,13 +233,13 @@ GRAPHQLINTROSPECTION_EXPORT introspection::TypeKind ModifiedArgument GRAPHQLINTROSPECTION_EXPORT AwaitableResolver ModifiedResult::convert( - FieldResult&& result, ResolverParams&& params); + FieldResult result, ResolverParams params); template <> GRAPHQLINTROSPECTION_EXPORT introspection::DirectiveLocation ModifiedArgument::convert( const response::Value& value); template <> GRAPHQLINTROSPECTION_EXPORT AwaitableResolver ModifiedResult::convert( - FieldResult&& result, ResolverParams&& params); + FieldResult result, ResolverParams params); #endif // GRAPHQL_DLLEXPORTS } // namespace service diff --git a/samples/client/BenchmarkClient.cpp b/samples/client/BenchmarkClient.cpp index ab677a16..1d2f5d4b 100644 --- a/samples/client/BenchmarkClient.cpp +++ b/samples/client/BenchmarkClient.cpp @@ -18,7 +18,7 @@ namespace graphql::client { using namespace query::Query; template <> -Response::appointments_AppointmentConnection::pageInfo_PageInfo ModifiedResponse::parse(response::Value&& response) +Response::appointments_AppointmentConnection::pageInfo_PageInfo ModifiedResponse::parse(response::Value response) { Response::appointments_AppointmentConnection::pageInfo_PageInfo result; @@ -40,7 +40,7 @@ Response::appointments_AppointmentConnection::pageInfo_PageInfo ModifiedResponse } template <> -Response::appointments_AppointmentConnection::edges_AppointmentEdge::node_Appointment ModifiedResponse::parse(response::Value&& response) +Response::appointments_AppointmentConnection::edges_AppointmentEdge::node_Appointment ModifiedResponse::parse(response::Value response) { Response::appointments_AppointmentConnection::edges_AppointmentEdge::node_Appointment result; @@ -77,7 +77,7 @@ Response::appointments_AppointmentConnection::edges_AppointmentEdge::node_Appoin } template <> -Response::appointments_AppointmentConnection::edges_AppointmentEdge ModifiedResponse::parse(response::Value&& response) +Response::appointments_AppointmentConnection::edges_AppointmentEdge ModifiedResponse::parse(response::Value response) { Response::appointments_AppointmentConnection::edges_AppointmentEdge result; @@ -99,7 +99,7 @@ Response::appointments_AppointmentConnection::edges_AppointmentEdge ModifiedResp } template <> -Response::appointments_AppointmentConnection ModifiedResponse::parse(response::Value&& response) +Response::appointments_AppointmentConnection ModifiedResponse::parse(response::Value response) { Response::appointments_AppointmentConnection result; @@ -167,7 +167,7 @@ const peg::ast& GetRequestObject() noexcept return s_request; } -Response parseResponse(response::Value&& response) +Response parseResponse(response::Value response) { Response result; diff --git a/samples/client/BenchmarkClient.h b/samples/client/BenchmarkClient.h index 5130226c..1e142216 100644 --- a/samples/client/BenchmarkClient.h +++ b/samples/client/BenchmarkClient.h @@ -82,7 +82,7 @@ struct Response appointments_AppointmentConnection appointments {}; }; -Response parseResponse(response::Value&& response); +Response parseResponse(response::Value response); } // namespace graphql::client::query::Query diff --git a/samples/client/MutateClient.cpp b/samples/client/MutateClient.cpp index d79aac5a..d9a8fc3a 100644 --- a/samples/client/MutateClient.cpp +++ b/samples/client/MutateClient.cpp @@ -48,7 +48,7 @@ response::Value ModifiedVariable::serialize(Variab } template <> -TaskState ModifiedResponse::parse(response::Value&& value) +TaskState ModifiedResponse::parse(response::Value value) { if (!value.maybe_enum()) { @@ -66,7 +66,7 @@ TaskState ModifiedResponse::parse(response::Value&& value) } template <> -Response::completedTask_CompleteTaskPayload::completedTask_Task ModifiedResponse::parse(response::Value&& response) +Response::completedTask_CompleteTaskPayload::completedTask_Task ModifiedResponse::parse(response::Value response) { Response::completedTask_CompleteTaskPayload::completedTask_Task result; @@ -98,7 +98,7 @@ Response::completedTask_CompleteTaskPayload::completedTask_Task ModifiedResponse } template <> -Response::completedTask_CompleteTaskPayload ModifiedResponse::parse(response::Value&& response) +Response::completedTask_CompleteTaskPayload ModifiedResponse::parse(response::Value response) { Response::completedTask_CompleteTaskPayload result; @@ -170,7 +170,7 @@ response::Value serializeVariables(Variables&& variables) return result; } -Response parseResponse(response::Value&& response) +Response parseResponse(response::Value response) { Response result; diff --git a/samples/client/MutateClient.h b/samples/client/MutateClient.h index 9d250fb0..b7565961 100644 --- a/samples/client/MutateClient.h +++ b/samples/client/MutateClient.h @@ -89,7 +89,7 @@ struct Response completedTask_CompleteTaskPayload completedTask {}; }; -Response parseResponse(response::Value&& response); +Response parseResponse(response::Value response); } // namespace graphql::client::mutation::CompleteTaskMutation diff --git a/samples/client/QueryClient.cpp b/samples/client/QueryClient.cpp index 6277b593..684ecbde 100644 --- a/samples/client/QueryClient.cpp +++ b/samples/client/QueryClient.cpp @@ -25,7 +25,7 @@ static const std::array s_namesTaskState = { }; template <> -TaskState ModifiedResponse::parse(response::Value&& value) +TaskState ModifiedResponse::parse(response::Value value) { if (!value.maybe_enum()) { @@ -43,7 +43,7 @@ TaskState ModifiedResponse::parse(response::Value&& value) } template <> -Response::appointments_AppointmentConnection::edges_AppointmentEdge::node_Appointment ModifiedResponse::parse(response::Value&& response) +Response::appointments_AppointmentConnection::edges_AppointmentEdge::node_Appointment ModifiedResponse::parse(response::Value response) { Response::appointments_AppointmentConnection::edges_AppointmentEdge::node_Appointment result; @@ -85,7 +85,7 @@ Response::appointments_AppointmentConnection::edges_AppointmentEdge::node_Appoin } template <> -Response::appointments_AppointmentConnection::edges_AppointmentEdge ModifiedResponse::parse(response::Value&& response) +Response::appointments_AppointmentConnection::edges_AppointmentEdge ModifiedResponse::parse(response::Value response) { Response::appointments_AppointmentConnection::edges_AppointmentEdge result; @@ -107,7 +107,7 @@ Response::appointments_AppointmentConnection::edges_AppointmentEdge ModifiedResp } template <> -Response::appointments_AppointmentConnection ModifiedResponse::parse(response::Value&& response) +Response::appointments_AppointmentConnection ModifiedResponse::parse(response::Value response) { Response::appointments_AppointmentConnection result; @@ -129,7 +129,7 @@ Response::appointments_AppointmentConnection ModifiedResponse -Response::tasks_TaskConnection::edges_TaskEdge::node_Task ModifiedResponse::parse(response::Value&& response) +Response::tasks_TaskConnection::edges_TaskEdge::node_Task ModifiedResponse::parse(response::Value response) { Response::tasks_TaskConnection::edges_TaskEdge::node_Task result; @@ -166,7 +166,7 @@ Response::tasks_TaskConnection::edges_TaskEdge::node_Task ModifiedResponse -Response::tasks_TaskConnection::edges_TaskEdge ModifiedResponse::parse(response::Value&& response) +Response::tasks_TaskConnection::edges_TaskEdge ModifiedResponse::parse(response::Value response) { Response::tasks_TaskConnection::edges_TaskEdge result; @@ -188,7 +188,7 @@ Response::tasks_TaskConnection::edges_TaskEdge ModifiedResponse -Response::tasks_TaskConnection ModifiedResponse::parse(response::Value&& response) +Response::tasks_TaskConnection ModifiedResponse::parse(response::Value response) { Response::tasks_TaskConnection result; @@ -210,7 +210,7 @@ Response::tasks_TaskConnection ModifiedResponse: } template <> -Response::unreadCounts_FolderConnection::edges_FolderEdge::node_Folder ModifiedResponse::parse(response::Value&& response) +Response::unreadCounts_FolderConnection::edges_FolderEdge::node_Folder ModifiedResponse::parse(response::Value response) { Response::unreadCounts_FolderConnection::edges_FolderEdge::node_Folder result; @@ -247,7 +247,7 @@ Response::unreadCounts_FolderConnection::edges_FolderEdge::node_Folder ModifiedR } template <> -Response::unreadCounts_FolderConnection::edges_FolderEdge ModifiedResponse::parse(response::Value&& response) +Response::unreadCounts_FolderConnection::edges_FolderEdge ModifiedResponse::parse(response::Value response) { Response::unreadCounts_FolderConnection::edges_FolderEdge result; @@ -269,7 +269,7 @@ Response::unreadCounts_FolderConnection::edges_FolderEdge ModifiedResponse -Response::unreadCounts_FolderConnection ModifiedResponse::parse(response::Value&& response) +Response::unreadCounts_FolderConnection ModifiedResponse::parse(response::Value response) { Response::unreadCounts_FolderConnection result; @@ -291,7 +291,7 @@ Response::unreadCounts_FolderConnection ModifiedResponse -Response::anyType_UnionType ModifiedResponse::parse(response::Value&& response) +Response::anyType_UnionType ModifiedResponse::parse(response::Value response) { Response::anyType_UnionType result; @@ -424,7 +424,7 @@ const peg::ast& GetRequestObject() noexcept return s_request; } -Response parseResponse(response::Value&& response) +Response parseResponse(response::Value response) { Response result; diff --git a/samples/client/QueryClient.h b/samples/client/QueryClient.h index 78d9fa45..deab57a5 100644 --- a/samples/client/QueryClient.h +++ b/samples/client/QueryClient.h @@ -176,7 +176,7 @@ struct Response std::vector> anyType {}; }; -Response parseResponse(response::Value&& response); +Response parseResponse(response::Value response); } // namespace graphql::client::query::Query diff --git a/samples/client/SubscribeClient.cpp b/samples/client/SubscribeClient.cpp index d9bae4f4..9444e9e1 100644 --- a/samples/client/SubscribeClient.cpp +++ b/samples/client/SubscribeClient.cpp @@ -18,7 +18,7 @@ namespace graphql::client { using namespace subscription::TestSubscription; template <> -Response::nextAppointment_Appointment ModifiedResponse::parse(response::Value&& response) +Response::nextAppointment_Appointment ModifiedResponse::parse(response::Value response) { Response::nextAppointment_Appointment result; @@ -89,7 +89,7 @@ const peg::ast& GetRequestObject() noexcept return s_request; } -Response parseResponse(response::Value&& response) +Response parseResponse(response::Value response) { Response result; diff --git a/samples/client/SubscribeClient.h b/samples/client/SubscribeClient.h index 7ddeb0e9..3bd49085 100644 --- a/samples/client/SubscribeClient.h +++ b/samples/client/SubscribeClient.h @@ -59,7 +59,7 @@ struct Response std::optional nextAppointment {}; }; -Response parseResponse(response::Value&& response); +Response parseResponse(response::Value response); } // namespace graphql::client::subscription::TestSubscription diff --git a/samples/learn/StarWarsSchema.cpp b/samples/learn/StarWarsSchema.cpp index 77de5726..d8704cc6 100644 --- a/samples/learn/StarWarsSchema.cpp +++ b/samples/learn/StarWarsSchema.cpp @@ -46,7 +46,7 @@ learn::Episode ModifiedArgument::convert(const response::Value& } template <> -service::AwaitableResolver ModifiedResult::convert(service::FieldResult&& result, ResolverParams&& params) +service::AwaitableResolver ModifiedResult::convert(service::FieldResult result, ResolverParams params) { return resolve(std::move(result), std::move(params), [](learn::Episode value, const ResolverParams&) diff --git a/samples/separate/TodaySchema.cpp b/samples/separate/TodaySchema.cpp index 2c9edbac..1492b3f8 100644 --- a/samples/separate/TodaySchema.cpp +++ b/samples/separate/TodaySchema.cpp @@ -47,7 +47,7 @@ today::TaskState ModifiedArgument::convert(const response::Val } template <> -service::AwaitableResolver ModifiedResult::convert(service::FieldResult&& result, ResolverParams&& params) +service::AwaitableResolver ModifiedResult::convert(service::FieldResult result, ResolverParams params) { return resolve(std::move(result), std::move(params), [](today::TaskState value, const ResolverParams&) diff --git a/samples/separate_nointrospection/TodaySchema.cpp b/samples/separate_nointrospection/TodaySchema.cpp index b68a3f1b..46d4fab0 100644 --- a/samples/separate_nointrospection/TodaySchema.cpp +++ b/samples/separate_nointrospection/TodaySchema.cpp @@ -47,7 +47,7 @@ today::TaskState ModifiedArgument::convert(const response::Val } template <> -service::AwaitableResolver ModifiedResult::convert(service::FieldResult&& result, ResolverParams&& params) +service::AwaitableResolver ModifiedResult::convert(service::FieldResult result, ResolverParams params) { return resolve(std::move(result), std::move(params), [](today::TaskState value, const ResolverParams&) diff --git a/samples/unified/TodaySchema.cpp b/samples/unified/TodaySchema.cpp index a513c8ad..a6f7c718 100644 --- a/samples/unified/TodaySchema.cpp +++ b/samples/unified/TodaySchema.cpp @@ -47,7 +47,7 @@ today::TaskState ModifiedArgument::convert(const response::Val } template <> -service::AwaitableResolver ModifiedResult::convert(service::FieldResult&& result, ResolverParams&& params) +service::AwaitableResolver ModifiedResult::convert(service::FieldResult result, ResolverParams params) { return resolve(std::move(result), std::move(params), [](today::TaskState value, const ResolverParams&) diff --git a/samples/unified_nointrospection/TodaySchema.cpp b/samples/unified_nointrospection/TodaySchema.cpp index cfcc7118..436a0f4e 100644 --- a/samples/unified_nointrospection/TodaySchema.cpp +++ b/samples/unified_nointrospection/TodaySchema.cpp @@ -47,7 +47,7 @@ today::TaskState ModifiedArgument::convert(const response::Val } template <> -service::AwaitableResolver ModifiedResult::convert(service::FieldResult&& result, ResolverParams&& params) +service::AwaitableResolver ModifiedResult::convert(service::FieldResult result, ResolverParams params) { return resolve(std::move(result), std::move(params), [](today::TaskState value, const ResolverParams&) diff --git a/samples/validation/ValidationSchema.cpp b/samples/validation/ValidationSchema.cpp index 581c8c3e..baf54748 100644 --- a/samples/validation/ValidationSchema.cpp +++ b/samples/validation/ValidationSchema.cpp @@ -46,7 +46,7 @@ validation::DogCommand ModifiedArgument::convert(const r } template <> -service::AwaitableResolver ModifiedResult::convert(service::FieldResult&& result, ResolverParams&& params) +service::AwaitableResolver ModifiedResult::convert(service::FieldResult result, ResolverParams params) { return resolve(std::move(result), std::move(params), [](validation::DogCommand value, const ResolverParams&) @@ -82,7 +82,7 @@ validation::CatCommand ModifiedArgument::convert(const r } template <> -service::AwaitableResolver ModifiedResult::convert(service::FieldResult&& result, ResolverParams&& params) +service::AwaitableResolver ModifiedResult::convert(service::FieldResult result, ResolverParams params) { return resolve(std::move(result), std::move(params), [](validation::CatCommand value, const ResolverParams&) diff --git a/src/ClientGenerator.cpp b/src/ClientGenerator.cpp index 5c699732..55b29fa3 100644 --- a/src/ClientGenerator.cpp +++ b/src/ClientGenerator.cpp @@ -324,7 +324,7 @@ response::Value serializeVariables(Variables&& variables); headerFile << R"cpp(}; -Response parseResponse(response::Value&& response); +Response parseResponse(response::Value response); )cpp"; pendingSeparator.add(); @@ -567,7 +567,7 @@ response::Value ModifiedVariable )cpp" << cppType << R"cpp( ModifiedResponse<)cpp" - << cppType << R"cpp(>::parse(response::Value&& value) + << cppType << R"cpp(>::parse(response::Value value) { if (!value.maybe_enum()) { @@ -639,7 +639,7 @@ response::Value serializeVariables(Variables&& variables) } sourceFile << R"cpp( -Response parseResponse(response::Value&& response) +Response parseResponse(response::Value response) { Response result; @@ -757,7 +757,7 @@ bool Generator::outputModifiedResponseImplementation(std::ostream& sourceFile, template <> )cpp" << cppType << R"cpp( ModifiedResponse<)cpp" << cppType - << R"cpp(>::parse(response::Value&& response) + << R"cpp(>::parse(response::Value response) { )cpp" << cppType << R"cpp( result; diff --git a/src/GraphQLClient.cpp b/src/GraphQLClient.cpp index bb9b45f5..c7383991 100644 --- a/src/GraphQLClient.cpp +++ b/src/GraphQLClient.cpp @@ -126,7 +126,7 @@ Error parseServiceError(response::Value&& error) return result; } -ServiceResponse parseServiceResponse(response::Value&& response) +ServiceResponse parseServiceResponse(response::Value response) { ServiceResponse result; @@ -203,7 +203,7 @@ response::Value ModifiedVariable::serialize(response::IdType&& } template <> -response::IntType ModifiedResponse::parse(response::Value&& value) +response::IntType ModifiedResponse::parse(response::Value value) { if (value.type() != response::Type::Int) { @@ -214,7 +214,7 @@ response::IntType ModifiedResponse::parse(response::Value&& v } template <> -response::FloatType ModifiedResponse::parse(response::Value&& value) +response::FloatType ModifiedResponse::parse(response::Value value) { if (value.type() != response::Type::Float && value.type() != response::Type::Int) { @@ -225,7 +225,7 @@ response::FloatType ModifiedResponse::parse(response::Value } template <> -response::StringType ModifiedResponse::parse(response::Value&& value) +response::StringType ModifiedResponse::parse(response::Value value) { if (value.type() != response::Type::String) { @@ -236,7 +236,7 @@ response::StringType ModifiedResponse::parse(response::Val } template <> -response::BooleanType ModifiedResponse::parse(response::Value&& value) +response::BooleanType ModifiedResponse::parse(response::Value value) { if (value.type() != response::Type::Boolean) { @@ -247,13 +247,13 @@ response::BooleanType ModifiedResponse::parse(response::V } template <> -response::Value ModifiedResponse::parse(response::Value&& value) +response::Value ModifiedResponse::parse(response::Value value) { - return response::Value { std::move(value) }; + return value; } template <> -response::IdType ModifiedResponse::parse(response::Value&& value) +response::IdType ModifiedResponse::parse(response::Value value) { if (value.type() != response::Type::String) { diff --git a/src/GraphQLService.cpp b/src/GraphQLService.cpp index 49a649f1..7c545bd5 100644 --- a/src/GraphQLService.cpp +++ b/src/GraphQLService.cpp @@ -165,7 +165,7 @@ response::Value schema_exception::getErrors() return buildErrorValues(std::move(_structuredErrors)); } -FieldParams::FieldParams(SelectionSetParams&& selectionSetParams, response::Value&& directives) +FieldParams::FieldParams(SelectionSetParams&& selectionSetParams, response::Value directives) : SelectionSetParams(std::move(selectionSetParams)) , fieldDirectives(std::move(directives)) { @@ -497,8 +497,8 @@ const response::Value& Fragment::getDirectives() const } ResolverParams::ResolverParams(const SelectionSetParams& selectionSetParams, - const peg::ast_node& field, std::string&& fieldName, response::Value&& arguments, - response::Value&& fieldDirectives, const peg::ast_node* selection, const FragmentMap& fragments, + const peg::ast_node& field, std::string&& fieldName, response::Value arguments, + response::Value fieldDirectives, const peg::ast_node* selection, const FragmentMap& fragments, const response::Value& variables) : SelectionSetParams(selectionSetParams) , field(field) @@ -628,7 +628,7 @@ void blockSubFields(const ResolverParams& params) template <> AwaitableResolver ModifiedResult::convert( - FieldResult&& result, ResolverParams&& params) + FieldResult result, ResolverParams params) { blockSubFields(params); @@ -641,7 +641,7 @@ AwaitableResolver ModifiedResult::convert( template <> AwaitableResolver ModifiedResult::convert( - FieldResult&& result, ResolverParams&& params) + FieldResult result, ResolverParams params) { blockSubFields(params); @@ -654,7 +654,7 @@ AwaitableResolver ModifiedResult::convert( template <> AwaitableResolver ModifiedResult::convert( - FieldResult&& result, ResolverParams&& params) + FieldResult result, ResolverParams params) { blockSubFields(params); @@ -667,7 +667,7 @@ AwaitableResolver ModifiedResult::convert( template <> AwaitableResolver ModifiedResult::convert( - FieldResult&& result, ResolverParams&& params) + FieldResult result, ResolverParams params) { blockSubFields(params); @@ -680,7 +680,7 @@ AwaitableResolver ModifiedResult::convert( template <> AwaitableResolver ModifiedResult::convert( - FieldResult&& result, ResolverParams&& params) + FieldResult result, ResolverParams params) { blockSubFields(params); @@ -693,7 +693,7 @@ AwaitableResolver ModifiedResult::convert( template <> AwaitableResolver ModifiedResult::convert( - FieldResult&& result, ResolverParams&& params) + FieldResult result, ResolverParams params) { blockSubFields(params); @@ -722,26 +722,23 @@ void requireSubFields(const ResolverParams& params) template <> AwaitableResolver ModifiedResult::convert( - FieldResult>&& result, ResolverParams&& params) + FieldResult> result, ResolverParams params) { - auto pendingResult = std::move(result); - auto pendingParams = std::move(params); + requireSubFields(params); - requireSubFields(pendingParams); + co_await await_async { params.launch }; - co_await await_async { pendingParams.launch }; - - auto awaitedResult = co_await std::move(pendingResult); + auto awaitedResult = co_await std::move(result); if (!awaitedResult) { co_return ResolverResult {}; } - auto document = co_await awaitedResult->resolve(pendingParams, - *pendingParams.selection, - pendingParams.fragments, - pendingParams.variables); + auto document = co_await awaitedResult->resolve(params, + *params.selection, + params.fragments, + params.variables); co_return std::move(document); } @@ -1211,8 +1208,8 @@ void Object::endSelectionSet(const SelectionSetParams&) const { } -OperationData::OperationData(std::shared_ptr&& state, response::Value&& variables, - response::Value&& directives, FragmentMap&& fragments) +OperationData::OperationData(std::shared_ptr state, response::Value variables, + response::Value directives, FragmentMap fragments) : state(std::move(state)) , variables(std::move(variables)) , directives(std::move(directives)) @@ -1275,8 +1272,8 @@ class OperationDefinitionVisitor std::optional _result; }; -SubscriptionData::SubscriptionData(std::shared_ptr&& data, SubscriptionName&& field, - response::Value&& arguments, response::Value&& fieldDirectives, peg::ast&& query, +SubscriptionData::SubscriptionData(std::shared_ptr data, SubscriptionName&& field, + response::Value arguments, response::Value fieldDirectives, peg::ast&& query, std::string&& operationName, SubscriptionCallback&& callback, const peg::ast_node& selection) : data(std::move(data)) , field(std::move(field)) @@ -1605,9 +1602,9 @@ void SubscriptionDefinitionVisitor::visitInlineFragment(const peg::ast_node& inl } } -Request::Request(TypeMap&& operationTypes, const std::shared_ptr& schema) +Request::Request(TypeMap operationTypes, std::shared_ptr schema) : _operations(std::move(operationTypes)) - , _validation(std::make_unique(schema)) + , _validation(std::make_unique(std::move(schema))) { } @@ -1673,15 +1670,18 @@ std::pair Request::findOperationDefiniti return result; } -response::AwaitableValue Request::resolve(const std::shared_ptr& state, - peg::ast& query, const std::string& operationName, response::Value&& variables) const +response::AwaitableValue Request::resolve(std::shared_ptr state, peg::ast& query, + std::string_view operationName, response::Value variables) const { - return resolve(std::launch::deferred, state, query, operationName, std::move(variables)); + return resolve(std::launch::deferred, + std::move(state), + query, + operationName, + std::move(variables)); } -response::AwaitableValue Request::resolve(std::launch launch, - const std::shared_ptr& state, peg::ast& query, const std::string& operationName, - response::Value&& variables) const +response::AwaitableValue Request::resolve(std::launch launch, std::shared_ptr state, + peg::ast& query, std::string_view operationName, response::Value variables) const { try { @@ -1947,52 +1947,61 @@ void Request::deliver( } void Request::deliver(const SubscriptionName& name, const SubscriptionArguments& arguments, - const std::shared_ptr& subscriptionObject) const + std::shared_ptr subscriptionObject) const { - deliver(std::launch::deferred, name, arguments, subscriptionObject).get(); + deliver(std::launch::deferred, name, arguments, std::move(subscriptionObject)).get(); } void Request::deliver(const SubscriptionName& name, const SubscriptionArguments& arguments, - const SubscriptionArguments& directives, - const std::shared_ptr& subscriptionObject) const + const SubscriptionArguments& directives, std::shared_ptr subscriptionObject) const { - deliver(std::launch::deferred, name, arguments, directives, subscriptionObject).get(); + deliver(std::launch::deferred, name, arguments, directives, std::move(subscriptionObject)) + .get(); } void Request::deliver(const SubscriptionName& name, const SubscriptionFilterCallback& applyArguments, - const std::shared_ptr& subscriptionObject) const + std::shared_ptr subscriptionObject) const { - deliver(std::launch::deferred, name, applyArguments, subscriptionObject).get(); + deliver(std::launch::deferred, name, applyArguments, std::move(subscriptionObject)).get(); } void Request::deliver(const SubscriptionName& name, const SubscriptionFilterCallback& applyArguments, const SubscriptionFilterCallback& applyDirectives, - const std::shared_ptr& subscriptionObject) const + std::shared_ptr subscriptionObject) const { - deliver(std::launch::deferred, name, applyArguments, applyDirectives, subscriptionObject).get(); + deliver(std::launch::deferred, + name, + applyArguments, + applyDirectives, + std::move(subscriptionObject)) + .get(); } internal::Awaitable Request::deliver(std::launch launch, const SubscriptionName& name, - const std::shared_ptr& subscriptionObject) const + std::shared_ptr subscriptionObject) const { return deliver(launch, name, SubscriptionArguments {}, SubscriptionArguments {}, - subscriptionObject); + std::move(subscriptionObject)); } internal::Awaitable Request::deliver(std::launch launch, const SubscriptionName& name, - const SubscriptionArguments& arguments, const std::shared_ptr& subscriptionObject) const + const SubscriptionArguments& arguments, std::shared_ptr subscriptionObject) const { - return deliver(launch, name, arguments, SubscriptionArguments {}, subscriptionObject); + return deliver(launch, + name, + arguments, + SubscriptionArguments {}, + std::move(subscriptionObject)); } internal::Awaitable Request::deliver(std::launch launch, const SubscriptionName& name, const SubscriptionArguments& arguments, const SubscriptionArguments& directives, - const std::shared_ptr& subscriptionObject) const + std::shared_ptr subscriptionObject) const { SubscriptionFilterCallback argumentsMatch = [&arguments](response::MapType::const_reference required) noexcept -> bool { @@ -2008,12 +2017,12 @@ internal::Awaitable Request::deliver(std::launch launch, const Subscriptio return (itrDirective != directives.end() && itrDirective->second == required.second); }; - return deliver(launch, name, argumentsMatch, directivesMatch, subscriptionObject); + return deliver(launch, name, argumentsMatch, directivesMatch, std::move(subscriptionObject)); } internal::Awaitable Request::deliver(std::launch launch, const SubscriptionName& name, const SubscriptionFilterCallback& applyArguments, - const std::shared_ptr& subscriptionObject) const + std::shared_ptr subscriptionObject) const { return deliver( launch, @@ -2022,13 +2031,13 @@ internal::Awaitable Request::deliver(std::launch launch, const Subscriptio [](response::MapType::const_reference) noexcept { return true; }, - subscriptionObject); + std::move(subscriptionObject)); } internal::Awaitable Request::deliver(std::launch launch, const SubscriptionName& name, const SubscriptionFilterCallback& applyArguments, const SubscriptionFilterCallback& applyDirectives, - const std::shared_ptr& subscriptionObject) const + std::shared_ptr subscriptionObject) const { const auto itrOperation = _operations.find(strSubscription); @@ -2040,7 +2049,7 @@ internal::Awaitable Request::deliver(std::launch launch, const Subscriptio } const auto optionalOrDefaultSubscription = - subscriptionObject ? subscriptionObject : itrOperation->second; + subscriptionObject ? std::move(subscriptionObject) : itrOperation->second; if (!optionalOrDefaultSubscription) { diff --git a/src/IntrospectionSchema.cpp b/src/IntrospectionSchema.cpp index 23c73aa0..42dee636 100644 --- a/src/IntrospectionSchema.cpp +++ b/src/IntrospectionSchema.cpp @@ -49,7 +49,7 @@ introspection::TypeKind ModifiedArgument::convert(const } template <> -service::AwaitableResolver ModifiedResult::convert(service::FieldResult&& result, ResolverParams&& params) +service::AwaitableResolver ModifiedResult::convert(service::FieldResult result, ResolverParams params) { return resolve(std::move(result), std::move(params), [](introspection::TypeKind value, const ResolverParams&) @@ -102,7 +102,7 @@ introspection::DirectiveLocation ModifiedArgument -service::AwaitableResolver ModifiedResult::convert(service::FieldResult&& result, ResolverParams&& params) +service::AwaitableResolver ModifiedResult::convert(service::FieldResult result, ResolverParams params) { return resolve(std::move(result), std::move(params), [](introspection::DirectiveLocation value, const ResolverParams&) diff --git a/src/SchemaGenerator.cpp b/src/SchemaGenerator.cpp index 3eb0ae82..6af1b1cd 100644 --- a/src/SchemaGenerator.cpp +++ b/src/SchemaGenerator.cpp @@ -410,7 +410,7 @@ GRAPHQLINTROSPECTION_EXPORT AwaitableResolver ModifiedResult<)cpp" << R"cpp(>::convert( FieldResult<)cpp" << _loader.getSchemaNamespace() << R"cpp(::)cpp" << enumType.cppType - << R"cpp(>&& result, ResolverParams&& params); + << R"cpp(> result, ResolverParams params); )cpp"; } @@ -661,7 +661,7 @@ service::AwaitableResolver ModifiedResult<)cpp" << _loader.getSchemaNamespace() << R"cpp(::)cpp" << enumType.cppType << R"cpp(>::convert(service::FieldResult<)cpp" << _loader.getSchemaNamespace() << R"cpp(::)cpp" << enumType.cppType - << R"cpp(>&& result, ResolverParams&& params) + << R"cpp(> result, ResolverParams params) { return resolve(std::move(result), std::move(params), []()cpp" << _loader.getSchemaNamespace() diff --git a/src/Validation.cpp b/src/Validation.cpp index 23e4731e..293b4b9e 100644 --- a/src/Validation.cpp +++ b/src/Validation.cpp @@ -358,7 +358,7 @@ ValidateType ValidateVariableTypeVisitor::getType() return result; } -ValidateExecutableVisitor::ValidateExecutableVisitor(const std::shared_ptr& schema) +ValidateExecutableVisitor::ValidateExecutableVisitor(std::shared_ptr schema) : _schema(schema) { const auto& queryType = _schema->queryType(); From ce8efd780b2117b330b715fdc5ac1cbb1787c6e8 Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Thu, 4 Nov 2021 11:54:22 -0700 Subject: [PATCH 023/119] Drop redundant virtual with override in stub declarations --- samples/CMakeLists.txt | 4 +-- samples/learn/DroidObject.cpp | 25 ------------------- samples/learn/DroidObject.h | 6 +---- samples/learn/HumanObject.cpp | 25 ------------------- samples/learn/HumanObject.h | 6 +---- samples/learn/MutationObject.cpp | 5 ---- samples/learn/MutationObject.h | 2 +- samples/learn/QueryObject.cpp | 15 ----------- samples/learn/QueryObject.h | 6 ++--- samples/learn/ReviewObject.cpp | 10 -------- samples/learn/ReviewObject.h | 4 +-- samples/separate/AppointmentObject.h | 2 +- samples/separate/FolderObject.h | 2 +- samples/separate/TaskObject.h | 2 +- .../AppointmentObject.h | 2 +- .../separate_nointrospection/FolderObject.h | 2 +- samples/separate_nointrospection/TaskObject.h | 2 +- samples/unified/TodaySchema.h | 6 ++--- samples/unified_nointrospection/TodaySchema.h | 6 ++--- samples/validation/ValidationSchema.h | 8 +++--- src/SchemaGenerator.cpp | 17 ++++++++++--- 21 files changed, 39 insertions(+), 118 deletions(-) diff --git a/samples/CMakeLists.txt b/samples/CMakeLists.txt index 64e3d512..4c27dddb 100644 --- a/samples/CMakeLists.txt +++ b/samples/CMakeLists.txt @@ -79,11 +79,11 @@ if(GRAPHQL_UPDATE_SAMPLES) add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/learn/learn_schema_files - COMMAND schemagen --schema="${CMAKE_CURRENT_SOURCE_DIR}/schema.learn.graphql" --prefix="StarWars" --namespace="learn" --separate-files > learn_schema_files + COMMAND schemagen --schema="${CMAKE_CURRENT_SOURCE_DIR}/schema.learn.graphql" --prefix="StarWars" --namespace="learn" --no-stubs --separate-files > learn_schema_files COMMAND ${CMAKE_COMMAND} -E copy_if_different learn_schema_files ${CMAKE_CURRENT_SOURCE_DIR}/learn DEPENDS schemagen graphqlpeg schema.learn.graphql WORKING_DIRECTORY learn - COMMENT "Generating mock StarWarsSchema (--separate-files)") + COMMENT "Generating mock StarWarsSchema (--no-stubs --separate-files)") add_custom_command( OUTPUT updated_samples diff --git a/samples/learn/DroidObject.cpp b/samples/learn/DroidObject.cpp index 001dc819..60e2ecfe 100644 --- a/samples/learn/DroidObject.cpp +++ b/samples/learn/DroidObject.cpp @@ -33,11 +33,6 @@ Droid::Droid() { } -service::FieldResult Droid::getId(service::FieldParams&&) const -{ - throw std::runtime_error(R"ex(Droid::getId is not implemented)ex"); -} - service::AwaitableResolver Droid::resolveId(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); @@ -48,11 +43,6 @@ service::AwaitableResolver Droid::resolveId(service::ResolverParams&& params) return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult> Droid::getName(service::FieldParams&&) const -{ - throw std::runtime_error(R"ex(Droid::getName is not implemented)ex"); -} - service::AwaitableResolver Droid::resolveName(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); @@ -63,11 +53,6 @@ service::AwaitableResolver Droid::resolveName(service::ResolverParams&& params) return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult>>> Droid::getFriends(service::FieldParams&&) const -{ - throw std::runtime_error(R"ex(Droid::getFriends is not implemented)ex"); -} - service::AwaitableResolver Droid::resolveFriends(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); @@ -78,11 +63,6 @@ service::AwaitableResolver Droid::resolveFriends(service::ResolverParams&& param return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult>>> Droid::getAppearsIn(service::FieldParams&&) const -{ - throw std::runtime_error(R"ex(Droid::getAppearsIn is not implemented)ex"); -} - service::AwaitableResolver Droid::resolveAppearsIn(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); @@ -93,11 +73,6 @@ service::AwaitableResolver Droid::resolveAppearsIn(service::ResolverParams&& par return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult> Droid::getPrimaryFunction(service::FieldParams&&) const -{ - throw std::runtime_error(R"ex(Droid::getPrimaryFunction is not implemented)ex"); -} - service::AwaitableResolver Droid::resolvePrimaryFunction(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); diff --git a/samples/learn/DroidObject.h b/samples/learn/DroidObject.h index 30d52501..1ea6819f 100644 --- a/samples/learn/DroidObject.h +++ b/samples/learn/DroidObject.h @@ -20,11 +20,7 @@ class Droid explicit Droid(); public: - virtual service::FieldResult getId(service::FieldParams&& params) const override; - virtual service::FieldResult> getName(service::FieldParams&& params) const override; - virtual service::FieldResult>>> getFriends(service::FieldParams&& params) const override; - virtual service::FieldResult>>> getAppearsIn(service::FieldParams&& params) const override; - virtual service::FieldResult> getPrimaryFunction(service::FieldParams&& params) const; + virtual service::FieldResult> getPrimaryFunction(service::FieldParams&& params) const = 0; private: service::AwaitableResolver resolveId(service::ResolverParams&& params); diff --git a/samples/learn/HumanObject.cpp b/samples/learn/HumanObject.cpp index 25a6e93d..2dd578c3 100644 --- a/samples/learn/HumanObject.cpp +++ b/samples/learn/HumanObject.cpp @@ -33,11 +33,6 @@ Human::Human() { } -service::FieldResult Human::getId(service::FieldParams&&) const -{ - throw std::runtime_error(R"ex(Human::getId is not implemented)ex"); -} - service::AwaitableResolver Human::resolveId(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); @@ -48,11 +43,6 @@ service::AwaitableResolver Human::resolveId(service::ResolverParams&& params) return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult> Human::getName(service::FieldParams&&) const -{ - throw std::runtime_error(R"ex(Human::getName is not implemented)ex"); -} - service::AwaitableResolver Human::resolveName(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); @@ -63,11 +53,6 @@ service::AwaitableResolver Human::resolveName(service::ResolverParams&& params) return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult>>> Human::getFriends(service::FieldParams&&) const -{ - throw std::runtime_error(R"ex(Human::getFriends is not implemented)ex"); -} - service::AwaitableResolver Human::resolveFriends(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); @@ -78,11 +63,6 @@ service::AwaitableResolver Human::resolveFriends(service::ResolverParams&& param return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult>>> Human::getAppearsIn(service::FieldParams&&) const -{ - throw std::runtime_error(R"ex(Human::getAppearsIn is not implemented)ex"); -} - service::AwaitableResolver Human::resolveAppearsIn(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); @@ -93,11 +73,6 @@ service::AwaitableResolver Human::resolveAppearsIn(service::ResolverParams&& par return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult> Human::getHomePlanet(service::FieldParams&&) const -{ - throw std::runtime_error(R"ex(Human::getHomePlanet is not implemented)ex"); -} - service::AwaitableResolver Human::resolveHomePlanet(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); diff --git a/samples/learn/HumanObject.h b/samples/learn/HumanObject.h index 9555a004..3d2d068a 100644 --- a/samples/learn/HumanObject.h +++ b/samples/learn/HumanObject.h @@ -20,11 +20,7 @@ class Human explicit Human(); public: - virtual service::FieldResult getId(service::FieldParams&& params) const override; - virtual service::FieldResult> getName(service::FieldParams&& params) const override; - virtual service::FieldResult>>> getFriends(service::FieldParams&& params) const override; - virtual service::FieldResult>>> getAppearsIn(service::FieldParams&& params) const override; - virtual service::FieldResult> getHomePlanet(service::FieldParams&& params) const; + virtual service::FieldResult> getHomePlanet(service::FieldParams&& params) const = 0; private: service::AwaitableResolver resolveId(service::ResolverParams&& params); diff --git a/samples/learn/MutationObject.cpp b/samples/learn/MutationObject.cpp index 1a8cfdb6..a6245e0e 100644 --- a/samples/learn/MutationObject.cpp +++ b/samples/learn/MutationObject.cpp @@ -28,11 +28,6 @@ Mutation::Mutation() { } -service::FieldResult> Mutation::applyCreateReview(service::FieldParams&&, Episode&&, ReviewInput&&) const -{ - throw std::runtime_error(R"ex(Mutation::applyCreateReview is not implemented)ex"); -} - service::AwaitableResolver Mutation::resolveCreateReview(service::ResolverParams&& params) { auto argEp = service::ModifiedArgument::require("ep", params.arguments); diff --git a/samples/learn/MutationObject.h b/samples/learn/MutationObject.h index e2265cce..65862e31 100644 --- a/samples/learn/MutationObject.h +++ b/samples/learn/MutationObject.h @@ -19,7 +19,7 @@ class Mutation explicit Mutation(); public: - virtual service::FieldResult> applyCreateReview(service::FieldParams&& params, Episode&& epArg, ReviewInput&& reviewArg) const; + virtual service::FieldResult> applyCreateReview(service::FieldParams&& params, Episode&& epArg, ReviewInput&& reviewArg) const = 0; private: service::AwaitableResolver resolveCreateReview(service::ResolverParams&& params); diff --git a/samples/learn/QueryObject.cpp b/samples/learn/QueryObject.cpp index 5c9e491d..375546c0 100644 --- a/samples/learn/QueryObject.cpp +++ b/samples/learn/QueryObject.cpp @@ -33,11 +33,6 @@ Query::Query() { } -service::FieldResult> Query::getHero(service::FieldParams&&, std::optional&&) const -{ - throw std::runtime_error(R"ex(Query::getHero is not implemented)ex"); -} - service::AwaitableResolver Query::resolveHero(service::ResolverParams&& params) { auto argEpisode = service::ModifiedArgument::require("episode", params.arguments); @@ -49,11 +44,6 @@ service::AwaitableResolver Query::resolveHero(service::ResolverParams&& params) return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult> Query::getHuman(service::FieldParams&&, response::StringType&&) const -{ - throw std::runtime_error(R"ex(Query::getHuman is not implemented)ex"); -} - service::AwaitableResolver Query::resolveHuman(service::ResolverParams&& params) { auto argId = service::ModifiedArgument::require("id", params.arguments); @@ -65,11 +55,6 @@ service::AwaitableResolver Query::resolveHuman(service::ResolverParams&& params) return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult> Query::getDroid(service::FieldParams&&, response::StringType&&) const -{ - throw std::runtime_error(R"ex(Query::getDroid is not implemented)ex"); -} - service::AwaitableResolver Query::resolveDroid(service::ResolverParams&& params) { auto argId = service::ModifiedArgument::require("id", params.arguments); diff --git a/samples/learn/QueryObject.h b/samples/learn/QueryObject.h index 707c9176..6153e39e 100644 --- a/samples/learn/QueryObject.h +++ b/samples/learn/QueryObject.h @@ -19,9 +19,9 @@ class Query explicit Query(); public: - virtual service::FieldResult> getHero(service::FieldParams&& params, std::optional&& episodeArg) const; - virtual service::FieldResult> getHuman(service::FieldParams&& params, response::StringType&& idArg) const; - virtual service::FieldResult> getDroid(service::FieldParams&& params, response::StringType&& idArg) const; + virtual service::FieldResult> getHero(service::FieldParams&& params, std::optional&& episodeArg) const = 0; + virtual service::FieldResult> getHuman(service::FieldParams&& params, response::StringType&& idArg) const = 0; + virtual service::FieldResult> getDroid(service::FieldParams&& params, response::StringType&& idArg) const = 0; private: service::AwaitableResolver resolveHero(service::ResolverParams&& params); diff --git a/samples/learn/ReviewObject.cpp b/samples/learn/ReviewObject.cpp index 1214509a..6db131d2 100644 --- a/samples/learn/ReviewObject.cpp +++ b/samples/learn/ReviewObject.cpp @@ -29,11 +29,6 @@ Review::Review() { } -service::FieldResult Review::getStars(service::FieldParams&&) const -{ - throw std::runtime_error(R"ex(Review::getStars is not implemented)ex"); -} - service::AwaitableResolver Review::resolveStars(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); @@ -44,11 +39,6 @@ service::AwaitableResolver Review::resolveStars(service::ResolverParams&& params return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult> Review::getCommentary(service::FieldParams&&) const -{ - throw std::runtime_error(R"ex(Review::getCommentary is not implemented)ex"); -} - service::AwaitableResolver Review::resolveCommentary(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); diff --git a/samples/learn/ReviewObject.h b/samples/learn/ReviewObject.h index 3272d903..6dd55281 100644 --- a/samples/learn/ReviewObject.h +++ b/samples/learn/ReviewObject.h @@ -19,8 +19,8 @@ class Review explicit Review(); public: - virtual service::FieldResult getStars(service::FieldParams&& params) const; - virtual service::FieldResult> getCommentary(service::FieldParams&& params) const; + virtual service::FieldResult getStars(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getCommentary(service::FieldParams&& params) const = 0; private: service::AwaitableResolver resolveStars(service::ResolverParams&& params); diff --git a/samples/separate/AppointmentObject.h b/samples/separate/AppointmentObject.h index e7f710ac..efdd3500 100644 --- a/samples/separate/AppointmentObject.h +++ b/samples/separate/AppointmentObject.h @@ -20,7 +20,7 @@ class Appointment explicit Appointment(); public: - virtual service::FieldResult getId(service::FieldParams&& params) const override; + service::FieldResult getId(service::FieldParams&& params) const override; virtual service::FieldResult> getWhen(service::FieldParams&& params) const; virtual service::FieldResult> getSubject(service::FieldParams&& params) const; virtual service::FieldResult getIsNow(service::FieldParams&& params) const; diff --git a/samples/separate/FolderObject.h b/samples/separate/FolderObject.h index abd48918..bd1999ba 100644 --- a/samples/separate/FolderObject.h +++ b/samples/separate/FolderObject.h @@ -20,7 +20,7 @@ class Folder explicit Folder(); public: - virtual service::FieldResult getId(service::FieldParams&& params) const override; + service::FieldResult getId(service::FieldParams&& params) const override; virtual service::FieldResult> getName(service::FieldParams&& params) const; virtual service::FieldResult getUnreadCount(service::FieldParams&& params) const; diff --git a/samples/separate/TaskObject.h b/samples/separate/TaskObject.h index c6a52bd7..a03e82cc 100644 --- a/samples/separate/TaskObject.h +++ b/samples/separate/TaskObject.h @@ -20,7 +20,7 @@ class Task explicit Task(); public: - virtual service::FieldResult getId(service::FieldParams&& params) const override; + service::FieldResult getId(service::FieldParams&& params) const override; virtual service::FieldResult> getTitle(service::FieldParams&& params) const; virtual service::FieldResult getIsComplete(service::FieldParams&& params) const; diff --git a/samples/separate_nointrospection/AppointmentObject.h b/samples/separate_nointrospection/AppointmentObject.h index e7f710ac..efdd3500 100644 --- a/samples/separate_nointrospection/AppointmentObject.h +++ b/samples/separate_nointrospection/AppointmentObject.h @@ -20,7 +20,7 @@ class Appointment explicit Appointment(); public: - virtual service::FieldResult getId(service::FieldParams&& params) const override; + service::FieldResult getId(service::FieldParams&& params) const override; virtual service::FieldResult> getWhen(service::FieldParams&& params) const; virtual service::FieldResult> getSubject(service::FieldParams&& params) const; virtual service::FieldResult getIsNow(service::FieldParams&& params) const; diff --git a/samples/separate_nointrospection/FolderObject.h b/samples/separate_nointrospection/FolderObject.h index abd48918..bd1999ba 100644 --- a/samples/separate_nointrospection/FolderObject.h +++ b/samples/separate_nointrospection/FolderObject.h @@ -20,7 +20,7 @@ class Folder explicit Folder(); public: - virtual service::FieldResult getId(service::FieldParams&& params) const override; + service::FieldResult getId(service::FieldParams&& params) const override; virtual service::FieldResult> getName(service::FieldParams&& params) const; virtual service::FieldResult getUnreadCount(service::FieldParams&& params) const; diff --git a/samples/separate_nointrospection/TaskObject.h b/samples/separate_nointrospection/TaskObject.h index c6a52bd7..a03e82cc 100644 --- a/samples/separate_nointrospection/TaskObject.h +++ b/samples/separate_nointrospection/TaskObject.h @@ -20,7 +20,7 @@ class Task explicit Task(); public: - virtual service::FieldResult getId(service::FieldParams&& params) const override; + service::FieldResult getId(service::FieldParams&& params) const override; virtual service::FieldResult> getTitle(service::FieldParams&& params) const; virtual service::FieldResult getIsComplete(service::FieldParams&& params) const; diff --git a/samples/unified/TodaySchema.h b/samples/unified/TodaySchema.h index 20a3868f..c4596c22 100644 --- a/samples/unified/TodaySchema.h +++ b/samples/unified/TodaySchema.h @@ -307,7 +307,7 @@ class Appointment explicit Appointment(); public: - virtual service::FieldResult getId(service::FieldParams&& params) const override; + service::FieldResult getId(service::FieldParams&& params) const override; virtual service::FieldResult> getWhen(service::FieldParams&& params) const; virtual service::FieldResult> getSubject(service::FieldParams&& params) const; virtual service::FieldResult getIsNow(service::FieldParams&& params) const; @@ -331,7 +331,7 @@ class Task explicit Task(); public: - virtual service::FieldResult getId(service::FieldParams&& params) const override; + service::FieldResult getId(service::FieldParams&& params) const override; virtual service::FieldResult> getTitle(service::FieldParams&& params) const; virtual service::FieldResult getIsComplete(service::FieldParams&& params) const; @@ -351,7 +351,7 @@ class Folder explicit Folder(); public: - virtual service::FieldResult getId(service::FieldParams&& params) const override; + service::FieldResult getId(service::FieldParams&& params) const override; virtual service::FieldResult> getName(service::FieldParams&& params) const; virtual service::FieldResult getUnreadCount(service::FieldParams&& params) const; diff --git a/samples/unified_nointrospection/TodaySchema.h b/samples/unified_nointrospection/TodaySchema.h index 77fc0eab..ef1ef1ca 100644 --- a/samples/unified_nointrospection/TodaySchema.h +++ b/samples/unified_nointrospection/TodaySchema.h @@ -303,7 +303,7 @@ class Appointment explicit Appointment(); public: - virtual service::FieldResult getId(service::FieldParams&& params) const override; + service::FieldResult getId(service::FieldParams&& params) const override; virtual service::FieldResult> getWhen(service::FieldParams&& params) const; virtual service::FieldResult> getSubject(service::FieldParams&& params) const; virtual service::FieldResult getIsNow(service::FieldParams&& params) const; @@ -327,7 +327,7 @@ class Task explicit Task(); public: - virtual service::FieldResult getId(service::FieldParams&& params) const override; + service::FieldResult getId(service::FieldParams&& params) const override; virtual service::FieldResult> getTitle(service::FieldParams&& params) const; virtual service::FieldResult getIsComplete(service::FieldParams&& params) const; @@ -347,7 +347,7 @@ class Folder explicit Folder(); public: - virtual service::FieldResult getId(service::FieldParams&& params) const override; + service::FieldResult getId(service::FieldParams&& params) const override; virtual service::FieldResult> getName(service::FieldParams&& params) const; virtual service::FieldResult getUnreadCount(service::FieldParams&& params) const; diff --git a/samples/validation/ValidationSchema.h b/samples/validation/ValidationSchema.h index 691368fe..ec903536 100644 --- a/samples/validation/ValidationSchema.h +++ b/samples/validation/ValidationSchema.h @@ -108,7 +108,7 @@ class Dog explicit Dog(); public: - virtual service::FieldResult getName(service::FieldParams&& params) const override; + service::FieldResult getName(service::FieldParams&& params) const override; virtual service::FieldResult> getNickname(service::FieldParams&& params) const; virtual service::FieldResult> getBarkVolume(service::FieldParams&& params) const; virtual service::FieldResult getDoesKnowCommand(service::FieldParams&& params, DogCommand&& dogCommandArg) const; @@ -134,7 +134,7 @@ class Alien explicit Alien(); public: - virtual service::FieldResult getName(service::FieldParams&& params) const override; + service::FieldResult getName(service::FieldParams&& params) const override; virtual service::FieldResult> getHomePlanet(service::FieldParams&& params) const; private: @@ -152,7 +152,7 @@ class Human explicit Human(); public: - virtual service::FieldResult getName(service::FieldParams&& params) const override; + service::FieldResult getName(service::FieldParams&& params) const override; virtual service::FieldResult>> getPets(service::FieldParams&& params) const; private: @@ -170,7 +170,7 @@ class Cat explicit Cat(); public: - virtual service::FieldResult getName(service::FieldParams&& params) const override; + service::FieldResult getName(service::FieldParams&& params) const override; virtual service::FieldResult> getNickname(service::FieldParams&& params) const; virtual service::FieldResult getDoesKnowCommand(service::FieldParams&& params, CatCommand&& catCommandArg) const; virtual service::FieldResult> getMeowVolume(service::FieldParams&& params) const; diff --git a/src/SchemaGenerator.cpp b/src/SchemaGenerator.cpp index 6af1b1cd..fa598962 100644 --- a/src/SchemaGenerator.cpp +++ b/src/SchemaGenerator.cpp @@ -524,7 +524,15 @@ std::string Generator::getFieldDeclaration(const OutputField& outputField) const std::string fieldName { outputField.cppName }; fieldName[0] = static_cast(std::toupper(static_cast(fieldName[0]))); - output << R"cpp( virtual service::FieldResult<)cpp" << _loader.getOutputCppType(outputField) + output << R"cpp( )cpp"; + + if (outputField.interfaceField || _loader.isIntrospection() || _options.noStubs + || !outputField.inheritedField) + { + output << R"cpp(virtual )cpp"; + } + + output << R"cpp(service::FieldResult<)cpp" << _loader.getOutputCppType(outputField) << R"cpp(> )cpp" << outputField.accessor << fieldName << R"cpp((service::FieldParams&& params)cpp"; @@ -1529,11 +1537,12 @@ service::AwaitableResolver )cpp" } } - sourceFile << R"cpp( std::unique_lock resolverLock(_resolverMutex); + sourceFile + << R"cpp( std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); auto result = )cpp" - << outputField.accessor << fieldName - << R"cpp((service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)))cpp"; + << outputField.accessor << fieldName + << R"cpp((service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)))cpp"; if (!outputField.arguments.empty()) { From bed6506b43647a2f50408398e6a76affac61e385 Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Fri, 19 Nov 2021 17:07:56 -0800 Subject: [PATCH 024/119] Alias internal::Awaitable return types in public interfaces --- doc/subscriptions.md | 33 +++++++++++-------------- include/graphqlservice/GraphQLService.h | 32 ++++++++++++------------ src/GraphQLService.cpp | 14 +++++------ 3 files changed, 38 insertions(+), 41 deletions(-) diff --git a/doc/subscriptions.md b/doc/subscriptions.md index 2af34d1d..a693df03 100644 --- a/doc/subscriptions.md +++ b/doc/subscriptions.md @@ -15,12 +15,11 @@ and `Request::unsubscribe` methods in [GraphQLService.h](../include/graphqlservi ```cpp GRAPHQLSERVICE_EXPORT SubscriptionKey subscribe( SubscriptionParams&& params, SubscriptionCallback&& callback); -GRAPHQLSERVICE_EXPORT internal::Awaitable subscribe( +GRAPHQLSERVICE_EXPORT AwaitableSubscribe subscribe( std::launch launch, SubscriptionParams&& params, SubscriptionCallback&& callback); GRAPHQLSERVICE_EXPORT void unsubscribe(SubscriptionKey key); -GRAPHQLSERVICE_EXPORT internal::Awaitable unsubscribe( - std::launch launch, SubscriptionKey key); +GRAPHQLSERVICE_EXPORT AwaitableUnsubscribe unsubscribe(std::launch launch, SubscriptionKey key); ``` You need to fill in a `SubscriptionParams` struct with the [parsed](./parsing.md) query and any other relevant operation parameters: @@ -120,22 +119,20 @@ also use an override of `Request::resolve` which lets you substitute the `std::launch::async` option to begin executing the queries and invoke the callbacks on multiple threads in parallel: ```cpp -GRAPHQLSERVICE_EXPORT internal::Awaitable deliver(std::launch launch, - const SubscriptionName& name, const std::shared_ptr& subscriptionObject) const; -GRAPHQLSERVICE_EXPORT internal::Awaitable deliver(std::launch launch, - const SubscriptionName& name, const SubscriptionArguments& arguments, - const std::shared_ptr& subscriptionObject) const; -GRAPHQLSERVICE_EXPORT internal::Awaitable deliver(std::launch launch, - const SubscriptionName& name, const SubscriptionArguments& arguments, - const SubscriptionArguments& directives, - const std::shared_ptr& subscriptionObject) const; -GRAPHQLSERVICE_EXPORT internal::Awaitable deliver(std::launch launch, - const SubscriptionName& name, const SubscriptionFilterCallback& applyArguments, - const std::shared_ptr& subscriptionObject) const; -GRAPHQLSERVICE_EXPORT internal::Awaitable deliver(std::launch launch, - const SubscriptionName& name, const SubscriptionFilterCallback& applyArguments, +GRAPHQLSERVICE_EXPORT AwaitableDeliver deliver(std::launch launch, const SubscriptionName& name, + std::shared_ptr subscriptionObject) const; +GRAPHQLSERVICE_EXPORT AwaitableDeliver deliver(std::launch launch, const SubscriptionName& name, + const SubscriptionArguments& arguments, std::shared_ptr subscriptionObject) const; +GRAPHQLSERVICE_EXPORT AwaitableDeliver deliver(std::launch launch, const SubscriptionName& name, + const SubscriptionArguments& arguments, const SubscriptionArguments& directives, + std::shared_ptr subscriptionObject) const; +GRAPHQLSERVICE_EXPORT AwaitableDeliver deliver(std::launch launch, const SubscriptionName& name, + const SubscriptionFilterCallback& applyArguments, + std::shared_ptr subscriptionObject) const; +GRAPHQLSERVICE_EXPORT AwaitableDeliver deliver(std::launch launch, const SubscriptionName& name, + const SubscriptionFilterCallback& applyArguments, const SubscriptionFilterCallback& applyDirectives, - const std::shared_ptr& subscriptionObject) const; + std::shared_ptr subscriptionObject) const; ``` ## Handling Multiple Operation Types diff --git a/include/graphqlservice/GraphQLService.h b/include/graphqlservice/GraphQLService.h index cb25338b..c9aa1640 100644 --- a/include/graphqlservice/GraphQLService.h +++ b/include/graphqlservice/GraphQLService.h @@ -902,6 +902,10 @@ using SubscriptionFilterCallback = std::function; +using AwaitableUnsubscribe = internal::Awaitable; +using AwaitableDeliver = internal::Awaitable; + // Registration information for subscription, cached in the Request::subscribe call. struct SubscriptionData : std::enable_shared_from_this { @@ -948,18 +952,16 @@ class Request : public std::enable_shared_from_this GRAPHQLSERVICE_EXPORT SubscriptionKey subscribe( SubscriptionParams&& params, SubscriptionCallback&& callback); - GRAPHQLSERVICE_EXPORT internal::Awaitable subscribe( + GRAPHQLSERVICE_EXPORT AwaitableSubscribe subscribe( std::launch launch, SubscriptionParams&& params, SubscriptionCallback&& callback); GRAPHQLSERVICE_EXPORT void unsubscribe(SubscriptionKey key); - GRAPHQLSERVICE_EXPORT internal::Awaitable unsubscribe( - std::launch launch, SubscriptionKey key); + GRAPHQLSERVICE_EXPORT AwaitableUnsubscribe unsubscribe(std::launch launch, SubscriptionKey key); GRAPHQLSERVICE_EXPORT void deliver( const SubscriptionName& name, const std::shared_ptr& subscriptionObject) const; GRAPHQLSERVICE_EXPORT void deliver(const SubscriptionName& name, - const SubscriptionArguments& arguments, - std::shared_ptr subscriptionObject) const; + const SubscriptionArguments& arguments, std::shared_ptr subscriptionObject) const; GRAPHQLSERVICE_EXPORT void deliver(const SubscriptionName& name, const SubscriptionArguments& arguments, const SubscriptionArguments& directives, std::shared_ptr subscriptionObject) const; @@ -971,20 +973,18 @@ class Request : public std::enable_shared_from_this const SubscriptionFilterCallback& applyDirectives, std::shared_ptr subscriptionObject) const; - GRAPHQLSERVICE_EXPORT internal::Awaitable deliver(std::launch launch, - const SubscriptionName& name, std::shared_ptr subscriptionObject) const; - GRAPHQLSERVICE_EXPORT internal::Awaitable deliver(std::launch launch, - const SubscriptionName& name, const SubscriptionArguments& arguments, + GRAPHQLSERVICE_EXPORT AwaitableDeliver deliver(std::launch launch, const SubscriptionName& name, std::shared_ptr subscriptionObject) const; - GRAPHQLSERVICE_EXPORT internal::Awaitable deliver(std::launch launch, - const SubscriptionName& name, const SubscriptionArguments& arguments, - const SubscriptionArguments& directives, + GRAPHQLSERVICE_EXPORT AwaitableDeliver deliver(std::launch launch, const SubscriptionName& name, + const SubscriptionArguments& arguments, std::shared_ptr subscriptionObject) const; + GRAPHQLSERVICE_EXPORT AwaitableDeliver deliver(std::launch launch, const SubscriptionName& name, + const SubscriptionArguments& arguments, const SubscriptionArguments& directives, std::shared_ptr subscriptionObject) const; - GRAPHQLSERVICE_EXPORT internal::Awaitable deliver(std::launch launch, - const SubscriptionName& name, const SubscriptionFilterCallback& applyArguments, + GRAPHQLSERVICE_EXPORT AwaitableDeliver deliver(std::launch launch, const SubscriptionName& name, + const SubscriptionFilterCallback& applyArguments, std::shared_ptr subscriptionObject) const; - GRAPHQLSERVICE_EXPORT internal::Awaitable deliver(std::launch launch, - const SubscriptionName& name, const SubscriptionFilterCallback& applyArguments, + GRAPHQLSERVICE_EXPORT AwaitableDeliver deliver(std::launch launch, const SubscriptionName& name, + const SubscriptionFilterCallback& applyArguments, const SubscriptionFilterCallback& applyDirectives, std::shared_ptr subscriptionObject) const; diff --git a/src/GraphQLService.cpp b/src/GraphQLService.cpp index 7c545bd5..22f51758 100644 --- a/src/GraphQLService.cpp +++ b/src/GraphQLService.cpp @@ -1835,7 +1835,7 @@ SubscriptionKey Request::subscribe(SubscriptionParams&& params, SubscriptionCall return key; } -internal::Awaitable Request::subscribe( +AwaitableSubscribe Request::subscribe( std::launch launch, SubscriptionParams&& params, SubscriptionCallback&& callback) { const auto spThis = shared_from_this(); @@ -1907,7 +1907,7 @@ void Request::unsubscribe(SubscriptionKey key) } } -internal::Awaitable Request::unsubscribe(std::launch launch, SubscriptionKey key) +AwaitableUnsubscribe Request::unsubscribe(std::launch launch, SubscriptionKey key) { const auto spThis = shared_from_this(); const auto itrOperation = spThis->_operations.find(strSubscription); @@ -1979,7 +1979,7 @@ void Request::deliver(const SubscriptionName& name, .get(); } -internal::Awaitable Request::deliver(std::launch launch, const SubscriptionName& name, +AwaitableDeliver Request::deliver(std::launch launch, const SubscriptionName& name, std::shared_ptr subscriptionObject) const { return deliver(launch, @@ -1989,7 +1989,7 @@ internal::Awaitable Request::deliver(std::launch launch, const Subscriptio std::move(subscriptionObject)); } -internal::Awaitable Request::deliver(std::launch launch, const SubscriptionName& name, +AwaitableDeliver Request::deliver(std::launch launch, const SubscriptionName& name, const SubscriptionArguments& arguments, std::shared_ptr subscriptionObject) const { return deliver(launch, @@ -1999,7 +1999,7 @@ internal::Awaitable Request::deliver(std::launch launch, const Subscriptio std::move(subscriptionObject)); } -internal::Awaitable Request::deliver(std::launch launch, const SubscriptionName& name, +AwaitableDeliver Request::deliver(std::launch launch, const SubscriptionName& name, const SubscriptionArguments& arguments, const SubscriptionArguments& directives, std::shared_ptr subscriptionObject) const { @@ -2020,7 +2020,7 @@ internal::Awaitable Request::deliver(std::launch launch, const Subscriptio return deliver(launch, name, argumentsMatch, directivesMatch, std::move(subscriptionObject)); } -internal::Awaitable Request::deliver(std::launch launch, const SubscriptionName& name, +AwaitableDeliver Request::deliver(std::launch launch, const SubscriptionName& name, const SubscriptionFilterCallback& applyArguments, std::shared_ptr subscriptionObject) const { @@ -2034,7 +2034,7 @@ internal::Awaitable Request::deliver(std::launch launch, const Subscriptio std::move(subscriptionObject)); } -internal::Awaitable Request::deliver(std::launch launch, const SubscriptionName& name, +AwaitableDeliver Request::deliver(std::launch launch, const SubscriptionName& name, const SubscriptionFilterCallback& applyArguments, const SubscriptionFilterCallback& applyDirectives, std::shared_ptr subscriptionObject) const From 8c6c91876f0ba85961047f2043279d647f073299 Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Mon, 29 Nov 2021 18:36:22 -0800 Subject: [PATCH 025/119] WIP prototype using type erasure --- .../introspection/Introspection.h | 145 +-- .../introspection/IntrospectionSchema.h | 434 +++++++-- samples/learn/DroidObject.cpp | 17 +- samples/learn/DroidObject.h | 64 +- samples/learn/HumanObject.cpp | 17 +- samples/learn/HumanObject.h | 64 +- samples/learn/MutationObject.cpp | 9 +- samples/learn/MutationObject.h | 42 +- samples/learn/QueryObject.cpp | 17 +- samples/learn/QueryObject.h | 56 +- samples/learn/ReviewObject.cpp | 11 +- samples/learn/ReviewObject.h | 49 +- samples/learn/StarWarsSchema.h | 6 + .../separate/AppointmentConnectionObject.cpp | 15 +- .../separate/AppointmentConnectionObject.h | 49 +- samples/separate/AppointmentEdgeObject.cpp | 15 +- samples/separate/AppointmentEdgeObject.h | 49 +- samples/separate/AppointmentObject.cpp | 36 +- samples/separate/AppointmentObject.h | 71 +- .../separate/CompleteTaskPayloadObject.cpp | 15 +- samples/separate/CompleteTaskPayloadObject.h | 49 +- samples/separate/ExpensiveObject.cpp | 8 +- samples/separate/ExpensiveObject.h | 42 +- samples/separate/FolderConnectionObject.cpp | 15 +- samples/separate/FolderConnectionObject.h | 49 +- samples/separate/FolderEdgeObject.cpp | 15 +- samples/separate/FolderEdgeObject.h | 49 +- samples/separate/FolderObject.cpp | 22 +- samples/separate/FolderObject.h | 57 +- samples/separate/MutationObject.cpp | 15 +- samples/separate/MutationObject.h | 49 +- samples/separate/NestedTypeObject.cpp | 15 +- samples/separate/NestedTypeObject.h | 49 +- samples/separate/PageInfoObject.cpp | 15 +- samples/separate/PageInfoObject.h | 49 +- samples/separate/QueryObject.cpp | 89 +- samples/separate/QueryObject.h | 119 ++- samples/separate/SubscriptionObject.cpp | 15 +- samples/separate/SubscriptionObject.h | 49 +- samples/separate/TaskConnectionObject.cpp | 15 +- samples/separate/TaskConnectionObject.h | 49 +- samples/separate/TaskEdgeObject.cpp | 15 +- samples/separate/TaskEdgeObject.h | 49 +- samples/separate/TaskObject.cpp | 22 +- samples/separate/TaskObject.h | 57 +- samples/separate/TodaySchema.h | 6 + .../AppointmentConnectionObject.cpp | 15 +- .../AppointmentConnectionObject.h | 49 +- .../AppointmentEdgeObject.cpp | 15 +- .../AppointmentEdgeObject.h | 49 +- .../AppointmentObject.cpp | 36 +- .../AppointmentObject.h | 71 +- .../CompleteTaskPayloadObject.cpp | 15 +- .../CompleteTaskPayloadObject.h | 49 +- .../ExpensiveObject.cpp | 8 +- .../ExpensiveObject.h | 42 +- .../FolderConnectionObject.cpp | 15 +- .../FolderConnectionObject.h | 49 +- .../FolderEdgeObject.cpp | 15 +- .../FolderEdgeObject.h | 49 +- .../separate_nointrospection/FolderObject.cpp | 22 +- .../separate_nointrospection/FolderObject.h | 57 +- .../MutationObject.cpp | 15 +- .../separate_nointrospection/MutationObject.h | 49 +- .../NestedTypeObject.cpp | 15 +- .../NestedTypeObject.h | 49 +- .../PageInfoObject.cpp | 15 +- .../separate_nointrospection/PageInfoObject.h | 49 +- .../separate_nointrospection/QueryObject.cpp | 85 +- .../separate_nointrospection/QueryObject.h | 119 ++- .../SubscriptionObject.cpp | 15 +- .../SubscriptionObject.h | 49 +- .../TaskConnectionObject.cpp | 15 +- .../TaskConnectionObject.h | 49 +- .../TaskEdgeObject.cpp | 15 +- .../separate_nointrospection/TaskEdgeObject.h | 49 +- .../separate_nointrospection/TaskObject.cpp | 22 +- samples/separate_nointrospection/TaskObject.h | 57 +- .../separate_nointrospection/TodaySchema.h | 6 + samples/star_wars/DroidData.cpp | 15 +- samples/star_wars/DroidData.h | 12 +- samples/star_wars/HumanData.cpp | 15 +- samples/star_wars/HumanData.h | 15 +- samples/star_wars/MutationData.cpp | 4 +- samples/star_wars/MutationData.h | 6 +- samples/star_wars/QueryData.cpp | 21 +- samples/star_wars/QueryData.h | 8 +- samples/star_wars/ReviewData.h | 6 +- samples/today/TodayMock.cpp | 38 +- samples/today/TodayMock.h | 161 ++-- samples/unified/TodaySchema.cpp | 342 ++----- samples/unified/TodaySchema.h | 891 +++++++++++++++--- .../unified_nointrospection/TodaySchema.cpp | 338 ++----- samples/unified_nointrospection/TodaySchema.h | 891 +++++++++++++++--- samples/validation/ValidationMock.h | 6 +- samples/validation/ValidationSchema.cpp | 259 ++--- samples/validation/ValidationSchema.h | 605 ++++++++++-- src/Introspection.cpp | 34 +- src/IntrospectionSchema.cpp | 106 ++- src/SchemaGenerator.cpp | 254 +++-- 100 files changed, 5200 insertions(+), 2220 deletions(-) diff --git a/include/graphqlservice/introspection/Introspection.h b/include/graphqlservice/introspection/Introspection.h index bc7e038c..dbce12cc 100644 --- a/include/graphqlservice/introspection/Introspection.h +++ b/include/graphqlservice/introspection/Introspection.h @@ -19,131 +19,144 @@ class Field; class InputValue; class EnumValue; -class Schema : public object::Schema +class Schema { public: GRAPHQLINTROSPECTION_EXPORT explicit Schema(const std::shared_ptr& schema); // Accessors - service::FieldResult>> getTypes( - service::FieldParams&& params) const final; - service::FieldResult> getQueryType( - service::FieldParams&& params) const final; - service::FieldResult> getMutationType( - service::FieldParams&& params) const final; - service::FieldResult> getSubscriptionType( - service::FieldParams&& params) const final; - service::FieldResult>> getDirectives( - service::FieldParams&& params) const final; + GRAPHQLINTROSPECTION_EXPORT service::FieldResult>> + getTypes(service::FieldParams&& params) const; + GRAPHQLINTROSPECTION_EXPORT service::FieldResult> getQueryType( + service::FieldParams&& params) const; + GRAPHQLINTROSPECTION_EXPORT service::FieldResult> getMutationType( + service::FieldParams&& params) const; + GRAPHQLINTROSPECTION_EXPORT service::FieldResult> + getSubscriptionType(service::FieldParams&& params) const; + GRAPHQLINTROSPECTION_EXPORT service::FieldResult< + std::vector>> + getDirectives(service::FieldParams&& params) const; private: const std::shared_ptr _schema; }; -class Type : public object::Type +class Type { public: GRAPHQLINTROSPECTION_EXPORT explicit Type(const std::shared_ptr& type); // Accessors - service::FieldResult getKind(service::FieldParams&&) const final; - service::FieldResult> getName( - service::FieldParams&& params) const final; - service::FieldResult> getDescription( - service::FieldParams&& params) const final; - service::FieldResult>>> getFields( - service::FieldParams&& params, - std::optional&& includeDeprecatedArg) const final; - service::FieldResult>>> getInterfaces( - service::FieldParams&& params) const final; - service::FieldResult>>> - getPossibleTypes(service::FieldParams&& params) const final; - service::FieldResult>>> + GRAPHQLINTROSPECTION_EXPORT service::FieldResult getKind( + service::FieldParams&&) const; + GRAPHQLINTROSPECTION_EXPORT service::FieldResult> getName( + service::FieldParams&& params) const; + GRAPHQLINTROSPECTION_EXPORT service::FieldResult> + getDescription(service::FieldParams&& params) const; + GRAPHQLINTROSPECTION_EXPORT service::FieldResult< + std::optional>>> + getFields(service::FieldParams&& params, + std::optional&& includeDeprecatedArg) const; + GRAPHQLINTROSPECTION_EXPORT service::FieldResult< + std::optional>>> + getInterfaces(service::FieldParams&& params) const; + GRAPHQLINTROSPECTION_EXPORT service::FieldResult< + std::optional>>> + getPossibleTypes(service::FieldParams&& params) const; + GRAPHQLINTROSPECTION_EXPORT service::FieldResult< + std::optional>>> getEnumValues(service::FieldParams&& params, - std::optional&& includeDeprecatedArg) const final; - service::FieldResult>>> - getInputFields(service::FieldParams&& params) const final; - service::FieldResult> getOfType( - service::FieldParams&& params) const final; + std::optional&& includeDeprecatedArg) const; + GRAPHQLINTROSPECTION_EXPORT service::FieldResult< + std::optional>>> + getInputFields(service::FieldParams&& params) const; + GRAPHQLINTROSPECTION_EXPORT service::FieldResult> getOfType( + service::FieldParams&& params) const; private: const std::shared_ptr _type; }; -class Field : public object::Field +class Field { public: GRAPHQLINTROSPECTION_EXPORT explicit Field(const std::shared_ptr& field); // Accessors - service::FieldResult getName(service::FieldParams&& params) const final; - service::FieldResult> getDescription( - service::FieldParams&& params) const final; - service::FieldResult>> getArgs( - service::FieldParams&& params) const final; - service::FieldResult> getType( - service::FieldParams&& params) const final; - service::FieldResult getIsDeprecated( - service::FieldParams&& params) const final; - service::FieldResult> getDeprecationReason( - service::FieldParams&& params) const final; + GRAPHQLINTROSPECTION_EXPORT service::FieldResult getName( + service::FieldParams&& params) const; + GRAPHQLINTROSPECTION_EXPORT service::FieldResult> + getDescription(service::FieldParams&& params) const; + GRAPHQLINTROSPECTION_EXPORT service::FieldResult< + std::vector>> + getArgs(service::FieldParams&& params) const; + GRAPHQLINTROSPECTION_EXPORT service::FieldResult> getType( + service::FieldParams&& params) const; + GRAPHQLINTROSPECTION_EXPORT service::FieldResult getIsDeprecated( + service::FieldParams&& params) const; + GRAPHQLINTROSPECTION_EXPORT service::FieldResult> + getDeprecationReason(service::FieldParams&& params) const; private: const std::shared_ptr _field; }; -class InputValue : public object::InputValue +class InputValue { public: GRAPHQLINTROSPECTION_EXPORT explicit InputValue( const std::shared_ptr& inputValue); // Accessors - service::FieldResult getName(service::FieldParams&& params) const final; - service::FieldResult> getDescription( - service::FieldParams&& params) const final; - service::FieldResult> getType( - service::FieldParams&& params) const final; - service::FieldResult> getDefaultValue( - service::FieldParams&& params) const final; + GRAPHQLINTROSPECTION_EXPORT service::FieldResult getName( + service::FieldParams&& params) const; + GRAPHQLINTROSPECTION_EXPORT service::FieldResult> + getDescription(service::FieldParams&& params) const; + GRAPHQLINTROSPECTION_EXPORT service::FieldResult> getType( + service::FieldParams&& params) const; + GRAPHQLINTROSPECTION_EXPORT service::FieldResult> + getDefaultValue(service::FieldParams&& params) const; private: const std::shared_ptr _inputValue; }; -class EnumValue : public object::EnumValue +class EnumValue { public: GRAPHQLINTROSPECTION_EXPORT explicit EnumValue( const std::shared_ptr& enumValue); // Accessors - service::FieldResult getName(service::FieldParams&& params) const final; - service::FieldResult> getDescription( - service::FieldParams&& params) const final; - service::FieldResult getIsDeprecated( - service::FieldParams&& params) const final; - service::FieldResult> getDeprecationReason( - service::FieldParams&& params) const final; + GRAPHQLINTROSPECTION_EXPORT service::FieldResult getName( + service::FieldParams&& params) const; + GRAPHQLINTROSPECTION_EXPORT service::FieldResult> + getDescription(service::FieldParams&& params) const; + GRAPHQLINTROSPECTION_EXPORT service::FieldResult getIsDeprecated( + service::FieldParams&& params) const; + GRAPHQLINTROSPECTION_EXPORT service::FieldResult> + getDeprecationReason(service::FieldParams&& params) const; private: const std::shared_ptr _enumValue; }; -class Directive : public object::Directive +class Directive { public: GRAPHQLINTROSPECTION_EXPORT explicit Directive( const std::shared_ptr& directive); // Accessors - service::FieldResult getName(service::FieldParams&& params) const final; - service::FieldResult> getDescription( - service::FieldParams&& params) const final; - service::FieldResult> getLocations( - service::FieldParams&& params) const final; - service::FieldResult>> getArgs( - service::FieldParams&& params) const final; + GRAPHQLINTROSPECTION_EXPORT service::FieldResult getName( + service::FieldParams&& params) const; + GRAPHQLINTROSPECTION_EXPORT service::FieldResult> + getDescription(service::FieldParams&& params) const; + GRAPHQLINTROSPECTION_EXPORT service::FieldResult> getLocations( + service::FieldParams&& params) const; + GRAPHQLINTROSPECTION_EXPORT service::FieldResult< + std::vector>> + getArgs(service::FieldParams&& params) const; private: const std::shared_ptr _directive; diff --git a/include/graphqlservice/introspection/IntrospectionSchema.h b/include/graphqlservice/introspection/IntrospectionSchema.h index 594a4ca4..0eff508a 100644 --- a/include/graphqlservice/introspection/IntrospectionSchema.h +++ b/include/graphqlservice/introspection/IntrospectionSchema.h @@ -79,16 +79,6 @@ class Directive; class Schema : public service::Object { -protected: - explicit Schema(); - -public: - virtual service::FieldResult>> getTypes(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getQueryType(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getMutationType(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getSubscriptionType(service::FieldParams&& params) const = 0; - virtual service::FieldResult>> getDirectives(service::FieldParams&& params) const = 0; - private: service::AwaitableResolver resolveTypes(service::ResolverParams&& params); service::AwaitableResolver resolveQueryType(service::ResolverParams&& params); @@ -97,25 +87,71 @@ class Schema service::AwaitableResolver resolveDirectives(service::ResolverParams&& params); service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + + struct Concept + { + virtual service::FieldResult>> getTypes(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getQueryType(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getMutationType(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getSubscriptionType(service::FieldParams&& params) const = 0; + virtual service::FieldResult>> getDirectives(service::FieldParams&& params) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::FieldResult>> getTypes(service::FieldParams&& params) const final + { + return _pimpl->getTypes(std::move(params)); + } + + service::FieldResult> getQueryType(service::FieldParams&& params) const final + { + return _pimpl->getQueryType(std::move(params)); + } + + service::FieldResult> getMutationType(service::FieldParams&& params) const final + { + return _pimpl->getMutationType(std::move(params)); + } + + service::FieldResult> getSubscriptionType(service::FieldParams&& params) const final + { + return _pimpl->getSubscriptionType(std::move(params)); + } + + service::FieldResult>> getDirectives(service::FieldParams&& params) const final + { + return _pimpl->getDirectives(std::move(params)); + } + + private: + const std::shared_ptr _pimpl; + }; + + GRAPHQLINTROSPECTION_EXPORT Schema(std::unique_ptr&& pimpl); + + const std::unique_ptr _pimpl; + +public: + template + Schema(std::shared_ptr pimpl) + : Schema { std::make_unique>(std::move(pimpl)) } + { + } + + GRAPHQLINTROSPECTION_EXPORT ~Schema(); }; class Type : public service::Object { -protected: - explicit Type(); - -public: - virtual service::FieldResult getKind(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getName(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getDescription(service::FieldParams&& params) const = 0; - virtual service::FieldResult>>> getFields(service::FieldParams&& params, std::optional&& includeDeprecatedArg) const = 0; - virtual service::FieldResult>>> getInterfaces(service::FieldParams&& params) const = 0; - virtual service::FieldResult>>> getPossibleTypes(service::FieldParams&& params) const = 0; - virtual service::FieldResult>>> getEnumValues(service::FieldParams&& params, std::optional&& includeDeprecatedArg) const = 0; - virtual service::FieldResult>>> getInputFields(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getOfType(service::FieldParams&& params) const = 0; - private: service::AwaitableResolver resolveKind(service::ResolverParams&& params); service::AwaitableResolver resolveName(service::ResolverParams&& params); @@ -128,22 +164,95 @@ class Type service::AwaitableResolver resolveOfType(service::ResolverParams&& params); service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + + struct Concept + { + virtual service::FieldResult getKind(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getName(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getDescription(service::FieldParams&& params) const = 0; + virtual service::FieldResult>>> getFields(service::FieldParams&& params, std::optional&& includeDeprecatedArg) const = 0; + virtual service::FieldResult>>> getInterfaces(service::FieldParams&& params) const = 0; + virtual service::FieldResult>>> getPossibleTypes(service::FieldParams&& params) const = 0; + virtual service::FieldResult>>> getEnumValues(service::FieldParams&& params, std::optional&& includeDeprecatedArg) const = 0; + virtual service::FieldResult>>> getInputFields(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getOfType(service::FieldParams&& params) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::FieldResult getKind(service::FieldParams&& params) const final + { + return _pimpl->getKind(std::move(params)); + } + + service::FieldResult> getName(service::FieldParams&& params) const final + { + return _pimpl->getName(std::move(params)); + } + + service::FieldResult> getDescription(service::FieldParams&& params) const final + { + return _pimpl->getDescription(std::move(params)); + } + + service::FieldResult>>> getFields(service::FieldParams&& params, std::optional&& includeDeprecatedArg) const final + { + return _pimpl->getFields(std::move(params), std::move(includeDeprecatedArg)); + } + + service::FieldResult>>> getInterfaces(service::FieldParams&& params) const final + { + return _pimpl->getInterfaces(std::move(params)); + } + + service::FieldResult>>> getPossibleTypes(service::FieldParams&& params) const final + { + return _pimpl->getPossibleTypes(std::move(params)); + } + + service::FieldResult>>> getEnumValues(service::FieldParams&& params, std::optional&& includeDeprecatedArg) const final + { + return _pimpl->getEnumValues(std::move(params), std::move(includeDeprecatedArg)); + } + + service::FieldResult>>> getInputFields(service::FieldParams&& params) const final + { + return _pimpl->getInputFields(std::move(params)); + } + + service::FieldResult> getOfType(service::FieldParams&& params) const final + { + return _pimpl->getOfType(std::move(params)); + } + + private: + const std::shared_ptr _pimpl; + }; + + GRAPHQLINTROSPECTION_EXPORT Type(std::unique_ptr&& pimpl); + + const std::unique_ptr _pimpl; + +public: + template + Type(std::shared_ptr pimpl) + : Type { std::make_unique>(std::move(pimpl)) } + { + } + + GRAPHQLINTROSPECTION_EXPORT ~Type(); }; class Field : public service::Object { -protected: - explicit Field(); - -public: - virtual service::FieldResult getName(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getDescription(service::FieldParams&& params) const = 0; - virtual service::FieldResult>> getArgs(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getType(service::FieldParams&& params) const = 0; - virtual service::FieldResult getIsDeprecated(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getDeprecationReason(service::FieldParams&& params) const = 0; - private: service::AwaitableResolver resolveName(service::ResolverParams&& params); service::AwaitableResolver resolveDescription(service::ResolverParams&& params); @@ -153,20 +262,77 @@ class Field service::AwaitableResolver resolveDeprecationReason(service::ResolverParams&& params); service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + + struct Concept + { + virtual service::FieldResult getName(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getDescription(service::FieldParams&& params) const = 0; + virtual service::FieldResult>> getArgs(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getType(service::FieldParams&& params) const = 0; + virtual service::FieldResult getIsDeprecated(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getDeprecationReason(service::FieldParams&& params) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::FieldResult getName(service::FieldParams&& params) const final + { + return _pimpl->getName(std::move(params)); + } + + service::FieldResult> getDescription(service::FieldParams&& params) const final + { + return _pimpl->getDescription(std::move(params)); + } + + service::FieldResult>> getArgs(service::FieldParams&& params) const final + { + return _pimpl->getArgs(std::move(params)); + } + + service::FieldResult> getType(service::FieldParams&& params) const final + { + return _pimpl->getType(std::move(params)); + } + + service::FieldResult getIsDeprecated(service::FieldParams&& params) const final + { + return _pimpl->getIsDeprecated(std::move(params)); + } + + service::FieldResult> getDeprecationReason(service::FieldParams&& params) const final + { + return _pimpl->getDeprecationReason(std::move(params)); + } + + private: + const std::shared_ptr _pimpl; + }; + + GRAPHQLINTROSPECTION_EXPORT Field(std::unique_ptr&& pimpl); + + const std::unique_ptr _pimpl; + +public: + template + Field(std::shared_ptr pimpl) + : Field { std::make_unique>(std::move(pimpl)) } + { + } + + GRAPHQLINTROSPECTION_EXPORT ~Field(); }; class InputValue : public service::Object { -protected: - explicit InputValue(); - -public: - virtual service::FieldResult getName(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getDescription(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getType(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getDefaultValue(service::FieldParams&& params) const = 0; - private: service::AwaitableResolver resolveName(service::ResolverParams&& params); service::AwaitableResolver resolveDescription(service::ResolverParams&& params); @@ -174,20 +340,65 @@ class InputValue service::AwaitableResolver resolveDefaultValue(service::ResolverParams&& params); service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + + struct Concept + { + virtual service::FieldResult getName(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getDescription(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getType(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getDefaultValue(service::FieldParams&& params) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::FieldResult getName(service::FieldParams&& params) const final + { + return _pimpl->getName(std::move(params)); + } + + service::FieldResult> getDescription(service::FieldParams&& params) const final + { + return _pimpl->getDescription(std::move(params)); + } + + service::FieldResult> getType(service::FieldParams&& params) const final + { + return _pimpl->getType(std::move(params)); + } + + service::FieldResult> getDefaultValue(service::FieldParams&& params) const final + { + return _pimpl->getDefaultValue(std::move(params)); + } + + private: + const std::shared_ptr _pimpl; + }; + + GRAPHQLINTROSPECTION_EXPORT InputValue(std::unique_ptr&& pimpl); + + const std::unique_ptr _pimpl; + +public: + template + InputValue(std::shared_ptr pimpl) + : InputValue { std::make_unique>(std::move(pimpl)) } + { + } + + GRAPHQLINTROSPECTION_EXPORT ~InputValue(); }; class EnumValue : public service::Object { -protected: - explicit EnumValue(); - -public: - virtual service::FieldResult getName(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getDescription(service::FieldParams&& params) const = 0; - virtual service::FieldResult getIsDeprecated(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getDeprecationReason(service::FieldParams&& params) const = 0; - private: service::AwaitableResolver resolveName(service::ResolverParams&& params); service::AwaitableResolver resolveDescription(service::ResolverParams&& params); @@ -195,20 +406,65 @@ class EnumValue service::AwaitableResolver resolveDeprecationReason(service::ResolverParams&& params); service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + + struct Concept + { + virtual service::FieldResult getName(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getDescription(service::FieldParams&& params) const = 0; + virtual service::FieldResult getIsDeprecated(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getDeprecationReason(service::FieldParams&& params) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::FieldResult getName(service::FieldParams&& params) const final + { + return _pimpl->getName(std::move(params)); + } + + service::FieldResult> getDescription(service::FieldParams&& params) const final + { + return _pimpl->getDescription(std::move(params)); + } + + service::FieldResult getIsDeprecated(service::FieldParams&& params) const final + { + return _pimpl->getIsDeprecated(std::move(params)); + } + + service::FieldResult> getDeprecationReason(service::FieldParams&& params) const final + { + return _pimpl->getDeprecationReason(std::move(params)); + } + + private: + const std::shared_ptr _pimpl; + }; + + GRAPHQLINTROSPECTION_EXPORT EnumValue(std::unique_ptr&& pimpl); + + const std::unique_ptr _pimpl; + +public: + template + EnumValue(std::shared_ptr pimpl) + : EnumValue { std::make_unique>(std::move(pimpl)) } + { + } + + GRAPHQLINTROSPECTION_EXPORT ~EnumValue(); }; class Directive : public service::Object { -protected: - explicit Directive(); - -public: - virtual service::FieldResult getName(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getDescription(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getLocations(service::FieldParams&& params) const = 0; - virtual service::FieldResult>> getArgs(service::FieldParams&& params) const = 0; - private: service::AwaitableResolver resolveName(service::ResolverParams&& params); service::AwaitableResolver resolveDescription(service::ResolverParams&& params); @@ -216,6 +472,60 @@ class Directive service::AwaitableResolver resolveArgs(service::ResolverParams&& params); service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + + struct Concept + { + virtual service::FieldResult getName(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getDescription(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getLocations(service::FieldParams&& params) const = 0; + virtual service::FieldResult>> getArgs(service::FieldParams&& params) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::FieldResult getName(service::FieldParams&& params) const final + { + return _pimpl->getName(std::move(params)); + } + + service::FieldResult> getDescription(service::FieldParams&& params) const final + { + return _pimpl->getDescription(std::move(params)); + } + + service::FieldResult> getLocations(service::FieldParams&& params) const final + { + return _pimpl->getLocations(std::move(params)); + } + + service::FieldResult>> getArgs(service::FieldParams&& params) const final + { + return _pimpl->getArgs(std::move(params)); + } + + private: + const std::shared_ptr _pimpl; + }; + + GRAPHQLINTROSPECTION_EXPORT Directive(std::unique_ptr&& pimpl); + + const std::unique_ptr _pimpl; + +public: + template + Directive(std::shared_ptr pimpl) + : Directive { std::make_unique>(std::move(pimpl)) } + { + } + + GRAPHQLINTROSPECTION_EXPORT ~Directive(); }; } // namespace object diff --git a/samples/learn/DroidObject.cpp b/samples/learn/DroidObject.cpp index 60e2ecfe..00e8d876 100644 --- a/samples/learn/DroidObject.cpp +++ b/samples/learn/DroidObject.cpp @@ -18,7 +18,7 @@ using namespace std::literals; namespace graphql::learn { namespace object { -Droid::Droid() +Droid::Droid(std::unique_ptr&& pimpl) : service::Object({ "Character", "Droid" @@ -30,6 +30,11 @@ Droid::Droid() { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, { R"gql(primaryFunction)gql"sv, [this](service::ResolverParams&& params) { return resolvePrimaryFunction(std::move(params)); } } }) + , _pimpl(std::move(pimpl)) +{ +} + +Droid::~Droid() { } @@ -37,7 +42,7 @@ service::AwaitableResolver Droid::resolveId(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getId(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getId(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); @@ -47,7 +52,7 @@ service::AwaitableResolver Droid::resolveName(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getName(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getName(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); @@ -57,7 +62,7 @@ service::AwaitableResolver Droid::resolveFriends(service::ResolverParams&& param { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getFriends(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getFriends(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); @@ -67,7 +72,7 @@ service::AwaitableResolver Droid::resolveAppearsIn(service::ResolverParams&& par { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getAppearsIn(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getAppearsIn(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); @@ -77,7 +82,7 @@ service::AwaitableResolver Droid::resolvePrimaryFunction(service::ResolverParams { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getPrimaryFunction(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getPrimaryFunction(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); diff --git a/samples/learn/DroidObject.h b/samples/learn/DroidObject.h index 1ea6819f..392ef450 100644 --- a/samples/learn/DroidObject.h +++ b/samples/learn/DroidObject.h @@ -14,14 +14,7 @@ namespace graphql::learn::object { class Droid : public service::Object - , public Character { -protected: - explicit Droid(); - -public: - virtual service::FieldResult> getPrimaryFunction(service::FieldParams&& params) const = 0; - private: service::AwaitableResolver resolveId(service::ResolverParams&& params); service::AwaitableResolver resolveName(service::ResolverParams&& params); @@ -30,6 +23,63 @@ class Droid service::AwaitableResolver resolvePrimaryFunction(service::ResolverParams&& params); service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + + struct Concept + : Character + { + virtual service::FieldResult> getPrimaryFunction(service::FieldParams&& params) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::FieldResult getId(service::FieldParams&& params) const final + { + return _pimpl->getId(std::move(params)); + } + + service::FieldResult> getName(service::FieldParams&& params) const final + { + return _pimpl->getName(std::move(params)); + } + + service::FieldResult>>> getFriends(service::FieldParams&& params) const final + { + return _pimpl->getFriends(std::move(params)); + } + + service::FieldResult>>> getAppearsIn(service::FieldParams&& params) const final + { + return _pimpl->getAppearsIn(std::move(params)); + } + + service::FieldResult> getPrimaryFunction(service::FieldParams&& params) const final + { + return _pimpl->getPrimaryFunction(std::move(params)); + } + + private: + const std::shared_ptr _pimpl; + }; + + Droid(std::unique_ptr&& pimpl); + + const std::unique_ptr _pimpl; + +public: + template + Droid(std::shared_ptr pimpl) + : Droid { std::make_unique>(std::move(pimpl)) } + { + } + + ~Droid(); }; } // namespace graphql::learn::object diff --git a/samples/learn/HumanObject.cpp b/samples/learn/HumanObject.cpp index 2dd578c3..3e51200e 100644 --- a/samples/learn/HumanObject.cpp +++ b/samples/learn/HumanObject.cpp @@ -18,7 +18,7 @@ using namespace std::literals; namespace graphql::learn { namespace object { -Human::Human() +Human::Human(std::unique_ptr&& pimpl) : service::Object({ "Character", "Human" @@ -30,6 +30,11 @@ Human::Human() { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, { R"gql(homePlanet)gql"sv, [this](service::ResolverParams&& params) { return resolveHomePlanet(std::move(params)); } } }) + , _pimpl(std::move(pimpl)) +{ +} + +Human::~Human() { } @@ -37,7 +42,7 @@ service::AwaitableResolver Human::resolveId(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getId(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getId(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); @@ -47,7 +52,7 @@ service::AwaitableResolver Human::resolveName(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getName(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getName(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); @@ -57,7 +62,7 @@ service::AwaitableResolver Human::resolveFriends(service::ResolverParams&& param { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getFriends(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getFriends(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); @@ -67,7 +72,7 @@ service::AwaitableResolver Human::resolveAppearsIn(service::ResolverParams&& par { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getAppearsIn(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getAppearsIn(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); @@ -77,7 +82,7 @@ service::AwaitableResolver Human::resolveHomePlanet(service::ResolverParams&& pa { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getHomePlanet(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getHomePlanet(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); diff --git a/samples/learn/HumanObject.h b/samples/learn/HumanObject.h index 3d2d068a..06010271 100644 --- a/samples/learn/HumanObject.h +++ b/samples/learn/HumanObject.h @@ -14,14 +14,7 @@ namespace graphql::learn::object { class Human : public service::Object - , public Character { -protected: - explicit Human(); - -public: - virtual service::FieldResult> getHomePlanet(service::FieldParams&& params) const = 0; - private: service::AwaitableResolver resolveId(service::ResolverParams&& params); service::AwaitableResolver resolveName(service::ResolverParams&& params); @@ -30,6 +23,63 @@ class Human service::AwaitableResolver resolveHomePlanet(service::ResolverParams&& params); service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + + struct Concept + : Character + { + virtual service::FieldResult> getHomePlanet(service::FieldParams&& params) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::FieldResult getId(service::FieldParams&& params) const final + { + return _pimpl->getId(std::move(params)); + } + + service::FieldResult> getName(service::FieldParams&& params) const final + { + return _pimpl->getName(std::move(params)); + } + + service::FieldResult>>> getFriends(service::FieldParams&& params) const final + { + return _pimpl->getFriends(std::move(params)); + } + + service::FieldResult>>> getAppearsIn(service::FieldParams&& params) const final + { + return _pimpl->getAppearsIn(std::move(params)); + } + + service::FieldResult> getHomePlanet(service::FieldParams&& params) const final + { + return _pimpl->getHomePlanet(std::move(params)); + } + + private: + const std::shared_ptr _pimpl; + }; + + Human(std::unique_ptr&& pimpl); + + const std::unique_ptr _pimpl; + +public: + template + Human(std::shared_ptr pimpl) + : Human { std::make_unique>(std::move(pimpl)) } + { + } + + ~Human(); }; } // namespace graphql::learn::object diff --git a/samples/learn/MutationObject.cpp b/samples/learn/MutationObject.cpp index a6245e0e..b04ae476 100644 --- a/samples/learn/MutationObject.cpp +++ b/samples/learn/MutationObject.cpp @@ -18,13 +18,18 @@ using namespace std::literals; namespace graphql::learn { namespace object { -Mutation::Mutation() +Mutation::Mutation(std::unique_ptr&& pimpl) : service::Object({ "Mutation" }, { { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, { R"gql(createReview)gql"sv, [this](service::ResolverParams&& params) { return resolveCreateReview(std::move(params)); } } }) + , _pimpl(std::move(pimpl)) +{ +} + +Mutation::~Mutation() { } @@ -34,7 +39,7 @@ service::AwaitableResolver Mutation::resolveCreateReview(service::ResolverParams auto argReview = service::ModifiedArgument::require("review", params.arguments); std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = applyCreateReview(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argEp), std::move(argReview)); + auto result = _pimpl->applyCreateReview(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argEp), std::move(argReview)); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); diff --git a/samples/learn/MutationObject.h b/samples/learn/MutationObject.h index 65862e31..25fdde16 100644 --- a/samples/learn/MutationObject.h +++ b/samples/learn/MutationObject.h @@ -15,16 +15,46 @@ namespace graphql::learn::object { class Mutation : public service::Object { -protected: - explicit Mutation(); - -public: - virtual service::FieldResult> applyCreateReview(service::FieldParams&& params, Episode&& epArg, ReviewInput&& reviewArg) const = 0; - private: service::AwaitableResolver resolveCreateReview(service::ResolverParams&& params); service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + + struct Concept + { + virtual service::FieldResult> applyCreateReview(service::FieldParams&& params, Episode&& epArg, ReviewInput&& reviewArg) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::FieldResult> applyCreateReview(service::FieldParams&& params, Episode&& epArg, ReviewInput&& reviewArg) const final + { + return _pimpl->applyCreateReview(std::move(params), std::move(epArg), std::move(reviewArg)); + } + + private: + const std::shared_ptr _pimpl; + }; + + Mutation(std::unique_ptr&& pimpl); + + const std::unique_ptr _pimpl; + +public: + template + Mutation(std::shared_ptr pimpl) + : Mutation { std::make_unique>(std::move(pimpl)) } + { + } + + ~Mutation(); }; } // namespace graphql::learn::object diff --git a/samples/learn/QueryObject.cpp b/samples/learn/QueryObject.cpp index 375546c0..7ccc6a49 100644 --- a/samples/learn/QueryObject.cpp +++ b/samples/learn/QueryObject.cpp @@ -18,7 +18,7 @@ using namespace std::literals; namespace graphql::learn { namespace object { -Query::Query() +Query::Query(std::unique_ptr&& pimpl) : service::Object({ "Query" }, { @@ -30,6 +30,11 @@ Query::Query() { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } } }) , _schema(GetSchema()) + , _pimpl(std::move(pimpl)) +{ +} + +Query::~Query() { } @@ -38,7 +43,7 @@ service::AwaitableResolver Query::resolveHero(service::ResolverParams&& params) auto argEpisode = service::ModifiedArgument::require("episode", params.arguments); std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getHero(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argEpisode)); + auto result = _pimpl->getHero(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argEpisode)); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); @@ -49,7 +54,7 @@ service::AwaitableResolver Query::resolveHuman(service::ResolverParams&& params) auto argId = service::ModifiedArgument::require("id", params.arguments); std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getHuman(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argId)); + auto result = _pimpl->getHuman(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argId)); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); @@ -60,7 +65,7 @@ service::AwaitableResolver Query::resolveDroid(service::ResolverParams&& params) auto argId = service::ModifiedArgument::require("id", params.arguments); std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getDroid(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argId)); + auto result = _pimpl->getDroid(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argId)); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); @@ -73,14 +78,14 @@ service::AwaitableResolver Query::resolve_typename(service::ResolverParams&& par service::AwaitableResolver Query::resolve_schema(service::ResolverParams&& params) { - return service::ModifiedResult::convert(std::static_pointer_cast(std::make_shared(_schema)), std::move(params)); + return service::ModifiedResult::convert(std::static_pointer_cast(std::make_shared(std::make_shared(_schema))), std::move(params)); } service::AwaitableResolver Query::resolve_type(service::ResolverParams&& params) { auto argName = service::ModifiedArgument::require("name", params.arguments); const auto& baseType = _schema->LookupType(argName); - std::shared_ptr result { baseType ? std::make_shared(baseType) : nullptr }; + std::shared_ptr result { baseType ? std::make_shared(std::make_shared(baseType)) : nullptr }; return service::ModifiedResult::convert(result, std::move(params)); } diff --git a/samples/learn/QueryObject.h b/samples/learn/QueryObject.h index 6153e39e..bf69a0a0 100644 --- a/samples/learn/QueryObject.h +++ b/samples/learn/QueryObject.h @@ -15,14 +15,6 @@ namespace graphql::learn::object { class Query : public service::Object { -protected: - explicit Query(); - -public: - virtual service::FieldResult> getHero(service::FieldParams&& params, std::optional&& episodeArg) const = 0; - virtual service::FieldResult> getHuman(service::FieldParams&& params, response::StringType&& idArg) const = 0; - virtual service::FieldResult> getDroid(service::FieldParams&& params, response::StringType&& idArg) const = 0; - private: service::AwaitableResolver resolveHero(service::ResolverParams&& params); service::AwaitableResolver resolveHuman(service::ResolverParams&& params); @@ -33,6 +25,54 @@ class Query service::AwaitableResolver resolve_type(service::ResolverParams&& params); std::shared_ptr _schema; + + struct Concept + { + virtual service::FieldResult> getHero(service::FieldParams&& params, std::optional&& episodeArg) const = 0; + virtual service::FieldResult> getHuman(service::FieldParams&& params, response::StringType&& idArg) const = 0; + virtual service::FieldResult> getDroid(service::FieldParams&& params, response::StringType&& idArg) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::FieldResult> getHero(service::FieldParams&& params, std::optional&& episodeArg) const final + { + return _pimpl->getHero(std::move(params), std::move(episodeArg)); + } + + service::FieldResult> getHuman(service::FieldParams&& params, response::StringType&& idArg) const final + { + return _pimpl->getHuman(std::move(params), std::move(idArg)); + } + + service::FieldResult> getDroid(service::FieldParams&& params, response::StringType&& idArg) const final + { + return _pimpl->getDroid(std::move(params), std::move(idArg)); + } + + private: + const std::shared_ptr _pimpl; + }; + + Query(std::unique_ptr&& pimpl); + + const std::unique_ptr _pimpl; + +public: + template + Query(std::shared_ptr pimpl) + : Query { std::make_unique>(std::move(pimpl)) } + { + } + + ~Query(); }; } // namespace graphql::learn::object diff --git a/samples/learn/ReviewObject.cpp b/samples/learn/ReviewObject.cpp index 6db131d2..0b0dd7cc 100644 --- a/samples/learn/ReviewObject.cpp +++ b/samples/learn/ReviewObject.cpp @@ -18,7 +18,7 @@ using namespace std::literals; namespace graphql::learn { namespace object { -Review::Review() +Review::Review(std::unique_ptr&& pimpl) : service::Object({ "Review" }, { @@ -26,6 +26,11 @@ Review::Review() { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, { R"gql(commentary)gql"sv, [this](service::ResolverParams&& params) { return resolveCommentary(std::move(params)); } } }) + , _pimpl(std::move(pimpl)) +{ +} + +Review::~Review() { } @@ -33,7 +38,7 @@ service::AwaitableResolver Review::resolveStars(service::ResolverParams&& params { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getStars(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getStars(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); @@ -43,7 +48,7 @@ service::AwaitableResolver Review::resolveCommentary(service::ResolverParams&& p { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getCommentary(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getCommentary(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); diff --git a/samples/learn/ReviewObject.h b/samples/learn/ReviewObject.h index 6dd55281..c04b2436 100644 --- a/samples/learn/ReviewObject.h +++ b/samples/learn/ReviewObject.h @@ -15,18 +15,53 @@ namespace graphql::learn::object { class Review : public service::Object { -protected: - explicit Review(); - -public: - virtual service::FieldResult getStars(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getCommentary(service::FieldParams&& params) const = 0; - private: service::AwaitableResolver resolveStars(service::ResolverParams&& params); service::AwaitableResolver resolveCommentary(service::ResolverParams&& params); service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + + struct Concept + { + virtual service::FieldResult getStars(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getCommentary(service::FieldParams&& params) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::FieldResult getStars(service::FieldParams&& params) const final + { + return _pimpl->getStars(std::move(params)); + } + + service::FieldResult> getCommentary(service::FieldParams&& params) const final + { + return _pimpl->getCommentary(std::move(params)); + } + + private: + const std::shared_ptr _pimpl; + }; + + Review(std::unique_ptr&& pimpl); + + const std::unique_ptr _pimpl; + +public: + template + Review(std::shared_ptr pimpl) + : Review { std::make_unique>(std::move(pimpl)) } + { + } + + ~Review(); }; } // namespace graphql::learn::object diff --git a/samples/learn/StarWarsSchema.h b/samples/learn/StarWarsSchema.h index 09520c4a..076397c3 100644 --- a/samples/learn/StarWarsSchema.h +++ b/samples/learn/StarWarsSchema.h @@ -58,6 +58,12 @@ class Operations public: explicit Operations(std::shared_ptr query, std::shared_ptr mutation); + template + explicit Operations(std::shared_ptr query, std::shared_ptr mutation) + : Operations { std::make_shared(std::move(query)), std::make_shared(std::move(mutation)) } + { + } + private: std::shared_ptr _query; std::shared_ptr _mutation; diff --git a/samples/separate/AppointmentConnectionObject.cpp b/samples/separate/AppointmentConnectionObject.cpp index 0fa13769..ad51753f 100644 --- a/samples/separate/AppointmentConnectionObject.cpp +++ b/samples/separate/AppointmentConnectionObject.cpp @@ -18,7 +18,7 @@ using namespace std::literals; namespace graphql::today { namespace object { -AppointmentConnection::AppointmentConnection() +AppointmentConnection::AppointmentConnection(std::unique_ptr&& pimpl) : service::Object({ "AppointmentConnection" }, { @@ -26,34 +26,29 @@ AppointmentConnection::AppointmentConnection() { R"gql(pageInfo)gql"sv, [this](service::ResolverParams&& params) { return resolvePageInfo(std::move(params)); } }, { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } } }) + , _pimpl(std::move(pimpl)) { } -service::FieldResult> AppointmentConnection::getPageInfo(service::FieldParams&&) const +AppointmentConnection::~AppointmentConnection() { - throw std::runtime_error(R"ex(AppointmentConnection::getPageInfo is not implemented)ex"); } service::AwaitableResolver AppointmentConnection::resolvePageInfo(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getPageInfo(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getPageInfo(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult>>> AppointmentConnection::getEdges(service::FieldParams&&) const -{ - throw std::runtime_error(R"ex(AppointmentConnection::getEdges is not implemented)ex"); -} - service::AwaitableResolver AppointmentConnection::resolveEdges(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getEdges(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getEdges(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); diff --git a/samples/separate/AppointmentConnectionObject.h b/samples/separate/AppointmentConnectionObject.h index ff7a67a3..e0338c67 100644 --- a/samples/separate/AppointmentConnectionObject.h +++ b/samples/separate/AppointmentConnectionObject.h @@ -15,18 +15,53 @@ namespace graphql::today::object { class AppointmentConnection : public service::Object { -protected: - explicit AppointmentConnection(); - -public: - virtual service::FieldResult> getPageInfo(service::FieldParams&& params) const; - virtual service::FieldResult>>> getEdges(service::FieldParams&& params) const; - private: service::AwaitableResolver resolvePageInfo(service::ResolverParams&& params); service::AwaitableResolver resolveEdges(service::ResolverParams&& params); service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + + struct Concept + { + virtual service::FieldResult> getPageInfo(service::FieldParams&& params) const = 0; + virtual service::FieldResult>>> getEdges(service::FieldParams&& params) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::FieldResult> getPageInfo(service::FieldParams&& params) const final + { + return _pimpl->getPageInfo(std::move(params)); + } + + service::FieldResult>>> getEdges(service::FieldParams&& params) const final + { + return _pimpl->getEdges(std::move(params)); + } + + private: + const std::shared_ptr _pimpl; + }; + + AppointmentConnection(std::unique_ptr&& pimpl); + + const std::unique_ptr _pimpl; + +public: + template + AppointmentConnection(std::shared_ptr pimpl) + : AppointmentConnection { std::make_unique>(std::move(pimpl)) } + { + } + + ~AppointmentConnection(); }; } // namespace graphql::today::object diff --git a/samples/separate/AppointmentEdgeObject.cpp b/samples/separate/AppointmentEdgeObject.cpp index 588dfeb0..2d222f4b 100644 --- a/samples/separate/AppointmentEdgeObject.cpp +++ b/samples/separate/AppointmentEdgeObject.cpp @@ -18,7 +18,7 @@ using namespace std::literals; namespace graphql::today { namespace object { -AppointmentEdge::AppointmentEdge() +AppointmentEdge::AppointmentEdge(std::unique_ptr&& pimpl) : service::Object({ "AppointmentEdge" }, { @@ -26,34 +26,29 @@ AppointmentEdge::AppointmentEdge() { R"gql(cursor)gql"sv, [this](service::ResolverParams&& params) { return resolveCursor(std::move(params)); } }, { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } } }) + , _pimpl(std::move(pimpl)) { } -service::FieldResult> AppointmentEdge::getNode(service::FieldParams&&) const +AppointmentEdge::~AppointmentEdge() { - throw std::runtime_error(R"ex(AppointmentEdge::getNode is not implemented)ex"); } service::AwaitableResolver AppointmentEdge::resolveNode(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getNode(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getNode(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult AppointmentEdge::getCursor(service::FieldParams&&) const -{ - throw std::runtime_error(R"ex(AppointmentEdge::getCursor is not implemented)ex"); -} - service::AwaitableResolver AppointmentEdge::resolveCursor(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getCursor(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getCursor(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); diff --git a/samples/separate/AppointmentEdgeObject.h b/samples/separate/AppointmentEdgeObject.h index f8a5236e..8101c409 100644 --- a/samples/separate/AppointmentEdgeObject.h +++ b/samples/separate/AppointmentEdgeObject.h @@ -15,18 +15,53 @@ namespace graphql::today::object { class AppointmentEdge : public service::Object { -protected: - explicit AppointmentEdge(); - -public: - virtual service::FieldResult> getNode(service::FieldParams&& params) const; - virtual service::FieldResult getCursor(service::FieldParams&& params) const; - private: service::AwaitableResolver resolveNode(service::ResolverParams&& params); service::AwaitableResolver resolveCursor(service::ResolverParams&& params); service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + + struct Concept + { + virtual service::FieldResult> getNode(service::FieldParams&& params) const = 0; + virtual service::FieldResult getCursor(service::FieldParams&& params) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::FieldResult> getNode(service::FieldParams&& params) const final + { + return _pimpl->getNode(std::move(params)); + } + + service::FieldResult getCursor(service::FieldParams&& params) const final + { + return _pimpl->getCursor(std::move(params)); + } + + private: + const std::shared_ptr _pimpl; + }; + + AppointmentEdge(std::unique_ptr&& pimpl); + + const std::unique_ptr _pimpl; + +public: + template + AppointmentEdge(std::shared_ptr pimpl) + : AppointmentEdge { std::make_unique>(std::move(pimpl)) } + { + } + + ~AppointmentEdge(); }; } // namespace graphql::today::object diff --git a/samples/separate/AppointmentObject.cpp b/samples/separate/AppointmentObject.cpp index 7b156a39..4327bc1b 100644 --- a/samples/separate/AppointmentObject.cpp +++ b/samples/separate/AppointmentObject.cpp @@ -18,7 +18,7 @@ using namespace std::literals; namespace graphql::today { namespace object { -Appointment::Appointment() +Appointment::Appointment(std::unique_ptr&& pimpl) : service::Object({ "Node", "UnionType", @@ -31,79 +31,59 @@ Appointment::Appointment() { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, { R"gql(forceError)gql"sv, [this](service::ResolverParams&& params) { return resolveForceError(std::move(params)); } } }) + , _pimpl(std::move(pimpl)) { } -service::FieldResult Appointment::getId(service::FieldParams&&) const +Appointment::~Appointment() { - throw std::runtime_error(R"ex(Appointment::getId is not implemented)ex"); } service::AwaitableResolver Appointment::resolveId(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getId(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getId(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult> Appointment::getWhen(service::FieldParams&&) const -{ - throw std::runtime_error(R"ex(Appointment::getWhen is not implemented)ex"); -} - service::AwaitableResolver Appointment::resolveWhen(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getWhen(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getWhen(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult> Appointment::getSubject(service::FieldParams&&) const -{ - throw std::runtime_error(R"ex(Appointment::getSubject is not implemented)ex"); -} - service::AwaitableResolver Appointment::resolveSubject(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getSubject(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getSubject(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult Appointment::getIsNow(service::FieldParams&&) const -{ - throw std::runtime_error(R"ex(Appointment::getIsNow is not implemented)ex"); -} - service::AwaitableResolver Appointment::resolveIsNow(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getIsNow(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getIsNow(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult> Appointment::getForceError(service::FieldParams&&) const -{ - throw std::runtime_error(R"ex(Appointment::getForceError is not implemented)ex"); -} - service::AwaitableResolver Appointment::resolveForceError(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getForceError(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getForceError(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); diff --git a/samples/separate/AppointmentObject.h b/samples/separate/AppointmentObject.h index efdd3500..c7449b1d 100644 --- a/samples/separate/AppointmentObject.h +++ b/samples/separate/AppointmentObject.h @@ -14,18 +14,7 @@ namespace graphql::today::object { class Appointment : public service::Object - , public Node { -protected: - explicit Appointment(); - -public: - service::FieldResult getId(service::FieldParams&& params) const override; - virtual service::FieldResult> getWhen(service::FieldParams&& params) const; - virtual service::FieldResult> getSubject(service::FieldParams&& params) const; - virtual service::FieldResult getIsNow(service::FieldParams&& params) const; - virtual service::FieldResult> getForceError(service::FieldParams&& params) const; - private: service::AwaitableResolver resolveId(service::ResolverParams&& params); service::AwaitableResolver resolveWhen(service::ResolverParams&& params); @@ -34,6 +23,66 @@ class Appointment service::AwaitableResolver resolveForceError(service::ResolverParams&& params); service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + + struct Concept + : Node + { + virtual service::FieldResult> getWhen(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getSubject(service::FieldParams&& params) const = 0; + virtual service::FieldResult getIsNow(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getForceError(service::FieldParams&& params) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::FieldResult getId(service::FieldParams&& params) const final + { + return _pimpl->getId(std::move(params)); + } + + service::FieldResult> getWhen(service::FieldParams&& params) const final + { + return _pimpl->getWhen(std::move(params)); + } + + service::FieldResult> getSubject(service::FieldParams&& params) const final + { + return _pimpl->getSubject(std::move(params)); + } + + service::FieldResult getIsNow(service::FieldParams&& params) const final + { + return _pimpl->getIsNow(std::move(params)); + } + + service::FieldResult> getForceError(service::FieldParams&& params) const final + { + return _pimpl->getForceError(std::move(params)); + } + + private: + const std::shared_ptr _pimpl; + }; + + Appointment(std::unique_ptr&& pimpl); + + const std::unique_ptr _pimpl; + +public: + template + Appointment(std::shared_ptr pimpl) + : Appointment { std::make_unique>(std::move(pimpl)) } + { + } + + ~Appointment(); }; } // namespace graphql::today::object diff --git a/samples/separate/CompleteTaskPayloadObject.cpp b/samples/separate/CompleteTaskPayloadObject.cpp index d3a742ac..ca0f6f76 100644 --- a/samples/separate/CompleteTaskPayloadObject.cpp +++ b/samples/separate/CompleteTaskPayloadObject.cpp @@ -18,7 +18,7 @@ using namespace std::literals; namespace graphql::today { namespace object { -CompleteTaskPayload::CompleteTaskPayload() +CompleteTaskPayload::CompleteTaskPayload(std::unique_ptr&& pimpl) : service::Object({ "CompleteTaskPayload" }, { @@ -26,34 +26,29 @@ CompleteTaskPayload::CompleteTaskPayload() { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, { R"gql(clientMutationId)gql"sv, [this](service::ResolverParams&& params) { return resolveClientMutationId(std::move(params)); } } }) + , _pimpl(std::move(pimpl)) { } -service::FieldResult> CompleteTaskPayload::getTask(service::FieldParams&&) const +CompleteTaskPayload::~CompleteTaskPayload() { - throw std::runtime_error(R"ex(CompleteTaskPayload::getTask is not implemented)ex"); } service::AwaitableResolver CompleteTaskPayload::resolveTask(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getTask(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getTask(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult> CompleteTaskPayload::getClientMutationId(service::FieldParams&&) const -{ - throw std::runtime_error(R"ex(CompleteTaskPayload::getClientMutationId is not implemented)ex"); -} - service::AwaitableResolver CompleteTaskPayload::resolveClientMutationId(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getClientMutationId(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getClientMutationId(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); diff --git a/samples/separate/CompleteTaskPayloadObject.h b/samples/separate/CompleteTaskPayloadObject.h index c44afd16..597d9f2d 100644 --- a/samples/separate/CompleteTaskPayloadObject.h +++ b/samples/separate/CompleteTaskPayloadObject.h @@ -15,18 +15,53 @@ namespace graphql::today::object { class CompleteTaskPayload : public service::Object { -protected: - explicit CompleteTaskPayload(); - -public: - virtual service::FieldResult> getTask(service::FieldParams&& params) const; - virtual service::FieldResult> getClientMutationId(service::FieldParams&& params) const; - private: service::AwaitableResolver resolveTask(service::ResolverParams&& params); service::AwaitableResolver resolveClientMutationId(service::ResolverParams&& params); service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + + struct Concept + { + virtual service::FieldResult> getTask(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getClientMutationId(service::FieldParams&& params) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::FieldResult> getTask(service::FieldParams&& params) const final + { + return _pimpl->getTask(std::move(params)); + } + + service::FieldResult> getClientMutationId(service::FieldParams&& params) const final + { + return _pimpl->getClientMutationId(std::move(params)); + } + + private: + const std::shared_ptr _pimpl; + }; + + CompleteTaskPayload(std::unique_ptr&& pimpl); + + const std::unique_ptr _pimpl; + +public: + template + CompleteTaskPayload(std::shared_ptr pimpl) + : CompleteTaskPayload { std::make_unique>(std::move(pimpl)) } + { + } + + ~CompleteTaskPayload(); }; } // namespace graphql::today::object diff --git a/samples/separate/ExpensiveObject.cpp b/samples/separate/ExpensiveObject.cpp index 2bc006c6..51cc5140 100644 --- a/samples/separate/ExpensiveObject.cpp +++ b/samples/separate/ExpensiveObject.cpp @@ -18,26 +18,26 @@ using namespace std::literals; namespace graphql::today { namespace object { -Expensive::Expensive() +Expensive::Expensive(std::unique_ptr&& pimpl) : service::Object({ "Expensive" }, { { R"gql(order)gql"sv, [this](service::ResolverParams&& params) { return resolveOrder(std::move(params)); } }, { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } } }) + , _pimpl(std::move(pimpl)) { } -service::FieldResult Expensive::getOrder(service::FieldParams&&) const +Expensive::~Expensive() { - throw std::runtime_error(R"ex(Expensive::getOrder is not implemented)ex"); } service::AwaitableResolver Expensive::resolveOrder(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getOrder(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getOrder(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); diff --git a/samples/separate/ExpensiveObject.h b/samples/separate/ExpensiveObject.h index 4c30bba0..60682b27 100644 --- a/samples/separate/ExpensiveObject.h +++ b/samples/separate/ExpensiveObject.h @@ -15,16 +15,46 @@ namespace graphql::today::object { class Expensive : public service::Object { -protected: - explicit Expensive(); - -public: - virtual service::FieldResult getOrder(service::FieldParams&& params) const; - private: service::AwaitableResolver resolveOrder(service::ResolverParams&& params); service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + + struct Concept + { + virtual service::FieldResult getOrder(service::FieldParams&& params) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::FieldResult getOrder(service::FieldParams&& params) const final + { + return _pimpl->getOrder(std::move(params)); + } + + private: + const std::shared_ptr _pimpl; + }; + + Expensive(std::unique_ptr&& pimpl); + + const std::unique_ptr _pimpl; + +public: + template + Expensive(std::shared_ptr pimpl) + : Expensive { std::make_unique>(std::move(pimpl)) } + { + } + + ~Expensive(); }; } // namespace graphql::today::object diff --git a/samples/separate/FolderConnectionObject.cpp b/samples/separate/FolderConnectionObject.cpp index 2d7ac269..802380da 100644 --- a/samples/separate/FolderConnectionObject.cpp +++ b/samples/separate/FolderConnectionObject.cpp @@ -18,7 +18,7 @@ using namespace std::literals; namespace graphql::today { namespace object { -FolderConnection::FolderConnection() +FolderConnection::FolderConnection(std::unique_ptr&& pimpl) : service::Object({ "FolderConnection" }, { @@ -26,34 +26,29 @@ FolderConnection::FolderConnection() { R"gql(pageInfo)gql"sv, [this](service::ResolverParams&& params) { return resolvePageInfo(std::move(params)); } }, { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } } }) + , _pimpl(std::move(pimpl)) { } -service::FieldResult> FolderConnection::getPageInfo(service::FieldParams&&) const +FolderConnection::~FolderConnection() { - throw std::runtime_error(R"ex(FolderConnection::getPageInfo is not implemented)ex"); } service::AwaitableResolver FolderConnection::resolvePageInfo(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getPageInfo(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getPageInfo(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult>>> FolderConnection::getEdges(service::FieldParams&&) const -{ - throw std::runtime_error(R"ex(FolderConnection::getEdges is not implemented)ex"); -} - service::AwaitableResolver FolderConnection::resolveEdges(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getEdges(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getEdges(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); diff --git a/samples/separate/FolderConnectionObject.h b/samples/separate/FolderConnectionObject.h index 74477723..22ec4432 100644 --- a/samples/separate/FolderConnectionObject.h +++ b/samples/separate/FolderConnectionObject.h @@ -15,18 +15,53 @@ namespace graphql::today::object { class FolderConnection : public service::Object { -protected: - explicit FolderConnection(); - -public: - virtual service::FieldResult> getPageInfo(service::FieldParams&& params) const; - virtual service::FieldResult>>> getEdges(service::FieldParams&& params) const; - private: service::AwaitableResolver resolvePageInfo(service::ResolverParams&& params); service::AwaitableResolver resolveEdges(service::ResolverParams&& params); service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + + struct Concept + { + virtual service::FieldResult> getPageInfo(service::FieldParams&& params) const = 0; + virtual service::FieldResult>>> getEdges(service::FieldParams&& params) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::FieldResult> getPageInfo(service::FieldParams&& params) const final + { + return _pimpl->getPageInfo(std::move(params)); + } + + service::FieldResult>>> getEdges(service::FieldParams&& params) const final + { + return _pimpl->getEdges(std::move(params)); + } + + private: + const std::shared_ptr _pimpl; + }; + + FolderConnection(std::unique_ptr&& pimpl); + + const std::unique_ptr _pimpl; + +public: + template + FolderConnection(std::shared_ptr pimpl) + : FolderConnection { std::make_unique>(std::move(pimpl)) } + { + } + + ~FolderConnection(); }; } // namespace graphql::today::object diff --git a/samples/separate/FolderEdgeObject.cpp b/samples/separate/FolderEdgeObject.cpp index 06672e4b..e4e63fb1 100644 --- a/samples/separate/FolderEdgeObject.cpp +++ b/samples/separate/FolderEdgeObject.cpp @@ -18,7 +18,7 @@ using namespace std::literals; namespace graphql::today { namespace object { -FolderEdge::FolderEdge() +FolderEdge::FolderEdge(std::unique_ptr&& pimpl) : service::Object({ "FolderEdge" }, { @@ -26,34 +26,29 @@ FolderEdge::FolderEdge() { R"gql(cursor)gql"sv, [this](service::ResolverParams&& params) { return resolveCursor(std::move(params)); } }, { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } } }) + , _pimpl(std::move(pimpl)) { } -service::FieldResult> FolderEdge::getNode(service::FieldParams&&) const +FolderEdge::~FolderEdge() { - throw std::runtime_error(R"ex(FolderEdge::getNode is not implemented)ex"); } service::AwaitableResolver FolderEdge::resolveNode(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getNode(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getNode(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult FolderEdge::getCursor(service::FieldParams&&) const -{ - throw std::runtime_error(R"ex(FolderEdge::getCursor is not implemented)ex"); -} - service::AwaitableResolver FolderEdge::resolveCursor(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getCursor(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getCursor(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); diff --git a/samples/separate/FolderEdgeObject.h b/samples/separate/FolderEdgeObject.h index 52ab2627..19b4d78b 100644 --- a/samples/separate/FolderEdgeObject.h +++ b/samples/separate/FolderEdgeObject.h @@ -15,18 +15,53 @@ namespace graphql::today::object { class FolderEdge : public service::Object { -protected: - explicit FolderEdge(); - -public: - virtual service::FieldResult> getNode(service::FieldParams&& params) const; - virtual service::FieldResult getCursor(service::FieldParams&& params) const; - private: service::AwaitableResolver resolveNode(service::ResolverParams&& params); service::AwaitableResolver resolveCursor(service::ResolverParams&& params); service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + + struct Concept + { + virtual service::FieldResult> getNode(service::FieldParams&& params) const = 0; + virtual service::FieldResult getCursor(service::FieldParams&& params) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::FieldResult> getNode(service::FieldParams&& params) const final + { + return _pimpl->getNode(std::move(params)); + } + + service::FieldResult getCursor(service::FieldParams&& params) const final + { + return _pimpl->getCursor(std::move(params)); + } + + private: + const std::shared_ptr _pimpl; + }; + + FolderEdge(std::unique_ptr&& pimpl); + + const std::unique_ptr _pimpl; + +public: + template + FolderEdge(std::shared_ptr pimpl) + : FolderEdge { std::make_unique>(std::move(pimpl)) } + { + } + + ~FolderEdge(); }; } // namespace graphql::today::object diff --git a/samples/separate/FolderObject.cpp b/samples/separate/FolderObject.cpp index 3fadea37..bccaf182 100644 --- a/samples/separate/FolderObject.cpp +++ b/samples/separate/FolderObject.cpp @@ -18,7 +18,7 @@ using namespace std::literals; namespace graphql::today { namespace object { -Folder::Folder() +Folder::Folder(std::unique_ptr&& pimpl) : service::Object({ "Node", "UnionType", @@ -29,49 +29,39 @@ Folder::Folder() { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, { R"gql(unreadCount)gql"sv, [this](service::ResolverParams&& params) { return resolveUnreadCount(std::move(params)); } } }) + , _pimpl(std::move(pimpl)) { } -service::FieldResult Folder::getId(service::FieldParams&&) const +Folder::~Folder() { - throw std::runtime_error(R"ex(Folder::getId is not implemented)ex"); } service::AwaitableResolver Folder::resolveId(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getId(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getId(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult> Folder::getName(service::FieldParams&&) const -{ - throw std::runtime_error(R"ex(Folder::getName is not implemented)ex"); -} - service::AwaitableResolver Folder::resolveName(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getName(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getName(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult Folder::getUnreadCount(service::FieldParams&&) const -{ - throw std::runtime_error(R"ex(Folder::getUnreadCount is not implemented)ex"); -} - service::AwaitableResolver Folder::resolveUnreadCount(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getUnreadCount(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getUnreadCount(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); diff --git a/samples/separate/FolderObject.h b/samples/separate/FolderObject.h index bd1999ba..91f0fcee 100644 --- a/samples/separate/FolderObject.h +++ b/samples/separate/FolderObject.h @@ -14,22 +14,61 @@ namespace graphql::today::object { class Folder : public service::Object - , public Node { -protected: - explicit Folder(); - -public: - service::FieldResult getId(service::FieldParams&& params) const override; - virtual service::FieldResult> getName(service::FieldParams&& params) const; - virtual service::FieldResult getUnreadCount(service::FieldParams&& params) const; - private: service::AwaitableResolver resolveId(service::ResolverParams&& params); service::AwaitableResolver resolveName(service::ResolverParams&& params); service::AwaitableResolver resolveUnreadCount(service::ResolverParams&& params); service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + + struct Concept + : Node + { + virtual service::FieldResult> getName(service::FieldParams&& params) const = 0; + virtual service::FieldResult getUnreadCount(service::FieldParams&& params) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::FieldResult getId(service::FieldParams&& params) const final + { + return _pimpl->getId(std::move(params)); + } + + service::FieldResult> getName(service::FieldParams&& params) const final + { + return _pimpl->getName(std::move(params)); + } + + service::FieldResult getUnreadCount(service::FieldParams&& params) const final + { + return _pimpl->getUnreadCount(std::move(params)); + } + + private: + const std::shared_ptr _pimpl; + }; + + Folder(std::unique_ptr&& pimpl); + + const std::unique_ptr _pimpl; + +public: + template + Folder(std::shared_ptr pimpl) + : Folder { std::make_unique>(std::move(pimpl)) } + { + } + + ~Folder(); }; } // namespace graphql::today::object diff --git a/samples/separate/MutationObject.cpp b/samples/separate/MutationObject.cpp index aa8d858b..9914a1e2 100644 --- a/samples/separate/MutationObject.cpp +++ b/samples/separate/MutationObject.cpp @@ -18,7 +18,7 @@ using namespace std::literals; namespace graphql::today { namespace object { -Mutation::Mutation() +Mutation::Mutation(std::unique_ptr&& pimpl) : service::Object({ "Mutation" }, { @@ -26,12 +26,12 @@ Mutation::Mutation() { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, { R"gql(completeTask)gql"sv, [this](service::ResolverParams&& params) { return resolveCompleteTask(std::move(params)); } } }) + , _pimpl(std::move(pimpl)) { } -service::FieldResult> Mutation::applyCompleteTask(service::FieldParams&&, CompleteTaskInput&&) const +Mutation::~Mutation() { - throw std::runtime_error(R"ex(Mutation::applyCompleteTask is not implemented)ex"); } service::AwaitableResolver Mutation::resolveCompleteTask(service::ResolverParams&& params) @@ -39,23 +39,18 @@ service::AwaitableResolver Mutation::resolveCompleteTask(service::ResolverParams auto argInput = service::ModifiedArgument::require("input", params.arguments); std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = applyCompleteTask(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argInput)); + auto result = _pimpl->applyCompleteTask(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argInput)); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult Mutation::applySetFloat(service::FieldParams&&, response::FloatType&&) const -{ - throw std::runtime_error(R"ex(Mutation::applySetFloat is not implemented)ex"); -} - service::AwaitableResolver Mutation::resolveSetFloat(service::ResolverParams&& params) { auto argValue = service::ModifiedArgument::require("value", params.arguments); std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = applySetFloat(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argValue)); + auto result = _pimpl->applySetFloat(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argValue)); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); diff --git a/samples/separate/MutationObject.h b/samples/separate/MutationObject.h index b72577ea..afa82edb 100644 --- a/samples/separate/MutationObject.h +++ b/samples/separate/MutationObject.h @@ -15,18 +15,53 @@ namespace graphql::today::object { class Mutation : public service::Object { -protected: - explicit Mutation(); - -public: - virtual service::FieldResult> applyCompleteTask(service::FieldParams&& params, CompleteTaskInput&& inputArg) const; - virtual service::FieldResult applySetFloat(service::FieldParams&& params, response::FloatType&& valueArg) const; - private: service::AwaitableResolver resolveCompleteTask(service::ResolverParams&& params); service::AwaitableResolver resolveSetFloat(service::ResolverParams&& params); service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + + struct Concept + { + virtual service::FieldResult> applyCompleteTask(service::FieldParams&& params, CompleteTaskInput&& inputArg) const = 0; + virtual service::FieldResult applySetFloat(service::FieldParams&& params, response::FloatType&& valueArg) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::FieldResult> applyCompleteTask(service::FieldParams&& params, CompleteTaskInput&& inputArg) const final + { + return _pimpl->applyCompleteTask(std::move(params), std::move(inputArg)); + } + + service::FieldResult applySetFloat(service::FieldParams&& params, response::FloatType&& valueArg) const final + { + return _pimpl->applySetFloat(std::move(params), std::move(valueArg)); + } + + private: + const std::shared_ptr _pimpl; + }; + + Mutation(std::unique_ptr&& pimpl); + + const std::unique_ptr _pimpl; + +public: + template + Mutation(std::shared_ptr pimpl) + : Mutation { std::make_unique>(std::move(pimpl)) } + { + } + + ~Mutation(); }; } // namespace graphql::today::object diff --git a/samples/separate/NestedTypeObject.cpp b/samples/separate/NestedTypeObject.cpp index 3117d57c..2dd40964 100644 --- a/samples/separate/NestedTypeObject.cpp +++ b/samples/separate/NestedTypeObject.cpp @@ -18,7 +18,7 @@ using namespace std::literals; namespace graphql::today { namespace object { -NestedType::NestedType() +NestedType::NestedType(std::unique_ptr&& pimpl) : service::Object({ "NestedType" }, { @@ -26,34 +26,29 @@ NestedType::NestedType() { R"gql(nested)gql"sv, [this](service::ResolverParams&& params) { return resolveNested(std::move(params)); } }, { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } } }) + , _pimpl(std::move(pimpl)) { } -service::FieldResult NestedType::getDepth(service::FieldParams&&) const +NestedType::~NestedType() { - throw std::runtime_error(R"ex(NestedType::getDepth is not implemented)ex"); } service::AwaitableResolver NestedType::resolveDepth(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getDepth(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getDepth(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult> NestedType::getNested(service::FieldParams&&) const -{ - throw std::runtime_error(R"ex(NestedType::getNested is not implemented)ex"); -} - service::AwaitableResolver NestedType::resolveNested(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getNested(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getNested(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); diff --git a/samples/separate/NestedTypeObject.h b/samples/separate/NestedTypeObject.h index eb06cf04..47348d9d 100644 --- a/samples/separate/NestedTypeObject.h +++ b/samples/separate/NestedTypeObject.h @@ -15,18 +15,53 @@ namespace graphql::today::object { class NestedType : public service::Object { -protected: - explicit NestedType(); - -public: - virtual service::FieldResult getDepth(service::FieldParams&& params) const; - virtual service::FieldResult> getNested(service::FieldParams&& params) const; - private: service::AwaitableResolver resolveDepth(service::ResolverParams&& params); service::AwaitableResolver resolveNested(service::ResolverParams&& params); service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + + struct Concept + { + virtual service::FieldResult getDepth(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getNested(service::FieldParams&& params) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::FieldResult getDepth(service::FieldParams&& params) const final + { + return _pimpl->getDepth(std::move(params)); + } + + service::FieldResult> getNested(service::FieldParams&& params) const final + { + return _pimpl->getNested(std::move(params)); + } + + private: + const std::shared_ptr _pimpl; + }; + + NestedType(std::unique_ptr&& pimpl); + + const std::unique_ptr _pimpl; + +public: + template + NestedType(std::shared_ptr pimpl) + : NestedType { std::make_unique>(std::move(pimpl)) } + { + } + + ~NestedType(); }; } // namespace graphql::today::object diff --git a/samples/separate/PageInfoObject.cpp b/samples/separate/PageInfoObject.cpp index 900d73a5..2c222dce 100644 --- a/samples/separate/PageInfoObject.cpp +++ b/samples/separate/PageInfoObject.cpp @@ -18,7 +18,7 @@ using namespace std::literals; namespace graphql::today { namespace object { -PageInfo::PageInfo() +PageInfo::PageInfo(std::unique_ptr&& pimpl) : service::Object({ "PageInfo" }, { @@ -26,34 +26,29 @@ PageInfo::PageInfo() { R"gql(hasNextPage)gql"sv, [this](service::ResolverParams&& params) { return resolveHasNextPage(std::move(params)); } }, { R"gql(hasPreviousPage)gql"sv, [this](service::ResolverParams&& params) { return resolveHasPreviousPage(std::move(params)); } } }) + , _pimpl(std::move(pimpl)) { } -service::FieldResult PageInfo::getHasNextPage(service::FieldParams&&) const +PageInfo::~PageInfo() { - throw std::runtime_error(R"ex(PageInfo::getHasNextPage is not implemented)ex"); } service::AwaitableResolver PageInfo::resolveHasNextPage(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getHasNextPage(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getHasNextPage(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult PageInfo::getHasPreviousPage(service::FieldParams&&) const -{ - throw std::runtime_error(R"ex(PageInfo::getHasPreviousPage is not implemented)ex"); -} - service::AwaitableResolver PageInfo::resolveHasPreviousPage(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getHasPreviousPage(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getHasPreviousPage(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); diff --git a/samples/separate/PageInfoObject.h b/samples/separate/PageInfoObject.h index b2d3a844..bacc5b21 100644 --- a/samples/separate/PageInfoObject.h +++ b/samples/separate/PageInfoObject.h @@ -15,18 +15,53 @@ namespace graphql::today::object { class PageInfo : public service::Object { -protected: - explicit PageInfo(); - -public: - virtual service::FieldResult getHasNextPage(service::FieldParams&& params) const; - virtual service::FieldResult getHasPreviousPage(service::FieldParams&& params) const; - private: service::AwaitableResolver resolveHasNextPage(service::ResolverParams&& params); service::AwaitableResolver resolveHasPreviousPage(service::ResolverParams&& params); service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + + struct Concept + { + virtual service::FieldResult getHasNextPage(service::FieldParams&& params) const = 0; + virtual service::FieldResult getHasPreviousPage(service::FieldParams&& params) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::FieldResult getHasNextPage(service::FieldParams&& params) const final + { + return _pimpl->getHasNextPage(std::move(params)); + } + + service::FieldResult getHasPreviousPage(service::FieldParams&& params) const final + { + return _pimpl->getHasPreviousPage(std::move(params)); + } + + private: + const std::shared_ptr _pimpl; + }; + + PageInfo(std::unique_ptr&& pimpl); + + const std::unique_ptr _pimpl; + +public: + template + PageInfo(std::shared_ptr pimpl) + : PageInfo { std::make_unique>(std::move(pimpl)) } + { + } + + ~PageInfo(); }; } // namespace graphql::today::object diff --git a/samples/separate/QueryObject.cpp b/samples/separate/QueryObject.cpp index 6df521bc..f29a3781 100644 --- a/samples/separate/QueryObject.cpp +++ b/samples/separate/QueryObject.cpp @@ -18,7 +18,7 @@ using namespace std::literals; namespace graphql::today { namespace object { -Query::Query() +Query::Query(std::unique_ptr&& pimpl) : service::Object({ "Query" }, { @@ -39,12 +39,12 @@ Query::Query() { R"gql(unreadCountsById)gql"sv, [this](service::ResolverParams&& params) { return resolveUnreadCountsById(std::move(params)); } } }) , _schema(GetSchema()) + , _pimpl(std::move(pimpl)) { } -service::FieldResult> Query::getNode(service::FieldParams&&, response::IdType&&) const +Query::~Query() { - throw std::runtime_error(R"ex(Query::getNode is not implemented)ex"); } service::AwaitableResolver Query::resolveNode(service::ResolverParams&& params) @@ -52,17 +52,12 @@ service::AwaitableResolver Query::resolveNode(service::ResolverParams&& params) auto argId = service::ModifiedArgument::require("id", params.arguments); std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getNode(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argId)); + auto result = _pimpl->getNode(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argId)); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult> Query::getAppointments(service::FieldParams&&, std::optional&&, std::optional&&, std::optional&&, std::optional&&) const -{ - throw std::runtime_error(R"ex(Query::getAppointments is not implemented)ex"); -} - service::AwaitableResolver Query::resolveAppointments(service::ResolverParams&& params) { auto argFirst = service::ModifiedArgument::require("first", params.arguments); @@ -71,17 +66,12 @@ service::AwaitableResolver Query::resolveAppointments(service::ResolverParams&& auto argBefore = service::ModifiedArgument::require("before", params.arguments); std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getAppointments(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argFirst), std::move(argAfter), std::move(argLast), std::move(argBefore)); + auto result = _pimpl->getAppointments(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argFirst), std::move(argAfter), std::move(argLast), std::move(argBefore)); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult> Query::getTasks(service::FieldParams&&, std::optional&&, std::optional&&, std::optional&&, std::optional&&) const -{ - throw std::runtime_error(R"ex(Query::getTasks is not implemented)ex"); -} - service::AwaitableResolver Query::resolveTasks(service::ResolverParams&& params) { auto argFirst = service::ModifiedArgument::require("first", params.arguments); @@ -90,17 +80,12 @@ service::AwaitableResolver Query::resolveTasks(service::ResolverParams&& params) auto argBefore = service::ModifiedArgument::require("before", params.arguments); std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getTasks(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argFirst), std::move(argAfter), std::move(argLast), std::move(argBefore)); + auto result = _pimpl->getTasks(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argFirst), std::move(argAfter), std::move(argLast), std::move(argBefore)); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult> Query::getUnreadCounts(service::FieldParams&&, std::optional&&, std::optional&&, std::optional&&, std::optional&&) const -{ - throw std::runtime_error(R"ex(Query::getUnreadCounts is not implemented)ex"); -} - service::AwaitableResolver Query::resolveUnreadCounts(service::ResolverParams&& params) { auto argFirst = service::ModifiedArgument::require("first", params.arguments); @@ -109,17 +94,12 @@ service::AwaitableResolver Query::resolveUnreadCounts(service::ResolverParams&& auto argBefore = service::ModifiedArgument::require("before", params.arguments); std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getUnreadCounts(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argFirst), std::move(argAfter), std::move(argLast), std::move(argBefore)); + auto result = _pimpl->getUnreadCounts(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argFirst), std::move(argAfter), std::move(argLast), std::move(argBefore)); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult>> Query::getAppointmentsById(service::FieldParams&&, std::vector&&) const -{ - throw std::runtime_error(R"ex(Query::getAppointmentsById is not implemented)ex"); -} - service::AwaitableResolver Query::resolveAppointmentsById(service::ResolverParams&& params) { const auto defaultArguments = []() @@ -147,115 +127,80 @@ service::AwaitableResolver Query::resolveAppointmentsById(service::ResolverParam : service::ModifiedArgument::require("ids", defaultArguments)); std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getAppointmentsById(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argIds)); + auto result = _pimpl->getAppointmentsById(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argIds)); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult>> Query::getTasksById(service::FieldParams&&, std::vector&&) const -{ - throw std::runtime_error(R"ex(Query::getTasksById is not implemented)ex"); -} - service::AwaitableResolver Query::resolveTasksById(service::ResolverParams&& params) { auto argIds = service::ModifiedArgument::require("ids", params.arguments); std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getTasksById(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argIds)); + auto result = _pimpl->getTasksById(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argIds)); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult>> Query::getUnreadCountsById(service::FieldParams&&, std::vector&&) const -{ - throw std::runtime_error(R"ex(Query::getUnreadCountsById is not implemented)ex"); -} - service::AwaitableResolver Query::resolveUnreadCountsById(service::ResolverParams&& params) { auto argIds = service::ModifiedArgument::require("ids", params.arguments); std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getUnreadCountsById(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argIds)); + auto result = _pimpl->getUnreadCountsById(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argIds)); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult> Query::getNested(service::FieldParams&&) const -{ - throw std::runtime_error(R"ex(Query::getNested is not implemented)ex"); -} - service::AwaitableResolver Query::resolveNested(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getNested(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getNested(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult Query::getUnimplemented(service::FieldParams&&) const -{ - throw std::runtime_error(R"ex(Query::getUnimplemented is not implemented)ex"); -} - service::AwaitableResolver Query::resolveUnimplemented(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getUnimplemented(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getUnimplemented(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult>> Query::getExpensive(service::FieldParams&&) const -{ - throw std::runtime_error(R"ex(Query::getExpensive is not implemented)ex"); -} - service::AwaitableResolver Query::resolveExpensive(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getExpensive(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getExpensive(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult Query::getTestTaskState(service::FieldParams&&) const -{ - throw std::runtime_error(R"ex(Query::getTestTaskState is not implemented)ex"); -} - service::AwaitableResolver Query::resolveTestTaskState(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getTestTaskState(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getTestTaskState(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult>> Query::getAnyType(service::FieldParams&&, std::vector&&) const -{ - throw std::runtime_error(R"ex(Query::getAnyType is not implemented)ex"); -} - service::AwaitableResolver Query::resolveAnyType(service::ResolverParams&& params) { auto argIds = service::ModifiedArgument::require("ids", params.arguments); std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getAnyType(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argIds)); + auto result = _pimpl->getAnyType(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argIds)); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); @@ -268,14 +213,14 @@ service::AwaitableResolver Query::resolve_typename(service::ResolverParams&& par service::AwaitableResolver Query::resolve_schema(service::ResolverParams&& params) { - return service::ModifiedResult::convert(std::static_pointer_cast(std::make_shared(_schema)), std::move(params)); + return service::ModifiedResult::convert(std::static_pointer_cast(std::make_shared(std::make_shared(_schema))), std::move(params)); } service::AwaitableResolver Query::resolve_type(service::ResolverParams&& params) { auto argName = service::ModifiedArgument::require("name", params.arguments); const auto& baseType = _schema->LookupType(argName); - std::shared_ptr result { baseType ? std::make_shared(baseType) : nullptr }; + std::shared_ptr result { baseType ? std::make_shared(std::make_shared(baseType)) : nullptr }; return service::ModifiedResult::convert(result, std::move(params)); } diff --git a/samples/separate/QueryObject.h b/samples/separate/QueryObject.h index 9518caf3..93a3bbcf 100644 --- a/samples/separate/QueryObject.h +++ b/samples/separate/QueryObject.h @@ -15,23 +15,6 @@ namespace graphql::today::object { class Query : public service::Object { -protected: - explicit Query(); - -public: - virtual service::FieldResult> getNode(service::FieldParams&& params, response::IdType&& idArg) const; - virtual service::FieldResult> getAppointments(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const; - virtual service::FieldResult> getTasks(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const; - virtual service::FieldResult> getUnreadCounts(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const; - virtual service::FieldResult>> getAppointmentsById(service::FieldParams&& params, std::vector&& idsArg) const; - virtual service::FieldResult>> getTasksById(service::FieldParams&& params, std::vector&& idsArg) const; - virtual service::FieldResult>> getUnreadCountsById(service::FieldParams&& params, std::vector&& idsArg) const; - virtual service::FieldResult> getNested(service::FieldParams&& params) const; - virtual service::FieldResult getUnimplemented(service::FieldParams&& params) const; - virtual service::FieldResult>> getExpensive(service::FieldParams&& params) const; - virtual service::FieldResult getTestTaskState(service::FieldParams&& params) const; - virtual service::FieldResult>> getAnyType(service::FieldParams&& params, std::vector&& idsArg) const; - private: service::AwaitableResolver resolveNode(service::ResolverParams&& params); service::AwaitableResolver resolveAppointments(service::ResolverParams&& params); @@ -51,6 +34,108 @@ class Query service::AwaitableResolver resolve_type(service::ResolverParams&& params); std::shared_ptr _schema; + + struct Concept + { + virtual service::FieldResult> getNode(service::FieldParams&& params, response::IdType&& idArg) const = 0; + virtual service::FieldResult> getAppointments(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const = 0; + virtual service::FieldResult> getTasks(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const = 0; + virtual service::FieldResult> getUnreadCounts(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const = 0; + virtual service::FieldResult>> getAppointmentsById(service::FieldParams&& params, std::vector&& idsArg) const = 0; + virtual service::FieldResult>> getTasksById(service::FieldParams&& params, std::vector&& idsArg) const = 0; + virtual service::FieldResult>> getUnreadCountsById(service::FieldParams&& params, std::vector&& idsArg) const = 0; + virtual service::FieldResult> getNested(service::FieldParams&& params) const = 0; + virtual service::FieldResult getUnimplemented(service::FieldParams&& params) const = 0; + virtual service::FieldResult>> getExpensive(service::FieldParams&& params) const = 0; + virtual service::FieldResult getTestTaskState(service::FieldParams&& params) const = 0; + virtual service::FieldResult>> getAnyType(service::FieldParams&& params, std::vector&& idsArg) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::FieldResult> getNode(service::FieldParams&& params, response::IdType&& idArg) const final + { + return _pimpl->getNode(std::move(params), std::move(idArg)); + } + + service::FieldResult> getAppointments(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const final + { + return _pimpl->getAppointments(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)); + } + + service::FieldResult> getTasks(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const final + { + return _pimpl->getTasks(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)); + } + + service::FieldResult> getUnreadCounts(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const final + { + return _pimpl->getUnreadCounts(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)); + } + + service::FieldResult>> getAppointmentsById(service::FieldParams&& params, std::vector&& idsArg) const final + { + return _pimpl->getAppointmentsById(std::move(params), std::move(idsArg)); + } + + service::FieldResult>> getTasksById(service::FieldParams&& params, std::vector&& idsArg) const final + { + return _pimpl->getTasksById(std::move(params), std::move(idsArg)); + } + + service::FieldResult>> getUnreadCountsById(service::FieldParams&& params, std::vector&& idsArg) const final + { + return _pimpl->getUnreadCountsById(std::move(params), std::move(idsArg)); + } + + service::FieldResult> getNested(service::FieldParams&& params) const final + { + return _pimpl->getNested(std::move(params)); + } + + service::FieldResult getUnimplemented(service::FieldParams&& params) const final + { + return _pimpl->getUnimplemented(std::move(params)); + } + + service::FieldResult>> getExpensive(service::FieldParams&& params) const final + { + return _pimpl->getExpensive(std::move(params)); + } + + service::FieldResult getTestTaskState(service::FieldParams&& params) const final + { + return _pimpl->getTestTaskState(std::move(params)); + } + + service::FieldResult>> getAnyType(service::FieldParams&& params, std::vector&& idsArg) const final + { + return _pimpl->getAnyType(std::move(params), std::move(idsArg)); + } + + private: + const std::shared_ptr _pimpl; + }; + + Query(std::unique_ptr&& pimpl); + + const std::unique_ptr _pimpl; + +public: + template + Query(std::shared_ptr pimpl) + : Query { std::make_unique>(std::move(pimpl)) } + { + } + + ~Query(); }; } // namespace graphql::today::object diff --git a/samples/separate/SubscriptionObject.cpp b/samples/separate/SubscriptionObject.cpp index 746a6e7e..b69a1270 100644 --- a/samples/separate/SubscriptionObject.cpp +++ b/samples/separate/SubscriptionObject.cpp @@ -18,7 +18,7 @@ using namespace std::literals; namespace graphql::today { namespace object { -Subscription::Subscription() +Subscription::Subscription(std::unique_ptr&& pimpl) : service::Object({ "Subscription" }, { @@ -26,35 +26,30 @@ Subscription::Subscription() { R"gql(nodeChange)gql"sv, [this](service::ResolverParams&& params) { return resolveNodeChange(std::move(params)); } }, { R"gql(nextAppointmentChange)gql"sv, [this](service::ResolverParams&& params) { return resolveNextAppointmentChange(std::move(params)); } } }) + , _pimpl(std::move(pimpl)) { } -service::FieldResult> Subscription::getNextAppointmentChange(service::FieldParams&&) const +Subscription::~Subscription() { - throw std::runtime_error(R"ex(Subscription::getNextAppointmentChange is not implemented)ex"); } service::AwaitableResolver Subscription::resolveNextAppointmentChange(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getNextAppointmentChange(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getNextAppointmentChange(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult> Subscription::getNodeChange(service::FieldParams&&, response::IdType&&) const -{ - throw std::runtime_error(R"ex(Subscription::getNodeChange is not implemented)ex"); -} - service::AwaitableResolver Subscription::resolveNodeChange(service::ResolverParams&& params) { auto argId = service::ModifiedArgument::require("id", params.arguments); std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getNodeChange(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argId)); + auto result = _pimpl->getNodeChange(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argId)); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); diff --git a/samples/separate/SubscriptionObject.h b/samples/separate/SubscriptionObject.h index 819ebc7a..feba2c94 100644 --- a/samples/separate/SubscriptionObject.h +++ b/samples/separate/SubscriptionObject.h @@ -15,18 +15,53 @@ namespace graphql::today::object { class Subscription : public service::Object { -protected: - explicit Subscription(); - -public: - virtual service::FieldResult> getNextAppointmentChange(service::FieldParams&& params) const; - virtual service::FieldResult> getNodeChange(service::FieldParams&& params, response::IdType&& idArg) const; - private: service::AwaitableResolver resolveNextAppointmentChange(service::ResolverParams&& params); service::AwaitableResolver resolveNodeChange(service::ResolverParams&& params); service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + + struct Concept + { + virtual service::FieldResult> getNextAppointmentChange(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getNodeChange(service::FieldParams&& params, response::IdType&& idArg) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::FieldResult> getNextAppointmentChange(service::FieldParams&& params) const final + { + return _pimpl->getNextAppointmentChange(std::move(params)); + } + + service::FieldResult> getNodeChange(service::FieldParams&& params, response::IdType&& idArg) const final + { + return _pimpl->getNodeChange(std::move(params), std::move(idArg)); + } + + private: + const std::shared_ptr _pimpl; + }; + + Subscription(std::unique_ptr&& pimpl); + + const std::unique_ptr _pimpl; + +public: + template + Subscription(std::shared_ptr pimpl) + : Subscription { std::make_unique>(std::move(pimpl)) } + { + } + + ~Subscription(); }; } // namespace graphql::today::object diff --git a/samples/separate/TaskConnectionObject.cpp b/samples/separate/TaskConnectionObject.cpp index e5da2c67..e74354cb 100644 --- a/samples/separate/TaskConnectionObject.cpp +++ b/samples/separate/TaskConnectionObject.cpp @@ -18,7 +18,7 @@ using namespace std::literals; namespace graphql::today { namespace object { -TaskConnection::TaskConnection() +TaskConnection::TaskConnection(std::unique_ptr&& pimpl) : service::Object({ "TaskConnection" }, { @@ -26,34 +26,29 @@ TaskConnection::TaskConnection() { R"gql(pageInfo)gql"sv, [this](service::ResolverParams&& params) { return resolvePageInfo(std::move(params)); } }, { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } } }) + , _pimpl(std::move(pimpl)) { } -service::FieldResult> TaskConnection::getPageInfo(service::FieldParams&&) const +TaskConnection::~TaskConnection() { - throw std::runtime_error(R"ex(TaskConnection::getPageInfo is not implemented)ex"); } service::AwaitableResolver TaskConnection::resolvePageInfo(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getPageInfo(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getPageInfo(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult>>> TaskConnection::getEdges(service::FieldParams&&) const -{ - throw std::runtime_error(R"ex(TaskConnection::getEdges is not implemented)ex"); -} - service::AwaitableResolver TaskConnection::resolveEdges(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getEdges(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getEdges(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); diff --git a/samples/separate/TaskConnectionObject.h b/samples/separate/TaskConnectionObject.h index c8a79517..e406fa2b 100644 --- a/samples/separate/TaskConnectionObject.h +++ b/samples/separate/TaskConnectionObject.h @@ -15,18 +15,53 @@ namespace graphql::today::object { class TaskConnection : public service::Object { -protected: - explicit TaskConnection(); - -public: - virtual service::FieldResult> getPageInfo(service::FieldParams&& params) const; - virtual service::FieldResult>>> getEdges(service::FieldParams&& params) const; - private: service::AwaitableResolver resolvePageInfo(service::ResolverParams&& params); service::AwaitableResolver resolveEdges(service::ResolverParams&& params); service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + + struct Concept + { + virtual service::FieldResult> getPageInfo(service::FieldParams&& params) const = 0; + virtual service::FieldResult>>> getEdges(service::FieldParams&& params) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::FieldResult> getPageInfo(service::FieldParams&& params) const final + { + return _pimpl->getPageInfo(std::move(params)); + } + + service::FieldResult>>> getEdges(service::FieldParams&& params) const final + { + return _pimpl->getEdges(std::move(params)); + } + + private: + const std::shared_ptr _pimpl; + }; + + TaskConnection(std::unique_ptr&& pimpl); + + const std::unique_ptr _pimpl; + +public: + template + TaskConnection(std::shared_ptr pimpl) + : TaskConnection { std::make_unique>(std::move(pimpl)) } + { + } + + ~TaskConnection(); }; } // namespace graphql::today::object diff --git a/samples/separate/TaskEdgeObject.cpp b/samples/separate/TaskEdgeObject.cpp index 9cdb491f..6ff72129 100644 --- a/samples/separate/TaskEdgeObject.cpp +++ b/samples/separate/TaskEdgeObject.cpp @@ -18,7 +18,7 @@ using namespace std::literals; namespace graphql::today { namespace object { -TaskEdge::TaskEdge() +TaskEdge::TaskEdge(std::unique_ptr&& pimpl) : service::Object({ "TaskEdge" }, { @@ -26,34 +26,29 @@ TaskEdge::TaskEdge() { R"gql(cursor)gql"sv, [this](service::ResolverParams&& params) { return resolveCursor(std::move(params)); } }, { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } } }) + , _pimpl(std::move(pimpl)) { } -service::FieldResult> TaskEdge::getNode(service::FieldParams&&) const +TaskEdge::~TaskEdge() { - throw std::runtime_error(R"ex(TaskEdge::getNode is not implemented)ex"); } service::AwaitableResolver TaskEdge::resolveNode(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getNode(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getNode(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult TaskEdge::getCursor(service::FieldParams&&) const -{ - throw std::runtime_error(R"ex(TaskEdge::getCursor is not implemented)ex"); -} - service::AwaitableResolver TaskEdge::resolveCursor(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getCursor(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getCursor(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); diff --git a/samples/separate/TaskEdgeObject.h b/samples/separate/TaskEdgeObject.h index 903ff369..60ced878 100644 --- a/samples/separate/TaskEdgeObject.h +++ b/samples/separate/TaskEdgeObject.h @@ -15,18 +15,53 @@ namespace graphql::today::object { class TaskEdge : public service::Object { -protected: - explicit TaskEdge(); - -public: - virtual service::FieldResult> getNode(service::FieldParams&& params) const; - virtual service::FieldResult getCursor(service::FieldParams&& params) const; - private: service::AwaitableResolver resolveNode(service::ResolverParams&& params); service::AwaitableResolver resolveCursor(service::ResolverParams&& params); service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + + struct Concept + { + virtual service::FieldResult> getNode(service::FieldParams&& params) const = 0; + virtual service::FieldResult getCursor(service::FieldParams&& params) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::FieldResult> getNode(service::FieldParams&& params) const final + { + return _pimpl->getNode(std::move(params)); + } + + service::FieldResult getCursor(service::FieldParams&& params) const final + { + return _pimpl->getCursor(std::move(params)); + } + + private: + const std::shared_ptr _pimpl; + }; + + TaskEdge(std::unique_ptr&& pimpl); + + const std::unique_ptr _pimpl; + +public: + template + TaskEdge(std::shared_ptr pimpl) + : TaskEdge { std::make_unique>(std::move(pimpl)) } + { + } + + ~TaskEdge(); }; } // namespace graphql::today::object diff --git a/samples/separate/TaskObject.cpp b/samples/separate/TaskObject.cpp index c65cbf0e..65237095 100644 --- a/samples/separate/TaskObject.cpp +++ b/samples/separate/TaskObject.cpp @@ -18,7 +18,7 @@ using namespace std::literals; namespace graphql::today { namespace object { -Task::Task() +Task::Task(std::unique_ptr&& pimpl) : service::Object({ "Node", "UnionType", @@ -29,49 +29,39 @@ Task::Task() { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, { R"gql(isComplete)gql"sv, [this](service::ResolverParams&& params) { return resolveIsComplete(std::move(params)); } } }) + , _pimpl(std::move(pimpl)) { } -service::FieldResult Task::getId(service::FieldParams&&) const +Task::~Task() { - throw std::runtime_error(R"ex(Task::getId is not implemented)ex"); } service::AwaitableResolver Task::resolveId(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getId(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getId(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult> Task::getTitle(service::FieldParams&&) const -{ - throw std::runtime_error(R"ex(Task::getTitle is not implemented)ex"); -} - service::AwaitableResolver Task::resolveTitle(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getTitle(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getTitle(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult Task::getIsComplete(service::FieldParams&&) const -{ - throw std::runtime_error(R"ex(Task::getIsComplete is not implemented)ex"); -} - service::AwaitableResolver Task::resolveIsComplete(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getIsComplete(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getIsComplete(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); diff --git a/samples/separate/TaskObject.h b/samples/separate/TaskObject.h index a03e82cc..8a161bbe 100644 --- a/samples/separate/TaskObject.h +++ b/samples/separate/TaskObject.h @@ -14,22 +14,61 @@ namespace graphql::today::object { class Task : public service::Object - , public Node { -protected: - explicit Task(); - -public: - service::FieldResult getId(service::FieldParams&& params) const override; - virtual service::FieldResult> getTitle(service::FieldParams&& params) const; - virtual service::FieldResult getIsComplete(service::FieldParams&& params) const; - private: service::AwaitableResolver resolveId(service::ResolverParams&& params); service::AwaitableResolver resolveTitle(service::ResolverParams&& params); service::AwaitableResolver resolveIsComplete(service::ResolverParams&& params); service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + + struct Concept + : Node + { + virtual service::FieldResult> getTitle(service::FieldParams&& params) const = 0; + virtual service::FieldResult getIsComplete(service::FieldParams&& params) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::FieldResult getId(service::FieldParams&& params) const final + { + return _pimpl->getId(std::move(params)); + } + + service::FieldResult> getTitle(service::FieldParams&& params) const final + { + return _pimpl->getTitle(std::move(params)); + } + + service::FieldResult getIsComplete(service::FieldParams&& params) const final + { + return _pimpl->getIsComplete(std::move(params)); + } + + private: + const std::shared_ptr _pimpl; + }; + + Task(std::unique_ptr&& pimpl); + + const std::unique_ptr _pimpl; + +public: + template + Task(std::shared_ptr pimpl) + : Task { std::make_unique>(std::move(pimpl)) } + { + } + + ~Task(); }; } // namespace graphql::today::object diff --git a/samples/separate/TodaySchema.h b/samples/separate/TodaySchema.h index 69514331..9f979a6e 100644 --- a/samples/separate/TodaySchema.h +++ b/samples/separate/TodaySchema.h @@ -92,6 +92,12 @@ class Operations public: explicit Operations(std::shared_ptr query, std::shared_ptr mutation, std::shared_ptr subscription); + template + explicit Operations(std::shared_ptr query, std::shared_ptr mutation, std::shared_ptr subscription) + : Operations { std::make_shared(std::move(query)), std::make_shared(std::move(mutation)), std::make_shared(std::move(subscription)) } + { + } + private: std::shared_ptr _query; std::shared_ptr _mutation; diff --git a/samples/separate_nointrospection/AppointmentConnectionObject.cpp b/samples/separate_nointrospection/AppointmentConnectionObject.cpp index 0fa13769..ad51753f 100644 --- a/samples/separate_nointrospection/AppointmentConnectionObject.cpp +++ b/samples/separate_nointrospection/AppointmentConnectionObject.cpp @@ -18,7 +18,7 @@ using namespace std::literals; namespace graphql::today { namespace object { -AppointmentConnection::AppointmentConnection() +AppointmentConnection::AppointmentConnection(std::unique_ptr&& pimpl) : service::Object({ "AppointmentConnection" }, { @@ -26,34 +26,29 @@ AppointmentConnection::AppointmentConnection() { R"gql(pageInfo)gql"sv, [this](service::ResolverParams&& params) { return resolvePageInfo(std::move(params)); } }, { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } } }) + , _pimpl(std::move(pimpl)) { } -service::FieldResult> AppointmentConnection::getPageInfo(service::FieldParams&&) const +AppointmentConnection::~AppointmentConnection() { - throw std::runtime_error(R"ex(AppointmentConnection::getPageInfo is not implemented)ex"); } service::AwaitableResolver AppointmentConnection::resolvePageInfo(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getPageInfo(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getPageInfo(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult>>> AppointmentConnection::getEdges(service::FieldParams&&) const -{ - throw std::runtime_error(R"ex(AppointmentConnection::getEdges is not implemented)ex"); -} - service::AwaitableResolver AppointmentConnection::resolveEdges(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getEdges(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getEdges(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); diff --git a/samples/separate_nointrospection/AppointmentConnectionObject.h b/samples/separate_nointrospection/AppointmentConnectionObject.h index ff7a67a3..e0338c67 100644 --- a/samples/separate_nointrospection/AppointmentConnectionObject.h +++ b/samples/separate_nointrospection/AppointmentConnectionObject.h @@ -15,18 +15,53 @@ namespace graphql::today::object { class AppointmentConnection : public service::Object { -protected: - explicit AppointmentConnection(); - -public: - virtual service::FieldResult> getPageInfo(service::FieldParams&& params) const; - virtual service::FieldResult>>> getEdges(service::FieldParams&& params) const; - private: service::AwaitableResolver resolvePageInfo(service::ResolverParams&& params); service::AwaitableResolver resolveEdges(service::ResolverParams&& params); service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + + struct Concept + { + virtual service::FieldResult> getPageInfo(service::FieldParams&& params) const = 0; + virtual service::FieldResult>>> getEdges(service::FieldParams&& params) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::FieldResult> getPageInfo(service::FieldParams&& params) const final + { + return _pimpl->getPageInfo(std::move(params)); + } + + service::FieldResult>>> getEdges(service::FieldParams&& params) const final + { + return _pimpl->getEdges(std::move(params)); + } + + private: + const std::shared_ptr _pimpl; + }; + + AppointmentConnection(std::unique_ptr&& pimpl); + + const std::unique_ptr _pimpl; + +public: + template + AppointmentConnection(std::shared_ptr pimpl) + : AppointmentConnection { std::make_unique>(std::move(pimpl)) } + { + } + + ~AppointmentConnection(); }; } // namespace graphql::today::object diff --git a/samples/separate_nointrospection/AppointmentEdgeObject.cpp b/samples/separate_nointrospection/AppointmentEdgeObject.cpp index 588dfeb0..2d222f4b 100644 --- a/samples/separate_nointrospection/AppointmentEdgeObject.cpp +++ b/samples/separate_nointrospection/AppointmentEdgeObject.cpp @@ -18,7 +18,7 @@ using namespace std::literals; namespace graphql::today { namespace object { -AppointmentEdge::AppointmentEdge() +AppointmentEdge::AppointmentEdge(std::unique_ptr&& pimpl) : service::Object({ "AppointmentEdge" }, { @@ -26,34 +26,29 @@ AppointmentEdge::AppointmentEdge() { R"gql(cursor)gql"sv, [this](service::ResolverParams&& params) { return resolveCursor(std::move(params)); } }, { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } } }) + , _pimpl(std::move(pimpl)) { } -service::FieldResult> AppointmentEdge::getNode(service::FieldParams&&) const +AppointmentEdge::~AppointmentEdge() { - throw std::runtime_error(R"ex(AppointmentEdge::getNode is not implemented)ex"); } service::AwaitableResolver AppointmentEdge::resolveNode(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getNode(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getNode(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult AppointmentEdge::getCursor(service::FieldParams&&) const -{ - throw std::runtime_error(R"ex(AppointmentEdge::getCursor is not implemented)ex"); -} - service::AwaitableResolver AppointmentEdge::resolveCursor(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getCursor(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getCursor(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); diff --git a/samples/separate_nointrospection/AppointmentEdgeObject.h b/samples/separate_nointrospection/AppointmentEdgeObject.h index f8a5236e..8101c409 100644 --- a/samples/separate_nointrospection/AppointmentEdgeObject.h +++ b/samples/separate_nointrospection/AppointmentEdgeObject.h @@ -15,18 +15,53 @@ namespace graphql::today::object { class AppointmentEdge : public service::Object { -protected: - explicit AppointmentEdge(); - -public: - virtual service::FieldResult> getNode(service::FieldParams&& params) const; - virtual service::FieldResult getCursor(service::FieldParams&& params) const; - private: service::AwaitableResolver resolveNode(service::ResolverParams&& params); service::AwaitableResolver resolveCursor(service::ResolverParams&& params); service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + + struct Concept + { + virtual service::FieldResult> getNode(service::FieldParams&& params) const = 0; + virtual service::FieldResult getCursor(service::FieldParams&& params) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::FieldResult> getNode(service::FieldParams&& params) const final + { + return _pimpl->getNode(std::move(params)); + } + + service::FieldResult getCursor(service::FieldParams&& params) const final + { + return _pimpl->getCursor(std::move(params)); + } + + private: + const std::shared_ptr _pimpl; + }; + + AppointmentEdge(std::unique_ptr&& pimpl); + + const std::unique_ptr _pimpl; + +public: + template + AppointmentEdge(std::shared_ptr pimpl) + : AppointmentEdge { std::make_unique>(std::move(pimpl)) } + { + } + + ~AppointmentEdge(); }; } // namespace graphql::today::object diff --git a/samples/separate_nointrospection/AppointmentObject.cpp b/samples/separate_nointrospection/AppointmentObject.cpp index 7b156a39..4327bc1b 100644 --- a/samples/separate_nointrospection/AppointmentObject.cpp +++ b/samples/separate_nointrospection/AppointmentObject.cpp @@ -18,7 +18,7 @@ using namespace std::literals; namespace graphql::today { namespace object { -Appointment::Appointment() +Appointment::Appointment(std::unique_ptr&& pimpl) : service::Object({ "Node", "UnionType", @@ -31,79 +31,59 @@ Appointment::Appointment() { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, { R"gql(forceError)gql"sv, [this](service::ResolverParams&& params) { return resolveForceError(std::move(params)); } } }) + , _pimpl(std::move(pimpl)) { } -service::FieldResult Appointment::getId(service::FieldParams&&) const +Appointment::~Appointment() { - throw std::runtime_error(R"ex(Appointment::getId is not implemented)ex"); } service::AwaitableResolver Appointment::resolveId(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getId(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getId(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult> Appointment::getWhen(service::FieldParams&&) const -{ - throw std::runtime_error(R"ex(Appointment::getWhen is not implemented)ex"); -} - service::AwaitableResolver Appointment::resolveWhen(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getWhen(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getWhen(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult> Appointment::getSubject(service::FieldParams&&) const -{ - throw std::runtime_error(R"ex(Appointment::getSubject is not implemented)ex"); -} - service::AwaitableResolver Appointment::resolveSubject(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getSubject(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getSubject(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult Appointment::getIsNow(service::FieldParams&&) const -{ - throw std::runtime_error(R"ex(Appointment::getIsNow is not implemented)ex"); -} - service::AwaitableResolver Appointment::resolveIsNow(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getIsNow(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getIsNow(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult> Appointment::getForceError(service::FieldParams&&) const -{ - throw std::runtime_error(R"ex(Appointment::getForceError is not implemented)ex"); -} - service::AwaitableResolver Appointment::resolveForceError(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getForceError(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getForceError(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); diff --git a/samples/separate_nointrospection/AppointmentObject.h b/samples/separate_nointrospection/AppointmentObject.h index efdd3500..c7449b1d 100644 --- a/samples/separate_nointrospection/AppointmentObject.h +++ b/samples/separate_nointrospection/AppointmentObject.h @@ -14,18 +14,7 @@ namespace graphql::today::object { class Appointment : public service::Object - , public Node { -protected: - explicit Appointment(); - -public: - service::FieldResult getId(service::FieldParams&& params) const override; - virtual service::FieldResult> getWhen(service::FieldParams&& params) const; - virtual service::FieldResult> getSubject(service::FieldParams&& params) const; - virtual service::FieldResult getIsNow(service::FieldParams&& params) const; - virtual service::FieldResult> getForceError(service::FieldParams&& params) const; - private: service::AwaitableResolver resolveId(service::ResolverParams&& params); service::AwaitableResolver resolveWhen(service::ResolverParams&& params); @@ -34,6 +23,66 @@ class Appointment service::AwaitableResolver resolveForceError(service::ResolverParams&& params); service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + + struct Concept + : Node + { + virtual service::FieldResult> getWhen(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getSubject(service::FieldParams&& params) const = 0; + virtual service::FieldResult getIsNow(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getForceError(service::FieldParams&& params) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::FieldResult getId(service::FieldParams&& params) const final + { + return _pimpl->getId(std::move(params)); + } + + service::FieldResult> getWhen(service::FieldParams&& params) const final + { + return _pimpl->getWhen(std::move(params)); + } + + service::FieldResult> getSubject(service::FieldParams&& params) const final + { + return _pimpl->getSubject(std::move(params)); + } + + service::FieldResult getIsNow(service::FieldParams&& params) const final + { + return _pimpl->getIsNow(std::move(params)); + } + + service::FieldResult> getForceError(service::FieldParams&& params) const final + { + return _pimpl->getForceError(std::move(params)); + } + + private: + const std::shared_ptr _pimpl; + }; + + Appointment(std::unique_ptr&& pimpl); + + const std::unique_ptr _pimpl; + +public: + template + Appointment(std::shared_ptr pimpl) + : Appointment { std::make_unique>(std::move(pimpl)) } + { + } + + ~Appointment(); }; } // namespace graphql::today::object diff --git a/samples/separate_nointrospection/CompleteTaskPayloadObject.cpp b/samples/separate_nointrospection/CompleteTaskPayloadObject.cpp index d3a742ac..ca0f6f76 100644 --- a/samples/separate_nointrospection/CompleteTaskPayloadObject.cpp +++ b/samples/separate_nointrospection/CompleteTaskPayloadObject.cpp @@ -18,7 +18,7 @@ using namespace std::literals; namespace graphql::today { namespace object { -CompleteTaskPayload::CompleteTaskPayload() +CompleteTaskPayload::CompleteTaskPayload(std::unique_ptr&& pimpl) : service::Object({ "CompleteTaskPayload" }, { @@ -26,34 +26,29 @@ CompleteTaskPayload::CompleteTaskPayload() { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, { R"gql(clientMutationId)gql"sv, [this](service::ResolverParams&& params) { return resolveClientMutationId(std::move(params)); } } }) + , _pimpl(std::move(pimpl)) { } -service::FieldResult> CompleteTaskPayload::getTask(service::FieldParams&&) const +CompleteTaskPayload::~CompleteTaskPayload() { - throw std::runtime_error(R"ex(CompleteTaskPayload::getTask is not implemented)ex"); } service::AwaitableResolver CompleteTaskPayload::resolveTask(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getTask(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getTask(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult> CompleteTaskPayload::getClientMutationId(service::FieldParams&&) const -{ - throw std::runtime_error(R"ex(CompleteTaskPayload::getClientMutationId is not implemented)ex"); -} - service::AwaitableResolver CompleteTaskPayload::resolveClientMutationId(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getClientMutationId(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getClientMutationId(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); diff --git a/samples/separate_nointrospection/CompleteTaskPayloadObject.h b/samples/separate_nointrospection/CompleteTaskPayloadObject.h index c44afd16..597d9f2d 100644 --- a/samples/separate_nointrospection/CompleteTaskPayloadObject.h +++ b/samples/separate_nointrospection/CompleteTaskPayloadObject.h @@ -15,18 +15,53 @@ namespace graphql::today::object { class CompleteTaskPayload : public service::Object { -protected: - explicit CompleteTaskPayload(); - -public: - virtual service::FieldResult> getTask(service::FieldParams&& params) const; - virtual service::FieldResult> getClientMutationId(service::FieldParams&& params) const; - private: service::AwaitableResolver resolveTask(service::ResolverParams&& params); service::AwaitableResolver resolveClientMutationId(service::ResolverParams&& params); service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + + struct Concept + { + virtual service::FieldResult> getTask(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getClientMutationId(service::FieldParams&& params) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::FieldResult> getTask(service::FieldParams&& params) const final + { + return _pimpl->getTask(std::move(params)); + } + + service::FieldResult> getClientMutationId(service::FieldParams&& params) const final + { + return _pimpl->getClientMutationId(std::move(params)); + } + + private: + const std::shared_ptr _pimpl; + }; + + CompleteTaskPayload(std::unique_ptr&& pimpl); + + const std::unique_ptr _pimpl; + +public: + template + CompleteTaskPayload(std::shared_ptr pimpl) + : CompleteTaskPayload { std::make_unique>(std::move(pimpl)) } + { + } + + ~CompleteTaskPayload(); }; } // namespace graphql::today::object diff --git a/samples/separate_nointrospection/ExpensiveObject.cpp b/samples/separate_nointrospection/ExpensiveObject.cpp index 2bc006c6..51cc5140 100644 --- a/samples/separate_nointrospection/ExpensiveObject.cpp +++ b/samples/separate_nointrospection/ExpensiveObject.cpp @@ -18,26 +18,26 @@ using namespace std::literals; namespace graphql::today { namespace object { -Expensive::Expensive() +Expensive::Expensive(std::unique_ptr&& pimpl) : service::Object({ "Expensive" }, { { R"gql(order)gql"sv, [this](service::ResolverParams&& params) { return resolveOrder(std::move(params)); } }, { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } } }) + , _pimpl(std::move(pimpl)) { } -service::FieldResult Expensive::getOrder(service::FieldParams&&) const +Expensive::~Expensive() { - throw std::runtime_error(R"ex(Expensive::getOrder is not implemented)ex"); } service::AwaitableResolver Expensive::resolveOrder(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getOrder(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getOrder(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); diff --git a/samples/separate_nointrospection/ExpensiveObject.h b/samples/separate_nointrospection/ExpensiveObject.h index 4c30bba0..60682b27 100644 --- a/samples/separate_nointrospection/ExpensiveObject.h +++ b/samples/separate_nointrospection/ExpensiveObject.h @@ -15,16 +15,46 @@ namespace graphql::today::object { class Expensive : public service::Object { -protected: - explicit Expensive(); - -public: - virtual service::FieldResult getOrder(service::FieldParams&& params) const; - private: service::AwaitableResolver resolveOrder(service::ResolverParams&& params); service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + + struct Concept + { + virtual service::FieldResult getOrder(service::FieldParams&& params) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::FieldResult getOrder(service::FieldParams&& params) const final + { + return _pimpl->getOrder(std::move(params)); + } + + private: + const std::shared_ptr _pimpl; + }; + + Expensive(std::unique_ptr&& pimpl); + + const std::unique_ptr _pimpl; + +public: + template + Expensive(std::shared_ptr pimpl) + : Expensive { std::make_unique>(std::move(pimpl)) } + { + } + + ~Expensive(); }; } // namespace graphql::today::object diff --git a/samples/separate_nointrospection/FolderConnectionObject.cpp b/samples/separate_nointrospection/FolderConnectionObject.cpp index 2d7ac269..802380da 100644 --- a/samples/separate_nointrospection/FolderConnectionObject.cpp +++ b/samples/separate_nointrospection/FolderConnectionObject.cpp @@ -18,7 +18,7 @@ using namespace std::literals; namespace graphql::today { namespace object { -FolderConnection::FolderConnection() +FolderConnection::FolderConnection(std::unique_ptr&& pimpl) : service::Object({ "FolderConnection" }, { @@ -26,34 +26,29 @@ FolderConnection::FolderConnection() { R"gql(pageInfo)gql"sv, [this](service::ResolverParams&& params) { return resolvePageInfo(std::move(params)); } }, { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } } }) + , _pimpl(std::move(pimpl)) { } -service::FieldResult> FolderConnection::getPageInfo(service::FieldParams&&) const +FolderConnection::~FolderConnection() { - throw std::runtime_error(R"ex(FolderConnection::getPageInfo is not implemented)ex"); } service::AwaitableResolver FolderConnection::resolvePageInfo(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getPageInfo(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getPageInfo(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult>>> FolderConnection::getEdges(service::FieldParams&&) const -{ - throw std::runtime_error(R"ex(FolderConnection::getEdges is not implemented)ex"); -} - service::AwaitableResolver FolderConnection::resolveEdges(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getEdges(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getEdges(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); diff --git a/samples/separate_nointrospection/FolderConnectionObject.h b/samples/separate_nointrospection/FolderConnectionObject.h index 74477723..22ec4432 100644 --- a/samples/separate_nointrospection/FolderConnectionObject.h +++ b/samples/separate_nointrospection/FolderConnectionObject.h @@ -15,18 +15,53 @@ namespace graphql::today::object { class FolderConnection : public service::Object { -protected: - explicit FolderConnection(); - -public: - virtual service::FieldResult> getPageInfo(service::FieldParams&& params) const; - virtual service::FieldResult>>> getEdges(service::FieldParams&& params) const; - private: service::AwaitableResolver resolvePageInfo(service::ResolverParams&& params); service::AwaitableResolver resolveEdges(service::ResolverParams&& params); service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + + struct Concept + { + virtual service::FieldResult> getPageInfo(service::FieldParams&& params) const = 0; + virtual service::FieldResult>>> getEdges(service::FieldParams&& params) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::FieldResult> getPageInfo(service::FieldParams&& params) const final + { + return _pimpl->getPageInfo(std::move(params)); + } + + service::FieldResult>>> getEdges(service::FieldParams&& params) const final + { + return _pimpl->getEdges(std::move(params)); + } + + private: + const std::shared_ptr _pimpl; + }; + + FolderConnection(std::unique_ptr&& pimpl); + + const std::unique_ptr _pimpl; + +public: + template + FolderConnection(std::shared_ptr pimpl) + : FolderConnection { std::make_unique>(std::move(pimpl)) } + { + } + + ~FolderConnection(); }; } // namespace graphql::today::object diff --git a/samples/separate_nointrospection/FolderEdgeObject.cpp b/samples/separate_nointrospection/FolderEdgeObject.cpp index 06672e4b..e4e63fb1 100644 --- a/samples/separate_nointrospection/FolderEdgeObject.cpp +++ b/samples/separate_nointrospection/FolderEdgeObject.cpp @@ -18,7 +18,7 @@ using namespace std::literals; namespace graphql::today { namespace object { -FolderEdge::FolderEdge() +FolderEdge::FolderEdge(std::unique_ptr&& pimpl) : service::Object({ "FolderEdge" }, { @@ -26,34 +26,29 @@ FolderEdge::FolderEdge() { R"gql(cursor)gql"sv, [this](service::ResolverParams&& params) { return resolveCursor(std::move(params)); } }, { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } } }) + , _pimpl(std::move(pimpl)) { } -service::FieldResult> FolderEdge::getNode(service::FieldParams&&) const +FolderEdge::~FolderEdge() { - throw std::runtime_error(R"ex(FolderEdge::getNode is not implemented)ex"); } service::AwaitableResolver FolderEdge::resolveNode(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getNode(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getNode(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult FolderEdge::getCursor(service::FieldParams&&) const -{ - throw std::runtime_error(R"ex(FolderEdge::getCursor is not implemented)ex"); -} - service::AwaitableResolver FolderEdge::resolveCursor(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getCursor(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getCursor(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); diff --git a/samples/separate_nointrospection/FolderEdgeObject.h b/samples/separate_nointrospection/FolderEdgeObject.h index 52ab2627..19b4d78b 100644 --- a/samples/separate_nointrospection/FolderEdgeObject.h +++ b/samples/separate_nointrospection/FolderEdgeObject.h @@ -15,18 +15,53 @@ namespace graphql::today::object { class FolderEdge : public service::Object { -protected: - explicit FolderEdge(); - -public: - virtual service::FieldResult> getNode(service::FieldParams&& params) const; - virtual service::FieldResult getCursor(service::FieldParams&& params) const; - private: service::AwaitableResolver resolveNode(service::ResolverParams&& params); service::AwaitableResolver resolveCursor(service::ResolverParams&& params); service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + + struct Concept + { + virtual service::FieldResult> getNode(service::FieldParams&& params) const = 0; + virtual service::FieldResult getCursor(service::FieldParams&& params) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::FieldResult> getNode(service::FieldParams&& params) const final + { + return _pimpl->getNode(std::move(params)); + } + + service::FieldResult getCursor(service::FieldParams&& params) const final + { + return _pimpl->getCursor(std::move(params)); + } + + private: + const std::shared_ptr _pimpl; + }; + + FolderEdge(std::unique_ptr&& pimpl); + + const std::unique_ptr _pimpl; + +public: + template + FolderEdge(std::shared_ptr pimpl) + : FolderEdge { std::make_unique>(std::move(pimpl)) } + { + } + + ~FolderEdge(); }; } // namespace graphql::today::object diff --git a/samples/separate_nointrospection/FolderObject.cpp b/samples/separate_nointrospection/FolderObject.cpp index 3fadea37..bccaf182 100644 --- a/samples/separate_nointrospection/FolderObject.cpp +++ b/samples/separate_nointrospection/FolderObject.cpp @@ -18,7 +18,7 @@ using namespace std::literals; namespace graphql::today { namespace object { -Folder::Folder() +Folder::Folder(std::unique_ptr&& pimpl) : service::Object({ "Node", "UnionType", @@ -29,49 +29,39 @@ Folder::Folder() { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, { R"gql(unreadCount)gql"sv, [this](service::ResolverParams&& params) { return resolveUnreadCount(std::move(params)); } } }) + , _pimpl(std::move(pimpl)) { } -service::FieldResult Folder::getId(service::FieldParams&&) const +Folder::~Folder() { - throw std::runtime_error(R"ex(Folder::getId is not implemented)ex"); } service::AwaitableResolver Folder::resolveId(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getId(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getId(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult> Folder::getName(service::FieldParams&&) const -{ - throw std::runtime_error(R"ex(Folder::getName is not implemented)ex"); -} - service::AwaitableResolver Folder::resolveName(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getName(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getName(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult Folder::getUnreadCount(service::FieldParams&&) const -{ - throw std::runtime_error(R"ex(Folder::getUnreadCount is not implemented)ex"); -} - service::AwaitableResolver Folder::resolveUnreadCount(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getUnreadCount(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getUnreadCount(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); diff --git a/samples/separate_nointrospection/FolderObject.h b/samples/separate_nointrospection/FolderObject.h index bd1999ba..91f0fcee 100644 --- a/samples/separate_nointrospection/FolderObject.h +++ b/samples/separate_nointrospection/FolderObject.h @@ -14,22 +14,61 @@ namespace graphql::today::object { class Folder : public service::Object - , public Node { -protected: - explicit Folder(); - -public: - service::FieldResult getId(service::FieldParams&& params) const override; - virtual service::FieldResult> getName(service::FieldParams&& params) const; - virtual service::FieldResult getUnreadCount(service::FieldParams&& params) const; - private: service::AwaitableResolver resolveId(service::ResolverParams&& params); service::AwaitableResolver resolveName(service::ResolverParams&& params); service::AwaitableResolver resolveUnreadCount(service::ResolverParams&& params); service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + + struct Concept + : Node + { + virtual service::FieldResult> getName(service::FieldParams&& params) const = 0; + virtual service::FieldResult getUnreadCount(service::FieldParams&& params) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::FieldResult getId(service::FieldParams&& params) const final + { + return _pimpl->getId(std::move(params)); + } + + service::FieldResult> getName(service::FieldParams&& params) const final + { + return _pimpl->getName(std::move(params)); + } + + service::FieldResult getUnreadCount(service::FieldParams&& params) const final + { + return _pimpl->getUnreadCount(std::move(params)); + } + + private: + const std::shared_ptr _pimpl; + }; + + Folder(std::unique_ptr&& pimpl); + + const std::unique_ptr _pimpl; + +public: + template + Folder(std::shared_ptr pimpl) + : Folder { std::make_unique>(std::move(pimpl)) } + { + } + + ~Folder(); }; } // namespace graphql::today::object diff --git a/samples/separate_nointrospection/MutationObject.cpp b/samples/separate_nointrospection/MutationObject.cpp index aa8d858b..9914a1e2 100644 --- a/samples/separate_nointrospection/MutationObject.cpp +++ b/samples/separate_nointrospection/MutationObject.cpp @@ -18,7 +18,7 @@ using namespace std::literals; namespace graphql::today { namespace object { -Mutation::Mutation() +Mutation::Mutation(std::unique_ptr&& pimpl) : service::Object({ "Mutation" }, { @@ -26,12 +26,12 @@ Mutation::Mutation() { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, { R"gql(completeTask)gql"sv, [this](service::ResolverParams&& params) { return resolveCompleteTask(std::move(params)); } } }) + , _pimpl(std::move(pimpl)) { } -service::FieldResult> Mutation::applyCompleteTask(service::FieldParams&&, CompleteTaskInput&&) const +Mutation::~Mutation() { - throw std::runtime_error(R"ex(Mutation::applyCompleteTask is not implemented)ex"); } service::AwaitableResolver Mutation::resolveCompleteTask(service::ResolverParams&& params) @@ -39,23 +39,18 @@ service::AwaitableResolver Mutation::resolveCompleteTask(service::ResolverParams auto argInput = service::ModifiedArgument::require("input", params.arguments); std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = applyCompleteTask(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argInput)); + auto result = _pimpl->applyCompleteTask(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argInput)); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult Mutation::applySetFloat(service::FieldParams&&, response::FloatType&&) const -{ - throw std::runtime_error(R"ex(Mutation::applySetFloat is not implemented)ex"); -} - service::AwaitableResolver Mutation::resolveSetFloat(service::ResolverParams&& params) { auto argValue = service::ModifiedArgument::require("value", params.arguments); std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = applySetFloat(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argValue)); + auto result = _pimpl->applySetFloat(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argValue)); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); diff --git a/samples/separate_nointrospection/MutationObject.h b/samples/separate_nointrospection/MutationObject.h index b72577ea..afa82edb 100644 --- a/samples/separate_nointrospection/MutationObject.h +++ b/samples/separate_nointrospection/MutationObject.h @@ -15,18 +15,53 @@ namespace graphql::today::object { class Mutation : public service::Object { -protected: - explicit Mutation(); - -public: - virtual service::FieldResult> applyCompleteTask(service::FieldParams&& params, CompleteTaskInput&& inputArg) const; - virtual service::FieldResult applySetFloat(service::FieldParams&& params, response::FloatType&& valueArg) const; - private: service::AwaitableResolver resolveCompleteTask(service::ResolverParams&& params); service::AwaitableResolver resolveSetFloat(service::ResolverParams&& params); service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + + struct Concept + { + virtual service::FieldResult> applyCompleteTask(service::FieldParams&& params, CompleteTaskInput&& inputArg) const = 0; + virtual service::FieldResult applySetFloat(service::FieldParams&& params, response::FloatType&& valueArg) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::FieldResult> applyCompleteTask(service::FieldParams&& params, CompleteTaskInput&& inputArg) const final + { + return _pimpl->applyCompleteTask(std::move(params), std::move(inputArg)); + } + + service::FieldResult applySetFloat(service::FieldParams&& params, response::FloatType&& valueArg) const final + { + return _pimpl->applySetFloat(std::move(params), std::move(valueArg)); + } + + private: + const std::shared_ptr _pimpl; + }; + + Mutation(std::unique_ptr&& pimpl); + + const std::unique_ptr _pimpl; + +public: + template + Mutation(std::shared_ptr pimpl) + : Mutation { std::make_unique>(std::move(pimpl)) } + { + } + + ~Mutation(); }; } // namespace graphql::today::object diff --git a/samples/separate_nointrospection/NestedTypeObject.cpp b/samples/separate_nointrospection/NestedTypeObject.cpp index be7f9b6a..db956679 100644 --- a/samples/separate_nointrospection/NestedTypeObject.cpp +++ b/samples/separate_nointrospection/NestedTypeObject.cpp @@ -18,7 +18,7 @@ using namespace std::literals; namespace graphql::today { namespace object { -NestedType::NestedType() +NestedType::NestedType(std::unique_ptr&& pimpl) : service::Object({ "NestedType" }, { @@ -26,34 +26,29 @@ NestedType::NestedType() { R"gql(nested)gql"sv, [this](service::ResolverParams&& params) { return resolveNested(std::move(params)); } }, { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } } }) + , _pimpl(std::move(pimpl)) { } -service::FieldResult NestedType::getDepth(service::FieldParams&&) const +NestedType::~NestedType() { - throw std::runtime_error(R"ex(NestedType::getDepth is not implemented)ex"); } service::AwaitableResolver NestedType::resolveDepth(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getDepth(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getDepth(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult> NestedType::getNested(service::FieldParams&&) const -{ - throw std::runtime_error(R"ex(NestedType::getNested is not implemented)ex"); -} - service::AwaitableResolver NestedType::resolveNested(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getNested(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getNested(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); diff --git a/samples/separate_nointrospection/NestedTypeObject.h b/samples/separate_nointrospection/NestedTypeObject.h index eb06cf04..47348d9d 100644 --- a/samples/separate_nointrospection/NestedTypeObject.h +++ b/samples/separate_nointrospection/NestedTypeObject.h @@ -15,18 +15,53 @@ namespace graphql::today::object { class NestedType : public service::Object { -protected: - explicit NestedType(); - -public: - virtual service::FieldResult getDepth(service::FieldParams&& params) const; - virtual service::FieldResult> getNested(service::FieldParams&& params) const; - private: service::AwaitableResolver resolveDepth(service::ResolverParams&& params); service::AwaitableResolver resolveNested(service::ResolverParams&& params); service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + + struct Concept + { + virtual service::FieldResult getDepth(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getNested(service::FieldParams&& params) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::FieldResult getDepth(service::FieldParams&& params) const final + { + return _pimpl->getDepth(std::move(params)); + } + + service::FieldResult> getNested(service::FieldParams&& params) const final + { + return _pimpl->getNested(std::move(params)); + } + + private: + const std::shared_ptr _pimpl; + }; + + NestedType(std::unique_ptr&& pimpl); + + const std::unique_ptr _pimpl; + +public: + template + NestedType(std::shared_ptr pimpl) + : NestedType { std::make_unique>(std::move(pimpl)) } + { + } + + ~NestedType(); }; } // namespace graphql::today::object diff --git a/samples/separate_nointrospection/PageInfoObject.cpp b/samples/separate_nointrospection/PageInfoObject.cpp index 900d73a5..2c222dce 100644 --- a/samples/separate_nointrospection/PageInfoObject.cpp +++ b/samples/separate_nointrospection/PageInfoObject.cpp @@ -18,7 +18,7 @@ using namespace std::literals; namespace graphql::today { namespace object { -PageInfo::PageInfo() +PageInfo::PageInfo(std::unique_ptr&& pimpl) : service::Object({ "PageInfo" }, { @@ -26,34 +26,29 @@ PageInfo::PageInfo() { R"gql(hasNextPage)gql"sv, [this](service::ResolverParams&& params) { return resolveHasNextPage(std::move(params)); } }, { R"gql(hasPreviousPage)gql"sv, [this](service::ResolverParams&& params) { return resolveHasPreviousPage(std::move(params)); } } }) + , _pimpl(std::move(pimpl)) { } -service::FieldResult PageInfo::getHasNextPage(service::FieldParams&&) const +PageInfo::~PageInfo() { - throw std::runtime_error(R"ex(PageInfo::getHasNextPage is not implemented)ex"); } service::AwaitableResolver PageInfo::resolveHasNextPage(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getHasNextPage(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getHasNextPage(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult PageInfo::getHasPreviousPage(service::FieldParams&&) const -{ - throw std::runtime_error(R"ex(PageInfo::getHasPreviousPage is not implemented)ex"); -} - service::AwaitableResolver PageInfo::resolveHasPreviousPage(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getHasPreviousPage(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getHasPreviousPage(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); diff --git a/samples/separate_nointrospection/PageInfoObject.h b/samples/separate_nointrospection/PageInfoObject.h index b2d3a844..bacc5b21 100644 --- a/samples/separate_nointrospection/PageInfoObject.h +++ b/samples/separate_nointrospection/PageInfoObject.h @@ -15,18 +15,53 @@ namespace graphql::today::object { class PageInfo : public service::Object { -protected: - explicit PageInfo(); - -public: - virtual service::FieldResult getHasNextPage(service::FieldParams&& params) const; - virtual service::FieldResult getHasPreviousPage(service::FieldParams&& params) const; - private: service::AwaitableResolver resolveHasNextPage(service::ResolverParams&& params); service::AwaitableResolver resolveHasPreviousPage(service::ResolverParams&& params); service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + + struct Concept + { + virtual service::FieldResult getHasNextPage(service::FieldParams&& params) const = 0; + virtual service::FieldResult getHasPreviousPage(service::FieldParams&& params) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::FieldResult getHasNextPage(service::FieldParams&& params) const final + { + return _pimpl->getHasNextPage(std::move(params)); + } + + service::FieldResult getHasPreviousPage(service::FieldParams&& params) const final + { + return _pimpl->getHasPreviousPage(std::move(params)); + } + + private: + const std::shared_ptr _pimpl; + }; + + PageInfo(std::unique_ptr&& pimpl); + + const std::unique_ptr _pimpl; + +public: + template + PageInfo(std::shared_ptr pimpl) + : PageInfo { std::make_unique>(std::move(pimpl)) } + { + } + + ~PageInfo(); }; } // namespace graphql::today::object diff --git a/samples/separate_nointrospection/QueryObject.cpp b/samples/separate_nointrospection/QueryObject.cpp index d3e98cb7..df92ce11 100644 --- a/samples/separate_nointrospection/QueryObject.cpp +++ b/samples/separate_nointrospection/QueryObject.cpp @@ -18,7 +18,7 @@ using namespace std::literals; namespace graphql::today { namespace object { -Query::Query() +Query::Query(std::unique_ptr&& pimpl) : service::Object({ "Query" }, { @@ -36,12 +36,12 @@ Query::Query() { R"gql(appointmentsById)gql"sv, [this](service::ResolverParams&& params) { return resolveAppointmentsById(std::move(params)); } }, { R"gql(unreadCountsById)gql"sv, [this](service::ResolverParams&& params) { return resolveUnreadCountsById(std::move(params)); } } }) + , _pimpl(std::move(pimpl)) { } -service::FieldResult> Query::getNode(service::FieldParams&&, response::IdType&&) const +Query::~Query() { - throw std::runtime_error(R"ex(Query::getNode is not implemented)ex"); } service::AwaitableResolver Query::resolveNode(service::ResolverParams&& params) @@ -49,17 +49,12 @@ service::AwaitableResolver Query::resolveNode(service::ResolverParams&& params) auto argId = service::ModifiedArgument::require("id", params.arguments); std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getNode(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argId)); + auto result = _pimpl->getNode(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argId)); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult> Query::getAppointments(service::FieldParams&&, std::optional&&, std::optional&&, std::optional&&, std::optional&&) const -{ - throw std::runtime_error(R"ex(Query::getAppointments is not implemented)ex"); -} - service::AwaitableResolver Query::resolveAppointments(service::ResolverParams&& params) { auto argFirst = service::ModifiedArgument::require("first", params.arguments); @@ -68,17 +63,12 @@ service::AwaitableResolver Query::resolveAppointments(service::ResolverParams&& auto argBefore = service::ModifiedArgument::require("before", params.arguments); std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getAppointments(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argFirst), std::move(argAfter), std::move(argLast), std::move(argBefore)); + auto result = _pimpl->getAppointments(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argFirst), std::move(argAfter), std::move(argLast), std::move(argBefore)); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult> Query::getTasks(service::FieldParams&&, std::optional&&, std::optional&&, std::optional&&, std::optional&&) const -{ - throw std::runtime_error(R"ex(Query::getTasks is not implemented)ex"); -} - service::AwaitableResolver Query::resolveTasks(service::ResolverParams&& params) { auto argFirst = service::ModifiedArgument::require("first", params.arguments); @@ -87,17 +77,12 @@ service::AwaitableResolver Query::resolveTasks(service::ResolverParams&& params) auto argBefore = service::ModifiedArgument::require("before", params.arguments); std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getTasks(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argFirst), std::move(argAfter), std::move(argLast), std::move(argBefore)); + auto result = _pimpl->getTasks(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argFirst), std::move(argAfter), std::move(argLast), std::move(argBefore)); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult> Query::getUnreadCounts(service::FieldParams&&, std::optional&&, std::optional&&, std::optional&&, std::optional&&) const -{ - throw std::runtime_error(R"ex(Query::getUnreadCounts is not implemented)ex"); -} - service::AwaitableResolver Query::resolveUnreadCounts(service::ResolverParams&& params) { auto argFirst = service::ModifiedArgument::require("first", params.arguments); @@ -106,17 +91,12 @@ service::AwaitableResolver Query::resolveUnreadCounts(service::ResolverParams&& auto argBefore = service::ModifiedArgument::require("before", params.arguments); std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getUnreadCounts(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argFirst), std::move(argAfter), std::move(argLast), std::move(argBefore)); + auto result = _pimpl->getUnreadCounts(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argFirst), std::move(argAfter), std::move(argLast), std::move(argBefore)); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult>> Query::getAppointmentsById(service::FieldParams&&, std::vector&&) const -{ - throw std::runtime_error(R"ex(Query::getAppointmentsById is not implemented)ex"); -} - service::AwaitableResolver Query::resolveAppointmentsById(service::ResolverParams&& params) { const auto defaultArguments = []() @@ -144,115 +124,80 @@ service::AwaitableResolver Query::resolveAppointmentsById(service::ResolverParam : service::ModifiedArgument::require("ids", defaultArguments)); std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getAppointmentsById(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argIds)); + auto result = _pimpl->getAppointmentsById(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argIds)); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult>> Query::getTasksById(service::FieldParams&&, std::vector&&) const -{ - throw std::runtime_error(R"ex(Query::getTasksById is not implemented)ex"); -} - service::AwaitableResolver Query::resolveTasksById(service::ResolverParams&& params) { auto argIds = service::ModifiedArgument::require("ids", params.arguments); std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getTasksById(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argIds)); + auto result = _pimpl->getTasksById(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argIds)); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult>> Query::getUnreadCountsById(service::FieldParams&&, std::vector&&) const -{ - throw std::runtime_error(R"ex(Query::getUnreadCountsById is not implemented)ex"); -} - service::AwaitableResolver Query::resolveUnreadCountsById(service::ResolverParams&& params) { auto argIds = service::ModifiedArgument::require("ids", params.arguments); std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getUnreadCountsById(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argIds)); + auto result = _pimpl->getUnreadCountsById(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argIds)); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult> Query::getNested(service::FieldParams&&) const -{ - throw std::runtime_error(R"ex(Query::getNested is not implemented)ex"); -} - service::AwaitableResolver Query::resolveNested(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getNested(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getNested(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult Query::getUnimplemented(service::FieldParams&&) const -{ - throw std::runtime_error(R"ex(Query::getUnimplemented is not implemented)ex"); -} - service::AwaitableResolver Query::resolveUnimplemented(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getUnimplemented(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getUnimplemented(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult>> Query::getExpensive(service::FieldParams&&) const -{ - throw std::runtime_error(R"ex(Query::getExpensive is not implemented)ex"); -} - service::AwaitableResolver Query::resolveExpensive(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getExpensive(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getExpensive(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult Query::getTestTaskState(service::FieldParams&&) const -{ - throw std::runtime_error(R"ex(Query::getTestTaskState is not implemented)ex"); -} - service::AwaitableResolver Query::resolveTestTaskState(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getTestTaskState(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getTestTaskState(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult>> Query::getAnyType(service::FieldParams&&, std::vector&&) const -{ - throw std::runtime_error(R"ex(Query::getAnyType is not implemented)ex"); -} - service::AwaitableResolver Query::resolveAnyType(service::ResolverParams&& params) { auto argIds = service::ModifiedArgument::require("ids", params.arguments); std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getAnyType(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argIds)); + auto result = _pimpl->getAnyType(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argIds)); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); diff --git a/samples/separate_nointrospection/QueryObject.h b/samples/separate_nointrospection/QueryObject.h index 3390090b..19690aa2 100644 --- a/samples/separate_nointrospection/QueryObject.h +++ b/samples/separate_nointrospection/QueryObject.h @@ -15,23 +15,6 @@ namespace graphql::today::object { class Query : public service::Object { -protected: - explicit Query(); - -public: - virtual service::FieldResult> getNode(service::FieldParams&& params, response::IdType&& idArg) const; - virtual service::FieldResult> getAppointments(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const; - virtual service::FieldResult> getTasks(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const; - virtual service::FieldResult> getUnreadCounts(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const; - virtual service::FieldResult>> getAppointmentsById(service::FieldParams&& params, std::vector&& idsArg) const; - virtual service::FieldResult>> getTasksById(service::FieldParams&& params, std::vector&& idsArg) const; - virtual service::FieldResult>> getUnreadCountsById(service::FieldParams&& params, std::vector&& idsArg) const; - virtual service::FieldResult> getNested(service::FieldParams&& params) const; - virtual service::FieldResult getUnimplemented(service::FieldParams&& params) const; - virtual service::FieldResult>> getExpensive(service::FieldParams&& params) const; - virtual service::FieldResult getTestTaskState(service::FieldParams&& params) const; - virtual service::FieldResult>> getAnyType(service::FieldParams&& params, std::vector&& idsArg) const; - private: service::AwaitableResolver resolveNode(service::ResolverParams&& params); service::AwaitableResolver resolveAppointments(service::ResolverParams&& params); @@ -47,6 +30,108 @@ class Query service::AwaitableResolver resolveAnyType(service::ResolverParams&& params); service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + + struct Concept + { + virtual service::FieldResult> getNode(service::FieldParams&& params, response::IdType&& idArg) const = 0; + virtual service::FieldResult> getAppointments(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const = 0; + virtual service::FieldResult> getTasks(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const = 0; + virtual service::FieldResult> getUnreadCounts(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const = 0; + virtual service::FieldResult>> getAppointmentsById(service::FieldParams&& params, std::vector&& idsArg) const = 0; + virtual service::FieldResult>> getTasksById(service::FieldParams&& params, std::vector&& idsArg) const = 0; + virtual service::FieldResult>> getUnreadCountsById(service::FieldParams&& params, std::vector&& idsArg) const = 0; + virtual service::FieldResult> getNested(service::FieldParams&& params) const = 0; + virtual service::FieldResult getUnimplemented(service::FieldParams&& params) const = 0; + virtual service::FieldResult>> getExpensive(service::FieldParams&& params) const = 0; + virtual service::FieldResult getTestTaskState(service::FieldParams&& params) const = 0; + virtual service::FieldResult>> getAnyType(service::FieldParams&& params, std::vector&& idsArg) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::FieldResult> getNode(service::FieldParams&& params, response::IdType&& idArg) const final + { + return _pimpl->getNode(std::move(params), std::move(idArg)); + } + + service::FieldResult> getAppointments(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const final + { + return _pimpl->getAppointments(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)); + } + + service::FieldResult> getTasks(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const final + { + return _pimpl->getTasks(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)); + } + + service::FieldResult> getUnreadCounts(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const final + { + return _pimpl->getUnreadCounts(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)); + } + + service::FieldResult>> getAppointmentsById(service::FieldParams&& params, std::vector&& idsArg) const final + { + return _pimpl->getAppointmentsById(std::move(params), std::move(idsArg)); + } + + service::FieldResult>> getTasksById(service::FieldParams&& params, std::vector&& idsArg) const final + { + return _pimpl->getTasksById(std::move(params), std::move(idsArg)); + } + + service::FieldResult>> getUnreadCountsById(service::FieldParams&& params, std::vector&& idsArg) const final + { + return _pimpl->getUnreadCountsById(std::move(params), std::move(idsArg)); + } + + service::FieldResult> getNested(service::FieldParams&& params) const final + { + return _pimpl->getNested(std::move(params)); + } + + service::FieldResult getUnimplemented(service::FieldParams&& params) const final + { + return _pimpl->getUnimplemented(std::move(params)); + } + + service::FieldResult>> getExpensive(service::FieldParams&& params) const final + { + return _pimpl->getExpensive(std::move(params)); + } + + service::FieldResult getTestTaskState(service::FieldParams&& params) const final + { + return _pimpl->getTestTaskState(std::move(params)); + } + + service::FieldResult>> getAnyType(service::FieldParams&& params, std::vector&& idsArg) const final + { + return _pimpl->getAnyType(std::move(params), std::move(idsArg)); + } + + private: + const std::shared_ptr _pimpl; + }; + + Query(std::unique_ptr&& pimpl); + + const std::unique_ptr _pimpl; + +public: + template + Query(std::shared_ptr pimpl) + : Query { std::make_unique>(std::move(pimpl)) } + { + } + + ~Query(); }; } // namespace graphql::today::object diff --git a/samples/separate_nointrospection/SubscriptionObject.cpp b/samples/separate_nointrospection/SubscriptionObject.cpp index 746a6e7e..b69a1270 100644 --- a/samples/separate_nointrospection/SubscriptionObject.cpp +++ b/samples/separate_nointrospection/SubscriptionObject.cpp @@ -18,7 +18,7 @@ using namespace std::literals; namespace graphql::today { namespace object { -Subscription::Subscription() +Subscription::Subscription(std::unique_ptr&& pimpl) : service::Object({ "Subscription" }, { @@ -26,35 +26,30 @@ Subscription::Subscription() { R"gql(nodeChange)gql"sv, [this](service::ResolverParams&& params) { return resolveNodeChange(std::move(params)); } }, { R"gql(nextAppointmentChange)gql"sv, [this](service::ResolverParams&& params) { return resolveNextAppointmentChange(std::move(params)); } } }) + , _pimpl(std::move(pimpl)) { } -service::FieldResult> Subscription::getNextAppointmentChange(service::FieldParams&&) const +Subscription::~Subscription() { - throw std::runtime_error(R"ex(Subscription::getNextAppointmentChange is not implemented)ex"); } service::AwaitableResolver Subscription::resolveNextAppointmentChange(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getNextAppointmentChange(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getNextAppointmentChange(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult> Subscription::getNodeChange(service::FieldParams&&, response::IdType&&) const -{ - throw std::runtime_error(R"ex(Subscription::getNodeChange is not implemented)ex"); -} - service::AwaitableResolver Subscription::resolveNodeChange(service::ResolverParams&& params) { auto argId = service::ModifiedArgument::require("id", params.arguments); std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getNodeChange(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argId)); + auto result = _pimpl->getNodeChange(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argId)); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); diff --git a/samples/separate_nointrospection/SubscriptionObject.h b/samples/separate_nointrospection/SubscriptionObject.h index 819ebc7a..feba2c94 100644 --- a/samples/separate_nointrospection/SubscriptionObject.h +++ b/samples/separate_nointrospection/SubscriptionObject.h @@ -15,18 +15,53 @@ namespace graphql::today::object { class Subscription : public service::Object { -protected: - explicit Subscription(); - -public: - virtual service::FieldResult> getNextAppointmentChange(service::FieldParams&& params) const; - virtual service::FieldResult> getNodeChange(service::FieldParams&& params, response::IdType&& idArg) const; - private: service::AwaitableResolver resolveNextAppointmentChange(service::ResolverParams&& params); service::AwaitableResolver resolveNodeChange(service::ResolverParams&& params); service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + + struct Concept + { + virtual service::FieldResult> getNextAppointmentChange(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getNodeChange(service::FieldParams&& params, response::IdType&& idArg) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::FieldResult> getNextAppointmentChange(service::FieldParams&& params) const final + { + return _pimpl->getNextAppointmentChange(std::move(params)); + } + + service::FieldResult> getNodeChange(service::FieldParams&& params, response::IdType&& idArg) const final + { + return _pimpl->getNodeChange(std::move(params), std::move(idArg)); + } + + private: + const std::shared_ptr _pimpl; + }; + + Subscription(std::unique_ptr&& pimpl); + + const std::unique_ptr _pimpl; + +public: + template + Subscription(std::shared_ptr pimpl) + : Subscription { std::make_unique>(std::move(pimpl)) } + { + } + + ~Subscription(); }; } // namespace graphql::today::object diff --git a/samples/separate_nointrospection/TaskConnectionObject.cpp b/samples/separate_nointrospection/TaskConnectionObject.cpp index e5da2c67..e74354cb 100644 --- a/samples/separate_nointrospection/TaskConnectionObject.cpp +++ b/samples/separate_nointrospection/TaskConnectionObject.cpp @@ -18,7 +18,7 @@ using namespace std::literals; namespace graphql::today { namespace object { -TaskConnection::TaskConnection() +TaskConnection::TaskConnection(std::unique_ptr&& pimpl) : service::Object({ "TaskConnection" }, { @@ -26,34 +26,29 @@ TaskConnection::TaskConnection() { R"gql(pageInfo)gql"sv, [this](service::ResolverParams&& params) { return resolvePageInfo(std::move(params)); } }, { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } } }) + , _pimpl(std::move(pimpl)) { } -service::FieldResult> TaskConnection::getPageInfo(service::FieldParams&&) const +TaskConnection::~TaskConnection() { - throw std::runtime_error(R"ex(TaskConnection::getPageInfo is not implemented)ex"); } service::AwaitableResolver TaskConnection::resolvePageInfo(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getPageInfo(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getPageInfo(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult>>> TaskConnection::getEdges(service::FieldParams&&) const -{ - throw std::runtime_error(R"ex(TaskConnection::getEdges is not implemented)ex"); -} - service::AwaitableResolver TaskConnection::resolveEdges(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getEdges(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getEdges(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); diff --git a/samples/separate_nointrospection/TaskConnectionObject.h b/samples/separate_nointrospection/TaskConnectionObject.h index c8a79517..e406fa2b 100644 --- a/samples/separate_nointrospection/TaskConnectionObject.h +++ b/samples/separate_nointrospection/TaskConnectionObject.h @@ -15,18 +15,53 @@ namespace graphql::today::object { class TaskConnection : public service::Object { -protected: - explicit TaskConnection(); - -public: - virtual service::FieldResult> getPageInfo(service::FieldParams&& params) const; - virtual service::FieldResult>>> getEdges(service::FieldParams&& params) const; - private: service::AwaitableResolver resolvePageInfo(service::ResolverParams&& params); service::AwaitableResolver resolveEdges(service::ResolverParams&& params); service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + + struct Concept + { + virtual service::FieldResult> getPageInfo(service::FieldParams&& params) const = 0; + virtual service::FieldResult>>> getEdges(service::FieldParams&& params) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::FieldResult> getPageInfo(service::FieldParams&& params) const final + { + return _pimpl->getPageInfo(std::move(params)); + } + + service::FieldResult>>> getEdges(service::FieldParams&& params) const final + { + return _pimpl->getEdges(std::move(params)); + } + + private: + const std::shared_ptr _pimpl; + }; + + TaskConnection(std::unique_ptr&& pimpl); + + const std::unique_ptr _pimpl; + +public: + template + TaskConnection(std::shared_ptr pimpl) + : TaskConnection { std::make_unique>(std::move(pimpl)) } + { + } + + ~TaskConnection(); }; } // namespace graphql::today::object diff --git a/samples/separate_nointrospection/TaskEdgeObject.cpp b/samples/separate_nointrospection/TaskEdgeObject.cpp index 9cdb491f..6ff72129 100644 --- a/samples/separate_nointrospection/TaskEdgeObject.cpp +++ b/samples/separate_nointrospection/TaskEdgeObject.cpp @@ -18,7 +18,7 @@ using namespace std::literals; namespace graphql::today { namespace object { -TaskEdge::TaskEdge() +TaskEdge::TaskEdge(std::unique_ptr&& pimpl) : service::Object({ "TaskEdge" }, { @@ -26,34 +26,29 @@ TaskEdge::TaskEdge() { R"gql(cursor)gql"sv, [this](service::ResolverParams&& params) { return resolveCursor(std::move(params)); } }, { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } } }) + , _pimpl(std::move(pimpl)) { } -service::FieldResult> TaskEdge::getNode(service::FieldParams&&) const +TaskEdge::~TaskEdge() { - throw std::runtime_error(R"ex(TaskEdge::getNode is not implemented)ex"); } service::AwaitableResolver TaskEdge::resolveNode(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getNode(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getNode(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult TaskEdge::getCursor(service::FieldParams&&) const -{ - throw std::runtime_error(R"ex(TaskEdge::getCursor is not implemented)ex"); -} - service::AwaitableResolver TaskEdge::resolveCursor(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getCursor(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getCursor(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); diff --git a/samples/separate_nointrospection/TaskEdgeObject.h b/samples/separate_nointrospection/TaskEdgeObject.h index 903ff369..60ced878 100644 --- a/samples/separate_nointrospection/TaskEdgeObject.h +++ b/samples/separate_nointrospection/TaskEdgeObject.h @@ -15,18 +15,53 @@ namespace graphql::today::object { class TaskEdge : public service::Object { -protected: - explicit TaskEdge(); - -public: - virtual service::FieldResult> getNode(service::FieldParams&& params) const; - virtual service::FieldResult getCursor(service::FieldParams&& params) const; - private: service::AwaitableResolver resolveNode(service::ResolverParams&& params); service::AwaitableResolver resolveCursor(service::ResolverParams&& params); service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + + struct Concept + { + virtual service::FieldResult> getNode(service::FieldParams&& params) const = 0; + virtual service::FieldResult getCursor(service::FieldParams&& params) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::FieldResult> getNode(service::FieldParams&& params) const final + { + return _pimpl->getNode(std::move(params)); + } + + service::FieldResult getCursor(service::FieldParams&& params) const final + { + return _pimpl->getCursor(std::move(params)); + } + + private: + const std::shared_ptr _pimpl; + }; + + TaskEdge(std::unique_ptr&& pimpl); + + const std::unique_ptr _pimpl; + +public: + template + TaskEdge(std::shared_ptr pimpl) + : TaskEdge { std::make_unique>(std::move(pimpl)) } + { + } + + ~TaskEdge(); }; } // namespace graphql::today::object diff --git a/samples/separate_nointrospection/TaskObject.cpp b/samples/separate_nointrospection/TaskObject.cpp index c65cbf0e..65237095 100644 --- a/samples/separate_nointrospection/TaskObject.cpp +++ b/samples/separate_nointrospection/TaskObject.cpp @@ -18,7 +18,7 @@ using namespace std::literals; namespace graphql::today { namespace object { -Task::Task() +Task::Task(std::unique_ptr&& pimpl) : service::Object({ "Node", "UnionType", @@ -29,49 +29,39 @@ Task::Task() { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, { R"gql(isComplete)gql"sv, [this](service::ResolverParams&& params) { return resolveIsComplete(std::move(params)); } } }) + , _pimpl(std::move(pimpl)) { } -service::FieldResult Task::getId(service::FieldParams&&) const +Task::~Task() { - throw std::runtime_error(R"ex(Task::getId is not implemented)ex"); } service::AwaitableResolver Task::resolveId(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getId(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getId(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult> Task::getTitle(service::FieldParams&&) const -{ - throw std::runtime_error(R"ex(Task::getTitle is not implemented)ex"); -} - service::AwaitableResolver Task::resolveTitle(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getTitle(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getTitle(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult Task::getIsComplete(service::FieldParams&&) const -{ - throw std::runtime_error(R"ex(Task::getIsComplete is not implemented)ex"); -} - service::AwaitableResolver Task::resolveIsComplete(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getIsComplete(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getIsComplete(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); diff --git a/samples/separate_nointrospection/TaskObject.h b/samples/separate_nointrospection/TaskObject.h index a03e82cc..8a161bbe 100644 --- a/samples/separate_nointrospection/TaskObject.h +++ b/samples/separate_nointrospection/TaskObject.h @@ -14,22 +14,61 @@ namespace graphql::today::object { class Task : public service::Object - , public Node { -protected: - explicit Task(); - -public: - service::FieldResult getId(service::FieldParams&& params) const override; - virtual service::FieldResult> getTitle(service::FieldParams&& params) const; - virtual service::FieldResult getIsComplete(service::FieldParams&& params) const; - private: service::AwaitableResolver resolveId(service::ResolverParams&& params); service::AwaitableResolver resolveTitle(service::ResolverParams&& params); service::AwaitableResolver resolveIsComplete(service::ResolverParams&& params); service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + + struct Concept + : Node + { + virtual service::FieldResult> getTitle(service::FieldParams&& params) const = 0; + virtual service::FieldResult getIsComplete(service::FieldParams&& params) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::FieldResult getId(service::FieldParams&& params) const final + { + return _pimpl->getId(std::move(params)); + } + + service::FieldResult> getTitle(service::FieldParams&& params) const final + { + return _pimpl->getTitle(std::move(params)); + } + + service::FieldResult getIsComplete(service::FieldParams&& params) const final + { + return _pimpl->getIsComplete(std::move(params)); + } + + private: + const std::shared_ptr _pimpl; + }; + + Task(std::unique_ptr&& pimpl); + + const std::unique_ptr _pimpl; + +public: + template + Task(std::shared_ptr pimpl) + : Task { std::make_unique>(std::move(pimpl)) } + { + } + + ~Task(); }; } // namespace graphql::today::object diff --git a/samples/separate_nointrospection/TodaySchema.h b/samples/separate_nointrospection/TodaySchema.h index 69514331..9f979a6e 100644 --- a/samples/separate_nointrospection/TodaySchema.h +++ b/samples/separate_nointrospection/TodaySchema.h @@ -92,6 +92,12 @@ class Operations public: explicit Operations(std::shared_ptr query, std::shared_ptr mutation, std::shared_ptr subscription); + template + explicit Operations(std::shared_ptr query, std::shared_ptr mutation, std::shared_ptr subscription) + : Operations { std::make_shared(std::move(query)), std::make_shared(std::move(mutation)), std::make_shared(std::move(subscription)) } + { + } + private: std::shared_ptr _query; std::shared_ptr _mutation; diff --git a/samples/star_wars/DroidData.cpp b/samples/star_wars/DroidData.cpp index b3ae6007..ed95aa50 100644 --- a/samples/star_wars/DroidData.cpp +++ b/samples/star_wars/DroidData.cpp @@ -58,11 +58,22 @@ service::FieldResult> std::transform(friends_.begin(), friends_.end(), - std::back_inserter(result), + result.begin(), [](const auto& wpFriend) noexcept { return std::visit( [](const auto& hero) noexcept { - return std::static_pointer_cast(hero.lock()); + using hero_t = std::decay_t; + + if constexpr (std::is_same_v, hero_t>) + { + return std::static_pointer_cast( + std::make_shared(hero.lock())); + } + else if constexpr (std::is_same_v, hero_t>) + { + return std::static_pointer_cast( + std::make_shared(hero.lock())); + } }, wpFriend); }); diff --git a/samples/star_wars/DroidData.h b/samples/star_wars/DroidData.h index 90b9c781..c68cf829 100644 --- a/samples/star_wars/DroidData.h +++ b/samples/star_wars/DroidData.h @@ -14,7 +14,7 @@ namespace graphql::learn { class Human; -class Droid : public object::Droid +class Droid { public: explicit Droid(response::StringType id, std::optional name, @@ -24,15 +24,15 @@ class Droid : public object::Droid const response::StringType& id() const noexcept; void addFriends(std::vector friends) noexcept; - service::FieldResult getId(service::FieldParams&& params) const final; + service::FieldResult getId(service::FieldParams&& params) const; service::FieldResult> getName( - service::FieldParams&& params) const final; + service::FieldParams&& params) const; service::FieldResult>>> getFriends( - service::FieldParams&& params) const final; + service::FieldParams&& params) const; service::FieldResult>>> getAppearsIn( - service::FieldParams&& params) const final; + service::FieldParams&& params) const; service::FieldResult> getPrimaryFunction( - service::FieldParams&& params) const final; + service::FieldParams&& params) const; private: const response::StringType id_; diff --git a/samples/star_wars/HumanData.cpp b/samples/star_wars/HumanData.cpp index 8c6801f2..4096097d 100644 --- a/samples/star_wars/HumanData.cpp +++ b/samples/star_wars/HumanData.cpp @@ -57,11 +57,22 @@ service::FieldResult> std::transform(friends_.begin(), friends_.end(), - std::back_inserter(result), + result.begin(), [](const auto& wpFriend) noexcept { return std::visit( [](const auto& hero) noexcept { - return std::static_pointer_cast(hero.lock()); + using hero_t = std::decay_t; + + if constexpr (std::is_same_v, hero_t>) + { + return std::static_pointer_cast( + std::make_shared(hero.lock())); + } + else if constexpr (std::is_same_v, hero_t>) + { + return std::static_pointer_cast( + std::make_shared(hero.lock())); + } }, wpFriend); }); diff --git a/samples/star_wars/HumanData.h b/samples/star_wars/HumanData.h index 280acc94..3a1660c2 100644 --- a/samples/star_wars/HumanData.h +++ b/samples/star_wars/HumanData.h @@ -12,25 +12,24 @@ namespace graphql::learn { -class Human : public object::Human +class Human { public: explicit Human(response::StringType id, std::optional name, - std::vector appearsIn, - std::optional homePlanet) noexcept; + std::vector appearsIn, std::optional homePlanet) noexcept; const response::StringType& id() const noexcept; void addFriends(std::vector friends) noexcept; - service::FieldResult getId(service::FieldParams&& params) const final; + service::FieldResult getId(service::FieldParams&& params) const; service::FieldResult> getName( - service::FieldParams&& params) const final; + service::FieldParams&& params) const; service::FieldResult>>> getFriends( - service::FieldParams&& params) const final; + service::FieldParams&& params) const; service::FieldResult>>> getAppearsIn( - service::FieldParams&& params) const final; + service::FieldParams&& params) const; service::FieldResult> getHomePlanet( - service::FieldParams&& params) const final; + service::FieldParams&& params) const; private: const response::StringType id_; diff --git a/samples/star_wars/MutationData.cpp b/samples/star_wars/MutationData.cpp index 0fa6e276..b87fa5ff 100644 --- a/samples/star_wars/MutationData.cpp +++ b/samples/star_wars/MutationData.cpp @@ -10,14 +10,14 @@ Mutation::Mutation() noexcept } service::FieldResult> Mutation::applyCreateReview( - service::FieldParams&& params, Episode&& epArg, ReviewInput&& reviewArg) const + service::FieldParams&& params, Episode&& epArg, ReviewInput&& reviewArg) { auto review = std::make_shared(reviewArg.stars, std::move(reviewArg.commentary)); // Save a copy of this review associated with this episode. reviews_[epArg].push_back(review); - return review; + return std::make_shared(std::move(review)); } } // namespace graphql::learn diff --git a/samples/star_wars/MutationData.h b/samples/star_wars/MutationData.h index 4bb85a38..483b7f29 100644 --- a/samples/star_wars/MutationData.h +++ b/samples/star_wars/MutationData.h @@ -12,18 +12,18 @@ namespace graphql::learn { -class Mutation : public object::Mutation +class Mutation { public: explicit Mutation() noexcept; service::FieldResult> applyCreateReview( - service::FieldParams&& params, Episode&& epArg, ReviewInput&& reviewArg) const final; + service::FieldParams&& params, Episode&& epArg, ReviewInput&& reviewArg); private: // This is just an example, the Mutation object probably shouldn't own a mutable store for the // reviews in a member variable. - mutable std::map>> reviews_; + std::map>> reviews_; }; } // namespace graphql::learn diff --git a/samples/star_wars/QueryData.cpp b/samples/star_wars/QueryData.cpp index 31a9ec01..cc95f2d1 100644 --- a/samples/star_wars/QueryData.cpp +++ b/samples/star_wars/QueryData.cpp @@ -24,7 +24,18 @@ service::FieldResult> Query::getHero( { result = std::visit( [](const auto& hero) noexcept { - return std::static_pointer_cast(hero); + using hero_t = std::decay_t; + + if constexpr (std::is_same_v, hero_t>) + { + return std::static_pointer_cast( + std::make_shared(hero)); + } + else if constexpr (std::is_same_v, hero_t>) + { + return std::static_pointer_cast( + std::make_shared(hero)); + } }, itr->second); } @@ -35,27 +46,27 @@ service::FieldResult> Query::getHero( service::FieldResult> Query::getHuman( service::FieldParams&&, response::StringType&& idArg) const { - std::shared_ptr result; + std::shared_ptr result; if (const auto itr = humans_.find(idArg); itr != humans_.end()) { result = itr->second; } - return { result }; + return std::make_shared(std::move(result)); } service::FieldResult> Query::getDroid( service::FieldParams&&, response::StringType&& idArg) const { - std::shared_ptr result; + std::shared_ptr result; if (const auto itr = droids_.find(idArg); itr != droids_.end()) { result = itr->second; } - return { result }; + return std::make_shared(std::move(result)); } } // namespace graphql::learn diff --git a/samples/star_wars/QueryData.h b/samples/star_wars/QueryData.h index 3dbdc109..ac331200 100644 --- a/samples/star_wars/QueryData.h +++ b/samples/star_wars/QueryData.h @@ -13,7 +13,7 @@ namespace graphql::learn { -class Query : public object::Query +class Query { public: explicit Query(std::map heroes, @@ -21,11 +21,11 @@ class Query : public object::Query std::map> droids) noexcept; service::FieldResult> getHero( - service::FieldParams&& params, std::optional&& episodeArg) const final; + service::FieldParams&& params, std::optional&& episodeArg) const; service::FieldResult> getHuman( - service::FieldParams&& params, response::StringType&& idArg) const final; + service::FieldParams&& params, response::StringType&& idArg) const; service::FieldResult> getDroid( - service::FieldParams&& params, response::StringType&& idArg) const final; + service::FieldParams&& params, response::StringType&& idArg) const; private: const std::map heroes_; diff --git a/samples/star_wars/ReviewData.h b/samples/star_wars/ReviewData.h index 36661860..d201e1d7 100644 --- a/samples/star_wars/ReviewData.h +++ b/samples/star_wars/ReviewData.h @@ -10,15 +10,15 @@ namespace graphql::learn { -class Review : public object::Review +class Review { public: explicit Review( response::IntType stars, std::optional commentary) noexcept; - service::FieldResult getStars(service::FieldParams&& params) const final; + service::FieldResult getStars(service::FieldParams&& params) const; service::FieldResult> getCommentary( - service::FieldParams&& params) const final; + service::FieldParams&& params) const; private: const response::IntType stars_; diff --git a/samples/today/TodayMock.cpp b/samples/today/TodayMock.cpp index 37b8d52b..eceae4a6 100644 --- a/samples/today/TodayMock.cpp +++ b/samples/today/TodayMock.cpp @@ -177,21 +177,21 @@ service::FieldResult> Query::getNode( if (appointment) { - co_return appointment; + co_return std::make_shared(std::move(appointment)); } auto task = findTask(params, id); if (task) { - co_return task; + co_return std::make_shared(std::move(task)); } auto folder = findUnreadCount(params, id); if (folder) { - co_return folder; + co_return std::make_shared(std::move(folder)); } co_return nullptr; @@ -311,7 +311,7 @@ service::FieldResult> Query::getA lastWrapped, std::move(beforeWrapped)); - return std::static_pointer_cast(connection); + return std::make_shared(connection); }, std::move(first), std::move(after), @@ -340,7 +340,7 @@ service::FieldResult> Query::getTasks( lastWrapped, std::move(beforeWrapped)); - return std::static_pointer_cast(connection); + return std::make_shared(connection); }, std::move(first), std::move(after), @@ -369,7 +369,7 @@ service::FieldResult> Query::getUnread lastWrapped, std::move(beforeWrapped)); - return std::static_pointer_cast(connection); + return std::make_shared(connection); }, std::move(first), std::move(after), @@ -387,7 +387,7 @@ service::FieldResult>> Query::g ids.cend(), result.begin(), [this, ¶ms](const response::IdType& id) { - return std::static_pointer_cast(findAppointment(params, id)); + return std::make_shared(findAppointment(params, id)); }); promise.set_value(std::move(result)); @@ -404,7 +404,7 @@ service::FieldResult>> Query::getTasks ids.cend(), result.begin(), [this, ¶ms](const response::IdType& id) { - return std::static_pointer_cast(findTask(params, id)); + return std::make_shared(findTask(params, id)); }); promise.set_value(std::move(result)); @@ -421,7 +421,7 @@ service::FieldResult>> Query::getUnr ids.cend(), result.begin(), [this, ¶ms](const response::IdType& id) { - return std::static_pointer_cast(findUnreadCount(params, id)); + return std::make_shared(findUnreadCount(params, id)); }); promise.set_value(std::move(result)); @@ -433,7 +433,8 @@ service::FieldResult> Query::getNested( { std::promise> promise; - promise.set_value(std::make_shared(std::move(params), 1)); + promise.set_value( + std::make_shared(std::make_shared(std::move(params), 1))); return promise.get_future(); } @@ -445,7 +446,7 @@ service::FieldResult>> Query::get for (auto& entry : result) { - entry = std::make_shared(); + entry = std::make_shared(std::make_shared()); } return result; @@ -466,8 +467,9 @@ service::FieldResult>> Query::getAn std::transform(_appointments.cbegin(), _appointments.cend(), result.begin(), - [](const std::shared_ptr& appointment) noexcept { - return std::static_pointer_cast(appointment); + [](const auto& appointment) noexcept { + return std::static_pointer_cast( + std::make_shared(appointment)); }); return result; @@ -479,11 +481,12 @@ Mutation::Mutation(completeTaskMutation&& mutateCompleteTask) } service::FieldResult> Mutation::applyCompleteTask( - service::FieldParams&& params, CompleteTaskInput&& input) const + service::FieldParams&& params, CompleteTaskInput&& input) { std::promise> promise; - promise.set_value(_mutateCompleteTask(std::move(input))); + promise.set_value( + std::make_shared(_mutateCompleteTask(std::move(input)))); return promise.get_future(); } @@ -496,7 +499,7 @@ double Mutation::getFloat() noexcept } service::FieldResult Mutation::applySetFloat( - service::FieldParams&& params, response::FloatType&& valueArg) const + service::FieldParams&& params, response::FloatType&& valueArg) { _setFloat = std::make_optional(valueArg); return valueArg; @@ -528,7 +531,8 @@ service::FieldResult> NestedType::getNested( { std::promise> promise; - promise.set_value(std::make_shared(std::move(params), depth + 1)); + promise.set_value(std::make_shared( + std::make_shared(std::move(params), depth + 1))); return promise.get_future(); } diff --git a/samples/today/TodayMock.h b/samples/today/TodayMock.h index 69d8d7e6..455bc34e 100644 --- a/samples/today/TodayMock.h +++ b/samples/today/TodayMock.h @@ -40,7 +40,7 @@ class Task; class Folder; class Expensive; -class Query : public object::Query +class Query : public std::enable_shared_from_this { public: using appointmentsLoader = std::function>()>; @@ -51,32 +51,32 @@ class Query : public object::Query unreadCountsLoader&& getUnreadCounts); service::FieldResult> getNode( - service::FieldParams&& params, response::IdType&& id) const final; + service::FieldParams&& params, response::IdType&& id) const; service::FieldResult> getAppointments( service::FieldParams&& params, std::optional&& first, std::optional&& after, std::optional&& last, - std::optional&& before) const final; + std::optional&& before) const; service::FieldResult> getTasks( service::FieldParams&& params, std::optional&& first, std::optional&& after, std::optional&& last, - std::optional&& before) const final; + std::optional&& before) const; service::FieldResult> getUnreadCounts( service::FieldParams&& params, std::optional&& first, std::optional&& after, std::optional&& last, - std::optional&& before) const final; + std::optional&& before) const; service::FieldResult>> getAppointmentsById( - service::FieldParams&& params, std::vector&& ids) const final; + service::FieldParams&& params, std::vector&& ids) const; service::FieldResult>> getTasksById( - service::FieldParams&& params, std::vector&& ids) const final; + service::FieldParams&& params, std::vector&& ids) const; service::FieldResult>> getUnreadCountsById( - service::FieldParams&& params, std::vector&& ids) const final; + service::FieldParams&& params, std::vector&& ids) const; service::FieldResult> getNested( - service::FieldParams&& params) const final; + service::FieldParams&& params) const; service::FieldResult>> getExpensive( - service::FieldParams&& params) const final; - service::FieldResult getTestTaskState(service::FieldParams&& params) const final; + service::FieldParams&& params) const; + service::FieldResult getTestTaskState(service::FieldParams&& params) const; service::FieldResult>> getAnyType( - service::FieldParams&& params, std::vector&& idsArg) const final; + service::FieldParams&& params, std::vector&& idsArg) const; private: std::shared_ptr findAppointment( @@ -100,7 +100,7 @@ class Query : public object::Query mutable std::vector> _unreadCounts; }; -class PageInfo : public object::PageInfo +class PageInfo { public: explicit PageInfo(bool hasNextPage, bool hasPreviousPage) @@ -109,12 +109,12 @@ class PageInfo : public object::PageInfo { } - service::FieldResult getHasNextPage(service::FieldParams&&) const final + service::FieldResult getHasNextPage(service::FieldParams&&) const { return _hasNextPage; } - service::FieldResult getHasPreviousPage(service::FieldParams&&) const final + service::FieldResult getHasPreviousPage(service::FieldParams&&) const { return _hasPreviousPage; } @@ -124,7 +124,7 @@ class PageInfo : public object::PageInfo const bool _hasPreviousPage; }; -class Appointment : public object::Appointment +class Appointment { public: explicit Appointment( @@ -136,29 +136,29 @@ class Appointment : public object::Appointment return _id; } - service::FieldResult getId(service::FieldParams&&) const final + service::FieldResult getId(service::FieldParams&&) const { return _id; } - service::FieldResult> getWhen(service::FieldParams&&) const final + service::FieldResult> getWhen(service::FieldParams&&) const { return std::make_optional(std::string(_when)); } service::FieldResult> getSubject( - service::FieldParams&&) const final + service::FieldParams&&) const { return std::make_optional(_subject); } - service::FieldResult getIsNow(service::FieldParams&&) const final + service::FieldResult getIsNow(service::FieldParams&&) const { return _isNow; } service::FieldResult> getForceError( - service::FieldParams&&) const final + service::FieldParams&&) const { throw std::runtime_error(R"ex(this error was forced)ex"); } @@ -170,7 +170,7 @@ class Appointment : public object::Appointment bool _isNow; }; -class AppointmentEdge : public object::AppointmentEdge +class AppointmentEdge { public: explicit AppointmentEdge(std::shared_ptr appointment) @@ -178,13 +178,12 @@ class AppointmentEdge : public object::AppointmentEdge { } - service::FieldResult> getNode( - service::FieldParams&&) const final + service::FieldResult> getNode(service::FieldParams&&) const { - return std::static_pointer_cast(_appointment); + return std::make_shared(_appointment); } - service::FieldResult getCursor(service::FieldParams&& params) const final + service::FieldResult getCursor(service::FieldParams&& params) const { co_return response::Value(co_await _appointment->getId(std::move(params))); } @@ -193,7 +192,7 @@ class AppointmentEdge : public object::AppointmentEdge std::shared_ptr _appointment; }; -class AppointmentConnection : public object::AppointmentConnection +class AppointmentConnection { public: explicit AppointmentConnection(bool hasNextPage, bool hasPreviousPage, @@ -204,13 +203,13 @@ class AppointmentConnection : public object::AppointmentConnection } service::FieldResult> getPageInfo( - service::FieldParams&&) const final + service::FieldParams&&) const { - return _pageInfo; + return std::make_shared(_pageInfo); } service::FieldResult>>> - getEdges(service::FieldParams&&) const final + getEdges(service::FieldParams&&) const { auto result = std::make_optional>>( _appointments.size()); @@ -219,7 +218,8 @@ class AppointmentConnection : public object::AppointmentConnection _appointments.cend(), result->begin(), [](const std::shared_ptr& node) { - return std::make_shared(node); + return std::make_shared( + std::make_shared(node)); }); return { std::move(result) }; @@ -230,7 +230,7 @@ class AppointmentConnection : public object::AppointmentConnection std::vector> _appointments; }; -class Task : public object::Task +class Task { public: explicit Task(response::IdType&& id, std::string&& title, bool isComplete); @@ -241,18 +241,17 @@ class Task : public object::Task return _id; } - service::FieldResult getId(service::FieldParams&&) const final + service::FieldResult getId(service::FieldParams&&) const { return _id; } - service::FieldResult> getTitle( - service::FieldParams&&) const final + service::FieldResult> getTitle(service::FieldParams&&) const { return std::make_optional(_title); } - service::FieldResult getIsComplete(service::FieldParams&&) const final + service::FieldResult getIsComplete(service::FieldParams&&) const { return _isComplete; } @@ -264,7 +263,7 @@ class Task : public object::Task TaskState _state = TaskState::New; }; -class TaskEdge : public object::TaskEdge +class TaskEdge { public: explicit TaskEdge(std::shared_ptr task) @@ -272,12 +271,12 @@ class TaskEdge : public object::TaskEdge { } - service::FieldResult> getNode(service::FieldParams&&) const final + service::FieldResult> getNode(service::FieldParams&&) const { - return std::static_pointer_cast(_task); + return std::make_shared(_task); } - service::FieldResult getCursor(service::FieldParams&& params) const final + service::FieldResult getCursor(service::FieldParams&& params) const { co_return response::Value(co_await _task->getId(std::move(params))); } @@ -286,7 +285,7 @@ class TaskEdge : public object::TaskEdge std::shared_ptr _task; }; -class TaskConnection : public object::TaskConnection +class TaskConnection { public: explicit TaskConnection( @@ -297,13 +296,13 @@ class TaskConnection : public object::TaskConnection } service::FieldResult> getPageInfo( - service::FieldParams&&) const final + service::FieldParams&&) const { - return _pageInfo; + return std::make_shared(_pageInfo); } service::FieldResult>>> getEdges( - service::FieldParams&&) const final + service::FieldParams&&) const { auto result = std::make_optional>>(_tasks.size()); @@ -312,7 +311,7 @@ class TaskConnection : public object::TaskConnection _tasks.cend(), result->begin(), [](const std::shared_ptr& node) { - return std::make_shared(node); + return std::make_shared(std::make_shared(node)); }); return { std::move(result) }; @@ -323,7 +322,7 @@ class TaskConnection : public object::TaskConnection std::vector> _tasks; }; -class Folder : public object::Folder +class Folder { public: explicit Folder(response::IdType&& id, std::string&& name, int unreadCount); @@ -334,18 +333,17 @@ class Folder : public object::Folder return _id; } - service::FieldResult getId(service::FieldParams&&) const final + service::FieldResult getId(service::FieldParams&&) const { return _id; } - service::FieldResult> getName( - service::FieldParams&&) const final + service::FieldResult> getName(service::FieldParams&&) const { return std::make_optional(_name); } - service::FieldResult getUnreadCount(service::FieldParams&&) const final + service::FieldResult getUnreadCount(service::FieldParams&&) const { return _unreadCount; } @@ -356,7 +354,7 @@ class Folder : public object::Folder int _unreadCount; }; -class FolderEdge : public object::FolderEdge +class FolderEdge { public: explicit FolderEdge(std::shared_ptr folder) @@ -364,13 +362,12 @@ class FolderEdge : public object::FolderEdge { } - service::FieldResult> getNode( - service::FieldParams&&) const final + service::FieldResult> getNode(service::FieldParams&&) const { - return std::static_pointer_cast(_folder); + return std::make_shared(_folder); } - service::FieldResult getCursor(service::FieldParams&& params) const final + service::FieldResult getCursor(service::FieldParams&& params) const { co_return response::Value(co_await _folder->getId(std::move(params))); } @@ -379,7 +376,7 @@ class FolderEdge : public object::FolderEdge std::shared_ptr _folder; }; -class FolderConnection : public object::FolderConnection +class FolderConnection { public: explicit FolderConnection( @@ -390,13 +387,13 @@ class FolderConnection : public object::FolderConnection } service::FieldResult> getPageInfo( - service::FieldParams&&) const final + service::FieldParams&&) const { - return _pageInfo; + return std::make_shared(_pageInfo); } service::FieldResult>>> getEdges( - service::FieldParams&&) const final + service::FieldParams&&) const { auto result = std::make_optional>>(_folders.size()); @@ -405,7 +402,7 @@ class FolderConnection : public object::FolderConnection _folders.cend(), result->begin(), [](const std::shared_ptr& node) { - return std::make_shared(node); + return std::make_shared(std::make_shared(node)); }); return { std::move(result) }; @@ -416,7 +413,7 @@ class FolderConnection : public object::FolderConnection std::vector> _folders; }; -class CompleteTaskPayload : public object::CompleteTaskPayload +class CompleteTaskPayload { public: explicit CompleteTaskPayload( @@ -426,13 +423,13 @@ class CompleteTaskPayload : public object::CompleteTaskPayload { } - service::FieldResult> getTask(service::FieldParams&&) const final + service::FieldResult> getTask(service::FieldParams&&) const { - return std::static_pointer_cast(_task); + return std::make_shared(_task); } service::FieldResult> getClientMutationId( - service::FieldParams&&) const final + service::FieldParams&&) const { return { _clientMutationId ? std::make_optional(*_clientMutationId) : std::nullopt }; @@ -443,7 +440,7 @@ class CompleteTaskPayload : public object::CompleteTaskPayload std::optional _clientMutationId; }; -class Mutation : public object::Mutation +class Mutation { public: using completeTaskMutation = @@ -454,34 +451,34 @@ class Mutation : public object::Mutation static double getFloat() noexcept; service::FieldResult> applyCompleteTask( - service::FieldParams&& params, CompleteTaskInput&& input) const final; + service::FieldParams&& params, CompleteTaskInput&& input); service::FieldResult applySetFloat( - service::FieldParams&& params, response::FloatType&& valueArg) const final; + service::FieldParams&& params, response::FloatType&& valueArg); private: completeTaskMutation _mutateCompleteTask; static std::optional _setFloat; }; -class Subscription : public object::Subscription +class Subscription { public: explicit Subscription() = default; service::FieldResult> getNextAppointmentChange( - service::FieldParams&&) const final + service::FieldParams&&) const { throw std::runtime_error("Unexpected call to getNextAppointmentChange"); } service::FieldResult> getNodeChange( - service::FieldParams&&, response::IdType&&) const final + service::FieldParams&&, response::IdType&&) const { throw std::runtime_error("Unexpected call to getNodeChange"); } }; -class NextAppointmentChange : public object::Subscription +class NextAppointmentChange { public: using nextAppointmentChange = @@ -511,7 +508,7 @@ class NextAppointmentChange : public object::Subscription } service::FieldResult> getNextAppointmentChange( - service::FieldParams&& params) const final + service::FieldParams&& params) const { switch (params.resolverContext) { @@ -537,11 +534,11 @@ class NextAppointmentChange : public object::Subscription throw std::runtime_error("Unexpected ResolverContext"); } - return std::static_pointer_cast(_changeNextAppointment(params.state)); + return std::make_shared(_changeNextAppointment(params.state)); } service::FieldResult> getNodeChange( - service::FieldParams&&, response::IdType&&) const final + service::FieldParams&&, response::IdType&&) const { throw std::runtime_error("Unexpected call to getNodeChange"); } @@ -554,7 +551,7 @@ class NextAppointmentChange : public object::Subscription static size_t _notifyUnsubscribeCount; }; -class NodeChange : public object::Subscription +class NodeChange { public: using nodeChange = std::function( @@ -566,13 +563,13 @@ class NodeChange : public object::Subscription } service::FieldResult> getNextAppointmentChange( - service::FieldParams&&) const final + service::FieldParams&&) const { throw std::runtime_error("Unexpected call to getNextAppointmentChange"); } service::FieldResult> getNodeChange( - service::FieldParams&& params, response::IdType&& idArg) const final + service::FieldParams&& params, response::IdType&& idArg) const { return std::static_pointer_cast( _changeNode(params.state, std::move(idArg))); @@ -594,14 +591,14 @@ struct CapturedParams const response::Value fieldDirectives; }; -class NestedType : public object::NestedType +class NestedType { public: explicit NestedType(service::FieldParams&& params, int depth); - service::FieldResult getDepth(service::FieldParams&& params) const final; + service::FieldResult getDepth(service::FieldParams&& params) const; service::FieldResult> getNested( - service::FieldParams&& params) const final; + service::FieldParams&& params) const; static std::stack getCapturedParams(); @@ -612,7 +609,7 @@ class NestedType : public object::NestedType const int depth; }; -class Expensive : public object::Expensive +class Expensive { public: static bool Reset() noexcept; @@ -620,7 +617,7 @@ class Expensive : public object::Expensive explicit Expensive(); ~Expensive(); - service::FieldResult getOrder(service::FieldParams&& params) const final; + service::FieldResult getOrder(service::FieldParams&& params) const; static constexpr size_t count = 5; static std::mutex testMutex; diff --git a/samples/unified/TodaySchema.cpp b/samples/unified/TodaySchema.cpp index a6f7c718..42dd1e5d 100644 --- a/samples/unified/TodaySchema.cpp +++ b/samples/unified/TodaySchema.cpp @@ -141,7 +141,7 @@ today::FirstNestedInput ModifiedArgument::convert(const namespace today { namespace object { -Query::Query() +Query::Query(std::unique_ptr&& pimpl) : service::Object({ "Query" }, { @@ -162,12 +162,12 @@ Query::Query() { R"gql(unreadCountsById)gql"sv, [this](service::ResolverParams&& params) { return resolveUnreadCountsById(std::move(params)); } } }) , _schema(GetSchema()) + , _pimpl(std::move(pimpl)) { } -service::FieldResult> Query::getNode(service::FieldParams&&, response::IdType&&) const +Query::~Query() { - throw std::runtime_error(R"ex(Query::getNode is not implemented)ex"); } service::AwaitableResolver Query::resolveNode(service::ResolverParams&& params) @@ -175,17 +175,12 @@ service::AwaitableResolver Query::resolveNode(service::ResolverParams&& params) auto argId = service::ModifiedArgument::require("id", params.arguments); std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getNode(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argId)); + auto result = _pimpl->getNode(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argId)); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult> Query::getAppointments(service::FieldParams&&, std::optional&&, std::optional&&, std::optional&&, std::optional&&) const -{ - throw std::runtime_error(R"ex(Query::getAppointments is not implemented)ex"); -} - service::AwaitableResolver Query::resolveAppointments(service::ResolverParams&& params) { auto argFirst = service::ModifiedArgument::require("first", params.arguments); @@ -194,17 +189,12 @@ service::AwaitableResolver Query::resolveAppointments(service::ResolverParams&& auto argBefore = service::ModifiedArgument::require("before", params.arguments); std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getAppointments(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argFirst), std::move(argAfter), std::move(argLast), std::move(argBefore)); + auto result = _pimpl->getAppointments(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argFirst), std::move(argAfter), std::move(argLast), std::move(argBefore)); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult> Query::getTasks(service::FieldParams&&, std::optional&&, std::optional&&, std::optional&&, std::optional&&) const -{ - throw std::runtime_error(R"ex(Query::getTasks is not implemented)ex"); -} - service::AwaitableResolver Query::resolveTasks(service::ResolverParams&& params) { auto argFirst = service::ModifiedArgument::require("first", params.arguments); @@ -213,17 +203,12 @@ service::AwaitableResolver Query::resolveTasks(service::ResolverParams&& params) auto argBefore = service::ModifiedArgument::require("before", params.arguments); std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getTasks(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argFirst), std::move(argAfter), std::move(argLast), std::move(argBefore)); + auto result = _pimpl->getTasks(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argFirst), std::move(argAfter), std::move(argLast), std::move(argBefore)); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult> Query::getUnreadCounts(service::FieldParams&&, std::optional&&, std::optional&&, std::optional&&, std::optional&&) const -{ - throw std::runtime_error(R"ex(Query::getUnreadCounts is not implemented)ex"); -} - service::AwaitableResolver Query::resolveUnreadCounts(service::ResolverParams&& params) { auto argFirst = service::ModifiedArgument::require("first", params.arguments); @@ -232,17 +217,12 @@ service::AwaitableResolver Query::resolveUnreadCounts(service::ResolverParams&& auto argBefore = service::ModifiedArgument::require("before", params.arguments); std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getUnreadCounts(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argFirst), std::move(argAfter), std::move(argLast), std::move(argBefore)); + auto result = _pimpl->getUnreadCounts(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argFirst), std::move(argAfter), std::move(argLast), std::move(argBefore)); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult>> Query::getAppointmentsById(service::FieldParams&&, std::vector&&) const -{ - throw std::runtime_error(R"ex(Query::getAppointmentsById is not implemented)ex"); -} - service::AwaitableResolver Query::resolveAppointmentsById(service::ResolverParams&& params) { const auto defaultArguments = []() @@ -270,115 +250,80 @@ service::AwaitableResolver Query::resolveAppointmentsById(service::ResolverParam : service::ModifiedArgument::require("ids", defaultArguments)); std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getAppointmentsById(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argIds)); + auto result = _pimpl->getAppointmentsById(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argIds)); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult>> Query::getTasksById(service::FieldParams&&, std::vector&&) const -{ - throw std::runtime_error(R"ex(Query::getTasksById is not implemented)ex"); -} - service::AwaitableResolver Query::resolveTasksById(service::ResolverParams&& params) { auto argIds = service::ModifiedArgument::require("ids", params.arguments); std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getTasksById(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argIds)); + auto result = _pimpl->getTasksById(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argIds)); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult>> Query::getUnreadCountsById(service::FieldParams&&, std::vector&&) const -{ - throw std::runtime_error(R"ex(Query::getUnreadCountsById is not implemented)ex"); -} - service::AwaitableResolver Query::resolveUnreadCountsById(service::ResolverParams&& params) { auto argIds = service::ModifiedArgument::require("ids", params.arguments); std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getUnreadCountsById(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argIds)); + auto result = _pimpl->getUnreadCountsById(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argIds)); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult> Query::getNested(service::FieldParams&&) const -{ - throw std::runtime_error(R"ex(Query::getNested is not implemented)ex"); -} - service::AwaitableResolver Query::resolveNested(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getNested(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getNested(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult Query::getUnimplemented(service::FieldParams&&) const -{ - throw std::runtime_error(R"ex(Query::getUnimplemented is not implemented)ex"); -} - service::AwaitableResolver Query::resolveUnimplemented(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getUnimplemented(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getUnimplemented(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult>> Query::getExpensive(service::FieldParams&&) const -{ - throw std::runtime_error(R"ex(Query::getExpensive is not implemented)ex"); -} - service::AwaitableResolver Query::resolveExpensive(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getExpensive(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getExpensive(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult Query::getTestTaskState(service::FieldParams&&) const -{ - throw std::runtime_error(R"ex(Query::getTestTaskState is not implemented)ex"); -} - service::AwaitableResolver Query::resolveTestTaskState(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getTestTaskState(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getTestTaskState(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult>> Query::getAnyType(service::FieldParams&&, std::vector&&) const -{ - throw std::runtime_error(R"ex(Query::getAnyType is not implemented)ex"); -} - service::AwaitableResolver Query::resolveAnyType(service::ResolverParams&& params) { auto argIds = service::ModifiedArgument::require("ids", params.arguments); std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getAnyType(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argIds)); + auto result = _pimpl->getAnyType(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argIds)); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); @@ -391,19 +336,19 @@ service::AwaitableResolver Query::resolve_typename(service::ResolverParams&& par service::AwaitableResolver Query::resolve_schema(service::ResolverParams&& params) { - return service::ModifiedResult::convert(std::static_pointer_cast(std::make_shared(_schema)), std::move(params)); + return service::ModifiedResult::convert(std::static_pointer_cast(std::make_shared(std::make_shared(_schema))), std::move(params)); } service::AwaitableResolver Query::resolve_type(service::ResolverParams&& params) { auto argName = service::ModifiedArgument::require("name", params.arguments); const auto& baseType = _schema->LookupType(argName); - std::shared_ptr result { baseType ? std::make_shared(baseType) : nullptr }; + std::shared_ptr result { baseType ? std::make_shared(std::make_shared(baseType)) : nullptr }; return service::ModifiedResult::convert(result, std::move(params)); } -PageInfo::PageInfo() +PageInfo::PageInfo(std::unique_ptr&& pimpl) : service::Object({ "PageInfo" }, { @@ -411,34 +356,29 @@ PageInfo::PageInfo() { R"gql(hasNextPage)gql"sv, [this](service::ResolverParams&& params) { return resolveHasNextPage(std::move(params)); } }, { R"gql(hasPreviousPage)gql"sv, [this](service::ResolverParams&& params) { return resolveHasPreviousPage(std::move(params)); } } }) + , _pimpl(std::move(pimpl)) { } -service::FieldResult PageInfo::getHasNextPage(service::FieldParams&&) const +PageInfo::~PageInfo() { - throw std::runtime_error(R"ex(PageInfo::getHasNextPage is not implemented)ex"); } service::AwaitableResolver PageInfo::resolveHasNextPage(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getHasNextPage(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getHasNextPage(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult PageInfo::getHasPreviousPage(service::FieldParams&&) const -{ - throw std::runtime_error(R"ex(PageInfo::getHasPreviousPage is not implemented)ex"); -} - service::AwaitableResolver PageInfo::resolveHasPreviousPage(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getHasPreviousPage(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getHasPreviousPage(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); @@ -449,7 +389,7 @@ service::AwaitableResolver PageInfo::resolve_typename(service::ResolverParams&& return service::ModifiedResult::convert(response::StringType{ R"gql(PageInfo)gql" }, std::move(params)); } -AppointmentEdge::AppointmentEdge() +AppointmentEdge::AppointmentEdge(std::unique_ptr&& pimpl) : service::Object({ "AppointmentEdge" }, { @@ -457,34 +397,29 @@ AppointmentEdge::AppointmentEdge() { R"gql(cursor)gql"sv, [this](service::ResolverParams&& params) { return resolveCursor(std::move(params)); } }, { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } } }) + , _pimpl(std::move(pimpl)) { } -service::FieldResult> AppointmentEdge::getNode(service::FieldParams&&) const +AppointmentEdge::~AppointmentEdge() { - throw std::runtime_error(R"ex(AppointmentEdge::getNode is not implemented)ex"); } service::AwaitableResolver AppointmentEdge::resolveNode(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getNode(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getNode(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult AppointmentEdge::getCursor(service::FieldParams&&) const -{ - throw std::runtime_error(R"ex(AppointmentEdge::getCursor is not implemented)ex"); -} - service::AwaitableResolver AppointmentEdge::resolveCursor(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getCursor(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getCursor(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); @@ -495,7 +430,7 @@ service::AwaitableResolver AppointmentEdge::resolve_typename(service::ResolverPa return service::ModifiedResult::convert(response::StringType{ R"gql(AppointmentEdge)gql" }, std::move(params)); } -AppointmentConnection::AppointmentConnection() +AppointmentConnection::AppointmentConnection(std::unique_ptr&& pimpl) : service::Object({ "AppointmentConnection" }, { @@ -503,34 +438,29 @@ AppointmentConnection::AppointmentConnection() { R"gql(pageInfo)gql"sv, [this](service::ResolverParams&& params) { return resolvePageInfo(std::move(params)); } }, { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } } }) + , _pimpl(std::move(pimpl)) { } -service::FieldResult> AppointmentConnection::getPageInfo(service::FieldParams&&) const +AppointmentConnection::~AppointmentConnection() { - throw std::runtime_error(R"ex(AppointmentConnection::getPageInfo is not implemented)ex"); } service::AwaitableResolver AppointmentConnection::resolvePageInfo(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getPageInfo(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getPageInfo(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult>>> AppointmentConnection::getEdges(service::FieldParams&&) const -{ - throw std::runtime_error(R"ex(AppointmentConnection::getEdges is not implemented)ex"); -} - service::AwaitableResolver AppointmentConnection::resolveEdges(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getEdges(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getEdges(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); @@ -541,7 +471,7 @@ service::AwaitableResolver AppointmentConnection::resolve_typename(service::Reso return service::ModifiedResult::convert(response::StringType{ R"gql(AppointmentConnection)gql" }, std::move(params)); } -TaskEdge::TaskEdge() +TaskEdge::TaskEdge(std::unique_ptr&& pimpl) : service::Object({ "TaskEdge" }, { @@ -549,34 +479,29 @@ TaskEdge::TaskEdge() { R"gql(cursor)gql"sv, [this](service::ResolverParams&& params) { return resolveCursor(std::move(params)); } }, { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } } }) + , _pimpl(std::move(pimpl)) { } -service::FieldResult> TaskEdge::getNode(service::FieldParams&&) const +TaskEdge::~TaskEdge() { - throw std::runtime_error(R"ex(TaskEdge::getNode is not implemented)ex"); } service::AwaitableResolver TaskEdge::resolveNode(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getNode(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getNode(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult TaskEdge::getCursor(service::FieldParams&&) const -{ - throw std::runtime_error(R"ex(TaskEdge::getCursor is not implemented)ex"); -} - service::AwaitableResolver TaskEdge::resolveCursor(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getCursor(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getCursor(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); @@ -587,7 +512,7 @@ service::AwaitableResolver TaskEdge::resolve_typename(service::ResolverParams&& return service::ModifiedResult::convert(response::StringType{ R"gql(TaskEdge)gql" }, std::move(params)); } -TaskConnection::TaskConnection() +TaskConnection::TaskConnection(std::unique_ptr&& pimpl) : service::Object({ "TaskConnection" }, { @@ -595,34 +520,29 @@ TaskConnection::TaskConnection() { R"gql(pageInfo)gql"sv, [this](service::ResolverParams&& params) { return resolvePageInfo(std::move(params)); } }, { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } } }) + , _pimpl(std::move(pimpl)) { } -service::FieldResult> TaskConnection::getPageInfo(service::FieldParams&&) const +TaskConnection::~TaskConnection() { - throw std::runtime_error(R"ex(TaskConnection::getPageInfo is not implemented)ex"); } service::AwaitableResolver TaskConnection::resolvePageInfo(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getPageInfo(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getPageInfo(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult>>> TaskConnection::getEdges(service::FieldParams&&) const -{ - throw std::runtime_error(R"ex(TaskConnection::getEdges is not implemented)ex"); -} - service::AwaitableResolver TaskConnection::resolveEdges(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getEdges(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getEdges(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); @@ -633,7 +553,7 @@ service::AwaitableResolver TaskConnection::resolve_typename(service::ResolverPar return service::ModifiedResult::convert(response::StringType{ R"gql(TaskConnection)gql" }, std::move(params)); } -FolderEdge::FolderEdge() +FolderEdge::FolderEdge(std::unique_ptr&& pimpl) : service::Object({ "FolderEdge" }, { @@ -641,34 +561,29 @@ FolderEdge::FolderEdge() { R"gql(cursor)gql"sv, [this](service::ResolverParams&& params) { return resolveCursor(std::move(params)); } }, { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } } }) + , _pimpl(std::move(pimpl)) { } -service::FieldResult> FolderEdge::getNode(service::FieldParams&&) const +FolderEdge::~FolderEdge() { - throw std::runtime_error(R"ex(FolderEdge::getNode is not implemented)ex"); } service::AwaitableResolver FolderEdge::resolveNode(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getNode(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getNode(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult FolderEdge::getCursor(service::FieldParams&&) const -{ - throw std::runtime_error(R"ex(FolderEdge::getCursor is not implemented)ex"); -} - service::AwaitableResolver FolderEdge::resolveCursor(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getCursor(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getCursor(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); @@ -679,7 +594,7 @@ service::AwaitableResolver FolderEdge::resolve_typename(service::ResolverParams& return service::ModifiedResult::convert(response::StringType{ R"gql(FolderEdge)gql" }, std::move(params)); } -FolderConnection::FolderConnection() +FolderConnection::FolderConnection(std::unique_ptr&& pimpl) : service::Object({ "FolderConnection" }, { @@ -687,34 +602,29 @@ FolderConnection::FolderConnection() { R"gql(pageInfo)gql"sv, [this](service::ResolverParams&& params) { return resolvePageInfo(std::move(params)); } }, { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } } }) + , _pimpl(std::move(pimpl)) { } -service::FieldResult> FolderConnection::getPageInfo(service::FieldParams&&) const +FolderConnection::~FolderConnection() { - throw std::runtime_error(R"ex(FolderConnection::getPageInfo is not implemented)ex"); } service::AwaitableResolver FolderConnection::resolvePageInfo(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getPageInfo(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getPageInfo(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult>>> FolderConnection::getEdges(service::FieldParams&&) const -{ - throw std::runtime_error(R"ex(FolderConnection::getEdges is not implemented)ex"); -} - service::AwaitableResolver FolderConnection::resolveEdges(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getEdges(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getEdges(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); @@ -725,7 +635,7 @@ service::AwaitableResolver FolderConnection::resolve_typename(service::ResolverP return service::ModifiedResult::convert(response::StringType{ R"gql(FolderConnection)gql" }, std::move(params)); } -CompleteTaskPayload::CompleteTaskPayload() +CompleteTaskPayload::CompleteTaskPayload(std::unique_ptr&& pimpl) : service::Object({ "CompleteTaskPayload" }, { @@ -733,34 +643,29 @@ CompleteTaskPayload::CompleteTaskPayload() { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, { R"gql(clientMutationId)gql"sv, [this](service::ResolverParams&& params) { return resolveClientMutationId(std::move(params)); } } }) + , _pimpl(std::move(pimpl)) { } -service::FieldResult> CompleteTaskPayload::getTask(service::FieldParams&&) const +CompleteTaskPayload::~CompleteTaskPayload() { - throw std::runtime_error(R"ex(CompleteTaskPayload::getTask is not implemented)ex"); } service::AwaitableResolver CompleteTaskPayload::resolveTask(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getTask(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getTask(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult> CompleteTaskPayload::getClientMutationId(service::FieldParams&&) const -{ - throw std::runtime_error(R"ex(CompleteTaskPayload::getClientMutationId is not implemented)ex"); -} - service::AwaitableResolver CompleteTaskPayload::resolveClientMutationId(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getClientMutationId(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getClientMutationId(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); @@ -771,7 +676,7 @@ service::AwaitableResolver CompleteTaskPayload::resolve_typename(service::Resolv return service::ModifiedResult::convert(response::StringType{ R"gql(CompleteTaskPayload)gql" }, std::move(params)); } -Mutation::Mutation() +Mutation::Mutation(std::unique_ptr&& pimpl) : service::Object({ "Mutation" }, { @@ -779,12 +684,12 @@ Mutation::Mutation() { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, { R"gql(completeTask)gql"sv, [this](service::ResolverParams&& params) { return resolveCompleteTask(std::move(params)); } } }) + , _pimpl(std::move(pimpl)) { } -service::FieldResult> Mutation::applyCompleteTask(service::FieldParams&&, CompleteTaskInput&&) const +Mutation::~Mutation() { - throw std::runtime_error(R"ex(Mutation::applyCompleteTask is not implemented)ex"); } service::AwaitableResolver Mutation::resolveCompleteTask(service::ResolverParams&& params) @@ -792,23 +697,18 @@ service::AwaitableResolver Mutation::resolveCompleteTask(service::ResolverParams auto argInput = service::ModifiedArgument::require("input", params.arguments); std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = applyCompleteTask(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argInput)); + auto result = _pimpl->applyCompleteTask(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argInput)); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult Mutation::applySetFloat(service::FieldParams&&, response::FloatType&&) const -{ - throw std::runtime_error(R"ex(Mutation::applySetFloat is not implemented)ex"); -} - service::AwaitableResolver Mutation::resolveSetFloat(service::ResolverParams&& params) { auto argValue = service::ModifiedArgument::require("value", params.arguments); std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = applySetFloat(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argValue)); + auto result = _pimpl->applySetFloat(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argValue)); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); @@ -819,7 +719,7 @@ service::AwaitableResolver Mutation::resolve_typename(service::ResolverParams&& return service::ModifiedResult::convert(response::StringType{ R"gql(Mutation)gql" }, std::move(params)); } -Subscription::Subscription() +Subscription::Subscription(std::unique_ptr&& pimpl) : service::Object({ "Subscription" }, { @@ -827,35 +727,30 @@ Subscription::Subscription() { R"gql(nodeChange)gql"sv, [this](service::ResolverParams&& params) { return resolveNodeChange(std::move(params)); } }, { R"gql(nextAppointmentChange)gql"sv, [this](service::ResolverParams&& params) { return resolveNextAppointmentChange(std::move(params)); } } }) + , _pimpl(std::move(pimpl)) { } -service::FieldResult> Subscription::getNextAppointmentChange(service::FieldParams&&) const +Subscription::~Subscription() { - throw std::runtime_error(R"ex(Subscription::getNextAppointmentChange is not implemented)ex"); } service::AwaitableResolver Subscription::resolveNextAppointmentChange(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getNextAppointmentChange(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getNextAppointmentChange(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult> Subscription::getNodeChange(service::FieldParams&&, response::IdType&&) const -{ - throw std::runtime_error(R"ex(Subscription::getNodeChange is not implemented)ex"); -} - service::AwaitableResolver Subscription::resolveNodeChange(service::ResolverParams&& params) { auto argId = service::ModifiedArgument::require("id", params.arguments); std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getNodeChange(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argId)); + auto result = _pimpl->getNodeChange(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argId)); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); @@ -866,7 +761,7 @@ service::AwaitableResolver Subscription::resolve_typename(service::ResolverParam return service::ModifiedResult::convert(response::StringType{ R"gql(Subscription)gql" }, std::move(params)); } -Appointment::Appointment() +Appointment::Appointment(std::unique_ptr&& pimpl) : service::Object({ "Node", "UnionType", @@ -879,79 +774,59 @@ Appointment::Appointment() { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, { R"gql(forceError)gql"sv, [this](service::ResolverParams&& params) { return resolveForceError(std::move(params)); } } }) + , _pimpl(std::move(pimpl)) { } -service::FieldResult Appointment::getId(service::FieldParams&&) const +Appointment::~Appointment() { - throw std::runtime_error(R"ex(Appointment::getId is not implemented)ex"); } service::AwaitableResolver Appointment::resolveId(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getId(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getId(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult> Appointment::getWhen(service::FieldParams&&) const -{ - throw std::runtime_error(R"ex(Appointment::getWhen is not implemented)ex"); -} - service::AwaitableResolver Appointment::resolveWhen(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getWhen(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getWhen(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult> Appointment::getSubject(service::FieldParams&&) const -{ - throw std::runtime_error(R"ex(Appointment::getSubject is not implemented)ex"); -} - service::AwaitableResolver Appointment::resolveSubject(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getSubject(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getSubject(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult Appointment::getIsNow(service::FieldParams&&) const -{ - throw std::runtime_error(R"ex(Appointment::getIsNow is not implemented)ex"); -} - service::AwaitableResolver Appointment::resolveIsNow(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getIsNow(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getIsNow(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult> Appointment::getForceError(service::FieldParams&&) const -{ - throw std::runtime_error(R"ex(Appointment::getForceError is not implemented)ex"); -} - service::AwaitableResolver Appointment::resolveForceError(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getForceError(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getForceError(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); @@ -962,7 +837,7 @@ service::AwaitableResolver Appointment::resolve_typename(service::ResolverParams return service::ModifiedResult::convert(response::StringType{ R"gql(Appointment)gql" }, std::move(params)); } -Task::Task() +Task::Task(std::unique_ptr&& pimpl) : service::Object({ "Node", "UnionType", @@ -973,49 +848,39 @@ Task::Task() { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, { R"gql(isComplete)gql"sv, [this](service::ResolverParams&& params) { return resolveIsComplete(std::move(params)); } } }) + , _pimpl(std::move(pimpl)) { } -service::FieldResult Task::getId(service::FieldParams&&) const +Task::~Task() { - throw std::runtime_error(R"ex(Task::getId is not implemented)ex"); } service::AwaitableResolver Task::resolveId(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getId(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getId(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult> Task::getTitle(service::FieldParams&&) const -{ - throw std::runtime_error(R"ex(Task::getTitle is not implemented)ex"); -} - service::AwaitableResolver Task::resolveTitle(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getTitle(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getTitle(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult Task::getIsComplete(service::FieldParams&&) const -{ - throw std::runtime_error(R"ex(Task::getIsComplete is not implemented)ex"); -} - service::AwaitableResolver Task::resolveIsComplete(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getIsComplete(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getIsComplete(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); @@ -1026,7 +891,7 @@ service::AwaitableResolver Task::resolve_typename(service::ResolverParams&& para return service::ModifiedResult::convert(response::StringType{ R"gql(Task)gql" }, std::move(params)); } -Folder::Folder() +Folder::Folder(std::unique_ptr&& pimpl) : service::Object({ "Node", "UnionType", @@ -1037,49 +902,39 @@ Folder::Folder() { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, { R"gql(unreadCount)gql"sv, [this](service::ResolverParams&& params) { return resolveUnreadCount(std::move(params)); } } }) + , _pimpl(std::move(pimpl)) { } -service::FieldResult Folder::getId(service::FieldParams&&) const +Folder::~Folder() { - throw std::runtime_error(R"ex(Folder::getId is not implemented)ex"); } service::AwaitableResolver Folder::resolveId(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getId(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getId(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult> Folder::getName(service::FieldParams&&) const -{ - throw std::runtime_error(R"ex(Folder::getName is not implemented)ex"); -} - service::AwaitableResolver Folder::resolveName(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getName(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getName(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult Folder::getUnreadCount(service::FieldParams&&) const -{ - throw std::runtime_error(R"ex(Folder::getUnreadCount is not implemented)ex"); -} - service::AwaitableResolver Folder::resolveUnreadCount(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getUnreadCount(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getUnreadCount(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); @@ -1090,7 +945,7 @@ service::AwaitableResolver Folder::resolve_typename(service::ResolverParams&& pa return service::ModifiedResult::convert(response::StringType{ R"gql(Folder)gql" }, std::move(params)); } -NestedType::NestedType() +NestedType::NestedType(std::unique_ptr&& pimpl) : service::Object({ "NestedType" }, { @@ -1098,34 +953,29 @@ NestedType::NestedType() { R"gql(nested)gql"sv, [this](service::ResolverParams&& params) { return resolveNested(std::move(params)); } }, { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } } }) + , _pimpl(std::move(pimpl)) { } -service::FieldResult NestedType::getDepth(service::FieldParams&&) const +NestedType::~NestedType() { - throw std::runtime_error(R"ex(NestedType::getDepth is not implemented)ex"); } service::AwaitableResolver NestedType::resolveDepth(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getDepth(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getDepth(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult> NestedType::getNested(service::FieldParams&&) const -{ - throw std::runtime_error(R"ex(NestedType::getNested is not implemented)ex"); -} - service::AwaitableResolver NestedType::resolveNested(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getNested(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getNested(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); @@ -1136,26 +986,26 @@ service::AwaitableResolver NestedType::resolve_typename(service::ResolverParams& return service::ModifiedResult::convert(response::StringType{ R"gql(NestedType)gql" }, std::move(params)); } -Expensive::Expensive() +Expensive::Expensive(std::unique_ptr&& pimpl) : service::Object({ "Expensive" }, { { R"gql(order)gql"sv, [this](service::ResolverParams&& params) { return resolveOrder(std::move(params)); } }, { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } } }) + , _pimpl(std::move(pimpl)) { } -service::FieldResult Expensive::getOrder(service::FieldParams&&) const +Expensive::~Expensive() { - throw std::runtime_error(R"ex(Expensive::getOrder is not implemented)ex"); } service::AwaitableResolver Expensive::resolveOrder(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getOrder(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getOrder(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); diff --git a/samples/unified/TodaySchema.h b/samples/unified/TodaySchema.h index c4596c22..2db1ec02 100644 --- a/samples/unified/TodaySchema.h +++ b/samples/unified/TodaySchema.h @@ -91,23 +91,6 @@ namespace object { class Query : public service::Object { -protected: - explicit Query(); - -public: - virtual service::FieldResult> getNode(service::FieldParams&& params, response::IdType&& idArg) const; - virtual service::FieldResult> getAppointments(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const; - virtual service::FieldResult> getTasks(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const; - virtual service::FieldResult> getUnreadCounts(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const; - virtual service::FieldResult>> getAppointmentsById(service::FieldParams&& params, std::vector&& idsArg) const; - virtual service::FieldResult>> getTasksById(service::FieldParams&& params, std::vector&& idsArg) const; - virtual service::FieldResult>> getUnreadCountsById(service::FieldParams&& params, std::vector&& idsArg) const; - virtual service::FieldResult> getNested(service::FieldParams&& params) const; - virtual service::FieldResult getUnimplemented(service::FieldParams&& params) const; - virtual service::FieldResult>> getExpensive(service::FieldParams&& params) const; - virtual service::FieldResult getTestTaskState(service::FieldParams&& params) const; - virtual service::FieldResult>> getAnyType(service::FieldParams&& params, std::vector&& idsArg) const; - private: service::AwaitableResolver resolveNode(service::ResolverParams&& params); service::AwaitableResolver resolveAppointments(service::ResolverParams&& params); @@ -127,192 +110,633 @@ class Query service::AwaitableResolver resolve_type(service::ResolverParams&& params); std::shared_ptr _schema; + + struct Concept + { + virtual service::FieldResult> getNode(service::FieldParams&& params, response::IdType&& idArg) const = 0; + virtual service::FieldResult> getAppointments(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const = 0; + virtual service::FieldResult> getTasks(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const = 0; + virtual service::FieldResult> getUnreadCounts(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const = 0; + virtual service::FieldResult>> getAppointmentsById(service::FieldParams&& params, std::vector&& idsArg) const = 0; + virtual service::FieldResult>> getTasksById(service::FieldParams&& params, std::vector&& idsArg) const = 0; + virtual service::FieldResult>> getUnreadCountsById(service::FieldParams&& params, std::vector&& idsArg) const = 0; + virtual service::FieldResult> getNested(service::FieldParams&& params) const = 0; + virtual service::FieldResult getUnimplemented(service::FieldParams&& params) const = 0; + virtual service::FieldResult>> getExpensive(service::FieldParams&& params) const = 0; + virtual service::FieldResult getTestTaskState(service::FieldParams&& params) const = 0; + virtual service::FieldResult>> getAnyType(service::FieldParams&& params, std::vector&& idsArg) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::FieldResult> getNode(service::FieldParams&& params, response::IdType&& idArg) const final + { + return _pimpl->getNode(std::move(params), std::move(idArg)); + } + + service::FieldResult> getAppointments(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const final + { + return _pimpl->getAppointments(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)); + } + + service::FieldResult> getTasks(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const final + { + return _pimpl->getTasks(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)); + } + + service::FieldResult> getUnreadCounts(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const final + { + return _pimpl->getUnreadCounts(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)); + } + + service::FieldResult>> getAppointmentsById(service::FieldParams&& params, std::vector&& idsArg) const final + { + return _pimpl->getAppointmentsById(std::move(params), std::move(idsArg)); + } + + service::FieldResult>> getTasksById(service::FieldParams&& params, std::vector&& idsArg) const final + { + return _pimpl->getTasksById(std::move(params), std::move(idsArg)); + } + + service::FieldResult>> getUnreadCountsById(service::FieldParams&& params, std::vector&& idsArg) const final + { + return _pimpl->getUnreadCountsById(std::move(params), std::move(idsArg)); + } + + service::FieldResult> getNested(service::FieldParams&& params) const final + { + return _pimpl->getNested(std::move(params)); + } + + service::FieldResult getUnimplemented(service::FieldParams&& params) const final + { + return _pimpl->getUnimplemented(std::move(params)); + } + + service::FieldResult>> getExpensive(service::FieldParams&& params) const final + { + return _pimpl->getExpensive(std::move(params)); + } + + service::FieldResult getTestTaskState(service::FieldParams&& params) const final + { + return _pimpl->getTestTaskState(std::move(params)); + } + + service::FieldResult>> getAnyType(service::FieldParams&& params, std::vector&& idsArg) const final + { + return _pimpl->getAnyType(std::move(params), std::move(idsArg)); + } + + private: + const std::shared_ptr _pimpl; + }; + + Query(std::unique_ptr&& pimpl); + + const std::unique_ptr _pimpl; + +public: + template + Query(std::shared_ptr pimpl) + : Query { std::make_unique>(std::move(pimpl)) } + { + } + + ~Query(); }; class PageInfo : public service::Object { -protected: - explicit PageInfo(); - -public: - virtual service::FieldResult getHasNextPage(service::FieldParams&& params) const; - virtual service::FieldResult getHasPreviousPage(service::FieldParams&& params) const; - private: service::AwaitableResolver resolveHasNextPage(service::ResolverParams&& params); service::AwaitableResolver resolveHasPreviousPage(service::ResolverParams&& params); service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + + struct Concept + { + virtual service::FieldResult getHasNextPage(service::FieldParams&& params) const = 0; + virtual service::FieldResult getHasPreviousPage(service::FieldParams&& params) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::FieldResult getHasNextPage(service::FieldParams&& params) const final + { + return _pimpl->getHasNextPage(std::move(params)); + } + + service::FieldResult getHasPreviousPage(service::FieldParams&& params) const final + { + return _pimpl->getHasPreviousPage(std::move(params)); + } + + private: + const std::shared_ptr _pimpl; + }; + + PageInfo(std::unique_ptr&& pimpl); + + const std::unique_ptr _pimpl; + +public: + template + PageInfo(std::shared_ptr pimpl) + : PageInfo { std::make_unique>(std::move(pimpl)) } + { + } + + ~PageInfo(); }; class AppointmentEdge : public service::Object { -protected: - explicit AppointmentEdge(); - -public: - virtual service::FieldResult> getNode(service::FieldParams&& params) const; - virtual service::FieldResult getCursor(service::FieldParams&& params) const; - private: service::AwaitableResolver resolveNode(service::ResolverParams&& params); service::AwaitableResolver resolveCursor(service::ResolverParams&& params); service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + + struct Concept + { + virtual service::FieldResult> getNode(service::FieldParams&& params) const = 0; + virtual service::FieldResult getCursor(service::FieldParams&& params) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::FieldResult> getNode(service::FieldParams&& params) const final + { + return _pimpl->getNode(std::move(params)); + } + + service::FieldResult getCursor(service::FieldParams&& params) const final + { + return _pimpl->getCursor(std::move(params)); + } + + private: + const std::shared_ptr _pimpl; + }; + + AppointmentEdge(std::unique_ptr&& pimpl); + + const std::unique_ptr _pimpl; + +public: + template + AppointmentEdge(std::shared_ptr pimpl) + : AppointmentEdge { std::make_unique>(std::move(pimpl)) } + { + } + + ~AppointmentEdge(); }; class AppointmentConnection : public service::Object { -protected: - explicit AppointmentConnection(); - -public: - virtual service::FieldResult> getPageInfo(service::FieldParams&& params) const; - virtual service::FieldResult>>> getEdges(service::FieldParams&& params) const; - private: service::AwaitableResolver resolvePageInfo(service::ResolverParams&& params); service::AwaitableResolver resolveEdges(service::ResolverParams&& params); service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + + struct Concept + { + virtual service::FieldResult> getPageInfo(service::FieldParams&& params) const = 0; + virtual service::FieldResult>>> getEdges(service::FieldParams&& params) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::FieldResult> getPageInfo(service::FieldParams&& params) const final + { + return _pimpl->getPageInfo(std::move(params)); + } + + service::FieldResult>>> getEdges(service::FieldParams&& params) const final + { + return _pimpl->getEdges(std::move(params)); + } + + private: + const std::shared_ptr _pimpl; + }; + + AppointmentConnection(std::unique_ptr&& pimpl); + + const std::unique_ptr _pimpl; + +public: + template + AppointmentConnection(std::shared_ptr pimpl) + : AppointmentConnection { std::make_unique>(std::move(pimpl)) } + { + } + + ~AppointmentConnection(); }; class TaskEdge : public service::Object { -protected: - explicit TaskEdge(); - -public: - virtual service::FieldResult> getNode(service::FieldParams&& params) const; - virtual service::FieldResult getCursor(service::FieldParams&& params) const; - private: service::AwaitableResolver resolveNode(service::ResolverParams&& params); service::AwaitableResolver resolveCursor(service::ResolverParams&& params); service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + + struct Concept + { + virtual service::FieldResult> getNode(service::FieldParams&& params) const = 0; + virtual service::FieldResult getCursor(service::FieldParams&& params) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::FieldResult> getNode(service::FieldParams&& params) const final + { + return _pimpl->getNode(std::move(params)); + } + + service::FieldResult getCursor(service::FieldParams&& params) const final + { + return _pimpl->getCursor(std::move(params)); + } + + private: + const std::shared_ptr _pimpl; + }; + + TaskEdge(std::unique_ptr&& pimpl); + + const std::unique_ptr _pimpl; + +public: + template + TaskEdge(std::shared_ptr pimpl) + : TaskEdge { std::make_unique>(std::move(pimpl)) } + { + } + + ~TaskEdge(); }; class TaskConnection : public service::Object { -protected: - explicit TaskConnection(); - -public: - virtual service::FieldResult> getPageInfo(service::FieldParams&& params) const; - virtual service::FieldResult>>> getEdges(service::FieldParams&& params) const; - private: service::AwaitableResolver resolvePageInfo(service::ResolverParams&& params); service::AwaitableResolver resolveEdges(service::ResolverParams&& params); service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + + struct Concept + { + virtual service::FieldResult> getPageInfo(service::FieldParams&& params) const = 0; + virtual service::FieldResult>>> getEdges(service::FieldParams&& params) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::FieldResult> getPageInfo(service::FieldParams&& params) const final + { + return _pimpl->getPageInfo(std::move(params)); + } + + service::FieldResult>>> getEdges(service::FieldParams&& params) const final + { + return _pimpl->getEdges(std::move(params)); + } + + private: + const std::shared_ptr _pimpl; + }; + + TaskConnection(std::unique_ptr&& pimpl); + + const std::unique_ptr _pimpl; + +public: + template + TaskConnection(std::shared_ptr pimpl) + : TaskConnection { std::make_unique>(std::move(pimpl)) } + { + } + + ~TaskConnection(); }; class FolderEdge : public service::Object { -protected: - explicit FolderEdge(); - -public: - virtual service::FieldResult> getNode(service::FieldParams&& params) const; - virtual service::FieldResult getCursor(service::FieldParams&& params) const; - private: service::AwaitableResolver resolveNode(service::ResolverParams&& params); service::AwaitableResolver resolveCursor(service::ResolverParams&& params); service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + + struct Concept + { + virtual service::FieldResult> getNode(service::FieldParams&& params) const = 0; + virtual service::FieldResult getCursor(service::FieldParams&& params) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::FieldResult> getNode(service::FieldParams&& params) const final + { + return _pimpl->getNode(std::move(params)); + } + + service::FieldResult getCursor(service::FieldParams&& params) const final + { + return _pimpl->getCursor(std::move(params)); + } + + private: + const std::shared_ptr _pimpl; + }; + + FolderEdge(std::unique_ptr&& pimpl); + + const std::unique_ptr _pimpl; + +public: + template + FolderEdge(std::shared_ptr pimpl) + : FolderEdge { std::make_unique>(std::move(pimpl)) } + { + } + + ~FolderEdge(); }; class FolderConnection : public service::Object { -protected: - explicit FolderConnection(); - -public: - virtual service::FieldResult> getPageInfo(service::FieldParams&& params) const; - virtual service::FieldResult>>> getEdges(service::FieldParams&& params) const; - private: service::AwaitableResolver resolvePageInfo(service::ResolverParams&& params); service::AwaitableResolver resolveEdges(service::ResolverParams&& params); service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + + struct Concept + { + virtual service::FieldResult> getPageInfo(service::FieldParams&& params) const = 0; + virtual service::FieldResult>>> getEdges(service::FieldParams&& params) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::FieldResult> getPageInfo(service::FieldParams&& params) const final + { + return _pimpl->getPageInfo(std::move(params)); + } + + service::FieldResult>>> getEdges(service::FieldParams&& params) const final + { + return _pimpl->getEdges(std::move(params)); + } + + private: + const std::shared_ptr _pimpl; + }; + + FolderConnection(std::unique_ptr&& pimpl); + + const std::unique_ptr _pimpl; + +public: + template + FolderConnection(std::shared_ptr pimpl) + : FolderConnection { std::make_unique>(std::move(pimpl)) } + { + } + + ~FolderConnection(); }; class CompleteTaskPayload : public service::Object { -protected: - explicit CompleteTaskPayload(); - -public: - virtual service::FieldResult> getTask(service::FieldParams&& params) const; - virtual service::FieldResult> getClientMutationId(service::FieldParams&& params) const; - private: service::AwaitableResolver resolveTask(service::ResolverParams&& params); service::AwaitableResolver resolveClientMutationId(service::ResolverParams&& params); service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + + struct Concept + { + virtual service::FieldResult> getTask(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getClientMutationId(service::FieldParams&& params) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::FieldResult> getTask(service::FieldParams&& params) const final + { + return _pimpl->getTask(std::move(params)); + } + + service::FieldResult> getClientMutationId(service::FieldParams&& params) const final + { + return _pimpl->getClientMutationId(std::move(params)); + } + + private: + const std::shared_ptr _pimpl; + }; + + CompleteTaskPayload(std::unique_ptr&& pimpl); + + const std::unique_ptr _pimpl; + +public: + template + CompleteTaskPayload(std::shared_ptr pimpl) + : CompleteTaskPayload { std::make_unique>(std::move(pimpl)) } + { + } + + ~CompleteTaskPayload(); }; class Mutation : public service::Object { -protected: - explicit Mutation(); - -public: - virtual service::FieldResult> applyCompleteTask(service::FieldParams&& params, CompleteTaskInput&& inputArg) const; - virtual service::FieldResult applySetFloat(service::FieldParams&& params, response::FloatType&& valueArg) const; - private: service::AwaitableResolver resolveCompleteTask(service::ResolverParams&& params); service::AwaitableResolver resolveSetFloat(service::ResolverParams&& params); service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + + struct Concept + { + virtual service::FieldResult> applyCompleteTask(service::FieldParams&& params, CompleteTaskInput&& inputArg) const = 0; + virtual service::FieldResult applySetFloat(service::FieldParams&& params, response::FloatType&& valueArg) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::FieldResult> applyCompleteTask(service::FieldParams&& params, CompleteTaskInput&& inputArg) const final + { + return _pimpl->applyCompleteTask(std::move(params), std::move(inputArg)); + } + + service::FieldResult applySetFloat(service::FieldParams&& params, response::FloatType&& valueArg) const final + { + return _pimpl->applySetFloat(std::move(params), std::move(valueArg)); + } + + private: + const std::shared_ptr _pimpl; + }; + + Mutation(std::unique_ptr&& pimpl); + + const std::unique_ptr _pimpl; + +public: + template + Mutation(std::shared_ptr pimpl) + : Mutation { std::make_unique>(std::move(pimpl)) } + { + } + + ~Mutation(); }; class Subscription : public service::Object { -protected: - explicit Subscription(); - -public: - virtual service::FieldResult> getNextAppointmentChange(service::FieldParams&& params) const; - virtual service::FieldResult> getNodeChange(service::FieldParams&& params, response::IdType&& idArg) const; - private: service::AwaitableResolver resolveNextAppointmentChange(service::ResolverParams&& params); service::AwaitableResolver resolveNodeChange(service::ResolverParams&& params); service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + + struct Concept + { + virtual service::FieldResult> getNextAppointmentChange(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getNodeChange(service::FieldParams&& params, response::IdType&& idArg) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::FieldResult> getNextAppointmentChange(service::FieldParams&& params) const final + { + return _pimpl->getNextAppointmentChange(std::move(params)); + } + + service::FieldResult> getNodeChange(service::FieldParams&& params, response::IdType&& idArg) const final + { + return _pimpl->getNodeChange(std::move(params), std::move(idArg)); + } + + private: + const std::shared_ptr _pimpl; + }; + + Subscription(std::unique_ptr&& pimpl); + + const std::unique_ptr _pimpl; + +public: + template + Subscription(std::shared_ptr pimpl) + : Subscription { std::make_unique>(std::move(pimpl)) } + { + } + + ~Subscription(); }; class Appointment : public service::Object - , public Node { -protected: - explicit Appointment(); - -public: - service::FieldResult getId(service::FieldParams&& params) const override; - virtual service::FieldResult> getWhen(service::FieldParams&& params) const; - virtual service::FieldResult> getSubject(service::FieldParams&& params) const; - virtual service::FieldResult getIsNow(service::FieldParams&& params) const; - virtual service::FieldResult> getForceError(service::FieldParams&& params) const; - private: service::AwaitableResolver resolveId(service::ResolverParams&& params); service::AwaitableResolver resolveWhen(service::ResolverParams&& params); @@ -321,78 +745,281 @@ class Appointment service::AwaitableResolver resolveForceError(service::ResolverParams&& params); service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + + struct Concept + : Node + { + virtual service::FieldResult> getWhen(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getSubject(service::FieldParams&& params) const = 0; + virtual service::FieldResult getIsNow(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getForceError(service::FieldParams&& params) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::FieldResult getId(service::FieldParams&& params) const final + { + return _pimpl->getId(std::move(params)); + } + + service::FieldResult> getWhen(service::FieldParams&& params) const final + { + return _pimpl->getWhen(std::move(params)); + } + + service::FieldResult> getSubject(service::FieldParams&& params) const final + { + return _pimpl->getSubject(std::move(params)); + } + + service::FieldResult getIsNow(service::FieldParams&& params) const final + { + return _pimpl->getIsNow(std::move(params)); + } + + service::FieldResult> getForceError(service::FieldParams&& params) const final + { + return _pimpl->getForceError(std::move(params)); + } + + private: + const std::shared_ptr _pimpl; + }; + + Appointment(std::unique_ptr&& pimpl); + + const std::unique_ptr _pimpl; + +public: + template + Appointment(std::shared_ptr pimpl) + : Appointment { std::make_unique>(std::move(pimpl)) } + { + } + + ~Appointment(); }; class Task : public service::Object - , public Node { -protected: - explicit Task(); - -public: - service::FieldResult getId(service::FieldParams&& params) const override; - virtual service::FieldResult> getTitle(service::FieldParams&& params) const; - virtual service::FieldResult getIsComplete(service::FieldParams&& params) const; - private: service::AwaitableResolver resolveId(service::ResolverParams&& params); service::AwaitableResolver resolveTitle(service::ResolverParams&& params); service::AwaitableResolver resolveIsComplete(service::ResolverParams&& params); service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + + struct Concept + : Node + { + virtual service::FieldResult> getTitle(service::FieldParams&& params) const = 0; + virtual service::FieldResult getIsComplete(service::FieldParams&& params) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::FieldResult getId(service::FieldParams&& params) const final + { + return _pimpl->getId(std::move(params)); + } + + service::FieldResult> getTitle(service::FieldParams&& params) const final + { + return _pimpl->getTitle(std::move(params)); + } + + service::FieldResult getIsComplete(service::FieldParams&& params) const final + { + return _pimpl->getIsComplete(std::move(params)); + } + + private: + const std::shared_ptr _pimpl; + }; + + Task(std::unique_ptr&& pimpl); + + const std::unique_ptr _pimpl; + +public: + template + Task(std::shared_ptr pimpl) + : Task { std::make_unique>(std::move(pimpl)) } + { + } + + ~Task(); }; class Folder : public service::Object - , public Node { -protected: - explicit Folder(); - -public: - service::FieldResult getId(service::FieldParams&& params) const override; - virtual service::FieldResult> getName(service::FieldParams&& params) const; - virtual service::FieldResult getUnreadCount(service::FieldParams&& params) const; - private: service::AwaitableResolver resolveId(service::ResolverParams&& params); service::AwaitableResolver resolveName(service::ResolverParams&& params); service::AwaitableResolver resolveUnreadCount(service::ResolverParams&& params); service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + + struct Concept + : Node + { + virtual service::FieldResult> getName(service::FieldParams&& params) const = 0; + virtual service::FieldResult getUnreadCount(service::FieldParams&& params) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::FieldResult getId(service::FieldParams&& params) const final + { + return _pimpl->getId(std::move(params)); + } + + service::FieldResult> getName(service::FieldParams&& params) const final + { + return _pimpl->getName(std::move(params)); + } + + service::FieldResult getUnreadCount(service::FieldParams&& params) const final + { + return _pimpl->getUnreadCount(std::move(params)); + } + + private: + const std::shared_ptr _pimpl; + }; + + Folder(std::unique_ptr&& pimpl); + + const std::unique_ptr _pimpl; + +public: + template + Folder(std::shared_ptr pimpl) + : Folder { std::make_unique>(std::move(pimpl)) } + { + } + + ~Folder(); }; class NestedType : public service::Object { -protected: - explicit NestedType(); - -public: - virtual service::FieldResult getDepth(service::FieldParams&& params) const; - virtual service::FieldResult> getNested(service::FieldParams&& params) const; - private: service::AwaitableResolver resolveDepth(service::ResolverParams&& params); service::AwaitableResolver resolveNested(service::ResolverParams&& params); service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + + struct Concept + { + virtual service::FieldResult getDepth(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getNested(service::FieldParams&& params) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::FieldResult getDepth(service::FieldParams&& params) const final + { + return _pimpl->getDepth(std::move(params)); + } + + service::FieldResult> getNested(service::FieldParams&& params) const final + { + return _pimpl->getNested(std::move(params)); + } + + private: + const std::shared_ptr _pimpl; + }; + + NestedType(std::unique_ptr&& pimpl); + + const std::unique_ptr _pimpl; + +public: + template + NestedType(std::shared_ptr pimpl) + : NestedType { std::make_unique>(std::move(pimpl)) } + { + } + + ~NestedType(); }; class Expensive : public service::Object { -protected: - explicit Expensive(); - -public: - virtual service::FieldResult getOrder(service::FieldParams&& params) const; - private: service::AwaitableResolver resolveOrder(service::ResolverParams&& params); service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + + struct Concept + { + virtual service::FieldResult getOrder(service::FieldParams&& params) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::FieldResult getOrder(service::FieldParams&& params) const final + { + return _pimpl->getOrder(std::move(params)); + } + + private: + const std::shared_ptr _pimpl; + }; + + Expensive(std::unique_ptr&& pimpl); + + const std::unique_ptr _pimpl; + +public: + template + Expensive(std::shared_ptr pimpl) + : Expensive { std::make_unique>(std::move(pimpl)) } + { + } + + ~Expensive(); }; } // namespace object @@ -403,6 +1030,12 @@ class Operations public: explicit Operations(std::shared_ptr query, std::shared_ptr mutation, std::shared_ptr subscription); + template + explicit Operations(std::shared_ptr query, std::shared_ptr mutation, std::shared_ptr subscription) + : Operations { std::make_shared(std::move(query)), std::make_shared(std::move(mutation)), std::make_shared(std::move(subscription)) } + { + } + private: std::shared_ptr _query; std::shared_ptr _mutation; diff --git a/samples/unified_nointrospection/TodaySchema.cpp b/samples/unified_nointrospection/TodaySchema.cpp index 436a0f4e..6a704f8b 100644 --- a/samples/unified_nointrospection/TodaySchema.cpp +++ b/samples/unified_nointrospection/TodaySchema.cpp @@ -141,7 +141,7 @@ today::FirstNestedInput ModifiedArgument::convert(const namespace today { namespace object { -Query::Query() +Query::Query(std::unique_ptr&& pimpl) : service::Object({ "Query" }, { @@ -159,12 +159,12 @@ Query::Query() { R"gql(appointmentsById)gql"sv, [this](service::ResolverParams&& params) { return resolveAppointmentsById(std::move(params)); } }, { R"gql(unreadCountsById)gql"sv, [this](service::ResolverParams&& params) { return resolveUnreadCountsById(std::move(params)); } } }) + , _pimpl(std::move(pimpl)) { } -service::FieldResult> Query::getNode(service::FieldParams&&, response::IdType&&) const +Query::~Query() { - throw std::runtime_error(R"ex(Query::getNode is not implemented)ex"); } service::AwaitableResolver Query::resolveNode(service::ResolverParams&& params) @@ -172,17 +172,12 @@ service::AwaitableResolver Query::resolveNode(service::ResolverParams&& params) auto argId = service::ModifiedArgument::require("id", params.arguments); std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getNode(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argId)); + auto result = _pimpl->getNode(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argId)); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult> Query::getAppointments(service::FieldParams&&, std::optional&&, std::optional&&, std::optional&&, std::optional&&) const -{ - throw std::runtime_error(R"ex(Query::getAppointments is not implemented)ex"); -} - service::AwaitableResolver Query::resolveAppointments(service::ResolverParams&& params) { auto argFirst = service::ModifiedArgument::require("first", params.arguments); @@ -191,17 +186,12 @@ service::AwaitableResolver Query::resolveAppointments(service::ResolverParams&& auto argBefore = service::ModifiedArgument::require("before", params.arguments); std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getAppointments(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argFirst), std::move(argAfter), std::move(argLast), std::move(argBefore)); + auto result = _pimpl->getAppointments(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argFirst), std::move(argAfter), std::move(argLast), std::move(argBefore)); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult> Query::getTasks(service::FieldParams&&, std::optional&&, std::optional&&, std::optional&&, std::optional&&) const -{ - throw std::runtime_error(R"ex(Query::getTasks is not implemented)ex"); -} - service::AwaitableResolver Query::resolveTasks(service::ResolverParams&& params) { auto argFirst = service::ModifiedArgument::require("first", params.arguments); @@ -210,17 +200,12 @@ service::AwaitableResolver Query::resolveTasks(service::ResolverParams&& params) auto argBefore = service::ModifiedArgument::require("before", params.arguments); std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getTasks(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argFirst), std::move(argAfter), std::move(argLast), std::move(argBefore)); + auto result = _pimpl->getTasks(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argFirst), std::move(argAfter), std::move(argLast), std::move(argBefore)); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult> Query::getUnreadCounts(service::FieldParams&&, std::optional&&, std::optional&&, std::optional&&, std::optional&&) const -{ - throw std::runtime_error(R"ex(Query::getUnreadCounts is not implemented)ex"); -} - service::AwaitableResolver Query::resolveUnreadCounts(service::ResolverParams&& params) { auto argFirst = service::ModifiedArgument::require("first", params.arguments); @@ -229,17 +214,12 @@ service::AwaitableResolver Query::resolveUnreadCounts(service::ResolverParams&& auto argBefore = service::ModifiedArgument::require("before", params.arguments); std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getUnreadCounts(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argFirst), std::move(argAfter), std::move(argLast), std::move(argBefore)); + auto result = _pimpl->getUnreadCounts(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argFirst), std::move(argAfter), std::move(argLast), std::move(argBefore)); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult>> Query::getAppointmentsById(service::FieldParams&&, std::vector&&) const -{ - throw std::runtime_error(R"ex(Query::getAppointmentsById is not implemented)ex"); -} - service::AwaitableResolver Query::resolveAppointmentsById(service::ResolverParams&& params) { const auto defaultArguments = []() @@ -267,115 +247,80 @@ service::AwaitableResolver Query::resolveAppointmentsById(service::ResolverParam : service::ModifiedArgument::require("ids", defaultArguments)); std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getAppointmentsById(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argIds)); + auto result = _pimpl->getAppointmentsById(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argIds)); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult>> Query::getTasksById(service::FieldParams&&, std::vector&&) const -{ - throw std::runtime_error(R"ex(Query::getTasksById is not implemented)ex"); -} - service::AwaitableResolver Query::resolveTasksById(service::ResolverParams&& params) { auto argIds = service::ModifiedArgument::require("ids", params.arguments); std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getTasksById(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argIds)); + auto result = _pimpl->getTasksById(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argIds)); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult>> Query::getUnreadCountsById(service::FieldParams&&, std::vector&&) const -{ - throw std::runtime_error(R"ex(Query::getUnreadCountsById is not implemented)ex"); -} - service::AwaitableResolver Query::resolveUnreadCountsById(service::ResolverParams&& params) { auto argIds = service::ModifiedArgument::require("ids", params.arguments); std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getUnreadCountsById(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argIds)); + auto result = _pimpl->getUnreadCountsById(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argIds)); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult> Query::getNested(service::FieldParams&&) const -{ - throw std::runtime_error(R"ex(Query::getNested is not implemented)ex"); -} - service::AwaitableResolver Query::resolveNested(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getNested(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getNested(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult Query::getUnimplemented(service::FieldParams&&) const -{ - throw std::runtime_error(R"ex(Query::getUnimplemented is not implemented)ex"); -} - service::AwaitableResolver Query::resolveUnimplemented(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getUnimplemented(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getUnimplemented(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult>> Query::getExpensive(service::FieldParams&&) const -{ - throw std::runtime_error(R"ex(Query::getExpensive is not implemented)ex"); -} - service::AwaitableResolver Query::resolveExpensive(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getExpensive(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getExpensive(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult Query::getTestTaskState(service::FieldParams&&) const -{ - throw std::runtime_error(R"ex(Query::getTestTaskState is not implemented)ex"); -} - service::AwaitableResolver Query::resolveTestTaskState(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getTestTaskState(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getTestTaskState(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult>> Query::getAnyType(service::FieldParams&&, std::vector&&) const -{ - throw std::runtime_error(R"ex(Query::getAnyType is not implemented)ex"); -} - service::AwaitableResolver Query::resolveAnyType(service::ResolverParams&& params) { auto argIds = service::ModifiedArgument::require("ids", params.arguments); std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getAnyType(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argIds)); + auto result = _pimpl->getAnyType(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argIds)); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); @@ -386,7 +331,7 @@ service::AwaitableResolver Query::resolve_typename(service::ResolverParams&& par return service::ModifiedResult::convert(response::StringType{ R"gql(Query)gql" }, std::move(params)); } -PageInfo::PageInfo() +PageInfo::PageInfo(std::unique_ptr&& pimpl) : service::Object({ "PageInfo" }, { @@ -394,34 +339,29 @@ PageInfo::PageInfo() { R"gql(hasNextPage)gql"sv, [this](service::ResolverParams&& params) { return resolveHasNextPage(std::move(params)); } }, { R"gql(hasPreviousPage)gql"sv, [this](service::ResolverParams&& params) { return resolveHasPreviousPage(std::move(params)); } } }) + , _pimpl(std::move(pimpl)) { } -service::FieldResult PageInfo::getHasNextPage(service::FieldParams&&) const +PageInfo::~PageInfo() { - throw std::runtime_error(R"ex(PageInfo::getHasNextPage is not implemented)ex"); } service::AwaitableResolver PageInfo::resolveHasNextPage(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getHasNextPage(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getHasNextPage(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult PageInfo::getHasPreviousPage(service::FieldParams&&) const -{ - throw std::runtime_error(R"ex(PageInfo::getHasPreviousPage is not implemented)ex"); -} - service::AwaitableResolver PageInfo::resolveHasPreviousPage(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getHasPreviousPage(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getHasPreviousPage(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); @@ -432,7 +372,7 @@ service::AwaitableResolver PageInfo::resolve_typename(service::ResolverParams&& return service::ModifiedResult::convert(response::StringType{ R"gql(PageInfo)gql" }, std::move(params)); } -AppointmentEdge::AppointmentEdge() +AppointmentEdge::AppointmentEdge(std::unique_ptr&& pimpl) : service::Object({ "AppointmentEdge" }, { @@ -440,34 +380,29 @@ AppointmentEdge::AppointmentEdge() { R"gql(cursor)gql"sv, [this](service::ResolverParams&& params) { return resolveCursor(std::move(params)); } }, { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } } }) + , _pimpl(std::move(pimpl)) { } -service::FieldResult> AppointmentEdge::getNode(service::FieldParams&&) const +AppointmentEdge::~AppointmentEdge() { - throw std::runtime_error(R"ex(AppointmentEdge::getNode is not implemented)ex"); } service::AwaitableResolver AppointmentEdge::resolveNode(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getNode(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getNode(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult AppointmentEdge::getCursor(service::FieldParams&&) const -{ - throw std::runtime_error(R"ex(AppointmentEdge::getCursor is not implemented)ex"); -} - service::AwaitableResolver AppointmentEdge::resolveCursor(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getCursor(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getCursor(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); @@ -478,7 +413,7 @@ service::AwaitableResolver AppointmentEdge::resolve_typename(service::ResolverPa return service::ModifiedResult::convert(response::StringType{ R"gql(AppointmentEdge)gql" }, std::move(params)); } -AppointmentConnection::AppointmentConnection() +AppointmentConnection::AppointmentConnection(std::unique_ptr&& pimpl) : service::Object({ "AppointmentConnection" }, { @@ -486,34 +421,29 @@ AppointmentConnection::AppointmentConnection() { R"gql(pageInfo)gql"sv, [this](service::ResolverParams&& params) { return resolvePageInfo(std::move(params)); } }, { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } } }) + , _pimpl(std::move(pimpl)) { } -service::FieldResult> AppointmentConnection::getPageInfo(service::FieldParams&&) const +AppointmentConnection::~AppointmentConnection() { - throw std::runtime_error(R"ex(AppointmentConnection::getPageInfo is not implemented)ex"); } service::AwaitableResolver AppointmentConnection::resolvePageInfo(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getPageInfo(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getPageInfo(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult>>> AppointmentConnection::getEdges(service::FieldParams&&) const -{ - throw std::runtime_error(R"ex(AppointmentConnection::getEdges is not implemented)ex"); -} - service::AwaitableResolver AppointmentConnection::resolveEdges(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getEdges(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getEdges(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); @@ -524,7 +454,7 @@ service::AwaitableResolver AppointmentConnection::resolve_typename(service::Reso return service::ModifiedResult::convert(response::StringType{ R"gql(AppointmentConnection)gql" }, std::move(params)); } -TaskEdge::TaskEdge() +TaskEdge::TaskEdge(std::unique_ptr&& pimpl) : service::Object({ "TaskEdge" }, { @@ -532,34 +462,29 @@ TaskEdge::TaskEdge() { R"gql(cursor)gql"sv, [this](service::ResolverParams&& params) { return resolveCursor(std::move(params)); } }, { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } } }) + , _pimpl(std::move(pimpl)) { } -service::FieldResult> TaskEdge::getNode(service::FieldParams&&) const +TaskEdge::~TaskEdge() { - throw std::runtime_error(R"ex(TaskEdge::getNode is not implemented)ex"); } service::AwaitableResolver TaskEdge::resolveNode(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getNode(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getNode(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult TaskEdge::getCursor(service::FieldParams&&) const -{ - throw std::runtime_error(R"ex(TaskEdge::getCursor is not implemented)ex"); -} - service::AwaitableResolver TaskEdge::resolveCursor(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getCursor(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getCursor(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); @@ -570,7 +495,7 @@ service::AwaitableResolver TaskEdge::resolve_typename(service::ResolverParams&& return service::ModifiedResult::convert(response::StringType{ R"gql(TaskEdge)gql" }, std::move(params)); } -TaskConnection::TaskConnection() +TaskConnection::TaskConnection(std::unique_ptr&& pimpl) : service::Object({ "TaskConnection" }, { @@ -578,34 +503,29 @@ TaskConnection::TaskConnection() { R"gql(pageInfo)gql"sv, [this](service::ResolverParams&& params) { return resolvePageInfo(std::move(params)); } }, { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } } }) + , _pimpl(std::move(pimpl)) { } -service::FieldResult> TaskConnection::getPageInfo(service::FieldParams&&) const +TaskConnection::~TaskConnection() { - throw std::runtime_error(R"ex(TaskConnection::getPageInfo is not implemented)ex"); } service::AwaitableResolver TaskConnection::resolvePageInfo(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getPageInfo(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getPageInfo(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult>>> TaskConnection::getEdges(service::FieldParams&&) const -{ - throw std::runtime_error(R"ex(TaskConnection::getEdges is not implemented)ex"); -} - service::AwaitableResolver TaskConnection::resolveEdges(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getEdges(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getEdges(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); @@ -616,7 +536,7 @@ service::AwaitableResolver TaskConnection::resolve_typename(service::ResolverPar return service::ModifiedResult::convert(response::StringType{ R"gql(TaskConnection)gql" }, std::move(params)); } -FolderEdge::FolderEdge() +FolderEdge::FolderEdge(std::unique_ptr&& pimpl) : service::Object({ "FolderEdge" }, { @@ -624,34 +544,29 @@ FolderEdge::FolderEdge() { R"gql(cursor)gql"sv, [this](service::ResolverParams&& params) { return resolveCursor(std::move(params)); } }, { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } } }) + , _pimpl(std::move(pimpl)) { } -service::FieldResult> FolderEdge::getNode(service::FieldParams&&) const +FolderEdge::~FolderEdge() { - throw std::runtime_error(R"ex(FolderEdge::getNode is not implemented)ex"); } service::AwaitableResolver FolderEdge::resolveNode(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getNode(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getNode(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult FolderEdge::getCursor(service::FieldParams&&) const -{ - throw std::runtime_error(R"ex(FolderEdge::getCursor is not implemented)ex"); -} - service::AwaitableResolver FolderEdge::resolveCursor(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getCursor(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getCursor(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); @@ -662,7 +577,7 @@ service::AwaitableResolver FolderEdge::resolve_typename(service::ResolverParams& return service::ModifiedResult::convert(response::StringType{ R"gql(FolderEdge)gql" }, std::move(params)); } -FolderConnection::FolderConnection() +FolderConnection::FolderConnection(std::unique_ptr&& pimpl) : service::Object({ "FolderConnection" }, { @@ -670,34 +585,29 @@ FolderConnection::FolderConnection() { R"gql(pageInfo)gql"sv, [this](service::ResolverParams&& params) { return resolvePageInfo(std::move(params)); } }, { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } } }) + , _pimpl(std::move(pimpl)) { } -service::FieldResult> FolderConnection::getPageInfo(service::FieldParams&&) const +FolderConnection::~FolderConnection() { - throw std::runtime_error(R"ex(FolderConnection::getPageInfo is not implemented)ex"); } service::AwaitableResolver FolderConnection::resolvePageInfo(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getPageInfo(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getPageInfo(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult>>> FolderConnection::getEdges(service::FieldParams&&) const -{ - throw std::runtime_error(R"ex(FolderConnection::getEdges is not implemented)ex"); -} - service::AwaitableResolver FolderConnection::resolveEdges(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getEdges(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getEdges(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); @@ -708,7 +618,7 @@ service::AwaitableResolver FolderConnection::resolve_typename(service::ResolverP return service::ModifiedResult::convert(response::StringType{ R"gql(FolderConnection)gql" }, std::move(params)); } -CompleteTaskPayload::CompleteTaskPayload() +CompleteTaskPayload::CompleteTaskPayload(std::unique_ptr&& pimpl) : service::Object({ "CompleteTaskPayload" }, { @@ -716,34 +626,29 @@ CompleteTaskPayload::CompleteTaskPayload() { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, { R"gql(clientMutationId)gql"sv, [this](service::ResolverParams&& params) { return resolveClientMutationId(std::move(params)); } } }) + , _pimpl(std::move(pimpl)) { } -service::FieldResult> CompleteTaskPayload::getTask(service::FieldParams&&) const +CompleteTaskPayload::~CompleteTaskPayload() { - throw std::runtime_error(R"ex(CompleteTaskPayload::getTask is not implemented)ex"); } service::AwaitableResolver CompleteTaskPayload::resolveTask(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getTask(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getTask(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult> CompleteTaskPayload::getClientMutationId(service::FieldParams&&) const -{ - throw std::runtime_error(R"ex(CompleteTaskPayload::getClientMutationId is not implemented)ex"); -} - service::AwaitableResolver CompleteTaskPayload::resolveClientMutationId(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getClientMutationId(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getClientMutationId(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); @@ -754,7 +659,7 @@ service::AwaitableResolver CompleteTaskPayload::resolve_typename(service::Resolv return service::ModifiedResult::convert(response::StringType{ R"gql(CompleteTaskPayload)gql" }, std::move(params)); } -Mutation::Mutation() +Mutation::Mutation(std::unique_ptr&& pimpl) : service::Object({ "Mutation" }, { @@ -762,12 +667,12 @@ Mutation::Mutation() { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, { R"gql(completeTask)gql"sv, [this](service::ResolverParams&& params) { return resolveCompleteTask(std::move(params)); } } }) + , _pimpl(std::move(pimpl)) { } -service::FieldResult> Mutation::applyCompleteTask(service::FieldParams&&, CompleteTaskInput&&) const +Mutation::~Mutation() { - throw std::runtime_error(R"ex(Mutation::applyCompleteTask is not implemented)ex"); } service::AwaitableResolver Mutation::resolveCompleteTask(service::ResolverParams&& params) @@ -775,23 +680,18 @@ service::AwaitableResolver Mutation::resolveCompleteTask(service::ResolverParams auto argInput = service::ModifiedArgument::require("input", params.arguments); std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = applyCompleteTask(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argInput)); + auto result = _pimpl->applyCompleteTask(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argInput)); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult Mutation::applySetFloat(service::FieldParams&&, response::FloatType&&) const -{ - throw std::runtime_error(R"ex(Mutation::applySetFloat is not implemented)ex"); -} - service::AwaitableResolver Mutation::resolveSetFloat(service::ResolverParams&& params) { auto argValue = service::ModifiedArgument::require("value", params.arguments); std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = applySetFloat(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argValue)); + auto result = _pimpl->applySetFloat(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argValue)); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); @@ -802,7 +702,7 @@ service::AwaitableResolver Mutation::resolve_typename(service::ResolverParams&& return service::ModifiedResult::convert(response::StringType{ R"gql(Mutation)gql" }, std::move(params)); } -Subscription::Subscription() +Subscription::Subscription(std::unique_ptr&& pimpl) : service::Object({ "Subscription" }, { @@ -810,35 +710,30 @@ Subscription::Subscription() { R"gql(nodeChange)gql"sv, [this](service::ResolverParams&& params) { return resolveNodeChange(std::move(params)); } }, { R"gql(nextAppointmentChange)gql"sv, [this](service::ResolverParams&& params) { return resolveNextAppointmentChange(std::move(params)); } } }) + , _pimpl(std::move(pimpl)) { } -service::FieldResult> Subscription::getNextAppointmentChange(service::FieldParams&&) const +Subscription::~Subscription() { - throw std::runtime_error(R"ex(Subscription::getNextAppointmentChange is not implemented)ex"); } service::AwaitableResolver Subscription::resolveNextAppointmentChange(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getNextAppointmentChange(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getNextAppointmentChange(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult> Subscription::getNodeChange(service::FieldParams&&, response::IdType&&) const -{ - throw std::runtime_error(R"ex(Subscription::getNodeChange is not implemented)ex"); -} - service::AwaitableResolver Subscription::resolveNodeChange(service::ResolverParams&& params) { auto argId = service::ModifiedArgument::require("id", params.arguments); std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getNodeChange(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argId)); + auto result = _pimpl->getNodeChange(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argId)); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); @@ -849,7 +744,7 @@ service::AwaitableResolver Subscription::resolve_typename(service::ResolverParam return service::ModifiedResult::convert(response::StringType{ R"gql(Subscription)gql" }, std::move(params)); } -Appointment::Appointment() +Appointment::Appointment(std::unique_ptr&& pimpl) : service::Object({ "Node", "UnionType", @@ -862,79 +757,59 @@ Appointment::Appointment() { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, { R"gql(forceError)gql"sv, [this](service::ResolverParams&& params) { return resolveForceError(std::move(params)); } } }) + , _pimpl(std::move(pimpl)) { } -service::FieldResult Appointment::getId(service::FieldParams&&) const +Appointment::~Appointment() { - throw std::runtime_error(R"ex(Appointment::getId is not implemented)ex"); } service::AwaitableResolver Appointment::resolveId(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getId(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getId(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult> Appointment::getWhen(service::FieldParams&&) const -{ - throw std::runtime_error(R"ex(Appointment::getWhen is not implemented)ex"); -} - service::AwaitableResolver Appointment::resolveWhen(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getWhen(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getWhen(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult> Appointment::getSubject(service::FieldParams&&) const -{ - throw std::runtime_error(R"ex(Appointment::getSubject is not implemented)ex"); -} - service::AwaitableResolver Appointment::resolveSubject(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getSubject(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getSubject(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult Appointment::getIsNow(service::FieldParams&&) const -{ - throw std::runtime_error(R"ex(Appointment::getIsNow is not implemented)ex"); -} - service::AwaitableResolver Appointment::resolveIsNow(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getIsNow(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getIsNow(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult> Appointment::getForceError(service::FieldParams&&) const -{ - throw std::runtime_error(R"ex(Appointment::getForceError is not implemented)ex"); -} - service::AwaitableResolver Appointment::resolveForceError(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getForceError(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getForceError(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); @@ -945,7 +820,7 @@ service::AwaitableResolver Appointment::resolve_typename(service::ResolverParams return service::ModifiedResult::convert(response::StringType{ R"gql(Appointment)gql" }, std::move(params)); } -Task::Task() +Task::Task(std::unique_ptr&& pimpl) : service::Object({ "Node", "UnionType", @@ -956,49 +831,39 @@ Task::Task() { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, { R"gql(isComplete)gql"sv, [this](service::ResolverParams&& params) { return resolveIsComplete(std::move(params)); } } }) + , _pimpl(std::move(pimpl)) { } -service::FieldResult Task::getId(service::FieldParams&&) const +Task::~Task() { - throw std::runtime_error(R"ex(Task::getId is not implemented)ex"); } service::AwaitableResolver Task::resolveId(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getId(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getId(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult> Task::getTitle(service::FieldParams&&) const -{ - throw std::runtime_error(R"ex(Task::getTitle is not implemented)ex"); -} - service::AwaitableResolver Task::resolveTitle(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getTitle(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getTitle(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult Task::getIsComplete(service::FieldParams&&) const -{ - throw std::runtime_error(R"ex(Task::getIsComplete is not implemented)ex"); -} - service::AwaitableResolver Task::resolveIsComplete(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getIsComplete(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getIsComplete(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); @@ -1009,7 +874,7 @@ service::AwaitableResolver Task::resolve_typename(service::ResolverParams&& para return service::ModifiedResult::convert(response::StringType{ R"gql(Task)gql" }, std::move(params)); } -Folder::Folder() +Folder::Folder(std::unique_ptr&& pimpl) : service::Object({ "Node", "UnionType", @@ -1020,49 +885,39 @@ Folder::Folder() { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, { R"gql(unreadCount)gql"sv, [this](service::ResolverParams&& params) { return resolveUnreadCount(std::move(params)); } } }) + , _pimpl(std::move(pimpl)) { } -service::FieldResult Folder::getId(service::FieldParams&&) const +Folder::~Folder() { - throw std::runtime_error(R"ex(Folder::getId is not implemented)ex"); } service::AwaitableResolver Folder::resolveId(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getId(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getId(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult> Folder::getName(service::FieldParams&&) const -{ - throw std::runtime_error(R"ex(Folder::getName is not implemented)ex"); -} - service::AwaitableResolver Folder::resolveName(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getName(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getName(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult Folder::getUnreadCount(service::FieldParams&&) const -{ - throw std::runtime_error(R"ex(Folder::getUnreadCount is not implemented)ex"); -} - service::AwaitableResolver Folder::resolveUnreadCount(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getUnreadCount(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getUnreadCount(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); @@ -1073,7 +928,7 @@ service::AwaitableResolver Folder::resolve_typename(service::ResolverParams&& pa return service::ModifiedResult::convert(response::StringType{ R"gql(Folder)gql" }, std::move(params)); } -NestedType::NestedType() +NestedType::NestedType(std::unique_ptr&& pimpl) : service::Object({ "NestedType" }, { @@ -1081,34 +936,29 @@ NestedType::NestedType() { R"gql(nested)gql"sv, [this](service::ResolverParams&& params) { return resolveNested(std::move(params)); } }, { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } } }) + , _pimpl(std::move(pimpl)) { } -service::FieldResult NestedType::getDepth(service::FieldParams&&) const +NestedType::~NestedType() { - throw std::runtime_error(R"ex(NestedType::getDepth is not implemented)ex"); } service::AwaitableResolver NestedType::resolveDepth(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getDepth(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getDepth(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult> NestedType::getNested(service::FieldParams&&) const -{ - throw std::runtime_error(R"ex(NestedType::getNested is not implemented)ex"); -} - service::AwaitableResolver NestedType::resolveNested(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getNested(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getNested(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); @@ -1119,26 +969,26 @@ service::AwaitableResolver NestedType::resolve_typename(service::ResolverParams& return service::ModifiedResult::convert(response::StringType{ R"gql(NestedType)gql" }, std::move(params)); } -Expensive::Expensive() +Expensive::Expensive(std::unique_ptr&& pimpl) : service::Object({ "Expensive" }, { { R"gql(order)gql"sv, [this](service::ResolverParams&& params) { return resolveOrder(std::move(params)); } }, { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } } }) + , _pimpl(std::move(pimpl)) { } -service::FieldResult Expensive::getOrder(service::FieldParams&&) const +Expensive::~Expensive() { - throw std::runtime_error(R"ex(Expensive::getOrder is not implemented)ex"); } service::AwaitableResolver Expensive::resolveOrder(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getOrder(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getOrder(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); diff --git a/samples/unified_nointrospection/TodaySchema.h b/samples/unified_nointrospection/TodaySchema.h index ef1ef1ca..17f19232 100644 --- a/samples/unified_nointrospection/TodaySchema.h +++ b/samples/unified_nointrospection/TodaySchema.h @@ -91,23 +91,6 @@ namespace object { class Query : public service::Object { -protected: - explicit Query(); - -public: - virtual service::FieldResult> getNode(service::FieldParams&& params, response::IdType&& idArg) const; - virtual service::FieldResult> getAppointments(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const; - virtual service::FieldResult> getTasks(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const; - virtual service::FieldResult> getUnreadCounts(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const; - virtual service::FieldResult>> getAppointmentsById(service::FieldParams&& params, std::vector&& idsArg) const; - virtual service::FieldResult>> getTasksById(service::FieldParams&& params, std::vector&& idsArg) const; - virtual service::FieldResult>> getUnreadCountsById(service::FieldParams&& params, std::vector&& idsArg) const; - virtual service::FieldResult> getNested(service::FieldParams&& params) const; - virtual service::FieldResult getUnimplemented(service::FieldParams&& params) const; - virtual service::FieldResult>> getExpensive(service::FieldParams&& params) const; - virtual service::FieldResult getTestTaskState(service::FieldParams&& params) const; - virtual service::FieldResult>> getAnyType(service::FieldParams&& params, std::vector&& idsArg) const; - private: service::AwaitableResolver resolveNode(service::ResolverParams&& params); service::AwaitableResolver resolveAppointments(service::ResolverParams&& params); @@ -123,192 +106,633 @@ class Query service::AwaitableResolver resolveAnyType(service::ResolverParams&& params); service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + + struct Concept + { + virtual service::FieldResult> getNode(service::FieldParams&& params, response::IdType&& idArg) const = 0; + virtual service::FieldResult> getAppointments(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const = 0; + virtual service::FieldResult> getTasks(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const = 0; + virtual service::FieldResult> getUnreadCounts(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const = 0; + virtual service::FieldResult>> getAppointmentsById(service::FieldParams&& params, std::vector&& idsArg) const = 0; + virtual service::FieldResult>> getTasksById(service::FieldParams&& params, std::vector&& idsArg) const = 0; + virtual service::FieldResult>> getUnreadCountsById(service::FieldParams&& params, std::vector&& idsArg) const = 0; + virtual service::FieldResult> getNested(service::FieldParams&& params) const = 0; + virtual service::FieldResult getUnimplemented(service::FieldParams&& params) const = 0; + virtual service::FieldResult>> getExpensive(service::FieldParams&& params) const = 0; + virtual service::FieldResult getTestTaskState(service::FieldParams&& params) const = 0; + virtual service::FieldResult>> getAnyType(service::FieldParams&& params, std::vector&& idsArg) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::FieldResult> getNode(service::FieldParams&& params, response::IdType&& idArg) const final + { + return _pimpl->getNode(std::move(params), std::move(idArg)); + } + + service::FieldResult> getAppointments(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const final + { + return _pimpl->getAppointments(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)); + } + + service::FieldResult> getTasks(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const final + { + return _pimpl->getTasks(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)); + } + + service::FieldResult> getUnreadCounts(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const final + { + return _pimpl->getUnreadCounts(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)); + } + + service::FieldResult>> getAppointmentsById(service::FieldParams&& params, std::vector&& idsArg) const final + { + return _pimpl->getAppointmentsById(std::move(params), std::move(idsArg)); + } + + service::FieldResult>> getTasksById(service::FieldParams&& params, std::vector&& idsArg) const final + { + return _pimpl->getTasksById(std::move(params), std::move(idsArg)); + } + + service::FieldResult>> getUnreadCountsById(service::FieldParams&& params, std::vector&& idsArg) const final + { + return _pimpl->getUnreadCountsById(std::move(params), std::move(idsArg)); + } + + service::FieldResult> getNested(service::FieldParams&& params) const final + { + return _pimpl->getNested(std::move(params)); + } + + service::FieldResult getUnimplemented(service::FieldParams&& params) const final + { + return _pimpl->getUnimplemented(std::move(params)); + } + + service::FieldResult>> getExpensive(service::FieldParams&& params) const final + { + return _pimpl->getExpensive(std::move(params)); + } + + service::FieldResult getTestTaskState(service::FieldParams&& params) const final + { + return _pimpl->getTestTaskState(std::move(params)); + } + + service::FieldResult>> getAnyType(service::FieldParams&& params, std::vector&& idsArg) const final + { + return _pimpl->getAnyType(std::move(params), std::move(idsArg)); + } + + private: + const std::shared_ptr _pimpl; + }; + + Query(std::unique_ptr&& pimpl); + + const std::unique_ptr _pimpl; + +public: + template + Query(std::shared_ptr pimpl) + : Query { std::make_unique>(std::move(pimpl)) } + { + } + + ~Query(); }; class PageInfo : public service::Object { -protected: - explicit PageInfo(); - -public: - virtual service::FieldResult getHasNextPage(service::FieldParams&& params) const; - virtual service::FieldResult getHasPreviousPage(service::FieldParams&& params) const; - private: service::AwaitableResolver resolveHasNextPage(service::ResolverParams&& params); service::AwaitableResolver resolveHasPreviousPage(service::ResolverParams&& params); service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + + struct Concept + { + virtual service::FieldResult getHasNextPage(service::FieldParams&& params) const = 0; + virtual service::FieldResult getHasPreviousPage(service::FieldParams&& params) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::FieldResult getHasNextPage(service::FieldParams&& params) const final + { + return _pimpl->getHasNextPage(std::move(params)); + } + + service::FieldResult getHasPreviousPage(service::FieldParams&& params) const final + { + return _pimpl->getHasPreviousPage(std::move(params)); + } + + private: + const std::shared_ptr _pimpl; + }; + + PageInfo(std::unique_ptr&& pimpl); + + const std::unique_ptr _pimpl; + +public: + template + PageInfo(std::shared_ptr pimpl) + : PageInfo { std::make_unique>(std::move(pimpl)) } + { + } + + ~PageInfo(); }; class AppointmentEdge : public service::Object { -protected: - explicit AppointmentEdge(); - -public: - virtual service::FieldResult> getNode(service::FieldParams&& params) const; - virtual service::FieldResult getCursor(service::FieldParams&& params) const; - private: service::AwaitableResolver resolveNode(service::ResolverParams&& params); service::AwaitableResolver resolveCursor(service::ResolverParams&& params); service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + + struct Concept + { + virtual service::FieldResult> getNode(service::FieldParams&& params) const = 0; + virtual service::FieldResult getCursor(service::FieldParams&& params) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::FieldResult> getNode(service::FieldParams&& params) const final + { + return _pimpl->getNode(std::move(params)); + } + + service::FieldResult getCursor(service::FieldParams&& params) const final + { + return _pimpl->getCursor(std::move(params)); + } + + private: + const std::shared_ptr _pimpl; + }; + + AppointmentEdge(std::unique_ptr&& pimpl); + + const std::unique_ptr _pimpl; + +public: + template + AppointmentEdge(std::shared_ptr pimpl) + : AppointmentEdge { std::make_unique>(std::move(pimpl)) } + { + } + + ~AppointmentEdge(); }; class AppointmentConnection : public service::Object { -protected: - explicit AppointmentConnection(); - -public: - virtual service::FieldResult> getPageInfo(service::FieldParams&& params) const; - virtual service::FieldResult>>> getEdges(service::FieldParams&& params) const; - private: service::AwaitableResolver resolvePageInfo(service::ResolverParams&& params); service::AwaitableResolver resolveEdges(service::ResolverParams&& params); service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + + struct Concept + { + virtual service::FieldResult> getPageInfo(service::FieldParams&& params) const = 0; + virtual service::FieldResult>>> getEdges(service::FieldParams&& params) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::FieldResult> getPageInfo(service::FieldParams&& params) const final + { + return _pimpl->getPageInfo(std::move(params)); + } + + service::FieldResult>>> getEdges(service::FieldParams&& params) const final + { + return _pimpl->getEdges(std::move(params)); + } + + private: + const std::shared_ptr _pimpl; + }; + + AppointmentConnection(std::unique_ptr&& pimpl); + + const std::unique_ptr _pimpl; + +public: + template + AppointmentConnection(std::shared_ptr pimpl) + : AppointmentConnection { std::make_unique>(std::move(pimpl)) } + { + } + + ~AppointmentConnection(); }; class TaskEdge : public service::Object { -protected: - explicit TaskEdge(); - -public: - virtual service::FieldResult> getNode(service::FieldParams&& params) const; - virtual service::FieldResult getCursor(service::FieldParams&& params) const; - private: service::AwaitableResolver resolveNode(service::ResolverParams&& params); service::AwaitableResolver resolveCursor(service::ResolverParams&& params); service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + + struct Concept + { + virtual service::FieldResult> getNode(service::FieldParams&& params) const = 0; + virtual service::FieldResult getCursor(service::FieldParams&& params) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::FieldResult> getNode(service::FieldParams&& params) const final + { + return _pimpl->getNode(std::move(params)); + } + + service::FieldResult getCursor(service::FieldParams&& params) const final + { + return _pimpl->getCursor(std::move(params)); + } + + private: + const std::shared_ptr _pimpl; + }; + + TaskEdge(std::unique_ptr&& pimpl); + + const std::unique_ptr _pimpl; + +public: + template + TaskEdge(std::shared_ptr pimpl) + : TaskEdge { std::make_unique>(std::move(pimpl)) } + { + } + + ~TaskEdge(); }; class TaskConnection : public service::Object { -protected: - explicit TaskConnection(); - -public: - virtual service::FieldResult> getPageInfo(service::FieldParams&& params) const; - virtual service::FieldResult>>> getEdges(service::FieldParams&& params) const; - private: service::AwaitableResolver resolvePageInfo(service::ResolverParams&& params); service::AwaitableResolver resolveEdges(service::ResolverParams&& params); service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + + struct Concept + { + virtual service::FieldResult> getPageInfo(service::FieldParams&& params) const = 0; + virtual service::FieldResult>>> getEdges(service::FieldParams&& params) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::FieldResult> getPageInfo(service::FieldParams&& params) const final + { + return _pimpl->getPageInfo(std::move(params)); + } + + service::FieldResult>>> getEdges(service::FieldParams&& params) const final + { + return _pimpl->getEdges(std::move(params)); + } + + private: + const std::shared_ptr _pimpl; + }; + + TaskConnection(std::unique_ptr&& pimpl); + + const std::unique_ptr _pimpl; + +public: + template + TaskConnection(std::shared_ptr pimpl) + : TaskConnection { std::make_unique>(std::move(pimpl)) } + { + } + + ~TaskConnection(); }; class FolderEdge : public service::Object { -protected: - explicit FolderEdge(); - -public: - virtual service::FieldResult> getNode(service::FieldParams&& params) const; - virtual service::FieldResult getCursor(service::FieldParams&& params) const; - private: service::AwaitableResolver resolveNode(service::ResolverParams&& params); service::AwaitableResolver resolveCursor(service::ResolverParams&& params); service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + + struct Concept + { + virtual service::FieldResult> getNode(service::FieldParams&& params) const = 0; + virtual service::FieldResult getCursor(service::FieldParams&& params) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::FieldResult> getNode(service::FieldParams&& params) const final + { + return _pimpl->getNode(std::move(params)); + } + + service::FieldResult getCursor(service::FieldParams&& params) const final + { + return _pimpl->getCursor(std::move(params)); + } + + private: + const std::shared_ptr _pimpl; + }; + + FolderEdge(std::unique_ptr&& pimpl); + + const std::unique_ptr _pimpl; + +public: + template + FolderEdge(std::shared_ptr pimpl) + : FolderEdge { std::make_unique>(std::move(pimpl)) } + { + } + + ~FolderEdge(); }; class FolderConnection : public service::Object { -protected: - explicit FolderConnection(); - -public: - virtual service::FieldResult> getPageInfo(service::FieldParams&& params) const; - virtual service::FieldResult>>> getEdges(service::FieldParams&& params) const; - private: service::AwaitableResolver resolvePageInfo(service::ResolverParams&& params); service::AwaitableResolver resolveEdges(service::ResolverParams&& params); service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + + struct Concept + { + virtual service::FieldResult> getPageInfo(service::FieldParams&& params) const = 0; + virtual service::FieldResult>>> getEdges(service::FieldParams&& params) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::FieldResult> getPageInfo(service::FieldParams&& params) const final + { + return _pimpl->getPageInfo(std::move(params)); + } + + service::FieldResult>>> getEdges(service::FieldParams&& params) const final + { + return _pimpl->getEdges(std::move(params)); + } + + private: + const std::shared_ptr _pimpl; + }; + + FolderConnection(std::unique_ptr&& pimpl); + + const std::unique_ptr _pimpl; + +public: + template + FolderConnection(std::shared_ptr pimpl) + : FolderConnection { std::make_unique>(std::move(pimpl)) } + { + } + + ~FolderConnection(); }; class CompleteTaskPayload : public service::Object { -protected: - explicit CompleteTaskPayload(); - -public: - virtual service::FieldResult> getTask(service::FieldParams&& params) const; - virtual service::FieldResult> getClientMutationId(service::FieldParams&& params) const; - private: service::AwaitableResolver resolveTask(service::ResolverParams&& params); service::AwaitableResolver resolveClientMutationId(service::ResolverParams&& params); service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + + struct Concept + { + virtual service::FieldResult> getTask(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getClientMutationId(service::FieldParams&& params) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::FieldResult> getTask(service::FieldParams&& params) const final + { + return _pimpl->getTask(std::move(params)); + } + + service::FieldResult> getClientMutationId(service::FieldParams&& params) const final + { + return _pimpl->getClientMutationId(std::move(params)); + } + + private: + const std::shared_ptr _pimpl; + }; + + CompleteTaskPayload(std::unique_ptr&& pimpl); + + const std::unique_ptr _pimpl; + +public: + template + CompleteTaskPayload(std::shared_ptr pimpl) + : CompleteTaskPayload { std::make_unique>(std::move(pimpl)) } + { + } + + ~CompleteTaskPayload(); }; class Mutation : public service::Object { -protected: - explicit Mutation(); - -public: - virtual service::FieldResult> applyCompleteTask(service::FieldParams&& params, CompleteTaskInput&& inputArg) const; - virtual service::FieldResult applySetFloat(service::FieldParams&& params, response::FloatType&& valueArg) const; - private: service::AwaitableResolver resolveCompleteTask(service::ResolverParams&& params); service::AwaitableResolver resolveSetFloat(service::ResolverParams&& params); service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + + struct Concept + { + virtual service::FieldResult> applyCompleteTask(service::FieldParams&& params, CompleteTaskInput&& inputArg) const = 0; + virtual service::FieldResult applySetFloat(service::FieldParams&& params, response::FloatType&& valueArg) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::FieldResult> applyCompleteTask(service::FieldParams&& params, CompleteTaskInput&& inputArg) const final + { + return _pimpl->applyCompleteTask(std::move(params), std::move(inputArg)); + } + + service::FieldResult applySetFloat(service::FieldParams&& params, response::FloatType&& valueArg) const final + { + return _pimpl->applySetFloat(std::move(params), std::move(valueArg)); + } + + private: + const std::shared_ptr _pimpl; + }; + + Mutation(std::unique_ptr&& pimpl); + + const std::unique_ptr _pimpl; + +public: + template + Mutation(std::shared_ptr pimpl) + : Mutation { std::make_unique>(std::move(pimpl)) } + { + } + + ~Mutation(); }; class Subscription : public service::Object { -protected: - explicit Subscription(); - -public: - virtual service::FieldResult> getNextAppointmentChange(service::FieldParams&& params) const; - virtual service::FieldResult> getNodeChange(service::FieldParams&& params, response::IdType&& idArg) const; - private: service::AwaitableResolver resolveNextAppointmentChange(service::ResolverParams&& params); service::AwaitableResolver resolveNodeChange(service::ResolverParams&& params); service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + + struct Concept + { + virtual service::FieldResult> getNextAppointmentChange(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getNodeChange(service::FieldParams&& params, response::IdType&& idArg) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::FieldResult> getNextAppointmentChange(service::FieldParams&& params) const final + { + return _pimpl->getNextAppointmentChange(std::move(params)); + } + + service::FieldResult> getNodeChange(service::FieldParams&& params, response::IdType&& idArg) const final + { + return _pimpl->getNodeChange(std::move(params), std::move(idArg)); + } + + private: + const std::shared_ptr _pimpl; + }; + + Subscription(std::unique_ptr&& pimpl); + + const std::unique_ptr _pimpl; + +public: + template + Subscription(std::shared_ptr pimpl) + : Subscription { std::make_unique>(std::move(pimpl)) } + { + } + + ~Subscription(); }; class Appointment : public service::Object - , public Node { -protected: - explicit Appointment(); - -public: - service::FieldResult getId(service::FieldParams&& params) const override; - virtual service::FieldResult> getWhen(service::FieldParams&& params) const; - virtual service::FieldResult> getSubject(service::FieldParams&& params) const; - virtual service::FieldResult getIsNow(service::FieldParams&& params) const; - virtual service::FieldResult> getForceError(service::FieldParams&& params) const; - private: service::AwaitableResolver resolveId(service::ResolverParams&& params); service::AwaitableResolver resolveWhen(service::ResolverParams&& params); @@ -317,78 +741,281 @@ class Appointment service::AwaitableResolver resolveForceError(service::ResolverParams&& params); service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + + struct Concept + : Node + { + virtual service::FieldResult> getWhen(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getSubject(service::FieldParams&& params) const = 0; + virtual service::FieldResult getIsNow(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getForceError(service::FieldParams&& params) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::FieldResult getId(service::FieldParams&& params) const final + { + return _pimpl->getId(std::move(params)); + } + + service::FieldResult> getWhen(service::FieldParams&& params) const final + { + return _pimpl->getWhen(std::move(params)); + } + + service::FieldResult> getSubject(service::FieldParams&& params) const final + { + return _pimpl->getSubject(std::move(params)); + } + + service::FieldResult getIsNow(service::FieldParams&& params) const final + { + return _pimpl->getIsNow(std::move(params)); + } + + service::FieldResult> getForceError(service::FieldParams&& params) const final + { + return _pimpl->getForceError(std::move(params)); + } + + private: + const std::shared_ptr _pimpl; + }; + + Appointment(std::unique_ptr&& pimpl); + + const std::unique_ptr _pimpl; + +public: + template + Appointment(std::shared_ptr pimpl) + : Appointment { std::make_unique>(std::move(pimpl)) } + { + } + + ~Appointment(); }; class Task : public service::Object - , public Node { -protected: - explicit Task(); - -public: - service::FieldResult getId(service::FieldParams&& params) const override; - virtual service::FieldResult> getTitle(service::FieldParams&& params) const; - virtual service::FieldResult getIsComplete(service::FieldParams&& params) const; - private: service::AwaitableResolver resolveId(service::ResolverParams&& params); service::AwaitableResolver resolveTitle(service::ResolverParams&& params); service::AwaitableResolver resolveIsComplete(service::ResolverParams&& params); service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + + struct Concept + : Node + { + virtual service::FieldResult> getTitle(service::FieldParams&& params) const = 0; + virtual service::FieldResult getIsComplete(service::FieldParams&& params) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::FieldResult getId(service::FieldParams&& params) const final + { + return _pimpl->getId(std::move(params)); + } + + service::FieldResult> getTitle(service::FieldParams&& params) const final + { + return _pimpl->getTitle(std::move(params)); + } + + service::FieldResult getIsComplete(service::FieldParams&& params) const final + { + return _pimpl->getIsComplete(std::move(params)); + } + + private: + const std::shared_ptr _pimpl; + }; + + Task(std::unique_ptr&& pimpl); + + const std::unique_ptr _pimpl; + +public: + template + Task(std::shared_ptr pimpl) + : Task { std::make_unique>(std::move(pimpl)) } + { + } + + ~Task(); }; class Folder : public service::Object - , public Node { -protected: - explicit Folder(); - -public: - service::FieldResult getId(service::FieldParams&& params) const override; - virtual service::FieldResult> getName(service::FieldParams&& params) const; - virtual service::FieldResult getUnreadCount(service::FieldParams&& params) const; - private: service::AwaitableResolver resolveId(service::ResolverParams&& params); service::AwaitableResolver resolveName(service::ResolverParams&& params); service::AwaitableResolver resolveUnreadCount(service::ResolverParams&& params); service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + + struct Concept + : Node + { + virtual service::FieldResult> getName(service::FieldParams&& params) const = 0; + virtual service::FieldResult getUnreadCount(service::FieldParams&& params) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::FieldResult getId(service::FieldParams&& params) const final + { + return _pimpl->getId(std::move(params)); + } + + service::FieldResult> getName(service::FieldParams&& params) const final + { + return _pimpl->getName(std::move(params)); + } + + service::FieldResult getUnreadCount(service::FieldParams&& params) const final + { + return _pimpl->getUnreadCount(std::move(params)); + } + + private: + const std::shared_ptr _pimpl; + }; + + Folder(std::unique_ptr&& pimpl); + + const std::unique_ptr _pimpl; + +public: + template + Folder(std::shared_ptr pimpl) + : Folder { std::make_unique>(std::move(pimpl)) } + { + } + + ~Folder(); }; class NestedType : public service::Object { -protected: - explicit NestedType(); - -public: - virtual service::FieldResult getDepth(service::FieldParams&& params) const; - virtual service::FieldResult> getNested(service::FieldParams&& params) const; - private: service::AwaitableResolver resolveDepth(service::ResolverParams&& params); service::AwaitableResolver resolveNested(service::ResolverParams&& params); service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + + struct Concept + { + virtual service::FieldResult getDepth(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getNested(service::FieldParams&& params) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::FieldResult getDepth(service::FieldParams&& params) const final + { + return _pimpl->getDepth(std::move(params)); + } + + service::FieldResult> getNested(service::FieldParams&& params) const final + { + return _pimpl->getNested(std::move(params)); + } + + private: + const std::shared_ptr _pimpl; + }; + + NestedType(std::unique_ptr&& pimpl); + + const std::unique_ptr _pimpl; + +public: + template + NestedType(std::shared_ptr pimpl) + : NestedType { std::make_unique>(std::move(pimpl)) } + { + } + + ~NestedType(); }; class Expensive : public service::Object { -protected: - explicit Expensive(); - -public: - virtual service::FieldResult getOrder(service::FieldParams&& params) const; - private: service::AwaitableResolver resolveOrder(service::ResolverParams&& params); service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + + struct Concept + { + virtual service::FieldResult getOrder(service::FieldParams&& params) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::FieldResult getOrder(service::FieldParams&& params) const final + { + return _pimpl->getOrder(std::move(params)); + } + + private: + const std::shared_ptr _pimpl; + }; + + Expensive(std::unique_ptr&& pimpl); + + const std::unique_ptr _pimpl; + +public: + template + Expensive(std::shared_ptr pimpl) + : Expensive { std::make_unique>(std::move(pimpl)) } + { + } + + ~Expensive(); }; } // namespace object @@ -399,6 +1026,12 @@ class Operations public: explicit Operations(std::shared_ptr query, std::shared_ptr mutation, std::shared_ptr subscription); + template + explicit Operations(std::shared_ptr query, std::shared_ptr mutation, std::shared_ptr subscription) + : Operations { std::make_shared(std::move(query)), std::make_shared(std::move(mutation)), std::make_shared(std::move(subscription)) } + { + } + private: std::shared_ptr _query; std::shared_ptr _mutation; diff --git a/samples/validation/ValidationMock.h b/samples/validation/ValidationMock.h index 4cb47be2..1f382528 100644 --- a/samples/validation/ValidationMock.h +++ b/samples/validation/ValidationMock.h @@ -10,19 +10,19 @@ namespace graphql::validation { -class Query : public object::Query +class Query { public: explicit Query() = default; }; -class Mutation : public object::Mutation +class Mutation { public: explicit Mutation() = default; }; -class Subscription : public object::Subscription +class Subscription { public: explicit Subscription() = default; diff --git a/samples/validation/ValidationSchema.cpp b/samples/validation/ValidationSchema.cpp index baf54748..31683697 100644 --- a/samples/validation/ValidationSchema.cpp +++ b/samples/validation/ValidationSchema.cpp @@ -112,7 +112,7 @@ validation::ComplexInput ModifiedArgument::convert(con namespace validation { namespace object { -Query::Query() +Query::Query(std::unique_ptr&& pimpl) : service::Object({ "Query" }, { @@ -128,111 +128,81 @@ Query::Query() { R"gql(booleanList)gql"sv, [this](service::ResolverParams&& params) { return resolveBooleanList(std::move(params)); } } }) , _schema(GetSchema()) + , _pimpl(std::move(pimpl)) { } -service::FieldResult> Query::getDog(service::FieldParams&&) const +Query::~Query() { - throw std::runtime_error(R"ex(Query::getDog is not implemented)ex"); } service::AwaitableResolver Query::resolveDog(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getDog(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getDog(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult> Query::getHuman(service::FieldParams&&) const -{ - throw std::runtime_error(R"ex(Query::getHuman is not implemented)ex"); -} - service::AwaitableResolver Query::resolveHuman(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getHuman(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getHuman(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult> Query::getPet(service::FieldParams&&) const -{ - throw std::runtime_error(R"ex(Query::getPet is not implemented)ex"); -} - service::AwaitableResolver Query::resolvePet(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getPet(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getPet(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult> Query::getCatOrDog(service::FieldParams&&) const -{ - throw std::runtime_error(R"ex(Query::getCatOrDog is not implemented)ex"); -} - service::AwaitableResolver Query::resolveCatOrDog(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getCatOrDog(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getCatOrDog(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult> Query::getArguments(service::FieldParams&&) const -{ - throw std::runtime_error(R"ex(Query::getArguments is not implemented)ex"); -} - service::AwaitableResolver Query::resolveArguments(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getArguments(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getArguments(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult> Query::getFindDog(service::FieldParams&&, std::optional&&) const -{ - throw std::runtime_error(R"ex(Query::getFindDog is not implemented)ex"); -} - service::AwaitableResolver Query::resolveFindDog(service::ResolverParams&& params) { auto argComplex = service::ModifiedArgument::require("complex", params.arguments); std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getFindDog(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argComplex)); + auto result = _pimpl->getFindDog(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argComplex)); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult> Query::getBooleanList(service::FieldParams&&, std::optional>&&) const -{ - throw std::runtime_error(R"ex(Query::getBooleanList is not implemented)ex"); -} - service::AwaitableResolver Query::resolveBooleanList(service::ResolverParams&& params) { auto argBooleanListArg = service::ModifiedArgument::require("booleanListArg", params.arguments); std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getBooleanList(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argBooleanListArg)); + auto result = _pimpl->getBooleanList(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argBooleanListArg)); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); @@ -245,19 +215,19 @@ service::AwaitableResolver Query::resolve_typename(service::ResolverParams&& par service::AwaitableResolver Query::resolve_schema(service::ResolverParams&& params) { - return service::ModifiedResult::convert(std::static_pointer_cast(std::make_shared(_schema)), std::move(params)); + return service::ModifiedResult::convert(std::static_pointer_cast(std::make_shared(std::make_shared(_schema))), std::move(params)); } service::AwaitableResolver Query::resolve_type(service::ResolverParams&& params) { auto argName = service::ModifiedArgument::require("name", params.arguments); const auto& baseType = _schema->LookupType(argName); - std::shared_ptr result { baseType ? std::make_shared(baseType) : nullptr }; + std::shared_ptr result { baseType ? std::make_shared(std::make_shared(baseType)) : nullptr }; return service::ModifiedResult::convert(result, std::move(params)); } -Dog::Dog() +Dog::Dog(std::unique_ptr&& pimpl) : service::Object({ "Pet", "CatOrDog", @@ -272,96 +242,71 @@ Dog::Dog() { R"gql(isHousetrained)gql"sv, [this](service::ResolverParams&& params) { return resolveIsHousetrained(std::move(params)); } }, { R"gql(doesKnowCommand)gql"sv, [this](service::ResolverParams&& params) { return resolveDoesKnowCommand(std::move(params)); } } }) + , _pimpl(std::move(pimpl)) { } -service::FieldResult Dog::getName(service::FieldParams&&) const +Dog::~Dog() { - throw std::runtime_error(R"ex(Dog::getName is not implemented)ex"); } service::AwaitableResolver Dog::resolveName(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getName(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getName(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult> Dog::getNickname(service::FieldParams&&) const -{ - throw std::runtime_error(R"ex(Dog::getNickname is not implemented)ex"); -} - service::AwaitableResolver Dog::resolveNickname(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getNickname(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getNickname(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult> Dog::getBarkVolume(service::FieldParams&&) const -{ - throw std::runtime_error(R"ex(Dog::getBarkVolume is not implemented)ex"); -} - service::AwaitableResolver Dog::resolveBarkVolume(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getBarkVolume(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getBarkVolume(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult Dog::getDoesKnowCommand(service::FieldParams&&, DogCommand&&) const -{ - throw std::runtime_error(R"ex(Dog::getDoesKnowCommand is not implemented)ex"); -} - service::AwaitableResolver Dog::resolveDoesKnowCommand(service::ResolverParams&& params) { auto argDogCommand = service::ModifiedArgument::require("dogCommand", params.arguments); std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getDoesKnowCommand(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argDogCommand)); + auto result = _pimpl->getDoesKnowCommand(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argDogCommand)); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult Dog::getIsHousetrained(service::FieldParams&&, std::optional&&) const -{ - throw std::runtime_error(R"ex(Dog::getIsHousetrained is not implemented)ex"); -} - service::AwaitableResolver Dog::resolveIsHousetrained(service::ResolverParams&& params) { auto argAtOtherHomes = service::ModifiedArgument::require("atOtherHomes", params.arguments); std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getIsHousetrained(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argAtOtherHomes)); + auto result = _pimpl->getIsHousetrained(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argAtOtherHomes)); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult> Dog::getOwner(service::FieldParams&&) const -{ - throw std::runtime_error(R"ex(Dog::getOwner is not implemented)ex"); -} - service::AwaitableResolver Dog::resolveOwner(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getOwner(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getOwner(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); @@ -372,7 +317,7 @@ service::AwaitableResolver Dog::resolve_typename(service::ResolverParams&& param return service::ModifiedResult::convert(response::StringType{ R"gql(Dog)gql" }, std::move(params)); } -Alien::Alien() +Alien::Alien(std::unique_ptr&& pimpl) : service::Object({ "Sentient", "HumanOrAlien", @@ -382,34 +327,29 @@ Alien::Alien() { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, { R"gql(homePlanet)gql"sv, [this](service::ResolverParams&& params) { return resolveHomePlanet(std::move(params)); } } }) + , _pimpl(std::move(pimpl)) { } -service::FieldResult Alien::getName(service::FieldParams&&) const +Alien::~Alien() { - throw std::runtime_error(R"ex(Alien::getName is not implemented)ex"); } service::AwaitableResolver Alien::resolveName(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getName(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getName(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult> Alien::getHomePlanet(service::FieldParams&&) const -{ - throw std::runtime_error(R"ex(Alien::getHomePlanet is not implemented)ex"); -} - service::AwaitableResolver Alien::resolveHomePlanet(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getHomePlanet(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getHomePlanet(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); @@ -420,7 +360,7 @@ service::AwaitableResolver Alien::resolve_typename(service::ResolverParams&& par return service::ModifiedResult::convert(response::StringType{ R"gql(Alien)gql" }, std::move(params)); } -Human::Human() +Human::Human(std::unique_ptr&& pimpl) : service::Object({ "Sentient", "DogOrHuman", @@ -431,34 +371,29 @@ Human::Human() { R"gql(pets)gql"sv, [this](service::ResolverParams&& params) { return resolvePets(std::move(params)); } }, { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } } }) + , _pimpl(std::move(pimpl)) { } -service::FieldResult Human::getName(service::FieldParams&&) const +Human::~Human() { - throw std::runtime_error(R"ex(Human::getName is not implemented)ex"); } service::AwaitableResolver Human::resolveName(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getName(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getName(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult>> Human::getPets(service::FieldParams&&) const -{ - throw std::runtime_error(R"ex(Human::getPets is not implemented)ex"); -} - service::AwaitableResolver Human::resolvePets(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getPets(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getPets(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); @@ -469,7 +404,7 @@ service::AwaitableResolver Human::resolve_typename(service::ResolverParams&& par return service::ModifiedResult::convert(response::StringType{ R"gql(Human)gql" }, std::move(params)); } -Cat::Cat() +Cat::Cat(std::unique_ptr&& pimpl) : service::Object({ "Pet", "CatOrDog", @@ -481,65 +416,50 @@ Cat::Cat() { R"gql(meowVolume)gql"sv, [this](service::ResolverParams&& params) { return resolveMeowVolume(std::move(params)); } }, { R"gql(doesKnowCommand)gql"sv, [this](service::ResolverParams&& params) { return resolveDoesKnowCommand(std::move(params)); } } }) + , _pimpl(std::move(pimpl)) { } -service::FieldResult Cat::getName(service::FieldParams&&) const +Cat::~Cat() { - throw std::runtime_error(R"ex(Cat::getName is not implemented)ex"); } service::AwaitableResolver Cat::resolveName(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getName(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getName(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult> Cat::getNickname(service::FieldParams&&) const -{ - throw std::runtime_error(R"ex(Cat::getNickname is not implemented)ex"); -} - service::AwaitableResolver Cat::resolveNickname(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getNickname(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getNickname(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult Cat::getDoesKnowCommand(service::FieldParams&&, CatCommand&&) const -{ - throw std::runtime_error(R"ex(Cat::getDoesKnowCommand is not implemented)ex"); -} - service::AwaitableResolver Cat::resolveDoesKnowCommand(service::ResolverParams&& params) { auto argCatCommand = service::ModifiedArgument::require("catCommand", params.arguments); std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getDoesKnowCommand(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argCatCommand)); + auto result = _pimpl->getDoesKnowCommand(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argCatCommand)); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult> Cat::getMeowVolume(service::FieldParams&&) const -{ - throw std::runtime_error(R"ex(Cat::getMeowVolume is not implemented)ex"); -} - service::AwaitableResolver Cat::resolveMeowVolume(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getMeowVolume(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getMeowVolume(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); @@ -550,26 +470,26 @@ service::AwaitableResolver Cat::resolve_typename(service::ResolverParams&& param return service::ModifiedResult::convert(response::StringType{ R"gql(Cat)gql" }, std::move(params)); } -Mutation::Mutation() +Mutation::Mutation(std::unique_ptr&& pimpl) : service::Object({ "Mutation" }, { { R"gql(mutateDog)gql"sv, [this](service::ResolverParams&& params) { return resolveMutateDog(std::move(params)); } }, { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } } }) + , _pimpl(std::move(pimpl)) { } -service::FieldResult> Mutation::applyMutateDog(service::FieldParams&&) const +Mutation::~Mutation() { - throw std::runtime_error(R"ex(Mutation::applyMutateDog is not implemented)ex"); } service::AwaitableResolver Mutation::resolveMutateDog(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = applyMutateDog(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->applyMutateDog(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); @@ -580,26 +500,26 @@ service::AwaitableResolver Mutation::resolve_typename(service::ResolverParams&& return service::ModifiedResult::convert(response::StringType{ R"gql(Mutation)gql" }, std::move(params)); } -MutateDogResult::MutateDogResult() +MutateDogResult::MutateDogResult(std::unique_ptr&& pimpl) : service::Object({ "MutateDogResult" }, { { R"gql(id)gql"sv, [this](service::ResolverParams&& params) { return resolveId(std::move(params)); } }, { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } } }) + , _pimpl(std::move(pimpl)) { } -service::FieldResult MutateDogResult::getId(service::FieldParams&&) const +MutateDogResult::~MutateDogResult() { - throw std::runtime_error(R"ex(MutateDogResult::getId is not implemented)ex"); } service::AwaitableResolver MutateDogResult::resolveId(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getId(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getId(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); @@ -610,7 +530,7 @@ service::AwaitableResolver MutateDogResult::resolve_typename(service::ResolverPa return service::ModifiedResult::convert(response::StringType{ R"gql(MutateDogResult)gql" }, std::move(params)); } -Subscription::Subscription() +Subscription::Subscription(std::unique_ptr&& pimpl) : service::Object({ "Subscription" }, { @@ -618,34 +538,29 @@ Subscription::Subscription() { R"gql(newMessage)gql"sv, [this](service::ResolverParams&& params) { return resolveNewMessage(std::move(params)); } }, { R"gql(disallowedSecondRootField)gql"sv, [this](service::ResolverParams&& params) { return resolveDisallowedSecondRootField(std::move(params)); } } }) + , _pimpl(std::move(pimpl)) { } -service::FieldResult> Subscription::getNewMessage(service::FieldParams&&) const +Subscription::~Subscription() { - throw std::runtime_error(R"ex(Subscription::getNewMessage is not implemented)ex"); } service::AwaitableResolver Subscription::resolveNewMessage(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getNewMessage(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getNewMessage(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult Subscription::getDisallowedSecondRootField(service::FieldParams&&) const -{ - throw std::runtime_error(R"ex(Subscription::getDisallowedSecondRootField is not implemented)ex"); -} - service::AwaitableResolver Subscription::resolveDisallowedSecondRootField(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getDisallowedSecondRootField(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getDisallowedSecondRootField(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); @@ -656,7 +571,7 @@ service::AwaitableResolver Subscription::resolve_typename(service::ResolverParam return service::ModifiedResult::convert(response::StringType{ R"gql(Subscription)gql" }, std::move(params)); } -Message::Message() +Message::Message(std::unique_ptr&& pimpl) : service::Object({ "Message" }, { @@ -664,34 +579,29 @@ Message::Message() { R"gql(sender)gql"sv, [this](service::ResolverParams&& params) { return resolveSender(std::move(params)); } }, { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } } }) + , _pimpl(std::move(pimpl)) { } -service::FieldResult> Message::getBody(service::FieldParams&&) const +Message::~Message() { - throw std::runtime_error(R"ex(Message::getBody is not implemented)ex"); } service::AwaitableResolver Message::resolveBody(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getBody(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getBody(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult Message::getSender(service::FieldParams&&) const -{ - throw std::runtime_error(R"ex(Message::getSender is not implemented)ex"); -} - service::AwaitableResolver Message::resolveSender(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getSender(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getSender(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); @@ -702,7 +612,7 @@ service::AwaitableResolver Message::resolve_typename(service::ResolverParams&& p return service::ModifiedResult::convert(response::StringType{ R"gql(Message)gql" }, std::move(params)); } -Arguments::Arguments() +Arguments::Arguments(std::unique_ptr&& pimpl) : service::Object({ "Arguments" }, { @@ -716,12 +626,12 @@ Arguments::Arguments() { R"gql(nonNullBooleanListField)gql"sv, [this](service::ResolverParams&& params) { return resolveNonNullBooleanListField(std::move(params)); } }, { R"gql(optionalNonNullBooleanArgField)gql"sv, [this](service::ResolverParams&& params) { return resolveOptionalNonNullBooleanArgField(std::move(params)); } } }) + , _pimpl(std::move(pimpl)) { } -service::FieldResult Arguments::getMultipleReqs(service::FieldParams&&, response::IntType&&, response::IntType&&) const +Arguments::~Arguments() { - throw std::runtime_error(R"ex(Arguments::getMultipleReqs is not implemented)ex"); } service::AwaitableResolver Arguments::resolveMultipleReqs(service::ResolverParams&& params) @@ -730,113 +640,78 @@ service::AwaitableResolver Arguments::resolveMultipleReqs(service::ResolverParam auto argY = service::ModifiedArgument::require("y", params.arguments); std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getMultipleReqs(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argX), std::move(argY)); + auto result = _pimpl->getMultipleReqs(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argX), std::move(argY)); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult> Arguments::getBooleanArgField(service::FieldParams&&, std::optional&&) const -{ - throw std::runtime_error(R"ex(Arguments::getBooleanArgField is not implemented)ex"); -} - service::AwaitableResolver Arguments::resolveBooleanArgField(service::ResolverParams&& params) { auto argBooleanArg = service::ModifiedArgument::require("booleanArg", params.arguments); std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getBooleanArgField(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argBooleanArg)); + auto result = _pimpl->getBooleanArgField(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argBooleanArg)); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult> Arguments::getFloatArgField(service::FieldParams&&, std::optional&&) const -{ - throw std::runtime_error(R"ex(Arguments::getFloatArgField is not implemented)ex"); -} - service::AwaitableResolver Arguments::resolveFloatArgField(service::ResolverParams&& params) { auto argFloatArg = service::ModifiedArgument::require("floatArg", params.arguments); std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getFloatArgField(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argFloatArg)); + auto result = _pimpl->getFloatArgField(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argFloatArg)); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult> Arguments::getIntArgField(service::FieldParams&&, std::optional&&) const -{ - throw std::runtime_error(R"ex(Arguments::getIntArgField is not implemented)ex"); -} - service::AwaitableResolver Arguments::resolveIntArgField(service::ResolverParams&& params) { auto argIntArg = service::ModifiedArgument::require("intArg", params.arguments); std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getIntArgField(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argIntArg)); + auto result = _pimpl->getIntArgField(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argIntArg)); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult Arguments::getNonNullBooleanArgField(service::FieldParams&&, response::BooleanType&&) const -{ - throw std::runtime_error(R"ex(Arguments::getNonNullBooleanArgField is not implemented)ex"); -} - service::AwaitableResolver Arguments::resolveNonNullBooleanArgField(service::ResolverParams&& params) { auto argNonNullBooleanArg = service::ModifiedArgument::require("nonNullBooleanArg", params.arguments); std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getNonNullBooleanArgField(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argNonNullBooleanArg)); + auto result = _pimpl->getNonNullBooleanArgField(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argNonNullBooleanArg)); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult>> Arguments::getNonNullBooleanListField(service::FieldParams&&, std::optional>&&) const -{ - throw std::runtime_error(R"ex(Arguments::getNonNullBooleanListField is not implemented)ex"); -} - service::AwaitableResolver Arguments::resolveNonNullBooleanListField(service::ResolverParams&& params) { auto argNonNullBooleanListArg = service::ModifiedArgument::require("nonNullBooleanListArg", params.arguments); std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getNonNullBooleanListField(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argNonNullBooleanListArg)); + auto result = _pimpl->getNonNullBooleanListField(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argNonNullBooleanListArg)); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult>>> Arguments::getBooleanListArgField(service::FieldParams&&, std::vector>&&) const -{ - throw std::runtime_error(R"ex(Arguments::getBooleanListArgField is not implemented)ex"); -} - service::AwaitableResolver Arguments::resolveBooleanListArgField(service::ResolverParams&& params) { auto argBooleanListArg = service::ModifiedArgument::require("booleanListArg", params.arguments); std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getBooleanListArgField(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argBooleanListArg)); + auto result = _pimpl->getBooleanListArgField(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argBooleanListArg)); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::FieldResult Arguments::getOptionalNonNullBooleanArgField(service::FieldParams&&, response::BooleanType&&) const -{ - throw std::runtime_error(R"ex(Arguments::getOptionalNonNullBooleanArgField is not implemented)ex"); -} - service::AwaitableResolver Arguments::resolveOptionalNonNullBooleanArgField(service::ResolverParams&& params) { const auto defaultArguments = []() @@ -856,7 +731,7 @@ service::AwaitableResolver Arguments::resolveOptionalNonNullBooleanArgField(serv : service::ModifiedArgument::require("optionalBooleanArg", defaultArguments)); std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getOptionalNonNullBooleanArgField(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argOptionalBooleanArg)); + auto result = _pimpl->getOptionalNonNullBooleanArgField(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argOptionalBooleanArg)); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); diff --git a/samples/validation/ValidationSchema.h b/samples/validation/ValidationSchema.h index ec903536..a738a995 100644 --- a/samples/validation/ValidationSchema.h +++ b/samples/validation/ValidationSchema.h @@ -72,18 +72,6 @@ namespace object { class Query : public service::Object { -protected: - explicit Query(); - -public: - virtual service::FieldResult> getDog(service::FieldParams&& params) const; - virtual service::FieldResult> getHuman(service::FieldParams&& params) const; - virtual service::FieldResult> getPet(service::FieldParams&& params) const; - virtual service::FieldResult> getCatOrDog(service::FieldParams&& params) const; - virtual service::FieldResult> getArguments(service::FieldParams&& params) const; - virtual service::FieldResult> getFindDog(service::FieldParams&& params, std::optional&& complexArg) const; - virtual service::FieldResult> getBooleanList(service::FieldParams&& params, std::optional>&& booleanListArgArg) const; - private: service::AwaitableResolver resolveDog(service::ResolverParams&& params); service::AwaitableResolver resolveHuman(service::ResolverParams&& params); @@ -98,23 +86,83 @@ class Query service::AwaitableResolver resolve_type(service::ResolverParams&& params); std::shared_ptr _schema; + + struct Concept + { + virtual service::FieldResult> getDog(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getHuman(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getPet(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getCatOrDog(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getArguments(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getFindDog(service::FieldParams&& params, std::optional&& complexArg) const = 0; + virtual service::FieldResult> getBooleanList(service::FieldParams&& params, std::optional>&& booleanListArgArg) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::FieldResult> getDog(service::FieldParams&& params) const final + { + return _pimpl->getDog(std::move(params)); + } + + service::FieldResult> getHuman(service::FieldParams&& params) const final + { + return _pimpl->getHuman(std::move(params)); + } + + service::FieldResult> getPet(service::FieldParams&& params) const final + { + return _pimpl->getPet(std::move(params)); + } + + service::FieldResult> getCatOrDog(service::FieldParams&& params) const final + { + return _pimpl->getCatOrDog(std::move(params)); + } + + service::FieldResult> getArguments(service::FieldParams&& params) const final + { + return _pimpl->getArguments(std::move(params)); + } + + service::FieldResult> getFindDog(service::FieldParams&& params, std::optional&& complexArg) const final + { + return _pimpl->getFindDog(std::move(params), std::move(complexArg)); + } + + service::FieldResult> getBooleanList(service::FieldParams&& params, std::optional>&& booleanListArgArg) const final + { + return _pimpl->getBooleanList(std::move(params), std::move(booleanListArgArg)); + } + + private: + const std::shared_ptr _pimpl; + }; + + Query(std::unique_ptr&& pimpl); + + const std::unique_ptr _pimpl; + +public: + template + Query(std::shared_ptr pimpl) + : Query { std::make_unique>(std::move(pimpl)) } + { + } + + ~Query(); }; class Dog : public service::Object - , public Pet { -protected: - explicit Dog(); - -public: - service::FieldResult getName(service::FieldParams&& params) const override; - virtual service::FieldResult> getNickname(service::FieldParams&& params) const; - virtual service::FieldResult> getBarkVolume(service::FieldParams&& params) const; - virtual service::FieldResult getDoesKnowCommand(service::FieldParams&& params, DogCommand&& dogCommandArg) const; - virtual service::FieldResult getIsHousetrained(service::FieldParams&& params, std::optional&& atOtherHomesArg) const; - virtual service::FieldResult> getOwner(service::FieldParams&& params) const; - private: service::AwaitableResolver resolveName(service::ResolverParams&& params); service::AwaitableResolver resolveNickname(service::ResolverParams&& params); @@ -124,57 +172,181 @@ class Dog service::AwaitableResolver resolveOwner(service::ResolverParams&& params); service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + + struct Concept + : Pet + { + virtual service::FieldResult> getNickname(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getBarkVolume(service::FieldParams&& params) const = 0; + virtual service::FieldResult getDoesKnowCommand(service::FieldParams&& params, DogCommand&& dogCommandArg) const = 0; + virtual service::FieldResult getIsHousetrained(service::FieldParams&& params, std::optional&& atOtherHomesArg) const = 0; + virtual service::FieldResult> getOwner(service::FieldParams&& params) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::FieldResult getName(service::FieldParams&& params) const final + { + return _pimpl->getName(std::move(params)); + } + + service::FieldResult> getNickname(service::FieldParams&& params) const final + { + return _pimpl->getNickname(std::move(params)); + } + + service::FieldResult> getBarkVolume(service::FieldParams&& params) const final + { + return _pimpl->getBarkVolume(std::move(params)); + } + + service::FieldResult getDoesKnowCommand(service::FieldParams&& params, DogCommand&& dogCommandArg) const final + { + return _pimpl->getDoesKnowCommand(std::move(params), std::move(dogCommandArg)); + } + + service::FieldResult getIsHousetrained(service::FieldParams&& params, std::optional&& atOtherHomesArg) const final + { + return _pimpl->getIsHousetrained(std::move(params), std::move(atOtherHomesArg)); + } + + service::FieldResult> getOwner(service::FieldParams&& params) const final + { + return _pimpl->getOwner(std::move(params)); + } + + private: + const std::shared_ptr _pimpl; + }; + + Dog(std::unique_ptr&& pimpl); + + const std::unique_ptr _pimpl; + +public: + template + Dog(std::shared_ptr pimpl) + : Dog { std::make_unique>(std::move(pimpl)) } + { + } + + ~Dog(); }; class Alien : public service::Object - , public Sentient { -protected: - explicit Alien(); - -public: - service::FieldResult getName(service::FieldParams&& params) const override; - virtual service::FieldResult> getHomePlanet(service::FieldParams&& params) const; - private: service::AwaitableResolver resolveName(service::ResolverParams&& params); service::AwaitableResolver resolveHomePlanet(service::ResolverParams&& params); service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + + struct Concept + : Sentient + { + virtual service::FieldResult> getHomePlanet(service::FieldParams&& params) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::FieldResult getName(service::FieldParams&& params) const final + { + return _pimpl->getName(std::move(params)); + } + + service::FieldResult> getHomePlanet(service::FieldParams&& params) const final + { + return _pimpl->getHomePlanet(std::move(params)); + } + + private: + const std::shared_ptr _pimpl; + }; + + Alien(std::unique_ptr&& pimpl); + + const std::unique_ptr _pimpl; + +public: + template + Alien(std::shared_ptr pimpl) + : Alien { std::make_unique>(std::move(pimpl)) } + { + } + + ~Alien(); }; class Human : public service::Object - , public Sentient { -protected: - explicit Human(); - -public: - service::FieldResult getName(service::FieldParams&& params) const override; - virtual service::FieldResult>> getPets(service::FieldParams&& params) const; - private: service::AwaitableResolver resolveName(service::ResolverParams&& params); service::AwaitableResolver resolvePets(service::ResolverParams&& params); service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + + struct Concept + : Sentient + { + virtual service::FieldResult>> getPets(service::FieldParams&& params) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::FieldResult getName(service::FieldParams&& params) const final + { + return _pimpl->getName(std::move(params)); + } + + service::FieldResult>> getPets(service::FieldParams&& params) const final + { + return _pimpl->getPets(std::move(params)); + } + + private: + const std::shared_ptr _pimpl; + }; + + Human(std::unique_ptr&& pimpl); + + const std::unique_ptr _pimpl; + +public: + template + Human(std::shared_ptr pimpl) + : Human { std::make_unique>(std::move(pimpl)) } + { + } + + ~Human(); }; class Cat : public service::Object - , public Pet { -protected: - explicit Cat(); - -public: - service::FieldResult getName(service::FieldParams&& params) const override; - virtual service::FieldResult> getNickname(service::FieldParams&& params) const; - virtual service::FieldResult getDoesKnowCommand(service::FieldParams&& params, CatCommand&& catCommandArg) const; - virtual service::FieldResult> getMeowVolume(service::FieldParams&& params) const; - private: service::AwaitableResolver resolveName(service::ResolverParams&& params); service::AwaitableResolver resolveNickname(service::ResolverParams&& params); @@ -182,88 +354,259 @@ class Cat service::AwaitableResolver resolveMeowVolume(service::ResolverParams&& params); service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + + struct Concept + : Pet + { + virtual service::FieldResult> getNickname(service::FieldParams&& params) const = 0; + virtual service::FieldResult getDoesKnowCommand(service::FieldParams&& params, CatCommand&& catCommandArg) const = 0; + virtual service::FieldResult> getMeowVolume(service::FieldParams&& params) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::FieldResult getName(service::FieldParams&& params) const final + { + return _pimpl->getName(std::move(params)); + } + + service::FieldResult> getNickname(service::FieldParams&& params) const final + { + return _pimpl->getNickname(std::move(params)); + } + + service::FieldResult getDoesKnowCommand(service::FieldParams&& params, CatCommand&& catCommandArg) const final + { + return _pimpl->getDoesKnowCommand(std::move(params), std::move(catCommandArg)); + } + + service::FieldResult> getMeowVolume(service::FieldParams&& params) const final + { + return _pimpl->getMeowVolume(std::move(params)); + } + + private: + const std::shared_ptr _pimpl; + }; + + Cat(std::unique_ptr&& pimpl); + + const std::unique_ptr _pimpl; + +public: + template + Cat(std::shared_ptr pimpl) + : Cat { std::make_unique>(std::move(pimpl)) } + { + } + + ~Cat(); }; class Mutation : public service::Object { -protected: - explicit Mutation(); - -public: - virtual service::FieldResult> applyMutateDog(service::FieldParams&& params) const; - private: service::AwaitableResolver resolveMutateDog(service::ResolverParams&& params); service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + + struct Concept + { + virtual service::FieldResult> applyMutateDog(service::FieldParams&& params) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::FieldResult> applyMutateDog(service::FieldParams&& params) const final + { + return _pimpl->applyMutateDog(std::move(params)); + } + + private: + const std::shared_ptr _pimpl; + }; + + Mutation(std::unique_ptr&& pimpl); + + const std::unique_ptr _pimpl; + +public: + template + Mutation(std::shared_ptr pimpl) + : Mutation { std::make_unique>(std::move(pimpl)) } + { + } + + ~Mutation(); }; class MutateDogResult : public service::Object { -protected: - explicit MutateDogResult(); - -public: - virtual service::FieldResult getId(service::FieldParams&& params) const; - private: service::AwaitableResolver resolveId(service::ResolverParams&& params); service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + + struct Concept + { + virtual service::FieldResult getId(service::FieldParams&& params) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::FieldResult getId(service::FieldParams&& params) const final + { + return _pimpl->getId(std::move(params)); + } + + private: + const std::shared_ptr _pimpl; + }; + + MutateDogResult(std::unique_ptr&& pimpl); + + const std::unique_ptr _pimpl; + +public: + template + MutateDogResult(std::shared_ptr pimpl) + : MutateDogResult { std::make_unique>(std::move(pimpl)) } + { + } + + ~MutateDogResult(); }; class Subscription : public service::Object { -protected: - explicit Subscription(); - -public: - virtual service::FieldResult> getNewMessage(service::FieldParams&& params) const; - virtual service::FieldResult getDisallowedSecondRootField(service::FieldParams&& params) const; - private: service::AwaitableResolver resolveNewMessage(service::ResolverParams&& params); service::AwaitableResolver resolveDisallowedSecondRootField(service::ResolverParams&& params); service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + + struct Concept + { + virtual service::FieldResult> getNewMessage(service::FieldParams&& params) const = 0; + virtual service::FieldResult getDisallowedSecondRootField(service::FieldParams&& params) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::FieldResult> getNewMessage(service::FieldParams&& params) const final + { + return _pimpl->getNewMessage(std::move(params)); + } + + service::FieldResult getDisallowedSecondRootField(service::FieldParams&& params) const final + { + return _pimpl->getDisallowedSecondRootField(std::move(params)); + } + + private: + const std::shared_ptr _pimpl; + }; + + Subscription(std::unique_ptr&& pimpl); + + const std::unique_ptr _pimpl; + +public: + template + Subscription(std::shared_ptr pimpl) + : Subscription { std::make_unique>(std::move(pimpl)) } + { + } + + ~Subscription(); }; class Message : public service::Object { -protected: - explicit Message(); - -public: - virtual service::FieldResult> getBody(service::FieldParams&& params) const; - virtual service::FieldResult getSender(service::FieldParams&& params) const; - private: service::AwaitableResolver resolveBody(service::ResolverParams&& params); service::AwaitableResolver resolveSender(service::ResolverParams&& params); service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + + struct Concept + { + virtual service::FieldResult> getBody(service::FieldParams&& params) const = 0; + virtual service::FieldResult getSender(service::FieldParams&& params) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::FieldResult> getBody(service::FieldParams&& params) const final + { + return _pimpl->getBody(std::move(params)); + } + + service::FieldResult getSender(service::FieldParams&& params) const final + { + return _pimpl->getSender(std::move(params)); + } + + private: + const std::shared_ptr _pimpl; + }; + + Message(std::unique_ptr&& pimpl); + + const std::unique_ptr _pimpl; + +public: + template + Message(std::shared_ptr pimpl) + : Message { std::make_unique>(std::move(pimpl)) } + { + } + + ~Message(); }; class Arguments : public service::Object { -protected: - explicit Arguments(); - -public: - virtual service::FieldResult getMultipleReqs(service::FieldParams&& params, response::IntType&& xArg, response::IntType&& yArg) const; - virtual service::FieldResult> getBooleanArgField(service::FieldParams&& params, std::optional&& booleanArgArg) const; - virtual service::FieldResult> getFloatArgField(service::FieldParams&& params, std::optional&& floatArgArg) const; - virtual service::FieldResult> getIntArgField(service::FieldParams&& params, std::optional&& intArgArg) const; - virtual service::FieldResult getNonNullBooleanArgField(service::FieldParams&& params, response::BooleanType&& nonNullBooleanArgArg) const; - virtual service::FieldResult>> getNonNullBooleanListField(service::FieldParams&& params, std::optional>&& nonNullBooleanListArgArg) const; - virtual service::FieldResult>>> getBooleanListArgField(service::FieldParams&& params, std::vector>&& booleanListArgArg) const; - virtual service::FieldResult getOptionalNonNullBooleanArgField(service::FieldParams&& params, response::BooleanType&& optionalBooleanArgArg) const; - private: service::AwaitableResolver resolveMultipleReqs(service::ResolverParams&& params); service::AwaitableResolver resolveBooleanArgField(service::ResolverParams&& params); @@ -275,6 +618,84 @@ class Arguments service::AwaitableResolver resolveOptionalNonNullBooleanArgField(service::ResolverParams&& params); service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + + struct Concept + { + virtual service::FieldResult getMultipleReqs(service::FieldParams&& params, response::IntType&& xArg, response::IntType&& yArg) const = 0; + virtual service::FieldResult> getBooleanArgField(service::FieldParams&& params, std::optional&& booleanArgArg) const = 0; + virtual service::FieldResult> getFloatArgField(service::FieldParams&& params, std::optional&& floatArgArg) const = 0; + virtual service::FieldResult> getIntArgField(service::FieldParams&& params, std::optional&& intArgArg) const = 0; + virtual service::FieldResult getNonNullBooleanArgField(service::FieldParams&& params, response::BooleanType&& nonNullBooleanArgArg) const = 0; + virtual service::FieldResult>> getNonNullBooleanListField(service::FieldParams&& params, std::optional>&& nonNullBooleanListArgArg) const = 0; + virtual service::FieldResult>>> getBooleanListArgField(service::FieldParams&& params, std::vector>&& booleanListArgArg) const = 0; + virtual service::FieldResult getOptionalNonNullBooleanArgField(service::FieldParams&& params, response::BooleanType&& optionalBooleanArgArg) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::FieldResult getMultipleReqs(service::FieldParams&& params, response::IntType&& xArg, response::IntType&& yArg) const final + { + return _pimpl->getMultipleReqs(std::move(params), std::move(xArg), std::move(yArg)); + } + + service::FieldResult> getBooleanArgField(service::FieldParams&& params, std::optional&& booleanArgArg) const final + { + return _pimpl->getBooleanArgField(std::move(params), std::move(booleanArgArg)); + } + + service::FieldResult> getFloatArgField(service::FieldParams&& params, std::optional&& floatArgArg) const final + { + return _pimpl->getFloatArgField(std::move(params), std::move(floatArgArg)); + } + + service::FieldResult> getIntArgField(service::FieldParams&& params, std::optional&& intArgArg) const final + { + return _pimpl->getIntArgField(std::move(params), std::move(intArgArg)); + } + + service::FieldResult getNonNullBooleanArgField(service::FieldParams&& params, response::BooleanType&& nonNullBooleanArgArg) const final + { + return _pimpl->getNonNullBooleanArgField(std::move(params), std::move(nonNullBooleanArgArg)); + } + + service::FieldResult>> getNonNullBooleanListField(service::FieldParams&& params, std::optional>&& nonNullBooleanListArgArg) const final + { + return _pimpl->getNonNullBooleanListField(std::move(params), std::move(nonNullBooleanListArgArg)); + } + + service::FieldResult>>> getBooleanListArgField(service::FieldParams&& params, std::vector>&& booleanListArgArg) const final + { + return _pimpl->getBooleanListArgField(std::move(params), std::move(booleanListArgArg)); + } + + service::FieldResult getOptionalNonNullBooleanArgField(service::FieldParams&& params, response::BooleanType&& optionalBooleanArgArg) const final + { + return _pimpl->getOptionalNonNullBooleanArgField(std::move(params), std::move(optionalBooleanArgArg)); + } + + private: + const std::shared_ptr _pimpl; + }; + + Arguments(std::unique_ptr&& pimpl); + + const std::unique_ptr _pimpl; + +public: + template + Arguments(std::shared_ptr pimpl) + : Arguments { std::make_unique>(std::move(pimpl)) } + { + } + + ~Arguments(); }; } // namespace object @@ -285,6 +706,12 @@ class Operations public: explicit Operations(std::shared_ptr query, std::shared_ptr mutation, std::shared_ptr subscription); + template + explicit Operations(std::shared_ptr query, std::shared_ptr mutation, std::shared_ptr subscription) + : Operations { std::make_shared(std::move(query)), std::make_shared(std::move(mutation)), std::make_shared(std::move(subscription)) } + { + } + private: std::shared_ptr _query; std::shared_ptr _mutation; diff --git a/src/Introspection.cpp b/src/Introspection.cpp index 44116409..63691f7d 100644 --- a/src/Introspection.cpp +++ b/src/Introspection.cpp @@ -17,7 +17,7 @@ service::FieldResult>> Schema::getType std::vector> result(types.size()); std::transform(types.begin(), types.end(), result.begin(), [](const auto& entry) { - return std::make_shared(entry.second); + return std::make_shared(std::make_shared(entry.second)); }); return result; @@ -28,7 +28,7 @@ service::FieldResult> Schema::getQueryType( { const auto& queryType = _schema->queryType(); - return queryType ? std::make_shared(queryType) : nullptr; + return queryType ? std::make_shared(std::make_shared(queryType)) : nullptr; } service::FieldResult> Schema::getMutationType( @@ -36,7 +36,8 @@ service::FieldResult> Schema::getMutationType( { const auto& mutationType = _schema->mutationType(); - return mutationType ? std::make_shared(mutationType) : nullptr; + return mutationType ? std::make_shared(std::make_shared(mutationType)) + : nullptr; } service::FieldResult> Schema::getSubscriptionType( @@ -44,7 +45,9 @@ service::FieldResult> Schema::getSubscriptionType( { const auto& subscriptionType = _schema->subscriptionType(); - return subscriptionType ? std::make_shared(subscriptionType) : nullptr; + return subscriptionType + ? std::make_shared(std::make_shared(subscriptionType)) + : nullptr; } service::FieldResult>> Schema::getDirectives( @@ -54,7 +57,7 @@ service::FieldResult>> Schema::ge std::vector> result(directives.size()); std::transform(directives.begin(), directives.end(), result.begin(), [](const auto& entry) { - return std::make_shared(entry); + return std::make_shared(std::make_shared(entry)); }); return result; @@ -109,7 +112,7 @@ service::FieldResult>>> { if (deprecated || !field->deprecationReason()) { - result->push_back(std::make_shared(field)); + result->push_back(std::make_shared(std::make_shared(field))); } } @@ -132,7 +135,7 @@ service::FieldResult>>> auto result = std::make_optional>>(interfaces.size()); std::transform(interfaces.begin(), interfaces.end(), result->begin(), [](const auto& entry) { - return std::make_shared(entry); + return std::make_shared(std::make_shared(entry)); }); return result; @@ -159,7 +162,7 @@ service::FieldResult>>> possibleTypes.end(), result->begin(), [](const auto& entry) { - return std::make_shared(entry.lock()); + return std::make_shared(std::make_shared(entry.lock())); }); return result; @@ -187,7 +190,8 @@ service::FieldResultdeprecationReason()) { - result->push_back(std::make_shared(value)); + result->push_back( + std::make_shared(std::make_shared(value))); } } @@ -211,7 +215,7 @@ service::FieldResult>>(inputFields.size()); std::transform(inputFields.begin(), inputFields.end(), result->begin(), [](const auto& entry) { - return std::make_shared(entry); + return std::make_shared(std::make_shared(entry)); }); return result; @@ -231,7 +235,7 @@ service::FieldResult> Type::getOfType(service::Fie const auto ofType = _type->ofType().lock(); - return ofType ? std::make_shared(ofType) : nullptr; + return ofType ? std::make_shared(std::make_shared(ofType)) : nullptr; } Field::Field(const std::shared_ptr& field) @@ -260,7 +264,7 @@ service::FieldResult>> Field::ge std::vector> result(args.size()); std::transform(args.begin(), args.end(), result.begin(), [](const auto& entry) { - return std::make_shared(entry); + return std::make_shared(std::make_shared(entry)); }); return result; @@ -270,7 +274,7 @@ service::FieldResult> Field::getType(service::Fiel { const auto type = _field->type().lock(); - return type ? std::make_shared(type) : nullptr; + return type ? std::make_shared(std::make_shared(type)) : nullptr; } service::FieldResult Field::getIsDeprecated(service::FieldParams&&) const @@ -311,7 +315,7 @@ service::FieldResult> InputValue::getType( { const auto type = _inputValue->type().lock(); - return type ? std::make_shared(type) : nullptr; + return type ? std::make_shared(std::make_shared(type)) : nullptr; } service::FieldResult> InputValue::getDefaultValue( @@ -388,7 +392,7 @@ service::FieldResult>> Directive std::vector> result(args.size()); std::transform(args.begin(), args.end(), result.begin(), [](const auto& entry) { - return std::make_shared(entry); + return std::make_shared(std::make_shared(entry)); }); return result; diff --git a/src/IntrospectionSchema.cpp b/src/IntrospectionSchema.cpp index 42dee636..9154bb31 100644 --- a/src/IntrospectionSchema.cpp +++ b/src/IntrospectionSchema.cpp @@ -120,7 +120,7 @@ service::AwaitableResolver ModifiedResult::con namespace introspection { namespace object { -Schema::Schema() +Schema::Schema(std::unique_ptr&& pimpl) : service::Object({ "__Schema" }, { @@ -131,6 +131,11 @@ Schema::Schema() { R"gql(mutationType)gql"sv, [this](service::ResolverParams&& params) { return resolveMutationType(std::move(params)); } }, { R"gql(subscriptionType)gql"sv, [this](service::ResolverParams&& params) { return resolveSubscriptionType(std::move(params)); } } }) + , _pimpl(std::move(pimpl)) +{ +} + +Schema::~Schema() { } @@ -138,7 +143,7 @@ service::AwaitableResolver Schema::resolveTypes(service::ResolverParams&& params { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getTypes(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getTypes(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); @@ -148,7 +153,7 @@ service::AwaitableResolver Schema::resolveQueryType(service::ResolverParams&& pa { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getQueryType(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getQueryType(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); @@ -158,7 +163,7 @@ service::AwaitableResolver Schema::resolveMutationType(service::ResolverParams&& { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getMutationType(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getMutationType(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); @@ -168,7 +173,7 @@ service::AwaitableResolver Schema::resolveSubscriptionType(service::ResolverPara { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getSubscriptionType(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getSubscriptionType(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); @@ -178,7 +183,7 @@ service::AwaitableResolver Schema::resolveDirectives(service::ResolverParams&& p { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getDirectives(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getDirectives(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); @@ -189,7 +194,7 @@ service::AwaitableResolver Schema::resolve_typename(service::ResolverParams&& pa return service::ModifiedResult::convert(response::StringType{ R"gql(__Schema)gql" }, std::move(params)); } -Type::Type() +Type::Type(std::unique_ptr&& pimpl) : service::Object({ "__Type" }, { @@ -204,6 +209,11 @@ Type::Type() { R"gql(inputFields)gql"sv, [this](service::ResolverParams&& params) { return resolveInputFields(std::move(params)); } }, { R"gql(possibleTypes)gql"sv, [this](service::ResolverParams&& params) { return resolvePossibleTypes(std::move(params)); } } }) + , _pimpl(std::move(pimpl)) +{ +} + +Type::~Type() { } @@ -211,7 +221,7 @@ service::AwaitableResolver Type::resolveKind(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getKind(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getKind(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); @@ -221,7 +231,7 @@ service::AwaitableResolver Type::resolveName(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getName(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getName(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); @@ -231,7 +241,7 @@ service::AwaitableResolver Type::resolveDescription(service::ResolverParams&& pa { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getDescription(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getDescription(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); @@ -256,7 +266,7 @@ service::AwaitableResolver Type::resolveFields(service::ResolverParams&& params) : service::ModifiedArgument::require("includeDeprecated", defaultArguments)); std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getFields(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argIncludeDeprecated)); + auto result = _pimpl->getFields(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argIncludeDeprecated)); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); @@ -266,7 +276,7 @@ service::AwaitableResolver Type::resolveInterfaces(service::ResolverParams&& par { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getInterfaces(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getInterfaces(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); @@ -276,7 +286,7 @@ service::AwaitableResolver Type::resolvePossibleTypes(service::ResolverParams&& { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getPossibleTypes(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getPossibleTypes(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); @@ -301,7 +311,7 @@ service::AwaitableResolver Type::resolveEnumValues(service::ResolverParams&& par : service::ModifiedArgument::require("includeDeprecated", defaultArguments)); std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getEnumValues(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argIncludeDeprecated)); + auto result = _pimpl->getEnumValues(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argIncludeDeprecated)); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); @@ -311,7 +321,7 @@ service::AwaitableResolver Type::resolveInputFields(service::ResolverParams&& pa { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getInputFields(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getInputFields(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); @@ -321,7 +331,7 @@ service::AwaitableResolver Type::resolveOfType(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getOfType(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getOfType(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); @@ -332,7 +342,7 @@ service::AwaitableResolver Type::resolve_typename(service::ResolverParams&& para return service::ModifiedResult::convert(response::StringType{ R"gql(__Type)gql" }, std::move(params)); } -Field::Field() +Field::Field(std::unique_ptr&& pimpl) : service::Object({ "__Field" }, { @@ -344,6 +354,11 @@ Field::Field() { R"gql(isDeprecated)gql"sv, [this](service::ResolverParams&& params) { return resolveIsDeprecated(std::move(params)); } }, { R"gql(deprecationReason)gql"sv, [this](service::ResolverParams&& params) { return resolveDeprecationReason(std::move(params)); } } }) + , _pimpl(std::move(pimpl)) +{ +} + +Field::~Field() { } @@ -351,7 +366,7 @@ service::AwaitableResolver Field::resolveName(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getName(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getName(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); @@ -361,7 +376,7 @@ service::AwaitableResolver Field::resolveDescription(service::ResolverParams&& p { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getDescription(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getDescription(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); @@ -371,7 +386,7 @@ service::AwaitableResolver Field::resolveArgs(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getArgs(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getArgs(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); @@ -381,7 +396,7 @@ service::AwaitableResolver Field::resolveType(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getType(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getType(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); @@ -391,7 +406,7 @@ service::AwaitableResolver Field::resolveIsDeprecated(service::ResolverParams&& { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getIsDeprecated(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getIsDeprecated(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); @@ -401,7 +416,7 @@ service::AwaitableResolver Field::resolveDeprecationReason(service::ResolverPara { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getDeprecationReason(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getDeprecationReason(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); @@ -412,7 +427,7 @@ service::AwaitableResolver Field::resolve_typename(service::ResolverParams&& par return service::ModifiedResult::convert(response::StringType{ R"gql(__Field)gql" }, std::move(params)); } -InputValue::InputValue() +InputValue::InputValue(std::unique_ptr&& pimpl) : service::Object({ "__InputValue" }, { @@ -422,6 +437,11 @@ InputValue::InputValue() { R"gql(description)gql"sv, [this](service::ResolverParams&& params) { return resolveDescription(std::move(params)); } }, { R"gql(defaultValue)gql"sv, [this](service::ResolverParams&& params) { return resolveDefaultValue(std::move(params)); } } }) + , _pimpl(std::move(pimpl)) +{ +} + +InputValue::~InputValue() { } @@ -429,7 +449,7 @@ service::AwaitableResolver InputValue::resolveName(service::ResolverParams&& par { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getName(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getName(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); @@ -439,7 +459,7 @@ service::AwaitableResolver InputValue::resolveDescription(service::ResolverParam { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getDescription(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getDescription(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); @@ -449,7 +469,7 @@ service::AwaitableResolver InputValue::resolveType(service::ResolverParams&& par { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getType(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getType(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); @@ -459,7 +479,7 @@ service::AwaitableResolver InputValue::resolveDefaultValue(service::ResolverPara { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getDefaultValue(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getDefaultValue(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); @@ -470,7 +490,7 @@ service::AwaitableResolver InputValue::resolve_typename(service::ResolverParams& return service::ModifiedResult::convert(response::StringType{ R"gql(__InputValue)gql" }, std::move(params)); } -EnumValue::EnumValue() +EnumValue::EnumValue(std::unique_ptr&& pimpl) : service::Object({ "__EnumValue" }, { @@ -480,6 +500,11 @@ EnumValue::EnumValue() { R"gql(isDeprecated)gql"sv, [this](service::ResolverParams&& params) { return resolveIsDeprecated(std::move(params)); } }, { R"gql(deprecationReason)gql"sv, [this](service::ResolverParams&& params) { return resolveDeprecationReason(std::move(params)); } } }) + , _pimpl(std::move(pimpl)) +{ +} + +EnumValue::~EnumValue() { } @@ -487,7 +512,7 @@ service::AwaitableResolver EnumValue::resolveName(service::ResolverParams&& para { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getName(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getName(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); @@ -497,7 +522,7 @@ service::AwaitableResolver EnumValue::resolveDescription(service::ResolverParams { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getDescription(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getDescription(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); @@ -507,7 +532,7 @@ service::AwaitableResolver EnumValue::resolveIsDeprecated(service::ResolverParam { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getIsDeprecated(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getIsDeprecated(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); @@ -517,7 +542,7 @@ service::AwaitableResolver EnumValue::resolveDeprecationReason(service::Resolver { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getDeprecationReason(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getDeprecationReason(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); @@ -528,7 +553,7 @@ service::AwaitableResolver EnumValue::resolve_typename(service::ResolverParams&& return service::ModifiedResult::convert(response::StringType{ R"gql(__EnumValue)gql" }, std::move(params)); } -Directive::Directive() +Directive::Directive(std::unique_ptr&& pimpl) : service::Object({ "__Directive" }, { @@ -538,6 +563,11 @@ Directive::Directive() { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, { R"gql(description)gql"sv, [this](service::ResolverParams&& params) { return resolveDescription(std::move(params)); } } }) + , _pimpl(std::move(pimpl)) +{ +} + +Directive::~Directive() { } @@ -545,7 +575,7 @@ service::AwaitableResolver Directive::resolveName(service::ResolverParams&& para { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getName(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getName(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); @@ -555,7 +585,7 @@ service::AwaitableResolver Directive::resolveDescription(service::ResolverParams { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getDescription(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getDescription(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); @@ -565,7 +595,7 @@ service::AwaitableResolver Directive::resolveLocations(service::ResolverParams&& { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getLocations(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getLocations(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); @@ -575,7 +605,7 @@ service::AwaitableResolver Directive::resolveArgs(service::ResolverParams&& para { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = getArgs(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getArgs(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); diff --git a/src/SchemaGenerator.cpp b/src/SchemaGenerator.cpp index fa598962..6c6af28c 100644 --- a/src/SchemaGenerator.cpp +++ b/src/SchemaGenerator.cpp @@ -345,7 +345,66 @@ static_assert(graphql::internal::MinorVersion == )cpp" } headerFile << R"cpp(); +)cpp"; + + if (!_loader.getOperationTypes().empty()) + { + firstOperation = true; + + headerFile << R"cpp( + template <)cpp"; + for (const auto& operation : _loader.getOperationTypes()) + { + if (!firstOperation) + { + headerFile << R"cpp(, )cpp"; + } + + firstOperation = false; + headerFile << R"cpp(class T)cpp" << operation.cppType; + } + + headerFile << R"cpp(> + explicit Operations()cpp"; + firstOperation = true; + + for (const auto& operation : _loader.getOperationTypes()) + { + if (!firstOperation) + { + headerFile << R"cpp(, )cpp"; + } + + firstOperation = false; + headerFile << R"cpp(std::shared_ptr )cpp" + << operation.operation; + } + + headerFile << R"cpp() + : Operations {)cpp"; + + firstOperation = true; + + for (const auto& operation : _loader.getOperationTypes()) + { + if (!firstOperation) + { + headerFile << R"cpp(,)cpp"; + } + + firstOperation = false; + headerFile << R"cpp( std::make_shared(std::move()cpp" << operation.operation << R"cpp()))cpp"; + } + + headerFile << R"cpp( } + { + } +)cpp"; + } + + headerFile << R"cpp( private: )cpp"; @@ -444,68 +503,147 @@ void Generator::outputObjectDeclaration( std::ostream& headerFile, const ObjectType& objectType, bool isQueryType) const { headerFile << R"cpp(class )cpp" << objectType.cppType << R"cpp( - : public service::Object)cpp"; + : public service::Object +{ +private: +)cpp"; - for (const auto& interfaceName : objectType.interfaces) + for (const auto& outputField : objectType.fields) { - headerFile << R"cpp( - , public )cpp" << _loader.getSafeCppName(interfaceName); + headerFile << getResolverDeclaration(outputField); } headerFile << R"cpp( -{ -protected: - explicit )cpp" - << objectType.cppType << R"cpp((); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params); )cpp"; - if (!objectType.fields.empty()) + if (!_options.noIntrospection && isQueryType) + { + headerFile + << R"cpp( service::AwaitableResolver resolve_schema(service::ResolverParams&& params); + service::AwaitableResolver resolve_type(service::ResolverParams&& params); + + std::shared_ptr _schema; +)cpp"; + } + + headerFile << R"cpp( + struct Concept)cpp"; + + if (!objectType.interfaces.empty()) { - bool firstField = true; + bool firstInterface = true; - for (const auto& outputField : objectType.fields) + for (const auto& interfaceName : objectType.interfaces) { - if (outputField.inheritedField && (_loader.isIntrospection() || _options.noStubs)) + headerFile << R"cpp( + )cpp"; + + if (firstInterface) { - continue; + headerFile << R"cpp(: )cpp"; + firstInterface = false; } - - if (firstField) + else { - headerFile << R"cpp( -public: -)cpp"; - firstField = false; + headerFile << R"cpp(, )cpp"; } - headerFile << getFieldDeclaration(outputField); + headerFile << _loader.getSafeCppName(interfaceName); } + } - headerFile << R"cpp( -private: + headerFile << R"cpp( + { )cpp"; - for (const auto& outputField : objectType.fields) + for (const auto& outputField : objectType.fields) + { + if (outputField.inheritedField) { - headerFile << getResolverDeclaration(outputField); + continue; } - headerFile << R"cpp( - service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + headerFile << R"cpp( )cpp" << getFieldDeclaration(outputField); + } + + headerFile << R"cpp( }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } )cpp"; - if (!_options.noIntrospection && isQueryType) + for (const auto& outputField : objectType.fields) + { + std::string fieldName(outputField.cppName); + + fieldName[0] = static_cast(std::toupper(static_cast(fieldName[0]))); + + headerFile << R"cpp( + service::FieldResult<)cpp" + << _loader.getOutputCppType(outputField) << R"cpp(> )cpp" << outputField.accessor + << fieldName << R"cpp((service::FieldParams&& params)cpp"; + for (const auto& argument : outputField.arguments) { - headerFile - << R"cpp( service::AwaitableResolver resolve_schema(service::ResolverParams&& params); - service::AwaitableResolver resolve_type(service::ResolverParams&& params); + headerFile << R"cpp(, )cpp" << _loader.getInputCppType(argument) << R"cpp(&& )cpp" + << argument.cppName << "Arg"; + } - std::shared_ptr _schema; -)cpp"; + headerFile << R"cpp() const final + { + return _pimpl->)cpp" + << outputField.accessor << fieldName << R"cpp((std::move(params))cpp"; + + for (const auto& argument : outputField.arguments) + { + headerFile << R"cpp(, std::move()cpp" << argument.cppName << "Arg)"; + } + + headerFile << R"cpp(); } +)cpp"; } - headerFile << R"cpp(}; + headerFile << R"cpp( + private: + const std::shared_ptr _pimpl; + }; + + )cpp"; + + if (_loader.isIntrospection()) + { + headerFile << R"cpp(GRAPHQLINTROSPECTION_EXPORT )cpp"; + } + + headerFile << objectType.cppType << R"cpp((std::unique_ptr&& pimpl); + + const std::unique_ptr _pimpl; + +public: + template + )cpp" << objectType.cppType + << R"cpp((std::shared_ptr pimpl) + : )cpp" << objectType.cppType + << R"cpp( { std::make_unique>(std::move(pimpl)) } + { + } + + )cpp"; + + if (_loader.isIntrospection()) + { + headerFile << R"cpp(GRAPHQLINTROSPECTION_EXPORT )cpp"; + } + + headerFile << R"cpp(~)cpp" << objectType.cppType << R"cpp((); +}; )cpp"; } @@ -542,16 +680,7 @@ std::string Generator::getFieldDeclaration(const OutputField& outputField) const << argument.cppName << "Arg"; } - output << R"cpp() const)cpp"; - if (outputField.interfaceField || _loader.isIntrospection() || _options.noStubs) - { - output << R"cpp( = 0)cpp"; - } - else if (outputField.inheritedField) - { - output << R"cpp( override)cpp"; - } - output << R"cpp(; + output << R"cpp() const = 0; )cpp"; return output.str(); @@ -1378,7 +1507,8 @@ void Generator::outputObjectImplementation( // Output the protected constructor which calls through to the service::Object constructor // with arguments that declare the set of types it implements and bind the fields to the // resolver methods. - sourceFile << objectType.cppType << R"cpp(::)cpp" << objectType.cppType << R"cpp(() + sourceFile << objectType.cppType << R"cpp(::)cpp" << objectType.cppType + << R"cpp((std::unique_ptr&& pimpl) : service::Object({ )cpp"; @@ -1453,6 +1583,12 @@ void Generator::outputObjectImplementation( } sourceFile << R"cpp( + , _pimpl(std::move(pimpl)) +{ +} + +)cpp" << objectType.cppType + << R"cpp(::~)cpp" << objectType.cppType << R"cpp(() { } )cpp"; @@ -1464,26 +1600,6 @@ void Generator::outputObjectImplementation( std::string fieldName(outputField.cppName); fieldName[0] = static_cast(std::toupper(static_cast(fieldName[0]))); - if (!_loader.isIntrospection() && !_options.noStubs) - { - sourceFile << R"cpp( -service::FieldResult<)cpp" - << _loader.getOutputCppType(outputField) << R"cpp(> )cpp" - << objectType.cppType << R"cpp(::)cpp" << outputField.accessor << fieldName - << R"cpp((service::FieldParams&&)cpp"; - for (const auto& argument : outputField.arguments) - { - sourceFile << R"cpp(, )cpp" << _loader.getInputCppType(argument) << R"cpp(&&)cpp"; - } - - sourceFile << R"cpp() const -{ - throw std::runtime_error(R"ex()cpp" - << objectType.cppType << R"cpp(::)cpp" << outputField.accessor << fieldName - << R"cpp( is not implemented)ex"); -} -)cpp"; - } sourceFile << R"cpp( service::AwaitableResolver )cpp" @@ -1540,7 +1656,7 @@ service::AwaitableResolver )cpp" sourceFile << R"cpp( std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); - auto result = )cpp" + auto result = _pimpl->)cpp" << outputField.accessor << fieldName << R"cpp((service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)))cpp"; @@ -1584,7 +1700,9 @@ service::AwaitableResolver )cpp" { return service::ModifiedResult::convert(std::static_pointer_cast(std::make_shared<)cpp" << SchemaLoader::getIntrospectionNamespace() - << R"cpp(::Schema>(_schema)), std::move(params)); + << R"cpp(::object::Schema>(std::make_shared<)cpp" + << SchemaLoader::getIntrospectionNamespace() + << R"cpp(::Schema>(_schema))), std::move(params)); } service::AwaitableResolver )cpp" @@ -1595,7 +1713,9 @@ service::AwaitableResolver )cpp" std::shared_ptr<)cpp" << SchemaLoader::getIntrospectionNamespace() << R"cpp(::object::Type> result { baseType ? std::make_shared<)cpp" - << SchemaLoader::getIntrospectionNamespace() << R"cpp(::Type>(baseType) : nullptr }; + << SchemaLoader::getIntrospectionNamespace() + << R"cpp(::object::Type>(std::make_shared<)cpp" + << SchemaLoader::getIntrospectionNamespace() << R"cpp(::Type>(baseType)) : nullptr }; return service::ModifiedResult<)cpp" << SchemaLoader::getIntrospectionNamespace() From 76428d1541a840a44a8a470037a6d693b7aa9981 Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Mon, 29 Nov 2021 19:50:09 -0800 Subject: [PATCH 026/119] Declare a default virtual destructor on Concepts --- .../introspection/IntrospectionSchema.h | 12 +++++++ samples/learn/DroidObject.h | 2 ++ samples/learn/HumanObject.h | 2 ++ samples/learn/MutationObject.h | 2 ++ samples/learn/QueryObject.h | 2 ++ samples/learn/ReviewObject.h | 2 ++ .../separate/AppointmentConnectionObject.h | 2 ++ samples/separate/AppointmentEdgeObject.h | 2 ++ samples/separate/AppointmentObject.h | 2 ++ samples/separate/CompleteTaskPayloadObject.h | 2 ++ samples/separate/ExpensiveObject.h | 2 ++ samples/separate/FolderConnectionObject.h | 2 ++ samples/separate/FolderEdgeObject.h | 2 ++ samples/separate/FolderObject.h | 2 ++ samples/separate/MutationObject.h | 2 ++ samples/separate/NestedTypeObject.h | 2 ++ samples/separate/PageInfoObject.h | 2 ++ samples/separate/QueryObject.h | 2 ++ samples/separate/SubscriptionObject.h | 2 ++ samples/separate/TaskConnectionObject.h | 2 ++ samples/separate/TaskEdgeObject.h | 2 ++ samples/separate/TaskObject.h | 2 ++ .../AppointmentConnectionObject.h | 2 ++ .../AppointmentEdgeObject.h | 2 ++ .../AppointmentObject.h | 2 ++ .../CompleteTaskPayloadObject.h | 2 ++ .../ExpensiveObject.h | 2 ++ .../FolderConnectionObject.h | 2 ++ .../FolderEdgeObject.h | 2 ++ .../separate_nointrospection/FolderObject.h | 2 ++ .../separate_nointrospection/MutationObject.h | 2 ++ .../NestedTypeObject.h | 2 ++ .../separate_nointrospection/PageInfoObject.h | 2 ++ .../separate_nointrospection/QueryObject.h | 2 ++ .../SubscriptionObject.h | 2 ++ .../TaskConnectionObject.h | 2 ++ .../separate_nointrospection/TaskEdgeObject.h | 2 ++ samples/separate_nointrospection/TaskObject.h | 2 ++ samples/unified/TodaySchema.h | 32 +++++++++++++++++++ samples/unified_nointrospection/TodaySchema.h | 32 +++++++++++++++++++ samples/validation/ValidationSchema.h | 20 ++++++++++++ src/SchemaGenerator.cpp | 2 ++ 42 files changed, 172 insertions(+) diff --git a/include/graphqlservice/introspection/IntrospectionSchema.h b/include/graphqlservice/introspection/IntrospectionSchema.h index 0eff508a..8264ee67 100644 --- a/include/graphqlservice/introspection/IntrospectionSchema.h +++ b/include/graphqlservice/introspection/IntrospectionSchema.h @@ -90,6 +90,8 @@ class Schema struct Concept { + virtual ~Concept() = default; + virtual service::FieldResult>> getTypes(service::FieldParams&& params) const = 0; virtual service::FieldResult> getQueryType(service::FieldParams&& params) const = 0; virtual service::FieldResult> getMutationType(service::FieldParams&& params) const = 0; @@ -167,6 +169,8 @@ class Type struct Concept { + virtual ~Concept() = default; + virtual service::FieldResult getKind(service::FieldParams&& params) const = 0; virtual service::FieldResult> getName(service::FieldParams&& params) const = 0; virtual service::FieldResult> getDescription(service::FieldParams&& params) const = 0; @@ -265,6 +269,8 @@ class Field struct Concept { + virtual ~Concept() = default; + virtual service::FieldResult getName(service::FieldParams&& params) const = 0; virtual service::FieldResult> getDescription(service::FieldParams&& params) const = 0; virtual service::FieldResult>> getArgs(service::FieldParams&& params) const = 0; @@ -343,6 +349,8 @@ class InputValue struct Concept { + virtual ~Concept() = default; + virtual service::FieldResult getName(service::FieldParams&& params) const = 0; virtual service::FieldResult> getDescription(service::FieldParams&& params) const = 0; virtual service::FieldResult> getType(service::FieldParams&& params) const = 0; @@ -409,6 +417,8 @@ class EnumValue struct Concept { + virtual ~Concept() = default; + virtual service::FieldResult getName(service::FieldParams&& params) const = 0; virtual service::FieldResult> getDescription(service::FieldParams&& params) const = 0; virtual service::FieldResult getIsDeprecated(service::FieldParams&& params) const = 0; @@ -475,6 +485,8 @@ class Directive struct Concept { + virtual ~Concept() = default; + virtual service::FieldResult getName(service::FieldParams&& params) const = 0; virtual service::FieldResult> getDescription(service::FieldParams&& params) const = 0; virtual service::FieldResult> getLocations(service::FieldParams&& params) const = 0; diff --git a/samples/learn/DroidObject.h b/samples/learn/DroidObject.h index 392ef450..08d2db66 100644 --- a/samples/learn/DroidObject.h +++ b/samples/learn/DroidObject.h @@ -27,6 +27,8 @@ class Droid struct Concept : Character { + virtual ~Concept() = default; + virtual service::FieldResult> getPrimaryFunction(service::FieldParams&& params) const = 0; }; diff --git a/samples/learn/HumanObject.h b/samples/learn/HumanObject.h index 06010271..c4bc6f65 100644 --- a/samples/learn/HumanObject.h +++ b/samples/learn/HumanObject.h @@ -27,6 +27,8 @@ class Human struct Concept : Character { + virtual ~Concept() = default; + virtual service::FieldResult> getHomePlanet(service::FieldParams&& params) const = 0; }; diff --git a/samples/learn/MutationObject.h b/samples/learn/MutationObject.h index 25fdde16..32a19474 100644 --- a/samples/learn/MutationObject.h +++ b/samples/learn/MutationObject.h @@ -22,6 +22,8 @@ class Mutation struct Concept { + virtual ~Concept() = default; + virtual service::FieldResult> applyCreateReview(service::FieldParams&& params, Episode&& epArg, ReviewInput&& reviewArg) const = 0; }; diff --git a/samples/learn/QueryObject.h b/samples/learn/QueryObject.h index bf69a0a0..fc4613e1 100644 --- a/samples/learn/QueryObject.h +++ b/samples/learn/QueryObject.h @@ -28,6 +28,8 @@ class Query struct Concept { + virtual ~Concept() = default; + virtual service::FieldResult> getHero(service::FieldParams&& params, std::optional&& episodeArg) const = 0; virtual service::FieldResult> getHuman(service::FieldParams&& params, response::StringType&& idArg) const = 0; virtual service::FieldResult> getDroid(service::FieldParams&& params, response::StringType&& idArg) const = 0; diff --git a/samples/learn/ReviewObject.h b/samples/learn/ReviewObject.h index c04b2436..81fd39c6 100644 --- a/samples/learn/ReviewObject.h +++ b/samples/learn/ReviewObject.h @@ -23,6 +23,8 @@ class Review struct Concept { + virtual ~Concept() = default; + virtual service::FieldResult getStars(service::FieldParams&& params) const = 0; virtual service::FieldResult> getCommentary(service::FieldParams&& params) const = 0; }; diff --git a/samples/separate/AppointmentConnectionObject.h b/samples/separate/AppointmentConnectionObject.h index e0338c67..1871b22a 100644 --- a/samples/separate/AppointmentConnectionObject.h +++ b/samples/separate/AppointmentConnectionObject.h @@ -23,6 +23,8 @@ class AppointmentConnection struct Concept { + virtual ~Concept() = default; + virtual service::FieldResult> getPageInfo(service::FieldParams&& params) const = 0; virtual service::FieldResult>>> getEdges(service::FieldParams&& params) const = 0; }; diff --git a/samples/separate/AppointmentEdgeObject.h b/samples/separate/AppointmentEdgeObject.h index 8101c409..0c25e610 100644 --- a/samples/separate/AppointmentEdgeObject.h +++ b/samples/separate/AppointmentEdgeObject.h @@ -23,6 +23,8 @@ class AppointmentEdge struct Concept { + virtual ~Concept() = default; + virtual service::FieldResult> getNode(service::FieldParams&& params) const = 0; virtual service::FieldResult getCursor(service::FieldParams&& params) const = 0; }; diff --git a/samples/separate/AppointmentObject.h b/samples/separate/AppointmentObject.h index c7449b1d..4e951093 100644 --- a/samples/separate/AppointmentObject.h +++ b/samples/separate/AppointmentObject.h @@ -27,6 +27,8 @@ class Appointment struct Concept : Node { + virtual ~Concept() = default; + virtual service::FieldResult> getWhen(service::FieldParams&& params) const = 0; virtual service::FieldResult> getSubject(service::FieldParams&& params) const = 0; virtual service::FieldResult getIsNow(service::FieldParams&& params) const = 0; diff --git a/samples/separate/CompleteTaskPayloadObject.h b/samples/separate/CompleteTaskPayloadObject.h index 597d9f2d..aae6f08f 100644 --- a/samples/separate/CompleteTaskPayloadObject.h +++ b/samples/separate/CompleteTaskPayloadObject.h @@ -23,6 +23,8 @@ class CompleteTaskPayload struct Concept { + virtual ~Concept() = default; + virtual service::FieldResult> getTask(service::FieldParams&& params) const = 0; virtual service::FieldResult> getClientMutationId(service::FieldParams&& params) const = 0; }; diff --git a/samples/separate/ExpensiveObject.h b/samples/separate/ExpensiveObject.h index 60682b27..7f644a85 100644 --- a/samples/separate/ExpensiveObject.h +++ b/samples/separate/ExpensiveObject.h @@ -22,6 +22,8 @@ class Expensive struct Concept { + virtual ~Concept() = default; + virtual service::FieldResult getOrder(service::FieldParams&& params) const = 0; }; diff --git a/samples/separate/FolderConnectionObject.h b/samples/separate/FolderConnectionObject.h index 22ec4432..62a5536d 100644 --- a/samples/separate/FolderConnectionObject.h +++ b/samples/separate/FolderConnectionObject.h @@ -23,6 +23,8 @@ class FolderConnection struct Concept { + virtual ~Concept() = default; + virtual service::FieldResult> getPageInfo(service::FieldParams&& params) const = 0; virtual service::FieldResult>>> getEdges(service::FieldParams&& params) const = 0; }; diff --git a/samples/separate/FolderEdgeObject.h b/samples/separate/FolderEdgeObject.h index 19b4d78b..60150db7 100644 --- a/samples/separate/FolderEdgeObject.h +++ b/samples/separate/FolderEdgeObject.h @@ -23,6 +23,8 @@ class FolderEdge struct Concept { + virtual ~Concept() = default; + virtual service::FieldResult> getNode(service::FieldParams&& params) const = 0; virtual service::FieldResult getCursor(service::FieldParams&& params) const = 0; }; diff --git a/samples/separate/FolderObject.h b/samples/separate/FolderObject.h index 91f0fcee..b6b90539 100644 --- a/samples/separate/FolderObject.h +++ b/samples/separate/FolderObject.h @@ -25,6 +25,8 @@ class Folder struct Concept : Node { + virtual ~Concept() = default; + virtual service::FieldResult> getName(service::FieldParams&& params) const = 0; virtual service::FieldResult getUnreadCount(service::FieldParams&& params) const = 0; }; diff --git a/samples/separate/MutationObject.h b/samples/separate/MutationObject.h index afa82edb..d5b78c30 100644 --- a/samples/separate/MutationObject.h +++ b/samples/separate/MutationObject.h @@ -23,6 +23,8 @@ class Mutation struct Concept { + virtual ~Concept() = default; + virtual service::FieldResult> applyCompleteTask(service::FieldParams&& params, CompleteTaskInput&& inputArg) const = 0; virtual service::FieldResult applySetFloat(service::FieldParams&& params, response::FloatType&& valueArg) const = 0; }; diff --git a/samples/separate/NestedTypeObject.h b/samples/separate/NestedTypeObject.h index 47348d9d..ff1b636a 100644 --- a/samples/separate/NestedTypeObject.h +++ b/samples/separate/NestedTypeObject.h @@ -23,6 +23,8 @@ class NestedType struct Concept { + virtual ~Concept() = default; + virtual service::FieldResult getDepth(service::FieldParams&& params) const = 0; virtual service::FieldResult> getNested(service::FieldParams&& params) const = 0; }; diff --git a/samples/separate/PageInfoObject.h b/samples/separate/PageInfoObject.h index bacc5b21..13fc8dd4 100644 --- a/samples/separate/PageInfoObject.h +++ b/samples/separate/PageInfoObject.h @@ -23,6 +23,8 @@ class PageInfo struct Concept { + virtual ~Concept() = default; + virtual service::FieldResult getHasNextPage(service::FieldParams&& params) const = 0; virtual service::FieldResult getHasPreviousPage(service::FieldParams&& params) const = 0; }; diff --git a/samples/separate/QueryObject.h b/samples/separate/QueryObject.h index 93a3bbcf..4171d850 100644 --- a/samples/separate/QueryObject.h +++ b/samples/separate/QueryObject.h @@ -37,6 +37,8 @@ class Query struct Concept { + virtual ~Concept() = default; + virtual service::FieldResult> getNode(service::FieldParams&& params, response::IdType&& idArg) const = 0; virtual service::FieldResult> getAppointments(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const = 0; virtual service::FieldResult> getTasks(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const = 0; diff --git a/samples/separate/SubscriptionObject.h b/samples/separate/SubscriptionObject.h index feba2c94..7d08680e 100644 --- a/samples/separate/SubscriptionObject.h +++ b/samples/separate/SubscriptionObject.h @@ -23,6 +23,8 @@ class Subscription struct Concept { + virtual ~Concept() = default; + virtual service::FieldResult> getNextAppointmentChange(service::FieldParams&& params) const = 0; virtual service::FieldResult> getNodeChange(service::FieldParams&& params, response::IdType&& idArg) const = 0; }; diff --git a/samples/separate/TaskConnectionObject.h b/samples/separate/TaskConnectionObject.h index e406fa2b..bf95669f 100644 --- a/samples/separate/TaskConnectionObject.h +++ b/samples/separate/TaskConnectionObject.h @@ -23,6 +23,8 @@ class TaskConnection struct Concept { + virtual ~Concept() = default; + virtual service::FieldResult> getPageInfo(service::FieldParams&& params) const = 0; virtual service::FieldResult>>> getEdges(service::FieldParams&& params) const = 0; }; diff --git a/samples/separate/TaskEdgeObject.h b/samples/separate/TaskEdgeObject.h index 60ced878..92c22089 100644 --- a/samples/separate/TaskEdgeObject.h +++ b/samples/separate/TaskEdgeObject.h @@ -23,6 +23,8 @@ class TaskEdge struct Concept { + virtual ~Concept() = default; + virtual service::FieldResult> getNode(service::FieldParams&& params) const = 0; virtual service::FieldResult getCursor(service::FieldParams&& params) const = 0; }; diff --git a/samples/separate/TaskObject.h b/samples/separate/TaskObject.h index 8a161bbe..acb8193e 100644 --- a/samples/separate/TaskObject.h +++ b/samples/separate/TaskObject.h @@ -25,6 +25,8 @@ class Task struct Concept : Node { + virtual ~Concept() = default; + virtual service::FieldResult> getTitle(service::FieldParams&& params) const = 0; virtual service::FieldResult getIsComplete(service::FieldParams&& params) const = 0; }; diff --git a/samples/separate_nointrospection/AppointmentConnectionObject.h b/samples/separate_nointrospection/AppointmentConnectionObject.h index e0338c67..1871b22a 100644 --- a/samples/separate_nointrospection/AppointmentConnectionObject.h +++ b/samples/separate_nointrospection/AppointmentConnectionObject.h @@ -23,6 +23,8 @@ class AppointmentConnection struct Concept { + virtual ~Concept() = default; + virtual service::FieldResult> getPageInfo(service::FieldParams&& params) const = 0; virtual service::FieldResult>>> getEdges(service::FieldParams&& params) const = 0; }; diff --git a/samples/separate_nointrospection/AppointmentEdgeObject.h b/samples/separate_nointrospection/AppointmentEdgeObject.h index 8101c409..0c25e610 100644 --- a/samples/separate_nointrospection/AppointmentEdgeObject.h +++ b/samples/separate_nointrospection/AppointmentEdgeObject.h @@ -23,6 +23,8 @@ class AppointmentEdge struct Concept { + virtual ~Concept() = default; + virtual service::FieldResult> getNode(service::FieldParams&& params) const = 0; virtual service::FieldResult getCursor(service::FieldParams&& params) const = 0; }; diff --git a/samples/separate_nointrospection/AppointmentObject.h b/samples/separate_nointrospection/AppointmentObject.h index c7449b1d..4e951093 100644 --- a/samples/separate_nointrospection/AppointmentObject.h +++ b/samples/separate_nointrospection/AppointmentObject.h @@ -27,6 +27,8 @@ class Appointment struct Concept : Node { + virtual ~Concept() = default; + virtual service::FieldResult> getWhen(service::FieldParams&& params) const = 0; virtual service::FieldResult> getSubject(service::FieldParams&& params) const = 0; virtual service::FieldResult getIsNow(service::FieldParams&& params) const = 0; diff --git a/samples/separate_nointrospection/CompleteTaskPayloadObject.h b/samples/separate_nointrospection/CompleteTaskPayloadObject.h index 597d9f2d..aae6f08f 100644 --- a/samples/separate_nointrospection/CompleteTaskPayloadObject.h +++ b/samples/separate_nointrospection/CompleteTaskPayloadObject.h @@ -23,6 +23,8 @@ class CompleteTaskPayload struct Concept { + virtual ~Concept() = default; + virtual service::FieldResult> getTask(service::FieldParams&& params) const = 0; virtual service::FieldResult> getClientMutationId(service::FieldParams&& params) const = 0; }; diff --git a/samples/separate_nointrospection/ExpensiveObject.h b/samples/separate_nointrospection/ExpensiveObject.h index 60682b27..7f644a85 100644 --- a/samples/separate_nointrospection/ExpensiveObject.h +++ b/samples/separate_nointrospection/ExpensiveObject.h @@ -22,6 +22,8 @@ class Expensive struct Concept { + virtual ~Concept() = default; + virtual service::FieldResult getOrder(service::FieldParams&& params) const = 0; }; diff --git a/samples/separate_nointrospection/FolderConnectionObject.h b/samples/separate_nointrospection/FolderConnectionObject.h index 22ec4432..62a5536d 100644 --- a/samples/separate_nointrospection/FolderConnectionObject.h +++ b/samples/separate_nointrospection/FolderConnectionObject.h @@ -23,6 +23,8 @@ class FolderConnection struct Concept { + virtual ~Concept() = default; + virtual service::FieldResult> getPageInfo(service::FieldParams&& params) const = 0; virtual service::FieldResult>>> getEdges(service::FieldParams&& params) const = 0; }; diff --git a/samples/separate_nointrospection/FolderEdgeObject.h b/samples/separate_nointrospection/FolderEdgeObject.h index 19b4d78b..60150db7 100644 --- a/samples/separate_nointrospection/FolderEdgeObject.h +++ b/samples/separate_nointrospection/FolderEdgeObject.h @@ -23,6 +23,8 @@ class FolderEdge struct Concept { + virtual ~Concept() = default; + virtual service::FieldResult> getNode(service::FieldParams&& params) const = 0; virtual service::FieldResult getCursor(service::FieldParams&& params) const = 0; }; diff --git a/samples/separate_nointrospection/FolderObject.h b/samples/separate_nointrospection/FolderObject.h index 91f0fcee..b6b90539 100644 --- a/samples/separate_nointrospection/FolderObject.h +++ b/samples/separate_nointrospection/FolderObject.h @@ -25,6 +25,8 @@ class Folder struct Concept : Node { + virtual ~Concept() = default; + virtual service::FieldResult> getName(service::FieldParams&& params) const = 0; virtual service::FieldResult getUnreadCount(service::FieldParams&& params) const = 0; }; diff --git a/samples/separate_nointrospection/MutationObject.h b/samples/separate_nointrospection/MutationObject.h index afa82edb..d5b78c30 100644 --- a/samples/separate_nointrospection/MutationObject.h +++ b/samples/separate_nointrospection/MutationObject.h @@ -23,6 +23,8 @@ class Mutation struct Concept { + virtual ~Concept() = default; + virtual service::FieldResult> applyCompleteTask(service::FieldParams&& params, CompleteTaskInput&& inputArg) const = 0; virtual service::FieldResult applySetFloat(service::FieldParams&& params, response::FloatType&& valueArg) const = 0; }; diff --git a/samples/separate_nointrospection/NestedTypeObject.h b/samples/separate_nointrospection/NestedTypeObject.h index 47348d9d..ff1b636a 100644 --- a/samples/separate_nointrospection/NestedTypeObject.h +++ b/samples/separate_nointrospection/NestedTypeObject.h @@ -23,6 +23,8 @@ class NestedType struct Concept { + virtual ~Concept() = default; + virtual service::FieldResult getDepth(service::FieldParams&& params) const = 0; virtual service::FieldResult> getNested(service::FieldParams&& params) const = 0; }; diff --git a/samples/separate_nointrospection/PageInfoObject.h b/samples/separate_nointrospection/PageInfoObject.h index bacc5b21..13fc8dd4 100644 --- a/samples/separate_nointrospection/PageInfoObject.h +++ b/samples/separate_nointrospection/PageInfoObject.h @@ -23,6 +23,8 @@ class PageInfo struct Concept { + virtual ~Concept() = default; + virtual service::FieldResult getHasNextPage(service::FieldParams&& params) const = 0; virtual service::FieldResult getHasPreviousPage(service::FieldParams&& params) const = 0; }; diff --git a/samples/separate_nointrospection/QueryObject.h b/samples/separate_nointrospection/QueryObject.h index 19690aa2..ebc8afb5 100644 --- a/samples/separate_nointrospection/QueryObject.h +++ b/samples/separate_nointrospection/QueryObject.h @@ -33,6 +33,8 @@ class Query struct Concept { + virtual ~Concept() = default; + virtual service::FieldResult> getNode(service::FieldParams&& params, response::IdType&& idArg) const = 0; virtual service::FieldResult> getAppointments(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const = 0; virtual service::FieldResult> getTasks(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const = 0; diff --git a/samples/separate_nointrospection/SubscriptionObject.h b/samples/separate_nointrospection/SubscriptionObject.h index feba2c94..7d08680e 100644 --- a/samples/separate_nointrospection/SubscriptionObject.h +++ b/samples/separate_nointrospection/SubscriptionObject.h @@ -23,6 +23,8 @@ class Subscription struct Concept { + virtual ~Concept() = default; + virtual service::FieldResult> getNextAppointmentChange(service::FieldParams&& params) const = 0; virtual service::FieldResult> getNodeChange(service::FieldParams&& params, response::IdType&& idArg) const = 0; }; diff --git a/samples/separate_nointrospection/TaskConnectionObject.h b/samples/separate_nointrospection/TaskConnectionObject.h index e406fa2b..bf95669f 100644 --- a/samples/separate_nointrospection/TaskConnectionObject.h +++ b/samples/separate_nointrospection/TaskConnectionObject.h @@ -23,6 +23,8 @@ class TaskConnection struct Concept { + virtual ~Concept() = default; + virtual service::FieldResult> getPageInfo(service::FieldParams&& params) const = 0; virtual service::FieldResult>>> getEdges(service::FieldParams&& params) const = 0; }; diff --git a/samples/separate_nointrospection/TaskEdgeObject.h b/samples/separate_nointrospection/TaskEdgeObject.h index 60ced878..92c22089 100644 --- a/samples/separate_nointrospection/TaskEdgeObject.h +++ b/samples/separate_nointrospection/TaskEdgeObject.h @@ -23,6 +23,8 @@ class TaskEdge struct Concept { + virtual ~Concept() = default; + virtual service::FieldResult> getNode(service::FieldParams&& params) const = 0; virtual service::FieldResult getCursor(service::FieldParams&& params) const = 0; }; diff --git a/samples/separate_nointrospection/TaskObject.h b/samples/separate_nointrospection/TaskObject.h index 8a161bbe..acb8193e 100644 --- a/samples/separate_nointrospection/TaskObject.h +++ b/samples/separate_nointrospection/TaskObject.h @@ -25,6 +25,8 @@ class Task struct Concept : Node { + virtual ~Concept() = default; + virtual service::FieldResult> getTitle(service::FieldParams&& params) const = 0; virtual service::FieldResult getIsComplete(service::FieldParams&& params) const = 0; }; diff --git a/samples/unified/TodaySchema.h b/samples/unified/TodaySchema.h index 2db1ec02..7d6db933 100644 --- a/samples/unified/TodaySchema.h +++ b/samples/unified/TodaySchema.h @@ -113,6 +113,8 @@ class Query struct Concept { + virtual ~Concept() = default; + virtual service::FieldResult> getNode(service::FieldParams&& params, response::IdType&& idArg) const = 0; virtual service::FieldResult> getAppointments(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const = 0; virtual service::FieldResult> getTasks(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const = 0; @@ -225,6 +227,8 @@ class PageInfo struct Concept { + virtual ~Concept() = default; + virtual service::FieldResult getHasNextPage(service::FieldParams&& params) const = 0; virtual service::FieldResult getHasPreviousPage(service::FieldParams&& params) const = 0; }; @@ -277,6 +281,8 @@ class AppointmentEdge struct Concept { + virtual ~Concept() = default; + virtual service::FieldResult> getNode(service::FieldParams&& params) const = 0; virtual service::FieldResult getCursor(service::FieldParams&& params) const = 0; }; @@ -329,6 +335,8 @@ class AppointmentConnection struct Concept { + virtual ~Concept() = default; + virtual service::FieldResult> getPageInfo(service::FieldParams&& params) const = 0; virtual service::FieldResult>>> getEdges(service::FieldParams&& params) const = 0; }; @@ -381,6 +389,8 @@ class TaskEdge struct Concept { + virtual ~Concept() = default; + virtual service::FieldResult> getNode(service::FieldParams&& params) const = 0; virtual service::FieldResult getCursor(service::FieldParams&& params) const = 0; }; @@ -433,6 +443,8 @@ class TaskConnection struct Concept { + virtual ~Concept() = default; + virtual service::FieldResult> getPageInfo(service::FieldParams&& params) const = 0; virtual service::FieldResult>>> getEdges(service::FieldParams&& params) const = 0; }; @@ -485,6 +497,8 @@ class FolderEdge struct Concept { + virtual ~Concept() = default; + virtual service::FieldResult> getNode(service::FieldParams&& params) const = 0; virtual service::FieldResult getCursor(service::FieldParams&& params) const = 0; }; @@ -537,6 +551,8 @@ class FolderConnection struct Concept { + virtual ~Concept() = default; + virtual service::FieldResult> getPageInfo(service::FieldParams&& params) const = 0; virtual service::FieldResult>>> getEdges(service::FieldParams&& params) const = 0; }; @@ -589,6 +605,8 @@ class CompleteTaskPayload struct Concept { + virtual ~Concept() = default; + virtual service::FieldResult> getTask(service::FieldParams&& params) const = 0; virtual service::FieldResult> getClientMutationId(service::FieldParams&& params) const = 0; }; @@ -641,6 +659,8 @@ class Mutation struct Concept { + virtual ~Concept() = default; + virtual service::FieldResult> applyCompleteTask(service::FieldParams&& params, CompleteTaskInput&& inputArg) const = 0; virtual service::FieldResult applySetFloat(service::FieldParams&& params, response::FloatType&& valueArg) const = 0; }; @@ -693,6 +713,8 @@ class Subscription struct Concept { + virtual ~Concept() = default; + virtual service::FieldResult> getNextAppointmentChange(service::FieldParams&& params) const = 0; virtual service::FieldResult> getNodeChange(service::FieldParams&& params, response::IdType&& idArg) const = 0; }; @@ -749,6 +771,8 @@ class Appointment struct Concept : Node { + virtual ~Concept() = default; + virtual service::FieldResult> getWhen(service::FieldParams&& params) const = 0; virtual service::FieldResult> getSubject(service::FieldParams&& params) const = 0; virtual service::FieldResult getIsNow(service::FieldParams&& params) const = 0; @@ -820,6 +844,8 @@ class Task struct Concept : Node { + virtual ~Concept() = default; + virtual service::FieldResult> getTitle(service::FieldParams&& params) const = 0; virtual service::FieldResult getIsComplete(service::FieldParams&& params) const = 0; }; @@ -879,6 +905,8 @@ class Folder struct Concept : Node { + virtual ~Concept() = default; + virtual service::FieldResult> getName(service::FieldParams&& params) const = 0; virtual service::FieldResult getUnreadCount(service::FieldParams&& params) const = 0; }; @@ -936,6 +964,8 @@ class NestedType struct Concept { + virtual ~Concept() = default; + virtual service::FieldResult getDepth(service::FieldParams&& params) const = 0; virtual service::FieldResult> getNested(service::FieldParams&& params) const = 0; }; @@ -987,6 +1017,8 @@ class Expensive struct Concept { + virtual ~Concept() = default; + virtual service::FieldResult getOrder(service::FieldParams&& params) const = 0; }; diff --git a/samples/unified_nointrospection/TodaySchema.h b/samples/unified_nointrospection/TodaySchema.h index 17f19232..19621861 100644 --- a/samples/unified_nointrospection/TodaySchema.h +++ b/samples/unified_nointrospection/TodaySchema.h @@ -109,6 +109,8 @@ class Query struct Concept { + virtual ~Concept() = default; + virtual service::FieldResult> getNode(service::FieldParams&& params, response::IdType&& idArg) const = 0; virtual service::FieldResult> getAppointments(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const = 0; virtual service::FieldResult> getTasks(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const = 0; @@ -221,6 +223,8 @@ class PageInfo struct Concept { + virtual ~Concept() = default; + virtual service::FieldResult getHasNextPage(service::FieldParams&& params) const = 0; virtual service::FieldResult getHasPreviousPage(service::FieldParams&& params) const = 0; }; @@ -273,6 +277,8 @@ class AppointmentEdge struct Concept { + virtual ~Concept() = default; + virtual service::FieldResult> getNode(service::FieldParams&& params) const = 0; virtual service::FieldResult getCursor(service::FieldParams&& params) const = 0; }; @@ -325,6 +331,8 @@ class AppointmentConnection struct Concept { + virtual ~Concept() = default; + virtual service::FieldResult> getPageInfo(service::FieldParams&& params) const = 0; virtual service::FieldResult>>> getEdges(service::FieldParams&& params) const = 0; }; @@ -377,6 +385,8 @@ class TaskEdge struct Concept { + virtual ~Concept() = default; + virtual service::FieldResult> getNode(service::FieldParams&& params) const = 0; virtual service::FieldResult getCursor(service::FieldParams&& params) const = 0; }; @@ -429,6 +439,8 @@ class TaskConnection struct Concept { + virtual ~Concept() = default; + virtual service::FieldResult> getPageInfo(service::FieldParams&& params) const = 0; virtual service::FieldResult>>> getEdges(service::FieldParams&& params) const = 0; }; @@ -481,6 +493,8 @@ class FolderEdge struct Concept { + virtual ~Concept() = default; + virtual service::FieldResult> getNode(service::FieldParams&& params) const = 0; virtual service::FieldResult getCursor(service::FieldParams&& params) const = 0; }; @@ -533,6 +547,8 @@ class FolderConnection struct Concept { + virtual ~Concept() = default; + virtual service::FieldResult> getPageInfo(service::FieldParams&& params) const = 0; virtual service::FieldResult>>> getEdges(service::FieldParams&& params) const = 0; }; @@ -585,6 +601,8 @@ class CompleteTaskPayload struct Concept { + virtual ~Concept() = default; + virtual service::FieldResult> getTask(service::FieldParams&& params) const = 0; virtual service::FieldResult> getClientMutationId(service::FieldParams&& params) const = 0; }; @@ -637,6 +655,8 @@ class Mutation struct Concept { + virtual ~Concept() = default; + virtual service::FieldResult> applyCompleteTask(service::FieldParams&& params, CompleteTaskInput&& inputArg) const = 0; virtual service::FieldResult applySetFloat(service::FieldParams&& params, response::FloatType&& valueArg) const = 0; }; @@ -689,6 +709,8 @@ class Subscription struct Concept { + virtual ~Concept() = default; + virtual service::FieldResult> getNextAppointmentChange(service::FieldParams&& params) const = 0; virtual service::FieldResult> getNodeChange(service::FieldParams&& params, response::IdType&& idArg) const = 0; }; @@ -745,6 +767,8 @@ class Appointment struct Concept : Node { + virtual ~Concept() = default; + virtual service::FieldResult> getWhen(service::FieldParams&& params) const = 0; virtual service::FieldResult> getSubject(service::FieldParams&& params) const = 0; virtual service::FieldResult getIsNow(service::FieldParams&& params) const = 0; @@ -816,6 +840,8 @@ class Task struct Concept : Node { + virtual ~Concept() = default; + virtual service::FieldResult> getTitle(service::FieldParams&& params) const = 0; virtual service::FieldResult getIsComplete(service::FieldParams&& params) const = 0; }; @@ -875,6 +901,8 @@ class Folder struct Concept : Node { + virtual ~Concept() = default; + virtual service::FieldResult> getName(service::FieldParams&& params) const = 0; virtual service::FieldResult getUnreadCount(service::FieldParams&& params) const = 0; }; @@ -932,6 +960,8 @@ class NestedType struct Concept { + virtual ~Concept() = default; + virtual service::FieldResult getDepth(service::FieldParams&& params) const = 0; virtual service::FieldResult> getNested(service::FieldParams&& params) const = 0; }; @@ -983,6 +1013,8 @@ class Expensive struct Concept { + virtual ~Concept() = default; + virtual service::FieldResult getOrder(service::FieldParams&& params) const = 0; }; diff --git a/samples/validation/ValidationSchema.h b/samples/validation/ValidationSchema.h index a738a995..d4d22839 100644 --- a/samples/validation/ValidationSchema.h +++ b/samples/validation/ValidationSchema.h @@ -89,6 +89,8 @@ class Query struct Concept { + virtual ~Concept() = default; + virtual service::FieldResult> getDog(service::FieldParams&& params) const = 0; virtual service::FieldResult> getHuman(service::FieldParams&& params) const = 0; virtual service::FieldResult> getPet(service::FieldParams&& params) const = 0; @@ -176,6 +178,8 @@ class Dog struct Concept : Pet { + virtual ~Concept() = default; + virtual service::FieldResult> getNickname(service::FieldParams&& params) const = 0; virtual service::FieldResult> getBarkVolume(service::FieldParams&& params) const = 0; virtual service::FieldResult getDoesKnowCommand(service::FieldParams&& params, DogCommand&& dogCommandArg) const = 0; @@ -252,6 +256,8 @@ class Alien struct Concept : Sentient { + virtual ~Concept() = default; + virtual service::FieldResult> getHomePlanet(service::FieldParams&& params) const = 0; }; @@ -304,6 +310,8 @@ class Human struct Concept : Sentient { + virtual ~Concept() = default; + virtual service::FieldResult>> getPets(service::FieldParams&& params) const = 0; }; @@ -358,6 +366,8 @@ class Cat struct Concept : Pet { + virtual ~Concept() = default; + virtual service::FieldResult> getNickname(service::FieldParams&& params) const = 0; virtual service::FieldResult getDoesKnowCommand(service::FieldParams&& params, CatCommand&& catCommandArg) const = 0; virtual service::FieldResult> getMeowVolume(service::FieldParams&& params) const = 0; @@ -420,6 +430,8 @@ class Mutation struct Concept { + virtual ~Concept() = default; + virtual service::FieldResult> applyMutateDog(service::FieldParams&& params) const = 0; }; @@ -465,6 +477,8 @@ class MutateDogResult struct Concept { + virtual ~Concept() = default; + virtual service::FieldResult getId(service::FieldParams&& params) const = 0; }; @@ -511,6 +525,8 @@ class Subscription struct Concept { + virtual ~Concept() = default; + virtual service::FieldResult> getNewMessage(service::FieldParams&& params) const = 0; virtual service::FieldResult getDisallowedSecondRootField(service::FieldParams&& params) const = 0; }; @@ -563,6 +579,8 @@ class Message struct Concept { + virtual ~Concept() = default; + virtual service::FieldResult> getBody(service::FieldParams&& params) const = 0; virtual service::FieldResult getSender(service::FieldParams&& params) const = 0; }; @@ -621,6 +639,8 @@ class Arguments struct Concept { + virtual ~Concept() = default; + virtual service::FieldResult getMultipleReqs(service::FieldParams&& params, response::IntType&& xArg, response::IntType&& yArg) const = 0; virtual service::FieldResult> getBooleanArgField(service::FieldParams&& params, std::optional&& booleanArgArg) const = 0; virtual service::FieldResult> getFloatArgField(service::FieldParams&& params, std::optional&& floatArgArg) const = 0; diff --git a/src/SchemaGenerator.cpp b/src/SchemaGenerator.cpp index 6c6af28c..535ad945 100644 --- a/src/SchemaGenerator.cpp +++ b/src/SchemaGenerator.cpp @@ -555,6 +555,8 @@ void Generator::outputObjectDeclaration( headerFile << R"cpp( { + virtual ~Concept() = default; + )cpp"; for (const auto& outputField : objectType.fields) From 060659519527f9bf7d60e29b866563e002340b44 Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Mon, 29 Nov 2021 20:21:05 -0800 Subject: [PATCH 027/119] Try explicit conversion to Concept unique_ptr --- .../introspection/IntrospectionSchema.h | 12 +++---- samples/learn/DroidObject.h | 2 +- samples/learn/HumanObject.h | 2 +- samples/learn/MutationObject.h | 2 +- samples/learn/QueryObject.h | 2 +- samples/learn/ReviewObject.h | 2 +- .../separate/AppointmentConnectionObject.h | 2 +- samples/separate/AppointmentEdgeObject.h | 2 +- samples/separate/AppointmentObject.h | 2 +- samples/separate/CompleteTaskPayloadObject.h | 2 +- samples/separate/ExpensiveObject.h | 2 +- samples/separate/FolderConnectionObject.h | 2 +- samples/separate/FolderEdgeObject.h | 2 +- samples/separate/FolderObject.h | 2 +- samples/separate/MutationObject.h | 2 +- samples/separate/NestedTypeObject.h | 2 +- samples/separate/PageInfoObject.h | 2 +- samples/separate/QueryObject.h | 2 +- samples/separate/SubscriptionObject.h | 2 +- samples/separate/TaskConnectionObject.h | 2 +- samples/separate/TaskEdgeObject.h | 2 +- samples/separate/TaskObject.h | 2 +- .../AppointmentConnectionObject.h | 2 +- .../AppointmentEdgeObject.h | 2 +- .../AppointmentObject.h | 2 +- .../CompleteTaskPayloadObject.h | 2 +- .../ExpensiveObject.h | 2 +- .../FolderConnectionObject.h | 2 +- .../FolderEdgeObject.h | 2 +- .../separate_nointrospection/FolderObject.h | 2 +- .../separate_nointrospection/MutationObject.h | 2 +- .../NestedTypeObject.h | 2 +- .../separate_nointrospection/PageInfoObject.h | 2 +- .../separate_nointrospection/QueryObject.h | 2 +- .../SubscriptionObject.h | 2 +- .../TaskConnectionObject.h | 2 +- .../separate_nointrospection/TaskEdgeObject.h | 2 +- samples/separate_nointrospection/TaskObject.h | 2 +- samples/unified/TodaySchema.h | 32 +++++++++---------- samples/unified_nointrospection/TodaySchema.h | 32 +++++++++---------- samples/validation/ValidationSchema.h | 20 ++++++------ src/SchemaGenerator.cpp | 2 +- 42 files changed, 86 insertions(+), 86 deletions(-) diff --git a/include/graphqlservice/introspection/IntrospectionSchema.h b/include/graphqlservice/introspection/IntrospectionSchema.h index 8264ee67..71a7f887 100644 --- a/include/graphqlservice/introspection/IntrospectionSchema.h +++ b/include/graphqlservice/introspection/IntrospectionSchema.h @@ -144,7 +144,7 @@ class Schema public: template Schema(std::shared_ptr pimpl) - : Schema { std::make_unique>(std::move(pimpl)) } + : Schema { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } @@ -247,7 +247,7 @@ class Type public: template Type(std::shared_ptr pimpl) - : Type { std::make_unique>(std::move(pimpl)) } + : Type { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } @@ -329,7 +329,7 @@ class Field public: template Field(std::shared_ptr pimpl) - : Field { std::make_unique>(std::move(pimpl)) } + : Field { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } @@ -397,7 +397,7 @@ class InputValue public: template InputValue(std::shared_ptr pimpl) - : InputValue { std::make_unique>(std::move(pimpl)) } + : InputValue { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } @@ -465,7 +465,7 @@ class EnumValue public: template EnumValue(std::shared_ptr pimpl) - : EnumValue { std::make_unique>(std::move(pimpl)) } + : EnumValue { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } @@ -533,7 +533,7 @@ class Directive public: template Directive(std::shared_ptr pimpl) - : Directive { std::make_unique>(std::move(pimpl)) } + : Directive { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } diff --git a/samples/learn/DroidObject.h b/samples/learn/DroidObject.h index 08d2db66..07d7f1d7 100644 --- a/samples/learn/DroidObject.h +++ b/samples/learn/DroidObject.h @@ -77,7 +77,7 @@ class Droid public: template Droid(std::shared_ptr pimpl) - : Droid { std::make_unique>(std::move(pimpl)) } + : Droid { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } diff --git a/samples/learn/HumanObject.h b/samples/learn/HumanObject.h index c4bc6f65..9d660e77 100644 --- a/samples/learn/HumanObject.h +++ b/samples/learn/HumanObject.h @@ -77,7 +77,7 @@ class Human public: template Human(std::shared_ptr pimpl) - : Human { std::make_unique>(std::move(pimpl)) } + : Human { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } diff --git a/samples/learn/MutationObject.h b/samples/learn/MutationObject.h index 32a19474..095db6f8 100644 --- a/samples/learn/MutationObject.h +++ b/samples/learn/MutationObject.h @@ -52,7 +52,7 @@ class Mutation public: template Mutation(std::shared_ptr pimpl) - : Mutation { std::make_unique>(std::move(pimpl)) } + : Mutation { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } diff --git a/samples/learn/QueryObject.h b/samples/learn/QueryObject.h index fc4613e1..f3dd5078 100644 --- a/samples/learn/QueryObject.h +++ b/samples/learn/QueryObject.h @@ -70,7 +70,7 @@ class Query public: template Query(std::shared_ptr pimpl) - : Query { std::make_unique>(std::move(pimpl)) } + : Query { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } diff --git a/samples/learn/ReviewObject.h b/samples/learn/ReviewObject.h index 81fd39c6..bad00c61 100644 --- a/samples/learn/ReviewObject.h +++ b/samples/learn/ReviewObject.h @@ -59,7 +59,7 @@ class Review public: template Review(std::shared_ptr pimpl) - : Review { std::make_unique>(std::move(pimpl)) } + : Review { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } diff --git a/samples/separate/AppointmentConnectionObject.h b/samples/separate/AppointmentConnectionObject.h index 1871b22a..2c84c81f 100644 --- a/samples/separate/AppointmentConnectionObject.h +++ b/samples/separate/AppointmentConnectionObject.h @@ -59,7 +59,7 @@ class AppointmentConnection public: template AppointmentConnection(std::shared_ptr pimpl) - : AppointmentConnection { std::make_unique>(std::move(pimpl)) } + : AppointmentConnection { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } diff --git a/samples/separate/AppointmentEdgeObject.h b/samples/separate/AppointmentEdgeObject.h index 0c25e610..44311d04 100644 --- a/samples/separate/AppointmentEdgeObject.h +++ b/samples/separate/AppointmentEdgeObject.h @@ -59,7 +59,7 @@ class AppointmentEdge public: template AppointmentEdge(std::shared_ptr pimpl) - : AppointmentEdge { std::make_unique>(std::move(pimpl)) } + : AppointmentEdge { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } diff --git a/samples/separate/AppointmentObject.h b/samples/separate/AppointmentObject.h index 4e951093..f6e57623 100644 --- a/samples/separate/AppointmentObject.h +++ b/samples/separate/AppointmentObject.h @@ -80,7 +80,7 @@ class Appointment public: template Appointment(std::shared_ptr pimpl) - : Appointment { std::make_unique>(std::move(pimpl)) } + : Appointment { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } diff --git a/samples/separate/CompleteTaskPayloadObject.h b/samples/separate/CompleteTaskPayloadObject.h index aae6f08f..b5eca507 100644 --- a/samples/separate/CompleteTaskPayloadObject.h +++ b/samples/separate/CompleteTaskPayloadObject.h @@ -59,7 +59,7 @@ class CompleteTaskPayload public: template CompleteTaskPayload(std::shared_ptr pimpl) - : CompleteTaskPayload { std::make_unique>(std::move(pimpl)) } + : CompleteTaskPayload { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } diff --git a/samples/separate/ExpensiveObject.h b/samples/separate/ExpensiveObject.h index 7f644a85..a48937ad 100644 --- a/samples/separate/ExpensiveObject.h +++ b/samples/separate/ExpensiveObject.h @@ -52,7 +52,7 @@ class Expensive public: template Expensive(std::shared_ptr pimpl) - : Expensive { std::make_unique>(std::move(pimpl)) } + : Expensive { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } diff --git a/samples/separate/FolderConnectionObject.h b/samples/separate/FolderConnectionObject.h index 62a5536d..fbc6673b 100644 --- a/samples/separate/FolderConnectionObject.h +++ b/samples/separate/FolderConnectionObject.h @@ -59,7 +59,7 @@ class FolderConnection public: template FolderConnection(std::shared_ptr pimpl) - : FolderConnection { std::make_unique>(std::move(pimpl)) } + : FolderConnection { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } diff --git a/samples/separate/FolderEdgeObject.h b/samples/separate/FolderEdgeObject.h index 60150db7..71d07aec 100644 --- a/samples/separate/FolderEdgeObject.h +++ b/samples/separate/FolderEdgeObject.h @@ -59,7 +59,7 @@ class FolderEdge public: template FolderEdge(std::shared_ptr pimpl) - : FolderEdge { std::make_unique>(std::move(pimpl)) } + : FolderEdge { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } diff --git a/samples/separate/FolderObject.h b/samples/separate/FolderObject.h index b6b90539..14ec9579 100644 --- a/samples/separate/FolderObject.h +++ b/samples/separate/FolderObject.h @@ -66,7 +66,7 @@ class Folder public: template Folder(std::shared_ptr pimpl) - : Folder { std::make_unique>(std::move(pimpl)) } + : Folder { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } diff --git a/samples/separate/MutationObject.h b/samples/separate/MutationObject.h index d5b78c30..cf0f4d81 100644 --- a/samples/separate/MutationObject.h +++ b/samples/separate/MutationObject.h @@ -59,7 +59,7 @@ class Mutation public: template Mutation(std::shared_ptr pimpl) - : Mutation { std::make_unique>(std::move(pimpl)) } + : Mutation { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } diff --git a/samples/separate/NestedTypeObject.h b/samples/separate/NestedTypeObject.h index ff1b636a..61d5888f 100644 --- a/samples/separate/NestedTypeObject.h +++ b/samples/separate/NestedTypeObject.h @@ -59,7 +59,7 @@ class NestedType public: template NestedType(std::shared_ptr pimpl) - : NestedType { std::make_unique>(std::move(pimpl)) } + : NestedType { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } diff --git a/samples/separate/PageInfoObject.h b/samples/separate/PageInfoObject.h index 13fc8dd4..1f94559c 100644 --- a/samples/separate/PageInfoObject.h +++ b/samples/separate/PageInfoObject.h @@ -59,7 +59,7 @@ class PageInfo public: template PageInfo(std::shared_ptr pimpl) - : PageInfo { std::make_unique>(std::move(pimpl)) } + : PageInfo { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } diff --git a/samples/separate/QueryObject.h b/samples/separate/QueryObject.h index 4171d850..b46b5f5f 100644 --- a/samples/separate/QueryObject.h +++ b/samples/separate/QueryObject.h @@ -133,7 +133,7 @@ class Query public: template Query(std::shared_ptr pimpl) - : Query { std::make_unique>(std::move(pimpl)) } + : Query { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } diff --git a/samples/separate/SubscriptionObject.h b/samples/separate/SubscriptionObject.h index 7d08680e..16664a41 100644 --- a/samples/separate/SubscriptionObject.h +++ b/samples/separate/SubscriptionObject.h @@ -59,7 +59,7 @@ class Subscription public: template Subscription(std::shared_ptr pimpl) - : Subscription { std::make_unique>(std::move(pimpl)) } + : Subscription { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } diff --git a/samples/separate/TaskConnectionObject.h b/samples/separate/TaskConnectionObject.h index bf95669f..1f2d232c 100644 --- a/samples/separate/TaskConnectionObject.h +++ b/samples/separate/TaskConnectionObject.h @@ -59,7 +59,7 @@ class TaskConnection public: template TaskConnection(std::shared_ptr pimpl) - : TaskConnection { std::make_unique>(std::move(pimpl)) } + : TaskConnection { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } diff --git a/samples/separate/TaskEdgeObject.h b/samples/separate/TaskEdgeObject.h index 92c22089..a7ca120a 100644 --- a/samples/separate/TaskEdgeObject.h +++ b/samples/separate/TaskEdgeObject.h @@ -59,7 +59,7 @@ class TaskEdge public: template TaskEdge(std::shared_ptr pimpl) - : TaskEdge { std::make_unique>(std::move(pimpl)) } + : TaskEdge { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } diff --git a/samples/separate/TaskObject.h b/samples/separate/TaskObject.h index acb8193e..2fe8447e 100644 --- a/samples/separate/TaskObject.h +++ b/samples/separate/TaskObject.h @@ -66,7 +66,7 @@ class Task public: template Task(std::shared_ptr pimpl) - : Task { std::make_unique>(std::move(pimpl)) } + : Task { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } diff --git a/samples/separate_nointrospection/AppointmentConnectionObject.h b/samples/separate_nointrospection/AppointmentConnectionObject.h index 1871b22a..2c84c81f 100644 --- a/samples/separate_nointrospection/AppointmentConnectionObject.h +++ b/samples/separate_nointrospection/AppointmentConnectionObject.h @@ -59,7 +59,7 @@ class AppointmentConnection public: template AppointmentConnection(std::shared_ptr pimpl) - : AppointmentConnection { std::make_unique>(std::move(pimpl)) } + : AppointmentConnection { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } diff --git a/samples/separate_nointrospection/AppointmentEdgeObject.h b/samples/separate_nointrospection/AppointmentEdgeObject.h index 0c25e610..44311d04 100644 --- a/samples/separate_nointrospection/AppointmentEdgeObject.h +++ b/samples/separate_nointrospection/AppointmentEdgeObject.h @@ -59,7 +59,7 @@ class AppointmentEdge public: template AppointmentEdge(std::shared_ptr pimpl) - : AppointmentEdge { std::make_unique>(std::move(pimpl)) } + : AppointmentEdge { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } diff --git a/samples/separate_nointrospection/AppointmentObject.h b/samples/separate_nointrospection/AppointmentObject.h index 4e951093..f6e57623 100644 --- a/samples/separate_nointrospection/AppointmentObject.h +++ b/samples/separate_nointrospection/AppointmentObject.h @@ -80,7 +80,7 @@ class Appointment public: template Appointment(std::shared_ptr pimpl) - : Appointment { std::make_unique>(std::move(pimpl)) } + : Appointment { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } diff --git a/samples/separate_nointrospection/CompleteTaskPayloadObject.h b/samples/separate_nointrospection/CompleteTaskPayloadObject.h index aae6f08f..b5eca507 100644 --- a/samples/separate_nointrospection/CompleteTaskPayloadObject.h +++ b/samples/separate_nointrospection/CompleteTaskPayloadObject.h @@ -59,7 +59,7 @@ class CompleteTaskPayload public: template CompleteTaskPayload(std::shared_ptr pimpl) - : CompleteTaskPayload { std::make_unique>(std::move(pimpl)) } + : CompleteTaskPayload { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } diff --git a/samples/separate_nointrospection/ExpensiveObject.h b/samples/separate_nointrospection/ExpensiveObject.h index 7f644a85..a48937ad 100644 --- a/samples/separate_nointrospection/ExpensiveObject.h +++ b/samples/separate_nointrospection/ExpensiveObject.h @@ -52,7 +52,7 @@ class Expensive public: template Expensive(std::shared_ptr pimpl) - : Expensive { std::make_unique>(std::move(pimpl)) } + : Expensive { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } diff --git a/samples/separate_nointrospection/FolderConnectionObject.h b/samples/separate_nointrospection/FolderConnectionObject.h index 62a5536d..fbc6673b 100644 --- a/samples/separate_nointrospection/FolderConnectionObject.h +++ b/samples/separate_nointrospection/FolderConnectionObject.h @@ -59,7 +59,7 @@ class FolderConnection public: template FolderConnection(std::shared_ptr pimpl) - : FolderConnection { std::make_unique>(std::move(pimpl)) } + : FolderConnection { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } diff --git a/samples/separate_nointrospection/FolderEdgeObject.h b/samples/separate_nointrospection/FolderEdgeObject.h index 60150db7..71d07aec 100644 --- a/samples/separate_nointrospection/FolderEdgeObject.h +++ b/samples/separate_nointrospection/FolderEdgeObject.h @@ -59,7 +59,7 @@ class FolderEdge public: template FolderEdge(std::shared_ptr pimpl) - : FolderEdge { std::make_unique>(std::move(pimpl)) } + : FolderEdge { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } diff --git a/samples/separate_nointrospection/FolderObject.h b/samples/separate_nointrospection/FolderObject.h index b6b90539..14ec9579 100644 --- a/samples/separate_nointrospection/FolderObject.h +++ b/samples/separate_nointrospection/FolderObject.h @@ -66,7 +66,7 @@ class Folder public: template Folder(std::shared_ptr pimpl) - : Folder { std::make_unique>(std::move(pimpl)) } + : Folder { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } diff --git a/samples/separate_nointrospection/MutationObject.h b/samples/separate_nointrospection/MutationObject.h index d5b78c30..cf0f4d81 100644 --- a/samples/separate_nointrospection/MutationObject.h +++ b/samples/separate_nointrospection/MutationObject.h @@ -59,7 +59,7 @@ class Mutation public: template Mutation(std::shared_ptr pimpl) - : Mutation { std::make_unique>(std::move(pimpl)) } + : Mutation { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } diff --git a/samples/separate_nointrospection/NestedTypeObject.h b/samples/separate_nointrospection/NestedTypeObject.h index ff1b636a..61d5888f 100644 --- a/samples/separate_nointrospection/NestedTypeObject.h +++ b/samples/separate_nointrospection/NestedTypeObject.h @@ -59,7 +59,7 @@ class NestedType public: template NestedType(std::shared_ptr pimpl) - : NestedType { std::make_unique>(std::move(pimpl)) } + : NestedType { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } diff --git a/samples/separate_nointrospection/PageInfoObject.h b/samples/separate_nointrospection/PageInfoObject.h index 13fc8dd4..1f94559c 100644 --- a/samples/separate_nointrospection/PageInfoObject.h +++ b/samples/separate_nointrospection/PageInfoObject.h @@ -59,7 +59,7 @@ class PageInfo public: template PageInfo(std::shared_ptr pimpl) - : PageInfo { std::make_unique>(std::move(pimpl)) } + : PageInfo { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } diff --git a/samples/separate_nointrospection/QueryObject.h b/samples/separate_nointrospection/QueryObject.h index ebc8afb5..1169b447 100644 --- a/samples/separate_nointrospection/QueryObject.h +++ b/samples/separate_nointrospection/QueryObject.h @@ -129,7 +129,7 @@ class Query public: template Query(std::shared_ptr pimpl) - : Query { std::make_unique>(std::move(pimpl)) } + : Query { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } diff --git a/samples/separate_nointrospection/SubscriptionObject.h b/samples/separate_nointrospection/SubscriptionObject.h index 7d08680e..16664a41 100644 --- a/samples/separate_nointrospection/SubscriptionObject.h +++ b/samples/separate_nointrospection/SubscriptionObject.h @@ -59,7 +59,7 @@ class Subscription public: template Subscription(std::shared_ptr pimpl) - : Subscription { std::make_unique>(std::move(pimpl)) } + : Subscription { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } diff --git a/samples/separate_nointrospection/TaskConnectionObject.h b/samples/separate_nointrospection/TaskConnectionObject.h index bf95669f..1f2d232c 100644 --- a/samples/separate_nointrospection/TaskConnectionObject.h +++ b/samples/separate_nointrospection/TaskConnectionObject.h @@ -59,7 +59,7 @@ class TaskConnection public: template TaskConnection(std::shared_ptr pimpl) - : TaskConnection { std::make_unique>(std::move(pimpl)) } + : TaskConnection { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } diff --git a/samples/separate_nointrospection/TaskEdgeObject.h b/samples/separate_nointrospection/TaskEdgeObject.h index 92c22089..a7ca120a 100644 --- a/samples/separate_nointrospection/TaskEdgeObject.h +++ b/samples/separate_nointrospection/TaskEdgeObject.h @@ -59,7 +59,7 @@ class TaskEdge public: template TaskEdge(std::shared_ptr pimpl) - : TaskEdge { std::make_unique>(std::move(pimpl)) } + : TaskEdge { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } diff --git a/samples/separate_nointrospection/TaskObject.h b/samples/separate_nointrospection/TaskObject.h index acb8193e..2fe8447e 100644 --- a/samples/separate_nointrospection/TaskObject.h +++ b/samples/separate_nointrospection/TaskObject.h @@ -66,7 +66,7 @@ class Task public: template Task(std::shared_ptr pimpl) - : Task { std::make_unique>(std::move(pimpl)) } + : Task { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } diff --git a/samples/unified/TodaySchema.h b/samples/unified/TodaySchema.h index 7d6db933..2d0e22c0 100644 --- a/samples/unified/TodaySchema.h +++ b/samples/unified/TodaySchema.h @@ -209,7 +209,7 @@ class Query public: template Query(std::shared_ptr pimpl) - : Query { std::make_unique>(std::move(pimpl)) } + : Query { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } @@ -263,7 +263,7 @@ class PageInfo public: template PageInfo(std::shared_ptr pimpl) - : PageInfo { std::make_unique>(std::move(pimpl)) } + : PageInfo { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } @@ -317,7 +317,7 @@ class AppointmentEdge public: template AppointmentEdge(std::shared_ptr pimpl) - : AppointmentEdge { std::make_unique>(std::move(pimpl)) } + : AppointmentEdge { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } @@ -371,7 +371,7 @@ class AppointmentConnection public: template AppointmentConnection(std::shared_ptr pimpl) - : AppointmentConnection { std::make_unique>(std::move(pimpl)) } + : AppointmentConnection { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } @@ -425,7 +425,7 @@ class TaskEdge public: template TaskEdge(std::shared_ptr pimpl) - : TaskEdge { std::make_unique>(std::move(pimpl)) } + : TaskEdge { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } @@ -479,7 +479,7 @@ class TaskConnection public: template TaskConnection(std::shared_ptr pimpl) - : TaskConnection { std::make_unique>(std::move(pimpl)) } + : TaskConnection { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } @@ -533,7 +533,7 @@ class FolderEdge public: template FolderEdge(std::shared_ptr pimpl) - : FolderEdge { std::make_unique>(std::move(pimpl)) } + : FolderEdge { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } @@ -587,7 +587,7 @@ class FolderConnection public: template FolderConnection(std::shared_ptr pimpl) - : FolderConnection { std::make_unique>(std::move(pimpl)) } + : FolderConnection { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } @@ -641,7 +641,7 @@ class CompleteTaskPayload public: template CompleteTaskPayload(std::shared_ptr pimpl) - : CompleteTaskPayload { std::make_unique>(std::move(pimpl)) } + : CompleteTaskPayload { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } @@ -695,7 +695,7 @@ class Mutation public: template Mutation(std::shared_ptr pimpl) - : Mutation { std::make_unique>(std::move(pimpl)) } + : Mutation { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } @@ -749,7 +749,7 @@ class Subscription public: template Subscription(std::shared_ptr pimpl) - : Subscription { std::make_unique>(std::move(pimpl)) } + : Subscription { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } @@ -824,7 +824,7 @@ class Appointment public: template Appointment(std::shared_ptr pimpl) - : Appointment { std::make_unique>(std::move(pimpl)) } + : Appointment { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } @@ -885,7 +885,7 @@ class Task public: template Task(std::shared_ptr pimpl) - : Task { std::make_unique>(std::move(pimpl)) } + : Task { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } @@ -946,7 +946,7 @@ class Folder public: template Folder(std::shared_ptr pimpl) - : Folder { std::make_unique>(std::move(pimpl)) } + : Folder { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } @@ -1000,7 +1000,7 @@ class NestedType public: template NestedType(std::shared_ptr pimpl) - : NestedType { std::make_unique>(std::move(pimpl)) } + : NestedType { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } @@ -1047,7 +1047,7 @@ class Expensive public: template Expensive(std::shared_ptr pimpl) - : Expensive { std::make_unique>(std::move(pimpl)) } + : Expensive { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } diff --git a/samples/unified_nointrospection/TodaySchema.h b/samples/unified_nointrospection/TodaySchema.h index 19621861..86a0d22d 100644 --- a/samples/unified_nointrospection/TodaySchema.h +++ b/samples/unified_nointrospection/TodaySchema.h @@ -205,7 +205,7 @@ class Query public: template Query(std::shared_ptr pimpl) - : Query { std::make_unique>(std::move(pimpl)) } + : Query { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } @@ -259,7 +259,7 @@ class PageInfo public: template PageInfo(std::shared_ptr pimpl) - : PageInfo { std::make_unique>(std::move(pimpl)) } + : PageInfo { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } @@ -313,7 +313,7 @@ class AppointmentEdge public: template AppointmentEdge(std::shared_ptr pimpl) - : AppointmentEdge { std::make_unique>(std::move(pimpl)) } + : AppointmentEdge { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } @@ -367,7 +367,7 @@ class AppointmentConnection public: template AppointmentConnection(std::shared_ptr pimpl) - : AppointmentConnection { std::make_unique>(std::move(pimpl)) } + : AppointmentConnection { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } @@ -421,7 +421,7 @@ class TaskEdge public: template TaskEdge(std::shared_ptr pimpl) - : TaskEdge { std::make_unique>(std::move(pimpl)) } + : TaskEdge { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } @@ -475,7 +475,7 @@ class TaskConnection public: template TaskConnection(std::shared_ptr pimpl) - : TaskConnection { std::make_unique>(std::move(pimpl)) } + : TaskConnection { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } @@ -529,7 +529,7 @@ class FolderEdge public: template FolderEdge(std::shared_ptr pimpl) - : FolderEdge { std::make_unique>(std::move(pimpl)) } + : FolderEdge { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } @@ -583,7 +583,7 @@ class FolderConnection public: template FolderConnection(std::shared_ptr pimpl) - : FolderConnection { std::make_unique>(std::move(pimpl)) } + : FolderConnection { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } @@ -637,7 +637,7 @@ class CompleteTaskPayload public: template CompleteTaskPayload(std::shared_ptr pimpl) - : CompleteTaskPayload { std::make_unique>(std::move(pimpl)) } + : CompleteTaskPayload { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } @@ -691,7 +691,7 @@ class Mutation public: template Mutation(std::shared_ptr pimpl) - : Mutation { std::make_unique>(std::move(pimpl)) } + : Mutation { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } @@ -745,7 +745,7 @@ class Subscription public: template Subscription(std::shared_ptr pimpl) - : Subscription { std::make_unique>(std::move(pimpl)) } + : Subscription { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } @@ -820,7 +820,7 @@ class Appointment public: template Appointment(std::shared_ptr pimpl) - : Appointment { std::make_unique>(std::move(pimpl)) } + : Appointment { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } @@ -881,7 +881,7 @@ class Task public: template Task(std::shared_ptr pimpl) - : Task { std::make_unique>(std::move(pimpl)) } + : Task { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } @@ -942,7 +942,7 @@ class Folder public: template Folder(std::shared_ptr pimpl) - : Folder { std::make_unique>(std::move(pimpl)) } + : Folder { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } @@ -996,7 +996,7 @@ class NestedType public: template NestedType(std::shared_ptr pimpl) - : NestedType { std::make_unique>(std::move(pimpl)) } + : NestedType { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } @@ -1043,7 +1043,7 @@ class Expensive public: template Expensive(std::shared_ptr pimpl) - : Expensive { std::make_unique>(std::move(pimpl)) } + : Expensive { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } diff --git a/samples/validation/ValidationSchema.h b/samples/validation/ValidationSchema.h index d4d22839..98c698d0 100644 --- a/samples/validation/ValidationSchema.h +++ b/samples/validation/ValidationSchema.h @@ -155,7 +155,7 @@ class Query public: template Query(std::shared_ptr pimpl) - : Query { std::make_unique>(std::move(pimpl)) } + : Query { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } @@ -237,7 +237,7 @@ class Dog public: template Dog(std::shared_ptr pimpl) - : Dog { std::make_unique>(std::move(pimpl)) } + : Dog { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } @@ -291,7 +291,7 @@ class Alien public: template Alien(std::shared_ptr pimpl) - : Alien { std::make_unique>(std::move(pimpl)) } + : Alien { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } @@ -345,7 +345,7 @@ class Human public: template Human(std::shared_ptr pimpl) - : Human { std::make_unique>(std::move(pimpl)) } + : Human { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } @@ -413,7 +413,7 @@ class Cat public: template Cat(std::shared_ptr pimpl) - : Cat { std::make_unique>(std::move(pimpl)) } + : Cat { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } @@ -460,7 +460,7 @@ class Mutation public: template Mutation(std::shared_ptr pimpl) - : Mutation { std::make_unique>(std::move(pimpl)) } + : Mutation { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } @@ -507,7 +507,7 @@ class MutateDogResult public: template MutateDogResult(std::shared_ptr pimpl) - : MutateDogResult { std::make_unique>(std::move(pimpl)) } + : MutateDogResult { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } @@ -561,7 +561,7 @@ class Subscription public: template Subscription(std::shared_ptr pimpl) - : Subscription { std::make_unique>(std::move(pimpl)) } + : Subscription { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } @@ -615,7 +615,7 @@ class Message public: template Message(std::shared_ptr pimpl) - : Message { std::make_unique>(std::move(pimpl)) } + : Message { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } @@ -711,7 +711,7 @@ class Arguments public: template Arguments(std::shared_ptr pimpl) - : Arguments { std::make_unique>(std::move(pimpl)) } + : Arguments { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } diff --git a/src/SchemaGenerator.cpp b/src/SchemaGenerator.cpp index 535ad945..1ba49609 100644 --- a/src/SchemaGenerator.cpp +++ b/src/SchemaGenerator.cpp @@ -633,7 +633,7 @@ void Generator::outputObjectDeclaration( )cpp" << objectType.cppType << R"cpp((std::shared_ptr pimpl) : )cpp" << objectType.cppType - << R"cpp( { std::make_unique>(std::move(pimpl)) } + << R"cpp( { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } From de60045ab818b3268192397b798ddd404383401e Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Mon, 29 Nov 2021 20:45:35 -0800 Subject: [PATCH 028/119] Fix TodayTests --- test/TodayTests.cpp | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/test/TodayTests.cpp b/test/TodayTests.cpp index 5ebdd92a..571d000b 100644 --- a/test/TodayTests.cpp +++ b/test/TodayTests.cpp @@ -675,7 +675,8 @@ TEST_F(TodayServiceCase, SubscribeNextAppointmentChangeOverride) result = std::move(response); }); _service->deliver("nextAppointmentChange", - std::static_pointer_cast(subscriptionObject)); + std::static_pointer_cast( + std::make_shared(std::move(subscriptionObject)))); _service->unsubscribe(key); try @@ -1196,8 +1197,10 @@ TEST_F(TodayServiceCase, SubscribeNodeChangeMatchingId) EXPECT_EQ(13, std::static_pointer_cast(state)->requestId) << "should pass the RequestState to the subscription resolvers"; EXPECT_EQ(_fakeTaskId, idArg); - return std::static_pointer_cast( - std::make_shared(response::IdType(_fakeTaskId), "Don't forget", true)); + return std::static_pointer_cast(std::make_shared( + std::make_shared(response::IdType(_fakeTaskId), + "Don't forget", + true))); }); response::Value result; auto key = _service->subscribe(service::SubscriptionParams { state, @@ -1209,7 +1212,8 @@ TEST_F(TodayServiceCase, SubscribeNodeChangeMatchingId) }); _service->deliver("nodeChange", { { "id", response::Value(std::string("ZmFrZVRhc2tJZA==")) } }, - std::static_pointer_cast(subscriptionObject)); + std::static_pointer_cast( + std::make_shared(std::move(subscriptionObject)))); _service->unsubscribe(key); try @@ -1265,7 +1269,8 @@ TEST_F(TodayServiceCase, SubscribeNodeChangeMismatchedId) }); _service->deliver("nodeChange", { { "id", response::Value(std::string("ZmFrZUFwcG9pbnRtZW50SWQ=")) } }, - std::static_pointer_cast(subscriptionObject)); + std::static_pointer_cast( + std::make_shared(std::move(subscriptionObject)))); _service->unsubscribe(key); try @@ -1309,8 +1314,10 @@ TEST_F(TodayServiceCase, SubscribeNodeChangeFuzzyComparator) EXPECT_EQ(14, std::static_pointer_cast(state)->requestId) << "should pass the RequestState to the subscription resolvers"; EXPECT_EQ(fuzzyId, idArg); - return std::static_pointer_cast( - std::make_shared(response::IdType(_fakeTaskId), "Don't forget", true)); + return std::static_pointer_cast(std::make_shared( + std::make_shared(response::IdType(_fakeTaskId), + "Don't forget", + true))); }); response::Value result; auto key = _service->subscribe(service::SubscriptionParams { state, @@ -1322,7 +1329,8 @@ TEST_F(TodayServiceCase, SubscribeNodeChangeFuzzyComparator) }); _service->deliver("nodeChange", filterCallback, - std::static_pointer_cast(subscriptionObject)); + std::static_pointer_cast( + std::make_shared(std::move(subscriptionObject)))); _service->unsubscribe(key); try @@ -1388,7 +1396,8 @@ TEST_F(TodayServiceCase, SubscribeNodeChangeFuzzyMismatch) }); _service->deliver("nodeChange", filterCallback, - std::static_pointer_cast(subscriptionObject)); + std::static_pointer_cast( + std::make_shared(std::move(subscriptionObject)))); _service->unsubscribe(key); try @@ -1423,8 +1432,10 @@ TEST_F(TodayServiceCase, SubscribeNodeChangeMatchingVariable) EXPECT_EQ(14, std::static_pointer_cast(state)->requestId) << "should pass the RequestState to the subscription resolvers"; EXPECT_EQ(_fakeTaskId, idArg); - return std::static_pointer_cast( - std::make_shared(response::IdType(_fakeTaskId), "Don't forget", true)); + return std::static_pointer_cast(std::make_shared( + std::make_shared(response::IdType(_fakeTaskId), + "Don't forget", + true))); }); response::Value result; auto key = _service->subscribe(service::SubscriptionParams { state, @@ -1436,7 +1447,8 @@ TEST_F(TodayServiceCase, SubscribeNodeChangeMatchingVariable) }); _service->deliver("nodeChange", { { "id", response::Value(std::string("ZmFrZVRhc2tJZA==")) } }, - std::static_pointer_cast(subscriptionObject)); + std::static_pointer_cast( + std::make_shared(std::move(subscriptionObject)))); _service->unsubscribe(key); try From a943f28e03fd88ebdcf4ccc36591125dc04069c6 Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Tue, 30 Nov 2021 17:35:26 -0800 Subject: [PATCH 029/119] Reimplement stubs with concepts to test for fallback --- .../introspection/IntrospectionSchema.h | 61 +- samples/learn/DroidObject.cpp | 4 - samples/learn/DroidObject.h | 2 - samples/learn/HumanObject.cpp | 4 - samples/learn/HumanObject.h | 2 - samples/learn/MutationObject.cpp | 4 - samples/learn/MutationObject.h | 2 - samples/learn/QueryObject.cpp | 4 - samples/learn/QueryObject.h | 2 - samples/learn/ReviewObject.cpp | 4 - samples/learn/ReviewObject.h | 2 - .../separate/AppointmentConnectionObject.cpp | 4 - .../separate/AppointmentConnectionObject.h | 36 +- samples/separate/AppointmentEdgeObject.cpp | 4 - samples/separate/AppointmentEdgeObject.h | 36 +- samples/separate/AppointmentObject.cpp | 4 - samples/separate/AppointmentObject.h | 81 +- .../separate/CompleteTaskPayloadObject.cpp | 4 - samples/separate/CompleteTaskPayloadObject.h | 36 +- samples/separate/ExpensiveObject.cpp | 4 - samples/separate/ExpensiveObject.h | 21 +- samples/separate/FolderConnectionObject.cpp | 4 - samples/separate/FolderConnectionObject.h | 36 +- samples/separate/FolderEdgeObject.cpp | 4 - samples/separate/FolderEdgeObject.h | 36 +- samples/separate/FolderObject.cpp | 4 - samples/separate/FolderObject.h | 51 +- samples/separate/MutationObject.cpp | 4 - samples/separate/MutationObject.h | 36 +- samples/separate/NestedTypeObject.cpp | 4 - samples/separate/NestedTypeObject.h | 36 +- samples/separate/PageInfoObject.cpp | 4 - samples/separate/PageInfoObject.h | 36 +- samples/separate/QueryObject.cpp | 4 - samples/separate/QueryObject.h | 186 ++++- samples/separate/SubscriptionObject.cpp | 4 - samples/separate/SubscriptionObject.h | 36 +- samples/separate/TaskConnectionObject.cpp | 4 - samples/separate/TaskConnectionObject.h | 36 +- samples/separate/TaskEdgeObject.cpp | 4 - samples/separate/TaskEdgeObject.h | 36 +- samples/separate/TaskObject.cpp | 4 - samples/separate/TaskObject.h | 51 +- samples/separate/TodaySchema.h | 1 + .../AppointmentConnectionObject.cpp | 4 - .../AppointmentConnectionObject.h | 36 +- .../AppointmentEdgeObject.cpp | 4 - .../AppointmentEdgeObject.h | 36 +- .../AppointmentObject.cpp | 4 - .../AppointmentObject.h | 81 +- .../CompleteTaskPayloadObject.cpp | 4 - .../CompleteTaskPayloadObject.h | 36 +- .../ExpensiveObject.cpp | 4 - .../ExpensiveObject.h | 21 +- .../FolderConnectionObject.cpp | 4 - .../FolderConnectionObject.h | 36 +- .../FolderEdgeObject.cpp | 4 - .../FolderEdgeObject.h | 36 +- .../separate_nointrospection/FolderObject.cpp | 4 - .../separate_nointrospection/FolderObject.h | 51 +- .../MutationObject.cpp | 4 - .../separate_nointrospection/MutationObject.h | 36 +- .../NestedTypeObject.cpp | 4 - .../NestedTypeObject.h | 36 +- .../PageInfoObject.cpp | 4 - .../separate_nointrospection/PageInfoObject.h | 36 +- .../separate_nointrospection/QueryObject.cpp | 4 - .../separate_nointrospection/QueryObject.h | 186 ++++- .../SubscriptionObject.cpp | 4 - .../SubscriptionObject.h | 36 +- .../TaskConnectionObject.cpp | 4 - .../TaskConnectionObject.h | 36 +- .../TaskEdgeObject.cpp | 4 - .../separate_nointrospection/TaskEdgeObject.h | 36 +- .../separate_nointrospection/TaskObject.cpp | 4 - samples/separate_nointrospection/TaskObject.h | 51 +- .../separate_nointrospection/TodaySchema.h | 1 + samples/unified/TodaySchema.cpp | 64 -- samples/unified/TodaySchema.h | 757 ++++++++++++++++-- .../unified_nointrospection/TodaySchema.cpp | 64 -- samples/unified_nointrospection/TodaySchema.h | 757 ++++++++++++++++-- samples/validation/ValidationSchema.cpp | 40 - samples/validation/ValidationSchema.h | 568 +++++++++++-- src/IntrospectionSchema.cpp | 36 +- src/SchemaGenerator.cpp | 196 ++++- 85 files changed, 3525 insertions(+), 750 deletions(-) diff --git a/include/graphqlservice/introspection/IntrospectionSchema.h b/include/graphqlservice/introspection/IntrospectionSchema.h index 71a7f887..d19d7032 100644 --- a/include/graphqlservice/introspection/IntrospectionSchema.h +++ b/include/graphqlservice/introspection/IntrospectionSchema.h @@ -67,6 +67,13 @@ enum class DirectiveLocation INPUT_FIELD_DEFINITION }; +class Schema; +class Type; +class Field; +class InputValue; +class EnumValue; +class Directive; + namespace object { class Schema; @@ -137,17 +144,10 @@ class Schema const std::shared_ptr _pimpl; }; - GRAPHQLINTROSPECTION_EXPORT Schema(std::unique_ptr&& pimpl); - const std::unique_ptr _pimpl; public: - template - Schema(std::shared_ptr pimpl) - : Schema { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } - { - } - + GRAPHQLINTROSPECTION_EXPORT Schema(std::shared_ptr pimpl); GRAPHQLINTROSPECTION_EXPORT ~Schema(); }; @@ -240,17 +240,10 @@ class Type const std::shared_ptr _pimpl; }; - GRAPHQLINTROSPECTION_EXPORT Type(std::unique_ptr&& pimpl); - const std::unique_ptr _pimpl; public: - template - Type(std::shared_ptr pimpl) - : Type { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } - { - } - + GRAPHQLINTROSPECTION_EXPORT Type(std::shared_ptr pimpl); GRAPHQLINTROSPECTION_EXPORT ~Type(); }; @@ -322,17 +315,10 @@ class Field const std::shared_ptr _pimpl; }; - GRAPHQLINTROSPECTION_EXPORT Field(std::unique_ptr&& pimpl); - const std::unique_ptr _pimpl; public: - template - Field(std::shared_ptr pimpl) - : Field { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } - { - } - + GRAPHQLINTROSPECTION_EXPORT Field(std::shared_ptr pimpl); GRAPHQLINTROSPECTION_EXPORT ~Field(); }; @@ -390,17 +376,10 @@ class InputValue const std::shared_ptr _pimpl; }; - GRAPHQLINTROSPECTION_EXPORT InputValue(std::unique_ptr&& pimpl); - const std::unique_ptr _pimpl; public: - template - InputValue(std::shared_ptr pimpl) - : InputValue { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } - { - } - + GRAPHQLINTROSPECTION_EXPORT InputValue(std::shared_ptr pimpl); GRAPHQLINTROSPECTION_EXPORT ~InputValue(); }; @@ -458,17 +437,10 @@ class EnumValue const std::shared_ptr _pimpl; }; - GRAPHQLINTROSPECTION_EXPORT EnumValue(std::unique_ptr&& pimpl); - const std::unique_ptr _pimpl; public: - template - EnumValue(std::shared_ptr pimpl) - : EnumValue { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } - { - } - + GRAPHQLINTROSPECTION_EXPORT EnumValue(std::shared_ptr pimpl); GRAPHQLINTROSPECTION_EXPORT ~EnumValue(); }; @@ -526,17 +498,10 @@ class Directive const std::shared_ptr _pimpl; }; - GRAPHQLINTROSPECTION_EXPORT Directive(std::unique_ptr&& pimpl); - const std::unique_ptr _pimpl; public: - template - Directive(std::shared_ptr pimpl) - : Directive { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } - { - } - + GRAPHQLINTROSPECTION_EXPORT Directive(std::shared_ptr pimpl); GRAPHQLINTROSPECTION_EXPORT ~Directive(); }; diff --git a/samples/learn/DroidObject.cpp b/samples/learn/DroidObject.cpp index 00e8d876..fa5bebfc 100644 --- a/samples/learn/DroidObject.cpp +++ b/samples/learn/DroidObject.cpp @@ -34,10 +34,6 @@ Droid::Droid(std::unique_ptr&& pimpl) { } -Droid::~Droid() -{ -} - service::AwaitableResolver Droid::resolveId(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); diff --git a/samples/learn/DroidObject.h b/samples/learn/DroidObject.h index 07d7f1d7..20c7ba6a 100644 --- a/samples/learn/DroidObject.h +++ b/samples/learn/DroidObject.h @@ -80,8 +80,6 @@ class Droid : Droid { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } - - ~Droid(); }; } // namespace graphql::learn::object diff --git a/samples/learn/HumanObject.cpp b/samples/learn/HumanObject.cpp index 3e51200e..c03edb6c 100644 --- a/samples/learn/HumanObject.cpp +++ b/samples/learn/HumanObject.cpp @@ -34,10 +34,6 @@ Human::Human(std::unique_ptr&& pimpl) { } -Human::~Human() -{ -} - service::AwaitableResolver Human::resolveId(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); diff --git a/samples/learn/HumanObject.h b/samples/learn/HumanObject.h index 9d660e77..de5b0903 100644 --- a/samples/learn/HumanObject.h +++ b/samples/learn/HumanObject.h @@ -80,8 +80,6 @@ class Human : Human { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } - - ~Human(); }; } // namespace graphql::learn::object diff --git a/samples/learn/MutationObject.cpp b/samples/learn/MutationObject.cpp index b04ae476..f9d46926 100644 --- a/samples/learn/MutationObject.cpp +++ b/samples/learn/MutationObject.cpp @@ -29,10 +29,6 @@ Mutation::Mutation(std::unique_ptr&& pimpl) { } -Mutation::~Mutation() -{ -} - service::AwaitableResolver Mutation::resolveCreateReview(service::ResolverParams&& params) { auto argEp = service::ModifiedArgument::require("ep", params.arguments); diff --git a/samples/learn/MutationObject.h b/samples/learn/MutationObject.h index 095db6f8..5432b6ce 100644 --- a/samples/learn/MutationObject.h +++ b/samples/learn/MutationObject.h @@ -55,8 +55,6 @@ class Mutation : Mutation { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } - - ~Mutation(); }; } // namespace graphql::learn::object diff --git a/samples/learn/QueryObject.cpp b/samples/learn/QueryObject.cpp index 7ccc6a49..c4d5c975 100644 --- a/samples/learn/QueryObject.cpp +++ b/samples/learn/QueryObject.cpp @@ -34,10 +34,6 @@ Query::Query(std::unique_ptr&& pimpl) { } -Query::~Query() -{ -} - service::AwaitableResolver Query::resolveHero(service::ResolverParams&& params) { auto argEpisode = service::ModifiedArgument::require("episode", params.arguments); diff --git a/samples/learn/QueryObject.h b/samples/learn/QueryObject.h index f3dd5078..523ee0f1 100644 --- a/samples/learn/QueryObject.h +++ b/samples/learn/QueryObject.h @@ -73,8 +73,6 @@ class Query : Query { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } - - ~Query(); }; } // namespace graphql::learn::object diff --git a/samples/learn/ReviewObject.cpp b/samples/learn/ReviewObject.cpp index 0b0dd7cc..2376d8a9 100644 --- a/samples/learn/ReviewObject.cpp +++ b/samples/learn/ReviewObject.cpp @@ -30,10 +30,6 @@ Review::Review(std::unique_ptr&& pimpl) { } -Review::~Review() -{ -} - service::AwaitableResolver Review::resolveStars(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); diff --git a/samples/learn/ReviewObject.h b/samples/learn/ReviewObject.h index bad00c61..0dad4ba5 100644 --- a/samples/learn/ReviewObject.h +++ b/samples/learn/ReviewObject.h @@ -62,8 +62,6 @@ class Review : Review { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } - - ~Review(); }; } // namespace graphql::learn::object diff --git a/samples/separate/AppointmentConnectionObject.cpp b/samples/separate/AppointmentConnectionObject.cpp index ad51753f..622e42a9 100644 --- a/samples/separate/AppointmentConnectionObject.cpp +++ b/samples/separate/AppointmentConnectionObject.cpp @@ -30,10 +30,6 @@ AppointmentConnection::AppointmentConnection(std::unique_ptr&& pimpl) { } -AppointmentConnection::~AppointmentConnection() -{ -} - service::AwaitableResolver AppointmentConnection::resolvePageInfo(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); diff --git a/samples/separate/AppointmentConnectionObject.h b/samples/separate/AppointmentConnectionObject.h index 2c84c81f..8df5345c 100644 --- a/samples/separate/AppointmentConnectionObject.h +++ b/samples/separate/AppointmentConnectionObject.h @@ -12,6 +12,22 @@ namespace graphql::today::object { +namespace AppointmentConnectionStubs { + +template +concept HasPageInfo = requires (TImpl impl, service::FieldParams params) +{ + { impl.getPageInfo(std::move(params)) } -> std::convertible_to>>; +}; + +template +concept HasEdges = requires (TImpl impl, service::FieldParams params) +{ + { impl.getEdges(std::move(params)) } -> std::convertible_to>>>>; +}; + +} // namespace AppointmentConnectionStubs + class AppointmentConnection : public service::Object { @@ -40,12 +56,26 @@ class AppointmentConnection service::FieldResult> getPageInfo(service::FieldParams&& params) const final { - return _pimpl->getPageInfo(std::move(params)); + if constexpr (AppointmentConnectionStubs::HasPageInfo) + { + return _pimpl->getPageInfo(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(AppointmentConnection::getPageInfo is not implemented)ex"); + } } service::FieldResult>>> getEdges(service::FieldParams&& params) const final { - return _pimpl->getEdges(std::move(params)); + if constexpr (AppointmentConnectionStubs::HasEdges) + { + return _pimpl->getEdges(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(AppointmentConnection::getEdges is not implemented)ex"); + } } private: @@ -62,8 +92,6 @@ class AppointmentConnection : AppointmentConnection { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } - - ~AppointmentConnection(); }; } // namespace graphql::today::object diff --git a/samples/separate/AppointmentEdgeObject.cpp b/samples/separate/AppointmentEdgeObject.cpp index 2d222f4b..df02bd88 100644 --- a/samples/separate/AppointmentEdgeObject.cpp +++ b/samples/separate/AppointmentEdgeObject.cpp @@ -30,10 +30,6 @@ AppointmentEdge::AppointmentEdge(std::unique_ptr&& pimpl) { } -AppointmentEdge::~AppointmentEdge() -{ -} - service::AwaitableResolver AppointmentEdge::resolveNode(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); diff --git a/samples/separate/AppointmentEdgeObject.h b/samples/separate/AppointmentEdgeObject.h index 44311d04..e2d0922b 100644 --- a/samples/separate/AppointmentEdgeObject.h +++ b/samples/separate/AppointmentEdgeObject.h @@ -12,6 +12,22 @@ namespace graphql::today::object { +namespace AppointmentEdgeStubs { + +template +concept HasNode = requires (TImpl impl, service::FieldParams params) +{ + { impl.getNode(std::move(params)) } -> std::convertible_to>>; +}; + +template +concept HasCursor = requires (TImpl impl, service::FieldParams params) +{ + { impl.getCursor(std::move(params)) } -> std::convertible_to>; +}; + +} // namespace AppointmentEdgeStubs + class AppointmentEdge : public service::Object { @@ -40,12 +56,26 @@ class AppointmentEdge service::FieldResult> getNode(service::FieldParams&& params) const final { - return _pimpl->getNode(std::move(params)); + if constexpr (AppointmentEdgeStubs::HasNode) + { + return _pimpl->getNode(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(AppointmentEdge::getNode is not implemented)ex"); + } } service::FieldResult getCursor(service::FieldParams&& params) const final { - return _pimpl->getCursor(std::move(params)); + if constexpr (AppointmentEdgeStubs::HasCursor) + { + return _pimpl->getCursor(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(AppointmentEdge::getCursor is not implemented)ex"); + } } private: @@ -62,8 +92,6 @@ class AppointmentEdge : AppointmentEdge { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } - - ~AppointmentEdge(); }; } // namespace graphql::today::object diff --git a/samples/separate/AppointmentObject.cpp b/samples/separate/AppointmentObject.cpp index 4327bc1b..30b83427 100644 --- a/samples/separate/AppointmentObject.cpp +++ b/samples/separate/AppointmentObject.cpp @@ -35,10 +35,6 @@ Appointment::Appointment(std::unique_ptr&& pimpl) { } -Appointment::~Appointment() -{ -} - service::AwaitableResolver Appointment::resolveId(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); diff --git a/samples/separate/AppointmentObject.h b/samples/separate/AppointmentObject.h index f6e57623..d13318bc 100644 --- a/samples/separate/AppointmentObject.h +++ b/samples/separate/AppointmentObject.h @@ -12,6 +12,40 @@ namespace graphql::today::object { +namespace AppointmentStubs { + +template +concept HasId = requires (TImpl impl, service::FieldParams params) +{ + { impl.getId(std::move(params)) } -> std::convertible_to>; +}; + +template +concept HasWhen = requires (TImpl impl, service::FieldParams params) +{ + { impl.getWhen(std::move(params)) } -> std::convertible_to>>; +}; + +template +concept HasSubject = requires (TImpl impl, service::FieldParams params) +{ + { impl.getSubject(std::move(params)) } -> std::convertible_to>>; +}; + +template +concept HasIsNow = requires (TImpl impl, service::FieldParams params) +{ + { impl.getIsNow(std::move(params)) } -> std::convertible_to>; +}; + +template +concept HasForceError = requires (TImpl impl, service::FieldParams params) +{ + { impl.getForceError(std::move(params)) } -> std::convertible_to>>; +}; + +} // namespace AppointmentStubs + class Appointment : public service::Object { @@ -46,27 +80,62 @@ class Appointment service::FieldResult getId(service::FieldParams&& params) const final { - return _pimpl->getId(std::move(params)); + if constexpr (AppointmentStubs::HasId) + { + return _pimpl->getId(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(Appointment::getId is not implemented)ex"); + } } service::FieldResult> getWhen(service::FieldParams&& params) const final { - return _pimpl->getWhen(std::move(params)); + if constexpr (AppointmentStubs::HasWhen) + { + return _pimpl->getWhen(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(Appointment::getWhen is not implemented)ex"); + } } service::FieldResult> getSubject(service::FieldParams&& params) const final { - return _pimpl->getSubject(std::move(params)); + if constexpr (AppointmentStubs::HasSubject) + { + return _pimpl->getSubject(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(Appointment::getSubject is not implemented)ex"); + } } service::FieldResult getIsNow(service::FieldParams&& params) const final { - return _pimpl->getIsNow(std::move(params)); + if constexpr (AppointmentStubs::HasIsNow) + { + return _pimpl->getIsNow(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(Appointment::getIsNow is not implemented)ex"); + } } service::FieldResult> getForceError(service::FieldParams&& params) const final { - return _pimpl->getForceError(std::move(params)); + if constexpr (AppointmentStubs::HasForceError) + { + return _pimpl->getForceError(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(Appointment::getForceError is not implemented)ex"); + } } private: @@ -83,8 +152,6 @@ class Appointment : Appointment { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } - - ~Appointment(); }; } // namespace graphql::today::object diff --git a/samples/separate/CompleteTaskPayloadObject.cpp b/samples/separate/CompleteTaskPayloadObject.cpp index ca0f6f76..2924a90c 100644 --- a/samples/separate/CompleteTaskPayloadObject.cpp +++ b/samples/separate/CompleteTaskPayloadObject.cpp @@ -30,10 +30,6 @@ CompleteTaskPayload::CompleteTaskPayload(std::unique_ptr&& pimpl) { } -CompleteTaskPayload::~CompleteTaskPayload() -{ -} - service::AwaitableResolver CompleteTaskPayload::resolveTask(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); diff --git a/samples/separate/CompleteTaskPayloadObject.h b/samples/separate/CompleteTaskPayloadObject.h index b5eca507..9e180344 100644 --- a/samples/separate/CompleteTaskPayloadObject.h +++ b/samples/separate/CompleteTaskPayloadObject.h @@ -12,6 +12,22 @@ namespace graphql::today::object { +namespace CompleteTaskPayloadStubs { + +template +concept HasTask = requires (TImpl impl, service::FieldParams params) +{ + { impl.getTask(std::move(params)) } -> std::convertible_to>>; +}; + +template +concept HasClientMutationId = requires (TImpl impl, service::FieldParams params) +{ + { impl.getClientMutationId(std::move(params)) } -> std::convertible_to>>; +}; + +} // namespace CompleteTaskPayloadStubs + class CompleteTaskPayload : public service::Object { @@ -40,12 +56,26 @@ class CompleteTaskPayload service::FieldResult> getTask(service::FieldParams&& params) const final { - return _pimpl->getTask(std::move(params)); + if constexpr (CompleteTaskPayloadStubs::HasTask) + { + return _pimpl->getTask(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(CompleteTaskPayload::getTask is not implemented)ex"); + } } service::FieldResult> getClientMutationId(service::FieldParams&& params) const final { - return _pimpl->getClientMutationId(std::move(params)); + if constexpr (CompleteTaskPayloadStubs::HasClientMutationId) + { + return _pimpl->getClientMutationId(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(CompleteTaskPayload::getClientMutationId is not implemented)ex"); + } } private: @@ -62,8 +92,6 @@ class CompleteTaskPayload : CompleteTaskPayload { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } - - ~CompleteTaskPayload(); }; } // namespace graphql::today::object diff --git a/samples/separate/ExpensiveObject.cpp b/samples/separate/ExpensiveObject.cpp index 51cc5140..d8634115 100644 --- a/samples/separate/ExpensiveObject.cpp +++ b/samples/separate/ExpensiveObject.cpp @@ -29,10 +29,6 @@ Expensive::Expensive(std::unique_ptr&& pimpl) { } -Expensive::~Expensive() -{ -} - service::AwaitableResolver Expensive::resolveOrder(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); diff --git a/samples/separate/ExpensiveObject.h b/samples/separate/ExpensiveObject.h index a48937ad..8b151c0c 100644 --- a/samples/separate/ExpensiveObject.h +++ b/samples/separate/ExpensiveObject.h @@ -12,6 +12,16 @@ namespace graphql::today::object { +namespace ExpensiveStubs { + +template +concept HasOrder = requires (TImpl impl, service::FieldParams params) +{ + { impl.getOrder(std::move(params)) } -> std::convertible_to>; +}; + +} // namespace ExpensiveStubs + class Expensive : public service::Object { @@ -38,7 +48,14 @@ class Expensive service::FieldResult getOrder(service::FieldParams&& params) const final { - return _pimpl->getOrder(std::move(params)); + if constexpr (ExpensiveStubs::HasOrder) + { + return _pimpl->getOrder(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(Expensive::getOrder is not implemented)ex"); + } } private: @@ -55,8 +72,6 @@ class Expensive : Expensive { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } - - ~Expensive(); }; } // namespace graphql::today::object diff --git a/samples/separate/FolderConnectionObject.cpp b/samples/separate/FolderConnectionObject.cpp index 802380da..26c4ab6d 100644 --- a/samples/separate/FolderConnectionObject.cpp +++ b/samples/separate/FolderConnectionObject.cpp @@ -30,10 +30,6 @@ FolderConnection::FolderConnection(std::unique_ptr&& pimpl) { } -FolderConnection::~FolderConnection() -{ -} - service::AwaitableResolver FolderConnection::resolvePageInfo(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); diff --git a/samples/separate/FolderConnectionObject.h b/samples/separate/FolderConnectionObject.h index fbc6673b..f3a659bf 100644 --- a/samples/separate/FolderConnectionObject.h +++ b/samples/separate/FolderConnectionObject.h @@ -12,6 +12,22 @@ namespace graphql::today::object { +namespace FolderConnectionStubs { + +template +concept HasPageInfo = requires (TImpl impl, service::FieldParams params) +{ + { impl.getPageInfo(std::move(params)) } -> std::convertible_to>>; +}; + +template +concept HasEdges = requires (TImpl impl, service::FieldParams params) +{ + { impl.getEdges(std::move(params)) } -> std::convertible_to>>>>; +}; + +} // namespace FolderConnectionStubs + class FolderConnection : public service::Object { @@ -40,12 +56,26 @@ class FolderConnection service::FieldResult> getPageInfo(service::FieldParams&& params) const final { - return _pimpl->getPageInfo(std::move(params)); + if constexpr (FolderConnectionStubs::HasPageInfo) + { + return _pimpl->getPageInfo(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(FolderConnection::getPageInfo is not implemented)ex"); + } } service::FieldResult>>> getEdges(service::FieldParams&& params) const final { - return _pimpl->getEdges(std::move(params)); + if constexpr (FolderConnectionStubs::HasEdges) + { + return _pimpl->getEdges(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(FolderConnection::getEdges is not implemented)ex"); + } } private: @@ -62,8 +92,6 @@ class FolderConnection : FolderConnection { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } - - ~FolderConnection(); }; } // namespace graphql::today::object diff --git a/samples/separate/FolderEdgeObject.cpp b/samples/separate/FolderEdgeObject.cpp index e4e63fb1..a3b31b14 100644 --- a/samples/separate/FolderEdgeObject.cpp +++ b/samples/separate/FolderEdgeObject.cpp @@ -30,10 +30,6 @@ FolderEdge::FolderEdge(std::unique_ptr&& pimpl) { } -FolderEdge::~FolderEdge() -{ -} - service::AwaitableResolver FolderEdge::resolveNode(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); diff --git a/samples/separate/FolderEdgeObject.h b/samples/separate/FolderEdgeObject.h index 71d07aec..9869c4a3 100644 --- a/samples/separate/FolderEdgeObject.h +++ b/samples/separate/FolderEdgeObject.h @@ -12,6 +12,22 @@ namespace graphql::today::object { +namespace FolderEdgeStubs { + +template +concept HasNode = requires (TImpl impl, service::FieldParams params) +{ + { impl.getNode(std::move(params)) } -> std::convertible_to>>; +}; + +template +concept HasCursor = requires (TImpl impl, service::FieldParams params) +{ + { impl.getCursor(std::move(params)) } -> std::convertible_to>; +}; + +} // namespace FolderEdgeStubs + class FolderEdge : public service::Object { @@ -40,12 +56,26 @@ class FolderEdge service::FieldResult> getNode(service::FieldParams&& params) const final { - return _pimpl->getNode(std::move(params)); + if constexpr (FolderEdgeStubs::HasNode) + { + return _pimpl->getNode(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(FolderEdge::getNode is not implemented)ex"); + } } service::FieldResult getCursor(service::FieldParams&& params) const final { - return _pimpl->getCursor(std::move(params)); + if constexpr (FolderEdgeStubs::HasCursor) + { + return _pimpl->getCursor(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(FolderEdge::getCursor is not implemented)ex"); + } } private: @@ -62,8 +92,6 @@ class FolderEdge : FolderEdge { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } - - ~FolderEdge(); }; } // namespace graphql::today::object diff --git a/samples/separate/FolderObject.cpp b/samples/separate/FolderObject.cpp index bccaf182..b95936e9 100644 --- a/samples/separate/FolderObject.cpp +++ b/samples/separate/FolderObject.cpp @@ -33,10 +33,6 @@ Folder::Folder(std::unique_ptr&& pimpl) { } -Folder::~Folder() -{ -} - service::AwaitableResolver Folder::resolveId(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); diff --git a/samples/separate/FolderObject.h b/samples/separate/FolderObject.h index 14ec9579..f5601542 100644 --- a/samples/separate/FolderObject.h +++ b/samples/separate/FolderObject.h @@ -12,6 +12,28 @@ namespace graphql::today::object { +namespace FolderStubs { + +template +concept HasId = requires (TImpl impl, service::FieldParams params) +{ + { impl.getId(std::move(params)) } -> std::convertible_to>; +}; + +template +concept HasName = requires (TImpl impl, service::FieldParams params) +{ + { impl.getName(std::move(params)) } -> std::convertible_to>>; +}; + +template +concept HasUnreadCount = requires (TImpl impl, service::FieldParams params) +{ + { impl.getUnreadCount(std::move(params)) } -> std::convertible_to>; +}; + +} // namespace FolderStubs + class Folder : public service::Object { @@ -42,17 +64,38 @@ class Folder service::FieldResult getId(service::FieldParams&& params) const final { - return _pimpl->getId(std::move(params)); + if constexpr (FolderStubs::HasId) + { + return _pimpl->getId(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(Folder::getId is not implemented)ex"); + } } service::FieldResult> getName(service::FieldParams&& params) const final { - return _pimpl->getName(std::move(params)); + if constexpr (FolderStubs::HasName) + { + return _pimpl->getName(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(Folder::getName is not implemented)ex"); + } } service::FieldResult getUnreadCount(service::FieldParams&& params) const final { - return _pimpl->getUnreadCount(std::move(params)); + if constexpr (FolderStubs::HasUnreadCount) + { + return _pimpl->getUnreadCount(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(Folder::getUnreadCount is not implemented)ex"); + } } private: @@ -69,8 +112,6 @@ class Folder : Folder { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } - - ~Folder(); }; } // namespace graphql::today::object diff --git a/samples/separate/MutationObject.cpp b/samples/separate/MutationObject.cpp index 9914a1e2..20ee2188 100644 --- a/samples/separate/MutationObject.cpp +++ b/samples/separate/MutationObject.cpp @@ -30,10 +30,6 @@ Mutation::Mutation(std::unique_ptr&& pimpl) { } -Mutation::~Mutation() -{ -} - service::AwaitableResolver Mutation::resolveCompleteTask(service::ResolverParams&& params) { auto argInput = service::ModifiedArgument::require("input", params.arguments); diff --git a/samples/separate/MutationObject.h b/samples/separate/MutationObject.h index cf0f4d81..1371d2bd 100644 --- a/samples/separate/MutationObject.h +++ b/samples/separate/MutationObject.h @@ -12,6 +12,22 @@ namespace graphql::today::object { +namespace MutationStubs { + +template +concept HasCompleteTask = requires (TImpl impl, service::FieldParams params, CompleteTaskInput inputArg) +{ + { impl.applyCompleteTask(std::move(params), std::move(inputArg)) } -> std::convertible_to>>; +}; + +template +concept HasSetFloat = requires (TImpl impl, service::FieldParams params, response::FloatType valueArg) +{ + { impl.applySetFloat(std::move(params), std::move(valueArg)) } -> std::convertible_to>; +}; + +} // namespace MutationStubs + class Mutation : public service::Object { @@ -40,12 +56,26 @@ class Mutation service::FieldResult> applyCompleteTask(service::FieldParams&& params, CompleteTaskInput&& inputArg) const final { - return _pimpl->applyCompleteTask(std::move(params), std::move(inputArg)); + if constexpr (MutationStubs::HasCompleteTask) + { + return _pimpl->applyCompleteTask(std::move(params), std::move(inputArg)); + } + else + { + throw std::runtime_error(R"ex(Mutation::applyCompleteTask is not implemented)ex"); + } } service::FieldResult applySetFloat(service::FieldParams&& params, response::FloatType&& valueArg) const final { - return _pimpl->applySetFloat(std::move(params), std::move(valueArg)); + if constexpr (MutationStubs::HasSetFloat) + { + return _pimpl->applySetFloat(std::move(params), std::move(valueArg)); + } + else + { + throw std::runtime_error(R"ex(Mutation::applySetFloat is not implemented)ex"); + } } private: @@ -62,8 +92,6 @@ class Mutation : Mutation { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } - - ~Mutation(); }; } // namespace graphql::today::object diff --git a/samples/separate/NestedTypeObject.cpp b/samples/separate/NestedTypeObject.cpp index 2dd40964..f44b1eed 100644 --- a/samples/separate/NestedTypeObject.cpp +++ b/samples/separate/NestedTypeObject.cpp @@ -30,10 +30,6 @@ NestedType::NestedType(std::unique_ptr&& pimpl) { } -NestedType::~NestedType() -{ -} - service::AwaitableResolver NestedType::resolveDepth(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); diff --git a/samples/separate/NestedTypeObject.h b/samples/separate/NestedTypeObject.h index 61d5888f..a19f3095 100644 --- a/samples/separate/NestedTypeObject.h +++ b/samples/separate/NestedTypeObject.h @@ -12,6 +12,22 @@ namespace graphql::today::object { +namespace NestedTypeStubs { + +template +concept HasDepth = requires (TImpl impl, service::FieldParams params) +{ + { impl.getDepth(std::move(params)) } -> std::convertible_to>; +}; + +template +concept HasNested = requires (TImpl impl, service::FieldParams params) +{ + { impl.getNested(std::move(params)) } -> std::convertible_to>>; +}; + +} // namespace NestedTypeStubs + class NestedType : public service::Object { @@ -40,12 +56,26 @@ class NestedType service::FieldResult getDepth(service::FieldParams&& params) const final { - return _pimpl->getDepth(std::move(params)); + if constexpr (NestedTypeStubs::HasDepth) + { + return _pimpl->getDepth(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(NestedType::getDepth is not implemented)ex"); + } } service::FieldResult> getNested(service::FieldParams&& params) const final { - return _pimpl->getNested(std::move(params)); + if constexpr (NestedTypeStubs::HasNested) + { + return _pimpl->getNested(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(NestedType::getNested is not implemented)ex"); + } } private: @@ -62,8 +92,6 @@ class NestedType : NestedType { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } - - ~NestedType(); }; } // namespace graphql::today::object diff --git a/samples/separate/PageInfoObject.cpp b/samples/separate/PageInfoObject.cpp index 2c222dce..d406c9f2 100644 --- a/samples/separate/PageInfoObject.cpp +++ b/samples/separate/PageInfoObject.cpp @@ -30,10 +30,6 @@ PageInfo::PageInfo(std::unique_ptr&& pimpl) { } -PageInfo::~PageInfo() -{ -} - service::AwaitableResolver PageInfo::resolveHasNextPage(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); diff --git a/samples/separate/PageInfoObject.h b/samples/separate/PageInfoObject.h index 1f94559c..6d5234ee 100644 --- a/samples/separate/PageInfoObject.h +++ b/samples/separate/PageInfoObject.h @@ -12,6 +12,22 @@ namespace graphql::today::object { +namespace PageInfoStubs { + +template +concept HasHasNextPage = requires (TImpl impl, service::FieldParams params) +{ + { impl.getHasNextPage(std::move(params)) } -> std::convertible_to>; +}; + +template +concept HasHasPreviousPage = requires (TImpl impl, service::FieldParams params) +{ + { impl.getHasPreviousPage(std::move(params)) } -> std::convertible_to>; +}; + +} // namespace PageInfoStubs + class PageInfo : public service::Object { @@ -40,12 +56,26 @@ class PageInfo service::FieldResult getHasNextPage(service::FieldParams&& params) const final { - return _pimpl->getHasNextPage(std::move(params)); + if constexpr (PageInfoStubs::HasHasNextPage) + { + return _pimpl->getHasNextPage(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(PageInfo::getHasNextPage is not implemented)ex"); + } } service::FieldResult getHasPreviousPage(service::FieldParams&& params) const final { - return _pimpl->getHasPreviousPage(std::move(params)); + if constexpr (PageInfoStubs::HasHasPreviousPage) + { + return _pimpl->getHasPreviousPage(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(PageInfo::getHasPreviousPage is not implemented)ex"); + } } private: @@ -62,8 +92,6 @@ class PageInfo : PageInfo { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } - - ~PageInfo(); }; } // namespace graphql::today::object diff --git a/samples/separate/QueryObject.cpp b/samples/separate/QueryObject.cpp index f29a3781..7767ac0a 100644 --- a/samples/separate/QueryObject.cpp +++ b/samples/separate/QueryObject.cpp @@ -43,10 +43,6 @@ Query::Query(std::unique_ptr&& pimpl) { } -Query::~Query() -{ -} - service::AwaitableResolver Query::resolveNode(service::ResolverParams&& params) { auto argId = service::ModifiedArgument::require("id", params.arguments); diff --git a/samples/separate/QueryObject.h b/samples/separate/QueryObject.h index b46b5f5f..46f588f9 100644 --- a/samples/separate/QueryObject.h +++ b/samples/separate/QueryObject.h @@ -12,6 +12,82 @@ namespace graphql::today::object { +namespace QueryStubs { + +template +concept HasNode = requires (TImpl impl, service::FieldParams params, response::IdType idArg) +{ + { impl.getNode(std::move(params), std::move(idArg)) } -> std::convertible_to>>; +}; + +template +concept HasAppointments = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) +{ + { impl.getAppointments(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } -> std::convertible_to>>; +}; + +template +concept HasTasks = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) +{ + { impl.getTasks(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } -> std::convertible_to>>; +}; + +template +concept HasUnreadCounts = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) +{ + { impl.getUnreadCounts(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } -> std::convertible_to>>; +}; + +template +concept HasAppointmentsById = requires (TImpl impl, service::FieldParams params, std::vector idsArg) +{ + { impl.getAppointmentsById(std::move(params), std::move(idsArg)) } -> std::convertible_to>>>; +}; + +template +concept HasTasksById = requires (TImpl impl, service::FieldParams params, std::vector idsArg) +{ + { impl.getTasksById(std::move(params), std::move(idsArg)) } -> std::convertible_to>>>; +}; + +template +concept HasUnreadCountsById = requires (TImpl impl, service::FieldParams params, std::vector idsArg) +{ + { impl.getUnreadCountsById(std::move(params), std::move(idsArg)) } -> std::convertible_to>>>; +}; + +template +concept HasNested = requires (TImpl impl, service::FieldParams params) +{ + { impl.getNested(std::move(params)) } -> std::convertible_to>>; +}; + +template +concept HasUnimplemented = requires (TImpl impl, service::FieldParams params) +{ + { impl.getUnimplemented(std::move(params)) } -> std::convertible_to>; +}; + +template +concept HasExpensive = requires (TImpl impl, service::FieldParams params) +{ + { impl.getExpensive(std::move(params)) } -> std::convertible_to>>>; +}; + +template +concept HasTestTaskState = requires (TImpl impl, service::FieldParams params) +{ + { impl.getTestTaskState(std::move(params)) } -> std::convertible_to>; +}; + +template +concept HasAnyType = requires (TImpl impl, service::FieldParams params, std::vector idsArg) +{ + { impl.getAnyType(std::move(params), std::move(idsArg)) } -> std::convertible_to>>>; +}; + +} // namespace QueryStubs + class Query : public service::Object { @@ -64,62 +140,146 @@ class Query service::FieldResult> getNode(service::FieldParams&& params, response::IdType&& idArg) const final { - return _pimpl->getNode(std::move(params), std::move(idArg)); + if constexpr (QueryStubs::HasNode) + { + return _pimpl->getNode(std::move(params), std::move(idArg)); + } + else + { + throw std::runtime_error(R"ex(Query::getNode is not implemented)ex"); + } } service::FieldResult> getAppointments(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const final { - return _pimpl->getAppointments(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)); + if constexpr (QueryStubs::HasAppointments) + { + return _pimpl->getAppointments(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)); + } + else + { + throw std::runtime_error(R"ex(Query::getAppointments is not implemented)ex"); + } } service::FieldResult> getTasks(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const final { - return _pimpl->getTasks(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)); + if constexpr (QueryStubs::HasTasks) + { + return _pimpl->getTasks(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)); + } + else + { + throw std::runtime_error(R"ex(Query::getTasks is not implemented)ex"); + } } service::FieldResult> getUnreadCounts(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const final { - return _pimpl->getUnreadCounts(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)); + if constexpr (QueryStubs::HasUnreadCounts) + { + return _pimpl->getUnreadCounts(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)); + } + else + { + throw std::runtime_error(R"ex(Query::getUnreadCounts is not implemented)ex"); + } } service::FieldResult>> getAppointmentsById(service::FieldParams&& params, std::vector&& idsArg) const final { - return _pimpl->getAppointmentsById(std::move(params), std::move(idsArg)); + if constexpr (QueryStubs::HasAppointmentsById) + { + return _pimpl->getAppointmentsById(std::move(params), std::move(idsArg)); + } + else + { + throw std::runtime_error(R"ex(Query::getAppointmentsById is not implemented)ex"); + } } service::FieldResult>> getTasksById(service::FieldParams&& params, std::vector&& idsArg) const final { - return _pimpl->getTasksById(std::move(params), std::move(idsArg)); + if constexpr (QueryStubs::HasTasksById) + { + return _pimpl->getTasksById(std::move(params), std::move(idsArg)); + } + else + { + throw std::runtime_error(R"ex(Query::getTasksById is not implemented)ex"); + } } service::FieldResult>> getUnreadCountsById(service::FieldParams&& params, std::vector&& idsArg) const final { - return _pimpl->getUnreadCountsById(std::move(params), std::move(idsArg)); + if constexpr (QueryStubs::HasUnreadCountsById) + { + return _pimpl->getUnreadCountsById(std::move(params), std::move(idsArg)); + } + else + { + throw std::runtime_error(R"ex(Query::getUnreadCountsById is not implemented)ex"); + } } service::FieldResult> getNested(service::FieldParams&& params) const final { - return _pimpl->getNested(std::move(params)); + if constexpr (QueryStubs::HasNested) + { + return _pimpl->getNested(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(Query::getNested is not implemented)ex"); + } } service::FieldResult getUnimplemented(service::FieldParams&& params) const final { - return _pimpl->getUnimplemented(std::move(params)); + if constexpr (QueryStubs::HasUnimplemented) + { + return _pimpl->getUnimplemented(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(Query::getUnimplemented is not implemented)ex"); + } } service::FieldResult>> getExpensive(service::FieldParams&& params) const final { - return _pimpl->getExpensive(std::move(params)); + if constexpr (QueryStubs::HasExpensive) + { + return _pimpl->getExpensive(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(Query::getExpensive is not implemented)ex"); + } } service::FieldResult getTestTaskState(service::FieldParams&& params) const final { - return _pimpl->getTestTaskState(std::move(params)); + if constexpr (QueryStubs::HasTestTaskState) + { + return _pimpl->getTestTaskState(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(Query::getTestTaskState is not implemented)ex"); + } } service::FieldResult>> getAnyType(service::FieldParams&& params, std::vector&& idsArg) const final { - return _pimpl->getAnyType(std::move(params), std::move(idsArg)); + if constexpr (QueryStubs::HasAnyType) + { + return _pimpl->getAnyType(std::move(params), std::move(idsArg)); + } + else + { + throw std::runtime_error(R"ex(Query::getAnyType is not implemented)ex"); + } } private: @@ -136,8 +296,6 @@ class Query : Query { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } - - ~Query(); }; } // namespace graphql::today::object diff --git a/samples/separate/SubscriptionObject.cpp b/samples/separate/SubscriptionObject.cpp index b69a1270..949f4914 100644 --- a/samples/separate/SubscriptionObject.cpp +++ b/samples/separate/SubscriptionObject.cpp @@ -30,10 +30,6 @@ Subscription::Subscription(std::unique_ptr&& pimpl) { } -Subscription::~Subscription() -{ -} - service::AwaitableResolver Subscription::resolveNextAppointmentChange(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); diff --git a/samples/separate/SubscriptionObject.h b/samples/separate/SubscriptionObject.h index 16664a41..ca36231f 100644 --- a/samples/separate/SubscriptionObject.h +++ b/samples/separate/SubscriptionObject.h @@ -12,6 +12,22 @@ namespace graphql::today::object { +namespace SubscriptionStubs { + +template +concept HasNextAppointmentChange = requires (TImpl impl, service::FieldParams params) +{ + { impl.getNextAppointmentChange(std::move(params)) } -> std::convertible_to>>; +}; + +template +concept HasNodeChange = requires (TImpl impl, service::FieldParams params, response::IdType idArg) +{ + { impl.getNodeChange(std::move(params), std::move(idArg)) } -> std::convertible_to>>; +}; + +} // namespace SubscriptionStubs + class Subscription : public service::Object { @@ -40,12 +56,26 @@ class Subscription service::FieldResult> getNextAppointmentChange(service::FieldParams&& params) const final { - return _pimpl->getNextAppointmentChange(std::move(params)); + if constexpr (SubscriptionStubs::HasNextAppointmentChange) + { + return _pimpl->getNextAppointmentChange(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(Subscription::getNextAppointmentChange is not implemented)ex"); + } } service::FieldResult> getNodeChange(service::FieldParams&& params, response::IdType&& idArg) const final { - return _pimpl->getNodeChange(std::move(params), std::move(idArg)); + if constexpr (SubscriptionStubs::HasNodeChange) + { + return _pimpl->getNodeChange(std::move(params), std::move(idArg)); + } + else + { + throw std::runtime_error(R"ex(Subscription::getNodeChange is not implemented)ex"); + } } private: @@ -62,8 +92,6 @@ class Subscription : Subscription { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } - - ~Subscription(); }; } // namespace graphql::today::object diff --git a/samples/separate/TaskConnectionObject.cpp b/samples/separate/TaskConnectionObject.cpp index e74354cb..b5053add 100644 --- a/samples/separate/TaskConnectionObject.cpp +++ b/samples/separate/TaskConnectionObject.cpp @@ -30,10 +30,6 @@ TaskConnection::TaskConnection(std::unique_ptr&& pimpl) { } -TaskConnection::~TaskConnection() -{ -} - service::AwaitableResolver TaskConnection::resolvePageInfo(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); diff --git a/samples/separate/TaskConnectionObject.h b/samples/separate/TaskConnectionObject.h index 1f2d232c..b4e4c037 100644 --- a/samples/separate/TaskConnectionObject.h +++ b/samples/separate/TaskConnectionObject.h @@ -12,6 +12,22 @@ namespace graphql::today::object { +namespace TaskConnectionStubs { + +template +concept HasPageInfo = requires (TImpl impl, service::FieldParams params) +{ + { impl.getPageInfo(std::move(params)) } -> std::convertible_to>>; +}; + +template +concept HasEdges = requires (TImpl impl, service::FieldParams params) +{ + { impl.getEdges(std::move(params)) } -> std::convertible_to>>>>; +}; + +} // namespace TaskConnectionStubs + class TaskConnection : public service::Object { @@ -40,12 +56,26 @@ class TaskConnection service::FieldResult> getPageInfo(service::FieldParams&& params) const final { - return _pimpl->getPageInfo(std::move(params)); + if constexpr (TaskConnectionStubs::HasPageInfo) + { + return _pimpl->getPageInfo(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(TaskConnection::getPageInfo is not implemented)ex"); + } } service::FieldResult>>> getEdges(service::FieldParams&& params) const final { - return _pimpl->getEdges(std::move(params)); + if constexpr (TaskConnectionStubs::HasEdges) + { + return _pimpl->getEdges(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(TaskConnection::getEdges is not implemented)ex"); + } } private: @@ -62,8 +92,6 @@ class TaskConnection : TaskConnection { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } - - ~TaskConnection(); }; } // namespace graphql::today::object diff --git a/samples/separate/TaskEdgeObject.cpp b/samples/separate/TaskEdgeObject.cpp index 6ff72129..422506a8 100644 --- a/samples/separate/TaskEdgeObject.cpp +++ b/samples/separate/TaskEdgeObject.cpp @@ -30,10 +30,6 @@ TaskEdge::TaskEdge(std::unique_ptr&& pimpl) { } -TaskEdge::~TaskEdge() -{ -} - service::AwaitableResolver TaskEdge::resolveNode(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); diff --git a/samples/separate/TaskEdgeObject.h b/samples/separate/TaskEdgeObject.h index a7ca120a..815a2097 100644 --- a/samples/separate/TaskEdgeObject.h +++ b/samples/separate/TaskEdgeObject.h @@ -12,6 +12,22 @@ namespace graphql::today::object { +namespace TaskEdgeStubs { + +template +concept HasNode = requires (TImpl impl, service::FieldParams params) +{ + { impl.getNode(std::move(params)) } -> std::convertible_to>>; +}; + +template +concept HasCursor = requires (TImpl impl, service::FieldParams params) +{ + { impl.getCursor(std::move(params)) } -> std::convertible_to>; +}; + +} // namespace TaskEdgeStubs + class TaskEdge : public service::Object { @@ -40,12 +56,26 @@ class TaskEdge service::FieldResult> getNode(service::FieldParams&& params) const final { - return _pimpl->getNode(std::move(params)); + if constexpr (TaskEdgeStubs::HasNode) + { + return _pimpl->getNode(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(TaskEdge::getNode is not implemented)ex"); + } } service::FieldResult getCursor(service::FieldParams&& params) const final { - return _pimpl->getCursor(std::move(params)); + if constexpr (TaskEdgeStubs::HasCursor) + { + return _pimpl->getCursor(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(TaskEdge::getCursor is not implemented)ex"); + } } private: @@ -62,8 +92,6 @@ class TaskEdge : TaskEdge { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } - - ~TaskEdge(); }; } // namespace graphql::today::object diff --git a/samples/separate/TaskObject.cpp b/samples/separate/TaskObject.cpp index 65237095..60742961 100644 --- a/samples/separate/TaskObject.cpp +++ b/samples/separate/TaskObject.cpp @@ -33,10 +33,6 @@ Task::Task(std::unique_ptr&& pimpl) { } -Task::~Task() -{ -} - service::AwaitableResolver Task::resolveId(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); diff --git a/samples/separate/TaskObject.h b/samples/separate/TaskObject.h index 2fe8447e..78413875 100644 --- a/samples/separate/TaskObject.h +++ b/samples/separate/TaskObject.h @@ -12,6 +12,28 @@ namespace graphql::today::object { +namespace TaskStubs { + +template +concept HasId = requires (TImpl impl, service::FieldParams params) +{ + { impl.getId(std::move(params)) } -> std::convertible_to>; +}; + +template +concept HasTitle = requires (TImpl impl, service::FieldParams params) +{ + { impl.getTitle(std::move(params)) } -> std::convertible_to>>; +}; + +template +concept HasIsComplete = requires (TImpl impl, service::FieldParams params) +{ + { impl.getIsComplete(std::move(params)) } -> std::convertible_to>; +}; + +} // namespace TaskStubs + class Task : public service::Object { @@ -42,17 +64,38 @@ class Task service::FieldResult getId(service::FieldParams&& params) const final { - return _pimpl->getId(std::move(params)); + if constexpr (TaskStubs::HasId) + { + return _pimpl->getId(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(Task::getId is not implemented)ex"); + } } service::FieldResult> getTitle(service::FieldParams&& params) const final { - return _pimpl->getTitle(std::move(params)); + if constexpr (TaskStubs::HasTitle) + { + return _pimpl->getTitle(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(Task::getTitle is not implemented)ex"); + } } service::FieldResult getIsComplete(service::FieldParams&& params) const final { - return _pimpl->getIsComplete(std::move(params)); + if constexpr (TaskStubs::HasIsComplete) + { + return _pimpl->getIsComplete(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(Task::getIsComplete is not implemented)ex"); + } } private: @@ -69,8 +112,6 @@ class Task : Task { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } - - ~Task(); }; } // namespace graphql::today::object diff --git a/samples/separate/TodaySchema.h b/samples/separate/TodaySchema.h index 9f979a6e..7514ae28 100644 --- a/samples/separate/TodaySchema.h +++ b/samples/separate/TodaySchema.h @@ -14,6 +14,7 @@ static_assert(graphql::internal::MajorVersion == 4, "regenerate with schemagen: major version mismatch"); static_assert(graphql::internal::MinorVersion == 0, "regenerate with schemagen: minor version mismatch"); +#include #include #include #include diff --git a/samples/separate_nointrospection/AppointmentConnectionObject.cpp b/samples/separate_nointrospection/AppointmentConnectionObject.cpp index ad51753f..622e42a9 100644 --- a/samples/separate_nointrospection/AppointmentConnectionObject.cpp +++ b/samples/separate_nointrospection/AppointmentConnectionObject.cpp @@ -30,10 +30,6 @@ AppointmentConnection::AppointmentConnection(std::unique_ptr&& pimpl) { } -AppointmentConnection::~AppointmentConnection() -{ -} - service::AwaitableResolver AppointmentConnection::resolvePageInfo(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); diff --git a/samples/separate_nointrospection/AppointmentConnectionObject.h b/samples/separate_nointrospection/AppointmentConnectionObject.h index 2c84c81f..8df5345c 100644 --- a/samples/separate_nointrospection/AppointmentConnectionObject.h +++ b/samples/separate_nointrospection/AppointmentConnectionObject.h @@ -12,6 +12,22 @@ namespace graphql::today::object { +namespace AppointmentConnectionStubs { + +template +concept HasPageInfo = requires (TImpl impl, service::FieldParams params) +{ + { impl.getPageInfo(std::move(params)) } -> std::convertible_to>>; +}; + +template +concept HasEdges = requires (TImpl impl, service::FieldParams params) +{ + { impl.getEdges(std::move(params)) } -> std::convertible_to>>>>; +}; + +} // namespace AppointmentConnectionStubs + class AppointmentConnection : public service::Object { @@ -40,12 +56,26 @@ class AppointmentConnection service::FieldResult> getPageInfo(service::FieldParams&& params) const final { - return _pimpl->getPageInfo(std::move(params)); + if constexpr (AppointmentConnectionStubs::HasPageInfo) + { + return _pimpl->getPageInfo(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(AppointmentConnection::getPageInfo is not implemented)ex"); + } } service::FieldResult>>> getEdges(service::FieldParams&& params) const final { - return _pimpl->getEdges(std::move(params)); + if constexpr (AppointmentConnectionStubs::HasEdges) + { + return _pimpl->getEdges(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(AppointmentConnection::getEdges is not implemented)ex"); + } } private: @@ -62,8 +92,6 @@ class AppointmentConnection : AppointmentConnection { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } - - ~AppointmentConnection(); }; } // namespace graphql::today::object diff --git a/samples/separate_nointrospection/AppointmentEdgeObject.cpp b/samples/separate_nointrospection/AppointmentEdgeObject.cpp index 2d222f4b..df02bd88 100644 --- a/samples/separate_nointrospection/AppointmentEdgeObject.cpp +++ b/samples/separate_nointrospection/AppointmentEdgeObject.cpp @@ -30,10 +30,6 @@ AppointmentEdge::AppointmentEdge(std::unique_ptr&& pimpl) { } -AppointmentEdge::~AppointmentEdge() -{ -} - service::AwaitableResolver AppointmentEdge::resolveNode(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); diff --git a/samples/separate_nointrospection/AppointmentEdgeObject.h b/samples/separate_nointrospection/AppointmentEdgeObject.h index 44311d04..e2d0922b 100644 --- a/samples/separate_nointrospection/AppointmentEdgeObject.h +++ b/samples/separate_nointrospection/AppointmentEdgeObject.h @@ -12,6 +12,22 @@ namespace graphql::today::object { +namespace AppointmentEdgeStubs { + +template +concept HasNode = requires (TImpl impl, service::FieldParams params) +{ + { impl.getNode(std::move(params)) } -> std::convertible_to>>; +}; + +template +concept HasCursor = requires (TImpl impl, service::FieldParams params) +{ + { impl.getCursor(std::move(params)) } -> std::convertible_to>; +}; + +} // namespace AppointmentEdgeStubs + class AppointmentEdge : public service::Object { @@ -40,12 +56,26 @@ class AppointmentEdge service::FieldResult> getNode(service::FieldParams&& params) const final { - return _pimpl->getNode(std::move(params)); + if constexpr (AppointmentEdgeStubs::HasNode) + { + return _pimpl->getNode(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(AppointmentEdge::getNode is not implemented)ex"); + } } service::FieldResult getCursor(service::FieldParams&& params) const final { - return _pimpl->getCursor(std::move(params)); + if constexpr (AppointmentEdgeStubs::HasCursor) + { + return _pimpl->getCursor(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(AppointmentEdge::getCursor is not implemented)ex"); + } } private: @@ -62,8 +92,6 @@ class AppointmentEdge : AppointmentEdge { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } - - ~AppointmentEdge(); }; } // namespace graphql::today::object diff --git a/samples/separate_nointrospection/AppointmentObject.cpp b/samples/separate_nointrospection/AppointmentObject.cpp index 4327bc1b..30b83427 100644 --- a/samples/separate_nointrospection/AppointmentObject.cpp +++ b/samples/separate_nointrospection/AppointmentObject.cpp @@ -35,10 +35,6 @@ Appointment::Appointment(std::unique_ptr&& pimpl) { } -Appointment::~Appointment() -{ -} - service::AwaitableResolver Appointment::resolveId(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); diff --git a/samples/separate_nointrospection/AppointmentObject.h b/samples/separate_nointrospection/AppointmentObject.h index f6e57623..d13318bc 100644 --- a/samples/separate_nointrospection/AppointmentObject.h +++ b/samples/separate_nointrospection/AppointmentObject.h @@ -12,6 +12,40 @@ namespace graphql::today::object { +namespace AppointmentStubs { + +template +concept HasId = requires (TImpl impl, service::FieldParams params) +{ + { impl.getId(std::move(params)) } -> std::convertible_to>; +}; + +template +concept HasWhen = requires (TImpl impl, service::FieldParams params) +{ + { impl.getWhen(std::move(params)) } -> std::convertible_to>>; +}; + +template +concept HasSubject = requires (TImpl impl, service::FieldParams params) +{ + { impl.getSubject(std::move(params)) } -> std::convertible_to>>; +}; + +template +concept HasIsNow = requires (TImpl impl, service::FieldParams params) +{ + { impl.getIsNow(std::move(params)) } -> std::convertible_to>; +}; + +template +concept HasForceError = requires (TImpl impl, service::FieldParams params) +{ + { impl.getForceError(std::move(params)) } -> std::convertible_to>>; +}; + +} // namespace AppointmentStubs + class Appointment : public service::Object { @@ -46,27 +80,62 @@ class Appointment service::FieldResult getId(service::FieldParams&& params) const final { - return _pimpl->getId(std::move(params)); + if constexpr (AppointmentStubs::HasId) + { + return _pimpl->getId(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(Appointment::getId is not implemented)ex"); + } } service::FieldResult> getWhen(service::FieldParams&& params) const final { - return _pimpl->getWhen(std::move(params)); + if constexpr (AppointmentStubs::HasWhen) + { + return _pimpl->getWhen(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(Appointment::getWhen is not implemented)ex"); + } } service::FieldResult> getSubject(service::FieldParams&& params) const final { - return _pimpl->getSubject(std::move(params)); + if constexpr (AppointmentStubs::HasSubject) + { + return _pimpl->getSubject(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(Appointment::getSubject is not implemented)ex"); + } } service::FieldResult getIsNow(service::FieldParams&& params) const final { - return _pimpl->getIsNow(std::move(params)); + if constexpr (AppointmentStubs::HasIsNow) + { + return _pimpl->getIsNow(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(Appointment::getIsNow is not implemented)ex"); + } } service::FieldResult> getForceError(service::FieldParams&& params) const final { - return _pimpl->getForceError(std::move(params)); + if constexpr (AppointmentStubs::HasForceError) + { + return _pimpl->getForceError(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(Appointment::getForceError is not implemented)ex"); + } } private: @@ -83,8 +152,6 @@ class Appointment : Appointment { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } - - ~Appointment(); }; } // namespace graphql::today::object diff --git a/samples/separate_nointrospection/CompleteTaskPayloadObject.cpp b/samples/separate_nointrospection/CompleteTaskPayloadObject.cpp index ca0f6f76..2924a90c 100644 --- a/samples/separate_nointrospection/CompleteTaskPayloadObject.cpp +++ b/samples/separate_nointrospection/CompleteTaskPayloadObject.cpp @@ -30,10 +30,6 @@ CompleteTaskPayload::CompleteTaskPayload(std::unique_ptr&& pimpl) { } -CompleteTaskPayload::~CompleteTaskPayload() -{ -} - service::AwaitableResolver CompleteTaskPayload::resolveTask(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); diff --git a/samples/separate_nointrospection/CompleteTaskPayloadObject.h b/samples/separate_nointrospection/CompleteTaskPayloadObject.h index b5eca507..9e180344 100644 --- a/samples/separate_nointrospection/CompleteTaskPayloadObject.h +++ b/samples/separate_nointrospection/CompleteTaskPayloadObject.h @@ -12,6 +12,22 @@ namespace graphql::today::object { +namespace CompleteTaskPayloadStubs { + +template +concept HasTask = requires (TImpl impl, service::FieldParams params) +{ + { impl.getTask(std::move(params)) } -> std::convertible_to>>; +}; + +template +concept HasClientMutationId = requires (TImpl impl, service::FieldParams params) +{ + { impl.getClientMutationId(std::move(params)) } -> std::convertible_to>>; +}; + +} // namespace CompleteTaskPayloadStubs + class CompleteTaskPayload : public service::Object { @@ -40,12 +56,26 @@ class CompleteTaskPayload service::FieldResult> getTask(service::FieldParams&& params) const final { - return _pimpl->getTask(std::move(params)); + if constexpr (CompleteTaskPayloadStubs::HasTask) + { + return _pimpl->getTask(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(CompleteTaskPayload::getTask is not implemented)ex"); + } } service::FieldResult> getClientMutationId(service::FieldParams&& params) const final { - return _pimpl->getClientMutationId(std::move(params)); + if constexpr (CompleteTaskPayloadStubs::HasClientMutationId) + { + return _pimpl->getClientMutationId(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(CompleteTaskPayload::getClientMutationId is not implemented)ex"); + } } private: @@ -62,8 +92,6 @@ class CompleteTaskPayload : CompleteTaskPayload { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } - - ~CompleteTaskPayload(); }; } // namespace graphql::today::object diff --git a/samples/separate_nointrospection/ExpensiveObject.cpp b/samples/separate_nointrospection/ExpensiveObject.cpp index 51cc5140..d8634115 100644 --- a/samples/separate_nointrospection/ExpensiveObject.cpp +++ b/samples/separate_nointrospection/ExpensiveObject.cpp @@ -29,10 +29,6 @@ Expensive::Expensive(std::unique_ptr&& pimpl) { } -Expensive::~Expensive() -{ -} - service::AwaitableResolver Expensive::resolveOrder(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); diff --git a/samples/separate_nointrospection/ExpensiveObject.h b/samples/separate_nointrospection/ExpensiveObject.h index a48937ad..8b151c0c 100644 --- a/samples/separate_nointrospection/ExpensiveObject.h +++ b/samples/separate_nointrospection/ExpensiveObject.h @@ -12,6 +12,16 @@ namespace graphql::today::object { +namespace ExpensiveStubs { + +template +concept HasOrder = requires (TImpl impl, service::FieldParams params) +{ + { impl.getOrder(std::move(params)) } -> std::convertible_to>; +}; + +} // namespace ExpensiveStubs + class Expensive : public service::Object { @@ -38,7 +48,14 @@ class Expensive service::FieldResult getOrder(service::FieldParams&& params) const final { - return _pimpl->getOrder(std::move(params)); + if constexpr (ExpensiveStubs::HasOrder) + { + return _pimpl->getOrder(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(Expensive::getOrder is not implemented)ex"); + } } private: @@ -55,8 +72,6 @@ class Expensive : Expensive { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } - - ~Expensive(); }; } // namespace graphql::today::object diff --git a/samples/separate_nointrospection/FolderConnectionObject.cpp b/samples/separate_nointrospection/FolderConnectionObject.cpp index 802380da..26c4ab6d 100644 --- a/samples/separate_nointrospection/FolderConnectionObject.cpp +++ b/samples/separate_nointrospection/FolderConnectionObject.cpp @@ -30,10 +30,6 @@ FolderConnection::FolderConnection(std::unique_ptr&& pimpl) { } -FolderConnection::~FolderConnection() -{ -} - service::AwaitableResolver FolderConnection::resolvePageInfo(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); diff --git a/samples/separate_nointrospection/FolderConnectionObject.h b/samples/separate_nointrospection/FolderConnectionObject.h index fbc6673b..f3a659bf 100644 --- a/samples/separate_nointrospection/FolderConnectionObject.h +++ b/samples/separate_nointrospection/FolderConnectionObject.h @@ -12,6 +12,22 @@ namespace graphql::today::object { +namespace FolderConnectionStubs { + +template +concept HasPageInfo = requires (TImpl impl, service::FieldParams params) +{ + { impl.getPageInfo(std::move(params)) } -> std::convertible_to>>; +}; + +template +concept HasEdges = requires (TImpl impl, service::FieldParams params) +{ + { impl.getEdges(std::move(params)) } -> std::convertible_to>>>>; +}; + +} // namespace FolderConnectionStubs + class FolderConnection : public service::Object { @@ -40,12 +56,26 @@ class FolderConnection service::FieldResult> getPageInfo(service::FieldParams&& params) const final { - return _pimpl->getPageInfo(std::move(params)); + if constexpr (FolderConnectionStubs::HasPageInfo) + { + return _pimpl->getPageInfo(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(FolderConnection::getPageInfo is not implemented)ex"); + } } service::FieldResult>>> getEdges(service::FieldParams&& params) const final { - return _pimpl->getEdges(std::move(params)); + if constexpr (FolderConnectionStubs::HasEdges) + { + return _pimpl->getEdges(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(FolderConnection::getEdges is not implemented)ex"); + } } private: @@ -62,8 +92,6 @@ class FolderConnection : FolderConnection { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } - - ~FolderConnection(); }; } // namespace graphql::today::object diff --git a/samples/separate_nointrospection/FolderEdgeObject.cpp b/samples/separate_nointrospection/FolderEdgeObject.cpp index e4e63fb1..a3b31b14 100644 --- a/samples/separate_nointrospection/FolderEdgeObject.cpp +++ b/samples/separate_nointrospection/FolderEdgeObject.cpp @@ -30,10 +30,6 @@ FolderEdge::FolderEdge(std::unique_ptr&& pimpl) { } -FolderEdge::~FolderEdge() -{ -} - service::AwaitableResolver FolderEdge::resolveNode(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); diff --git a/samples/separate_nointrospection/FolderEdgeObject.h b/samples/separate_nointrospection/FolderEdgeObject.h index 71d07aec..9869c4a3 100644 --- a/samples/separate_nointrospection/FolderEdgeObject.h +++ b/samples/separate_nointrospection/FolderEdgeObject.h @@ -12,6 +12,22 @@ namespace graphql::today::object { +namespace FolderEdgeStubs { + +template +concept HasNode = requires (TImpl impl, service::FieldParams params) +{ + { impl.getNode(std::move(params)) } -> std::convertible_to>>; +}; + +template +concept HasCursor = requires (TImpl impl, service::FieldParams params) +{ + { impl.getCursor(std::move(params)) } -> std::convertible_to>; +}; + +} // namespace FolderEdgeStubs + class FolderEdge : public service::Object { @@ -40,12 +56,26 @@ class FolderEdge service::FieldResult> getNode(service::FieldParams&& params) const final { - return _pimpl->getNode(std::move(params)); + if constexpr (FolderEdgeStubs::HasNode) + { + return _pimpl->getNode(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(FolderEdge::getNode is not implemented)ex"); + } } service::FieldResult getCursor(service::FieldParams&& params) const final { - return _pimpl->getCursor(std::move(params)); + if constexpr (FolderEdgeStubs::HasCursor) + { + return _pimpl->getCursor(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(FolderEdge::getCursor is not implemented)ex"); + } } private: @@ -62,8 +92,6 @@ class FolderEdge : FolderEdge { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } - - ~FolderEdge(); }; } // namespace graphql::today::object diff --git a/samples/separate_nointrospection/FolderObject.cpp b/samples/separate_nointrospection/FolderObject.cpp index bccaf182..b95936e9 100644 --- a/samples/separate_nointrospection/FolderObject.cpp +++ b/samples/separate_nointrospection/FolderObject.cpp @@ -33,10 +33,6 @@ Folder::Folder(std::unique_ptr&& pimpl) { } -Folder::~Folder() -{ -} - service::AwaitableResolver Folder::resolveId(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); diff --git a/samples/separate_nointrospection/FolderObject.h b/samples/separate_nointrospection/FolderObject.h index 14ec9579..f5601542 100644 --- a/samples/separate_nointrospection/FolderObject.h +++ b/samples/separate_nointrospection/FolderObject.h @@ -12,6 +12,28 @@ namespace graphql::today::object { +namespace FolderStubs { + +template +concept HasId = requires (TImpl impl, service::FieldParams params) +{ + { impl.getId(std::move(params)) } -> std::convertible_to>; +}; + +template +concept HasName = requires (TImpl impl, service::FieldParams params) +{ + { impl.getName(std::move(params)) } -> std::convertible_to>>; +}; + +template +concept HasUnreadCount = requires (TImpl impl, service::FieldParams params) +{ + { impl.getUnreadCount(std::move(params)) } -> std::convertible_to>; +}; + +} // namespace FolderStubs + class Folder : public service::Object { @@ -42,17 +64,38 @@ class Folder service::FieldResult getId(service::FieldParams&& params) const final { - return _pimpl->getId(std::move(params)); + if constexpr (FolderStubs::HasId) + { + return _pimpl->getId(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(Folder::getId is not implemented)ex"); + } } service::FieldResult> getName(service::FieldParams&& params) const final { - return _pimpl->getName(std::move(params)); + if constexpr (FolderStubs::HasName) + { + return _pimpl->getName(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(Folder::getName is not implemented)ex"); + } } service::FieldResult getUnreadCount(service::FieldParams&& params) const final { - return _pimpl->getUnreadCount(std::move(params)); + if constexpr (FolderStubs::HasUnreadCount) + { + return _pimpl->getUnreadCount(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(Folder::getUnreadCount is not implemented)ex"); + } } private: @@ -69,8 +112,6 @@ class Folder : Folder { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } - - ~Folder(); }; } // namespace graphql::today::object diff --git a/samples/separate_nointrospection/MutationObject.cpp b/samples/separate_nointrospection/MutationObject.cpp index 9914a1e2..20ee2188 100644 --- a/samples/separate_nointrospection/MutationObject.cpp +++ b/samples/separate_nointrospection/MutationObject.cpp @@ -30,10 +30,6 @@ Mutation::Mutation(std::unique_ptr&& pimpl) { } -Mutation::~Mutation() -{ -} - service::AwaitableResolver Mutation::resolveCompleteTask(service::ResolverParams&& params) { auto argInput = service::ModifiedArgument::require("input", params.arguments); diff --git a/samples/separate_nointrospection/MutationObject.h b/samples/separate_nointrospection/MutationObject.h index cf0f4d81..1371d2bd 100644 --- a/samples/separate_nointrospection/MutationObject.h +++ b/samples/separate_nointrospection/MutationObject.h @@ -12,6 +12,22 @@ namespace graphql::today::object { +namespace MutationStubs { + +template +concept HasCompleteTask = requires (TImpl impl, service::FieldParams params, CompleteTaskInput inputArg) +{ + { impl.applyCompleteTask(std::move(params), std::move(inputArg)) } -> std::convertible_to>>; +}; + +template +concept HasSetFloat = requires (TImpl impl, service::FieldParams params, response::FloatType valueArg) +{ + { impl.applySetFloat(std::move(params), std::move(valueArg)) } -> std::convertible_to>; +}; + +} // namespace MutationStubs + class Mutation : public service::Object { @@ -40,12 +56,26 @@ class Mutation service::FieldResult> applyCompleteTask(service::FieldParams&& params, CompleteTaskInput&& inputArg) const final { - return _pimpl->applyCompleteTask(std::move(params), std::move(inputArg)); + if constexpr (MutationStubs::HasCompleteTask) + { + return _pimpl->applyCompleteTask(std::move(params), std::move(inputArg)); + } + else + { + throw std::runtime_error(R"ex(Mutation::applyCompleteTask is not implemented)ex"); + } } service::FieldResult applySetFloat(service::FieldParams&& params, response::FloatType&& valueArg) const final { - return _pimpl->applySetFloat(std::move(params), std::move(valueArg)); + if constexpr (MutationStubs::HasSetFloat) + { + return _pimpl->applySetFloat(std::move(params), std::move(valueArg)); + } + else + { + throw std::runtime_error(R"ex(Mutation::applySetFloat is not implemented)ex"); + } } private: @@ -62,8 +92,6 @@ class Mutation : Mutation { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } - - ~Mutation(); }; } // namespace graphql::today::object diff --git a/samples/separate_nointrospection/NestedTypeObject.cpp b/samples/separate_nointrospection/NestedTypeObject.cpp index db956679..fc80a6bb 100644 --- a/samples/separate_nointrospection/NestedTypeObject.cpp +++ b/samples/separate_nointrospection/NestedTypeObject.cpp @@ -30,10 +30,6 @@ NestedType::NestedType(std::unique_ptr&& pimpl) { } -NestedType::~NestedType() -{ -} - service::AwaitableResolver NestedType::resolveDepth(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); diff --git a/samples/separate_nointrospection/NestedTypeObject.h b/samples/separate_nointrospection/NestedTypeObject.h index 61d5888f..a19f3095 100644 --- a/samples/separate_nointrospection/NestedTypeObject.h +++ b/samples/separate_nointrospection/NestedTypeObject.h @@ -12,6 +12,22 @@ namespace graphql::today::object { +namespace NestedTypeStubs { + +template +concept HasDepth = requires (TImpl impl, service::FieldParams params) +{ + { impl.getDepth(std::move(params)) } -> std::convertible_to>; +}; + +template +concept HasNested = requires (TImpl impl, service::FieldParams params) +{ + { impl.getNested(std::move(params)) } -> std::convertible_to>>; +}; + +} // namespace NestedTypeStubs + class NestedType : public service::Object { @@ -40,12 +56,26 @@ class NestedType service::FieldResult getDepth(service::FieldParams&& params) const final { - return _pimpl->getDepth(std::move(params)); + if constexpr (NestedTypeStubs::HasDepth) + { + return _pimpl->getDepth(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(NestedType::getDepth is not implemented)ex"); + } } service::FieldResult> getNested(service::FieldParams&& params) const final { - return _pimpl->getNested(std::move(params)); + if constexpr (NestedTypeStubs::HasNested) + { + return _pimpl->getNested(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(NestedType::getNested is not implemented)ex"); + } } private: @@ -62,8 +92,6 @@ class NestedType : NestedType { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } - - ~NestedType(); }; } // namespace graphql::today::object diff --git a/samples/separate_nointrospection/PageInfoObject.cpp b/samples/separate_nointrospection/PageInfoObject.cpp index 2c222dce..d406c9f2 100644 --- a/samples/separate_nointrospection/PageInfoObject.cpp +++ b/samples/separate_nointrospection/PageInfoObject.cpp @@ -30,10 +30,6 @@ PageInfo::PageInfo(std::unique_ptr&& pimpl) { } -PageInfo::~PageInfo() -{ -} - service::AwaitableResolver PageInfo::resolveHasNextPage(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); diff --git a/samples/separate_nointrospection/PageInfoObject.h b/samples/separate_nointrospection/PageInfoObject.h index 1f94559c..6d5234ee 100644 --- a/samples/separate_nointrospection/PageInfoObject.h +++ b/samples/separate_nointrospection/PageInfoObject.h @@ -12,6 +12,22 @@ namespace graphql::today::object { +namespace PageInfoStubs { + +template +concept HasHasNextPage = requires (TImpl impl, service::FieldParams params) +{ + { impl.getHasNextPage(std::move(params)) } -> std::convertible_to>; +}; + +template +concept HasHasPreviousPage = requires (TImpl impl, service::FieldParams params) +{ + { impl.getHasPreviousPage(std::move(params)) } -> std::convertible_to>; +}; + +} // namespace PageInfoStubs + class PageInfo : public service::Object { @@ -40,12 +56,26 @@ class PageInfo service::FieldResult getHasNextPage(service::FieldParams&& params) const final { - return _pimpl->getHasNextPage(std::move(params)); + if constexpr (PageInfoStubs::HasHasNextPage) + { + return _pimpl->getHasNextPage(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(PageInfo::getHasNextPage is not implemented)ex"); + } } service::FieldResult getHasPreviousPage(service::FieldParams&& params) const final { - return _pimpl->getHasPreviousPage(std::move(params)); + if constexpr (PageInfoStubs::HasHasPreviousPage) + { + return _pimpl->getHasPreviousPage(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(PageInfo::getHasPreviousPage is not implemented)ex"); + } } private: @@ -62,8 +92,6 @@ class PageInfo : PageInfo { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } - - ~PageInfo(); }; } // namespace graphql::today::object diff --git a/samples/separate_nointrospection/QueryObject.cpp b/samples/separate_nointrospection/QueryObject.cpp index df92ce11..dad53db8 100644 --- a/samples/separate_nointrospection/QueryObject.cpp +++ b/samples/separate_nointrospection/QueryObject.cpp @@ -40,10 +40,6 @@ Query::Query(std::unique_ptr&& pimpl) { } -Query::~Query() -{ -} - service::AwaitableResolver Query::resolveNode(service::ResolverParams&& params) { auto argId = service::ModifiedArgument::require("id", params.arguments); diff --git a/samples/separate_nointrospection/QueryObject.h b/samples/separate_nointrospection/QueryObject.h index 1169b447..ad396463 100644 --- a/samples/separate_nointrospection/QueryObject.h +++ b/samples/separate_nointrospection/QueryObject.h @@ -12,6 +12,82 @@ namespace graphql::today::object { +namespace QueryStubs { + +template +concept HasNode = requires (TImpl impl, service::FieldParams params, response::IdType idArg) +{ + { impl.getNode(std::move(params), std::move(idArg)) } -> std::convertible_to>>; +}; + +template +concept HasAppointments = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) +{ + { impl.getAppointments(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } -> std::convertible_to>>; +}; + +template +concept HasTasks = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) +{ + { impl.getTasks(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } -> std::convertible_to>>; +}; + +template +concept HasUnreadCounts = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) +{ + { impl.getUnreadCounts(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } -> std::convertible_to>>; +}; + +template +concept HasAppointmentsById = requires (TImpl impl, service::FieldParams params, std::vector idsArg) +{ + { impl.getAppointmentsById(std::move(params), std::move(idsArg)) } -> std::convertible_to>>>; +}; + +template +concept HasTasksById = requires (TImpl impl, service::FieldParams params, std::vector idsArg) +{ + { impl.getTasksById(std::move(params), std::move(idsArg)) } -> std::convertible_to>>>; +}; + +template +concept HasUnreadCountsById = requires (TImpl impl, service::FieldParams params, std::vector idsArg) +{ + { impl.getUnreadCountsById(std::move(params), std::move(idsArg)) } -> std::convertible_to>>>; +}; + +template +concept HasNested = requires (TImpl impl, service::FieldParams params) +{ + { impl.getNested(std::move(params)) } -> std::convertible_to>>; +}; + +template +concept HasUnimplemented = requires (TImpl impl, service::FieldParams params) +{ + { impl.getUnimplemented(std::move(params)) } -> std::convertible_to>; +}; + +template +concept HasExpensive = requires (TImpl impl, service::FieldParams params) +{ + { impl.getExpensive(std::move(params)) } -> std::convertible_to>>>; +}; + +template +concept HasTestTaskState = requires (TImpl impl, service::FieldParams params) +{ + { impl.getTestTaskState(std::move(params)) } -> std::convertible_to>; +}; + +template +concept HasAnyType = requires (TImpl impl, service::FieldParams params, std::vector idsArg) +{ + { impl.getAnyType(std::move(params), std::move(idsArg)) } -> std::convertible_to>>>; +}; + +} // namespace QueryStubs + class Query : public service::Object { @@ -60,62 +136,146 @@ class Query service::FieldResult> getNode(service::FieldParams&& params, response::IdType&& idArg) const final { - return _pimpl->getNode(std::move(params), std::move(idArg)); + if constexpr (QueryStubs::HasNode) + { + return _pimpl->getNode(std::move(params), std::move(idArg)); + } + else + { + throw std::runtime_error(R"ex(Query::getNode is not implemented)ex"); + } } service::FieldResult> getAppointments(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const final { - return _pimpl->getAppointments(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)); + if constexpr (QueryStubs::HasAppointments) + { + return _pimpl->getAppointments(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)); + } + else + { + throw std::runtime_error(R"ex(Query::getAppointments is not implemented)ex"); + } } service::FieldResult> getTasks(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const final { - return _pimpl->getTasks(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)); + if constexpr (QueryStubs::HasTasks) + { + return _pimpl->getTasks(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)); + } + else + { + throw std::runtime_error(R"ex(Query::getTasks is not implemented)ex"); + } } service::FieldResult> getUnreadCounts(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const final { - return _pimpl->getUnreadCounts(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)); + if constexpr (QueryStubs::HasUnreadCounts) + { + return _pimpl->getUnreadCounts(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)); + } + else + { + throw std::runtime_error(R"ex(Query::getUnreadCounts is not implemented)ex"); + } } service::FieldResult>> getAppointmentsById(service::FieldParams&& params, std::vector&& idsArg) const final { - return _pimpl->getAppointmentsById(std::move(params), std::move(idsArg)); + if constexpr (QueryStubs::HasAppointmentsById) + { + return _pimpl->getAppointmentsById(std::move(params), std::move(idsArg)); + } + else + { + throw std::runtime_error(R"ex(Query::getAppointmentsById is not implemented)ex"); + } } service::FieldResult>> getTasksById(service::FieldParams&& params, std::vector&& idsArg) const final { - return _pimpl->getTasksById(std::move(params), std::move(idsArg)); + if constexpr (QueryStubs::HasTasksById) + { + return _pimpl->getTasksById(std::move(params), std::move(idsArg)); + } + else + { + throw std::runtime_error(R"ex(Query::getTasksById is not implemented)ex"); + } } service::FieldResult>> getUnreadCountsById(service::FieldParams&& params, std::vector&& idsArg) const final { - return _pimpl->getUnreadCountsById(std::move(params), std::move(idsArg)); + if constexpr (QueryStubs::HasUnreadCountsById) + { + return _pimpl->getUnreadCountsById(std::move(params), std::move(idsArg)); + } + else + { + throw std::runtime_error(R"ex(Query::getUnreadCountsById is not implemented)ex"); + } } service::FieldResult> getNested(service::FieldParams&& params) const final { - return _pimpl->getNested(std::move(params)); + if constexpr (QueryStubs::HasNested) + { + return _pimpl->getNested(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(Query::getNested is not implemented)ex"); + } } service::FieldResult getUnimplemented(service::FieldParams&& params) const final { - return _pimpl->getUnimplemented(std::move(params)); + if constexpr (QueryStubs::HasUnimplemented) + { + return _pimpl->getUnimplemented(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(Query::getUnimplemented is not implemented)ex"); + } } service::FieldResult>> getExpensive(service::FieldParams&& params) const final { - return _pimpl->getExpensive(std::move(params)); + if constexpr (QueryStubs::HasExpensive) + { + return _pimpl->getExpensive(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(Query::getExpensive is not implemented)ex"); + } } service::FieldResult getTestTaskState(service::FieldParams&& params) const final { - return _pimpl->getTestTaskState(std::move(params)); + if constexpr (QueryStubs::HasTestTaskState) + { + return _pimpl->getTestTaskState(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(Query::getTestTaskState is not implemented)ex"); + } } service::FieldResult>> getAnyType(service::FieldParams&& params, std::vector&& idsArg) const final { - return _pimpl->getAnyType(std::move(params), std::move(idsArg)); + if constexpr (QueryStubs::HasAnyType) + { + return _pimpl->getAnyType(std::move(params), std::move(idsArg)); + } + else + { + throw std::runtime_error(R"ex(Query::getAnyType is not implemented)ex"); + } } private: @@ -132,8 +292,6 @@ class Query : Query { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } - - ~Query(); }; } // namespace graphql::today::object diff --git a/samples/separate_nointrospection/SubscriptionObject.cpp b/samples/separate_nointrospection/SubscriptionObject.cpp index b69a1270..949f4914 100644 --- a/samples/separate_nointrospection/SubscriptionObject.cpp +++ b/samples/separate_nointrospection/SubscriptionObject.cpp @@ -30,10 +30,6 @@ Subscription::Subscription(std::unique_ptr&& pimpl) { } -Subscription::~Subscription() -{ -} - service::AwaitableResolver Subscription::resolveNextAppointmentChange(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); diff --git a/samples/separate_nointrospection/SubscriptionObject.h b/samples/separate_nointrospection/SubscriptionObject.h index 16664a41..ca36231f 100644 --- a/samples/separate_nointrospection/SubscriptionObject.h +++ b/samples/separate_nointrospection/SubscriptionObject.h @@ -12,6 +12,22 @@ namespace graphql::today::object { +namespace SubscriptionStubs { + +template +concept HasNextAppointmentChange = requires (TImpl impl, service::FieldParams params) +{ + { impl.getNextAppointmentChange(std::move(params)) } -> std::convertible_to>>; +}; + +template +concept HasNodeChange = requires (TImpl impl, service::FieldParams params, response::IdType idArg) +{ + { impl.getNodeChange(std::move(params), std::move(idArg)) } -> std::convertible_to>>; +}; + +} // namespace SubscriptionStubs + class Subscription : public service::Object { @@ -40,12 +56,26 @@ class Subscription service::FieldResult> getNextAppointmentChange(service::FieldParams&& params) const final { - return _pimpl->getNextAppointmentChange(std::move(params)); + if constexpr (SubscriptionStubs::HasNextAppointmentChange) + { + return _pimpl->getNextAppointmentChange(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(Subscription::getNextAppointmentChange is not implemented)ex"); + } } service::FieldResult> getNodeChange(service::FieldParams&& params, response::IdType&& idArg) const final { - return _pimpl->getNodeChange(std::move(params), std::move(idArg)); + if constexpr (SubscriptionStubs::HasNodeChange) + { + return _pimpl->getNodeChange(std::move(params), std::move(idArg)); + } + else + { + throw std::runtime_error(R"ex(Subscription::getNodeChange is not implemented)ex"); + } } private: @@ -62,8 +92,6 @@ class Subscription : Subscription { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } - - ~Subscription(); }; } // namespace graphql::today::object diff --git a/samples/separate_nointrospection/TaskConnectionObject.cpp b/samples/separate_nointrospection/TaskConnectionObject.cpp index e74354cb..b5053add 100644 --- a/samples/separate_nointrospection/TaskConnectionObject.cpp +++ b/samples/separate_nointrospection/TaskConnectionObject.cpp @@ -30,10 +30,6 @@ TaskConnection::TaskConnection(std::unique_ptr&& pimpl) { } -TaskConnection::~TaskConnection() -{ -} - service::AwaitableResolver TaskConnection::resolvePageInfo(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); diff --git a/samples/separate_nointrospection/TaskConnectionObject.h b/samples/separate_nointrospection/TaskConnectionObject.h index 1f2d232c..b4e4c037 100644 --- a/samples/separate_nointrospection/TaskConnectionObject.h +++ b/samples/separate_nointrospection/TaskConnectionObject.h @@ -12,6 +12,22 @@ namespace graphql::today::object { +namespace TaskConnectionStubs { + +template +concept HasPageInfo = requires (TImpl impl, service::FieldParams params) +{ + { impl.getPageInfo(std::move(params)) } -> std::convertible_to>>; +}; + +template +concept HasEdges = requires (TImpl impl, service::FieldParams params) +{ + { impl.getEdges(std::move(params)) } -> std::convertible_to>>>>; +}; + +} // namespace TaskConnectionStubs + class TaskConnection : public service::Object { @@ -40,12 +56,26 @@ class TaskConnection service::FieldResult> getPageInfo(service::FieldParams&& params) const final { - return _pimpl->getPageInfo(std::move(params)); + if constexpr (TaskConnectionStubs::HasPageInfo) + { + return _pimpl->getPageInfo(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(TaskConnection::getPageInfo is not implemented)ex"); + } } service::FieldResult>>> getEdges(service::FieldParams&& params) const final { - return _pimpl->getEdges(std::move(params)); + if constexpr (TaskConnectionStubs::HasEdges) + { + return _pimpl->getEdges(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(TaskConnection::getEdges is not implemented)ex"); + } } private: @@ -62,8 +92,6 @@ class TaskConnection : TaskConnection { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } - - ~TaskConnection(); }; } // namespace graphql::today::object diff --git a/samples/separate_nointrospection/TaskEdgeObject.cpp b/samples/separate_nointrospection/TaskEdgeObject.cpp index 6ff72129..422506a8 100644 --- a/samples/separate_nointrospection/TaskEdgeObject.cpp +++ b/samples/separate_nointrospection/TaskEdgeObject.cpp @@ -30,10 +30,6 @@ TaskEdge::TaskEdge(std::unique_ptr&& pimpl) { } -TaskEdge::~TaskEdge() -{ -} - service::AwaitableResolver TaskEdge::resolveNode(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); diff --git a/samples/separate_nointrospection/TaskEdgeObject.h b/samples/separate_nointrospection/TaskEdgeObject.h index a7ca120a..815a2097 100644 --- a/samples/separate_nointrospection/TaskEdgeObject.h +++ b/samples/separate_nointrospection/TaskEdgeObject.h @@ -12,6 +12,22 @@ namespace graphql::today::object { +namespace TaskEdgeStubs { + +template +concept HasNode = requires (TImpl impl, service::FieldParams params) +{ + { impl.getNode(std::move(params)) } -> std::convertible_to>>; +}; + +template +concept HasCursor = requires (TImpl impl, service::FieldParams params) +{ + { impl.getCursor(std::move(params)) } -> std::convertible_to>; +}; + +} // namespace TaskEdgeStubs + class TaskEdge : public service::Object { @@ -40,12 +56,26 @@ class TaskEdge service::FieldResult> getNode(service::FieldParams&& params) const final { - return _pimpl->getNode(std::move(params)); + if constexpr (TaskEdgeStubs::HasNode) + { + return _pimpl->getNode(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(TaskEdge::getNode is not implemented)ex"); + } } service::FieldResult getCursor(service::FieldParams&& params) const final { - return _pimpl->getCursor(std::move(params)); + if constexpr (TaskEdgeStubs::HasCursor) + { + return _pimpl->getCursor(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(TaskEdge::getCursor is not implemented)ex"); + } } private: @@ -62,8 +92,6 @@ class TaskEdge : TaskEdge { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } - - ~TaskEdge(); }; } // namespace graphql::today::object diff --git a/samples/separate_nointrospection/TaskObject.cpp b/samples/separate_nointrospection/TaskObject.cpp index 65237095..60742961 100644 --- a/samples/separate_nointrospection/TaskObject.cpp +++ b/samples/separate_nointrospection/TaskObject.cpp @@ -33,10 +33,6 @@ Task::Task(std::unique_ptr&& pimpl) { } -Task::~Task() -{ -} - service::AwaitableResolver Task::resolveId(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); diff --git a/samples/separate_nointrospection/TaskObject.h b/samples/separate_nointrospection/TaskObject.h index 2fe8447e..78413875 100644 --- a/samples/separate_nointrospection/TaskObject.h +++ b/samples/separate_nointrospection/TaskObject.h @@ -12,6 +12,28 @@ namespace graphql::today::object { +namespace TaskStubs { + +template +concept HasId = requires (TImpl impl, service::FieldParams params) +{ + { impl.getId(std::move(params)) } -> std::convertible_to>; +}; + +template +concept HasTitle = requires (TImpl impl, service::FieldParams params) +{ + { impl.getTitle(std::move(params)) } -> std::convertible_to>>; +}; + +template +concept HasIsComplete = requires (TImpl impl, service::FieldParams params) +{ + { impl.getIsComplete(std::move(params)) } -> std::convertible_to>; +}; + +} // namespace TaskStubs + class Task : public service::Object { @@ -42,17 +64,38 @@ class Task service::FieldResult getId(service::FieldParams&& params) const final { - return _pimpl->getId(std::move(params)); + if constexpr (TaskStubs::HasId) + { + return _pimpl->getId(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(Task::getId is not implemented)ex"); + } } service::FieldResult> getTitle(service::FieldParams&& params) const final { - return _pimpl->getTitle(std::move(params)); + if constexpr (TaskStubs::HasTitle) + { + return _pimpl->getTitle(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(Task::getTitle is not implemented)ex"); + } } service::FieldResult getIsComplete(service::FieldParams&& params) const final { - return _pimpl->getIsComplete(std::move(params)); + if constexpr (TaskStubs::HasIsComplete) + { + return _pimpl->getIsComplete(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(Task::getIsComplete is not implemented)ex"); + } } private: @@ -69,8 +112,6 @@ class Task : Task { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } - - ~Task(); }; } // namespace graphql::today::object diff --git a/samples/separate_nointrospection/TodaySchema.h b/samples/separate_nointrospection/TodaySchema.h index 9f979a6e..7514ae28 100644 --- a/samples/separate_nointrospection/TodaySchema.h +++ b/samples/separate_nointrospection/TodaySchema.h @@ -14,6 +14,7 @@ static_assert(graphql::internal::MajorVersion == 4, "regenerate with schemagen: major version mismatch"); static_assert(graphql::internal::MinorVersion == 0, "regenerate with schemagen: minor version mismatch"); +#include #include #include #include diff --git a/samples/unified/TodaySchema.cpp b/samples/unified/TodaySchema.cpp index 42dd1e5d..c3716d3e 100644 --- a/samples/unified/TodaySchema.cpp +++ b/samples/unified/TodaySchema.cpp @@ -166,10 +166,6 @@ Query::Query(std::unique_ptr&& pimpl) { } -Query::~Query() -{ -} - service::AwaitableResolver Query::resolveNode(service::ResolverParams&& params) { auto argId = service::ModifiedArgument::require("id", params.arguments); @@ -360,10 +356,6 @@ PageInfo::PageInfo(std::unique_ptr&& pimpl) { } -PageInfo::~PageInfo() -{ -} - service::AwaitableResolver PageInfo::resolveHasNextPage(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); @@ -401,10 +393,6 @@ AppointmentEdge::AppointmentEdge(std::unique_ptr&& pimpl) { } -AppointmentEdge::~AppointmentEdge() -{ -} - service::AwaitableResolver AppointmentEdge::resolveNode(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); @@ -442,10 +430,6 @@ AppointmentConnection::AppointmentConnection(std::unique_ptr&& pimpl) { } -AppointmentConnection::~AppointmentConnection() -{ -} - service::AwaitableResolver AppointmentConnection::resolvePageInfo(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); @@ -483,10 +467,6 @@ TaskEdge::TaskEdge(std::unique_ptr&& pimpl) { } -TaskEdge::~TaskEdge() -{ -} - service::AwaitableResolver TaskEdge::resolveNode(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); @@ -524,10 +504,6 @@ TaskConnection::TaskConnection(std::unique_ptr&& pimpl) { } -TaskConnection::~TaskConnection() -{ -} - service::AwaitableResolver TaskConnection::resolvePageInfo(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); @@ -565,10 +541,6 @@ FolderEdge::FolderEdge(std::unique_ptr&& pimpl) { } -FolderEdge::~FolderEdge() -{ -} - service::AwaitableResolver FolderEdge::resolveNode(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); @@ -606,10 +578,6 @@ FolderConnection::FolderConnection(std::unique_ptr&& pimpl) { } -FolderConnection::~FolderConnection() -{ -} - service::AwaitableResolver FolderConnection::resolvePageInfo(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); @@ -647,10 +615,6 @@ CompleteTaskPayload::CompleteTaskPayload(std::unique_ptr&& pimpl) { } -CompleteTaskPayload::~CompleteTaskPayload() -{ -} - service::AwaitableResolver CompleteTaskPayload::resolveTask(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); @@ -688,10 +652,6 @@ Mutation::Mutation(std::unique_ptr&& pimpl) { } -Mutation::~Mutation() -{ -} - service::AwaitableResolver Mutation::resolveCompleteTask(service::ResolverParams&& params) { auto argInput = service::ModifiedArgument::require("input", params.arguments); @@ -731,10 +691,6 @@ Subscription::Subscription(std::unique_ptr&& pimpl) { } -Subscription::~Subscription() -{ -} - service::AwaitableResolver Subscription::resolveNextAppointmentChange(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); @@ -778,10 +734,6 @@ Appointment::Appointment(std::unique_ptr&& pimpl) { } -Appointment::~Appointment() -{ -} - service::AwaitableResolver Appointment::resolveId(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); @@ -852,10 +804,6 @@ Task::Task(std::unique_ptr&& pimpl) { } -Task::~Task() -{ -} - service::AwaitableResolver Task::resolveId(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); @@ -906,10 +854,6 @@ Folder::Folder(std::unique_ptr&& pimpl) { } -Folder::~Folder() -{ -} - service::AwaitableResolver Folder::resolveId(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); @@ -957,10 +901,6 @@ NestedType::NestedType(std::unique_ptr&& pimpl) { } -NestedType::~NestedType() -{ -} - service::AwaitableResolver NestedType::resolveDepth(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); @@ -997,10 +937,6 @@ Expensive::Expensive(std::unique_ptr&& pimpl) { } -Expensive::~Expensive() -{ -} - service::AwaitableResolver Expensive::resolveOrder(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); diff --git a/samples/unified/TodaySchema.h b/samples/unified/TodaySchema.h index 2d0e22c0..bd7a90ee 100644 --- a/samples/unified/TodaySchema.h +++ b/samples/unified/TodaySchema.h @@ -14,6 +14,7 @@ static_assert(graphql::internal::MajorVersion == 4, "regenerate with schemagen: major version mismatch"); static_assert(graphql::internal::MinorVersion == 0, "regenerate with schemagen: minor version mismatch"); +#include #include #include #include @@ -88,6 +89,82 @@ struct Node namespace object { +namespace QueryStubs { + +template +concept HasNode = requires (TImpl impl, service::FieldParams params, response::IdType idArg) +{ + { impl.getNode(std::move(params), std::move(idArg)) } -> std::convertible_to>>; +}; + +template +concept HasAppointments = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) +{ + { impl.getAppointments(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } -> std::convertible_to>>; +}; + +template +concept HasTasks = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) +{ + { impl.getTasks(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } -> std::convertible_to>>; +}; + +template +concept HasUnreadCounts = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) +{ + { impl.getUnreadCounts(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } -> std::convertible_to>>; +}; + +template +concept HasAppointmentsById = requires (TImpl impl, service::FieldParams params, std::vector idsArg) +{ + { impl.getAppointmentsById(std::move(params), std::move(idsArg)) } -> std::convertible_to>>>; +}; + +template +concept HasTasksById = requires (TImpl impl, service::FieldParams params, std::vector idsArg) +{ + { impl.getTasksById(std::move(params), std::move(idsArg)) } -> std::convertible_to>>>; +}; + +template +concept HasUnreadCountsById = requires (TImpl impl, service::FieldParams params, std::vector idsArg) +{ + { impl.getUnreadCountsById(std::move(params), std::move(idsArg)) } -> std::convertible_to>>>; +}; + +template +concept HasNested = requires (TImpl impl, service::FieldParams params) +{ + { impl.getNested(std::move(params)) } -> std::convertible_to>>; +}; + +template +concept HasUnimplemented = requires (TImpl impl, service::FieldParams params) +{ + { impl.getUnimplemented(std::move(params)) } -> std::convertible_to>; +}; + +template +concept HasExpensive = requires (TImpl impl, service::FieldParams params) +{ + { impl.getExpensive(std::move(params)) } -> std::convertible_to>>>; +}; + +template +concept HasTestTaskState = requires (TImpl impl, service::FieldParams params) +{ + { impl.getTestTaskState(std::move(params)) } -> std::convertible_to>; +}; + +template +concept HasAnyType = requires (TImpl impl, service::FieldParams params, std::vector idsArg) +{ + { impl.getAnyType(std::move(params), std::move(idsArg)) } -> std::convertible_to>>>; +}; + +} // namespace QueryStubs + class Query : public service::Object { @@ -140,62 +217,146 @@ class Query service::FieldResult> getNode(service::FieldParams&& params, response::IdType&& idArg) const final { - return _pimpl->getNode(std::move(params), std::move(idArg)); + if constexpr (QueryStubs::HasNode) + { + return _pimpl->getNode(std::move(params), std::move(idArg)); + } + else + { + throw std::runtime_error(R"ex(Query::getNode is not implemented)ex"); + } } service::FieldResult> getAppointments(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const final { - return _pimpl->getAppointments(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)); + if constexpr (QueryStubs::HasAppointments) + { + return _pimpl->getAppointments(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)); + } + else + { + throw std::runtime_error(R"ex(Query::getAppointments is not implemented)ex"); + } } service::FieldResult> getTasks(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const final { - return _pimpl->getTasks(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)); + if constexpr (QueryStubs::HasTasks) + { + return _pimpl->getTasks(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)); + } + else + { + throw std::runtime_error(R"ex(Query::getTasks is not implemented)ex"); + } } service::FieldResult> getUnreadCounts(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const final { - return _pimpl->getUnreadCounts(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)); + if constexpr (QueryStubs::HasUnreadCounts) + { + return _pimpl->getUnreadCounts(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)); + } + else + { + throw std::runtime_error(R"ex(Query::getUnreadCounts is not implemented)ex"); + } } service::FieldResult>> getAppointmentsById(service::FieldParams&& params, std::vector&& idsArg) const final { - return _pimpl->getAppointmentsById(std::move(params), std::move(idsArg)); + if constexpr (QueryStubs::HasAppointmentsById) + { + return _pimpl->getAppointmentsById(std::move(params), std::move(idsArg)); + } + else + { + throw std::runtime_error(R"ex(Query::getAppointmentsById is not implemented)ex"); + } } service::FieldResult>> getTasksById(service::FieldParams&& params, std::vector&& idsArg) const final { - return _pimpl->getTasksById(std::move(params), std::move(idsArg)); + if constexpr (QueryStubs::HasTasksById) + { + return _pimpl->getTasksById(std::move(params), std::move(idsArg)); + } + else + { + throw std::runtime_error(R"ex(Query::getTasksById is not implemented)ex"); + } } service::FieldResult>> getUnreadCountsById(service::FieldParams&& params, std::vector&& idsArg) const final { - return _pimpl->getUnreadCountsById(std::move(params), std::move(idsArg)); + if constexpr (QueryStubs::HasUnreadCountsById) + { + return _pimpl->getUnreadCountsById(std::move(params), std::move(idsArg)); + } + else + { + throw std::runtime_error(R"ex(Query::getUnreadCountsById is not implemented)ex"); + } } service::FieldResult> getNested(service::FieldParams&& params) const final { - return _pimpl->getNested(std::move(params)); + if constexpr (QueryStubs::HasNested) + { + return _pimpl->getNested(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(Query::getNested is not implemented)ex"); + } } service::FieldResult getUnimplemented(service::FieldParams&& params) const final { - return _pimpl->getUnimplemented(std::move(params)); + if constexpr (QueryStubs::HasUnimplemented) + { + return _pimpl->getUnimplemented(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(Query::getUnimplemented is not implemented)ex"); + } } service::FieldResult>> getExpensive(service::FieldParams&& params) const final { - return _pimpl->getExpensive(std::move(params)); + if constexpr (QueryStubs::HasExpensive) + { + return _pimpl->getExpensive(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(Query::getExpensive is not implemented)ex"); + } } service::FieldResult getTestTaskState(service::FieldParams&& params) const final { - return _pimpl->getTestTaskState(std::move(params)); + if constexpr (QueryStubs::HasTestTaskState) + { + return _pimpl->getTestTaskState(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(Query::getTestTaskState is not implemented)ex"); + } } service::FieldResult>> getAnyType(service::FieldParams&& params, std::vector&& idsArg) const final { - return _pimpl->getAnyType(std::move(params), std::move(idsArg)); + if constexpr (QueryStubs::HasAnyType) + { + return _pimpl->getAnyType(std::move(params), std::move(idsArg)); + } + else + { + throw std::runtime_error(R"ex(Query::getAnyType is not implemented)ex"); + } } private: @@ -212,10 +373,24 @@ class Query : Query { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } +}; - ~Query(); +namespace PageInfoStubs { + +template +concept HasHasNextPage = requires (TImpl impl, service::FieldParams params) +{ + { impl.getHasNextPage(std::move(params)) } -> std::convertible_to>; +}; + +template +concept HasHasPreviousPage = requires (TImpl impl, service::FieldParams params) +{ + { impl.getHasPreviousPage(std::move(params)) } -> std::convertible_to>; }; +} // namespace PageInfoStubs + class PageInfo : public service::Object { @@ -244,12 +419,26 @@ class PageInfo service::FieldResult getHasNextPage(service::FieldParams&& params) const final { - return _pimpl->getHasNextPage(std::move(params)); + if constexpr (PageInfoStubs::HasHasNextPage) + { + return _pimpl->getHasNextPage(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(PageInfo::getHasNextPage is not implemented)ex"); + } } service::FieldResult getHasPreviousPage(service::FieldParams&& params) const final { - return _pimpl->getHasPreviousPage(std::move(params)); + if constexpr (PageInfoStubs::HasHasPreviousPage) + { + return _pimpl->getHasPreviousPage(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(PageInfo::getHasPreviousPage is not implemented)ex"); + } } private: @@ -266,10 +455,24 @@ class PageInfo : PageInfo { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } +}; + +namespace AppointmentEdgeStubs { + +template +concept HasNode = requires (TImpl impl, service::FieldParams params) +{ + { impl.getNode(std::move(params)) } -> std::convertible_to>>; +}; - ~PageInfo(); +template +concept HasCursor = requires (TImpl impl, service::FieldParams params) +{ + { impl.getCursor(std::move(params)) } -> std::convertible_to>; }; +} // namespace AppointmentEdgeStubs + class AppointmentEdge : public service::Object { @@ -298,12 +501,26 @@ class AppointmentEdge service::FieldResult> getNode(service::FieldParams&& params) const final { - return _pimpl->getNode(std::move(params)); + if constexpr (AppointmentEdgeStubs::HasNode) + { + return _pimpl->getNode(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(AppointmentEdge::getNode is not implemented)ex"); + } } service::FieldResult getCursor(service::FieldParams&& params) const final { - return _pimpl->getCursor(std::move(params)); + if constexpr (AppointmentEdgeStubs::HasCursor) + { + return _pimpl->getCursor(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(AppointmentEdge::getCursor is not implemented)ex"); + } } private: @@ -320,10 +537,24 @@ class AppointmentEdge : AppointmentEdge { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } +}; + +namespace AppointmentConnectionStubs { - ~AppointmentEdge(); +template +concept HasPageInfo = requires (TImpl impl, service::FieldParams params) +{ + { impl.getPageInfo(std::move(params)) } -> std::convertible_to>>; }; +template +concept HasEdges = requires (TImpl impl, service::FieldParams params) +{ + { impl.getEdges(std::move(params)) } -> std::convertible_to>>>>; +}; + +} // namespace AppointmentConnectionStubs + class AppointmentConnection : public service::Object { @@ -352,12 +583,26 @@ class AppointmentConnection service::FieldResult> getPageInfo(service::FieldParams&& params) const final { - return _pimpl->getPageInfo(std::move(params)); + if constexpr (AppointmentConnectionStubs::HasPageInfo) + { + return _pimpl->getPageInfo(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(AppointmentConnection::getPageInfo is not implemented)ex"); + } } service::FieldResult>>> getEdges(service::FieldParams&& params) const final { - return _pimpl->getEdges(std::move(params)); + if constexpr (AppointmentConnectionStubs::HasEdges) + { + return _pimpl->getEdges(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(AppointmentConnection::getEdges is not implemented)ex"); + } } private: @@ -374,10 +619,24 @@ class AppointmentConnection : AppointmentConnection { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } +}; + +namespace TaskEdgeStubs { + +template +concept HasNode = requires (TImpl impl, service::FieldParams params) +{ + { impl.getNode(std::move(params)) } -> std::convertible_to>>; +}; - ~AppointmentConnection(); +template +concept HasCursor = requires (TImpl impl, service::FieldParams params) +{ + { impl.getCursor(std::move(params)) } -> std::convertible_to>; }; +} // namespace TaskEdgeStubs + class TaskEdge : public service::Object { @@ -406,12 +665,26 @@ class TaskEdge service::FieldResult> getNode(service::FieldParams&& params) const final { - return _pimpl->getNode(std::move(params)); + if constexpr (TaskEdgeStubs::HasNode) + { + return _pimpl->getNode(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(TaskEdge::getNode is not implemented)ex"); + } } service::FieldResult getCursor(service::FieldParams&& params) const final { - return _pimpl->getCursor(std::move(params)); + if constexpr (TaskEdgeStubs::HasCursor) + { + return _pimpl->getCursor(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(TaskEdge::getCursor is not implemented)ex"); + } } private: @@ -428,10 +701,24 @@ class TaskEdge : TaskEdge { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } +}; - ~TaskEdge(); +namespace TaskConnectionStubs { + +template +concept HasPageInfo = requires (TImpl impl, service::FieldParams params) +{ + { impl.getPageInfo(std::move(params)) } -> std::convertible_to>>; }; +template +concept HasEdges = requires (TImpl impl, service::FieldParams params) +{ + { impl.getEdges(std::move(params)) } -> std::convertible_to>>>>; +}; + +} // namespace TaskConnectionStubs + class TaskConnection : public service::Object { @@ -460,12 +747,26 @@ class TaskConnection service::FieldResult> getPageInfo(service::FieldParams&& params) const final { - return _pimpl->getPageInfo(std::move(params)); + if constexpr (TaskConnectionStubs::HasPageInfo) + { + return _pimpl->getPageInfo(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(TaskConnection::getPageInfo is not implemented)ex"); + } } service::FieldResult>>> getEdges(service::FieldParams&& params) const final { - return _pimpl->getEdges(std::move(params)); + if constexpr (TaskConnectionStubs::HasEdges) + { + return _pimpl->getEdges(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(TaskConnection::getEdges is not implemented)ex"); + } } private: @@ -482,10 +783,24 @@ class TaskConnection : TaskConnection { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } +}; + +namespace FolderEdgeStubs { + +template +concept HasNode = requires (TImpl impl, service::FieldParams params) +{ + { impl.getNode(std::move(params)) } -> std::convertible_to>>; +}; - ~TaskConnection(); +template +concept HasCursor = requires (TImpl impl, service::FieldParams params) +{ + { impl.getCursor(std::move(params)) } -> std::convertible_to>; }; +} // namespace FolderEdgeStubs + class FolderEdge : public service::Object { @@ -514,12 +829,26 @@ class FolderEdge service::FieldResult> getNode(service::FieldParams&& params) const final { - return _pimpl->getNode(std::move(params)); + if constexpr (FolderEdgeStubs::HasNode) + { + return _pimpl->getNode(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(FolderEdge::getNode is not implemented)ex"); + } } service::FieldResult getCursor(service::FieldParams&& params) const final { - return _pimpl->getCursor(std::move(params)); + if constexpr (FolderEdgeStubs::HasCursor) + { + return _pimpl->getCursor(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(FolderEdge::getCursor is not implemented)ex"); + } } private: @@ -536,10 +865,24 @@ class FolderEdge : FolderEdge { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } +}; + +namespace FolderConnectionStubs { + +template +concept HasPageInfo = requires (TImpl impl, service::FieldParams params) +{ + { impl.getPageInfo(std::move(params)) } -> std::convertible_to>>; +}; - ~FolderEdge(); +template +concept HasEdges = requires (TImpl impl, service::FieldParams params) +{ + { impl.getEdges(std::move(params)) } -> std::convertible_to>>>>; }; +} // namespace FolderConnectionStubs + class FolderConnection : public service::Object { @@ -568,12 +911,26 @@ class FolderConnection service::FieldResult> getPageInfo(service::FieldParams&& params) const final { - return _pimpl->getPageInfo(std::move(params)); + if constexpr (FolderConnectionStubs::HasPageInfo) + { + return _pimpl->getPageInfo(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(FolderConnection::getPageInfo is not implemented)ex"); + } } service::FieldResult>>> getEdges(service::FieldParams&& params) const final { - return _pimpl->getEdges(std::move(params)); + if constexpr (FolderConnectionStubs::HasEdges) + { + return _pimpl->getEdges(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(FolderConnection::getEdges is not implemented)ex"); + } } private: @@ -590,10 +947,24 @@ class FolderConnection : FolderConnection { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } +}; - ~FolderConnection(); +namespace CompleteTaskPayloadStubs { + +template +concept HasTask = requires (TImpl impl, service::FieldParams params) +{ + { impl.getTask(std::move(params)) } -> std::convertible_to>>; +}; + +template +concept HasClientMutationId = requires (TImpl impl, service::FieldParams params) +{ + { impl.getClientMutationId(std::move(params)) } -> std::convertible_to>>; }; +} // namespace CompleteTaskPayloadStubs + class CompleteTaskPayload : public service::Object { @@ -622,12 +993,26 @@ class CompleteTaskPayload service::FieldResult> getTask(service::FieldParams&& params) const final { - return _pimpl->getTask(std::move(params)); + if constexpr (CompleteTaskPayloadStubs::HasTask) + { + return _pimpl->getTask(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(CompleteTaskPayload::getTask is not implemented)ex"); + } } service::FieldResult> getClientMutationId(service::FieldParams&& params) const final { - return _pimpl->getClientMutationId(std::move(params)); + if constexpr (CompleteTaskPayloadStubs::HasClientMutationId) + { + return _pimpl->getClientMutationId(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(CompleteTaskPayload::getClientMutationId is not implemented)ex"); + } } private: @@ -644,10 +1029,24 @@ class CompleteTaskPayload : CompleteTaskPayload { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } +}; + +namespace MutationStubs { - ~CompleteTaskPayload(); +template +concept HasCompleteTask = requires (TImpl impl, service::FieldParams params, CompleteTaskInput inputArg) +{ + { impl.applyCompleteTask(std::move(params), std::move(inputArg)) } -> std::convertible_to>>; }; +template +concept HasSetFloat = requires (TImpl impl, service::FieldParams params, response::FloatType valueArg) +{ + { impl.applySetFloat(std::move(params), std::move(valueArg)) } -> std::convertible_to>; +}; + +} // namespace MutationStubs + class Mutation : public service::Object { @@ -676,12 +1075,26 @@ class Mutation service::FieldResult> applyCompleteTask(service::FieldParams&& params, CompleteTaskInput&& inputArg) const final { - return _pimpl->applyCompleteTask(std::move(params), std::move(inputArg)); + if constexpr (MutationStubs::HasCompleteTask) + { + return _pimpl->applyCompleteTask(std::move(params), std::move(inputArg)); + } + else + { + throw std::runtime_error(R"ex(Mutation::applyCompleteTask is not implemented)ex"); + } } service::FieldResult applySetFloat(service::FieldParams&& params, response::FloatType&& valueArg) const final { - return _pimpl->applySetFloat(std::move(params), std::move(valueArg)); + if constexpr (MutationStubs::HasSetFloat) + { + return _pimpl->applySetFloat(std::move(params), std::move(valueArg)); + } + else + { + throw std::runtime_error(R"ex(Mutation::applySetFloat is not implemented)ex"); + } } private: @@ -698,10 +1111,24 @@ class Mutation : Mutation { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } +}; + +namespace SubscriptionStubs { - ~Mutation(); +template +concept HasNextAppointmentChange = requires (TImpl impl, service::FieldParams params) +{ + { impl.getNextAppointmentChange(std::move(params)) } -> std::convertible_to>>; }; +template +concept HasNodeChange = requires (TImpl impl, service::FieldParams params, response::IdType idArg) +{ + { impl.getNodeChange(std::move(params), std::move(idArg)) } -> std::convertible_to>>; +}; + +} // namespace SubscriptionStubs + class Subscription : public service::Object { @@ -730,12 +1157,26 @@ class Subscription service::FieldResult> getNextAppointmentChange(service::FieldParams&& params) const final { - return _pimpl->getNextAppointmentChange(std::move(params)); + if constexpr (SubscriptionStubs::HasNextAppointmentChange) + { + return _pimpl->getNextAppointmentChange(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(Subscription::getNextAppointmentChange is not implemented)ex"); + } } service::FieldResult> getNodeChange(service::FieldParams&& params, response::IdType&& idArg) const final { - return _pimpl->getNodeChange(std::move(params), std::move(idArg)); + if constexpr (SubscriptionStubs::HasNodeChange) + { + return _pimpl->getNodeChange(std::move(params), std::move(idArg)); + } + else + { + throw std::runtime_error(R"ex(Subscription::getNodeChange is not implemented)ex"); + } } private: @@ -752,10 +1193,42 @@ class Subscription : Subscription { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } +}; + +namespace AppointmentStubs { + +template +concept HasId = requires (TImpl impl, service::FieldParams params) +{ + { impl.getId(std::move(params)) } -> std::convertible_to>; +}; + +template +concept HasWhen = requires (TImpl impl, service::FieldParams params) +{ + { impl.getWhen(std::move(params)) } -> std::convertible_to>>; +}; + +template +concept HasSubject = requires (TImpl impl, service::FieldParams params) +{ + { impl.getSubject(std::move(params)) } -> std::convertible_to>>; +}; + +template +concept HasIsNow = requires (TImpl impl, service::FieldParams params) +{ + { impl.getIsNow(std::move(params)) } -> std::convertible_to>; +}; - ~Subscription(); +template +concept HasForceError = requires (TImpl impl, service::FieldParams params) +{ + { impl.getForceError(std::move(params)) } -> std::convertible_to>>; }; +} // namespace AppointmentStubs + class Appointment : public service::Object { @@ -790,27 +1263,62 @@ class Appointment service::FieldResult getId(service::FieldParams&& params) const final { - return _pimpl->getId(std::move(params)); + if constexpr (AppointmentStubs::HasId) + { + return _pimpl->getId(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(Appointment::getId is not implemented)ex"); + } } service::FieldResult> getWhen(service::FieldParams&& params) const final { - return _pimpl->getWhen(std::move(params)); + if constexpr (AppointmentStubs::HasWhen) + { + return _pimpl->getWhen(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(Appointment::getWhen is not implemented)ex"); + } } service::FieldResult> getSubject(service::FieldParams&& params) const final { - return _pimpl->getSubject(std::move(params)); + if constexpr (AppointmentStubs::HasSubject) + { + return _pimpl->getSubject(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(Appointment::getSubject is not implemented)ex"); + } } service::FieldResult getIsNow(service::FieldParams&& params) const final { - return _pimpl->getIsNow(std::move(params)); + if constexpr (AppointmentStubs::HasIsNow) + { + return _pimpl->getIsNow(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(Appointment::getIsNow is not implemented)ex"); + } } service::FieldResult> getForceError(service::FieldParams&& params) const final { - return _pimpl->getForceError(std::move(params)); + if constexpr (AppointmentStubs::HasForceError) + { + return _pimpl->getForceError(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(Appointment::getForceError is not implemented)ex"); + } } private: @@ -827,10 +1335,30 @@ class Appointment : Appointment { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } +}; + +namespace TaskStubs { + +template +concept HasId = requires (TImpl impl, service::FieldParams params) +{ + { impl.getId(std::move(params)) } -> std::convertible_to>; +}; + +template +concept HasTitle = requires (TImpl impl, service::FieldParams params) +{ + { impl.getTitle(std::move(params)) } -> std::convertible_to>>; +}; - ~Appointment(); +template +concept HasIsComplete = requires (TImpl impl, service::FieldParams params) +{ + { impl.getIsComplete(std::move(params)) } -> std::convertible_to>; }; +} // namespace TaskStubs + class Task : public service::Object { @@ -861,17 +1389,38 @@ class Task service::FieldResult getId(service::FieldParams&& params) const final { - return _pimpl->getId(std::move(params)); + if constexpr (TaskStubs::HasId) + { + return _pimpl->getId(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(Task::getId is not implemented)ex"); + } } service::FieldResult> getTitle(service::FieldParams&& params) const final { - return _pimpl->getTitle(std::move(params)); + if constexpr (TaskStubs::HasTitle) + { + return _pimpl->getTitle(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(Task::getTitle is not implemented)ex"); + } } service::FieldResult getIsComplete(service::FieldParams&& params) const final { - return _pimpl->getIsComplete(std::move(params)); + if constexpr (TaskStubs::HasIsComplete) + { + return _pimpl->getIsComplete(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(Task::getIsComplete is not implemented)ex"); + } } private: @@ -888,10 +1437,30 @@ class Task : Task { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } +}; - ~Task(); +namespace FolderStubs { + +template +concept HasId = requires (TImpl impl, service::FieldParams params) +{ + { impl.getId(std::move(params)) } -> std::convertible_to>; }; +template +concept HasName = requires (TImpl impl, service::FieldParams params) +{ + { impl.getName(std::move(params)) } -> std::convertible_to>>; +}; + +template +concept HasUnreadCount = requires (TImpl impl, service::FieldParams params) +{ + { impl.getUnreadCount(std::move(params)) } -> std::convertible_to>; +}; + +} // namespace FolderStubs + class Folder : public service::Object { @@ -922,17 +1491,38 @@ class Folder service::FieldResult getId(service::FieldParams&& params) const final { - return _pimpl->getId(std::move(params)); + if constexpr (FolderStubs::HasId) + { + return _pimpl->getId(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(Folder::getId is not implemented)ex"); + } } service::FieldResult> getName(service::FieldParams&& params) const final { - return _pimpl->getName(std::move(params)); + if constexpr (FolderStubs::HasName) + { + return _pimpl->getName(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(Folder::getName is not implemented)ex"); + } } service::FieldResult getUnreadCount(service::FieldParams&& params) const final { - return _pimpl->getUnreadCount(std::move(params)); + if constexpr (FolderStubs::HasUnreadCount) + { + return _pimpl->getUnreadCount(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(Folder::getUnreadCount is not implemented)ex"); + } } private: @@ -949,10 +1539,24 @@ class Folder : Folder { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } +}; - ~Folder(); +namespace NestedTypeStubs { + +template +concept HasDepth = requires (TImpl impl, service::FieldParams params) +{ + { impl.getDepth(std::move(params)) } -> std::convertible_to>; }; +template +concept HasNested = requires (TImpl impl, service::FieldParams params) +{ + { impl.getNested(std::move(params)) } -> std::convertible_to>>; +}; + +} // namespace NestedTypeStubs + class NestedType : public service::Object { @@ -981,12 +1585,26 @@ class NestedType service::FieldResult getDepth(service::FieldParams&& params) const final { - return _pimpl->getDepth(std::move(params)); + if constexpr (NestedTypeStubs::HasDepth) + { + return _pimpl->getDepth(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(NestedType::getDepth is not implemented)ex"); + } } service::FieldResult> getNested(service::FieldParams&& params) const final { - return _pimpl->getNested(std::move(params)); + if constexpr (NestedTypeStubs::HasNested) + { + return _pimpl->getNested(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(NestedType::getNested is not implemented)ex"); + } } private: @@ -1003,10 +1621,18 @@ class NestedType : NestedType { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } +}; - ~NestedType(); +namespace ExpensiveStubs { + +template +concept HasOrder = requires (TImpl impl, service::FieldParams params) +{ + { impl.getOrder(std::move(params)) } -> std::convertible_to>; }; +} // namespace ExpensiveStubs + class Expensive : public service::Object { @@ -1033,7 +1659,14 @@ class Expensive service::FieldResult getOrder(service::FieldParams&& params) const final { - return _pimpl->getOrder(std::move(params)); + if constexpr (ExpensiveStubs::HasOrder) + { + return _pimpl->getOrder(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(Expensive::getOrder is not implemented)ex"); + } } private: @@ -1050,8 +1683,6 @@ class Expensive : Expensive { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } - - ~Expensive(); }; } // namespace object diff --git a/samples/unified_nointrospection/TodaySchema.cpp b/samples/unified_nointrospection/TodaySchema.cpp index 6a704f8b..b1a9cdaa 100644 --- a/samples/unified_nointrospection/TodaySchema.cpp +++ b/samples/unified_nointrospection/TodaySchema.cpp @@ -163,10 +163,6 @@ Query::Query(std::unique_ptr&& pimpl) { } -Query::~Query() -{ -} - service::AwaitableResolver Query::resolveNode(service::ResolverParams&& params) { auto argId = service::ModifiedArgument::require("id", params.arguments); @@ -343,10 +339,6 @@ PageInfo::PageInfo(std::unique_ptr&& pimpl) { } -PageInfo::~PageInfo() -{ -} - service::AwaitableResolver PageInfo::resolveHasNextPage(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); @@ -384,10 +376,6 @@ AppointmentEdge::AppointmentEdge(std::unique_ptr&& pimpl) { } -AppointmentEdge::~AppointmentEdge() -{ -} - service::AwaitableResolver AppointmentEdge::resolveNode(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); @@ -425,10 +413,6 @@ AppointmentConnection::AppointmentConnection(std::unique_ptr&& pimpl) { } -AppointmentConnection::~AppointmentConnection() -{ -} - service::AwaitableResolver AppointmentConnection::resolvePageInfo(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); @@ -466,10 +450,6 @@ TaskEdge::TaskEdge(std::unique_ptr&& pimpl) { } -TaskEdge::~TaskEdge() -{ -} - service::AwaitableResolver TaskEdge::resolveNode(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); @@ -507,10 +487,6 @@ TaskConnection::TaskConnection(std::unique_ptr&& pimpl) { } -TaskConnection::~TaskConnection() -{ -} - service::AwaitableResolver TaskConnection::resolvePageInfo(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); @@ -548,10 +524,6 @@ FolderEdge::FolderEdge(std::unique_ptr&& pimpl) { } -FolderEdge::~FolderEdge() -{ -} - service::AwaitableResolver FolderEdge::resolveNode(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); @@ -589,10 +561,6 @@ FolderConnection::FolderConnection(std::unique_ptr&& pimpl) { } -FolderConnection::~FolderConnection() -{ -} - service::AwaitableResolver FolderConnection::resolvePageInfo(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); @@ -630,10 +598,6 @@ CompleteTaskPayload::CompleteTaskPayload(std::unique_ptr&& pimpl) { } -CompleteTaskPayload::~CompleteTaskPayload() -{ -} - service::AwaitableResolver CompleteTaskPayload::resolveTask(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); @@ -671,10 +635,6 @@ Mutation::Mutation(std::unique_ptr&& pimpl) { } -Mutation::~Mutation() -{ -} - service::AwaitableResolver Mutation::resolveCompleteTask(service::ResolverParams&& params) { auto argInput = service::ModifiedArgument::require("input", params.arguments); @@ -714,10 +674,6 @@ Subscription::Subscription(std::unique_ptr&& pimpl) { } -Subscription::~Subscription() -{ -} - service::AwaitableResolver Subscription::resolveNextAppointmentChange(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); @@ -761,10 +717,6 @@ Appointment::Appointment(std::unique_ptr&& pimpl) { } -Appointment::~Appointment() -{ -} - service::AwaitableResolver Appointment::resolveId(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); @@ -835,10 +787,6 @@ Task::Task(std::unique_ptr&& pimpl) { } -Task::~Task() -{ -} - service::AwaitableResolver Task::resolveId(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); @@ -889,10 +837,6 @@ Folder::Folder(std::unique_ptr&& pimpl) { } -Folder::~Folder() -{ -} - service::AwaitableResolver Folder::resolveId(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); @@ -940,10 +884,6 @@ NestedType::NestedType(std::unique_ptr&& pimpl) { } -NestedType::~NestedType() -{ -} - service::AwaitableResolver NestedType::resolveDepth(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); @@ -980,10 +920,6 @@ Expensive::Expensive(std::unique_ptr&& pimpl) { } -Expensive::~Expensive() -{ -} - service::AwaitableResolver Expensive::resolveOrder(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); diff --git a/samples/unified_nointrospection/TodaySchema.h b/samples/unified_nointrospection/TodaySchema.h index 86a0d22d..13dacce3 100644 --- a/samples/unified_nointrospection/TodaySchema.h +++ b/samples/unified_nointrospection/TodaySchema.h @@ -14,6 +14,7 @@ static_assert(graphql::internal::MajorVersion == 4, "regenerate with schemagen: major version mismatch"); static_assert(graphql::internal::MinorVersion == 0, "regenerate with schemagen: minor version mismatch"); +#include #include #include #include @@ -88,6 +89,82 @@ struct Node namespace object { +namespace QueryStubs { + +template +concept HasNode = requires (TImpl impl, service::FieldParams params, response::IdType idArg) +{ + { impl.getNode(std::move(params), std::move(idArg)) } -> std::convertible_to>>; +}; + +template +concept HasAppointments = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) +{ + { impl.getAppointments(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } -> std::convertible_to>>; +}; + +template +concept HasTasks = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) +{ + { impl.getTasks(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } -> std::convertible_to>>; +}; + +template +concept HasUnreadCounts = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) +{ + { impl.getUnreadCounts(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } -> std::convertible_to>>; +}; + +template +concept HasAppointmentsById = requires (TImpl impl, service::FieldParams params, std::vector idsArg) +{ + { impl.getAppointmentsById(std::move(params), std::move(idsArg)) } -> std::convertible_to>>>; +}; + +template +concept HasTasksById = requires (TImpl impl, service::FieldParams params, std::vector idsArg) +{ + { impl.getTasksById(std::move(params), std::move(idsArg)) } -> std::convertible_to>>>; +}; + +template +concept HasUnreadCountsById = requires (TImpl impl, service::FieldParams params, std::vector idsArg) +{ + { impl.getUnreadCountsById(std::move(params), std::move(idsArg)) } -> std::convertible_to>>>; +}; + +template +concept HasNested = requires (TImpl impl, service::FieldParams params) +{ + { impl.getNested(std::move(params)) } -> std::convertible_to>>; +}; + +template +concept HasUnimplemented = requires (TImpl impl, service::FieldParams params) +{ + { impl.getUnimplemented(std::move(params)) } -> std::convertible_to>; +}; + +template +concept HasExpensive = requires (TImpl impl, service::FieldParams params) +{ + { impl.getExpensive(std::move(params)) } -> std::convertible_to>>>; +}; + +template +concept HasTestTaskState = requires (TImpl impl, service::FieldParams params) +{ + { impl.getTestTaskState(std::move(params)) } -> std::convertible_to>; +}; + +template +concept HasAnyType = requires (TImpl impl, service::FieldParams params, std::vector idsArg) +{ + { impl.getAnyType(std::move(params), std::move(idsArg)) } -> std::convertible_to>>>; +}; + +} // namespace QueryStubs + class Query : public service::Object { @@ -136,62 +213,146 @@ class Query service::FieldResult> getNode(service::FieldParams&& params, response::IdType&& idArg) const final { - return _pimpl->getNode(std::move(params), std::move(idArg)); + if constexpr (QueryStubs::HasNode) + { + return _pimpl->getNode(std::move(params), std::move(idArg)); + } + else + { + throw std::runtime_error(R"ex(Query::getNode is not implemented)ex"); + } } service::FieldResult> getAppointments(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const final { - return _pimpl->getAppointments(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)); + if constexpr (QueryStubs::HasAppointments) + { + return _pimpl->getAppointments(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)); + } + else + { + throw std::runtime_error(R"ex(Query::getAppointments is not implemented)ex"); + } } service::FieldResult> getTasks(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const final { - return _pimpl->getTasks(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)); + if constexpr (QueryStubs::HasTasks) + { + return _pimpl->getTasks(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)); + } + else + { + throw std::runtime_error(R"ex(Query::getTasks is not implemented)ex"); + } } service::FieldResult> getUnreadCounts(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const final { - return _pimpl->getUnreadCounts(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)); + if constexpr (QueryStubs::HasUnreadCounts) + { + return _pimpl->getUnreadCounts(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)); + } + else + { + throw std::runtime_error(R"ex(Query::getUnreadCounts is not implemented)ex"); + } } service::FieldResult>> getAppointmentsById(service::FieldParams&& params, std::vector&& idsArg) const final { - return _pimpl->getAppointmentsById(std::move(params), std::move(idsArg)); + if constexpr (QueryStubs::HasAppointmentsById) + { + return _pimpl->getAppointmentsById(std::move(params), std::move(idsArg)); + } + else + { + throw std::runtime_error(R"ex(Query::getAppointmentsById is not implemented)ex"); + } } service::FieldResult>> getTasksById(service::FieldParams&& params, std::vector&& idsArg) const final { - return _pimpl->getTasksById(std::move(params), std::move(idsArg)); + if constexpr (QueryStubs::HasTasksById) + { + return _pimpl->getTasksById(std::move(params), std::move(idsArg)); + } + else + { + throw std::runtime_error(R"ex(Query::getTasksById is not implemented)ex"); + } } service::FieldResult>> getUnreadCountsById(service::FieldParams&& params, std::vector&& idsArg) const final { - return _pimpl->getUnreadCountsById(std::move(params), std::move(idsArg)); + if constexpr (QueryStubs::HasUnreadCountsById) + { + return _pimpl->getUnreadCountsById(std::move(params), std::move(idsArg)); + } + else + { + throw std::runtime_error(R"ex(Query::getUnreadCountsById is not implemented)ex"); + } } service::FieldResult> getNested(service::FieldParams&& params) const final { - return _pimpl->getNested(std::move(params)); + if constexpr (QueryStubs::HasNested) + { + return _pimpl->getNested(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(Query::getNested is not implemented)ex"); + } } service::FieldResult getUnimplemented(service::FieldParams&& params) const final { - return _pimpl->getUnimplemented(std::move(params)); + if constexpr (QueryStubs::HasUnimplemented) + { + return _pimpl->getUnimplemented(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(Query::getUnimplemented is not implemented)ex"); + } } service::FieldResult>> getExpensive(service::FieldParams&& params) const final { - return _pimpl->getExpensive(std::move(params)); + if constexpr (QueryStubs::HasExpensive) + { + return _pimpl->getExpensive(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(Query::getExpensive is not implemented)ex"); + } } service::FieldResult getTestTaskState(service::FieldParams&& params) const final { - return _pimpl->getTestTaskState(std::move(params)); + if constexpr (QueryStubs::HasTestTaskState) + { + return _pimpl->getTestTaskState(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(Query::getTestTaskState is not implemented)ex"); + } } service::FieldResult>> getAnyType(service::FieldParams&& params, std::vector&& idsArg) const final { - return _pimpl->getAnyType(std::move(params), std::move(idsArg)); + if constexpr (QueryStubs::HasAnyType) + { + return _pimpl->getAnyType(std::move(params), std::move(idsArg)); + } + else + { + throw std::runtime_error(R"ex(Query::getAnyType is not implemented)ex"); + } } private: @@ -208,10 +369,24 @@ class Query : Query { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } +}; - ~Query(); +namespace PageInfoStubs { + +template +concept HasHasNextPage = requires (TImpl impl, service::FieldParams params) +{ + { impl.getHasNextPage(std::move(params)) } -> std::convertible_to>; +}; + +template +concept HasHasPreviousPage = requires (TImpl impl, service::FieldParams params) +{ + { impl.getHasPreviousPage(std::move(params)) } -> std::convertible_to>; }; +} // namespace PageInfoStubs + class PageInfo : public service::Object { @@ -240,12 +415,26 @@ class PageInfo service::FieldResult getHasNextPage(service::FieldParams&& params) const final { - return _pimpl->getHasNextPage(std::move(params)); + if constexpr (PageInfoStubs::HasHasNextPage) + { + return _pimpl->getHasNextPage(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(PageInfo::getHasNextPage is not implemented)ex"); + } } service::FieldResult getHasPreviousPage(service::FieldParams&& params) const final { - return _pimpl->getHasPreviousPage(std::move(params)); + if constexpr (PageInfoStubs::HasHasPreviousPage) + { + return _pimpl->getHasPreviousPage(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(PageInfo::getHasPreviousPage is not implemented)ex"); + } } private: @@ -262,10 +451,24 @@ class PageInfo : PageInfo { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } +}; + +namespace AppointmentEdgeStubs { + +template +concept HasNode = requires (TImpl impl, service::FieldParams params) +{ + { impl.getNode(std::move(params)) } -> std::convertible_to>>; +}; - ~PageInfo(); +template +concept HasCursor = requires (TImpl impl, service::FieldParams params) +{ + { impl.getCursor(std::move(params)) } -> std::convertible_to>; }; +} // namespace AppointmentEdgeStubs + class AppointmentEdge : public service::Object { @@ -294,12 +497,26 @@ class AppointmentEdge service::FieldResult> getNode(service::FieldParams&& params) const final { - return _pimpl->getNode(std::move(params)); + if constexpr (AppointmentEdgeStubs::HasNode) + { + return _pimpl->getNode(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(AppointmentEdge::getNode is not implemented)ex"); + } } service::FieldResult getCursor(service::FieldParams&& params) const final { - return _pimpl->getCursor(std::move(params)); + if constexpr (AppointmentEdgeStubs::HasCursor) + { + return _pimpl->getCursor(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(AppointmentEdge::getCursor is not implemented)ex"); + } } private: @@ -316,10 +533,24 @@ class AppointmentEdge : AppointmentEdge { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } +}; + +namespace AppointmentConnectionStubs { - ~AppointmentEdge(); +template +concept HasPageInfo = requires (TImpl impl, service::FieldParams params) +{ + { impl.getPageInfo(std::move(params)) } -> std::convertible_to>>; }; +template +concept HasEdges = requires (TImpl impl, service::FieldParams params) +{ + { impl.getEdges(std::move(params)) } -> std::convertible_to>>>>; +}; + +} // namespace AppointmentConnectionStubs + class AppointmentConnection : public service::Object { @@ -348,12 +579,26 @@ class AppointmentConnection service::FieldResult> getPageInfo(service::FieldParams&& params) const final { - return _pimpl->getPageInfo(std::move(params)); + if constexpr (AppointmentConnectionStubs::HasPageInfo) + { + return _pimpl->getPageInfo(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(AppointmentConnection::getPageInfo is not implemented)ex"); + } } service::FieldResult>>> getEdges(service::FieldParams&& params) const final { - return _pimpl->getEdges(std::move(params)); + if constexpr (AppointmentConnectionStubs::HasEdges) + { + return _pimpl->getEdges(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(AppointmentConnection::getEdges is not implemented)ex"); + } } private: @@ -370,10 +615,24 @@ class AppointmentConnection : AppointmentConnection { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } +}; + +namespace TaskEdgeStubs { + +template +concept HasNode = requires (TImpl impl, service::FieldParams params) +{ + { impl.getNode(std::move(params)) } -> std::convertible_to>>; +}; - ~AppointmentConnection(); +template +concept HasCursor = requires (TImpl impl, service::FieldParams params) +{ + { impl.getCursor(std::move(params)) } -> std::convertible_to>; }; +} // namespace TaskEdgeStubs + class TaskEdge : public service::Object { @@ -402,12 +661,26 @@ class TaskEdge service::FieldResult> getNode(service::FieldParams&& params) const final { - return _pimpl->getNode(std::move(params)); + if constexpr (TaskEdgeStubs::HasNode) + { + return _pimpl->getNode(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(TaskEdge::getNode is not implemented)ex"); + } } service::FieldResult getCursor(service::FieldParams&& params) const final { - return _pimpl->getCursor(std::move(params)); + if constexpr (TaskEdgeStubs::HasCursor) + { + return _pimpl->getCursor(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(TaskEdge::getCursor is not implemented)ex"); + } } private: @@ -424,10 +697,24 @@ class TaskEdge : TaskEdge { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } +}; - ~TaskEdge(); +namespace TaskConnectionStubs { + +template +concept HasPageInfo = requires (TImpl impl, service::FieldParams params) +{ + { impl.getPageInfo(std::move(params)) } -> std::convertible_to>>; }; +template +concept HasEdges = requires (TImpl impl, service::FieldParams params) +{ + { impl.getEdges(std::move(params)) } -> std::convertible_to>>>>; +}; + +} // namespace TaskConnectionStubs + class TaskConnection : public service::Object { @@ -456,12 +743,26 @@ class TaskConnection service::FieldResult> getPageInfo(service::FieldParams&& params) const final { - return _pimpl->getPageInfo(std::move(params)); + if constexpr (TaskConnectionStubs::HasPageInfo) + { + return _pimpl->getPageInfo(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(TaskConnection::getPageInfo is not implemented)ex"); + } } service::FieldResult>>> getEdges(service::FieldParams&& params) const final { - return _pimpl->getEdges(std::move(params)); + if constexpr (TaskConnectionStubs::HasEdges) + { + return _pimpl->getEdges(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(TaskConnection::getEdges is not implemented)ex"); + } } private: @@ -478,10 +779,24 @@ class TaskConnection : TaskConnection { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } +}; + +namespace FolderEdgeStubs { + +template +concept HasNode = requires (TImpl impl, service::FieldParams params) +{ + { impl.getNode(std::move(params)) } -> std::convertible_to>>; +}; - ~TaskConnection(); +template +concept HasCursor = requires (TImpl impl, service::FieldParams params) +{ + { impl.getCursor(std::move(params)) } -> std::convertible_to>; }; +} // namespace FolderEdgeStubs + class FolderEdge : public service::Object { @@ -510,12 +825,26 @@ class FolderEdge service::FieldResult> getNode(service::FieldParams&& params) const final { - return _pimpl->getNode(std::move(params)); + if constexpr (FolderEdgeStubs::HasNode) + { + return _pimpl->getNode(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(FolderEdge::getNode is not implemented)ex"); + } } service::FieldResult getCursor(service::FieldParams&& params) const final { - return _pimpl->getCursor(std::move(params)); + if constexpr (FolderEdgeStubs::HasCursor) + { + return _pimpl->getCursor(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(FolderEdge::getCursor is not implemented)ex"); + } } private: @@ -532,10 +861,24 @@ class FolderEdge : FolderEdge { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } +}; + +namespace FolderConnectionStubs { + +template +concept HasPageInfo = requires (TImpl impl, service::FieldParams params) +{ + { impl.getPageInfo(std::move(params)) } -> std::convertible_to>>; +}; - ~FolderEdge(); +template +concept HasEdges = requires (TImpl impl, service::FieldParams params) +{ + { impl.getEdges(std::move(params)) } -> std::convertible_to>>>>; }; +} // namespace FolderConnectionStubs + class FolderConnection : public service::Object { @@ -564,12 +907,26 @@ class FolderConnection service::FieldResult> getPageInfo(service::FieldParams&& params) const final { - return _pimpl->getPageInfo(std::move(params)); + if constexpr (FolderConnectionStubs::HasPageInfo) + { + return _pimpl->getPageInfo(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(FolderConnection::getPageInfo is not implemented)ex"); + } } service::FieldResult>>> getEdges(service::FieldParams&& params) const final { - return _pimpl->getEdges(std::move(params)); + if constexpr (FolderConnectionStubs::HasEdges) + { + return _pimpl->getEdges(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(FolderConnection::getEdges is not implemented)ex"); + } } private: @@ -586,10 +943,24 @@ class FolderConnection : FolderConnection { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } +}; - ~FolderConnection(); +namespace CompleteTaskPayloadStubs { + +template +concept HasTask = requires (TImpl impl, service::FieldParams params) +{ + { impl.getTask(std::move(params)) } -> std::convertible_to>>; +}; + +template +concept HasClientMutationId = requires (TImpl impl, service::FieldParams params) +{ + { impl.getClientMutationId(std::move(params)) } -> std::convertible_to>>; }; +} // namespace CompleteTaskPayloadStubs + class CompleteTaskPayload : public service::Object { @@ -618,12 +989,26 @@ class CompleteTaskPayload service::FieldResult> getTask(service::FieldParams&& params) const final { - return _pimpl->getTask(std::move(params)); + if constexpr (CompleteTaskPayloadStubs::HasTask) + { + return _pimpl->getTask(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(CompleteTaskPayload::getTask is not implemented)ex"); + } } service::FieldResult> getClientMutationId(service::FieldParams&& params) const final { - return _pimpl->getClientMutationId(std::move(params)); + if constexpr (CompleteTaskPayloadStubs::HasClientMutationId) + { + return _pimpl->getClientMutationId(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(CompleteTaskPayload::getClientMutationId is not implemented)ex"); + } } private: @@ -640,10 +1025,24 @@ class CompleteTaskPayload : CompleteTaskPayload { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } +}; + +namespace MutationStubs { - ~CompleteTaskPayload(); +template +concept HasCompleteTask = requires (TImpl impl, service::FieldParams params, CompleteTaskInput inputArg) +{ + { impl.applyCompleteTask(std::move(params), std::move(inputArg)) } -> std::convertible_to>>; }; +template +concept HasSetFloat = requires (TImpl impl, service::FieldParams params, response::FloatType valueArg) +{ + { impl.applySetFloat(std::move(params), std::move(valueArg)) } -> std::convertible_to>; +}; + +} // namespace MutationStubs + class Mutation : public service::Object { @@ -672,12 +1071,26 @@ class Mutation service::FieldResult> applyCompleteTask(service::FieldParams&& params, CompleteTaskInput&& inputArg) const final { - return _pimpl->applyCompleteTask(std::move(params), std::move(inputArg)); + if constexpr (MutationStubs::HasCompleteTask) + { + return _pimpl->applyCompleteTask(std::move(params), std::move(inputArg)); + } + else + { + throw std::runtime_error(R"ex(Mutation::applyCompleteTask is not implemented)ex"); + } } service::FieldResult applySetFloat(service::FieldParams&& params, response::FloatType&& valueArg) const final { - return _pimpl->applySetFloat(std::move(params), std::move(valueArg)); + if constexpr (MutationStubs::HasSetFloat) + { + return _pimpl->applySetFloat(std::move(params), std::move(valueArg)); + } + else + { + throw std::runtime_error(R"ex(Mutation::applySetFloat is not implemented)ex"); + } } private: @@ -694,10 +1107,24 @@ class Mutation : Mutation { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } +}; + +namespace SubscriptionStubs { - ~Mutation(); +template +concept HasNextAppointmentChange = requires (TImpl impl, service::FieldParams params) +{ + { impl.getNextAppointmentChange(std::move(params)) } -> std::convertible_to>>; }; +template +concept HasNodeChange = requires (TImpl impl, service::FieldParams params, response::IdType idArg) +{ + { impl.getNodeChange(std::move(params), std::move(idArg)) } -> std::convertible_to>>; +}; + +} // namespace SubscriptionStubs + class Subscription : public service::Object { @@ -726,12 +1153,26 @@ class Subscription service::FieldResult> getNextAppointmentChange(service::FieldParams&& params) const final { - return _pimpl->getNextAppointmentChange(std::move(params)); + if constexpr (SubscriptionStubs::HasNextAppointmentChange) + { + return _pimpl->getNextAppointmentChange(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(Subscription::getNextAppointmentChange is not implemented)ex"); + } } service::FieldResult> getNodeChange(service::FieldParams&& params, response::IdType&& idArg) const final { - return _pimpl->getNodeChange(std::move(params), std::move(idArg)); + if constexpr (SubscriptionStubs::HasNodeChange) + { + return _pimpl->getNodeChange(std::move(params), std::move(idArg)); + } + else + { + throw std::runtime_error(R"ex(Subscription::getNodeChange is not implemented)ex"); + } } private: @@ -748,10 +1189,42 @@ class Subscription : Subscription { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } +}; + +namespace AppointmentStubs { + +template +concept HasId = requires (TImpl impl, service::FieldParams params) +{ + { impl.getId(std::move(params)) } -> std::convertible_to>; +}; + +template +concept HasWhen = requires (TImpl impl, service::FieldParams params) +{ + { impl.getWhen(std::move(params)) } -> std::convertible_to>>; +}; + +template +concept HasSubject = requires (TImpl impl, service::FieldParams params) +{ + { impl.getSubject(std::move(params)) } -> std::convertible_to>>; +}; + +template +concept HasIsNow = requires (TImpl impl, service::FieldParams params) +{ + { impl.getIsNow(std::move(params)) } -> std::convertible_to>; +}; - ~Subscription(); +template +concept HasForceError = requires (TImpl impl, service::FieldParams params) +{ + { impl.getForceError(std::move(params)) } -> std::convertible_to>>; }; +} // namespace AppointmentStubs + class Appointment : public service::Object { @@ -786,27 +1259,62 @@ class Appointment service::FieldResult getId(service::FieldParams&& params) const final { - return _pimpl->getId(std::move(params)); + if constexpr (AppointmentStubs::HasId) + { + return _pimpl->getId(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(Appointment::getId is not implemented)ex"); + } } service::FieldResult> getWhen(service::FieldParams&& params) const final { - return _pimpl->getWhen(std::move(params)); + if constexpr (AppointmentStubs::HasWhen) + { + return _pimpl->getWhen(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(Appointment::getWhen is not implemented)ex"); + } } service::FieldResult> getSubject(service::FieldParams&& params) const final { - return _pimpl->getSubject(std::move(params)); + if constexpr (AppointmentStubs::HasSubject) + { + return _pimpl->getSubject(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(Appointment::getSubject is not implemented)ex"); + } } service::FieldResult getIsNow(service::FieldParams&& params) const final { - return _pimpl->getIsNow(std::move(params)); + if constexpr (AppointmentStubs::HasIsNow) + { + return _pimpl->getIsNow(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(Appointment::getIsNow is not implemented)ex"); + } } service::FieldResult> getForceError(service::FieldParams&& params) const final { - return _pimpl->getForceError(std::move(params)); + if constexpr (AppointmentStubs::HasForceError) + { + return _pimpl->getForceError(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(Appointment::getForceError is not implemented)ex"); + } } private: @@ -823,10 +1331,30 @@ class Appointment : Appointment { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } +}; + +namespace TaskStubs { + +template +concept HasId = requires (TImpl impl, service::FieldParams params) +{ + { impl.getId(std::move(params)) } -> std::convertible_to>; +}; + +template +concept HasTitle = requires (TImpl impl, service::FieldParams params) +{ + { impl.getTitle(std::move(params)) } -> std::convertible_to>>; +}; - ~Appointment(); +template +concept HasIsComplete = requires (TImpl impl, service::FieldParams params) +{ + { impl.getIsComplete(std::move(params)) } -> std::convertible_to>; }; +} // namespace TaskStubs + class Task : public service::Object { @@ -857,17 +1385,38 @@ class Task service::FieldResult getId(service::FieldParams&& params) const final { - return _pimpl->getId(std::move(params)); + if constexpr (TaskStubs::HasId) + { + return _pimpl->getId(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(Task::getId is not implemented)ex"); + } } service::FieldResult> getTitle(service::FieldParams&& params) const final { - return _pimpl->getTitle(std::move(params)); + if constexpr (TaskStubs::HasTitle) + { + return _pimpl->getTitle(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(Task::getTitle is not implemented)ex"); + } } service::FieldResult getIsComplete(service::FieldParams&& params) const final { - return _pimpl->getIsComplete(std::move(params)); + if constexpr (TaskStubs::HasIsComplete) + { + return _pimpl->getIsComplete(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(Task::getIsComplete is not implemented)ex"); + } } private: @@ -884,10 +1433,30 @@ class Task : Task { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } +}; - ~Task(); +namespace FolderStubs { + +template +concept HasId = requires (TImpl impl, service::FieldParams params) +{ + { impl.getId(std::move(params)) } -> std::convertible_to>; }; +template +concept HasName = requires (TImpl impl, service::FieldParams params) +{ + { impl.getName(std::move(params)) } -> std::convertible_to>>; +}; + +template +concept HasUnreadCount = requires (TImpl impl, service::FieldParams params) +{ + { impl.getUnreadCount(std::move(params)) } -> std::convertible_to>; +}; + +} // namespace FolderStubs + class Folder : public service::Object { @@ -918,17 +1487,38 @@ class Folder service::FieldResult getId(service::FieldParams&& params) const final { - return _pimpl->getId(std::move(params)); + if constexpr (FolderStubs::HasId) + { + return _pimpl->getId(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(Folder::getId is not implemented)ex"); + } } service::FieldResult> getName(service::FieldParams&& params) const final { - return _pimpl->getName(std::move(params)); + if constexpr (FolderStubs::HasName) + { + return _pimpl->getName(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(Folder::getName is not implemented)ex"); + } } service::FieldResult getUnreadCount(service::FieldParams&& params) const final { - return _pimpl->getUnreadCount(std::move(params)); + if constexpr (FolderStubs::HasUnreadCount) + { + return _pimpl->getUnreadCount(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(Folder::getUnreadCount is not implemented)ex"); + } } private: @@ -945,10 +1535,24 @@ class Folder : Folder { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } +}; - ~Folder(); +namespace NestedTypeStubs { + +template +concept HasDepth = requires (TImpl impl, service::FieldParams params) +{ + { impl.getDepth(std::move(params)) } -> std::convertible_to>; }; +template +concept HasNested = requires (TImpl impl, service::FieldParams params) +{ + { impl.getNested(std::move(params)) } -> std::convertible_to>>; +}; + +} // namespace NestedTypeStubs + class NestedType : public service::Object { @@ -977,12 +1581,26 @@ class NestedType service::FieldResult getDepth(service::FieldParams&& params) const final { - return _pimpl->getDepth(std::move(params)); + if constexpr (NestedTypeStubs::HasDepth) + { + return _pimpl->getDepth(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(NestedType::getDepth is not implemented)ex"); + } } service::FieldResult> getNested(service::FieldParams&& params) const final { - return _pimpl->getNested(std::move(params)); + if constexpr (NestedTypeStubs::HasNested) + { + return _pimpl->getNested(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(NestedType::getNested is not implemented)ex"); + } } private: @@ -999,10 +1617,18 @@ class NestedType : NestedType { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } +}; - ~NestedType(); +namespace ExpensiveStubs { + +template +concept HasOrder = requires (TImpl impl, service::FieldParams params) +{ + { impl.getOrder(std::move(params)) } -> std::convertible_to>; }; +} // namespace ExpensiveStubs + class Expensive : public service::Object { @@ -1029,7 +1655,14 @@ class Expensive service::FieldResult getOrder(service::FieldParams&& params) const final { - return _pimpl->getOrder(std::move(params)); + if constexpr (ExpensiveStubs::HasOrder) + { + return _pimpl->getOrder(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(Expensive::getOrder is not implemented)ex"); + } } private: @@ -1046,8 +1679,6 @@ class Expensive : Expensive { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } - - ~Expensive(); }; } // namespace object diff --git a/samples/validation/ValidationSchema.cpp b/samples/validation/ValidationSchema.cpp index 31683697..79f7f324 100644 --- a/samples/validation/ValidationSchema.cpp +++ b/samples/validation/ValidationSchema.cpp @@ -132,10 +132,6 @@ Query::Query(std::unique_ptr&& pimpl) { } -Query::~Query() -{ -} - service::AwaitableResolver Query::resolveDog(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); @@ -246,10 +242,6 @@ Dog::Dog(std::unique_ptr&& pimpl) { } -Dog::~Dog() -{ -} - service::AwaitableResolver Dog::resolveName(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); @@ -331,10 +323,6 @@ Alien::Alien(std::unique_ptr&& pimpl) { } -Alien::~Alien() -{ -} - service::AwaitableResolver Alien::resolveName(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); @@ -375,10 +363,6 @@ Human::Human(std::unique_ptr&& pimpl) { } -Human::~Human() -{ -} - service::AwaitableResolver Human::resolveName(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); @@ -420,10 +404,6 @@ Cat::Cat(std::unique_ptr&& pimpl) { } -Cat::~Cat() -{ -} - service::AwaitableResolver Cat::resolveName(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); @@ -481,10 +461,6 @@ Mutation::Mutation(std::unique_ptr&& pimpl) { } -Mutation::~Mutation() -{ -} - service::AwaitableResolver Mutation::resolveMutateDog(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); @@ -511,10 +487,6 @@ MutateDogResult::MutateDogResult(std::unique_ptr&& pimpl) { } -MutateDogResult::~MutateDogResult() -{ -} - service::AwaitableResolver MutateDogResult::resolveId(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); @@ -542,10 +514,6 @@ Subscription::Subscription(std::unique_ptr&& pimpl) { } -Subscription::~Subscription() -{ -} - service::AwaitableResolver Subscription::resolveNewMessage(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); @@ -583,10 +551,6 @@ Message::Message(std::unique_ptr&& pimpl) { } -Message::~Message() -{ -} - service::AwaitableResolver Message::resolveBody(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); @@ -630,10 +594,6 @@ Arguments::Arguments(std::unique_ptr&& pimpl) { } -Arguments::~Arguments() -{ -} - service::AwaitableResolver Arguments::resolveMultipleReqs(service::ResolverParams&& params) { auto argX = service::ModifiedArgument::require("x", params.arguments); diff --git a/samples/validation/ValidationSchema.h b/samples/validation/ValidationSchema.h index 98c698d0..16253133 100644 --- a/samples/validation/ValidationSchema.h +++ b/samples/validation/ValidationSchema.h @@ -14,6 +14,7 @@ static_assert(graphql::internal::MajorVersion == 4, "regenerate with schemagen: major version mismatch"); static_assert(graphql::internal::MinorVersion == 0, "regenerate with schemagen: minor version mismatch"); +#include #include #include #include @@ -69,6 +70,52 @@ struct Pet namespace object { +namespace QueryStubs { + +template +concept HasDog = requires (TImpl impl, service::FieldParams params) +{ + { impl.getDog(std::move(params)) } -> std::convertible_to>>; +}; + +template +concept HasHuman = requires (TImpl impl, service::FieldParams params) +{ + { impl.getHuman(std::move(params)) } -> std::convertible_to>>; +}; + +template +concept HasPet = requires (TImpl impl, service::FieldParams params) +{ + { impl.getPet(std::move(params)) } -> std::convertible_to>>; +}; + +template +concept HasCatOrDog = requires (TImpl impl, service::FieldParams params) +{ + { impl.getCatOrDog(std::move(params)) } -> std::convertible_to>>; +}; + +template +concept HasArguments = requires (TImpl impl, service::FieldParams params) +{ + { impl.getArguments(std::move(params)) } -> std::convertible_to>>; +}; + +template +concept HasFindDog = requires (TImpl impl, service::FieldParams params, std::optional complexArg) +{ + { impl.getFindDog(std::move(params), std::move(complexArg)) } -> std::convertible_to>>; +}; + +template +concept HasBooleanList = requires (TImpl impl, service::FieldParams params, std::optional> booleanListArgArg) +{ + { impl.getBooleanList(std::move(params), std::move(booleanListArgArg)) } -> std::convertible_to>>; +}; + +} // namespace QueryStubs + class Query : public service::Object { @@ -111,37 +158,86 @@ class Query service::FieldResult> getDog(service::FieldParams&& params) const final { - return _pimpl->getDog(std::move(params)); + if constexpr (QueryStubs::HasDog) + { + return _pimpl->getDog(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(Query::getDog is not implemented)ex"); + } } service::FieldResult> getHuman(service::FieldParams&& params) const final { - return _pimpl->getHuman(std::move(params)); + if constexpr (QueryStubs::HasHuman) + { + return _pimpl->getHuman(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(Query::getHuman is not implemented)ex"); + } } service::FieldResult> getPet(service::FieldParams&& params) const final { - return _pimpl->getPet(std::move(params)); + if constexpr (QueryStubs::HasPet) + { + return _pimpl->getPet(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(Query::getPet is not implemented)ex"); + } } service::FieldResult> getCatOrDog(service::FieldParams&& params) const final { - return _pimpl->getCatOrDog(std::move(params)); + if constexpr (QueryStubs::HasCatOrDog) + { + return _pimpl->getCatOrDog(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(Query::getCatOrDog is not implemented)ex"); + } } service::FieldResult> getArguments(service::FieldParams&& params) const final { - return _pimpl->getArguments(std::move(params)); + if constexpr (QueryStubs::HasArguments) + { + return _pimpl->getArguments(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(Query::getArguments is not implemented)ex"); + } } service::FieldResult> getFindDog(service::FieldParams&& params, std::optional&& complexArg) const final { - return _pimpl->getFindDog(std::move(params), std::move(complexArg)); + if constexpr (QueryStubs::HasFindDog) + { + return _pimpl->getFindDog(std::move(params), std::move(complexArg)); + } + else + { + throw std::runtime_error(R"ex(Query::getFindDog is not implemented)ex"); + } } service::FieldResult> getBooleanList(service::FieldParams&& params, std::optional>&& booleanListArgArg) const final { - return _pimpl->getBooleanList(std::move(params), std::move(booleanListArgArg)); + if constexpr (QueryStubs::HasBooleanList) + { + return _pimpl->getBooleanList(std::move(params), std::move(booleanListArgArg)); + } + else + { + throw std::runtime_error(R"ex(Query::getBooleanList is not implemented)ex"); + } } private: @@ -158,10 +254,48 @@ class Query : Query { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } +}; + +namespace DogStubs { - ~Query(); +template +concept HasName = requires (TImpl impl, service::FieldParams params) +{ + { impl.getName(std::move(params)) } -> std::convertible_to>; }; +template +concept HasNickname = requires (TImpl impl, service::FieldParams params) +{ + { impl.getNickname(std::move(params)) } -> std::convertible_to>>; +}; + +template +concept HasBarkVolume = requires (TImpl impl, service::FieldParams params) +{ + { impl.getBarkVolume(std::move(params)) } -> std::convertible_to>>; +}; + +template +concept HasDoesKnowCommand = requires (TImpl impl, service::FieldParams params, DogCommand dogCommandArg) +{ + { impl.getDoesKnowCommand(std::move(params), std::move(dogCommandArg)) } -> std::convertible_to>; +}; + +template +concept HasIsHousetrained = requires (TImpl impl, service::FieldParams params, std::optional atOtherHomesArg) +{ + { impl.getIsHousetrained(std::move(params), std::move(atOtherHomesArg)) } -> std::convertible_to>; +}; + +template +concept HasOwner = requires (TImpl impl, service::FieldParams params) +{ + { impl.getOwner(std::move(params)) } -> std::convertible_to>>; +}; + +} // namespace DogStubs + class Dog : public service::Object { @@ -198,32 +332,74 @@ class Dog service::FieldResult getName(service::FieldParams&& params) const final { - return _pimpl->getName(std::move(params)); + if constexpr (DogStubs::HasName) + { + return _pimpl->getName(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(Dog::getName is not implemented)ex"); + } } service::FieldResult> getNickname(service::FieldParams&& params) const final { - return _pimpl->getNickname(std::move(params)); + if constexpr (DogStubs::HasNickname) + { + return _pimpl->getNickname(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(Dog::getNickname is not implemented)ex"); + } } service::FieldResult> getBarkVolume(service::FieldParams&& params) const final { - return _pimpl->getBarkVolume(std::move(params)); + if constexpr (DogStubs::HasBarkVolume) + { + return _pimpl->getBarkVolume(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(Dog::getBarkVolume is not implemented)ex"); + } } service::FieldResult getDoesKnowCommand(service::FieldParams&& params, DogCommand&& dogCommandArg) const final { - return _pimpl->getDoesKnowCommand(std::move(params), std::move(dogCommandArg)); + if constexpr (DogStubs::HasDoesKnowCommand) + { + return _pimpl->getDoesKnowCommand(std::move(params), std::move(dogCommandArg)); + } + else + { + throw std::runtime_error(R"ex(Dog::getDoesKnowCommand is not implemented)ex"); + } } service::FieldResult getIsHousetrained(service::FieldParams&& params, std::optional&& atOtherHomesArg) const final { - return _pimpl->getIsHousetrained(std::move(params), std::move(atOtherHomesArg)); + if constexpr (DogStubs::HasIsHousetrained) + { + return _pimpl->getIsHousetrained(std::move(params), std::move(atOtherHomesArg)); + } + else + { + throw std::runtime_error(R"ex(Dog::getIsHousetrained is not implemented)ex"); + } } service::FieldResult> getOwner(service::FieldParams&& params) const final { - return _pimpl->getOwner(std::move(params)); + if constexpr (DogStubs::HasOwner) + { + return _pimpl->getOwner(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(Dog::getOwner is not implemented)ex"); + } } private: @@ -240,10 +416,24 @@ class Dog : Dog { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } +}; + +namespace AlienStubs { - ~Dog(); +template +concept HasName = requires (TImpl impl, service::FieldParams params) +{ + { impl.getName(std::move(params)) } -> std::convertible_to>; }; +template +concept HasHomePlanet = requires (TImpl impl, service::FieldParams params) +{ + { impl.getHomePlanet(std::move(params)) } -> std::convertible_to>>; +}; + +} // namespace AlienStubs + class Alien : public service::Object { @@ -272,12 +462,26 @@ class Alien service::FieldResult getName(service::FieldParams&& params) const final { - return _pimpl->getName(std::move(params)); + if constexpr (AlienStubs::HasName) + { + return _pimpl->getName(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(Alien::getName is not implemented)ex"); + } } service::FieldResult> getHomePlanet(service::FieldParams&& params) const final { - return _pimpl->getHomePlanet(std::move(params)); + if constexpr (AlienStubs::HasHomePlanet) + { + return _pimpl->getHomePlanet(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(Alien::getHomePlanet is not implemented)ex"); + } } private: @@ -294,10 +498,24 @@ class Alien : Alien { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } +}; + +namespace HumanStubs { + +template +concept HasName = requires (TImpl impl, service::FieldParams params) +{ + { impl.getName(std::move(params)) } -> std::convertible_to>; +}; - ~Alien(); +template +concept HasPets = requires (TImpl impl, service::FieldParams params) +{ + { impl.getPets(std::move(params)) } -> std::convertible_to>>>; }; +} // namespace HumanStubs + class Human : public service::Object { @@ -326,12 +544,26 @@ class Human service::FieldResult getName(service::FieldParams&& params) const final { - return _pimpl->getName(std::move(params)); + if constexpr (HumanStubs::HasName) + { + return _pimpl->getName(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(Human::getName is not implemented)ex"); + } } service::FieldResult>> getPets(service::FieldParams&& params) const final { - return _pimpl->getPets(std::move(params)); + if constexpr (HumanStubs::HasPets) + { + return _pimpl->getPets(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(Human::getPets is not implemented)ex"); + } } private: @@ -348,10 +580,36 @@ class Human : Human { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } +}; + +namespace CatStubs { - ~Human(); +template +concept HasName = requires (TImpl impl, service::FieldParams params) +{ + { impl.getName(std::move(params)) } -> std::convertible_to>; }; +template +concept HasNickname = requires (TImpl impl, service::FieldParams params) +{ + { impl.getNickname(std::move(params)) } -> std::convertible_to>>; +}; + +template +concept HasDoesKnowCommand = requires (TImpl impl, service::FieldParams params, CatCommand catCommandArg) +{ + { impl.getDoesKnowCommand(std::move(params), std::move(catCommandArg)) } -> std::convertible_to>; +}; + +template +concept HasMeowVolume = requires (TImpl impl, service::FieldParams params) +{ + { impl.getMeowVolume(std::move(params)) } -> std::convertible_to>>; +}; + +} // namespace CatStubs + class Cat : public service::Object { @@ -384,22 +642,50 @@ class Cat service::FieldResult getName(service::FieldParams&& params) const final { - return _pimpl->getName(std::move(params)); + if constexpr (CatStubs::HasName) + { + return _pimpl->getName(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(Cat::getName is not implemented)ex"); + } } service::FieldResult> getNickname(service::FieldParams&& params) const final { - return _pimpl->getNickname(std::move(params)); + if constexpr (CatStubs::HasNickname) + { + return _pimpl->getNickname(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(Cat::getNickname is not implemented)ex"); + } } service::FieldResult getDoesKnowCommand(service::FieldParams&& params, CatCommand&& catCommandArg) const final { - return _pimpl->getDoesKnowCommand(std::move(params), std::move(catCommandArg)); + if constexpr (CatStubs::HasDoesKnowCommand) + { + return _pimpl->getDoesKnowCommand(std::move(params), std::move(catCommandArg)); + } + else + { + throw std::runtime_error(R"ex(Cat::getDoesKnowCommand is not implemented)ex"); + } } service::FieldResult> getMeowVolume(service::FieldParams&& params) const final { - return _pimpl->getMeowVolume(std::move(params)); + if constexpr (CatStubs::HasMeowVolume) + { + return _pimpl->getMeowVolume(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(Cat::getMeowVolume is not implemented)ex"); + } } private: @@ -416,10 +702,18 @@ class Cat : Cat { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } +}; + +namespace MutationStubs { - ~Cat(); +template +concept HasMutateDog = requires (TImpl impl, service::FieldParams params) +{ + { impl.applyMutateDog(std::move(params)) } -> std::convertible_to>>; }; +} // namespace MutationStubs + class Mutation : public service::Object { @@ -446,7 +740,14 @@ class Mutation service::FieldResult> applyMutateDog(service::FieldParams&& params) const final { - return _pimpl->applyMutateDog(std::move(params)); + if constexpr (MutationStubs::HasMutateDog) + { + return _pimpl->applyMutateDog(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(Mutation::applyMutateDog is not implemented)ex"); + } } private: @@ -463,10 +764,18 @@ class Mutation : Mutation { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } +}; - ~Mutation(); +namespace MutateDogResultStubs { + +template +concept HasId = requires (TImpl impl, service::FieldParams params) +{ + { impl.getId(std::move(params)) } -> std::convertible_to>; }; +} // namespace MutateDogResultStubs + class MutateDogResult : public service::Object { @@ -493,7 +802,14 @@ class MutateDogResult service::FieldResult getId(service::FieldParams&& params) const final { - return _pimpl->getId(std::move(params)); + if constexpr (MutateDogResultStubs::HasId) + { + return _pimpl->getId(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(MutateDogResult::getId is not implemented)ex"); + } } private: @@ -510,10 +826,24 @@ class MutateDogResult : MutateDogResult { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } +}; + +namespace SubscriptionStubs { + +template +concept HasNewMessage = requires (TImpl impl, service::FieldParams params) +{ + { impl.getNewMessage(std::move(params)) } -> std::convertible_to>>; +}; - ~MutateDogResult(); +template +concept HasDisallowedSecondRootField = requires (TImpl impl, service::FieldParams params) +{ + { impl.getDisallowedSecondRootField(std::move(params)) } -> std::convertible_to>; }; +} // namespace SubscriptionStubs + class Subscription : public service::Object { @@ -542,12 +872,26 @@ class Subscription service::FieldResult> getNewMessage(service::FieldParams&& params) const final { - return _pimpl->getNewMessage(std::move(params)); + if constexpr (SubscriptionStubs::HasNewMessage) + { + return _pimpl->getNewMessage(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(Subscription::getNewMessage is not implemented)ex"); + } } service::FieldResult getDisallowedSecondRootField(service::FieldParams&& params) const final { - return _pimpl->getDisallowedSecondRootField(std::move(params)); + if constexpr (SubscriptionStubs::HasDisallowedSecondRootField) + { + return _pimpl->getDisallowedSecondRootField(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(Subscription::getDisallowedSecondRootField is not implemented)ex"); + } } private: @@ -564,10 +908,24 @@ class Subscription : Subscription { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } +}; + +namespace MessageStubs { + +template +concept HasBody = requires (TImpl impl, service::FieldParams params) +{ + { impl.getBody(std::move(params)) } -> std::convertible_to>>; +}; - ~Subscription(); +template +concept HasSender = requires (TImpl impl, service::FieldParams params) +{ + { impl.getSender(std::move(params)) } -> std::convertible_to>; }; +} // namespace MessageStubs + class Message : public service::Object { @@ -596,12 +954,26 @@ class Message service::FieldResult> getBody(service::FieldParams&& params) const final { - return _pimpl->getBody(std::move(params)); + if constexpr (MessageStubs::HasBody) + { + return _pimpl->getBody(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(Message::getBody is not implemented)ex"); + } } service::FieldResult getSender(service::FieldParams&& params) const final { - return _pimpl->getSender(std::move(params)); + if constexpr (MessageStubs::HasSender) + { + return _pimpl->getSender(std::move(params)); + } + else + { + throw std::runtime_error(R"ex(Message::getSender is not implemented)ex"); + } } private: @@ -618,10 +990,60 @@ class Message : Message { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } +}; + +namespace ArgumentsStubs { + +template +concept HasMultipleReqs = requires (TImpl impl, service::FieldParams params, response::IntType xArg, response::IntType yArg) +{ + { impl.getMultipleReqs(std::move(params), std::move(xArg), std::move(yArg)) } -> std::convertible_to>; +}; - ~Message(); +template +concept HasBooleanArgField = requires (TImpl impl, service::FieldParams params, std::optional booleanArgArg) +{ + { impl.getBooleanArgField(std::move(params), std::move(booleanArgArg)) } -> std::convertible_to>>; +}; + +template +concept HasFloatArgField = requires (TImpl impl, service::FieldParams params, std::optional floatArgArg) +{ + { impl.getFloatArgField(std::move(params), std::move(floatArgArg)) } -> std::convertible_to>>; +}; + +template +concept HasIntArgField = requires (TImpl impl, service::FieldParams params, std::optional intArgArg) +{ + { impl.getIntArgField(std::move(params), std::move(intArgArg)) } -> std::convertible_to>>; }; +template +concept HasNonNullBooleanArgField = requires (TImpl impl, service::FieldParams params, response::BooleanType nonNullBooleanArgArg) +{ + { impl.getNonNullBooleanArgField(std::move(params), std::move(nonNullBooleanArgArg)) } -> std::convertible_to>; +}; + +template +concept HasNonNullBooleanListField = requires (TImpl impl, service::FieldParams params, std::optional> nonNullBooleanListArgArg) +{ + { impl.getNonNullBooleanListField(std::move(params), std::move(nonNullBooleanListArgArg)) } -> std::convertible_to>>>; +}; + +template +concept HasBooleanListArgField = requires (TImpl impl, service::FieldParams params, std::vector> booleanListArgArg) +{ + { impl.getBooleanListArgField(std::move(params), std::move(booleanListArgArg)) } -> std::convertible_to>>>>; +}; + +template +concept HasOptionalNonNullBooleanArgField = requires (TImpl impl, service::FieldParams params, response::BooleanType optionalBooleanArgArg) +{ + { impl.getOptionalNonNullBooleanArgField(std::move(params), std::move(optionalBooleanArgArg)) } -> std::convertible_to>; +}; + +} // namespace ArgumentsStubs + class Arguments : public service::Object { @@ -662,42 +1084,98 @@ class Arguments service::FieldResult getMultipleReqs(service::FieldParams&& params, response::IntType&& xArg, response::IntType&& yArg) const final { - return _pimpl->getMultipleReqs(std::move(params), std::move(xArg), std::move(yArg)); + if constexpr (ArgumentsStubs::HasMultipleReqs) + { + return _pimpl->getMultipleReqs(std::move(params), std::move(xArg), std::move(yArg)); + } + else + { + throw std::runtime_error(R"ex(Arguments::getMultipleReqs is not implemented)ex"); + } } service::FieldResult> getBooleanArgField(service::FieldParams&& params, std::optional&& booleanArgArg) const final { - return _pimpl->getBooleanArgField(std::move(params), std::move(booleanArgArg)); + if constexpr (ArgumentsStubs::HasBooleanArgField) + { + return _pimpl->getBooleanArgField(std::move(params), std::move(booleanArgArg)); + } + else + { + throw std::runtime_error(R"ex(Arguments::getBooleanArgField is not implemented)ex"); + } } service::FieldResult> getFloatArgField(service::FieldParams&& params, std::optional&& floatArgArg) const final { - return _pimpl->getFloatArgField(std::move(params), std::move(floatArgArg)); + if constexpr (ArgumentsStubs::HasFloatArgField) + { + return _pimpl->getFloatArgField(std::move(params), std::move(floatArgArg)); + } + else + { + throw std::runtime_error(R"ex(Arguments::getFloatArgField is not implemented)ex"); + } } service::FieldResult> getIntArgField(service::FieldParams&& params, std::optional&& intArgArg) const final { - return _pimpl->getIntArgField(std::move(params), std::move(intArgArg)); + if constexpr (ArgumentsStubs::HasIntArgField) + { + return _pimpl->getIntArgField(std::move(params), std::move(intArgArg)); + } + else + { + throw std::runtime_error(R"ex(Arguments::getIntArgField is not implemented)ex"); + } } service::FieldResult getNonNullBooleanArgField(service::FieldParams&& params, response::BooleanType&& nonNullBooleanArgArg) const final { - return _pimpl->getNonNullBooleanArgField(std::move(params), std::move(nonNullBooleanArgArg)); + if constexpr (ArgumentsStubs::HasNonNullBooleanArgField) + { + return _pimpl->getNonNullBooleanArgField(std::move(params), std::move(nonNullBooleanArgArg)); + } + else + { + throw std::runtime_error(R"ex(Arguments::getNonNullBooleanArgField is not implemented)ex"); + } } service::FieldResult>> getNonNullBooleanListField(service::FieldParams&& params, std::optional>&& nonNullBooleanListArgArg) const final { - return _pimpl->getNonNullBooleanListField(std::move(params), std::move(nonNullBooleanListArgArg)); + if constexpr (ArgumentsStubs::HasNonNullBooleanListField) + { + return _pimpl->getNonNullBooleanListField(std::move(params), std::move(nonNullBooleanListArgArg)); + } + else + { + throw std::runtime_error(R"ex(Arguments::getNonNullBooleanListField is not implemented)ex"); + } } service::FieldResult>>> getBooleanListArgField(service::FieldParams&& params, std::vector>&& booleanListArgArg) const final { - return _pimpl->getBooleanListArgField(std::move(params), std::move(booleanListArgArg)); + if constexpr (ArgumentsStubs::HasBooleanListArgField) + { + return _pimpl->getBooleanListArgField(std::move(params), std::move(booleanListArgArg)); + } + else + { + throw std::runtime_error(R"ex(Arguments::getBooleanListArgField is not implemented)ex"); + } } service::FieldResult getOptionalNonNullBooleanArgField(service::FieldParams&& params, response::BooleanType&& optionalBooleanArgArg) const final { - return _pimpl->getOptionalNonNullBooleanArgField(std::move(params), std::move(optionalBooleanArgArg)); + if constexpr (ArgumentsStubs::HasOptionalNonNullBooleanArgField) + { + return _pimpl->getOptionalNonNullBooleanArgField(std::move(params), std::move(optionalBooleanArgArg)); + } + else + { + throw std::runtime_error(R"ex(Arguments::getOptionalNonNullBooleanArgField is not implemented)ex"); + } } private: @@ -714,8 +1192,6 @@ class Arguments : Arguments { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } - - ~Arguments(); }; } // namespace object diff --git a/src/IntrospectionSchema.cpp b/src/IntrospectionSchema.cpp index 9154bb31..a4e65b9d 100644 --- a/src/IntrospectionSchema.cpp +++ b/src/IntrospectionSchema.cpp @@ -120,7 +120,7 @@ service::AwaitableResolver ModifiedResult::con namespace introspection { namespace object { -Schema::Schema(std::unique_ptr&& pimpl) +Schema::Schema(std::shared_ptr pimpl) : service::Object({ "__Schema" }, { @@ -131,12 +131,14 @@ Schema::Schema(std::unique_ptr&& pimpl) { R"gql(mutationType)gql"sv, [this](service::ResolverParams&& params) { return resolveMutationType(std::move(params)); } }, { R"gql(subscriptionType)gql"sv, [this](service::ResolverParams&& params) { return resolveSubscriptionType(std::move(params)); } } }) - , _pimpl(std::move(pimpl)) + , _pimpl(std::make_unique>(std::move(pimpl))) { } Schema::~Schema() { + // This is empty, but explicitly defined here so that it can access the un-exported destructor + // of the implementation type. } service::AwaitableResolver Schema::resolveTypes(service::ResolverParams&& params) @@ -194,7 +196,7 @@ service::AwaitableResolver Schema::resolve_typename(service::ResolverParams&& pa return service::ModifiedResult::convert(response::StringType{ R"gql(__Schema)gql" }, std::move(params)); } -Type::Type(std::unique_ptr&& pimpl) +Type::Type(std::shared_ptr pimpl) : service::Object({ "__Type" }, { @@ -209,12 +211,14 @@ Type::Type(std::unique_ptr&& pimpl) { R"gql(inputFields)gql"sv, [this](service::ResolverParams&& params) { return resolveInputFields(std::move(params)); } }, { R"gql(possibleTypes)gql"sv, [this](service::ResolverParams&& params) { return resolvePossibleTypes(std::move(params)); } } }) - , _pimpl(std::move(pimpl)) + , _pimpl(std::make_unique>(std::move(pimpl))) { } Type::~Type() { + // This is empty, but explicitly defined here so that it can access the un-exported destructor + // of the implementation type. } service::AwaitableResolver Type::resolveKind(service::ResolverParams&& params) @@ -342,7 +346,7 @@ service::AwaitableResolver Type::resolve_typename(service::ResolverParams&& para return service::ModifiedResult::convert(response::StringType{ R"gql(__Type)gql" }, std::move(params)); } -Field::Field(std::unique_ptr&& pimpl) +Field::Field(std::shared_ptr pimpl) : service::Object({ "__Field" }, { @@ -354,12 +358,14 @@ Field::Field(std::unique_ptr&& pimpl) { R"gql(isDeprecated)gql"sv, [this](service::ResolverParams&& params) { return resolveIsDeprecated(std::move(params)); } }, { R"gql(deprecationReason)gql"sv, [this](service::ResolverParams&& params) { return resolveDeprecationReason(std::move(params)); } } }) - , _pimpl(std::move(pimpl)) + , _pimpl(std::make_unique>(std::move(pimpl))) { } Field::~Field() { + // This is empty, but explicitly defined here so that it can access the un-exported destructor + // of the implementation type. } service::AwaitableResolver Field::resolveName(service::ResolverParams&& params) @@ -427,7 +433,7 @@ service::AwaitableResolver Field::resolve_typename(service::ResolverParams&& par return service::ModifiedResult::convert(response::StringType{ R"gql(__Field)gql" }, std::move(params)); } -InputValue::InputValue(std::unique_ptr&& pimpl) +InputValue::InputValue(std::shared_ptr pimpl) : service::Object({ "__InputValue" }, { @@ -437,12 +443,14 @@ InputValue::InputValue(std::unique_ptr&& pimpl) { R"gql(description)gql"sv, [this](service::ResolverParams&& params) { return resolveDescription(std::move(params)); } }, { R"gql(defaultValue)gql"sv, [this](service::ResolverParams&& params) { return resolveDefaultValue(std::move(params)); } } }) - , _pimpl(std::move(pimpl)) + , _pimpl(std::make_unique>(std::move(pimpl))) { } InputValue::~InputValue() { + // This is empty, but explicitly defined here so that it can access the un-exported destructor + // of the implementation type. } service::AwaitableResolver InputValue::resolveName(service::ResolverParams&& params) @@ -490,7 +498,7 @@ service::AwaitableResolver InputValue::resolve_typename(service::ResolverParams& return service::ModifiedResult::convert(response::StringType{ R"gql(__InputValue)gql" }, std::move(params)); } -EnumValue::EnumValue(std::unique_ptr&& pimpl) +EnumValue::EnumValue(std::shared_ptr pimpl) : service::Object({ "__EnumValue" }, { @@ -500,12 +508,14 @@ EnumValue::EnumValue(std::unique_ptr&& pimpl) { R"gql(isDeprecated)gql"sv, [this](service::ResolverParams&& params) { return resolveIsDeprecated(std::move(params)); } }, { R"gql(deprecationReason)gql"sv, [this](service::ResolverParams&& params) { return resolveDeprecationReason(std::move(params)); } } }) - , _pimpl(std::move(pimpl)) + , _pimpl(std::make_unique>(std::move(pimpl))) { } EnumValue::~EnumValue() { + // This is empty, but explicitly defined here so that it can access the un-exported destructor + // of the implementation type. } service::AwaitableResolver EnumValue::resolveName(service::ResolverParams&& params) @@ -553,7 +563,7 @@ service::AwaitableResolver EnumValue::resolve_typename(service::ResolverParams&& return service::ModifiedResult::convert(response::StringType{ R"gql(__EnumValue)gql" }, std::move(params)); } -Directive::Directive(std::unique_ptr&& pimpl) +Directive::Directive(std::shared_ptr pimpl) : service::Object({ "__Directive" }, { @@ -563,12 +573,14 @@ Directive::Directive(std::unique_ptr&& pimpl) { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, { R"gql(description)gql"sv, [this](service::ResolverParams&& params) { return resolveDescription(std::move(params)); } } }) - , _pimpl(std::move(pimpl)) + , _pimpl(std::make_unique>(std::move(pimpl))) { } Directive::~Directive() { + // This is empty, but explicitly defined here so that it can access the un-exported destructor + // of the implementation type. } service::AwaitableResolver Directive::resolveName(service::ResolverParams&& params) diff --git a/src/SchemaGenerator.cpp b/src/SchemaGenerator.cpp index 1ba49609..47c7e5c2 100644 --- a/src/SchemaGenerator.cpp +++ b/src/SchemaGenerator.cpp @@ -170,6 +170,12 @@ static_assert(graphql::internal::MinorVersion == )cpp" #endif // !GRAPHQL_DLLEXPORTS // clang-format on +)cpp"; + } + else if (!_options.noStubs) + { + headerFile << + R"cpp(#include )cpp"; } @@ -252,6 +258,18 @@ static_assert(graphql::internal::MinorVersion == )cpp" if (!_loader.getObjectTypes().empty()) { + if (_loader.isIntrospection()) + { + // Forward declare all of the concrete types for the Introspection schema + for (const auto& objectType : _loader.getObjectTypes()) + { + headerFile << R"cpp(class )cpp" << objectType.cppType << R"cpp(; +)cpp"; + } + + headerFile << std::endl; + } + objectNamespace.enter(); headerFile << std::endl; @@ -502,6 +520,56 @@ GRAPHQLINTROSPECTION_EXPORT )cpp" void Generator::outputObjectDeclaration( std::ostream& headerFile, const ObjectType& objectType, bool isQueryType) const { + std::ostringstream ossNamespace; + + ossNamespace << objectType.cppType << "Stubs"; + + const auto stubNamespace = ossNamespace.str(); + + if (!_options.noStubs && !_loader.isIntrospection()) + { + NamespaceScope conceptsNamespace { headerFile, stubNamespace }; + + headerFile << std::endl; + + for (const auto& outputField : objectType.fields) + { + std::string fieldName(outputField.cppName); + + fieldName[0] = + static_cast(std::toupper(static_cast(fieldName[0]))); + + headerFile << R"cpp(template +concept Has)cpp" << fieldName + << R"cpp( = requires (TImpl impl, service::FieldParams params)cpp"; + for (const auto& argument : outputField.arguments) + { + headerFile << R"cpp(, )cpp" << _loader.getInputCppType(argument) << R"cpp( )cpp" + << argument.cppName << R"cpp(Arg)cpp"; + } + + headerFile << R"cpp() +{ + { impl.)cpp" << outputField.accessor + << fieldName << R"cpp((std::move(params))cpp"; + for (const auto& argument : outputField.arguments) + { + headerFile << R"cpp(, std::move()cpp" << argument.cppName << R"cpp(Arg))cpp"; + } + + headerFile << R"cpp() } -> std::convertible_to>; +}; + +)cpp"; + } + + if (conceptsNamespace.exit()) + { + headerFile << std::endl; + } + } + headerFile << R"cpp(class )cpp" << objectType.cppType << R"cpp( : public service::Object { @@ -594,20 +662,47 @@ void Generator::outputObjectDeclaration( for (const auto& argument : outputField.arguments) { headerFile << R"cpp(, )cpp" << _loader.getInputCppType(argument) << R"cpp(&& )cpp" - << argument.cppName << "Arg"; + << argument.cppName << R"cpp(Arg)cpp"; } headerFile << R"cpp() const final { - return _pimpl->)cpp" - << outputField.accessor << fieldName << R"cpp((std::move(params))cpp"; + )cpp"; + + if (_options.noStubs || _loader.isIntrospection()) + { + headerFile << R"cpp(return _pimpl->)cpp" << outputField.accessor << fieldName + << R"cpp((std::move(params))cpp"; + } + else + { + headerFile << R"cpp(if constexpr ()cpp" << stubNamespace << R"cpp(::Has)cpp" + << fieldName << R"cpp() + { + return _pimpl->)cpp" + << outputField.accessor << fieldName << R"cpp((std::move(params))cpp"; + } for (const auto& argument : outputField.arguments) { - headerFile << R"cpp(, std::move()cpp" << argument.cppName << "Arg)"; + headerFile << R"cpp(, std::move()cpp" << argument.cppName << R"cpp(Arg))cpp"; } - headerFile << R"cpp(); + headerFile << R"cpp();)cpp"; + + if (!_options.noStubs && !_loader.isIntrospection()) + { + headerFile << R"cpp( + } + else + { + throw std::runtime_error(R"ex()cpp" + << objectType.cppType << R"cpp(::)cpp" << outputField.accessor << fieldName + << R"cpp( is not implemented)ex"); + })cpp"; + } + + headerFile << R"cpp( } )cpp"; } @@ -621,32 +716,37 @@ void Generator::outputObjectDeclaration( if (_loader.isIntrospection()) { - headerFile << R"cpp(GRAPHQLINTROSPECTION_EXPORT )cpp"; - } + headerFile << R"cpp(const std::unique_ptr _pimpl; - headerFile << objectType.cppType << R"cpp((std::unique_ptr&& pimpl); +public: + GRAPHQLINTROSPECTION_EXPORT )cpp" + << objectType.cppType << R"cpp((std::shared_ptr<)cpp" + << SchemaLoader::getIntrospectionNamespace() << R"cpp(::)cpp" + << objectType.cppType << R"cpp(> pimpl); + GRAPHQLINTROSPECTION_EXPORT ~)cpp" + << objectType.cppType << R"cpp((); +}; +)cpp"; + } + else + { + headerFile + << objectType.cppType << R"cpp((std::unique_ptr&& pimpl); const std::unique_ptr _pimpl; public: template )cpp" << objectType.cppType - << R"cpp((std::shared_ptr pimpl) - : )cpp" << objectType.cppType - << R"cpp( { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } + << R"cpp((std::shared_ptr pimpl) + : )cpp" + << objectType.cppType + << R"cpp( { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } - - )cpp"; - - if (_loader.isIntrospection()) - { - headerFile << R"cpp(GRAPHQLINTROSPECTION_EXPORT )cpp"; - } - - headerFile << R"cpp(~)cpp" << objectType.cppType << R"cpp((); }; )cpp"; + } } std::string Generator::getFieldDeclaration(const InputField& inputField) const noexcept @@ -664,15 +764,7 @@ std::string Generator::getFieldDeclaration(const OutputField& outputField) const std::string fieldName { outputField.cppName }; fieldName[0] = static_cast(std::toupper(static_cast(fieldName[0]))); - output << R"cpp( )cpp"; - - if (outputField.interfaceField || _loader.isIntrospection() || _options.noStubs - || !outputField.inheritedField) - { - output << R"cpp(virtual )cpp"; - } - - output << R"cpp(service::FieldResult<)cpp" << _loader.getOutputCppType(outputField) + output << R"cpp( virtual service::FieldResult<)cpp" << _loader.getOutputCppType(outputField) << R"cpp(> )cpp" << outputField.accessor << fieldName << R"cpp((service::FieldParams&& params)cpp"; @@ -1506,13 +1598,27 @@ void Generator::outputObjectImplementation( { using namespace std::literals; - // Output the protected constructor which calls through to the service::Object constructor - // with arguments that declare the set of types it implements and bind the fields to the - // resolver methods. - sourceFile << objectType.cppType << R"cpp(::)cpp" << objectType.cppType - << R"cpp((std::unique_ptr&& pimpl) + if (_loader.isIntrospection()) + { + // Output the public constructor which calls through to the service::Object constructor + // with arguments that declare the set of types it implements and bind the fields to the + // resolver methods. + sourceFile << objectType.cppType << R"cpp(::)cpp" << objectType.cppType + << R"cpp((std::shared_ptr<)cpp" << SchemaLoader::getIntrospectionNamespace() + << R"cpp(::)cpp" << objectType.cppType << R"cpp(> pimpl) : service::Object({ )cpp"; + } + else + { + // Output the private constructor which calls through to the service::Object constructor + // with arguments that declare the set of types it implements and bind the fields to the + // resolver methods. + sourceFile << objectType.cppType << R"cpp(::)cpp" << objectType.cppType + << R"cpp((std::unique_ptr&& pimpl) + : service::Object({ +)cpp"; + } for (const auto& interfaceName : objectType.interfaces) { @@ -1584,16 +1690,34 @@ void Generator::outputObjectImplementation( , _schema(GetSchema()))cpp"; } + if (_loader.isIntrospection()) + { + sourceFile << R"cpp( + , _pimpl(std::make_unique>(std::move(pimpl))))cpp"; + } + else + { + sourceFile << R"cpp( + , _pimpl(std::move(pimpl)))cpp"; + } sourceFile << R"cpp( - , _pimpl(std::move(pimpl)) { } +)cpp"; + if (_loader.isIntrospection()) + { + sourceFile << R"cpp( )cpp" << objectType.cppType - << R"cpp(::~)cpp" << objectType.cppType << R"cpp(() + << R"cpp(::~)cpp" << objectType.cppType << R"cpp(() { + // This is empty, but explicitly defined here so that it can access the un-exported destructor + // of the implementation type. } )cpp"; + } // Output each of the resolver implementations, which call the virtual property // getters that the implementer must define. From 66b5f8dd4f785e9a72ea4bef785822c60da6ab31 Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Tue, 30 Nov 2021 18:14:43 -0800 Subject: [PATCH 030/119] Simple workaround for missing concepts header on macOS --- .../introspection/IntrospectionSchema.h | 64 +++--- samples/learn/DroidObject.h | 10 +- samples/learn/HumanObject.h | 10 +- samples/learn/MutationObject.h | 2 +- samples/learn/QueryObject.h | 6 +- samples/learn/ReviewObject.h | 4 +- .../separate/AppointmentConnectionObject.h | 8 +- samples/separate/AppointmentEdgeObject.h | 8 +- samples/separate/AppointmentObject.h | 20 +- samples/separate/CompleteTaskPayloadObject.h | 8 +- samples/separate/ExpensiveObject.h | 4 +- samples/separate/FolderConnectionObject.h | 8 +- samples/separate/FolderEdgeObject.h | 8 +- samples/separate/FolderObject.h | 12 +- samples/separate/MutationObject.h | 8 +- samples/separate/NestedTypeObject.h | 8 +- samples/separate/PageInfoObject.h | 8 +- samples/separate/QueryObject.h | 48 ++--- samples/separate/SubscriptionObject.h | 8 +- samples/separate/TaskConnectionObject.h | 8 +- samples/separate/TaskEdgeObject.h | 8 +- samples/separate/TaskObject.h | 12 +- samples/separate/TodaySchema.h | 1 - .../AppointmentConnectionObject.h | 8 +- .../AppointmentEdgeObject.h | 8 +- .../AppointmentObject.h | 20 +- .../CompleteTaskPayloadObject.h | 8 +- .../ExpensiveObject.h | 4 +- .../FolderConnectionObject.h | 8 +- .../FolderEdgeObject.h | 8 +- .../separate_nointrospection/FolderObject.h | 12 +- .../separate_nointrospection/MutationObject.h | 8 +- .../NestedTypeObject.h | 8 +- .../separate_nointrospection/PageInfoObject.h | 8 +- .../separate_nointrospection/QueryObject.h | 48 ++--- .../SubscriptionObject.h | 8 +- .../TaskConnectionObject.h | 8 +- .../separate_nointrospection/TaskEdgeObject.h | 8 +- samples/separate_nointrospection/TaskObject.h | 12 +- .../separate_nointrospection/TodaySchema.h | 1 - samples/unified/TodaySchema.h | 185 +++++++++--------- samples/unified_nointrospection/TodaySchema.h | 185 +++++++++--------- samples/validation/ValidationSchema.h | 141 +++++++------ src/SchemaGenerator.cpp | 29 +-- 44 files changed, 496 insertions(+), 510 deletions(-) diff --git a/include/graphqlservice/introspection/IntrospectionSchema.h b/include/graphqlservice/introspection/IntrospectionSchema.h index d19d7032..ee8904aa 100644 --- a/include/graphqlservice/introspection/IntrospectionSchema.h +++ b/include/graphqlservice/introspection/IntrospectionSchema.h @@ -117,27 +117,27 @@ class Schema service::FieldResult>> getTypes(service::FieldParams&& params) const final { - return _pimpl->getTypes(std::move(params)); + return { _pimpl->getTypes(std::move(params)) }; } service::FieldResult> getQueryType(service::FieldParams&& params) const final { - return _pimpl->getQueryType(std::move(params)); + return { _pimpl->getQueryType(std::move(params)) }; } service::FieldResult> getMutationType(service::FieldParams&& params) const final { - return _pimpl->getMutationType(std::move(params)); + return { _pimpl->getMutationType(std::move(params)) }; } service::FieldResult> getSubscriptionType(service::FieldParams&& params) const final { - return _pimpl->getSubscriptionType(std::move(params)); + return { _pimpl->getSubscriptionType(std::move(params)) }; } service::FieldResult>> getDirectives(service::FieldParams&& params) const final { - return _pimpl->getDirectives(std::move(params)); + return { _pimpl->getDirectives(std::move(params)) }; } private: @@ -193,47 +193,47 @@ class Type service::FieldResult getKind(service::FieldParams&& params) const final { - return _pimpl->getKind(std::move(params)); + return { _pimpl->getKind(std::move(params)) }; } service::FieldResult> getName(service::FieldParams&& params) const final { - return _pimpl->getName(std::move(params)); + return { _pimpl->getName(std::move(params)) }; } service::FieldResult> getDescription(service::FieldParams&& params) const final { - return _pimpl->getDescription(std::move(params)); + return { _pimpl->getDescription(std::move(params)) }; } service::FieldResult>>> getFields(service::FieldParams&& params, std::optional&& includeDeprecatedArg) const final { - return _pimpl->getFields(std::move(params), std::move(includeDeprecatedArg)); + return { _pimpl->getFields(std::move(params), std::move(includeDeprecatedArg)) }; } service::FieldResult>>> getInterfaces(service::FieldParams&& params) const final { - return _pimpl->getInterfaces(std::move(params)); + return { _pimpl->getInterfaces(std::move(params)) }; } service::FieldResult>>> getPossibleTypes(service::FieldParams&& params) const final { - return _pimpl->getPossibleTypes(std::move(params)); + return { _pimpl->getPossibleTypes(std::move(params)) }; } service::FieldResult>>> getEnumValues(service::FieldParams&& params, std::optional&& includeDeprecatedArg) const final { - return _pimpl->getEnumValues(std::move(params), std::move(includeDeprecatedArg)); + return { _pimpl->getEnumValues(std::move(params), std::move(includeDeprecatedArg)) }; } service::FieldResult>>> getInputFields(service::FieldParams&& params) const final { - return _pimpl->getInputFields(std::move(params)); + return { _pimpl->getInputFields(std::move(params)) }; } service::FieldResult> getOfType(service::FieldParams&& params) const final { - return _pimpl->getOfType(std::move(params)); + return { _pimpl->getOfType(std::move(params)) }; } private: @@ -283,32 +283,32 @@ class Field service::FieldResult getName(service::FieldParams&& params) const final { - return _pimpl->getName(std::move(params)); + return { _pimpl->getName(std::move(params)) }; } service::FieldResult> getDescription(service::FieldParams&& params) const final { - return _pimpl->getDescription(std::move(params)); + return { _pimpl->getDescription(std::move(params)) }; } service::FieldResult>> getArgs(service::FieldParams&& params) const final { - return _pimpl->getArgs(std::move(params)); + return { _pimpl->getArgs(std::move(params)) }; } service::FieldResult> getType(service::FieldParams&& params) const final { - return _pimpl->getType(std::move(params)); + return { _pimpl->getType(std::move(params)) }; } service::FieldResult getIsDeprecated(service::FieldParams&& params) const final { - return _pimpl->getIsDeprecated(std::move(params)); + return { _pimpl->getIsDeprecated(std::move(params)) }; } service::FieldResult> getDeprecationReason(service::FieldParams&& params) const final { - return _pimpl->getDeprecationReason(std::move(params)); + return { _pimpl->getDeprecationReason(std::move(params)) }; } private: @@ -354,22 +354,22 @@ class InputValue service::FieldResult getName(service::FieldParams&& params) const final { - return _pimpl->getName(std::move(params)); + return { _pimpl->getName(std::move(params)) }; } service::FieldResult> getDescription(service::FieldParams&& params) const final { - return _pimpl->getDescription(std::move(params)); + return { _pimpl->getDescription(std::move(params)) }; } service::FieldResult> getType(service::FieldParams&& params) const final { - return _pimpl->getType(std::move(params)); + return { _pimpl->getType(std::move(params)) }; } service::FieldResult> getDefaultValue(service::FieldParams&& params) const final { - return _pimpl->getDefaultValue(std::move(params)); + return { _pimpl->getDefaultValue(std::move(params)) }; } private: @@ -415,22 +415,22 @@ class EnumValue service::FieldResult getName(service::FieldParams&& params) const final { - return _pimpl->getName(std::move(params)); + return { _pimpl->getName(std::move(params)) }; } service::FieldResult> getDescription(service::FieldParams&& params) const final { - return _pimpl->getDescription(std::move(params)); + return { _pimpl->getDescription(std::move(params)) }; } service::FieldResult getIsDeprecated(service::FieldParams&& params) const final { - return _pimpl->getIsDeprecated(std::move(params)); + return { _pimpl->getIsDeprecated(std::move(params)) }; } service::FieldResult> getDeprecationReason(service::FieldParams&& params) const final { - return _pimpl->getDeprecationReason(std::move(params)); + return { _pimpl->getDeprecationReason(std::move(params)) }; } private: @@ -476,22 +476,22 @@ class Directive service::FieldResult getName(service::FieldParams&& params) const final { - return _pimpl->getName(std::move(params)); + return { _pimpl->getName(std::move(params)) }; } service::FieldResult> getDescription(service::FieldParams&& params) const final { - return _pimpl->getDescription(std::move(params)); + return { _pimpl->getDescription(std::move(params)) }; } service::FieldResult> getLocations(service::FieldParams&& params) const final { - return _pimpl->getLocations(std::move(params)); + return { _pimpl->getLocations(std::move(params)) }; } service::FieldResult>> getArgs(service::FieldParams&& params) const final { - return _pimpl->getArgs(std::move(params)); + return { _pimpl->getArgs(std::move(params)) }; } private: diff --git a/samples/learn/DroidObject.h b/samples/learn/DroidObject.h index 20c7ba6a..a0676f06 100644 --- a/samples/learn/DroidObject.h +++ b/samples/learn/DroidObject.h @@ -43,27 +43,27 @@ class Droid service::FieldResult getId(service::FieldParams&& params) const final { - return _pimpl->getId(std::move(params)); + return { _pimpl->getId(std::move(params)) }; } service::FieldResult> getName(service::FieldParams&& params) const final { - return _pimpl->getName(std::move(params)); + return { _pimpl->getName(std::move(params)) }; } service::FieldResult>>> getFriends(service::FieldParams&& params) const final { - return _pimpl->getFriends(std::move(params)); + return { _pimpl->getFriends(std::move(params)) }; } service::FieldResult>>> getAppearsIn(service::FieldParams&& params) const final { - return _pimpl->getAppearsIn(std::move(params)); + return { _pimpl->getAppearsIn(std::move(params)) }; } service::FieldResult> getPrimaryFunction(service::FieldParams&& params) const final { - return _pimpl->getPrimaryFunction(std::move(params)); + return { _pimpl->getPrimaryFunction(std::move(params)) }; } private: diff --git a/samples/learn/HumanObject.h b/samples/learn/HumanObject.h index de5b0903..f9263bf1 100644 --- a/samples/learn/HumanObject.h +++ b/samples/learn/HumanObject.h @@ -43,27 +43,27 @@ class Human service::FieldResult getId(service::FieldParams&& params) const final { - return _pimpl->getId(std::move(params)); + return { _pimpl->getId(std::move(params)) }; } service::FieldResult> getName(service::FieldParams&& params) const final { - return _pimpl->getName(std::move(params)); + return { _pimpl->getName(std::move(params)) }; } service::FieldResult>>> getFriends(service::FieldParams&& params) const final { - return _pimpl->getFriends(std::move(params)); + return { _pimpl->getFriends(std::move(params)) }; } service::FieldResult>>> getAppearsIn(service::FieldParams&& params) const final { - return _pimpl->getAppearsIn(std::move(params)); + return { _pimpl->getAppearsIn(std::move(params)) }; } service::FieldResult> getHomePlanet(service::FieldParams&& params) const final { - return _pimpl->getHomePlanet(std::move(params)); + return { _pimpl->getHomePlanet(std::move(params)) }; } private: diff --git a/samples/learn/MutationObject.h b/samples/learn/MutationObject.h index 5432b6ce..3a2e6c28 100644 --- a/samples/learn/MutationObject.h +++ b/samples/learn/MutationObject.h @@ -38,7 +38,7 @@ class Mutation service::FieldResult> applyCreateReview(service::FieldParams&& params, Episode&& epArg, ReviewInput&& reviewArg) const final { - return _pimpl->applyCreateReview(std::move(params), std::move(epArg), std::move(reviewArg)); + return { _pimpl->applyCreateReview(std::move(params), std::move(epArg), std::move(reviewArg)) }; } private: diff --git a/samples/learn/QueryObject.h b/samples/learn/QueryObject.h index 523ee0f1..6cd2ccc8 100644 --- a/samples/learn/QueryObject.h +++ b/samples/learn/QueryObject.h @@ -46,17 +46,17 @@ class Query service::FieldResult> getHero(service::FieldParams&& params, std::optional&& episodeArg) const final { - return _pimpl->getHero(std::move(params), std::move(episodeArg)); + return { _pimpl->getHero(std::move(params), std::move(episodeArg)) }; } service::FieldResult> getHuman(service::FieldParams&& params, response::StringType&& idArg) const final { - return _pimpl->getHuman(std::move(params), std::move(idArg)); + return { _pimpl->getHuman(std::move(params), std::move(idArg)) }; } service::FieldResult> getDroid(service::FieldParams&& params, response::StringType&& idArg) const final { - return _pimpl->getDroid(std::move(params), std::move(idArg)); + return { _pimpl->getDroid(std::move(params), std::move(idArg)) }; } private: diff --git a/samples/learn/ReviewObject.h b/samples/learn/ReviewObject.h index 0dad4ba5..ebc9a862 100644 --- a/samples/learn/ReviewObject.h +++ b/samples/learn/ReviewObject.h @@ -40,12 +40,12 @@ class Review service::FieldResult getStars(service::FieldParams&& params) const final { - return _pimpl->getStars(std::move(params)); + return { _pimpl->getStars(std::move(params)) }; } service::FieldResult> getCommentary(service::FieldParams&& params) const final { - return _pimpl->getCommentary(std::move(params)); + return { _pimpl->getCommentary(std::move(params)) }; } private: diff --git a/samples/separate/AppointmentConnectionObject.h b/samples/separate/AppointmentConnectionObject.h index 8df5345c..d8e3e2f5 100644 --- a/samples/separate/AppointmentConnectionObject.h +++ b/samples/separate/AppointmentConnectionObject.h @@ -17,13 +17,13 @@ namespace AppointmentConnectionStubs { template concept HasPageInfo = requires (TImpl impl, service::FieldParams params) { - { impl.getPageInfo(std::move(params)) } -> std::convertible_to>>; + { service::FieldResult> { impl.getPageInfo(std::move(params)) } }; }; template concept HasEdges = requires (TImpl impl, service::FieldParams params) { - { impl.getEdges(std::move(params)) } -> std::convertible_to>>>>; + { service::FieldResult>>> { impl.getEdges(std::move(params)) } }; }; } // namespace AppointmentConnectionStubs @@ -58,7 +58,7 @@ class AppointmentConnection { if constexpr (AppointmentConnectionStubs::HasPageInfo) { - return _pimpl->getPageInfo(std::move(params)); + return { _pimpl->getPageInfo(std::move(params)) }; } else { @@ -70,7 +70,7 @@ class AppointmentConnection { if constexpr (AppointmentConnectionStubs::HasEdges) { - return _pimpl->getEdges(std::move(params)); + return { _pimpl->getEdges(std::move(params)) }; } else { diff --git a/samples/separate/AppointmentEdgeObject.h b/samples/separate/AppointmentEdgeObject.h index e2d0922b..7adc12b1 100644 --- a/samples/separate/AppointmentEdgeObject.h +++ b/samples/separate/AppointmentEdgeObject.h @@ -17,13 +17,13 @@ namespace AppointmentEdgeStubs { template concept HasNode = requires (TImpl impl, service::FieldParams params) { - { impl.getNode(std::move(params)) } -> std::convertible_to>>; + { service::FieldResult> { impl.getNode(std::move(params)) } }; }; template concept HasCursor = requires (TImpl impl, service::FieldParams params) { - { impl.getCursor(std::move(params)) } -> std::convertible_to>; + { service::FieldResult { impl.getCursor(std::move(params)) } }; }; } // namespace AppointmentEdgeStubs @@ -58,7 +58,7 @@ class AppointmentEdge { if constexpr (AppointmentEdgeStubs::HasNode) { - return _pimpl->getNode(std::move(params)); + return { _pimpl->getNode(std::move(params)) }; } else { @@ -70,7 +70,7 @@ class AppointmentEdge { if constexpr (AppointmentEdgeStubs::HasCursor) { - return _pimpl->getCursor(std::move(params)); + return { _pimpl->getCursor(std::move(params)) }; } else { diff --git a/samples/separate/AppointmentObject.h b/samples/separate/AppointmentObject.h index d13318bc..1a1188af 100644 --- a/samples/separate/AppointmentObject.h +++ b/samples/separate/AppointmentObject.h @@ -17,31 +17,31 @@ namespace AppointmentStubs { template concept HasId = requires (TImpl impl, service::FieldParams params) { - { impl.getId(std::move(params)) } -> std::convertible_to>; + { service::FieldResult { impl.getId(std::move(params)) } }; }; template concept HasWhen = requires (TImpl impl, service::FieldParams params) { - { impl.getWhen(std::move(params)) } -> std::convertible_to>>; + { service::FieldResult> { impl.getWhen(std::move(params)) } }; }; template concept HasSubject = requires (TImpl impl, service::FieldParams params) { - { impl.getSubject(std::move(params)) } -> std::convertible_to>>; + { service::FieldResult> { impl.getSubject(std::move(params)) } }; }; template concept HasIsNow = requires (TImpl impl, service::FieldParams params) { - { impl.getIsNow(std::move(params)) } -> std::convertible_to>; + { service::FieldResult { impl.getIsNow(std::move(params)) } }; }; template concept HasForceError = requires (TImpl impl, service::FieldParams params) { - { impl.getForceError(std::move(params)) } -> std::convertible_to>>; + { service::FieldResult> { impl.getForceError(std::move(params)) } }; }; } // namespace AppointmentStubs @@ -82,7 +82,7 @@ class Appointment { if constexpr (AppointmentStubs::HasId) { - return _pimpl->getId(std::move(params)); + return { _pimpl->getId(std::move(params)) }; } else { @@ -94,7 +94,7 @@ class Appointment { if constexpr (AppointmentStubs::HasWhen) { - return _pimpl->getWhen(std::move(params)); + return { _pimpl->getWhen(std::move(params)) }; } else { @@ -106,7 +106,7 @@ class Appointment { if constexpr (AppointmentStubs::HasSubject) { - return _pimpl->getSubject(std::move(params)); + return { _pimpl->getSubject(std::move(params)) }; } else { @@ -118,7 +118,7 @@ class Appointment { if constexpr (AppointmentStubs::HasIsNow) { - return _pimpl->getIsNow(std::move(params)); + return { _pimpl->getIsNow(std::move(params)) }; } else { @@ -130,7 +130,7 @@ class Appointment { if constexpr (AppointmentStubs::HasForceError) { - return _pimpl->getForceError(std::move(params)); + return { _pimpl->getForceError(std::move(params)) }; } else { diff --git a/samples/separate/CompleteTaskPayloadObject.h b/samples/separate/CompleteTaskPayloadObject.h index 9e180344..b4603d44 100644 --- a/samples/separate/CompleteTaskPayloadObject.h +++ b/samples/separate/CompleteTaskPayloadObject.h @@ -17,13 +17,13 @@ namespace CompleteTaskPayloadStubs { template concept HasTask = requires (TImpl impl, service::FieldParams params) { - { impl.getTask(std::move(params)) } -> std::convertible_to>>; + { service::FieldResult> { impl.getTask(std::move(params)) } }; }; template concept HasClientMutationId = requires (TImpl impl, service::FieldParams params) { - { impl.getClientMutationId(std::move(params)) } -> std::convertible_to>>; + { service::FieldResult> { impl.getClientMutationId(std::move(params)) } }; }; } // namespace CompleteTaskPayloadStubs @@ -58,7 +58,7 @@ class CompleteTaskPayload { if constexpr (CompleteTaskPayloadStubs::HasTask) { - return _pimpl->getTask(std::move(params)); + return { _pimpl->getTask(std::move(params)) }; } else { @@ -70,7 +70,7 @@ class CompleteTaskPayload { if constexpr (CompleteTaskPayloadStubs::HasClientMutationId) { - return _pimpl->getClientMutationId(std::move(params)); + return { _pimpl->getClientMutationId(std::move(params)) }; } else { diff --git a/samples/separate/ExpensiveObject.h b/samples/separate/ExpensiveObject.h index 8b151c0c..347cff6f 100644 --- a/samples/separate/ExpensiveObject.h +++ b/samples/separate/ExpensiveObject.h @@ -17,7 +17,7 @@ namespace ExpensiveStubs { template concept HasOrder = requires (TImpl impl, service::FieldParams params) { - { impl.getOrder(std::move(params)) } -> std::convertible_to>; + { service::FieldResult { impl.getOrder(std::move(params)) } }; }; } // namespace ExpensiveStubs @@ -50,7 +50,7 @@ class Expensive { if constexpr (ExpensiveStubs::HasOrder) { - return _pimpl->getOrder(std::move(params)); + return { _pimpl->getOrder(std::move(params)) }; } else { diff --git a/samples/separate/FolderConnectionObject.h b/samples/separate/FolderConnectionObject.h index f3a659bf..f7c88190 100644 --- a/samples/separate/FolderConnectionObject.h +++ b/samples/separate/FolderConnectionObject.h @@ -17,13 +17,13 @@ namespace FolderConnectionStubs { template concept HasPageInfo = requires (TImpl impl, service::FieldParams params) { - { impl.getPageInfo(std::move(params)) } -> std::convertible_to>>; + { service::FieldResult> { impl.getPageInfo(std::move(params)) } }; }; template concept HasEdges = requires (TImpl impl, service::FieldParams params) { - { impl.getEdges(std::move(params)) } -> std::convertible_to>>>>; + { service::FieldResult>>> { impl.getEdges(std::move(params)) } }; }; } // namespace FolderConnectionStubs @@ -58,7 +58,7 @@ class FolderConnection { if constexpr (FolderConnectionStubs::HasPageInfo) { - return _pimpl->getPageInfo(std::move(params)); + return { _pimpl->getPageInfo(std::move(params)) }; } else { @@ -70,7 +70,7 @@ class FolderConnection { if constexpr (FolderConnectionStubs::HasEdges) { - return _pimpl->getEdges(std::move(params)); + return { _pimpl->getEdges(std::move(params)) }; } else { diff --git a/samples/separate/FolderEdgeObject.h b/samples/separate/FolderEdgeObject.h index 9869c4a3..a089a110 100644 --- a/samples/separate/FolderEdgeObject.h +++ b/samples/separate/FolderEdgeObject.h @@ -17,13 +17,13 @@ namespace FolderEdgeStubs { template concept HasNode = requires (TImpl impl, service::FieldParams params) { - { impl.getNode(std::move(params)) } -> std::convertible_to>>; + { service::FieldResult> { impl.getNode(std::move(params)) } }; }; template concept HasCursor = requires (TImpl impl, service::FieldParams params) { - { impl.getCursor(std::move(params)) } -> std::convertible_to>; + { service::FieldResult { impl.getCursor(std::move(params)) } }; }; } // namespace FolderEdgeStubs @@ -58,7 +58,7 @@ class FolderEdge { if constexpr (FolderEdgeStubs::HasNode) { - return _pimpl->getNode(std::move(params)); + return { _pimpl->getNode(std::move(params)) }; } else { @@ -70,7 +70,7 @@ class FolderEdge { if constexpr (FolderEdgeStubs::HasCursor) { - return _pimpl->getCursor(std::move(params)); + return { _pimpl->getCursor(std::move(params)) }; } else { diff --git a/samples/separate/FolderObject.h b/samples/separate/FolderObject.h index f5601542..52414320 100644 --- a/samples/separate/FolderObject.h +++ b/samples/separate/FolderObject.h @@ -17,19 +17,19 @@ namespace FolderStubs { template concept HasId = requires (TImpl impl, service::FieldParams params) { - { impl.getId(std::move(params)) } -> std::convertible_to>; + { service::FieldResult { impl.getId(std::move(params)) } }; }; template concept HasName = requires (TImpl impl, service::FieldParams params) { - { impl.getName(std::move(params)) } -> std::convertible_to>>; + { service::FieldResult> { impl.getName(std::move(params)) } }; }; template concept HasUnreadCount = requires (TImpl impl, service::FieldParams params) { - { impl.getUnreadCount(std::move(params)) } -> std::convertible_to>; + { service::FieldResult { impl.getUnreadCount(std::move(params)) } }; }; } // namespace FolderStubs @@ -66,7 +66,7 @@ class Folder { if constexpr (FolderStubs::HasId) { - return _pimpl->getId(std::move(params)); + return { _pimpl->getId(std::move(params)) }; } else { @@ -78,7 +78,7 @@ class Folder { if constexpr (FolderStubs::HasName) { - return _pimpl->getName(std::move(params)); + return { _pimpl->getName(std::move(params)) }; } else { @@ -90,7 +90,7 @@ class Folder { if constexpr (FolderStubs::HasUnreadCount) { - return _pimpl->getUnreadCount(std::move(params)); + return { _pimpl->getUnreadCount(std::move(params)) }; } else { diff --git a/samples/separate/MutationObject.h b/samples/separate/MutationObject.h index 1371d2bd..fc34f52f 100644 --- a/samples/separate/MutationObject.h +++ b/samples/separate/MutationObject.h @@ -17,13 +17,13 @@ namespace MutationStubs { template concept HasCompleteTask = requires (TImpl impl, service::FieldParams params, CompleteTaskInput inputArg) { - { impl.applyCompleteTask(std::move(params), std::move(inputArg)) } -> std::convertible_to>>; + { service::FieldResult> { impl.applyCompleteTask(std::move(params), std::move(inputArg)) } }; }; template concept HasSetFloat = requires (TImpl impl, service::FieldParams params, response::FloatType valueArg) { - { impl.applySetFloat(std::move(params), std::move(valueArg)) } -> std::convertible_to>; + { service::FieldResult { impl.applySetFloat(std::move(params), std::move(valueArg)) } }; }; } // namespace MutationStubs @@ -58,7 +58,7 @@ class Mutation { if constexpr (MutationStubs::HasCompleteTask) { - return _pimpl->applyCompleteTask(std::move(params), std::move(inputArg)); + return { _pimpl->applyCompleteTask(std::move(params), std::move(inputArg)) }; } else { @@ -70,7 +70,7 @@ class Mutation { if constexpr (MutationStubs::HasSetFloat) { - return _pimpl->applySetFloat(std::move(params), std::move(valueArg)); + return { _pimpl->applySetFloat(std::move(params), std::move(valueArg)) }; } else { diff --git a/samples/separate/NestedTypeObject.h b/samples/separate/NestedTypeObject.h index a19f3095..3278036a 100644 --- a/samples/separate/NestedTypeObject.h +++ b/samples/separate/NestedTypeObject.h @@ -17,13 +17,13 @@ namespace NestedTypeStubs { template concept HasDepth = requires (TImpl impl, service::FieldParams params) { - { impl.getDepth(std::move(params)) } -> std::convertible_to>; + { service::FieldResult { impl.getDepth(std::move(params)) } }; }; template concept HasNested = requires (TImpl impl, service::FieldParams params) { - { impl.getNested(std::move(params)) } -> std::convertible_to>>; + { service::FieldResult> { impl.getNested(std::move(params)) } }; }; } // namespace NestedTypeStubs @@ -58,7 +58,7 @@ class NestedType { if constexpr (NestedTypeStubs::HasDepth) { - return _pimpl->getDepth(std::move(params)); + return { _pimpl->getDepth(std::move(params)) }; } else { @@ -70,7 +70,7 @@ class NestedType { if constexpr (NestedTypeStubs::HasNested) { - return _pimpl->getNested(std::move(params)); + return { _pimpl->getNested(std::move(params)) }; } else { diff --git a/samples/separate/PageInfoObject.h b/samples/separate/PageInfoObject.h index 6d5234ee..2f160b3c 100644 --- a/samples/separate/PageInfoObject.h +++ b/samples/separate/PageInfoObject.h @@ -17,13 +17,13 @@ namespace PageInfoStubs { template concept HasHasNextPage = requires (TImpl impl, service::FieldParams params) { - { impl.getHasNextPage(std::move(params)) } -> std::convertible_to>; + { service::FieldResult { impl.getHasNextPage(std::move(params)) } }; }; template concept HasHasPreviousPage = requires (TImpl impl, service::FieldParams params) { - { impl.getHasPreviousPage(std::move(params)) } -> std::convertible_to>; + { service::FieldResult { impl.getHasPreviousPage(std::move(params)) } }; }; } // namespace PageInfoStubs @@ -58,7 +58,7 @@ class PageInfo { if constexpr (PageInfoStubs::HasHasNextPage) { - return _pimpl->getHasNextPage(std::move(params)); + return { _pimpl->getHasNextPage(std::move(params)) }; } else { @@ -70,7 +70,7 @@ class PageInfo { if constexpr (PageInfoStubs::HasHasPreviousPage) { - return _pimpl->getHasPreviousPage(std::move(params)); + return { _pimpl->getHasPreviousPage(std::move(params)) }; } else { diff --git a/samples/separate/QueryObject.h b/samples/separate/QueryObject.h index 46f588f9..0bd082be 100644 --- a/samples/separate/QueryObject.h +++ b/samples/separate/QueryObject.h @@ -17,73 +17,73 @@ namespace QueryStubs { template concept HasNode = requires (TImpl impl, service::FieldParams params, response::IdType idArg) { - { impl.getNode(std::move(params), std::move(idArg)) } -> std::convertible_to>>; + { service::FieldResult> { impl.getNode(std::move(params), std::move(idArg)) } }; }; template concept HasAppointments = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) { - { impl.getAppointments(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } -> std::convertible_to>>; + { service::FieldResult> { impl.getAppointments(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; }; template concept HasTasks = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) { - { impl.getTasks(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } -> std::convertible_to>>; + { service::FieldResult> { impl.getTasks(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; }; template concept HasUnreadCounts = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) { - { impl.getUnreadCounts(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } -> std::convertible_to>>; + { service::FieldResult> { impl.getUnreadCounts(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; }; template concept HasAppointmentsById = requires (TImpl impl, service::FieldParams params, std::vector idsArg) { - { impl.getAppointmentsById(std::move(params), std::move(idsArg)) } -> std::convertible_to>>>; + { service::FieldResult>> { impl.getAppointmentsById(std::move(params), std::move(idsArg)) } }; }; template concept HasTasksById = requires (TImpl impl, service::FieldParams params, std::vector idsArg) { - { impl.getTasksById(std::move(params), std::move(idsArg)) } -> std::convertible_to>>>; + { service::FieldResult>> { impl.getTasksById(std::move(params), std::move(idsArg)) } }; }; template concept HasUnreadCountsById = requires (TImpl impl, service::FieldParams params, std::vector idsArg) { - { impl.getUnreadCountsById(std::move(params), std::move(idsArg)) } -> std::convertible_to>>>; + { service::FieldResult>> { impl.getUnreadCountsById(std::move(params), std::move(idsArg)) } }; }; template concept HasNested = requires (TImpl impl, service::FieldParams params) { - { impl.getNested(std::move(params)) } -> std::convertible_to>>; + { service::FieldResult> { impl.getNested(std::move(params)) } }; }; template concept HasUnimplemented = requires (TImpl impl, service::FieldParams params) { - { impl.getUnimplemented(std::move(params)) } -> std::convertible_to>; + { service::FieldResult { impl.getUnimplemented(std::move(params)) } }; }; template concept HasExpensive = requires (TImpl impl, service::FieldParams params) { - { impl.getExpensive(std::move(params)) } -> std::convertible_to>>>; + { service::FieldResult>> { impl.getExpensive(std::move(params)) } }; }; template concept HasTestTaskState = requires (TImpl impl, service::FieldParams params) { - { impl.getTestTaskState(std::move(params)) } -> std::convertible_to>; + { service::FieldResult { impl.getTestTaskState(std::move(params)) } }; }; template concept HasAnyType = requires (TImpl impl, service::FieldParams params, std::vector idsArg) { - { impl.getAnyType(std::move(params), std::move(idsArg)) } -> std::convertible_to>>>; + { service::FieldResult>> { impl.getAnyType(std::move(params), std::move(idsArg)) } }; }; } // namespace QueryStubs @@ -142,7 +142,7 @@ class Query { if constexpr (QueryStubs::HasNode) { - return _pimpl->getNode(std::move(params), std::move(idArg)); + return { _pimpl->getNode(std::move(params), std::move(idArg)) }; } else { @@ -154,7 +154,7 @@ class Query { if constexpr (QueryStubs::HasAppointments) { - return _pimpl->getAppointments(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)); + return { _pimpl->getAppointments(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) }; } else { @@ -166,7 +166,7 @@ class Query { if constexpr (QueryStubs::HasTasks) { - return _pimpl->getTasks(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)); + return { _pimpl->getTasks(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) }; } else { @@ -178,7 +178,7 @@ class Query { if constexpr (QueryStubs::HasUnreadCounts) { - return _pimpl->getUnreadCounts(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)); + return { _pimpl->getUnreadCounts(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) }; } else { @@ -190,7 +190,7 @@ class Query { if constexpr (QueryStubs::HasAppointmentsById) { - return _pimpl->getAppointmentsById(std::move(params), std::move(idsArg)); + return { _pimpl->getAppointmentsById(std::move(params), std::move(idsArg)) }; } else { @@ -202,7 +202,7 @@ class Query { if constexpr (QueryStubs::HasTasksById) { - return _pimpl->getTasksById(std::move(params), std::move(idsArg)); + return { _pimpl->getTasksById(std::move(params), std::move(idsArg)) }; } else { @@ -214,7 +214,7 @@ class Query { if constexpr (QueryStubs::HasUnreadCountsById) { - return _pimpl->getUnreadCountsById(std::move(params), std::move(idsArg)); + return { _pimpl->getUnreadCountsById(std::move(params), std::move(idsArg)) }; } else { @@ -226,7 +226,7 @@ class Query { if constexpr (QueryStubs::HasNested) { - return _pimpl->getNested(std::move(params)); + return { _pimpl->getNested(std::move(params)) }; } else { @@ -238,7 +238,7 @@ class Query { if constexpr (QueryStubs::HasUnimplemented) { - return _pimpl->getUnimplemented(std::move(params)); + return { _pimpl->getUnimplemented(std::move(params)) }; } else { @@ -250,7 +250,7 @@ class Query { if constexpr (QueryStubs::HasExpensive) { - return _pimpl->getExpensive(std::move(params)); + return { _pimpl->getExpensive(std::move(params)) }; } else { @@ -262,7 +262,7 @@ class Query { if constexpr (QueryStubs::HasTestTaskState) { - return _pimpl->getTestTaskState(std::move(params)); + return { _pimpl->getTestTaskState(std::move(params)) }; } else { @@ -274,7 +274,7 @@ class Query { if constexpr (QueryStubs::HasAnyType) { - return _pimpl->getAnyType(std::move(params), std::move(idsArg)); + return { _pimpl->getAnyType(std::move(params), std::move(idsArg)) }; } else { diff --git a/samples/separate/SubscriptionObject.h b/samples/separate/SubscriptionObject.h index ca36231f..62178ef9 100644 --- a/samples/separate/SubscriptionObject.h +++ b/samples/separate/SubscriptionObject.h @@ -17,13 +17,13 @@ namespace SubscriptionStubs { template concept HasNextAppointmentChange = requires (TImpl impl, service::FieldParams params) { - { impl.getNextAppointmentChange(std::move(params)) } -> std::convertible_to>>; + { service::FieldResult> { impl.getNextAppointmentChange(std::move(params)) } }; }; template concept HasNodeChange = requires (TImpl impl, service::FieldParams params, response::IdType idArg) { - { impl.getNodeChange(std::move(params), std::move(idArg)) } -> std::convertible_to>>; + { service::FieldResult> { impl.getNodeChange(std::move(params), std::move(idArg)) } }; }; } // namespace SubscriptionStubs @@ -58,7 +58,7 @@ class Subscription { if constexpr (SubscriptionStubs::HasNextAppointmentChange) { - return _pimpl->getNextAppointmentChange(std::move(params)); + return { _pimpl->getNextAppointmentChange(std::move(params)) }; } else { @@ -70,7 +70,7 @@ class Subscription { if constexpr (SubscriptionStubs::HasNodeChange) { - return _pimpl->getNodeChange(std::move(params), std::move(idArg)); + return { _pimpl->getNodeChange(std::move(params), std::move(idArg)) }; } else { diff --git a/samples/separate/TaskConnectionObject.h b/samples/separate/TaskConnectionObject.h index b4e4c037..50c78c1e 100644 --- a/samples/separate/TaskConnectionObject.h +++ b/samples/separate/TaskConnectionObject.h @@ -17,13 +17,13 @@ namespace TaskConnectionStubs { template concept HasPageInfo = requires (TImpl impl, service::FieldParams params) { - { impl.getPageInfo(std::move(params)) } -> std::convertible_to>>; + { service::FieldResult> { impl.getPageInfo(std::move(params)) } }; }; template concept HasEdges = requires (TImpl impl, service::FieldParams params) { - { impl.getEdges(std::move(params)) } -> std::convertible_to>>>>; + { service::FieldResult>>> { impl.getEdges(std::move(params)) } }; }; } // namespace TaskConnectionStubs @@ -58,7 +58,7 @@ class TaskConnection { if constexpr (TaskConnectionStubs::HasPageInfo) { - return _pimpl->getPageInfo(std::move(params)); + return { _pimpl->getPageInfo(std::move(params)) }; } else { @@ -70,7 +70,7 @@ class TaskConnection { if constexpr (TaskConnectionStubs::HasEdges) { - return _pimpl->getEdges(std::move(params)); + return { _pimpl->getEdges(std::move(params)) }; } else { diff --git a/samples/separate/TaskEdgeObject.h b/samples/separate/TaskEdgeObject.h index 815a2097..fd5e1556 100644 --- a/samples/separate/TaskEdgeObject.h +++ b/samples/separate/TaskEdgeObject.h @@ -17,13 +17,13 @@ namespace TaskEdgeStubs { template concept HasNode = requires (TImpl impl, service::FieldParams params) { - { impl.getNode(std::move(params)) } -> std::convertible_to>>; + { service::FieldResult> { impl.getNode(std::move(params)) } }; }; template concept HasCursor = requires (TImpl impl, service::FieldParams params) { - { impl.getCursor(std::move(params)) } -> std::convertible_to>; + { service::FieldResult { impl.getCursor(std::move(params)) } }; }; } // namespace TaskEdgeStubs @@ -58,7 +58,7 @@ class TaskEdge { if constexpr (TaskEdgeStubs::HasNode) { - return _pimpl->getNode(std::move(params)); + return { _pimpl->getNode(std::move(params)) }; } else { @@ -70,7 +70,7 @@ class TaskEdge { if constexpr (TaskEdgeStubs::HasCursor) { - return _pimpl->getCursor(std::move(params)); + return { _pimpl->getCursor(std::move(params)) }; } else { diff --git a/samples/separate/TaskObject.h b/samples/separate/TaskObject.h index 78413875..0cbb17b6 100644 --- a/samples/separate/TaskObject.h +++ b/samples/separate/TaskObject.h @@ -17,19 +17,19 @@ namespace TaskStubs { template concept HasId = requires (TImpl impl, service::FieldParams params) { - { impl.getId(std::move(params)) } -> std::convertible_to>; + { service::FieldResult { impl.getId(std::move(params)) } }; }; template concept HasTitle = requires (TImpl impl, service::FieldParams params) { - { impl.getTitle(std::move(params)) } -> std::convertible_to>>; + { service::FieldResult> { impl.getTitle(std::move(params)) } }; }; template concept HasIsComplete = requires (TImpl impl, service::FieldParams params) { - { impl.getIsComplete(std::move(params)) } -> std::convertible_to>; + { service::FieldResult { impl.getIsComplete(std::move(params)) } }; }; } // namespace TaskStubs @@ -66,7 +66,7 @@ class Task { if constexpr (TaskStubs::HasId) { - return _pimpl->getId(std::move(params)); + return { _pimpl->getId(std::move(params)) }; } else { @@ -78,7 +78,7 @@ class Task { if constexpr (TaskStubs::HasTitle) { - return _pimpl->getTitle(std::move(params)); + return { _pimpl->getTitle(std::move(params)) }; } else { @@ -90,7 +90,7 @@ class Task { if constexpr (TaskStubs::HasIsComplete) { - return _pimpl->getIsComplete(std::move(params)); + return { _pimpl->getIsComplete(std::move(params)) }; } else { diff --git a/samples/separate/TodaySchema.h b/samples/separate/TodaySchema.h index 7514ae28..9f979a6e 100644 --- a/samples/separate/TodaySchema.h +++ b/samples/separate/TodaySchema.h @@ -14,7 +14,6 @@ static_assert(graphql::internal::MajorVersion == 4, "regenerate with schemagen: major version mismatch"); static_assert(graphql::internal::MinorVersion == 0, "regenerate with schemagen: minor version mismatch"); -#include #include #include #include diff --git a/samples/separate_nointrospection/AppointmentConnectionObject.h b/samples/separate_nointrospection/AppointmentConnectionObject.h index 8df5345c..d8e3e2f5 100644 --- a/samples/separate_nointrospection/AppointmentConnectionObject.h +++ b/samples/separate_nointrospection/AppointmentConnectionObject.h @@ -17,13 +17,13 @@ namespace AppointmentConnectionStubs { template concept HasPageInfo = requires (TImpl impl, service::FieldParams params) { - { impl.getPageInfo(std::move(params)) } -> std::convertible_to>>; + { service::FieldResult> { impl.getPageInfo(std::move(params)) } }; }; template concept HasEdges = requires (TImpl impl, service::FieldParams params) { - { impl.getEdges(std::move(params)) } -> std::convertible_to>>>>; + { service::FieldResult>>> { impl.getEdges(std::move(params)) } }; }; } // namespace AppointmentConnectionStubs @@ -58,7 +58,7 @@ class AppointmentConnection { if constexpr (AppointmentConnectionStubs::HasPageInfo) { - return _pimpl->getPageInfo(std::move(params)); + return { _pimpl->getPageInfo(std::move(params)) }; } else { @@ -70,7 +70,7 @@ class AppointmentConnection { if constexpr (AppointmentConnectionStubs::HasEdges) { - return _pimpl->getEdges(std::move(params)); + return { _pimpl->getEdges(std::move(params)) }; } else { diff --git a/samples/separate_nointrospection/AppointmentEdgeObject.h b/samples/separate_nointrospection/AppointmentEdgeObject.h index e2d0922b..7adc12b1 100644 --- a/samples/separate_nointrospection/AppointmentEdgeObject.h +++ b/samples/separate_nointrospection/AppointmentEdgeObject.h @@ -17,13 +17,13 @@ namespace AppointmentEdgeStubs { template concept HasNode = requires (TImpl impl, service::FieldParams params) { - { impl.getNode(std::move(params)) } -> std::convertible_to>>; + { service::FieldResult> { impl.getNode(std::move(params)) } }; }; template concept HasCursor = requires (TImpl impl, service::FieldParams params) { - { impl.getCursor(std::move(params)) } -> std::convertible_to>; + { service::FieldResult { impl.getCursor(std::move(params)) } }; }; } // namespace AppointmentEdgeStubs @@ -58,7 +58,7 @@ class AppointmentEdge { if constexpr (AppointmentEdgeStubs::HasNode) { - return _pimpl->getNode(std::move(params)); + return { _pimpl->getNode(std::move(params)) }; } else { @@ -70,7 +70,7 @@ class AppointmentEdge { if constexpr (AppointmentEdgeStubs::HasCursor) { - return _pimpl->getCursor(std::move(params)); + return { _pimpl->getCursor(std::move(params)) }; } else { diff --git a/samples/separate_nointrospection/AppointmentObject.h b/samples/separate_nointrospection/AppointmentObject.h index d13318bc..1a1188af 100644 --- a/samples/separate_nointrospection/AppointmentObject.h +++ b/samples/separate_nointrospection/AppointmentObject.h @@ -17,31 +17,31 @@ namespace AppointmentStubs { template concept HasId = requires (TImpl impl, service::FieldParams params) { - { impl.getId(std::move(params)) } -> std::convertible_to>; + { service::FieldResult { impl.getId(std::move(params)) } }; }; template concept HasWhen = requires (TImpl impl, service::FieldParams params) { - { impl.getWhen(std::move(params)) } -> std::convertible_to>>; + { service::FieldResult> { impl.getWhen(std::move(params)) } }; }; template concept HasSubject = requires (TImpl impl, service::FieldParams params) { - { impl.getSubject(std::move(params)) } -> std::convertible_to>>; + { service::FieldResult> { impl.getSubject(std::move(params)) } }; }; template concept HasIsNow = requires (TImpl impl, service::FieldParams params) { - { impl.getIsNow(std::move(params)) } -> std::convertible_to>; + { service::FieldResult { impl.getIsNow(std::move(params)) } }; }; template concept HasForceError = requires (TImpl impl, service::FieldParams params) { - { impl.getForceError(std::move(params)) } -> std::convertible_to>>; + { service::FieldResult> { impl.getForceError(std::move(params)) } }; }; } // namespace AppointmentStubs @@ -82,7 +82,7 @@ class Appointment { if constexpr (AppointmentStubs::HasId) { - return _pimpl->getId(std::move(params)); + return { _pimpl->getId(std::move(params)) }; } else { @@ -94,7 +94,7 @@ class Appointment { if constexpr (AppointmentStubs::HasWhen) { - return _pimpl->getWhen(std::move(params)); + return { _pimpl->getWhen(std::move(params)) }; } else { @@ -106,7 +106,7 @@ class Appointment { if constexpr (AppointmentStubs::HasSubject) { - return _pimpl->getSubject(std::move(params)); + return { _pimpl->getSubject(std::move(params)) }; } else { @@ -118,7 +118,7 @@ class Appointment { if constexpr (AppointmentStubs::HasIsNow) { - return _pimpl->getIsNow(std::move(params)); + return { _pimpl->getIsNow(std::move(params)) }; } else { @@ -130,7 +130,7 @@ class Appointment { if constexpr (AppointmentStubs::HasForceError) { - return _pimpl->getForceError(std::move(params)); + return { _pimpl->getForceError(std::move(params)) }; } else { diff --git a/samples/separate_nointrospection/CompleteTaskPayloadObject.h b/samples/separate_nointrospection/CompleteTaskPayloadObject.h index 9e180344..b4603d44 100644 --- a/samples/separate_nointrospection/CompleteTaskPayloadObject.h +++ b/samples/separate_nointrospection/CompleteTaskPayloadObject.h @@ -17,13 +17,13 @@ namespace CompleteTaskPayloadStubs { template concept HasTask = requires (TImpl impl, service::FieldParams params) { - { impl.getTask(std::move(params)) } -> std::convertible_to>>; + { service::FieldResult> { impl.getTask(std::move(params)) } }; }; template concept HasClientMutationId = requires (TImpl impl, service::FieldParams params) { - { impl.getClientMutationId(std::move(params)) } -> std::convertible_to>>; + { service::FieldResult> { impl.getClientMutationId(std::move(params)) } }; }; } // namespace CompleteTaskPayloadStubs @@ -58,7 +58,7 @@ class CompleteTaskPayload { if constexpr (CompleteTaskPayloadStubs::HasTask) { - return _pimpl->getTask(std::move(params)); + return { _pimpl->getTask(std::move(params)) }; } else { @@ -70,7 +70,7 @@ class CompleteTaskPayload { if constexpr (CompleteTaskPayloadStubs::HasClientMutationId) { - return _pimpl->getClientMutationId(std::move(params)); + return { _pimpl->getClientMutationId(std::move(params)) }; } else { diff --git a/samples/separate_nointrospection/ExpensiveObject.h b/samples/separate_nointrospection/ExpensiveObject.h index 8b151c0c..347cff6f 100644 --- a/samples/separate_nointrospection/ExpensiveObject.h +++ b/samples/separate_nointrospection/ExpensiveObject.h @@ -17,7 +17,7 @@ namespace ExpensiveStubs { template concept HasOrder = requires (TImpl impl, service::FieldParams params) { - { impl.getOrder(std::move(params)) } -> std::convertible_to>; + { service::FieldResult { impl.getOrder(std::move(params)) } }; }; } // namespace ExpensiveStubs @@ -50,7 +50,7 @@ class Expensive { if constexpr (ExpensiveStubs::HasOrder) { - return _pimpl->getOrder(std::move(params)); + return { _pimpl->getOrder(std::move(params)) }; } else { diff --git a/samples/separate_nointrospection/FolderConnectionObject.h b/samples/separate_nointrospection/FolderConnectionObject.h index f3a659bf..f7c88190 100644 --- a/samples/separate_nointrospection/FolderConnectionObject.h +++ b/samples/separate_nointrospection/FolderConnectionObject.h @@ -17,13 +17,13 @@ namespace FolderConnectionStubs { template concept HasPageInfo = requires (TImpl impl, service::FieldParams params) { - { impl.getPageInfo(std::move(params)) } -> std::convertible_to>>; + { service::FieldResult> { impl.getPageInfo(std::move(params)) } }; }; template concept HasEdges = requires (TImpl impl, service::FieldParams params) { - { impl.getEdges(std::move(params)) } -> std::convertible_to>>>>; + { service::FieldResult>>> { impl.getEdges(std::move(params)) } }; }; } // namespace FolderConnectionStubs @@ -58,7 +58,7 @@ class FolderConnection { if constexpr (FolderConnectionStubs::HasPageInfo) { - return _pimpl->getPageInfo(std::move(params)); + return { _pimpl->getPageInfo(std::move(params)) }; } else { @@ -70,7 +70,7 @@ class FolderConnection { if constexpr (FolderConnectionStubs::HasEdges) { - return _pimpl->getEdges(std::move(params)); + return { _pimpl->getEdges(std::move(params)) }; } else { diff --git a/samples/separate_nointrospection/FolderEdgeObject.h b/samples/separate_nointrospection/FolderEdgeObject.h index 9869c4a3..a089a110 100644 --- a/samples/separate_nointrospection/FolderEdgeObject.h +++ b/samples/separate_nointrospection/FolderEdgeObject.h @@ -17,13 +17,13 @@ namespace FolderEdgeStubs { template concept HasNode = requires (TImpl impl, service::FieldParams params) { - { impl.getNode(std::move(params)) } -> std::convertible_to>>; + { service::FieldResult> { impl.getNode(std::move(params)) } }; }; template concept HasCursor = requires (TImpl impl, service::FieldParams params) { - { impl.getCursor(std::move(params)) } -> std::convertible_to>; + { service::FieldResult { impl.getCursor(std::move(params)) } }; }; } // namespace FolderEdgeStubs @@ -58,7 +58,7 @@ class FolderEdge { if constexpr (FolderEdgeStubs::HasNode) { - return _pimpl->getNode(std::move(params)); + return { _pimpl->getNode(std::move(params)) }; } else { @@ -70,7 +70,7 @@ class FolderEdge { if constexpr (FolderEdgeStubs::HasCursor) { - return _pimpl->getCursor(std::move(params)); + return { _pimpl->getCursor(std::move(params)) }; } else { diff --git a/samples/separate_nointrospection/FolderObject.h b/samples/separate_nointrospection/FolderObject.h index f5601542..52414320 100644 --- a/samples/separate_nointrospection/FolderObject.h +++ b/samples/separate_nointrospection/FolderObject.h @@ -17,19 +17,19 @@ namespace FolderStubs { template concept HasId = requires (TImpl impl, service::FieldParams params) { - { impl.getId(std::move(params)) } -> std::convertible_to>; + { service::FieldResult { impl.getId(std::move(params)) } }; }; template concept HasName = requires (TImpl impl, service::FieldParams params) { - { impl.getName(std::move(params)) } -> std::convertible_to>>; + { service::FieldResult> { impl.getName(std::move(params)) } }; }; template concept HasUnreadCount = requires (TImpl impl, service::FieldParams params) { - { impl.getUnreadCount(std::move(params)) } -> std::convertible_to>; + { service::FieldResult { impl.getUnreadCount(std::move(params)) } }; }; } // namespace FolderStubs @@ -66,7 +66,7 @@ class Folder { if constexpr (FolderStubs::HasId) { - return _pimpl->getId(std::move(params)); + return { _pimpl->getId(std::move(params)) }; } else { @@ -78,7 +78,7 @@ class Folder { if constexpr (FolderStubs::HasName) { - return _pimpl->getName(std::move(params)); + return { _pimpl->getName(std::move(params)) }; } else { @@ -90,7 +90,7 @@ class Folder { if constexpr (FolderStubs::HasUnreadCount) { - return _pimpl->getUnreadCount(std::move(params)); + return { _pimpl->getUnreadCount(std::move(params)) }; } else { diff --git a/samples/separate_nointrospection/MutationObject.h b/samples/separate_nointrospection/MutationObject.h index 1371d2bd..fc34f52f 100644 --- a/samples/separate_nointrospection/MutationObject.h +++ b/samples/separate_nointrospection/MutationObject.h @@ -17,13 +17,13 @@ namespace MutationStubs { template concept HasCompleteTask = requires (TImpl impl, service::FieldParams params, CompleteTaskInput inputArg) { - { impl.applyCompleteTask(std::move(params), std::move(inputArg)) } -> std::convertible_to>>; + { service::FieldResult> { impl.applyCompleteTask(std::move(params), std::move(inputArg)) } }; }; template concept HasSetFloat = requires (TImpl impl, service::FieldParams params, response::FloatType valueArg) { - { impl.applySetFloat(std::move(params), std::move(valueArg)) } -> std::convertible_to>; + { service::FieldResult { impl.applySetFloat(std::move(params), std::move(valueArg)) } }; }; } // namespace MutationStubs @@ -58,7 +58,7 @@ class Mutation { if constexpr (MutationStubs::HasCompleteTask) { - return _pimpl->applyCompleteTask(std::move(params), std::move(inputArg)); + return { _pimpl->applyCompleteTask(std::move(params), std::move(inputArg)) }; } else { @@ -70,7 +70,7 @@ class Mutation { if constexpr (MutationStubs::HasSetFloat) { - return _pimpl->applySetFloat(std::move(params), std::move(valueArg)); + return { _pimpl->applySetFloat(std::move(params), std::move(valueArg)) }; } else { diff --git a/samples/separate_nointrospection/NestedTypeObject.h b/samples/separate_nointrospection/NestedTypeObject.h index a19f3095..3278036a 100644 --- a/samples/separate_nointrospection/NestedTypeObject.h +++ b/samples/separate_nointrospection/NestedTypeObject.h @@ -17,13 +17,13 @@ namespace NestedTypeStubs { template concept HasDepth = requires (TImpl impl, service::FieldParams params) { - { impl.getDepth(std::move(params)) } -> std::convertible_to>; + { service::FieldResult { impl.getDepth(std::move(params)) } }; }; template concept HasNested = requires (TImpl impl, service::FieldParams params) { - { impl.getNested(std::move(params)) } -> std::convertible_to>>; + { service::FieldResult> { impl.getNested(std::move(params)) } }; }; } // namespace NestedTypeStubs @@ -58,7 +58,7 @@ class NestedType { if constexpr (NestedTypeStubs::HasDepth) { - return _pimpl->getDepth(std::move(params)); + return { _pimpl->getDepth(std::move(params)) }; } else { @@ -70,7 +70,7 @@ class NestedType { if constexpr (NestedTypeStubs::HasNested) { - return _pimpl->getNested(std::move(params)); + return { _pimpl->getNested(std::move(params)) }; } else { diff --git a/samples/separate_nointrospection/PageInfoObject.h b/samples/separate_nointrospection/PageInfoObject.h index 6d5234ee..2f160b3c 100644 --- a/samples/separate_nointrospection/PageInfoObject.h +++ b/samples/separate_nointrospection/PageInfoObject.h @@ -17,13 +17,13 @@ namespace PageInfoStubs { template concept HasHasNextPage = requires (TImpl impl, service::FieldParams params) { - { impl.getHasNextPage(std::move(params)) } -> std::convertible_to>; + { service::FieldResult { impl.getHasNextPage(std::move(params)) } }; }; template concept HasHasPreviousPage = requires (TImpl impl, service::FieldParams params) { - { impl.getHasPreviousPage(std::move(params)) } -> std::convertible_to>; + { service::FieldResult { impl.getHasPreviousPage(std::move(params)) } }; }; } // namespace PageInfoStubs @@ -58,7 +58,7 @@ class PageInfo { if constexpr (PageInfoStubs::HasHasNextPage) { - return _pimpl->getHasNextPage(std::move(params)); + return { _pimpl->getHasNextPage(std::move(params)) }; } else { @@ -70,7 +70,7 @@ class PageInfo { if constexpr (PageInfoStubs::HasHasPreviousPage) { - return _pimpl->getHasPreviousPage(std::move(params)); + return { _pimpl->getHasPreviousPage(std::move(params)) }; } else { diff --git a/samples/separate_nointrospection/QueryObject.h b/samples/separate_nointrospection/QueryObject.h index ad396463..0a1db1d0 100644 --- a/samples/separate_nointrospection/QueryObject.h +++ b/samples/separate_nointrospection/QueryObject.h @@ -17,73 +17,73 @@ namespace QueryStubs { template concept HasNode = requires (TImpl impl, service::FieldParams params, response::IdType idArg) { - { impl.getNode(std::move(params), std::move(idArg)) } -> std::convertible_to>>; + { service::FieldResult> { impl.getNode(std::move(params), std::move(idArg)) } }; }; template concept HasAppointments = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) { - { impl.getAppointments(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } -> std::convertible_to>>; + { service::FieldResult> { impl.getAppointments(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; }; template concept HasTasks = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) { - { impl.getTasks(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } -> std::convertible_to>>; + { service::FieldResult> { impl.getTasks(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; }; template concept HasUnreadCounts = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) { - { impl.getUnreadCounts(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } -> std::convertible_to>>; + { service::FieldResult> { impl.getUnreadCounts(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; }; template concept HasAppointmentsById = requires (TImpl impl, service::FieldParams params, std::vector idsArg) { - { impl.getAppointmentsById(std::move(params), std::move(idsArg)) } -> std::convertible_to>>>; + { service::FieldResult>> { impl.getAppointmentsById(std::move(params), std::move(idsArg)) } }; }; template concept HasTasksById = requires (TImpl impl, service::FieldParams params, std::vector idsArg) { - { impl.getTasksById(std::move(params), std::move(idsArg)) } -> std::convertible_to>>>; + { service::FieldResult>> { impl.getTasksById(std::move(params), std::move(idsArg)) } }; }; template concept HasUnreadCountsById = requires (TImpl impl, service::FieldParams params, std::vector idsArg) { - { impl.getUnreadCountsById(std::move(params), std::move(idsArg)) } -> std::convertible_to>>>; + { service::FieldResult>> { impl.getUnreadCountsById(std::move(params), std::move(idsArg)) } }; }; template concept HasNested = requires (TImpl impl, service::FieldParams params) { - { impl.getNested(std::move(params)) } -> std::convertible_to>>; + { service::FieldResult> { impl.getNested(std::move(params)) } }; }; template concept HasUnimplemented = requires (TImpl impl, service::FieldParams params) { - { impl.getUnimplemented(std::move(params)) } -> std::convertible_to>; + { service::FieldResult { impl.getUnimplemented(std::move(params)) } }; }; template concept HasExpensive = requires (TImpl impl, service::FieldParams params) { - { impl.getExpensive(std::move(params)) } -> std::convertible_to>>>; + { service::FieldResult>> { impl.getExpensive(std::move(params)) } }; }; template concept HasTestTaskState = requires (TImpl impl, service::FieldParams params) { - { impl.getTestTaskState(std::move(params)) } -> std::convertible_to>; + { service::FieldResult { impl.getTestTaskState(std::move(params)) } }; }; template concept HasAnyType = requires (TImpl impl, service::FieldParams params, std::vector idsArg) { - { impl.getAnyType(std::move(params), std::move(idsArg)) } -> std::convertible_to>>>; + { service::FieldResult>> { impl.getAnyType(std::move(params), std::move(idsArg)) } }; }; } // namespace QueryStubs @@ -138,7 +138,7 @@ class Query { if constexpr (QueryStubs::HasNode) { - return _pimpl->getNode(std::move(params), std::move(idArg)); + return { _pimpl->getNode(std::move(params), std::move(idArg)) }; } else { @@ -150,7 +150,7 @@ class Query { if constexpr (QueryStubs::HasAppointments) { - return _pimpl->getAppointments(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)); + return { _pimpl->getAppointments(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) }; } else { @@ -162,7 +162,7 @@ class Query { if constexpr (QueryStubs::HasTasks) { - return _pimpl->getTasks(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)); + return { _pimpl->getTasks(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) }; } else { @@ -174,7 +174,7 @@ class Query { if constexpr (QueryStubs::HasUnreadCounts) { - return _pimpl->getUnreadCounts(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)); + return { _pimpl->getUnreadCounts(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) }; } else { @@ -186,7 +186,7 @@ class Query { if constexpr (QueryStubs::HasAppointmentsById) { - return _pimpl->getAppointmentsById(std::move(params), std::move(idsArg)); + return { _pimpl->getAppointmentsById(std::move(params), std::move(idsArg)) }; } else { @@ -198,7 +198,7 @@ class Query { if constexpr (QueryStubs::HasTasksById) { - return _pimpl->getTasksById(std::move(params), std::move(idsArg)); + return { _pimpl->getTasksById(std::move(params), std::move(idsArg)) }; } else { @@ -210,7 +210,7 @@ class Query { if constexpr (QueryStubs::HasUnreadCountsById) { - return _pimpl->getUnreadCountsById(std::move(params), std::move(idsArg)); + return { _pimpl->getUnreadCountsById(std::move(params), std::move(idsArg)) }; } else { @@ -222,7 +222,7 @@ class Query { if constexpr (QueryStubs::HasNested) { - return _pimpl->getNested(std::move(params)); + return { _pimpl->getNested(std::move(params)) }; } else { @@ -234,7 +234,7 @@ class Query { if constexpr (QueryStubs::HasUnimplemented) { - return _pimpl->getUnimplemented(std::move(params)); + return { _pimpl->getUnimplemented(std::move(params)) }; } else { @@ -246,7 +246,7 @@ class Query { if constexpr (QueryStubs::HasExpensive) { - return _pimpl->getExpensive(std::move(params)); + return { _pimpl->getExpensive(std::move(params)) }; } else { @@ -258,7 +258,7 @@ class Query { if constexpr (QueryStubs::HasTestTaskState) { - return _pimpl->getTestTaskState(std::move(params)); + return { _pimpl->getTestTaskState(std::move(params)) }; } else { @@ -270,7 +270,7 @@ class Query { if constexpr (QueryStubs::HasAnyType) { - return _pimpl->getAnyType(std::move(params), std::move(idsArg)); + return { _pimpl->getAnyType(std::move(params), std::move(idsArg)) }; } else { diff --git a/samples/separate_nointrospection/SubscriptionObject.h b/samples/separate_nointrospection/SubscriptionObject.h index ca36231f..62178ef9 100644 --- a/samples/separate_nointrospection/SubscriptionObject.h +++ b/samples/separate_nointrospection/SubscriptionObject.h @@ -17,13 +17,13 @@ namespace SubscriptionStubs { template concept HasNextAppointmentChange = requires (TImpl impl, service::FieldParams params) { - { impl.getNextAppointmentChange(std::move(params)) } -> std::convertible_to>>; + { service::FieldResult> { impl.getNextAppointmentChange(std::move(params)) } }; }; template concept HasNodeChange = requires (TImpl impl, service::FieldParams params, response::IdType idArg) { - { impl.getNodeChange(std::move(params), std::move(idArg)) } -> std::convertible_to>>; + { service::FieldResult> { impl.getNodeChange(std::move(params), std::move(idArg)) } }; }; } // namespace SubscriptionStubs @@ -58,7 +58,7 @@ class Subscription { if constexpr (SubscriptionStubs::HasNextAppointmentChange) { - return _pimpl->getNextAppointmentChange(std::move(params)); + return { _pimpl->getNextAppointmentChange(std::move(params)) }; } else { @@ -70,7 +70,7 @@ class Subscription { if constexpr (SubscriptionStubs::HasNodeChange) { - return _pimpl->getNodeChange(std::move(params), std::move(idArg)); + return { _pimpl->getNodeChange(std::move(params), std::move(idArg)) }; } else { diff --git a/samples/separate_nointrospection/TaskConnectionObject.h b/samples/separate_nointrospection/TaskConnectionObject.h index b4e4c037..50c78c1e 100644 --- a/samples/separate_nointrospection/TaskConnectionObject.h +++ b/samples/separate_nointrospection/TaskConnectionObject.h @@ -17,13 +17,13 @@ namespace TaskConnectionStubs { template concept HasPageInfo = requires (TImpl impl, service::FieldParams params) { - { impl.getPageInfo(std::move(params)) } -> std::convertible_to>>; + { service::FieldResult> { impl.getPageInfo(std::move(params)) } }; }; template concept HasEdges = requires (TImpl impl, service::FieldParams params) { - { impl.getEdges(std::move(params)) } -> std::convertible_to>>>>; + { service::FieldResult>>> { impl.getEdges(std::move(params)) } }; }; } // namespace TaskConnectionStubs @@ -58,7 +58,7 @@ class TaskConnection { if constexpr (TaskConnectionStubs::HasPageInfo) { - return _pimpl->getPageInfo(std::move(params)); + return { _pimpl->getPageInfo(std::move(params)) }; } else { @@ -70,7 +70,7 @@ class TaskConnection { if constexpr (TaskConnectionStubs::HasEdges) { - return _pimpl->getEdges(std::move(params)); + return { _pimpl->getEdges(std::move(params)) }; } else { diff --git a/samples/separate_nointrospection/TaskEdgeObject.h b/samples/separate_nointrospection/TaskEdgeObject.h index 815a2097..fd5e1556 100644 --- a/samples/separate_nointrospection/TaskEdgeObject.h +++ b/samples/separate_nointrospection/TaskEdgeObject.h @@ -17,13 +17,13 @@ namespace TaskEdgeStubs { template concept HasNode = requires (TImpl impl, service::FieldParams params) { - { impl.getNode(std::move(params)) } -> std::convertible_to>>; + { service::FieldResult> { impl.getNode(std::move(params)) } }; }; template concept HasCursor = requires (TImpl impl, service::FieldParams params) { - { impl.getCursor(std::move(params)) } -> std::convertible_to>; + { service::FieldResult { impl.getCursor(std::move(params)) } }; }; } // namespace TaskEdgeStubs @@ -58,7 +58,7 @@ class TaskEdge { if constexpr (TaskEdgeStubs::HasNode) { - return _pimpl->getNode(std::move(params)); + return { _pimpl->getNode(std::move(params)) }; } else { @@ -70,7 +70,7 @@ class TaskEdge { if constexpr (TaskEdgeStubs::HasCursor) { - return _pimpl->getCursor(std::move(params)); + return { _pimpl->getCursor(std::move(params)) }; } else { diff --git a/samples/separate_nointrospection/TaskObject.h b/samples/separate_nointrospection/TaskObject.h index 78413875..0cbb17b6 100644 --- a/samples/separate_nointrospection/TaskObject.h +++ b/samples/separate_nointrospection/TaskObject.h @@ -17,19 +17,19 @@ namespace TaskStubs { template concept HasId = requires (TImpl impl, service::FieldParams params) { - { impl.getId(std::move(params)) } -> std::convertible_to>; + { service::FieldResult { impl.getId(std::move(params)) } }; }; template concept HasTitle = requires (TImpl impl, service::FieldParams params) { - { impl.getTitle(std::move(params)) } -> std::convertible_to>>; + { service::FieldResult> { impl.getTitle(std::move(params)) } }; }; template concept HasIsComplete = requires (TImpl impl, service::FieldParams params) { - { impl.getIsComplete(std::move(params)) } -> std::convertible_to>; + { service::FieldResult { impl.getIsComplete(std::move(params)) } }; }; } // namespace TaskStubs @@ -66,7 +66,7 @@ class Task { if constexpr (TaskStubs::HasId) { - return _pimpl->getId(std::move(params)); + return { _pimpl->getId(std::move(params)) }; } else { @@ -78,7 +78,7 @@ class Task { if constexpr (TaskStubs::HasTitle) { - return _pimpl->getTitle(std::move(params)); + return { _pimpl->getTitle(std::move(params)) }; } else { @@ -90,7 +90,7 @@ class Task { if constexpr (TaskStubs::HasIsComplete) { - return _pimpl->getIsComplete(std::move(params)); + return { _pimpl->getIsComplete(std::move(params)) }; } else { diff --git a/samples/separate_nointrospection/TodaySchema.h b/samples/separate_nointrospection/TodaySchema.h index 7514ae28..9f979a6e 100644 --- a/samples/separate_nointrospection/TodaySchema.h +++ b/samples/separate_nointrospection/TodaySchema.h @@ -14,7 +14,6 @@ static_assert(graphql::internal::MajorVersion == 4, "regenerate with schemagen: major version mismatch"); static_assert(graphql::internal::MinorVersion == 0, "regenerate with schemagen: minor version mismatch"); -#include #include #include #include diff --git a/samples/unified/TodaySchema.h b/samples/unified/TodaySchema.h index bd7a90ee..06ccb574 100644 --- a/samples/unified/TodaySchema.h +++ b/samples/unified/TodaySchema.h @@ -14,7 +14,6 @@ static_assert(graphql::internal::MajorVersion == 4, "regenerate with schemagen: major version mismatch"); static_assert(graphql::internal::MinorVersion == 0, "regenerate with schemagen: minor version mismatch"); -#include #include #include #include @@ -94,73 +93,73 @@ namespace QueryStubs { template concept HasNode = requires (TImpl impl, service::FieldParams params, response::IdType idArg) { - { impl.getNode(std::move(params), std::move(idArg)) } -> std::convertible_to>>; + { service::FieldResult> { impl.getNode(std::move(params), std::move(idArg)) } }; }; template concept HasAppointments = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) { - { impl.getAppointments(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } -> std::convertible_to>>; + { service::FieldResult> { impl.getAppointments(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; }; template concept HasTasks = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) { - { impl.getTasks(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } -> std::convertible_to>>; + { service::FieldResult> { impl.getTasks(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; }; template concept HasUnreadCounts = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) { - { impl.getUnreadCounts(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } -> std::convertible_to>>; + { service::FieldResult> { impl.getUnreadCounts(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; }; template concept HasAppointmentsById = requires (TImpl impl, service::FieldParams params, std::vector idsArg) { - { impl.getAppointmentsById(std::move(params), std::move(idsArg)) } -> std::convertible_to>>>; + { service::FieldResult>> { impl.getAppointmentsById(std::move(params), std::move(idsArg)) } }; }; template concept HasTasksById = requires (TImpl impl, service::FieldParams params, std::vector idsArg) { - { impl.getTasksById(std::move(params), std::move(idsArg)) } -> std::convertible_to>>>; + { service::FieldResult>> { impl.getTasksById(std::move(params), std::move(idsArg)) } }; }; template concept HasUnreadCountsById = requires (TImpl impl, service::FieldParams params, std::vector idsArg) { - { impl.getUnreadCountsById(std::move(params), std::move(idsArg)) } -> std::convertible_to>>>; + { service::FieldResult>> { impl.getUnreadCountsById(std::move(params), std::move(idsArg)) } }; }; template concept HasNested = requires (TImpl impl, service::FieldParams params) { - { impl.getNested(std::move(params)) } -> std::convertible_to>>; + { service::FieldResult> { impl.getNested(std::move(params)) } }; }; template concept HasUnimplemented = requires (TImpl impl, service::FieldParams params) { - { impl.getUnimplemented(std::move(params)) } -> std::convertible_to>; + { service::FieldResult { impl.getUnimplemented(std::move(params)) } }; }; template concept HasExpensive = requires (TImpl impl, service::FieldParams params) { - { impl.getExpensive(std::move(params)) } -> std::convertible_to>>>; + { service::FieldResult>> { impl.getExpensive(std::move(params)) } }; }; template concept HasTestTaskState = requires (TImpl impl, service::FieldParams params) { - { impl.getTestTaskState(std::move(params)) } -> std::convertible_to>; + { service::FieldResult { impl.getTestTaskState(std::move(params)) } }; }; template concept HasAnyType = requires (TImpl impl, service::FieldParams params, std::vector idsArg) { - { impl.getAnyType(std::move(params), std::move(idsArg)) } -> std::convertible_to>>>; + { service::FieldResult>> { impl.getAnyType(std::move(params), std::move(idsArg)) } }; }; } // namespace QueryStubs @@ -219,7 +218,7 @@ class Query { if constexpr (QueryStubs::HasNode) { - return _pimpl->getNode(std::move(params), std::move(idArg)); + return { _pimpl->getNode(std::move(params), std::move(idArg)) }; } else { @@ -231,7 +230,7 @@ class Query { if constexpr (QueryStubs::HasAppointments) { - return _pimpl->getAppointments(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)); + return { _pimpl->getAppointments(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) }; } else { @@ -243,7 +242,7 @@ class Query { if constexpr (QueryStubs::HasTasks) { - return _pimpl->getTasks(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)); + return { _pimpl->getTasks(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) }; } else { @@ -255,7 +254,7 @@ class Query { if constexpr (QueryStubs::HasUnreadCounts) { - return _pimpl->getUnreadCounts(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)); + return { _pimpl->getUnreadCounts(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) }; } else { @@ -267,7 +266,7 @@ class Query { if constexpr (QueryStubs::HasAppointmentsById) { - return _pimpl->getAppointmentsById(std::move(params), std::move(idsArg)); + return { _pimpl->getAppointmentsById(std::move(params), std::move(idsArg)) }; } else { @@ -279,7 +278,7 @@ class Query { if constexpr (QueryStubs::HasTasksById) { - return _pimpl->getTasksById(std::move(params), std::move(idsArg)); + return { _pimpl->getTasksById(std::move(params), std::move(idsArg)) }; } else { @@ -291,7 +290,7 @@ class Query { if constexpr (QueryStubs::HasUnreadCountsById) { - return _pimpl->getUnreadCountsById(std::move(params), std::move(idsArg)); + return { _pimpl->getUnreadCountsById(std::move(params), std::move(idsArg)) }; } else { @@ -303,7 +302,7 @@ class Query { if constexpr (QueryStubs::HasNested) { - return _pimpl->getNested(std::move(params)); + return { _pimpl->getNested(std::move(params)) }; } else { @@ -315,7 +314,7 @@ class Query { if constexpr (QueryStubs::HasUnimplemented) { - return _pimpl->getUnimplemented(std::move(params)); + return { _pimpl->getUnimplemented(std::move(params)) }; } else { @@ -327,7 +326,7 @@ class Query { if constexpr (QueryStubs::HasExpensive) { - return _pimpl->getExpensive(std::move(params)); + return { _pimpl->getExpensive(std::move(params)) }; } else { @@ -339,7 +338,7 @@ class Query { if constexpr (QueryStubs::HasTestTaskState) { - return _pimpl->getTestTaskState(std::move(params)); + return { _pimpl->getTestTaskState(std::move(params)) }; } else { @@ -351,7 +350,7 @@ class Query { if constexpr (QueryStubs::HasAnyType) { - return _pimpl->getAnyType(std::move(params), std::move(idsArg)); + return { _pimpl->getAnyType(std::move(params), std::move(idsArg)) }; } else { @@ -380,13 +379,13 @@ namespace PageInfoStubs { template concept HasHasNextPage = requires (TImpl impl, service::FieldParams params) { - { impl.getHasNextPage(std::move(params)) } -> std::convertible_to>; + { service::FieldResult { impl.getHasNextPage(std::move(params)) } }; }; template concept HasHasPreviousPage = requires (TImpl impl, service::FieldParams params) { - { impl.getHasPreviousPage(std::move(params)) } -> std::convertible_to>; + { service::FieldResult { impl.getHasPreviousPage(std::move(params)) } }; }; } // namespace PageInfoStubs @@ -421,7 +420,7 @@ class PageInfo { if constexpr (PageInfoStubs::HasHasNextPage) { - return _pimpl->getHasNextPage(std::move(params)); + return { _pimpl->getHasNextPage(std::move(params)) }; } else { @@ -433,7 +432,7 @@ class PageInfo { if constexpr (PageInfoStubs::HasHasPreviousPage) { - return _pimpl->getHasPreviousPage(std::move(params)); + return { _pimpl->getHasPreviousPage(std::move(params)) }; } else { @@ -462,13 +461,13 @@ namespace AppointmentEdgeStubs { template concept HasNode = requires (TImpl impl, service::FieldParams params) { - { impl.getNode(std::move(params)) } -> std::convertible_to>>; + { service::FieldResult> { impl.getNode(std::move(params)) } }; }; template concept HasCursor = requires (TImpl impl, service::FieldParams params) { - { impl.getCursor(std::move(params)) } -> std::convertible_to>; + { service::FieldResult { impl.getCursor(std::move(params)) } }; }; } // namespace AppointmentEdgeStubs @@ -503,7 +502,7 @@ class AppointmentEdge { if constexpr (AppointmentEdgeStubs::HasNode) { - return _pimpl->getNode(std::move(params)); + return { _pimpl->getNode(std::move(params)) }; } else { @@ -515,7 +514,7 @@ class AppointmentEdge { if constexpr (AppointmentEdgeStubs::HasCursor) { - return _pimpl->getCursor(std::move(params)); + return { _pimpl->getCursor(std::move(params)) }; } else { @@ -544,13 +543,13 @@ namespace AppointmentConnectionStubs { template concept HasPageInfo = requires (TImpl impl, service::FieldParams params) { - { impl.getPageInfo(std::move(params)) } -> std::convertible_to>>; + { service::FieldResult> { impl.getPageInfo(std::move(params)) } }; }; template concept HasEdges = requires (TImpl impl, service::FieldParams params) { - { impl.getEdges(std::move(params)) } -> std::convertible_to>>>>; + { service::FieldResult>>> { impl.getEdges(std::move(params)) } }; }; } // namespace AppointmentConnectionStubs @@ -585,7 +584,7 @@ class AppointmentConnection { if constexpr (AppointmentConnectionStubs::HasPageInfo) { - return _pimpl->getPageInfo(std::move(params)); + return { _pimpl->getPageInfo(std::move(params)) }; } else { @@ -597,7 +596,7 @@ class AppointmentConnection { if constexpr (AppointmentConnectionStubs::HasEdges) { - return _pimpl->getEdges(std::move(params)); + return { _pimpl->getEdges(std::move(params)) }; } else { @@ -626,13 +625,13 @@ namespace TaskEdgeStubs { template concept HasNode = requires (TImpl impl, service::FieldParams params) { - { impl.getNode(std::move(params)) } -> std::convertible_to>>; + { service::FieldResult> { impl.getNode(std::move(params)) } }; }; template concept HasCursor = requires (TImpl impl, service::FieldParams params) { - { impl.getCursor(std::move(params)) } -> std::convertible_to>; + { service::FieldResult { impl.getCursor(std::move(params)) } }; }; } // namespace TaskEdgeStubs @@ -667,7 +666,7 @@ class TaskEdge { if constexpr (TaskEdgeStubs::HasNode) { - return _pimpl->getNode(std::move(params)); + return { _pimpl->getNode(std::move(params)) }; } else { @@ -679,7 +678,7 @@ class TaskEdge { if constexpr (TaskEdgeStubs::HasCursor) { - return _pimpl->getCursor(std::move(params)); + return { _pimpl->getCursor(std::move(params)) }; } else { @@ -708,13 +707,13 @@ namespace TaskConnectionStubs { template concept HasPageInfo = requires (TImpl impl, service::FieldParams params) { - { impl.getPageInfo(std::move(params)) } -> std::convertible_to>>; + { service::FieldResult> { impl.getPageInfo(std::move(params)) } }; }; template concept HasEdges = requires (TImpl impl, service::FieldParams params) { - { impl.getEdges(std::move(params)) } -> std::convertible_to>>>>; + { service::FieldResult>>> { impl.getEdges(std::move(params)) } }; }; } // namespace TaskConnectionStubs @@ -749,7 +748,7 @@ class TaskConnection { if constexpr (TaskConnectionStubs::HasPageInfo) { - return _pimpl->getPageInfo(std::move(params)); + return { _pimpl->getPageInfo(std::move(params)) }; } else { @@ -761,7 +760,7 @@ class TaskConnection { if constexpr (TaskConnectionStubs::HasEdges) { - return _pimpl->getEdges(std::move(params)); + return { _pimpl->getEdges(std::move(params)) }; } else { @@ -790,13 +789,13 @@ namespace FolderEdgeStubs { template concept HasNode = requires (TImpl impl, service::FieldParams params) { - { impl.getNode(std::move(params)) } -> std::convertible_to>>; + { service::FieldResult> { impl.getNode(std::move(params)) } }; }; template concept HasCursor = requires (TImpl impl, service::FieldParams params) { - { impl.getCursor(std::move(params)) } -> std::convertible_to>; + { service::FieldResult { impl.getCursor(std::move(params)) } }; }; } // namespace FolderEdgeStubs @@ -831,7 +830,7 @@ class FolderEdge { if constexpr (FolderEdgeStubs::HasNode) { - return _pimpl->getNode(std::move(params)); + return { _pimpl->getNode(std::move(params)) }; } else { @@ -843,7 +842,7 @@ class FolderEdge { if constexpr (FolderEdgeStubs::HasCursor) { - return _pimpl->getCursor(std::move(params)); + return { _pimpl->getCursor(std::move(params)) }; } else { @@ -872,13 +871,13 @@ namespace FolderConnectionStubs { template concept HasPageInfo = requires (TImpl impl, service::FieldParams params) { - { impl.getPageInfo(std::move(params)) } -> std::convertible_to>>; + { service::FieldResult> { impl.getPageInfo(std::move(params)) } }; }; template concept HasEdges = requires (TImpl impl, service::FieldParams params) { - { impl.getEdges(std::move(params)) } -> std::convertible_to>>>>; + { service::FieldResult>>> { impl.getEdges(std::move(params)) } }; }; } // namespace FolderConnectionStubs @@ -913,7 +912,7 @@ class FolderConnection { if constexpr (FolderConnectionStubs::HasPageInfo) { - return _pimpl->getPageInfo(std::move(params)); + return { _pimpl->getPageInfo(std::move(params)) }; } else { @@ -925,7 +924,7 @@ class FolderConnection { if constexpr (FolderConnectionStubs::HasEdges) { - return _pimpl->getEdges(std::move(params)); + return { _pimpl->getEdges(std::move(params)) }; } else { @@ -954,13 +953,13 @@ namespace CompleteTaskPayloadStubs { template concept HasTask = requires (TImpl impl, service::FieldParams params) { - { impl.getTask(std::move(params)) } -> std::convertible_to>>; + { service::FieldResult> { impl.getTask(std::move(params)) } }; }; template concept HasClientMutationId = requires (TImpl impl, service::FieldParams params) { - { impl.getClientMutationId(std::move(params)) } -> std::convertible_to>>; + { service::FieldResult> { impl.getClientMutationId(std::move(params)) } }; }; } // namespace CompleteTaskPayloadStubs @@ -995,7 +994,7 @@ class CompleteTaskPayload { if constexpr (CompleteTaskPayloadStubs::HasTask) { - return _pimpl->getTask(std::move(params)); + return { _pimpl->getTask(std::move(params)) }; } else { @@ -1007,7 +1006,7 @@ class CompleteTaskPayload { if constexpr (CompleteTaskPayloadStubs::HasClientMutationId) { - return _pimpl->getClientMutationId(std::move(params)); + return { _pimpl->getClientMutationId(std::move(params)) }; } else { @@ -1036,13 +1035,13 @@ namespace MutationStubs { template concept HasCompleteTask = requires (TImpl impl, service::FieldParams params, CompleteTaskInput inputArg) { - { impl.applyCompleteTask(std::move(params), std::move(inputArg)) } -> std::convertible_to>>; + { service::FieldResult> { impl.applyCompleteTask(std::move(params), std::move(inputArg)) } }; }; template concept HasSetFloat = requires (TImpl impl, service::FieldParams params, response::FloatType valueArg) { - { impl.applySetFloat(std::move(params), std::move(valueArg)) } -> std::convertible_to>; + { service::FieldResult { impl.applySetFloat(std::move(params), std::move(valueArg)) } }; }; } // namespace MutationStubs @@ -1077,7 +1076,7 @@ class Mutation { if constexpr (MutationStubs::HasCompleteTask) { - return _pimpl->applyCompleteTask(std::move(params), std::move(inputArg)); + return { _pimpl->applyCompleteTask(std::move(params), std::move(inputArg)) }; } else { @@ -1089,7 +1088,7 @@ class Mutation { if constexpr (MutationStubs::HasSetFloat) { - return _pimpl->applySetFloat(std::move(params), std::move(valueArg)); + return { _pimpl->applySetFloat(std::move(params), std::move(valueArg)) }; } else { @@ -1118,13 +1117,13 @@ namespace SubscriptionStubs { template concept HasNextAppointmentChange = requires (TImpl impl, service::FieldParams params) { - { impl.getNextAppointmentChange(std::move(params)) } -> std::convertible_to>>; + { service::FieldResult> { impl.getNextAppointmentChange(std::move(params)) } }; }; template concept HasNodeChange = requires (TImpl impl, service::FieldParams params, response::IdType idArg) { - { impl.getNodeChange(std::move(params), std::move(idArg)) } -> std::convertible_to>>; + { service::FieldResult> { impl.getNodeChange(std::move(params), std::move(idArg)) } }; }; } // namespace SubscriptionStubs @@ -1159,7 +1158,7 @@ class Subscription { if constexpr (SubscriptionStubs::HasNextAppointmentChange) { - return _pimpl->getNextAppointmentChange(std::move(params)); + return { _pimpl->getNextAppointmentChange(std::move(params)) }; } else { @@ -1171,7 +1170,7 @@ class Subscription { if constexpr (SubscriptionStubs::HasNodeChange) { - return _pimpl->getNodeChange(std::move(params), std::move(idArg)); + return { _pimpl->getNodeChange(std::move(params), std::move(idArg)) }; } else { @@ -1200,31 +1199,31 @@ namespace AppointmentStubs { template concept HasId = requires (TImpl impl, service::FieldParams params) { - { impl.getId(std::move(params)) } -> std::convertible_to>; + { service::FieldResult { impl.getId(std::move(params)) } }; }; template concept HasWhen = requires (TImpl impl, service::FieldParams params) { - { impl.getWhen(std::move(params)) } -> std::convertible_to>>; + { service::FieldResult> { impl.getWhen(std::move(params)) } }; }; template concept HasSubject = requires (TImpl impl, service::FieldParams params) { - { impl.getSubject(std::move(params)) } -> std::convertible_to>>; + { service::FieldResult> { impl.getSubject(std::move(params)) } }; }; template concept HasIsNow = requires (TImpl impl, service::FieldParams params) { - { impl.getIsNow(std::move(params)) } -> std::convertible_to>; + { service::FieldResult { impl.getIsNow(std::move(params)) } }; }; template concept HasForceError = requires (TImpl impl, service::FieldParams params) { - { impl.getForceError(std::move(params)) } -> std::convertible_to>>; + { service::FieldResult> { impl.getForceError(std::move(params)) } }; }; } // namespace AppointmentStubs @@ -1265,7 +1264,7 @@ class Appointment { if constexpr (AppointmentStubs::HasId) { - return _pimpl->getId(std::move(params)); + return { _pimpl->getId(std::move(params)) }; } else { @@ -1277,7 +1276,7 @@ class Appointment { if constexpr (AppointmentStubs::HasWhen) { - return _pimpl->getWhen(std::move(params)); + return { _pimpl->getWhen(std::move(params)) }; } else { @@ -1289,7 +1288,7 @@ class Appointment { if constexpr (AppointmentStubs::HasSubject) { - return _pimpl->getSubject(std::move(params)); + return { _pimpl->getSubject(std::move(params)) }; } else { @@ -1301,7 +1300,7 @@ class Appointment { if constexpr (AppointmentStubs::HasIsNow) { - return _pimpl->getIsNow(std::move(params)); + return { _pimpl->getIsNow(std::move(params)) }; } else { @@ -1313,7 +1312,7 @@ class Appointment { if constexpr (AppointmentStubs::HasForceError) { - return _pimpl->getForceError(std::move(params)); + return { _pimpl->getForceError(std::move(params)) }; } else { @@ -1342,19 +1341,19 @@ namespace TaskStubs { template concept HasId = requires (TImpl impl, service::FieldParams params) { - { impl.getId(std::move(params)) } -> std::convertible_to>; + { service::FieldResult { impl.getId(std::move(params)) } }; }; template concept HasTitle = requires (TImpl impl, service::FieldParams params) { - { impl.getTitle(std::move(params)) } -> std::convertible_to>>; + { service::FieldResult> { impl.getTitle(std::move(params)) } }; }; template concept HasIsComplete = requires (TImpl impl, service::FieldParams params) { - { impl.getIsComplete(std::move(params)) } -> std::convertible_to>; + { service::FieldResult { impl.getIsComplete(std::move(params)) } }; }; } // namespace TaskStubs @@ -1391,7 +1390,7 @@ class Task { if constexpr (TaskStubs::HasId) { - return _pimpl->getId(std::move(params)); + return { _pimpl->getId(std::move(params)) }; } else { @@ -1403,7 +1402,7 @@ class Task { if constexpr (TaskStubs::HasTitle) { - return _pimpl->getTitle(std::move(params)); + return { _pimpl->getTitle(std::move(params)) }; } else { @@ -1415,7 +1414,7 @@ class Task { if constexpr (TaskStubs::HasIsComplete) { - return _pimpl->getIsComplete(std::move(params)); + return { _pimpl->getIsComplete(std::move(params)) }; } else { @@ -1444,19 +1443,19 @@ namespace FolderStubs { template concept HasId = requires (TImpl impl, service::FieldParams params) { - { impl.getId(std::move(params)) } -> std::convertible_to>; + { service::FieldResult { impl.getId(std::move(params)) } }; }; template concept HasName = requires (TImpl impl, service::FieldParams params) { - { impl.getName(std::move(params)) } -> std::convertible_to>>; + { service::FieldResult> { impl.getName(std::move(params)) } }; }; template concept HasUnreadCount = requires (TImpl impl, service::FieldParams params) { - { impl.getUnreadCount(std::move(params)) } -> std::convertible_to>; + { service::FieldResult { impl.getUnreadCount(std::move(params)) } }; }; } // namespace FolderStubs @@ -1493,7 +1492,7 @@ class Folder { if constexpr (FolderStubs::HasId) { - return _pimpl->getId(std::move(params)); + return { _pimpl->getId(std::move(params)) }; } else { @@ -1505,7 +1504,7 @@ class Folder { if constexpr (FolderStubs::HasName) { - return _pimpl->getName(std::move(params)); + return { _pimpl->getName(std::move(params)) }; } else { @@ -1517,7 +1516,7 @@ class Folder { if constexpr (FolderStubs::HasUnreadCount) { - return _pimpl->getUnreadCount(std::move(params)); + return { _pimpl->getUnreadCount(std::move(params)) }; } else { @@ -1546,13 +1545,13 @@ namespace NestedTypeStubs { template concept HasDepth = requires (TImpl impl, service::FieldParams params) { - { impl.getDepth(std::move(params)) } -> std::convertible_to>; + { service::FieldResult { impl.getDepth(std::move(params)) } }; }; template concept HasNested = requires (TImpl impl, service::FieldParams params) { - { impl.getNested(std::move(params)) } -> std::convertible_to>>; + { service::FieldResult> { impl.getNested(std::move(params)) } }; }; } // namespace NestedTypeStubs @@ -1587,7 +1586,7 @@ class NestedType { if constexpr (NestedTypeStubs::HasDepth) { - return _pimpl->getDepth(std::move(params)); + return { _pimpl->getDepth(std::move(params)) }; } else { @@ -1599,7 +1598,7 @@ class NestedType { if constexpr (NestedTypeStubs::HasNested) { - return _pimpl->getNested(std::move(params)); + return { _pimpl->getNested(std::move(params)) }; } else { @@ -1628,7 +1627,7 @@ namespace ExpensiveStubs { template concept HasOrder = requires (TImpl impl, service::FieldParams params) { - { impl.getOrder(std::move(params)) } -> std::convertible_to>; + { service::FieldResult { impl.getOrder(std::move(params)) } }; }; } // namespace ExpensiveStubs @@ -1661,7 +1660,7 @@ class Expensive { if constexpr (ExpensiveStubs::HasOrder) { - return _pimpl->getOrder(std::move(params)); + return { _pimpl->getOrder(std::move(params)) }; } else { diff --git a/samples/unified_nointrospection/TodaySchema.h b/samples/unified_nointrospection/TodaySchema.h index 13dacce3..94e36c42 100644 --- a/samples/unified_nointrospection/TodaySchema.h +++ b/samples/unified_nointrospection/TodaySchema.h @@ -14,7 +14,6 @@ static_assert(graphql::internal::MajorVersion == 4, "regenerate with schemagen: major version mismatch"); static_assert(graphql::internal::MinorVersion == 0, "regenerate with schemagen: minor version mismatch"); -#include #include #include #include @@ -94,73 +93,73 @@ namespace QueryStubs { template concept HasNode = requires (TImpl impl, service::FieldParams params, response::IdType idArg) { - { impl.getNode(std::move(params), std::move(idArg)) } -> std::convertible_to>>; + { service::FieldResult> { impl.getNode(std::move(params), std::move(idArg)) } }; }; template concept HasAppointments = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) { - { impl.getAppointments(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } -> std::convertible_to>>; + { service::FieldResult> { impl.getAppointments(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; }; template concept HasTasks = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) { - { impl.getTasks(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } -> std::convertible_to>>; + { service::FieldResult> { impl.getTasks(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; }; template concept HasUnreadCounts = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) { - { impl.getUnreadCounts(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } -> std::convertible_to>>; + { service::FieldResult> { impl.getUnreadCounts(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; }; template concept HasAppointmentsById = requires (TImpl impl, service::FieldParams params, std::vector idsArg) { - { impl.getAppointmentsById(std::move(params), std::move(idsArg)) } -> std::convertible_to>>>; + { service::FieldResult>> { impl.getAppointmentsById(std::move(params), std::move(idsArg)) } }; }; template concept HasTasksById = requires (TImpl impl, service::FieldParams params, std::vector idsArg) { - { impl.getTasksById(std::move(params), std::move(idsArg)) } -> std::convertible_to>>>; + { service::FieldResult>> { impl.getTasksById(std::move(params), std::move(idsArg)) } }; }; template concept HasUnreadCountsById = requires (TImpl impl, service::FieldParams params, std::vector idsArg) { - { impl.getUnreadCountsById(std::move(params), std::move(idsArg)) } -> std::convertible_to>>>; + { service::FieldResult>> { impl.getUnreadCountsById(std::move(params), std::move(idsArg)) } }; }; template concept HasNested = requires (TImpl impl, service::FieldParams params) { - { impl.getNested(std::move(params)) } -> std::convertible_to>>; + { service::FieldResult> { impl.getNested(std::move(params)) } }; }; template concept HasUnimplemented = requires (TImpl impl, service::FieldParams params) { - { impl.getUnimplemented(std::move(params)) } -> std::convertible_to>; + { service::FieldResult { impl.getUnimplemented(std::move(params)) } }; }; template concept HasExpensive = requires (TImpl impl, service::FieldParams params) { - { impl.getExpensive(std::move(params)) } -> std::convertible_to>>>; + { service::FieldResult>> { impl.getExpensive(std::move(params)) } }; }; template concept HasTestTaskState = requires (TImpl impl, service::FieldParams params) { - { impl.getTestTaskState(std::move(params)) } -> std::convertible_to>; + { service::FieldResult { impl.getTestTaskState(std::move(params)) } }; }; template concept HasAnyType = requires (TImpl impl, service::FieldParams params, std::vector idsArg) { - { impl.getAnyType(std::move(params), std::move(idsArg)) } -> std::convertible_to>>>; + { service::FieldResult>> { impl.getAnyType(std::move(params), std::move(idsArg)) } }; }; } // namespace QueryStubs @@ -215,7 +214,7 @@ class Query { if constexpr (QueryStubs::HasNode) { - return _pimpl->getNode(std::move(params), std::move(idArg)); + return { _pimpl->getNode(std::move(params), std::move(idArg)) }; } else { @@ -227,7 +226,7 @@ class Query { if constexpr (QueryStubs::HasAppointments) { - return _pimpl->getAppointments(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)); + return { _pimpl->getAppointments(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) }; } else { @@ -239,7 +238,7 @@ class Query { if constexpr (QueryStubs::HasTasks) { - return _pimpl->getTasks(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)); + return { _pimpl->getTasks(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) }; } else { @@ -251,7 +250,7 @@ class Query { if constexpr (QueryStubs::HasUnreadCounts) { - return _pimpl->getUnreadCounts(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)); + return { _pimpl->getUnreadCounts(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) }; } else { @@ -263,7 +262,7 @@ class Query { if constexpr (QueryStubs::HasAppointmentsById) { - return _pimpl->getAppointmentsById(std::move(params), std::move(idsArg)); + return { _pimpl->getAppointmentsById(std::move(params), std::move(idsArg)) }; } else { @@ -275,7 +274,7 @@ class Query { if constexpr (QueryStubs::HasTasksById) { - return _pimpl->getTasksById(std::move(params), std::move(idsArg)); + return { _pimpl->getTasksById(std::move(params), std::move(idsArg)) }; } else { @@ -287,7 +286,7 @@ class Query { if constexpr (QueryStubs::HasUnreadCountsById) { - return _pimpl->getUnreadCountsById(std::move(params), std::move(idsArg)); + return { _pimpl->getUnreadCountsById(std::move(params), std::move(idsArg)) }; } else { @@ -299,7 +298,7 @@ class Query { if constexpr (QueryStubs::HasNested) { - return _pimpl->getNested(std::move(params)); + return { _pimpl->getNested(std::move(params)) }; } else { @@ -311,7 +310,7 @@ class Query { if constexpr (QueryStubs::HasUnimplemented) { - return _pimpl->getUnimplemented(std::move(params)); + return { _pimpl->getUnimplemented(std::move(params)) }; } else { @@ -323,7 +322,7 @@ class Query { if constexpr (QueryStubs::HasExpensive) { - return _pimpl->getExpensive(std::move(params)); + return { _pimpl->getExpensive(std::move(params)) }; } else { @@ -335,7 +334,7 @@ class Query { if constexpr (QueryStubs::HasTestTaskState) { - return _pimpl->getTestTaskState(std::move(params)); + return { _pimpl->getTestTaskState(std::move(params)) }; } else { @@ -347,7 +346,7 @@ class Query { if constexpr (QueryStubs::HasAnyType) { - return _pimpl->getAnyType(std::move(params), std::move(idsArg)); + return { _pimpl->getAnyType(std::move(params), std::move(idsArg)) }; } else { @@ -376,13 +375,13 @@ namespace PageInfoStubs { template concept HasHasNextPage = requires (TImpl impl, service::FieldParams params) { - { impl.getHasNextPage(std::move(params)) } -> std::convertible_to>; + { service::FieldResult { impl.getHasNextPage(std::move(params)) } }; }; template concept HasHasPreviousPage = requires (TImpl impl, service::FieldParams params) { - { impl.getHasPreviousPage(std::move(params)) } -> std::convertible_to>; + { service::FieldResult { impl.getHasPreviousPage(std::move(params)) } }; }; } // namespace PageInfoStubs @@ -417,7 +416,7 @@ class PageInfo { if constexpr (PageInfoStubs::HasHasNextPage) { - return _pimpl->getHasNextPage(std::move(params)); + return { _pimpl->getHasNextPage(std::move(params)) }; } else { @@ -429,7 +428,7 @@ class PageInfo { if constexpr (PageInfoStubs::HasHasPreviousPage) { - return _pimpl->getHasPreviousPage(std::move(params)); + return { _pimpl->getHasPreviousPage(std::move(params)) }; } else { @@ -458,13 +457,13 @@ namespace AppointmentEdgeStubs { template concept HasNode = requires (TImpl impl, service::FieldParams params) { - { impl.getNode(std::move(params)) } -> std::convertible_to>>; + { service::FieldResult> { impl.getNode(std::move(params)) } }; }; template concept HasCursor = requires (TImpl impl, service::FieldParams params) { - { impl.getCursor(std::move(params)) } -> std::convertible_to>; + { service::FieldResult { impl.getCursor(std::move(params)) } }; }; } // namespace AppointmentEdgeStubs @@ -499,7 +498,7 @@ class AppointmentEdge { if constexpr (AppointmentEdgeStubs::HasNode) { - return _pimpl->getNode(std::move(params)); + return { _pimpl->getNode(std::move(params)) }; } else { @@ -511,7 +510,7 @@ class AppointmentEdge { if constexpr (AppointmentEdgeStubs::HasCursor) { - return _pimpl->getCursor(std::move(params)); + return { _pimpl->getCursor(std::move(params)) }; } else { @@ -540,13 +539,13 @@ namespace AppointmentConnectionStubs { template concept HasPageInfo = requires (TImpl impl, service::FieldParams params) { - { impl.getPageInfo(std::move(params)) } -> std::convertible_to>>; + { service::FieldResult> { impl.getPageInfo(std::move(params)) } }; }; template concept HasEdges = requires (TImpl impl, service::FieldParams params) { - { impl.getEdges(std::move(params)) } -> std::convertible_to>>>>; + { service::FieldResult>>> { impl.getEdges(std::move(params)) } }; }; } // namespace AppointmentConnectionStubs @@ -581,7 +580,7 @@ class AppointmentConnection { if constexpr (AppointmentConnectionStubs::HasPageInfo) { - return _pimpl->getPageInfo(std::move(params)); + return { _pimpl->getPageInfo(std::move(params)) }; } else { @@ -593,7 +592,7 @@ class AppointmentConnection { if constexpr (AppointmentConnectionStubs::HasEdges) { - return _pimpl->getEdges(std::move(params)); + return { _pimpl->getEdges(std::move(params)) }; } else { @@ -622,13 +621,13 @@ namespace TaskEdgeStubs { template concept HasNode = requires (TImpl impl, service::FieldParams params) { - { impl.getNode(std::move(params)) } -> std::convertible_to>>; + { service::FieldResult> { impl.getNode(std::move(params)) } }; }; template concept HasCursor = requires (TImpl impl, service::FieldParams params) { - { impl.getCursor(std::move(params)) } -> std::convertible_to>; + { service::FieldResult { impl.getCursor(std::move(params)) } }; }; } // namespace TaskEdgeStubs @@ -663,7 +662,7 @@ class TaskEdge { if constexpr (TaskEdgeStubs::HasNode) { - return _pimpl->getNode(std::move(params)); + return { _pimpl->getNode(std::move(params)) }; } else { @@ -675,7 +674,7 @@ class TaskEdge { if constexpr (TaskEdgeStubs::HasCursor) { - return _pimpl->getCursor(std::move(params)); + return { _pimpl->getCursor(std::move(params)) }; } else { @@ -704,13 +703,13 @@ namespace TaskConnectionStubs { template concept HasPageInfo = requires (TImpl impl, service::FieldParams params) { - { impl.getPageInfo(std::move(params)) } -> std::convertible_to>>; + { service::FieldResult> { impl.getPageInfo(std::move(params)) } }; }; template concept HasEdges = requires (TImpl impl, service::FieldParams params) { - { impl.getEdges(std::move(params)) } -> std::convertible_to>>>>; + { service::FieldResult>>> { impl.getEdges(std::move(params)) } }; }; } // namespace TaskConnectionStubs @@ -745,7 +744,7 @@ class TaskConnection { if constexpr (TaskConnectionStubs::HasPageInfo) { - return _pimpl->getPageInfo(std::move(params)); + return { _pimpl->getPageInfo(std::move(params)) }; } else { @@ -757,7 +756,7 @@ class TaskConnection { if constexpr (TaskConnectionStubs::HasEdges) { - return _pimpl->getEdges(std::move(params)); + return { _pimpl->getEdges(std::move(params)) }; } else { @@ -786,13 +785,13 @@ namespace FolderEdgeStubs { template concept HasNode = requires (TImpl impl, service::FieldParams params) { - { impl.getNode(std::move(params)) } -> std::convertible_to>>; + { service::FieldResult> { impl.getNode(std::move(params)) } }; }; template concept HasCursor = requires (TImpl impl, service::FieldParams params) { - { impl.getCursor(std::move(params)) } -> std::convertible_to>; + { service::FieldResult { impl.getCursor(std::move(params)) } }; }; } // namespace FolderEdgeStubs @@ -827,7 +826,7 @@ class FolderEdge { if constexpr (FolderEdgeStubs::HasNode) { - return _pimpl->getNode(std::move(params)); + return { _pimpl->getNode(std::move(params)) }; } else { @@ -839,7 +838,7 @@ class FolderEdge { if constexpr (FolderEdgeStubs::HasCursor) { - return _pimpl->getCursor(std::move(params)); + return { _pimpl->getCursor(std::move(params)) }; } else { @@ -868,13 +867,13 @@ namespace FolderConnectionStubs { template concept HasPageInfo = requires (TImpl impl, service::FieldParams params) { - { impl.getPageInfo(std::move(params)) } -> std::convertible_to>>; + { service::FieldResult> { impl.getPageInfo(std::move(params)) } }; }; template concept HasEdges = requires (TImpl impl, service::FieldParams params) { - { impl.getEdges(std::move(params)) } -> std::convertible_to>>>>; + { service::FieldResult>>> { impl.getEdges(std::move(params)) } }; }; } // namespace FolderConnectionStubs @@ -909,7 +908,7 @@ class FolderConnection { if constexpr (FolderConnectionStubs::HasPageInfo) { - return _pimpl->getPageInfo(std::move(params)); + return { _pimpl->getPageInfo(std::move(params)) }; } else { @@ -921,7 +920,7 @@ class FolderConnection { if constexpr (FolderConnectionStubs::HasEdges) { - return _pimpl->getEdges(std::move(params)); + return { _pimpl->getEdges(std::move(params)) }; } else { @@ -950,13 +949,13 @@ namespace CompleteTaskPayloadStubs { template concept HasTask = requires (TImpl impl, service::FieldParams params) { - { impl.getTask(std::move(params)) } -> std::convertible_to>>; + { service::FieldResult> { impl.getTask(std::move(params)) } }; }; template concept HasClientMutationId = requires (TImpl impl, service::FieldParams params) { - { impl.getClientMutationId(std::move(params)) } -> std::convertible_to>>; + { service::FieldResult> { impl.getClientMutationId(std::move(params)) } }; }; } // namespace CompleteTaskPayloadStubs @@ -991,7 +990,7 @@ class CompleteTaskPayload { if constexpr (CompleteTaskPayloadStubs::HasTask) { - return _pimpl->getTask(std::move(params)); + return { _pimpl->getTask(std::move(params)) }; } else { @@ -1003,7 +1002,7 @@ class CompleteTaskPayload { if constexpr (CompleteTaskPayloadStubs::HasClientMutationId) { - return _pimpl->getClientMutationId(std::move(params)); + return { _pimpl->getClientMutationId(std::move(params)) }; } else { @@ -1032,13 +1031,13 @@ namespace MutationStubs { template concept HasCompleteTask = requires (TImpl impl, service::FieldParams params, CompleteTaskInput inputArg) { - { impl.applyCompleteTask(std::move(params), std::move(inputArg)) } -> std::convertible_to>>; + { service::FieldResult> { impl.applyCompleteTask(std::move(params), std::move(inputArg)) } }; }; template concept HasSetFloat = requires (TImpl impl, service::FieldParams params, response::FloatType valueArg) { - { impl.applySetFloat(std::move(params), std::move(valueArg)) } -> std::convertible_to>; + { service::FieldResult { impl.applySetFloat(std::move(params), std::move(valueArg)) } }; }; } // namespace MutationStubs @@ -1073,7 +1072,7 @@ class Mutation { if constexpr (MutationStubs::HasCompleteTask) { - return _pimpl->applyCompleteTask(std::move(params), std::move(inputArg)); + return { _pimpl->applyCompleteTask(std::move(params), std::move(inputArg)) }; } else { @@ -1085,7 +1084,7 @@ class Mutation { if constexpr (MutationStubs::HasSetFloat) { - return _pimpl->applySetFloat(std::move(params), std::move(valueArg)); + return { _pimpl->applySetFloat(std::move(params), std::move(valueArg)) }; } else { @@ -1114,13 +1113,13 @@ namespace SubscriptionStubs { template concept HasNextAppointmentChange = requires (TImpl impl, service::FieldParams params) { - { impl.getNextAppointmentChange(std::move(params)) } -> std::convertible_to>>; + { service::FieldResult> { impl.getNextAppointmentChange(std::move(params)) } }; }; template concept HasNodeChange = requires (TImpl impl, service::FieldParams params, response::IdType idArg) { - { impl.getNodeChange(std::move(params), std::move(idArg)) } -> std::convertible_to>>; + { service::FieldResult> { impl.getNodeChange(std::move(params), std::move(idArg)) } }; }; } // namespace SubscriptionStubs @@ -1155,7 +1154,7 @@ class Subscription { if constexpr (SubscriptionStubs::HasNextAppointmentChange) { - return _pimpl->getNextAppointmentChange(std::move(params)); + return { _pimpl->getNextAppointmentChange(std::move(params)) }; } else { @@ -1167,7 +1166,7 @@ class Subscription { if constexpr (SubscriptionStubs::HasNodeChange) { - return _pimpl->getNodeChange(std::move(params), std::move(idArg)); + return { _pimpl->getNodeChange(std::move(params), std::move(idArg)) }; } else { @@ -1196,31 +1195,31 @@ namespace AppointmentStubs { template concept HasId = requires (TImpl impl, service::FieldParams params) { - { impl.getId(std::move(params)) } -> std::convertible_to>; + { service::FieldResult { impl.getId(std::move(params)) } }; }; template concept HasWhen = requires (TImpl impl, service::FieldParams params) { - { impl.getWhen(std::move(params)) } -> std::convertible_to>>; + { service::FieldResult> { impl.getWhen(std::move(params)) } }; }; template concept HasSubject = requires (TImpl impl, service::FieldParams params) { - { impl.getSubject(std::move(params)) } -> std::convertible_to>>; + { service::FieldResult> { impl.getSubject(std::move(params)) } }; }; template concept HasIsNow = requires (TImpl impl, service::FieldParams params) { - { impl.getIsNow(std::move(params)) } -> std::convertible_to>; + { service::FieldResult { impl.getIsNow(std::move(params)) } }; }; template concept HasForceError = requires (TImpl impl, service::FieldParams params) { - { impl.getForceError(std::move(params)) } -> std::convertible_to>>; + { service::FieldResult> { impl.getForceError(std::move(params)) } }; }; } // namespace AppointmentStubs @@ -1261,7 +1260,7 @@ class Appointment { if constexpr (AppointmentStubs::HasId) { - return _pimpl->getId(std::move(params)); + return { _pimpl->getId(std::move(params)) }; } else { @@ -1273,7 +1272,7 @@ class Appointment { if constexpr (AppointmentStubs::HasWhen) { - return _pimpl->getWhen(std::move(params)); + return { _pimpl->getWhen(std::move(params)) }; } else { @@ -1285,7 +1284,7 @@ class Appointment { if constexpr (AppointmentStubs::HasSubject) { - return _pimpl->getSubject(std::move(params)); + return { _pimpl->getSubject(std::move(params)) }; } else { @@ -1297,7 +1296,7 @@ class Appointment { if constexpr (AppointmentStubs::HasIsNow) { - return _pimpl->getIsNow(std::move(params)); + return { _pimpl->getIsNow(std::move(params)) }; } else { @@ -1309,7 +1308,7 @@ class Appointment { if constexpr (AppointmentStubs::HasForceError) { - return _pimpl->getForceError(std::move(params)); + return { _pimpl->getForceError(std::move(params)) }; } else { @@ -1338,19 +1337,19 @@ namespace TaskStubs { template concept HasId = requires (TImpl impl, service::FieldParams params) { - { impl.getId(std::move(params)) } -> std::convertible_to>; + { service::FieldResult { impl.getId(std::move(params)) } }; }; template concept HasTitle = requires (TImpl impl, service::FieldParams params) { - { impl.getTitle(std::move(params)) } -> std::convertible_to>>; + { service::FieldResult> { impl.getTitle(std::move(params)) } }; }; template concept HasIsComplete = requires (TImpl impl, service::FieldParams params) { - { impl.getIsComplete(std::move(params)) } -> std::convertible_to>; + { service::FieldResult { impl.getIsComplete(std::move(params)) } }; }; } // namespace TaskStubs @@ -1387,7 +1386,7 @@ class Task { if constexpr (TaskStubs::HasId) { - return _pimpl->getId(std::move(params)); + return { _pimpl->getId(std::move(params)) }; } else { @@ -1399,7 +1398,7 @@ class Task { if constexpr (TaskStubs::HasTitle) { - return _pimpl->getTitle(std::move(params)); + return { _pimpl->getTitle(std::move(params)) }; } else { @@ -1411,7 +1410,7 @@ class Task { if constexpr (TaskStubs::HasIsComplete) { - return _pimpl->getIsComplete(std::move(params)); + return { _pimpl->getIsComplete(std::move(params)) }; } else { @@ -1440,19 +1439,19 @@ namespace FolderStubs { template concept HasId = requires (TImpl impl, service::FieldParams params) { - { impl.getId(std::move(params)) } -> std::convertible_to>; + { service::FieldResult { impl.getId(std::move(params)) } }; }; template concept HasName = requires (TImpl impl, service::FieldParams params) { - { impl.getName(std::move(params)) } -> std::convertible_to>>; + { service::FieldResult> { impl.getName(std::move(params)) } }; }; template concept HasUnreadCount = requires (TImpl impl, service::FieldParams params) { - { impl.getUnreadCount(std::move(params)) } -> std::convertible_to>; + { service::FieldResult { impl.getUnreadCount(std::move(params)) } }; }; } // namespace FolderStubs @@ -1489,7 +1488,7 @@ class Folder { if constexpr (FolderStubs::HasId) { - return _pimpl->getId(std::move(params)); + return { _pimpl->getId(std::move(params)) }; } else { @@ -1501,7 +1500,7 @@ class Folder { if constexpr (FolderStubs::HasName) { - return _pimpl->getName(std::move(params)); + return { _pimpl->getName(std::move(params)) }; } else { @@ -1513,7 +1512,7 @@ class Folder { if constexpr (FolderStubs::HasUnreadCount) { - return _pimpl->getUnreadCount(std::move(params)); + return { _pimpl->getUnreadCount(std::move(params)) }; } else { @@ -1542,13 +1541,13 @@ namespace NestedTypeStubs { template concept HasDepth = requires (TImpl impl, service::FieldParams params) { - { impl.getDepth(std::move(params)) } -> std::convertible_to>; + { service::FieldResult { impl.getDepth(std::move(params)) } }; }; template concept HasNested = requires (TImpl impl, service::FieldParams params) { - { impl.getNested(std::move(params)) } -> std::convertible_to>>; + { service::FieldResult> { impl.getNested(std::move(params)) } }; }; } // namespace NestedTypeStubs @@ -1583,7 +1582,7 @@ class NestedType { if constexpr (NestedTypeStubs::HasDepth) { - return _pimpl->getDepth(std::move(params)); + return { _pimpl->getDepth(std::move(params)) }; } else { @@ -1595,7 +1594,7 @@ class NestedType { if constexpr (NestedTypeStubs::HasNested) { - return _pimpl->getNested(std::move(params)); + return { _pimpl->getNested(std::move(params)) }; } else { @@ -1624,7 +1623,7 @@ namespace ExpensiveStubs { template concept HasOrder = requires (TImpl impl, service::FieldParams params) { - { impl.getOrder(std::move(params)) } -> std::convertible_to>; + { service::FieldResult { impl.getOrder(std::move(params)) } }; }; } // namespace ExpensiveStubs @@ -1657,7 +1656,7 @@ class Expensive { if constexpr (ExpensiveStubs::HasOrder) { - return _pimpl->getOrder(std::move(params)); + return { _pimpl->getOrder(std::move(params)) }; } else { diff --git a/samples/validation/ValidationSchema.h b/samples/validation/ValidationSchema.h index 16253133..c918f0ee 100644 --- a/samples/validation/ValidationSchema.h +++ b/samples/validation/ValidationSchema.h @@ -14,7 +14,6 @@ static_assert(graphql::internal::MajorVersion == 4, "regenerate with schemagen: major version mismatch"); static_assert(graphql::internal::MinorVersion == 0, "regenerate with schemagen: minor version mismatch"); -#include #include #include #include @@ -75,43 +74,43 @@ namespace QueryStubs { template concept HasDog = requires (TImpl impl, service::FieldParams params) { - { impl.getDog(std::move(params)) } -> std::convertible_to>>; + { service::FieldResult> { impl.getDog(std::move(params)) } }; }; template concept HasHuman = requires (TImpl impl, service::FieldParams params) { - { impl.getHuman(std::move(params)) } -> std::convertible_to>>; + { service::FieldResult> { impl.getHuman(std::move(params)) } }; }; template concept HasPet = requires (TImpl impl, service::FieldParams params) { - { impl.getPet(std::move(params)) } -> std::convertible_to>>; + { service::FieldResult> { impl.getPet(std::move(params)) } }; }; template concept HasCatOrDog = requires (TImpl impl, service::FieldParams params) { - { impl.getCatOrDog(std::move(params)) } -> std::convertible_to>>; + { service::FieldResult> { impl.getCatOrDog(std::move(params)) } }; }; template concept HasArguments = requires (TImpl impl, service::FieldParams params) { - { impl.getArguments(std::move(params)) } -> std::convertible_to>>; + { service::FieldResult> { impl.getArguments(std::move(params)) } }; }; template concept HasFindDog = requires (TImpl impl, service::FieldParams params, std::optional complexArg) { - { impl.getFindDog(std::move(params), std::move(complexArg)) } -> std::convertible_to>>; + { service::FieldResult> { impl.getFindDog(std::move(params), std::move(complexArg)) } }; }; template concept HasBooleanList = requires (TImpl impl, service::FieldParams params, std::optional> booleanListArgArg) { - { impl.getBooleanList(std::move(params), std::move(booleanListArgArg)) } -> std::convertible_to>>; + { service::FieldResult> { impl.getBooleanList(std::move(params), std::move(booleanListArgArg)) } }; }; } // namespace QueryStubs @@ -160,7 +159,7 @@ class Query { if constexpr (QueryStubs::HasDog) { - return _pimpl->getDog(std::move(params)); + return { _pimpl->getDog(std::move(params)) }; } else { @@ -172,7 +171,7 @@ class Query { if constexpr (QueryStubs::HasHuman) { - return _pimpl->getHuman(std::move(params)); + return { _pimpl->getHuman(std::move(params)) }; } else { @@ -184,7 +183,7 @@ class Query { if constexpr (QueryStubs::HasPet) { - return _pimpl->getPet(std::move(params)); + return { _pimpl->getPet(std::move(params)) }; } else { @@ -196,7 +195,7 @@ class Query { if constexpr (QueryStubs::HasCatOrDog) { - return _pimpl->getCatOrDog(std::move(params)); + return { _pimpl->getCatOrDog(std::move(params)) }; } else { @@ -208,7 +207,7 @@ class Query { if constexpr (QueryStubs::HasArguments) { - return _pimpl->getArguments(std::move(params)); + return { _pimpl->getArguments(std::move(params)) }; } else { @@ -220,7 +219,7 @@ class Query { if constexpr (QueryStubs::HasFindDog) { - return _pimpl->getFindDog(std::move(params), std::move(complexArg)); + return { _pimpl->getFindDog(std::move(params), std::move(complexArg)) }; } else { @@ -232,7 +231,7 @@ class Query { if constexpr (QueryStubs::HasBooleanList) { - return _pimpl->getBooleanList(std::move(params), std::move(booleanListArgArg)); + return { _pimpl->getBooleanList(std::move(params), std::move(booleanListArgArg)) }; } else { @@ -261,37 +260,37 @@ namespace DogStubs { template concept HasName = requires (TImpl impl, service::FieldParams params) { - { impl.getName(std::move(params)) } -> std::convertible_to>; + { service::FieldResult { impl.getName(std::move(params)) } }; }; template concept HasNickname = requires (TImpl impl, service::FieldParams params) { - { impl.getNickname(std::move(params)) } -> std::convertible_to>>; + { service::FieldResult> { impl.getNickname(std::move(params)) } }; }; template concept HasBarkVolume = requires (TImpl impl, service::FieldParams params) { - { impl.getBarkVolume(std::move(params)) } -> std::convertible_to>>; + { service::FieldResult> { impl.getBarkVolume(std::move(params)) } }; }; template concept HasDoesKnowCommand = requires (TImpl impl, service::FieldParams params, DogCommand dogCommandArg) { - { impl.getDoesKnowCommand(std::move(params), std::move(dogCommandArg)) } -> std::convertible_to>; + { service::FieldResult { impl.getDoesKnowCommand(std::move(params), std::move(dogCommandArg)) } }; }; template concept HasIsHousetrained = requires (TImpl impl, service::FieldParams params, std::optional atOtherHomesArg) { - { impl.getIsHousetrained(std::move(params), std::move(atOtherHomesArg)) } -> std::convertible_to>; + { service::FieldResult { impl.getIsHousetrained(std::move(params), std::move(atOtherHomesArg)) } }; }; template concept HasOwner = requires (TImpl impl, service::FieldParams params) { - { impl.getOwner(std::move(params)) } -> std::convertible_to>>; + { service::FieldResult> { impl.getOwner(std::move(params)) } }; }; } // namespace DogStubs @@ -334,7 +333,7 @@ class Dog { if constexpr (DogStubs::HasName) { - return _pimpl->getName(std::move(params)); + return { _pimpl->getName(std::move(params)) }; } else { @@ -346,7 +345,7 @@ class Dog { if constexpr (DogStubs::HasNickname) { - return _pimpl->getNickname(std::move(params)); + return { _pimpl->getNickname(std::move(params)) }; } else { @@ -358,7 +357,7 @@ class Dog { if constexpr (DogStubs::HasBarkVolume) { - return _pimpl->getBarkVolume(std::move(params)); + return { _pimpl->getBarkVolume(std::move(params)) }; } else { @@ -370,7 +369,7 @@ class Dog { if constexpr (DogStubs::HasDoesKnowCommand) { - return _pimpl->getDoesKnowCommand(std::move(params), std::move(dogCommandArg)); + return { _pimpl->getDoesKnowCommand(std::move(params), std::move(dogCommandArg)) }; } else { @@ -382,7 +381,7 @@ class Dog { if constexpr (DogStubs::HasIsHousetrained) { - return _pimpl->getIsHousetrained(std::move(params), std::move(atOtherHomesArg)); + return { _pimpl->getIsHousetrained(std::move(params), std::move(atOtherHomesArg)) }; } else { @@ -394,7 +393,7 @@ class Dog { if constexpr (DogStubs::HasOwner) { - return _pimpl->getOwner(std::move(params)); + return { _pimpl->getOwner(std::move(params)) }; } else { @@ -423,13 +422,13 @@ namespace AlienStubs { template concept HasName = requires (TImpl impl, service::FieldParams params) { - { impl.getName(std::move(params)) } -> std::convertible_to>; + { service::FieldResult { impl.getName(std::move(params)) } }; }; template concept HasHomePlanet = requires (TImpl impl, service::FieldParams params) { - { impl.getHomePlanet(std::move(params)) } -> std::convertible_to>>; + { service::FieldResult> { impl.getHomePlanet(std::move(params)) } }; }; } // namespace AlienStubs @@ -464,7 +463,7 @@ class Alien { if constexpr (AlienStubs::HasName) { - return _pimpl->getName(std::move(params)); + return { _pimpl->getName(std::move(params)) }; } else { @@ -476,7 +475,7 @@ class Alien { if constexpr (AlienStubs::HasHomePlanet) { - return _pimpl->getHomePlanet(std::move(params)); + return { _pimpl->getHomePlanet(std::move(params)) }; } else { @@ -505,13 +504,13 @@ namespace HumanStubs { template concept HasName = requires (TImpl impl, service::FieldParams params) { - { impl.getName(std::move(params)) } -> std::convertible_to>; + { service::FieldResult { impl.getName(std::move(params)) } }; }; template concept HasPets = requires (TImpl impl, service::FieldParams params) { - { impl.getPets(std::move(params)) } -> std::convertible_to>>>; + { service::FieldResult>> { impl.getPets(std::move(params)) } }; }; } // namespace HumanStubs @@ -546,7 +545,7 @@ class Human { if constexpr (HumanStubs::HasName) { - return _pimpl->getName(std::move(params)); + return { _pimpl->getName(std::move(params)) }; } else { @@ -558,7 +557,7 @@ class Human { if constexpr (HumanStubs::HasPets) { - return _pimpl->getPets(std::move(params)); + return { _pimpl->getPets(std::move(params)) }; } else { @@ -587,25 +586,25 @@ namespace CatStubs { template concept HasName = requires (TImpl impl, service::FieldParams params) { - { impl.getName(std::move(params)) } -> std::convertible_to>; + { service::FieldResult { impl.getName(std::move(params)) } }; }; template concept HasNickname = requires (TImpl impl, service::FieldParams params) { - { impl.getNickname(std::move(params)) } -> std::convertible_to>>; + { service::FieldResult> { impl.getNickname(std::move(params)) } }; }; template concept HasDoesKnowCommand = requires (TImpl impl, service::FieldParams params, CatCommand catCommandArg) { - { impl.getDoesKnowCommand(std::move(params), std::move(catCommandArg)) } -> std::convertible_to>; + { service::FieldResult { impl.getDoesKnowCommand(std::move(params), std::move(catCommandArg)) } }; }; template concept HasMeowVolume = requires (TImpl impl, service::FieldParams params) { - { impl.getMeowVolume(std::move(params)) } -> std::convertible_to>>; + { service::FieldResult> { impl.getMeowVolume(std::move(params)) } }; }; } // namespace CatStubs @@ -644,7 +643,7 @@ class Cat { if constexpr (CatStubs::HasName) { - return _pimpl->getName(std::move(params)); + return { _pimpl->getName(std::move(params)) }; } else { @@ -656,7 +655,7 @@ class Cat { if constexpr (CatStubs::HasNickname) { - return _pimpl->getNickname(std::move(params)); + return { _pimpl->getNickname(std::move(params)) }; } else { @@ -668,7 +667,7 @@ class Cat { if constexpr (CatStubs::HasDoesKnowCommand) { - return _pimpl->getDoesKnowCommand(std::move(params), std::move(catCommandArg)); + return { _pimpl->getDoesKnowCommand(std::move(params), std::move(catCommandArg)) }; } else { @@ -680,7 +679,7 @@ class Cat { if constexpr (CatStubs::HasMeowVolume) { - return _pimpl->getMeowVolume(std::move(params)); + return { _pimpl->getMeowVolume(std::move(params)) }; } else { @@ -709,7 +708,7 @@ namespace MutationStubs { template concept HasMutateDog = requires (TImpl impl, service::FieldParams params) { - { impl.applyMutateDog(std::move(params)) } -> std::convertible_to>>; + { service::FieldResult> { impl.applyMutateDog(std::move(params)) } }; }; } // namespace MutationStubs @@ -742,7 +741,7 @@ class Mutation { if constexpr (MutationStubs::HasMutateDog) { - return _pimpl->applyMutateDog(std::move(params)); + return { _pimpl->applyMutateDog(std::move(params)) }; } else { @@ -771,7 +770,7 @@ namespace MutateDogResultStubs { template concept HasId = requires (TImpl impl, service::FieldParams params) { - { impl.getId(std::move(params)) } -> std::convertible_to>; + { service::FieldResult { impl.getId(std::move(params)) } }; }; } // namespace MutateDogResultStubs @@ -804,7 +803,7 @@ class MutateDogResult { if constexpr (MutateDogResultStubs::HasId) { - return _pimpl->getId(std::move(params)); + return { _pimpl->getId(std::move(params)) }; } else { @@ -833,13 +832,13 @@ namespace SubscriptionStubs { template concept HasNewMessage = requires (TImpl impl, service::FieldParams params) { - { impl.getNewMessage(std::move(params)) } -> std::convertible_to>>; + { service::FieldResult> { impl.getNewMessage(std::move(params)) } }; }; template concept HasDisallowedSecondRootField = requires (TImpl impl, service::FieldParams params) { - { impl.getDisallowedSecondRootField(std::move(params)) } -> std::convertible_to>; + { service::FieldResult { impl.getDisallowedSecondRootField(std::move(params)) } }; }; } // namespace SubscriptionStubs @@ -874,7 +873,7 @@ class Subscription { if constexpr (SubscriptionStubs::HasNewMessage) { - return _pimpl->getNewMessage(std::move(params)); + return { _pimpl->getNewMessage(std::move(params)) }; } else { @@ -886,7 +885,7 @@ class Subscription { if constexpr (SubscriptionStubs::HasDisallowedSecondRootField) { - return _pimpl->getDisallowedSecondRootField(std::move(params)); + return { _pimpl->getDisallowedSecondRootField(std::move(params)) }; } else { @@ -915,13 +914,13 @@ namespace MessageStubs { template concept HasBody = requires (TImpl impl, service::FieldParams params) { - { impl.getBody(std::move(params)) } -> std::convertible_to>>; + { service::FieldResult> { impl.getBody(std::move(params)) } }; }; template concept HasSender = requires (TImpl impl, service::FieldParams params) { - { impl.getSender(std::move(params)) } -> std::convertible_to>; + { service::FieldResult { impl.getSender(std::move(params)) } }; }; } // namespace MessageStubs @@ -956,7 +955,7 @@ class Message { if constexpr (MessageStubs::HasBody) { - return _pimpl->getBody(std::move(params)); + return { _pimpl->getBody(std::move(params)) }; } else { @@ -968,7 +967,7 @@ class Message { if constexpr (MessageStubs::HasSender) { - return _pimpl->getSender(std::move(params)); + return { _pimpl->getSender(std::move(params)) }; } else { @@ -997,49 +996,49 @@ namespace ArgumentsStubs { template concept HasMultipleReqs = requires (TImpl impl, service::FieldParams params, response::IntType xArg, response::IntType yArg) { - { impl.getMultipleReqs(std::move(params), std::move(xArg), std::move(yArg)) } -> std::convertible_to>; + { service::FieldResult { impl.getMultipleReqs(std::move(params), std::move(xArg), std::move(yArg)) } }; }; template concept HasBooleanArgField = requires (TImpl impl, service::FieldParams params, std::optional booleanArgArg) { - { impl.getBooleanArgField(std::move(params), std::move(booleanArgArg)) } -> std::convertible_to>>; + { service::FieldResult> { impl.getBooleanArgField(std::move(params), std::move(booleanArgArg)) } }; }; template concept HasFloatArgField = requires (TImpl impl, service::FieldParams params, std::optional floatArgArg) { - { impl.getFloatArgField(std::move(params), std::move(floatArgArg)) } -> std::convertible_to>>; + { service::FieldResult> { impl.getFloatArgField(std::move(params), std::move(floatArgArg)) } }; }; template concept HasIntArgField = requires (TImpl impl, service::FieldParams params, std::optional intArgArg) { - { impl.getIntArgField(std::move(params), std::move(intArgArg)) } -> std::convertible_to>>; + { service::FieldResult> { impl.getIntArgField(std::move(params), std::move(intArgArg)) } }; }; template concept HasNonNullBooleanArgField = requires (TImpl impl, service::FieldParams params, response::BooleanType nonNullBooleanArgArg) { - { impl.getNonNullBooleanArgField(std::move(params), std::move(nonNullBooleanArgArg)) } -> std::convertible_to>; + { service::FieldResult { impl.getNonNullBooleanArgField(std::move(params), std::move(nonNullBooleanArgArg)) } }; }; template concept HasNonNullBooleanListField = requires (TImpl impl, service::FieldParams params, std::optional> nonNullBooleanListArgArg) { - { impl.getNonNullBooleanListField(std::move(params), std::move(nonNullBooleanListArgArg)) } -> std::convertible_to>>>; + { service::FieldResult>> { impl.getNonNullBooleanListField(std::move(params), std::move(nonNullBooleanListArgArg)) } }; }; template concept HasBooleanListArgField = requires (TImpl impl, service::FieldParams params, std::vector> booleanListArgArg) { - { impl.getBooleanListArgField(std::move(params), std::move(booleanListArgArg)) } -> std::convertible_to>>>>; + { service::FieldResult>>> { impl.getBooleanListArgField(std::move(params), std::move(booleanListArgArg)) } }; }; template concept HasOptionalNonNullBooleanArgField = requires (TImpl impl, service::FieldParams params, response::BooleanType optionalBooleanArgArg) { - { impl.getOptionalNonNullBooleanArgField(std::move(params), std::move(optionalBooleanArgArg)) } -> std::convertible_to>; + { service::FieldResult { impl.getOptionalNonNullBooleanArgField(std::move(params), std::move(optionalBooleanArgArg)) } }; }; } // namespace ArgumentsStubs @@ -1086,7 +1085,7 @@ class Arguments { if constexpr (ArgumentsStubs::HasMultipleReqs) { - return _pimpl->getMultipleReqs(std::move(params), std::move(xArg), std::move(yArg)); + return { _pimpl->getMultipleReqs(std::move(params), std::move(xArg), std::move(yArg)) }; } else { @@ -1098,7 +1097,7 @@ class Arguments { if constexpr (ArgumentsStubs::HasBooleanArgField) { - return _pimpl->getBooleanArgField(std::move(params), std::move(booleanArgArg)); + return { _pimpl->getBooleanArgField(std::move(params), std::move(booleanArgArg)) }; } else { @@ -1110,7 +1109,7 @@ class Arguments { if constexpr (ArgumentsStubs::HasFloatArgField) { - return _pimpl->getFloatArgField(std::move(params), std::move(floatArgArg)); + return { _pimpl->getFloatArgField(std::move(params), std::move(floatArgArg)) }; } else { @@ -1122,7 +1121,7 @@ class Arguments { if constexpr (ArgumentsStubs::HasIntArgField) { - return _pimpl->getIntArgField(std::move(params), std::move(intArgArg)); + return { _pimpl->getIntArgField(std::move(params), std::move(intArgArg)) }; } else { @@ -1134,7 +1133,7 @@ class Arguments { if constexpr (ArgumentsStubs::HasNonNullBooleanArgField) { - return _pimpl->getNonNullBooleanArgField(std::move(params), std::move(nonNullBooleanArgArg)); + return { _pimpl->getNonNullBooleanArgField(std::move(params), std::move(nonNullBooleanArgArg)) }; } else { @@ -1146,7 +1145,7 @@ class Arguments { if constexpr (ArgumentsStubs::HasNonNullBooleanListField) { - return _pimpl->getNonNullBooleanListField(std::move(params), std::move(nonNullBooleanListArgArg)); + return { _pimpl->getNonNullBooleanListField(std::move(params), std::move(nonNullBooleanListArgArg)) }; } else { @@ -1158,7 +1157,7 @@ class Arguments { if constexpr (ArgumentsStubs::HasBooleanListArgField) { - return _pimpl->getBooleanListArgField(std::move(params), std::move(booleanListArgArg)); + return { _pimpl->getBooleanListArgField(std::move(params), std::move(booleanListArgArg)) }; } else { @@ -1170,7 +1169,7 @@ class Arguments { if constexpr (ArgumentsStubs::HasOptionalNonNullBooleanArgField) { - return _pimpl->getOptionalNonNullBooleanArgField(std::move(params), std::move(optionalBooleanArgArg)); + return { _pimpl->getOptionalNonNullBooleanArgField(std::move(params), std::move(optionalBooleanArgArg)) }; } else { diff --git a/src/SchemaGenerator.cpp b/src/SchemaGenerator.cpp index 47c7e5c2..3c008812 100644 --- a/src/SchemaGenerator.cpp +++ b/src/SchemaGenerator.cpp @@ -170,12 +170,6 @@ static_assert(graphql::internal::MinorVersion == )cpp" #endif // !GRAPHQL_DLLEXPORTS // clang-format on -)cpp"; - } - else if (!_options.noStubs) - { - headerFile << - R"cpp(#include )cpp"; } @@ -550,15 +544,15 @@ concept Has)cpp" << fieldName headerFile << R"cpp() { - { impl.)cpp" << outputField.accessor - << fieldName << R"cpp((std::move(params))cpp"; + { service::FieldResult<)cpp" + << _loader.getOutputCppType(outputField) << R"cpp(> { impl.)cpp" + << outputField.accessor << fieldName << R"cpp((std::move(params))cpp"; for (const auto& argument : outputField.arguments) { headerFile << R"cpp(, std::move()cpp" << argument.cppName << R"cpp(Arg))cpp"; } - headerFile << R"cpp() } -> std::convertible_to>; + headerFile << R"cpp() } }; }; )cpp"; @@ -669,26 +663,23 @@ concept Has)cpp" << fieldName { )cpp"; - if (_options.noStubs || _loader.isIntrospection()) - { - headerFile << R"cpp(return _pimpl->)cpp" << outputField.accessor << fieldName - << R"cpp((std::move(params))cpp"; - } - else + if (!_options.noStubs && !_loader.isIntrospection()) { headerFile << R"cpp(if constexpr ()cpp" << stubNamespace << R"cpp(::Has)cpp" << fieldName << R"cpp() { - return _pimpl->)cpp" - << outputField.accessor << fieldName << R"cpp((std::move(params))cpp"; + )cpp"; } + headerFile << R"cpp(return { _pimpl->)cpp" + << outputField.accessor << fieldName << R"cpp((std::move(params))cpp"; + for (const auto& argument : outputField.arguments) { headerFile << R"cpp(, std::move()cpp" << argument.cppName << R"cpp(Arg))cpp"; } - headerFile << R"cpp();)cpp"; + headerFile << R"cpp() };)cpp"; if (!_options.noStubs && !_loader.isIntrospection()) { From 0780b4a5a593ea66b2fd09781c7b25892957450e Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Tue, 30 Nov 2021 18:44:51 -0800 Subject: [PATCH 031/119] Switch macOS to macos-11 for newer Xcode support --- .github/workflows/macos.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index 91ddd7fb..fe33c88f 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -9,7 +9,7 @@ jobs: matrix: config: [Debug, Release] - runs-on: macos-latest + runs-on: macos-11 steps: - uses: actions/checkout@v2 From b0f5d48475b3df488d1f6053a8a047341476361b Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Tue, 30 Nov 2021 19:26:25 -0800 Subject: [PATCH 032/119] Take advantage of type erasure to simplify + noexcept getters --- samples/star_wars/DroidData.cpp | 27 +++++++++++++-------------- samples/star_wars/DroidData.h | 17 ++++++++--------- samples/star_wars/HumanData.cpp | 27 +++++++++++++-------------- samples/star_wars/HumanData.h | 16 +++++++--------- samples/star_wars/MutationData.cpp | 4 ++-- samples/star_wars/MutationData.h | 4 ++-- samples/star_wars/QueryData.cpp | 14 +++++++------- samples/star_wars/QueryData.h | 12 ++++++------ samples/star_wars/ReviewData.cpp | 10 +++++----- samples/star_wars/ReviewData.h | 5 ++--- 10 files changed, 65 insertions(+), 71 deletions(-) diff --git a/samples/star_wars/DroidData.cpp b/samples/star_wars/DroidData.cpp index ed95aa50..1cff1c94 100644 --- a/samples/star_wars/DroidData.cpp +++ b/samples/star_wars/DroidData.cpp @@ -40,19 +40,18 @@ void Droid::addFriends( }); } -service::FieldResult Droid::getId(service::FieldParams&& params) const +response::StringType Droid::getId(service::FieldParams&& params) const noexcept { - return { id_ }; + return id_; } -service::FieldResult> Droid::getName( - service::FieldParams&& params) const +std::optional Droid::getName(service::FieldParams&& params) const noexcept { - return { name_ }; + return name_; } -service::FieldResult>>> Droid:: - getFriends(service::FieldParams&& params) const +std::optional>> Droid::getFriends( + service::FieldParams&& params) const noexcept { std::vector> result(friends_.size()); @@ -84,11 +83,11 @@ service::FieldResult> }), result.end()); - return { result.empty() ? std::nullopt : std::make_optional(std::move(result)) }; + return result.empty() ? std::nullopt : std::make_optional(std::move(result)); } -service::FieldResult>>> Droid::getAppearsIn( - service::FieldParams&& params) const +std::optional>> Droid::getAppearsIn( + service::FieldParams&& params) const noexcept { std::vector> result(appearsIn_.size()); @@ -99,13 +98,13 @@ service::FieldResult>>> Droid:: return std::make_optional(entry); }); - return { result.empty() ? std::nullopt : std::make_optional(std::move(result)) }; + return result.empty() ? std::nullopt : std::make_optional(std::move(result)); } -service::FieldResult> Droid::getPrimaryFunction( - service::FieldParams&& params) const +std::optional Droid::getPrimaryFunction( + service::FieldParams&& params) const noexcept { - return { primaryFunction_ }; + return primaryFunction_; } } // namespace graphql::learn diff --git a/samples/star_wars/DroidData.h b/samples/star_wars/DroidData.h index c68cf829..89024fdc 100644 --- a/samples/star_wars/DroidData.h +++ b/samples/star_wars/DroidData.h @@ -24,15 +24,14 @@ class Droid const response::StringType& id() const noexcept; void addFriends(std::vector friends) noexcept; - service::FieldResult getId(service::FieldParams&& params) const; - service::FieldResult> getName( - service::FieldParams&& params) const; - service::FieldResult>>> getFriends( - service::FieldParams&& params) const; - service::FieldResult>>> getAppearsIn( - service::FieldParams&& params) const; - service::FieldResult> getPrimaryFunction( - service::FieldParams&& params) const; + response::StringType getId(service::FieldParams&& params) const noexcept; + std::optional getName(service::FieldParams&& params) const noexcept; + std::optional>> getFriends( + service::FieldParams&& params) const noexcept; + std::optional>> getAppearsIn( + service::FieldParams&& params) const noexcept; + std::optional getPrimaryFunction( + service::FieldParams&& params) const noexcept; private: const response::StringType id_; diff --git a/samples/star_wars/HumanData.cpp b/samples/star_wars/HumanData.cpp index 4096097d..01866231 100644 --- a/samples/star_wars/HumanData.cpp +++ b/samples/star_wars/HumanData.cpp @@ -39,19 +39,18 @@ void Human::addFriends(std::vector friends) noexcept }); } -service::FieldResult Human::getId(service::FieldParams&& params) const +response::StringType Human::getId(service::FieldParams&& params) const noexcept { - return { id_ }; + return id_; } -service::FieldResult> Human::getName( - service::FieldParams&& params) const +std::optional Human::getName(service::FieldParams&& params) const noexcept { - return { name_ }; + return name_; } -service::FieldResult>>> Human:: - getFriends(service::FieldParams&& params) const +std::optional>> Human::getFriends( + service::FieldParams&& params) const noexcept { std::vector> result(friends_.size()); @@ -83,11 +82,11 @@ service::FieldResult> }), result.end()); - return { result.empty() ? std::nullopt : std::make_optional(std::move(result)) }; + return result.empty() ? std::nullopt : std::make_optional(std::move(result)); } -service::FieldResult>>> Human::getAppearsIn( - service::FieldParams&& params) const +std::optional>> Human::getAppearsIn( + service::FieldParams&& params) const noexcept { std::vector> result(appearsIn_.size()); @@ -98,13 +97,13 @@ service::FieldResult>>> Human:: return std::make_optional(entry); }); - return { result.empty() ? std::nullopt : std::make_optional(std::move(result)) }; + return result.empty() ? std::nullopt : std::make_optional(std::move(result)); } -service::FieldResult> Human::getHomePlanet( - service::FieldParams&& params) const +std::optional Human::getHomePlanet( + service::FieldParams&& params) const noexcept { - return { homePlanet_ }; + return homePlanet_; } } // namespace graphql::learn diff --git a/samples/star_wars/HumanData.h b/samples/star_wars/HumanData.h index 3a1660c2..bf6b99ad 100644 --- a/samples/star_wars/HumanData.h +++ b/samples/star_wars/HumanData.h @@ -21,15 +21,13 @@ class Human const response::StringType& id() const noexcept; void addFriends(std::vector friends) noexcept; - service::FieldResult getId(service::FieldParams&& params) const; - service::FieldResult> getName( - service::FieldParams&& params) const; - service::FieldResult>>> getFriends( - service::FieldParams&& params) const; - service::FieldResult>>> getAppearsIn( - service::FieldParams&& params) const; - service::FieldResult> getHomePlanet( - service::FieldParams&& params) const; + response::StringType getId(service::FieldParams&& params) const noexcept; + std::optional getName(service::FieldParams&& params) const noexcept; + std::optional>> getFriends( + service::FieldParams&& params) const noexcept; + std::optional>> getAppearsIn( + service::FieldParams&& params) const noexcept; + std::optional getHomePlanet(service::FieldParams&& params) const noexcept; private: const response::StringType id_; diff --git a/samples/star_wars/MutationData.cpp b/samples/star_wars/MutationData.cpp index b87fa5ff..a3dd20b3 100644 --- a/samples/star_wars/MutationData.cpp +++ b/samples/star_wars/MutationData.cpp @@ -9,8 +9,8 @@ Mutation::Mutation() noexcept { } -service::FieldResult> Mutation::applyCreateReview( - service::FieldParams&& params, Episode&& epArg, ReviewInput&& reviewArg) +std::shared_ptr Mutation::applyCreateReview( + service::FieldParams&& params, Episode&& epArg, ReviewInput&& reviewArg) noexcept { auto review = std::make_shared(reviewArg.stars, std::move(reviewArg.commentary)); diff --git a/samples/star_wars/MutationData.h b/samples/star_wars/MutationData.h index 483b7f29..4cf62b24 100644 --- a/samples/star_wars/MutationData.h +++ b/samples/star_wars/MutationData.h @@ -17,8 +17,8 @@ class Mutation public: explicit Mutation() noexcept; - service::FieldResult> applyCreateReview( - service::FieldParams&& params, Episode&& epArg, ReviewInput&& reviewArg); + std::shared_ptr applyCreateReview( + service::FieldParams&& params, Episode&& epArg, ReviewInput&& reviewArg) noexcept; private: // This is just an example, the Mutation object probably shouldn't own a mutable store for the diff --git a/samples/star_wars/QueryData.cpp b/samples/star_wars/QueryData.cpp index cc95f2d1..db9079a8 100644 --- a/samples/star_wars/QueryData.cpp +++ b/samples/star_wars/QueryData.cpp @@ -14,8 +14,8 @@ Query::Query(std::map heroes, { } -service::FieldResult> Query::getHero( - service::FieldParams&&, std::optional&& episodeArg) const +std::shared_ptr Query::getHero( + service::FieldParams&&, std::optional&& episodeArg) const noexcept { std::shared_ptr result; const auto episode = episodeArg ? *episodeArg : Episode::NEW_HOPE; @@ -40,11 +40,11 @@ service::FieldResult> Query::getHero( itr->second); } - return { result }; + return result; } -service::FieldResult> Query::getHuman( - service::FieldParams&&, response::StringType&& idArg) const +std::shared_ptr Query::getHuman( + service::FieldParams&&, response::StringType&& idArg) const noexcept { std::shared_ptr result; @@ -56,8 +56,8 @@ service::FieldResult> Query::getHuman( return std::make_shared(std::move(result)); } -service::FieldResult> Query::getDroid( - service::FieldParams&&, response::StringType&& idArg) const +std::shared_ptr Query::getDroid( + service::FieldParams&&, response::StringType&& idArg) const noexcept { std::shared_ptr result; diff --git a/samples/star_wars/QueryData.h b/samples/star_wars/QueryData.h index ac331200..8025d054 100644 --- a/samples/star_wars/QueryData.h +++ b/samples/star_wars/QueryData.h @@ -20,12 +20,12 @@ class Query std::map> humans, std::map> droids) noexcept; - service::FieldResult> getHero( - service::FieldParams&& params, std::optional&& episodeArg) const; - service::FieldResult> getHuman( - service::FieldParams&& params, response::StringType&& idArg) const; - service::FieldResult> getDroid( - service::FieldParams&& params, response::StringType&& idArg) const; + std::shared_ptr getHero( + service::FieldParams&& params, std::optional&& episodeArg) const noexcept; + std::shared_ptr getHuman( + service::FieldParams&& params, response::StringType&& idArg) const noexcept; + std::shared_ptr getDroid( + service::FieldParams&& params, response::StringType&& idArg) const noexcept; private: const std::map heroes_; diff --git a/samples/star_wars/ReviewData.cpp b/samples/star_wars/ReviewData.cpp index 0c066be3..dd986efc 100644 --- a/samples/star_wars/ReviewData.cpp +++ b/samples/star_wars/ReviewData.cpp @@ -11,15 +11,15 @@ Review::Review(response::IntType stars, std::optional comm { } -service::FieldResult Review::getStars(service::FieldParams&& params) const +response::IntType Review::getStars(service::FieldParams&& params) const noexcept { - return { stars_ }; + return stars_; } -service::FieldResult> Review::getCommentary( - service::FieldParams&& params) const +std::optional Review::getCommentary( + service::FieldParams&& params) const noexcept { - return { commentary_ }; + return commentary_; } } // namespace graphql::learn diff --git a/samples/star_wars/ReviewData.h b/samples/star_wars/ReviewData.h index d201e1d7..f701fc37 100644 --- a/samples/star_wars/ReviewData.h +++ b/samples/star_wars/ReviewData.h @@ -16,9 +16,8 @@ class Review explicit Review( response::IntType stars, std::optional commentary) noexcept; - service::FieldResult getStars(service::FieldParams&& params) const; - service::FieldResult> getCommentary( - service::FieldParams&& params) const; + response::IntType getStars(service::FieldParams&& params) const noexcept; + std::optional getCommentary(service::FieldParams&& params) const noexcept; private: const response::IntType stars_; From 630c7060e5bcc31a6af7833ad1700eaa215d0c78 Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Tue, 30 Nov 2021 23:12:38 -0800 Subject: [PATCH 033/119] Add type-erased begin/endSelectionSet overrides --- include/SchemaGenerator.h | 2 + .../introspection/IntrospectionSchema.h | 6 +- samples/learn/DroidObject.cpp | 10 + samples/learn/DroidObject.h | 37 + samples/learn/HumanObject.cpp | 10 + samples/learn/HumanObject.h | 37 + samples/learn/MutationObject.cpp | 10 + samples/learn/MutationObject.h | 37 + samples/learn/QueryObject.cpp | 10 + samples/learn/QueryObject.h | 37 + samples/learn/ReviewObject.cpp | 10 + samples/learn/ReviewObject.h | 37 + .../separate/AppointmentConnectionObject.cpp | 10 + .../separate/AppointmentConnectionObject.h | 43 +- samples/separate/AppointmentEdgeObject.cpp | 10 + samples/separate/AppointmentEdgeObject.h | 43 +- samples/separate/AppointmentObject.cpp | 10 + samples/separate/AppointmentObject.h | 49 +- .../separate/CompleteTaskPayloadObject.cpp | 10 + samples/separate/CompleteTaskPayloadObject.h | 43 +- samples/separate/ExpensiveObject.cpp | 10 + samples/separate/ExpensiveObject.h | 41 +- samples/separate/FolderConnectionObject.cpp | 10 + samples/separate/FolderConnectionObject.h | 43 +- samples/separate/FolderEdgeObject.cpp | 10 + samples/separate/FolderEdgeObject.h | 43 +- samples/separate/FolderObject.cpp | 10 + samples/separate/FolderObject.h | 45 +- samples/separate/MutationObject.cpp | 10 + samples/separate/MutationObject.h | 43 +- samples/separate/NestedTypeObject.cpp | 10 + samples/separate/NestedTypeObject.h | 43 +- samples/separate/PageInfoObject.cpp | 10 + samples/separate/PageInfoObject.h | 43 +- samples/separate/QueryObject.cpp | 10 + samples/separate/QueryObject.h | 63 +- samples/separate/SubscriptionObject.cpp | 10 + samples/separate/SubscriptionObject.h | 43 +- samples/separate/TaskConnectionObject.cpp | 10 + samples/separate/TaskConnectionObject.h | 43 +- samples/separate/TaskEdgeObject.cpp | 10 + samples/separate/TaskEdgeObject.h | 43 +- samples/separate/TaskObject.cpp | 10 + samples/separate/TaskObject.h | 45 +- .../AppointmentConnectionObject.cpp | 10 + .../AppointmentConnectionObject.h | 43 +- .../AppointmentEdgeObject.cpp | 10 + .../AppointmentEdgeObject.h | 43 +- .../AppointmentObject.cpp | 10 + .../AppointmentObject.h | 49 +- .../CompleteTaskPayloadObject.cpp | 10 + .../CompleteTaskPayloadObject.h | 43 +- .../ExpensiveObject.cpp | 10 + .../ExpensiveObject.h | 41 +- .../FolderConnectionObject.cpp | 10 + .../FolderConnectionObject.h | 43 +- .../FolderEdgeObject.cpp | 10 + .../FolderEdgeObject.h | 43 +- .../separate_nointrospection/FolderObject.cpp | 10 + .../separate_nointrospection/FolderObject.h | 45 +- .../MutationObject.cpp | 10 + .../separate_nointrospection/MutationObject.h | 43 +- .../NestedTypeObject.cpp | 10 + .../NestedTypeObject.h | 43 +- .../PageInfoObject.cpp | 10 + .../separate_nointrospection/PageInfoObject.h | 43 +- .../separate_nointrospection/QueryObject.cpp | 10 + .../separate_nointrospection/QueryObject.h | 63 +- .../SubscriptionObject.cpp | 10 + .../SubscriptionObject.h | 43 +- .../TaskConnectionObject.cpp | 10 + .../TaskConnectionObject.h | 43 +- .../TaskEdgeObject.cpp | 10 + .../separate_nointrospection/TaskEdgeObject.h | 43 +- .../separate_nointrospection/TaskObject.cpp | 10 + samples/separate_nointrospection/TaskObject.h | 45 +- samples/unified/TodaySchema.cpp | 160 +++ samples/unified/TodaySchema.h | 1213 ++++++++++++----- .../unified_nointrospection/TodaySchema.cpp | 160 +++ samples/unified_nointrospection/TodaySchema.h | 1213 ++++++++++++----- samples/validation/ValidationSchema.cpp | 100 ++ samples/validation/ValidationSchema.h | 833 +++++++---- src/SchemaGenerator.cpp | 179 ++- 83 files changed, 4713 insertions(+), 1140 deletions(-) diff --git a/include/SchemaGenerator.h b/include/SchemaGenerator.h index 1b617286..e7a4bd48 100644 --- a/include/SchemaGenerator.h +++ b/include/SchemaGenerator.h @@ -42,6 +42,8 @@ class Generator std::string getSourcePath() const noexcept; bool outputHeader() const noexcept; + void outputObjectStubs( + std::ostream& headerFile, const ObjectType& objectType) const; void outputObjectDeclaration( std::ostream& headerFile, const ObjectType& objectType, bool isQueryType) const; std::string getFieldDeclaration(const InputField& inputField) const noexcept; diff --git a/include/graphqlservice/introspection/IntrospectionSchema.h b/include/graphqlservice/introspection/IntrospectionSchema.h index ee8904aa..548433d3 100644 --- a/include/graphqlservice/introspection/IntrospectionSchema.h +++ b/include/graphqlservice/introspection/IntrospectionSchema.h @@ -67,6 +67,8 @@ enum class DirectiveLocation INPUT_FIELD_DEFINITION }; +namespace object { + class Schema; class Type; class Field; @@ -74,7 +76,7 @@ class InputValue; class EnumValue; class Directive; -namespace object { +} // namespace object class Schema; class Type; @@ -83,6 +85,8 @@ class InputValue; class EnumValue; class Directive; +namespace object { + class Schema : public service::Object { diff --git a/samples/learn/DroidObject.cpp b/samples/learn/DroidObject.cpp index fa5bebfc..87484db1 100644 --- a/samples/learn/DroidObject.cpp +++ b/samples/learn/DroidObject.cpp @@ -34,6 +34,16 @@ Droid::Droid(std::unique_ptr&& pimpl) { } +void Droid::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void Droid::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} + service::AwaitableResolver Droid::resolveId(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); diff --git a/samples/learn/DroidObject.h b/samples/learn/DroidObject.h index a0676f06..fc88af1f 100644 --- a/samples/learn/DroidObject.h +++ b/samples/learn/DroidObject.h @@ -11,6 +11,21 @@ #include "StarWarsSchema.h" namespace graphql::learn::object { +namespace stub::DroidStubs { + +template +concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.beginSelectionSet(params) }; +}; + +template +concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.endSelectionSet(params) }; +}; + +} // namespace stub::DroidStubs class Droid : public service::Object @@ -29,6 +44,9 @@ class Droid { virtual ~Concept() = default; + virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual service::FieldResult> getPrimaryFunction(service::FieldParams&& params) const = 0; }; @@ -41,6 +59,22 @@ class Droid { } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::DroidStubs::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::DroidStubs::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + service::FieldResult getId(service::FieldParams&& params) const final { return { _pimpl->getId(std::move(params)) }; @@ -72,6 +106,9 @@ class Droid Droid(std::unique_ptr&& pimpl); + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; + const std::unique_ptr _pimpl; public: diff --git a/samples/learn/HumanObject.cpp b/samples/learn/HumanObject.cpp index c03edb6c..4a4920cb 100644 --- a/samples/learn/HumanObject.cpp +++ b/samples/learn/HumanObject.cpp @@ -34,6 +34,16 @@ Human::Human(std::unique_ptr&& pimpl) { } +void Human::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void Human::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} + service::AwaitableResolver Human::resolveId(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); diff --git a/samples/learn/HumanObject.h b/samples/learn/HumanObject.h index f9263bf1..06fcdb90 100644 --- a/samples/learn/HumanObject.h +++ b/samples/learn/HumanObject.h @@ -11,6 +11,21 @@ #include "StarWarsSchema.h" namespace graphql::learn::object { +namespace stub::HumanStubs { + +template +concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.beginSelectionSet(params) }; +}; + +template +concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.endSelectionSet(params) }; +}; + +} // namespace stub::HumanStubs class Human : public service::Object @@ -29,6 +44,9 @@ class Human { virtual ~Concept() = default; + virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual service::FieldResult> getHomePlanet(service::FieldParams&& params) const = 0; }; @@ -41,6 +59,22 @@ class Human { } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::HumanStubs::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::HumanStubs::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + service::FieldResult getId(service::FieldParams&& params) const final { return { _pimpl->getId(std::move(params)) }; @@ -72,6 +106,9 @@ class Human Human(std::unique_ptr&& pimpl); + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; + const std::unique_ptr _pimpl; public: diff --git a/samples/learn/MutationObject.cpp b/samples/learn/MutationObject.cpp index f9d46926..299dd904 100644 --- a/samples/learn/MutationObject.cpp +++ b/samples/learn/MutationObject.cpp @@ -29,6 +29,16 @@ Mutation::Mutation(std::unique_ptr&& pimpl) { } +void Mutation::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void Mutation::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} + service::AwaitableResolver Mutation::resolveCreateReview(service::ResolverParams&& params) { auto argEp = service::ModifiedArgument::require("ep", params.arguments); diff --git a/samples/learn/MutationObject.h b/samples/learn/MutationObject.h index 3a2e6c28..2024ef5b 100644 --- a/samples/learn/MutationObject.h +++ b/samples/learn/MutationObject.h @@ -11,6 +11,21 @@ #include "StarWarsSchema.h" namespace graphql::learn::object { +namespace stub::MutationStubs { + +template +concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.beginSelectionSet(params) }; +}; + +template +concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.endSelectionSet(params) }; +}; + +} // namespace stub::MutationStubs class Mutation : public service::Object @@ -24,6 +39,9 @@ class Mutation { virtual ~Concept() = default; + virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual service::FieldResult> applyCreateReview(service::FieldParams&& params, Episode&& epArg, ReviewInput&& reviewArg) const = 0; }; @@ -36,6 +54,22 @@ class Mutation { } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::MutationStubs::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::MutationStubs::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + service::FieldResult> applyCreateReview(service::FieldParams&& params, Episode&& epArg, ReviewInput&& reviewArg) const final { return { _pimpl->applyCreateReview(std::move(params), std::move(epArg), std::move(reviewArg)) }; @@ -47,6 +81,9 @@ class Mutation Mutation(std::unique_ptr&& pimpl); + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; + const std::unique_ptr _pimpl; public: diff --git a/samples/learn/QueryObject.cpp b/samples/learn/QueryObject.cpp index c4d5c975..7ee362f9 100644 --- a/samples/learn/QueryObject.cpp +++ b/samples/learn/QueryObject.cpp @@ -34,6 +34,16 @@ Query::Query(std::unique_ptr&& pimpl) { } +void Query::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void Query::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} + service::AwaitableResolver Query::resolveHero(service::ResolverParams&& params) { auto argEpisode = service::ModifiedArgument::require("episode", params.arguments); diff --git a/samples/learn/QueryObject.h b/samples/learn/QueryObject.h index 6cd2ccc8..871a59fc 100644 --- a/samples/learn/QueryObject.h +++ b/samples/learn/QueryObject.h @@ -11,6 +11,21 @@ #include "StarWarsSchema.h" namespace graphql::learn::object { +namespace stub::QueryStubs { + +template +concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.beginSelectionSet(params) }; +}; + +template +concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.endSelectionSet(params) }; +}; + +} // namespace stub::QueryStubs class Query : public service::Object @@ -30,6 +45,9 @@ class Query { virtual ~Concept() = default; + virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual service::FieldResult> getHero(service::FieldParams&& params, std::optional&& episodeArg) const = 0; virtual service::FieldResult> getHuman(service::FieldParams&& params, response::StringType&& idArg) const = 0; virtual service::FieldResult> getDroid(service::FieldParams&& params, response::StringType&& idArg) const = 0; @@ -44,6 +62,22 @@ class Query { } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::QueryStubs::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::QueryStubs::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + service::FieldResult> getHero(service::FieldParams&& params, std::optional&& episodeArg) const final { return { _pimpl->getHero(std::move(params), std::move(episodeArg)) }; @@ -65,6 +99,9 @@ class Query Query(std::unique_ptr&& pimpl); + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; + const std::unique_ptr _pimpl; public: diff --git a/samples/learn/ReviewObject.cpp b/samples/learn/ReviewObject.cpp index 2376d8a9..29831c44 100644 --- a/samples/learn/ReviewObject.cpp +++ b/samples/learn/ReviewObject.cpp @@ -30,6 +30,16 @@ Review::Review(std::unique_ptr&& pimpl) { } +void Review::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void Review::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} + service::AwaitableResolver Review::resolveStars(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); diff --git a/samples/learn/ReviewObject.h b/samples/learn/ReviewObject.h index ebc9a862..d112b59c 100644 --- a/samples/learn/ReviewObject.h +++ b/samples/learn/ReviewObject.h @@ -11,6 +11,21 @@ #include "StarWarsSchema.h" namespace graphql::learn::object { +namespace stub::ReviewStubs { + +template +concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.beginSelectionSet(params) }; +}; + +template +concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.endSelectionSet(params) }; +}; + +} // namespace stub::ReviewStubs class Review : public service::Object @@ -25,6 +40,9 @@ class Review { virtual ~Concept() = default; + virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual service::FieldResult getStars(service::FieldParams&& params) const = 0; virtual service::FieldResult> getCommentary(service::FieldParams&& params) const = 0; }; @@ -38,6 +56,22 @@ class Review { } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::ReviewStubs::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::ReviewStubs::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + service::FieldResult getStars(service::FieldParams&& params) const final { return { _pimpl->getStars(std::move(params)) }; @@ -54,6 +88,9 @@ class Review Review(std::unique_ptr&& pimpl); + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; + const std::unique_ptr _pimpl; public: diff --git a/samples/separate/AppointmentConnectionObject.cpp b/samples/separate/AppointmentConnectionObject.cpp index 622e42a9..4925c263 100644 --- a/samples/separate/AppointmentConnectionObject.cpp +++ b/samples/separate/AppointmentConnectionObject.cpp @@ -30,6 +30,16 @@ AppointmentConnection::AppointmentConnection(std::unique_ptr&& pimpl) { } +void AppointmentConnection::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void AppointmentConnection::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} + service::AwaitableResolver AppointmentConnection::resolvePageInfo(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); diff --git a/samples/separate/AppointmentConnectionObject.h b/samples/separate/AppointmentConnectionObject.h index d8e3e2f5..b1769e29 100644 --- a/samples/separate/AppointmentConnectionObject.h +++ b/samples/separate/AppointmentConnectionObject.h @@ -11,8 +11,7 @@ #include "TodaySchema.h" namespace graphql::today::object { - -namespace AppointmentConnectionStubs { +namespace stub::AppointmentConnectionStubs { template concept HasPageInfo = requires (TImpl impl, service::FieldParams params) @@ -26,7 +25,19 @@ concept HasEdges = requires (TImpl impl, service::FieldParams params) { service::FieldResult>>> { impl.getEdges(std::move(params)) } }; }; -} // namespace AppointmentConnectionStubs +template +concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.beginSelectionSet(params) }; +}; + +template +concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.endSelectionSet(params) }; +}; + +} // namespace stub::AppointmentConnectionStubs class AppointmentConnection : public service::Object @@ -41,6 +52,9 @@ class AppointmentConnection { virtual ~Concept() = default; + virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual service::FieldResult> getPageInfo(service::FieldParams&& params) const = 0; virtual service::FieldResult>>> getEdges(service::FieldParams&& params) const = 0; }; @@ -54,9 +68,25 @@ class AppointmentConnection { } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::AppointmentConnectionStubs::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::AppointmentConnectionStubs::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + service::FieldResult> getPageInfo(service::FieldParams&& params) const final { - if constexpr (AppointmentConnectionStubs::HasPageInfo) + if constexpr (stub::AppointmentConnectionStubs::HasPageInfo) { return { _pimpl->getPageInfo(std::move(params)) }; } @@ -68,7 +98,7 @@ class AppointmentConnection service::FieldResult>>> getEdges(service::FieldParams&& params) const final { - if constexpr (AppointmentConnectionStubs::HasEdges) + if constexpr (stub::AppointmentConnectionStubs::HasEdges) { return { _pimpl->getEdges(std::move(params)) }; } @@ -84,6 +114,9 @@ class AppointmentConnection AppointmentConnection(std::unique_ptr&& pimpl); + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; + const std::unique_ptr _pimpl; public: diff --git a/samples/separate/AppointmentEdgeObject.cpp b/samples/separate/AppointmentEdgeObject.cpp index df02bd88..eff163fc 100644 --- a/samples/separate/AppointmentEdgeObject.cpp +++ b/samples/separate/AppointmentEdgeObject.cpp @@ -30,6 +30,16 @@ AppointmentEdge::AppointmentEdge(std::unique_ptr&& pimpl) { } +void AppointmentEdge::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void AppointmentEdge::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} + service::AwaitableResolver AppointmentEdge::resolveNode(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); diff --git a/samples/separate/AppointmentEdgeObject.h b/samples/separate/AppointmentEdgeObject.h index 7adc12b1..75b15875 100644 --- a/samples/separate/AppointmentEdgeObject.h +++ b/samples/separate/AppointmentEdgeObject.h @@ -11,8 +11,7 @@ #include "TodaySchema.h" namespace graphql::today::object { - -namespace AppointmentEdgeStubs { +namespace stub::AppointmentEdgeStubs { template concept HasNode = requires (TImpl impl, service::FieldParams params) @@ -26,7 +25,19 @@ concept HasCursor = requires (TImpl impl, service::FieldParams params) { service::FieldResult { impl.getCursor(std::move(params)) } }; }; -} // namespace AppointmentEdgeStubs +template +concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.beginSelectionSet(params) }; +}; + +template +concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.endSelectionSet(params) }; +}; + +} // namespace stub::AppointmentEdgeStubs class AppointmentEdge : public service::Object @@ -41,6 +52,9 @@ class AppointmentEdge { virtual ~Concept() = default; + virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual service::FieldResult> getNode(service::FieldParams&& params) const = 0; virtual service::FieldResult getCursor(service::FieldParams&& params) const = 0; }; @@ -54,9 +68,25 @@ class AppointmentEdge { } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::AppointmentEdgeStubs::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::AppointmentEdgeStubs::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + service::FieldResult> getNode(service::FieldParams&& params) const final { - if constexpr (AppointmentEdgeStubs::HasNode) + if constexpr (stub::AppointmentEdgeStubs::HasNode) { return { _pimpl->getNode(std::move(params)) }; } @@ -68,7 +98,7 @@ class AppointmentEdge service::FieldResult getCursor(service::FieldParams&& params) const final { - if constexpr (AppointmentEdgeStubs::HasCursor) + if constexpr (stub::AppointmentEdgeStubs::HasCursor) { return { _pimpl->getCursor(std::move(params)) }; } @@ -84,6 +114,9 @@ class AppointmentEdge AppointmentEdge(std::unique_ptr&& pimpl); + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; + const std::unique_ptr _pimpl; public: diff --git a/samples/separate/AppointmentObject.cpp b/samples/separate/AppointmentObject.cpp index 30b83427..228bdcff 100644 --- a/samples/separate/AppointmentObject.cpp +++ b/samples/separate/AppointmentObject.cpp @@ -35,6 +35,16 @@ Appointment::Appointment(std::unique_ptr&& pimpl) { } +void Appointment::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void Appointment::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} + service::AwaitableResolver Appointment::resolveId(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); diff --git a/samples/separate/AppointmentObject.h b/samples/separate/AppointmentObject.h index 1a1188af..e20b8661 100644 --- a/samples/separate/AppointmentObject.h +++ b/samples/separate/AppointmentObject.h @@ -11,8 +11,7 @@ #include "TodaySchema.h" namespace graphql::today::object { - -namespace AppointmentStubs { +namespace stub::AppointmentStubs { template concept HasId = requires (TImpl impl, service::FieldParams params) @@ -44,7 +43,19 @@ concept HasForceError = requires (TImpl impl, service::FieldParams params) { service::FieldResult> { impl.getForceError(std::move(params)) } }; }; -} // namespace AppointmentStubs +template +concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.beginSelectionSet(params) }; +}; + +template +concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.endSelectionSet(params) }; +}; + +} // namespace stub::AppointmentStubs class Appointment : public service::Object @@ -63,6 +74,9 @@ class Appointment { virtual ~Concept() = default; + virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual service::FieldResult> getWhen(service::FieldParams&& params) const = 0; virtual service::FieldResult> getSubject(service::FieldParams&& params) const = 0; virtual service::FieldResult getIsNow(service::FieldParams&& params) const = 0; @@ -78,9 +92,25 @@ class Appointment { } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::AppointmentStubs::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::AppointmentStubs::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + service::FieldResult getId(service::FieldParams&& params) const final { - if constexpr (AppointmentStubs::HasId) + if constexpr (stub::AppointmentStubs::HasId) { return { _pimpl->getId(std::move(params)) }; } @@ -92,7 +122,7 @@ class Appointment service::FieldResult> getWhen(service::FieldParams&& params) const final { - if constexpr (AppointmentStubs::HasWhen) + if constexpr (stub::AppointmentStubs::HasWhen) { return { _pimpl->getWhen(std::move(params)) }; } @@ -104,7 +134,7 @@ class Appointment service::FieldResult> getSubject(service::FieldParams&& params) const final { - if constexpr (AppointmentStubs::HasSubject) + if constexpr (stub::AppointmentStubs::HasSubject) { return { _pimpl->getSubject(std::move(params)) }; } @@ -116,7 +146,7 @@ class Appointment service::FieldResult getIsNow(service::FieldParams&& params) const final { - if constexpr (AppointmentStubs::HasIsNow) + if constexpr (stub::AppointmentStubs::HasIsNow) { return { _pimpl->getIsNow(std::move(params)) }; } @@ -128,7 +158,7 @@ class Appointment service::FieldResult> getForceError(service::FieldParams&& params) const final { - if constexpr (AppointmentStubs::HasForceError) + if constexpr (stub::AppointmentStubs::HasForceError) { return { _pimpl->getForceError(std::move(params)) }; } @@ -144,6 +174,9 @@ class Appointment Appointment(std::unique_ptr&& pimpl); + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; + const std::unique_ptr _pimpl; public: diff --git a/samples/separate/CompleteTaskPayloadObject.cpp b/samples/separate/CompleteTaskPayloadObject.cpp index 2924a90c..b6b85919 100644 --- a/samples/separate/CompleteTaskPayloadObject.cpp +++ b/samples/separate/CompleteTaskPayloadObject.cpp @@ -30,6 +30,16 @@ CompleteTaskPayload::CompleteTaskPayload(std::unique_ptr&& pimpl) { } +void CompleteTaskPayload::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void CompleteTaskPayload::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} + service::AwaitableResolver CompleteTaskPayload::resolveTask(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); diff --git a/samples/separate/CompleteTaskPayloadObject.h b/samples/separate/CompleteTaskPayloadObject.h index b4603d44..c3ae3927 100644 --- a/samples/separate/CompleteTaskPayloadObject.h +++ b/samples/separate/CompleteTaskPayloadObject.h @@ -11,8 +11,7 @@ #include "TodaySchema.h" namespace graphql::today::object { - -namespace CompleteTaskPayloadStubs { +namespace stub::CompleteTaskPayloadStubs { template concept HasTask = requires (TImpl impl, service::FieldParams params) @@ -26,7 +25,19 @@ concept HasClientMutationId = requires (TImpl impl, service::FieldParams params) { service::FieldResult> { impl.getClientMutationId(std::move(params)) } }; }; -} // namespace CompleteTaskPayloadStubs +template +concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.beginSelectionSet(params) }; +}; + +template +concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.endSelectionSet(params) }; +}; + +} // namespace stub::CompleteTaskPayloadStubs class CompleteTaskPayload : public service::Object @@ -41,6 +52,9 @@ class CompleteTaskPayload { virtual ~Concept() = default; + virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual service::FieldResult> getTask(service::FieldParams&& params) const = 0; virtual service::FieldResult> getClientMutationId(service::FieldParams&& params) const = 0; }; @@ -54,9 +68,25 @@ class CompleteTaskPayload { } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::CompleteTaskPayloadStubs::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::CompleteTaskPayloadStubs::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + service::FieldResult> getTask(service::FieldParams&& params) const final { - if constexpr (CompleteTaskPayloadStubs::HasTask) + if constexpr (stub::CompleteTaskPayloadStubs::HasTask) { return { _pimpl->getTask(std::move(params)) }; } @@ -68,7 +98,7 @@ class CompleteTaskPayload service::FieldResult> getClientMutationId(service::FieldParams&& params) const final { - if constexpr (CompleteTaskPayloadStubs::HasClientMutationId) + if constexpr (stub::CompleteTaskPayloadStubs::HasClientMutationId) { return { _pimpl->getClientMutationId(std::move(params)) }; } @@ -84,6 +114,9 @@ class CompleteTaskPayload CompleteTaskPayload(std::unique_ptr&& pimpl); + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; + const std::unique_ptr _pimpl; public: diff --git a/samples/separate/ExpensiveObject.cpp b/samples/separate/ExpensiveObject.cpp index d8634115..16528213 100644 --- a/samples/separate/ExpensiveObject.cpp +++ b/samples/separate/ExpensiveObject.cpp @@ -29,6 +29,16 @@ Expensive::Expensive(std::unique_ptr&& pimpl) { } +void Expensive::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void Expensive::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} + service::AwaitableResolver Expensive::resolveOrder(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); diff --git a/samples/separate/ExpensiveObject.h b/samples/separate/ExpensiveObject.h index 347cff6f..5a388c99 100644 --- a/samples/separate/ExpensiveObject.h +++ b/samples/separate/ExpensiveObject.h @@ -11,8 +11,7 @@ #include "TodaySchema.h" namespace graphql::today::object { - -namespace ExpensiveStubs { +namespace stub::ExpensiveStubs { template concept HasOrder = requires (TImpl impl, service::FieldParams params) @@ -20,7 +19,19 @@ concept HasOrder = requires (TImpl impl, service::FieldParams params) { service::FieldResult { impl.getOrder(std::move(params)) } }; }; -} // namespace ExpensiveStubs +template +concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.beginSelectionSet(params) }; +}; + +template +concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.endSelectionSet(params) }; +}; + +} // namespace stub::ExpensiveStubs class Expensive : public service::Object @@ -34,6 +45,9 @@ class Expensive { virtual ~Concept() = default; + virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual service::FieldResult getOrder(service::FieldParams&& params) const = 0; }; @@ -46,9 +60,25 @@ class Expensive { } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::ExpensiveStubs::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::ExpensiveStubs::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + service::FieldResult getOrder(service::FieldParams&& params) const final { - if constexpr (ExpensiveStubs::HasOrder) + if constexpr (stub::ExpensiveStubs::HasOrder) { return { _pimpl->getOrder(std::move(params)) }; } @@ -64,6 +94,9 @@ class Expensive Expensive(std::unique_ptr&& pimpl); + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; + const std::unique_ptr _pimpl; public: diff --git a/samples/separate/FolderConnectionObject.cpp b/samples/separate/FolderConnectionObject.cpp index 26c4ab6d..a9ac2ff5 100644 --- a/samples/separate/FolderConnectionObject.cpp +++ b/samples/separate/FolderConnectionObject.cpp @@ -30,6 +30,16 @@ FolderConnection::FolderConnection(std::unique_ptr&& pimpl) { } +void FolderConnection::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void FolderConnection::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} + service::AwaitableResolver FolderConnection::resolvePageInfo(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); diff --git a/samples/separate/FolderConnectionObject.h b/samples/separate/FolderConnectionObject.h index f7c88190..ffa4a7f0 100644 --- a/samples/separate/FolderConnectionObject.h +++ b/samples/separate/FolderConnectionObject.h @@ -11,8 +11,7 @@ #include "TodaySchema.h" namespace graphql::today::object { - -namespace FolderConnectionStubs { +namespace stub::FolderConnectionStubs { template concept HasPageInfo = requires (TImpl impl, service::FieldParams params) @@ -26,7 +25,19 @@ concept HasEdges = requires (TImpl impl, service::FieldParams params) { service::FieldResult>>> { impl.getEdges(std::move(params)) } }; }; -} // namespace FolderConnectionStubs +template +concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.beginSelectionSet(params) }; +}; + +template +concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.endSelectionSet(params) }; +}; + +} // namespace stub::FolderConnectionStubs class FolderConnection : public service::Object @@ -41,6 +52,9 @@ class FolderConnection { virtual ~Concept() = default; + virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual service::FieldResult> getPageInfo(service::FieldParams&& params) const = 0; virtual service::FieldResult>>> getEdges(service::FieldParams&& params) const = 0; }; @@ -54,9 +68,25 @@ class FolderConnection { } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::FolderConnectionStubs::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::FolderConnectionStubs::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + service::FieldResult> getPageInfo(service::FieldParams&& params) const final { - if constexpr (FolderConnectionStubs::HasPageInfo) + if constexpr (stub::FolderConnectionStubs::HasPageInfo) { return { _pimpl->getPageInfo(std::move(params)) }; } @@ -68,7 +98,7 @@ class FolderConnection service::FieldResult>>> getEdges(service::FieldParams&& params) const final { - if constexpr (FolderConnectionStubs::HasEdges) + if constexpr (stub::FolderConnectionStubs::HasEdges) { return { _pimpl->getEdges(std::move(params)) }; } @@ -84,6 +114,9 @@ class FolderConnection FolderConnection(std::unique_ptr&& pimpl); + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; + const std::unique_ptr _pimpl; public: diff --git a/samples/separate/FolderEdgeObject.cpp b/samples/separate/FolderEdgeObject.cpp index a3b31b14..bd741d44 100644 --- a/samples/separate/FolderEdgeObject.cpp +++ b/samples/separate/FolderEdgeObject.cpp @@ -30,6 +30,16 @@ FolderEdge::FolderEdge(std::unique_ptr&& pimpl) { } +void FolderEdge::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void FolderEdge::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} + service::AwaitableResolver FolderEdge::resolveNode(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); diff --git a/samples/separate/FolderEdgeObject.h b/samples/separate/FolderEdgeObject.h index a089a110..f030a84f 100644 --- a/samples/separate/FolderEdgeObject.h +++ b/samples/separate/FolderEdgeObject.h @@ -11,8 +11,7 @@ #include "TodaySchema.h" namespace graphql::today::object { - -namespace FolderEdgeStubs { +namespace stub::FolderEdgeStubs { template concept HasNode = requires (TImpl impl, service::FieldParams params) @@ -26,7 +25,19 @@ concept HasCursor = requires (TImpl impl, service::FieldParams params) { service::FieldResult { impl.getCursor(std::move(params)) } }; }; -} // namespace FolderEdgeStubs +template +concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.beginSelectionSet(params) }; +}; + +template +concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.endSelectionSet(params) }; +}; + +} // namespace stub::FolderEdgeStubs class FolderEdge : public service::Object @@ -41,6 +52,9 @@ class FolderEdge { virtual ~Concept() = default; + virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual service::FieldResult> getNode(service::FieldParams&& params) const = 0; virtual service::FieldResult getCursor(service::FieldParams&& params) const = 0; }; @@ -54,9 +68,25 @@ class FolderEdge { } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::FolderEdgeStubs::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::FolderEdgeStubs::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + service::FieldResult> getNode(service::FieldParams&& params) const final { - if constexpr (FolderEdgeStubs::HasNode) + if constexpr (stub::FolderEdgeStubs::HasNode) { return { _pimpl->getNode(std::move(params)) }; } @@ -68,7 +98,7 @@ class FolderEdge service::FieldResult getCursor(service::FieldParams&& params) const final { - if constexpr (FolderEdgeStubs::HasCursor) + if constexpr (stub::FolderEdgeStubs::HasCursor) { return { _pimpl->getCursor(std::move(params)) }; } @@ -84,6 +114,9 @@ class FolderEdge FolderEdge(std::unique_ptr&& pimpl); + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; + const std::unique_ptr _pimpl; public: diff --git a/samples/separate/FolderObject.cpp b/samples/separate/FolderObject.cpp index b95936e9..c425c3ff 100644 --- a/samples/separate/FolderObject.cpp +++ b/samples/separate/FolderObject.cpp @@ -33,6 +33,16 @@ Folder::Folder(std::unique_ptr&& pimpl) { } +void Folder::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void Folder::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} + service::AwaitableResolver Folder::resolveId(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); diff --git a/samples/separate/FolderObject.h b/samples/separate/FolderObject.h index 52414320..64c2882b 100644 --- a/samples/separate/FolderObject.h +++ b/samples/separate/FolderObject.h @@ -11,8 +11,7 @@ #include "TodaySchema.h" namespace graphql::today::object { - -namespace FolderStubs { +namespace stub::FolderStubs { template concept HasId = requires (TImpl impl, service::FieldParams params) @@ -32,7 +31,19 @@ concept HasUnreadCount = requires (TImpl impl, service::FieldParams params) { service::FieldResult { impl.getUnreadCount(std::move(params)) } }; }; -} // namespace FolderStubs +template +concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.beginSelectionSet(params) }; +}; + +template +concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.endSelectionSet(params) }; +}; + +} // namespace stub::FolderStubs class Folder : public service::Object @@ -49,6 +60,9 @@ class Folder { virtual ~Concept() = default; + virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual service::FieldResult> getName(service::FieldParams&& params) const = 0; virtual service::FieldResult getUnreadCount(service::FieldParams&& params) const = 0; }; @@ -62,9 +76,25 @@ class Folder { } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::FolderStubs::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::FolderStubs::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + service::FieldResult getId(service::FieldParams&& params) const final { - if constexpr (FolderStubs::HasId) + if constexpr (stub::FolderStubs::HasId) { return { _pimpl->getId(std::move(params)) }; } @@ -76,7 +106,7 @@ class Folder service::FieldResult> getName(service::FieldParams&& params) const final { - if constexpr (FolderStubs::HasName) + if constexpr (stub::FolderStubs::HasName) { return { _pimpl->getName(std::move(params)) }; } @@ -88,7 +118,7 @@ class Folder service::FieldResult getUnreadCount(service::FieldParams&& params) const final { - if constexpr (FolderStubs::HasUnreadCount) + if constexpr (stub::FolderStubs::HasUnreadCount) { return { _pimpl->getUnreadCount(std::move(params)) }; } @@ -104,6 +134,9 @@ class Folder Folder(std::unique_ptr&& pimpl); + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; + const std::unique_ptr _pimpl; public: diff --git a/samples/separate/MutationObject.cpp b/samples/separate/MutationObject.cpp index 20ee2188..6f41f9a0 100644 --- a/samples/separate/MutationObject.cpp +++ b/samples/separate/MutationObject.cpp @@ -30,6 +30,16 @@ Mutation::Mutation(std::unique_ptr&& pimpl) { } +void Mutation::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void Mutation::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} + service::AwaitableResolver Mutation::resolveCompleteTask(service::ResolverParams&& params) { auto argInput = service::ModifiedArgument::require("input", params.arguments); diff --git a/samples/separate/MutationObject.h b/samples/separate/MutationObject.h index fc34f52f..f1ecd666 100644 --- a/samples/separate/MutationObject.h +++ b/samples/separate/MutationObject.h @@ -11,8 +11,7 @@ #include "TodaySchema.h" namespace graphql::today::object { - -namespace MutationStubs { +namespace stub::MutationStubs { template concept HasCompleteTask = requires (TImpl impl, service::FieldParams params, CompleteTaskInput inputArg) @@ -26,7 +25,19 @@ concept HasSetFloat = requires (TImpl impl, service::FieldParams params, respons { service::FieldResult { impl.applySetFloat(std::move(params), std::move(valueArg)) } }; }; -} // namespace MutationStubs +template +concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.beginSelectionSet(params) }; +}; + +template +concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.endSelectionSet(params) }; +}; + +} // namespace stub::MutationStubs class Mutation : public service::Object @@ -41,6 +52,9 @@ class Mutation { virtual ~Concept() = default; + virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual service::FieldResult> applyCompleteTask(service::FieldParams&& params, CompleteTaskInput&& inputArg) const = 0; virtual service::FieldResult applySetFloat(service::FieldParams&& params, response::FloatType&& valueArg) const = 0; }; @@ -54,9 +68,25 @@ class Mutation { } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::MutationStubs::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::MutationStubs::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + service::FieldResult> applyCompleteTask(service::FieldParams&& params, CompleteTaskInput&& inputArg) const final { - if constexpr (MutationStubs::HasCompleteTask) + if constexpr (stub::MutationStubs::HasCompleteTask) { return { _pimpl->applyCompleteTask(std::move(params), std::move(inputArg)) }; } @@ -68,7 +98,7 @@ class Mutation service::FieldResult applySetFloat(service::FieldParams&& params, response::FloatType&& valueArg) const final { - if constexpr (MutationStubs::HasSetFloat) + if constexpr (stub::MutationStubs::HasSetFloat) { return { _pimpl->applySetFloat(std::move(params), std::move(valueArg)) }; } @@ -84,6 +114,9 @@ class Mutation Mutation(std::unique_ptr&& pimpl); + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; + const std::unique_ptr _pimpl; public: diff --git a/samples/separate/NestedTypeObject.cpp b/samples/separate/NestedTypeObject.cpp index f44b1eed..54a027b3 100644 --- a/samples/separate/NestedTypeObject.cpp +++ b/samples/separate/NestedTypeObject.cpp @@ -30,6 +30,16 @@ NestedType::NestedType(std::unique_ptr&& pimpl) { } +void NestedType::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void NestedType::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} + service::AwaitableResolver NestedType::resolveDepth(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); diff --git a/samples/separate/NestedTypeObject.h b/samples/separate/NestedTypeObject.h index 3278036a..ce9f276e 100644 --- a/samples/separate/NestedTypeObject.h +++ b/samples/separate/NestedTypeObject.h @@ -11,8 +11,7 @@ #include "TodaySchema.h" namespace graphql::today::object { - -namespace NestedTypeStubs { +namespace stub::NestedTypeStubs { template concept HasDepth = requires (TImpl impl, service::FieldParams params) @@ -26,7 +25,19 @@ concept HasNested = requires (TImpl impl, service::FieldParams params) { service::FieldResult> { impl.getNested(std::move(params)) } }; }; -} // namespace NestedTypeStubs +template +concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.beginSelectionSet(params) }; +}; + +template +concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.endSelectionSet(params) }; +}; + +} // namespace stub::NestedTypeStubs class NestedType : public service::Object @@ -41,6 +52,9 @@ class NestedType { virtual ~Concept() = default; + virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual service::FieldResult getDepth(service::FieldParams&& params) const = 0; virtual service::FieldResult> getNested(service::FieldParams&& params) const = 0; }; @@ -54,9 +68,25 @@ class NestedType { } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::NestedTypeStubs::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::NestedTypeStubs::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + service::FieldResult getDepth(service::FieldParams&& params) const final { - if constexpr (NestedTypeStubs::HasDepth) + if constexpr (stub::NestedTypeStubs::HasDepth) { return { _pimpl->getDepth(std::move(params)) }; } @@ -68,7 +98,7 @@ class NestedType service::FieldResult> getNested(service::FieldParams&& params) const final { - if constexpr (NestedTypeStubs::HasNested) + if constexpr (stub::NestedTypeStubs::HasNested) { return { _pimpl->getNested(std::move(params)) }; } @@ -84,6 +114,9 @@ class NestedType NestedType(std::unique_ptr&& pimpl); + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; + const std::unique_ptr _pimpl; public: diff --git a/samples/separate/PageInfoObject.cpp b/samples/separate/PageInfoObject.cpp index d406c9f2..e0cc198f 100644 --- a/samples/separate/PageInfoObject.cpp +++ b/samples/separate/PageInfoObject.cpp @@ -30,6 +30,16 @@ PageInfo::PageInfo(std::unique_ptr&& pimpl) { } +void PageInfo::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void PageInfo::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} + service::AwaitableResolver PageInfo::resolveHasNextPage(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); diff --git a/samples/separate/PageInfoObject.h b/samples/separate/PageInfoObject.h index 2f160b3c..675ff995 100644 --- a/samples/separate/PageInfoObject.h +++ b/samples/separate/PageInfoObject.h @@ -11,8 +11,7 @@ #include "TodaySchema.h" namespace graphql::today::object { - -namespace PageInfoStubs { +namespace stub::PageInfoStubs { template concept HasHasNextPage = requires (TImpl impl, service::FieldParams params) @@ -26,7 +25,19 @@ concept HasHasPreviousPage = requires (TImpl impl, service::FieldParams params) { service::FieldResult { impl.getHasPreviousPage(std::move(params)) } }; }; -} // namespace PageInfoStubs +template +concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.beginSelectionSet(params) }; +}; + +template +concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.endSelectionSet(params) }; +}; + +} // namespace stub::PageInfoStubs class PageInfo : public service::Object @@ -41,6 +52,9 @@ class PageInfo { virtual ~Concept() = default; + virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual service::FieldResult getHasNextPage(service::FieldParams&& params) const = 0; virtual service::FieldResult getHasPreviousPage(service::FieldParams&& params) const = 0; }; @@ -54,9 +68,25 @@ class PageInfo { } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::PageInfoStubs::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::PageInfoStubs::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + service::FieldResult getHasNextPage(service::FieldParams&& params) const final { - if constexpr (PageInfoStubs::HasHasNextPage) + if constexpr (stub::PageInfoStubs::HasHasNextPage) { return { _pimpl->getHasNextPage(std::move(params)) }; } @@ -68,7 +98,7 @@ class PageInfo service::FieldResult getHasPreviousPage(service::FieldParams&& params) const final { - if constexpr (PageInfoStubs::HasHasPreviousPage) + if constexpr (stub::PageInfoStubs::HasHasPreviousPage) { return { _pimpl->getHasPreviousPage(std::move(params)) }; } @@ -84,6 +114,9 @@ class PageInfo PageInfo(std::unique_ptr&& pimpl); + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; + const std::unique_ptr _pimpl; public: diff --git a/samples/separate/QueryObject.cpp b/samples/separate/QueryObject.cpp index 7767ac0a..0b395e44 100644 --- a/samples/separate/QueryObject.cpp +++ b/samples/separate/QueryObject.cpp @@ -43,6 +43,16 @@ Query::Query(std::unique_ptr&& pimpl) { } +void Query::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void Query::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} + service::AwaitableResolver Query::resolveNode(service::ResolverParams&& params) { auto argId = service::ModifiedArgument::require("id", params.arguments); diff --git a/samples/separate/QueryObject.h b/samples/separate/QueryObject.h index 0bd082be..6098c42a 100644 --- a/samples/separate/QueryObject.h +++ b/samples/separate/QueryObject.h @@ -11,8 +11,7 @@ #include "TodaySchema.h" namespace graphql::today::object { - -namespace QueryStubs { +namespace stub::QueryStubs { template concept HasNode = requires (TImpl impl, service::FieldParams params, response::IdType idArg) @@ -86,7 +85,19 @@ concept HasAnyType = requires (TImpl impl, service::FieldParams params, std::vec { service::FieldResult>> { impl.getAnyType(std::move(params), std::move(idsArg)) } }; }; -} // namespace QueryStubs +template +concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.beginSelectionSet(params) }; +}; + +template +concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.endSelectionSet(params) }; +}; + +} // namespace stub::QueryStubs class Query : public service::Object @@ -115,6 +126,9 @@ class Query { virtual ~Concept() = default; + virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual service::FieldResult> getNode(service::FieldParams&& params, response::IdType&& idArg) const = 0; virtual service::FieldResult> getAppointments(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const = 0; virtual service::FieldResult> getTasks(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const = 0; @@ -138,9 +152,25 @@ class Query { } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::QueryStubs::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::QueryStubs::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + service::FieldResult> getNode(service::FieldParams&& params, response::IdType&& idArg) const final { - if constexpr (QueryStubs::HasNode) + if constexpr (stub::QueryStubs::HasNode) { return { _pimpl->getNode(std::move(params), std::move(idArg)) }; } @@ -152,7 +182,7 @@ class Query service::FieldResult> getAppointments(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const final { - if constexpr (QueryStubs::HasAppointments) + if constexpr (stub::QueryStubs::HasAppointments) { return { _pimpl->getAppointments(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) }; } @@ -164,7 +194,7 @@ class Query service::FieldResult> getTasks(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const final { - if constexpr (QueryStubs::HasTasks) + if constexpr (stub::QueryStubs::HasTasks) { return { _pimpl->getTasks(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) }; } @@ -176,7 +206,7 @@ class Query service::FieldResult> getUnreadCounts(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const final { - if constexpr (QueryStubs::HasUnreadCounts) + if constexpr (stub::QueryStubs::HasUnreadCounts) { return { _pimpl->getUnreadCounts(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) }; } @@ -188,7 +218,7 @@ class Query service::FieldResult>> getAppointmentsById(service::FieldParams&& params, std::vector&& idsArg) const final { - if constexpr (QueryStubs::HasAppointmentsById) + if constexpr (stub::QueryStubs::HasAppointmentsById) { return { _pimpl->getAppointmentsById(std::move(params), std::move(idsArg)) }; } @@ -200,7 +230,7 @@ class Query service::FieldResult>> getTasksById(service::FieldParams&& params, std::vector&& idsArg) const final { - if constexpr (QueryStubs::HasTasksById) + if constexpr (stub::QueryStubs::HasTasksById) { return { _pimpl->getTasksById(std::move(params), std::move(idsArg)) }; } @@ -212,7 +242,7 @@ class Query service::FieldResult>> getUnreadCountsById(service::FieldParams&& params, std::vector&& idsArg) const final { - if constexpr (QueryStubs::HasUnreadCountsById) + if constexpr (stub::QueryStubs::HasUnreadCountsById) { return { _pimpl->getUnreadCountsById(std::move(params), std::move(idsArg)) }; } @@ -224,7 +254,7 @@ class Query service::FieldResult> getNested(service::FieldParams&& params) const final { - if constexpr (QueryStubs::HasNested) + if constexpr (stub::QueryStubs::HasNested) { return { _pimpl->getNested(std::move(params)) }; } @@ -236,7 +266,7 @@ class Query service::FieldResult getUnimplemented(service::FieldParams&& params) const final { - if constexpr (QueryStubs::HasUnimplemented) + if constexpr (stub::QueryStubs::HasUnimplemented) { return { _pimpl->getUnimplemented(std::move(params)) }; } @@ -248,7 +278,7 @@ class Query service::FieldResult>> getExpensive(service::FieldParams&& params) const final { - if constexpr (QueryStubs::HasExpensive) + if constexpr (stub::QueryStubs::HasExpensive) { return { _pimpl->getExpensive(std::move(params)) }; } @@ -260,7 +290,7 @@ class Query service::FieldResult getTestTaskState(service::FieldParams&& params) const final { - if constexpr (QueryStubs::HasTestTaskState) + if constexpr (stub::QueryStubs::HasTestTaskState) { return { _pimpl->getTestTaskState(std::move(params)) }; } @@ -272,7 +302,7 @@ class Query service::FieldResult>> getAnyType(service::FieldParams&& params, std::vector&& idsArg) const final { - if constexpr (QueryStubs::HasAnyType) + if constexpr (stub::QueryStubs::HasAnyType) { return { _pimpl->getAnyType(std::move(params), std::move(idsArg)) }; } @@ -288,6 +318,9 @@ class Query Query(std::unique_ptr&& pimpl); + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; + const std::unique_ptr _pimpl; public: diff --git a/samples/separate/SubscriptionObject.cpp b/samples/separate/SubscriptionObject.cpp index 949f4914..fa8caecc 100644 --- a/samples/separate/SubscriptionObject.cpp +++ b/samples/separate/SubscriptionObject.cpp @@ -30,6 +30,16 @@ Subscription::Subscription(std::unique_ptr&& pimpl) { } +void Subscription::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void Subscription::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} + service::AwaitableResolver Subscription::resolveNextAppointmentChange(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); diff --git a/samples/separate/SubscriptionObject.h b/samples/separate/SubscriptionObject.h index 62178ef9..252ac8b8 100644 --- a/samples/separate/SubscriptionObject.h +++ b/samples/separate/SubscriptionObject.h @@ -11,8 +11,7 @@ #include "TodaySchema.h" namespace graphql::today::object { - -namespace SubscriptionStubs { +namespace stub::SubscriptionStubs { template concept HasNextAppointmentChange = requires (TImpl impl, service::FieldParams params) @@ -26,7 +25,19 @@ concept HasNodeChange = requires (TImpl impl, service::FieldParams params, respo { service::FieldResult> { impl.getNodeChange(std::move(params), std::move(idArg)) } }; }; -} // namespace SubscriptionStubs +template +concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.beginSelectionSet(params) }; +}; + +template +concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.endSelectionSet(params) }; +}; + +} // namespace stub::SubscriptionStubs class Subscription : public service::Object @@ -41,6 +52,9 @@ class Subscription { virtual ~Concept() = default; + virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual service::FieldResult> getNextAppointmentChange(service::FieldParams&& params) const = 0; virtual service::FieldResult> getNodeChange(service::FieldParams&& params, response::IdType&& idArg) const = 0; }; @@ -54,9 +68,25 @@ class Subscription { } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::SubscriptionStubs::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::SubscriptionStubs::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + service::FieldResult> getNextAppointmentChange(service::FieldParams&& params) const final { - if constexpr (SubscriptionStubs::HasNextAppointmentChange) + if constexpr (stub::SubscriptionStubs::HasNextAppointmentChange) { return { _pimpl->getNextAppointmentChange(std::move(params)) }; } @@ -68,7 +98,7 @@ class Subscription service::FieldResult> getNodeChange(service::FieldParams&& params, response::IdType&& idArg) const final { - if constexpr (SubscriptionStubs::HasNodeChange) + if constexpr (stub::SubscriptionStubs::HasNodeChange) { return { _pimpl->getNodeChange(std::move(params), std::move(idArg)) }; } @@ -84,6 +114,9 @@ class Subscription Subscription(std::unique_ptr&& pimpl); + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; + const std::unique_ptr _pimpl; public: diff --git a/samples/separate/TaskConnectionObject.cpp b/samples/separate/TaskConnectionObject.cpp index b5053add..97f7084a 100644 --- a/samples/separate/TaskConnectionObject.cpp +++ b/samples/separate/TaskConnectionObject.cpp @@ -30,6 +30,16 @@ TaskConnection::TaskConnection(std::unique_ptr&& pimpl) { } +void TaskConnection::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void TaskConnection::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} + service::AwaitableResolver TaskConnection::resolvePageInfo(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); diff --git a/samples/separate/TaskConnectionObject.h b/samples/separate/TaskConnectionObject.h index 50c78c1e..dd2ca872 100644 --- a/samples/separate/TaskConnectionObject.h +++ b/samples/separate/TaskConnectionObject.h @@ -11,8 +11,7 @@ #include "TodaySchema.h" namespace graphql::today::object { - -namespace TaskConnectionStubs { +namespace stub::TaskConnectionStubs { template concept HasPageInfo = requires (TImpl impl, service::FieldParams params) @@ -26,7 +25,19 @@ concept HasEdges = requires (TImpl impl, service::FieldParams params) { service::FieldResult>>> { impl.getEdges(std::move(params)) } }; }; -} // namespace TaskConnectionStubs +template +concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.beginSelectionSet(params) }; +}; + +template +concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.endSelectionSet(params) }; +}; + +} // namespace stub::TaskConnectionStubs class TaskConnection : public service::Object @@ -41,6 +52,9 @@ class TaskConnection { virtual ~Concept() = default; + virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual service::FieldResult> getPageInfo(service::FieldParams&& params) const = 0; virtual service::FieldResult>>> getEdges(service::FieldParams&& params) const = 0; }; @@ -54,9 +68,25 @@ class TaskConnection { } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::TaskConnectionStubs::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::TaskConnectionStubs::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + service::FieldResult> getPageInfo(service::FieldParams&& params) const final { - if constexpr (TaskConnectionStubs::HasPageInfo) + if constexpr (stub::TaskConnectionStubs::HasPageInfo) { return { _pimpl->getPageInfo(std::move(params)) }; } @@ -68,7 +98,7 @@ class TaskConnection service::FieldResult>>> getEdges(service::FieldParams&& params) const final { - if constexpr (TaskConnectionStubs::HasEdges) + if constexpr (stub::TaskConnectionStubs::HasEdges) { return { _pimpl->getEdges(std::move(params)) }; } @@ -84,6 +114,9 @@ class TaskConnection TaskConnection(std::unique_ptr&& pimpl); + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; + const std::unique_ptr _pimpl; public: diff --git a/samples/separate/TaskEdgeObject.cpp b/samples/separate/TaskEdgeObject.cpp index 422506a8..98103a60 100644 --- a/samples/separate/TaskEdgeObject.cpp +++ b/samples/separate/TaskEdgeObject.cpp @@ -30,6 +30,16 @@ TaskEdge::TaskEdge(std::unique_ptr&& pimpl) { } +void TaskEdge::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void TaskEdge::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} + service::AwaitableResolver TaskEdge::resolveNode(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); diff --git a/samples/separate/TaskEdgeObject.h b/samples/separate/TaskEdgeObject.h index fd5e1556..b763ff84 100644 --- a/samples/separate/TaskEdgeObject.h +++ b/samples/separate/TaskEdgeObject.h @@ -11,8 +11,7 @@ #include "TodaySchema.h" namespace graphql::today::object { - -namespace TaskEdgeStubs { +namespace stub::TaskEdgeStubs { template concept HasNode = requires (TImpl impl, service::FieldParams params) @@ -26,7 +25,19 @@ concept HasCursor = requires (TImpl impl, service::FieldParams params) { service::FieldResult { impl.getCursor(std::move(params)) } }; }; -} // namespace TaskEdgeStubs +template +concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.beginSelectionSet(params) }; +}; + +template +concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.endSelectionSet(params) }; +}; + +} // namespace stub::TaskEdgeStubs class TaskEdge : public service::Object @@ -41,6 +52,9 @@ class TaskEdge { virtual ~Concept() = default; + virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual service::FieldResult> getNode(service::FieldParams&& params) const = 0; virtual service::FieldResult getCursor(service::FieldParams&& params) const = 0; }; @@ -54,9 +68,25 @@ class TaskEdge { } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::TaskEdgeStubs::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::TaskEdgeStubs::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + service::FieldResult> getNode(service::FieldParams&& params) const final { - if constexpr (TaskEdgeStubs::HasNode) + if constexpr (stub::TaskEdgeStubs::HasNode) { return { _pimpl->getNode(std::move(params)) }; } @@ -68,7 +98,7 @@ class TaskEdge service::FieldResult getCursor(service::FieldParams&& params) const final { - if constexpr (TaskEdgeStubs::HasCursor) + if constexpr (stub::TaskEdgeStubs::HasCursor) { return { _pimpl->getCursor(std::move(params)) }; } @@ -84,6 +114,9 @@ class TaskEdge TaskEdge(std::unique_ptr&& pimpl); + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; + const std::unique_ptr _pimpl; public: diff --git a/samples/separate/TaskObject.cpp b/samples/separate/TaskObject.cpp index 60742961..94bd1c58 100644 --- a/samples/separate/TaskObject.cpp +++ b/samples/separate/TaskObject.cpp @@ -33,6 +33,16 @@ Task::Task(std::unique_ptr&& pimpl) { } +void Task::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void Task::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} + service::AwaitableResolver Task::resolveId(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); diff --git a/samples/separate/TaskObject.h b/samples/separate/TaskObject.h index 0cbb17b6..c2f77d57 100644 --- a/samples/separate/TaskObject.h +++ b/samples/separate/TaskObject.h @@ -11,8 +11,7 @@ #include "TodaySchema.h" namespace graphql::today::object { - -namespace TaskStubs { +namespace stub::TaskStubs { template concept HasId = requires (TImpl impl, service::FieldParams params) @@ -32,7 +31,19 @@ concept HasIsComplete = requires (TImpl impl, service::FieldParams params) { service::FieldResult { impl.getIsComplete(std::move(params)) } }; }; -} // namespace TaskStubs +template +concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.beginSelectionSet(params) }; +}; + +template +concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.endSelectionSet(params) }; +}; + +} // namespace stub::TaskStubs class Task : public service::Object @@ -49,6 +60,9 @@ class Task { virtual ~Concept() = default; + virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual service::FieldResult> getTitle(service::FieldParams&& params) const = 0; virtual service::FieldResult getIsComplete(service::FieldParams&& params) const = 0; }; @@ -62,9 +76,25 @@ class Task { } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::TaskStubs::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::TaskStubs::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + service::FieldResult getId(service::FieldParams&& params) const final { - if constexpr (TaskStubs::HasId) + if constexpr (stub::TaskStubs::HasId) { return { _pimpl->getId(std::move(params)) }; } @@ -76,7 +106,7 @@ class Task service::FieldResult> getTitle(service::FieldParams&& params) const final { - if constexpr (TaskStubs::HasTitle) + if constexpr (stub::TaskStubs::HasTitle) { return { _pimpl->getTitle(std::move(params)) }; } @@ -88,7 +118,7 @@ class Task service::FieldResult getIsComplete(service::FieldParams&& params) const final { - if constexpr (TaskStubs::HasIsComplete) + if constexpr (stub::TaskStubs::HasIsComplete) { return { _pimpl->getIsComplete(std::move(params)) }; } @@ -104,6 +134,9 @@ class Task Task(std::unique_ptr&& pimpl); + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; + const std::unique_ptr _pimpl; public: diff --git a/samples/separate_nointrospection/AppointmentConnectionObject.cpp b/samples/separate_nointrospection/AppointmentConnectionObject.cpp index 622e42a9..4925c263 100644 --- a/samples/separate_nointrospection/AppointmentConnectionObject.cpp +++ b/samples/separate_nointrospection/AppointmentConnectionObject.cpp @@ -30,6 +30,16 @@ AppointmentConnection::AppointmentConnection(std::unique_ptr&& pimpl) { } +void AppointmentConnection::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void AppointmentConnection::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} + service::AwaitableResolver AppointmentConnection::resolvePageInfo(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); diff --git a/samples/separate_nointrospection/AppointmentConnectionObject.h b/samples/separate_nointrospection/AppointmentConnectionObject.h index d8e3e2f5..b1769e29 100644 --- a/samples/separate_nointrospection/AppointmentConnectionObject.h +++ b/samples/separate_nointrospection/AppointmentConnectionObject.h @@ -11,8 +11,7 @@ #include "TodaySchema.h" namespace graphql::today::object { - -namespace AppointmentConnectionStubs { +namespace stub::AppointmentConnectionStubs { template concept HasPageInfo = requires (TImpl impl, service::FieldParams params) @@ -26,7 +25,19 @@ concept HasEdges = requires (TImpl impl, service::FieldParams params) { service::FieldResult>>> { impl.getEdges(std::move(params)) } }; }; -} // namespace AppointmentConnectionStubs +template +concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.beginSelectionSet(params) }; +}; + +template +concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.endSelectionSet(params) }; +}; + +} // namespace stub::AppointmentConnectionStubs class AppointmentConnection : public service::Object @@ -41,6 +52,9 @@ class AppointmentConnection { virtual ~Concept() = default; + virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual service::FieldResult> getPageInfo(service::FieldParams&& params) const = 0; virtual service::FieldResult>>> getEdges(service::FieldParams&& params) const = 0; }; @@ -54,9 +68,25 @@ class AppointmentConnection { } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::AppointmentConnectionStubs::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::AppointmentConnectionStubs::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + service::FieldResult> getPageInfo(service::FieldParams&& params) const final { - if constexpr (AppointmentConnectionStubs::HasPageInfo) + if constexpr (stub::AppointmentConnectionStubs::HasPageInfo) { return { _pimpl->getPageInfo(std::move(params)) }; } @@ -68,7 +98,7 @@ class AppointmentConnection service::FieldResult>>> getEdges(service::FieldParams&& params) const final { - if constexpr (AppointmentConnectionStubs::HasEdges) + if constexpr (stub::AppointmentConnectionStubs::HasEdges) { return { _pimpl->getEdges(std::move(params)) }; } @@ -84,6 +114,9 @@ class AppointmentConnection AppointmentConnection(std::unique_ptr&& pimpl); + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; + const std::unique_ptr _pimpl; public: diff --git a/samples/separate_nointrospection/AppointmentEdgeObject.cpp b/samples/separate_nointrospection/AppointmentEdgeObject.cpp index df02bd88..eff163fc 100644 --- a/samples/separate_nointrospection/AppointmentEdgeObject.cpp +++ b/samples/separate_nointrospection/AppointmentEdgeObject.cpp @@ -30,6 +30,16 @@ AppointmentEdge::AppointmentEdge(std::unique_ptr&& pimpl) { } +void AppointmentEdge::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void AppointmentEdge::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} + service::AwaitableResolver AppointmentEdge::resolveNode(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); diff --git a/samples/separate_nointrospection/AppointmentEdgeObject.h b/samples/separate_nointrospection/AppointmentEdgeObject.h index 7adc12b1..75b15875 100644 --- a/samples/separate_nointrospection/AppointmentEdgeObject.h +++ b/samples/separate_nointrospection/AppointmentEdgeObject.h @@ -11,8 +11,7 @@ #include "TodaySchema.h" namespace graphql::today::object { - -namespace AppointmentEdgeStubs { +namespace stub::AppointmentEdgeStubs { template concept HasNode = requires (TImpl impl, service::FieldParams params) @@ -26,7 +25,19 @@ concept HasCursor = requires (TImpl impl, service::FieldParams params) { service::FieldResult { impl.getCursor(std::move(params)) } }; }; -} // namespace AppointmentEdgeStubs +template +concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.beginSelectionSet(params) }; +}; + +template +concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.endSelectionSet(params) }; +}; + +} // namespace stub::AppointmentEdgeStubs class AppointmentEdge : public service::Object @@ -41,6 +52,9 @@ class AppointmentEdge { virtual ~Concept() = default; + virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual service::FieldResult> getNode(service::FieldParams&& params) const = 0; virtual service::FieldResult getCursor(service::FieldParams&& params) const = 0; }; @@ -54,9 +68,25 @@ class AppointmentEdge { } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::AppointmentEdgeStubs::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::AppointmentEdgeStubs::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + service::FieldResult> getNode(service::FieldParams&& params) const final { - if constexpr (AppointmentEdgeStubs::HasNode) + if constexpr (stub::AppointmentEdgeStubs::HasNode) { return { _pimpl->getNode(std::move(params)) }; } @@ -68,7 +98,7 @@ class AppointmentEdge service::FieldResult getCursor(service::FieldParams&& params) const final { - if constexpr (AppointmentEdgeStubs::HasCursor) + if constexpr (stub::AppointmentEdgeStubs::HasCursor) { return { _pimpl->getCursor(std::move(params)) }; } @@ -84,6 +114,9 @@ class AppointmentEdge AppointmentEdge(std::unique_ptr&& pimpl); + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; + const std::unique_ptr _pimpl; public: diff --git a/samples/separate_nointrospection/AppointmentObject.cpp b/samples/separate_nointrospection/AppointmentObject.cpp index 30b83427..228bdcff 100644 --- a/samples/separate_nointrospection/AppointmentObject.cpp +++ b/samples/separate_nointrospection/AppointmentObject.cpp @@ -35,6 +35,16 @@ Appointment::Appointment(std::unique_ptr&& pimpl) { } +void Appointment::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void Appointment::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} + service::AwaitableResolver Appointment::resolveId(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); diff --git a/samples/separate_nointrospection/AppointmentObject.h b/samples/separate_nointrospection/AppointmentObject.h index 1a1188af..e20b8661 100644 --- a/samples/separate_nointrospection/AppointmentObject.h +++ b/samples/separate_nointrospection/AppointmentObject.h @@ -11,8 +11,7 @@ #include "TodaySchema.h" namespace graphql::today::object { - -namespace AppointmentStubs { +namespace stub::AppointmentStubs { template concept HasId = requires (TImpl impl, service::FieldParams params) @@ -44,7 +43,19 @@ concept HasForceError = requires (TImpl impl, service::FieldParams params) { service::FieldResult> { impl.getForceError(std::move(params)) } }; }; -} // namespace AppointmentStubs +template +concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.beginSelectionSet(params) }; +}; + +template +concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.endSelectionSet(params) }; +}; + +} // namespace stub::AppointmentStubs class Appointment : public service::Object @@ -63,6 +74,9 @@ class Appointment { virtual ~Concept() = default; + virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual service::FieldResult> getWhen(service::FieldParams&& params) const = 0; virtual service::FieldResult> getSubject(service::FieldParams&& params) const = 0; virtual service::FieldResult getIsNow(service::FieldParams&& params) const = 0; @@ -78,9 +92,25 @@ class Appointment { } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::AppointmentStubs::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::AppointmentStubs::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + service::FieldResult getId(service::FieldParams&& params) const final { - if constexpr (AppointmentStubs::HasId) + if constexpr (stub::AppointmentStubs::HasId) { return { _pimpl->getId(std::move(params)) }; } @@ -92,7 +122,7 @@ class Appointment service::FieldResult> getWhen(service::FieldParams&& params) const final { - if constexpr (AppointmentStubs::HasWhen) + if constexpr (stub::AppointmentStubs::HasWhen) { return { _pimpl->getWhen(std::move(params)) }; } @@ -104,7 +134,7 @@ class Appointment service::FieldResult> getSubject(service::FieldParams&& params) const final { - if constexpr (AppointmentStubs::HasSubject) + if constexpr (stub::AppointmentStubs::HasSubject) { return { _pimpl->getSubject(std::move(params)) }; } @@ -116,7 +146,7 @@ class Appointment service::FieldResult getIsNow(service::FieldParams&& params) const final { - if constexpr (AppointmentStubs::HasIsNow) + if constexpr (stub::AppointmentStubs::HasIsNow) { return { _pimpl->getIsNow(std::move(params)) }; } @@ -128,7 +158,7 @@ class Appointment service::FieldResult> getForceError(service::FieldParams&& params) const final { - if constexpr (AppointmentStubs::HasForceError) + if constexpr (stub::AppointmentStubs::HasForceError) { return { _pimpl->getForceError(std::move(params)) }; } @@ -144,6 +174,9 @@ class Appointment Appointment(std::unique_ptr&& pimpl); + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; + const std::unique_ptr _pimpl; public: diff --git a/samples/separate_nointrospection/CompleteTaskPayloadObject.cpp b/samples/separate_nointrospection/CompleteTaskPayloadObject.cpp index 2924a90c..b6b85919 100644 --- a/samples/separate_nointrospection/CompleteTaskPayloadObject.cpp +++ b/samples/separate_nointrospection/CompleteTaskPayloadObject.cpp @@ -30,6 +30,16 @@ CompleteTaskPayload::CompleteTaskPayload(std::unique_ptr&& pimpl) { } +void CompleteTaskPayload::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void CompleteTaskPayload::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} + service::AwaitableResolver CompleteTaskPayload::resolveTask(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); diff --git a/samples/separate_nointrospection/CompleteTaskPayloadObject.h b/samples/separate_nointrospection/CompleteTaskPayloadObject.h index b4603d44..c3ae3927 100644 --- a/samples/separate_nointrospection/CompleteTaskPayloadObject.h +++ b/samples/separate_nointrospection/CompleteTaskPayloadObject.h @@ -11,8 +11,7 @@ #include "TodaySchema.h" namespace graphql::today::object { - -namespace CompleteTaskPayloadStubs { +namespace stub::CompleteTaskPayloadStubs { template concept HasTask = requires (TImpl impl, service::FieldParams params) @@ -26,7 +25,19 @@ concept HasClientMutationId = requires (TImpl impl, service::FieldParams params) { service::FieldResult> { impl.getClientMutationId(std::move(params)) } }; }; -} // namespace CompleteTaskPayloadStubs +template +concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.beginSelectionSet(params) }; +}; + +template +concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.endSelectionSet(params) }; +}; + +} // namespace stub::CompleteTaskPayloadStubs class CompleteTaskPayload : public service::Object @@ -41,6 +52,9 @@ class CompleteTaskPayload { virtual ~Concept() = default; + virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual service::FieldResult> getTask(service::FieldParams&& params) const = 0; virtual service::FieldResult> getClientMutationId(service::FieldParams&& params) const = 0; }; @@ -54,9 +68,25 @@ class CompleteTaskPayload { } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::CompleteTaskPayloadStubs::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::CompleteTaskPayloadStubs::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + service::FieldResult> getTask(service::FieldParams&& params) const final { - if constexpr (CompleteTaskPayloadStubs::HasTask) + if constexpr (stub::CompleteTaskPayloadStubs::HasTask) { return { _pimpl->getTask(std::move(params)) }; } @@ -68,7 +98,7 @@ class CompleteTaskPayload service::FieldResult> getClientMutationId(service::FieldParams&& params) const final { - if constexpr (CompleteTaskPayloadStubs::HasClientMutationId) + if constexpr (stub::CompleteTaskPayloadStubs::HasClientMutationId) { return { _pimpl->getClientMutationId(std::move(params)) }; } @@ -84,6 +114,9 @@ class CompleteTaskPayload CompleteTaskPayload(std::unique_ptr&& pimpl); + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; + const std::unique_ptr _pimpl; public: diff --git a/samples/separate_nointrospection/ExpensiveObject.cpp b/samples/separate_nointrospection/ExpensiveObject.cpp index d8634115..16528213 100644 --- a/samples/separate_nointrospection/ExpensiveObject.cpp +++ b/samples/separate_nointrospection/ExpensiveObject.cpp @@ -29,6 +29,16 @@ Expensive::Expensive(std::unique_ptr&& pimpl) { } +void Expensive::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void Expensive::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} + service::AwaitableResolver Expensive::resolveOrder(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); diff --git a/samples/separate_nointrospection/ExpensiveObject.h b/samples/separate_nointrospection/ExpensiveObject.h index 347cff6f..5a388c99 100644 --- a/samples/separate_nointrospection/ExpensiveObject.h +++ b/samples/separate_nointrospection/ExpensiveObject.h @@ -11,8 +11,7 @@ #include "TodaySchema.h" namespace graphql::today::object { - -namespace ExpensiveStubs { +namespace stub::ExpensiveStubs { template concept HasOrder = requires (TImpl impl, service::FieldParams params) @@ -20,7 +19,19 @@ concept HasOrder = requires (TImpl impl, service::FieldParams params) { service::FieldResult { impl.getOrder(std::move(params)) } }; }; -} // namespace ExpensiveStubs +template +concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.beginSelectionSet(params) }; +}; + +template +concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.endSelectionSet(params) }; +}; + +} // namespace stub::ExpensiveStubs class Expensive : public service::Object @@ -34,6 +45,9 @@ class Expensive { virtual ~Concept() = default; + virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual service::FieldResult getOrder(service::FieldParams&& params) const = 0; }; @@ -46,9 +60,25 @@ class Expensive { } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::ExpensiveStubs::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::ExpensiveStubs::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + service::FieldResult getOrder(service::FieldParams&& params) const final { - if constexpr (ExpensiveStubs::HasOrder) + if constexpr (stub::ExpensiveStubs::HasOrder) { return { _pimpl->getOrder(std::move(params)) }; } @@ -64,6 +94,9 @@ class Expensive Expensive(std::unique_ptr&& pimpl); + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; + const std::unique_ptr _pimpl; public: diff --git a/samples/separate_nointrospection/FolderConnectionObject.cpp b/samples/separate_nointrospection/FolderConnectionObject.cpp index 26c4ab6d..a9ac2ff5 100644 --- a/samples/separate_nointrospection/FolderConnectionObject.cpp +++ b/samples/separate_nointrospection/FolderConnectionObject.cpp @@ -30,6 +30,16 @@ FolderConnection::FolderConnection(std::unique_ptr&& pimpl) { } +void FolderConnection::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void FolderConnection::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} + service::AwaitableResolver FolderConnection::resolvePageInfo(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); diff --git a/samples/separate_nointrospection/FolderConnectionObject.h b/samples/separate_nointrospection/FolderConnectionObject.h index f7c88190..ffa4a7f0 100644 --- a/samples/separate_nointrospection/FolderConnectionObject.h +++ b/samples/separate_nointrospection/FolderConnectionObject.h @@ -11,8 +11,7 @@ #include "TodaySchema.h" namespace graphql::today::object { - -namespace FolderConnectionStubs { +namespace stub::FolderConnectionStubs { template concept HasPageInfo = requires (TImpl impl, service::FieldParams params) @@ -26,7 +25,19 @@ concept HasEdges = requires (TImpl impl, service::FieldParams params) { service::FieldResult>>> { impl.getEdges(std::move(params)) } }; }; -} // namespace FolderConnectionStubs +template +concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.beginSelectionSet(params) }; +}; + +template +concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.endSelectionSet(params) }; +}; + +} // namespace stub::FolderConnectionStubs class FolderConnection : public service::Object @@ -41,6 +52,9 @@ class FolderConnection { virtual ~Concept() = default; + virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual service::FieldResult> getPageInfo(service::FieldParams&& params) const = 0; virtual service::FieldResult>>> getEdges(service::FieldParams&& params) const = 0; }; @@ -54,9 +68,25 @@ class FolderConnection { } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::FolderConnectionStubs::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::FolderConnectionStubs::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + service::FieldResult> getPageInfo(service::FieldParams&& params) const final { - if constexpr (FolderConnectionStubs::HasPageInfo) + if constexpr (stub::FolderConnectionStubs::HasPageInfo) { return { _pimpl->getPageInfo(std::move(params)) }; } @@ -68,7 +98,7 @@ class FolderConnection service::FieldResult>>> getEdges(service::FieldParams&& params) const final { - if constexpr (FolderConnectionStubs::HasEdges) + if constexpr (stub::FolderConnectionStubs::HasEdges) { return { _pimpl->getEdges(std::move(params)) }; } @@ -84,6 +114,9 @@ class FolderConnection FolderConnection(std::unique_ptr&& pimpl); + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; + const std::unique_ptr _pimpl; public: diff --git a/samples/separate_nointrospection/FolderEdgeObject.cpp b/samples/separate_nointrospection/FolderEdgeObject.cpp index a3b31b14..bd741d44 100644 --- a/samples/separate_nointrospection/FolderEdgeObject.cpp +++ b/samples/separate_nointrospection/FolderEdgeObject.cpp @@ -30,6 +30,16 @@ FolderEdge::FolderEdge(std::unique_ptr&& pimpl) { } +void FolderEdge::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void FolderEdge::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} + service::AwaitableResolver FolderEdge::resolveNode(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); diff --git a/samples/separate_nointrospection/FolderEdgeObject.h b/samples/separate_nointrospection/FolderEdgeObject.h index a089a110..f030a84f 100644 --- a/samples/separate_nointrospection/FolderEdgeObject.h +++ b/samples/separate_nointrospection/FolderEdgeObject.h @@ -11,8 +11,7 @@ #include "TodaySchema.h" namespace graphql::today::object { - -namespace FolderEdgeStubs { +namespace stub::FolderEdgeStubs { template concept HasNode = requires (TImpl impl, service::FieldParams params) @@ -26,7 +25,19 @@ concept HasCursor = requires (TImpl impl, service::FieldParams params) { service::FieldResult { impl.getCursor(std::move(params)) } }; }; -} // namespace FolderEdgeStubs +template +concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.beginSelectionSet(params) }; +}; + +template +concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.endSelectionSet(params) }; +}; + +} // namespace stub::FolderEdgeStubs class FolderEdge : public service::Object @@ -41,6 +52,9 @@ class FolderEdge { virtual ~Concept() = default; + virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual service::FieldResult> getNode(service::FieldParams&& params) const = 0; virtual service::FieldResult getCursor(service::FieldParams&& params) const = 0; }; @@ -54,9 +68,25 @@ class FolderEdge { } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::FolderEdgeStubs::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::FolderEdgeStubs::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + service::FieldResult> getNode(service::FieldParams&& params) const final { - if constexpr (FolderEdgeStubs::HasNode) + if constexpr (stub::FolderEdgeStubs::HasNode) { return { _pimpl->getNode(std::move(params)) }; } @@ -68,7 +98,7 @@ class FolderEdge service::FieldResult getCursor(service::FieldParams&& params) const final { - if constexpr (FolderEdgeStubs::HasCursor) + if constexpr (stub::FolderEdgeStubs::HasCursor) { return { _pimpl->getCursor(std::move(params)) }; } @@ -84,6 +114,9 @@ class FolderEdge FolderEdge(std::unique_ptr&& pimpl); + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; + const std::unique_ptr _pimpl; public: diff --git a/samples/separate_nointrospection/FolderObject.cpp b/samples/separate_nointrospection/FolderObject.cpp index b95936e9..c425c3ff 100644 --- a/samples/separate_nointrospection/FolderObject.cpp +++ b/samples/separate_nointrospection/FolderObject.cpp @@ -33,6 +33,16 @@ Folder::Folder(std::unique_ptr&& pimpl) { } +void Folder::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void Folder::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} + service::AwaitableResolver Folder::resolveId(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); diff --git a/samples/separate_nointrospection/FolderObject.h b/samples/separate_nointrospection/FolderObject.h index 52414320..64c2882b 100644 --- a/samples/separate_nointrospection/FolderObject.h +++ b/samples/separate_nointrospection/FolderObject.h @@ -11,8 +11,7 @@ #include "TodaySchema.h" namespace graphql::today::object { - -namespace FolderStubs { +namespace stub::FolderStubs { template concept HasId = requires (TImpl impl, service::FieldParams params) @@ -32,7 +31,19 @@ concept HasUnreadCount = requires (TImpl impl, service::FieldParams params) { service::FieldResult { impl.getUnreadCount(std::move(params)) } }; }; -} // namespace FolderStubs +template +concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.beginSelectionSet(params) }; +}; + +template +concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.endSelectionSet(params) }; +}; + +} // namespace stub::FolderStubs class Folder : public service::Object @@ -49,6 +60,9 @@ class Folder { virtual ~Concept() = default; + virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual service::FieldResult> getName(service::FieldParams&& params) const = 0; virtual service::FieldResult getUnreadCount(service::FieldParams&& params) const = 0; }; @@ -62,9 +76,25 @@ class Folder { } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::FolderStubs::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::FolderStubs::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + service::FieldResult getId(service::FieldParams&& params) const final { - if constexpr (FolderStubs::HasId) + if constexpr (stub::FolderStubs::HasId) { return { _pimpl->getId(std::move(params)) }; } @@ -76,7 +106,7 @@ class Folder service::FieldResult> getName(service::FieldParams&& params) const final { - if constexpr (FolderStubs::HasName) + if constexpr (stub::FolderStubs::HasName) { return { _pimpl->getName(std::move(params)) }; } @@ -88,7 +118,7 @@ class Folder service::FieldResult getUnreadCount(service::FieldParams&& params) const final { - if constexpr (FolderStubs::HasUnreadCount) + if constexpr (stub::FolderStubs::HasUnreadCount) { return { _pimpl->getUnreadCount(std::move(params)) }; } @@ -104,6 +134,9 @@ class Folder Folder(std::unique_ptr&& pimpl); + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; + const std::unique_ptr _pimpl; public: diff --git a/samples/separate_nointrospection/MutationObject.cpp b/samples/separate_nointrospection/MutationObject.cpp index 20ee2188..6f41f9a0 100644 --- a/samples/separate_nointrospection/MutationObject.cpp +++ b/samples/separate_nointrospection/MutationObject.cpp @@ -30,6 +30,16 @@ Mutation::Mutation(std::unique_ptr&& pimpl) { } +void Mutation::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void Mutation::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} + service::AwaitableResolver Mutation::resolveCompleteTask(service::ResolverParams&& params) { auto argInput = service::ModifiedArgument::require("input", params.arguments); diff --git a/samples/separate_nointrospection/MutationObject.h b/samples/separate_nointrospection/MutationObject.h index fc34f52f..f1ecd666 100644 --- a/samples/separate_nointrospection/MutationObject.h +++ b/samples/separate_nointrospection/MutationObject.h @@ -11,8 +11,7 @@ #include "TodaySchema.h" namespace graphql::today::object { - -namespace MutationStubs { +namespace stub::MutationStubs { template concept HasCompleteTask = requires (TImpl impl, service::FieldParams params, CompleteTaskInput inputArg) @@ -26,7 +25,19 @@ concept HasSetFloat = requires (TImpl impl, service::FieldParams params, respons { service::FieldResult { impl.applySetFloat(std::move(params), std::move(valueArg)) } }; }; -} // namespace MutationStubs +template +concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.beginSelectionSet(params) }; +}; + +template +concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.endSelectionSet(params) }; +}; + +} // namespace stub::MutationStubs class Mutation : public service::Object @@ -41,6 +52,9 @@ class Mutation { virtual ~Concept() = default; + virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual service::FieldResult> applyCompleteTask(service::FieldParams&& params, CompleteTaskInput&& inputArg) const = 0; virtual service::FieldResult applySetFloat(service::FieldParams&& params, response::FloatType&& valueArg) const = 0; }; @@ -54,9 +68,25 @@ class Mutation { } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::MutationStubs::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::MutationStubs::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + service::FieldResult> applyCompleteTask(service::FieldParams&& params, CompleteTaskInput&& inputArg) const final { - if constexpr (MutationStubs::HasCompleteTask) + if constexpr (stub::MutationStubs::HasCompleteTask) { return { _pimpl->applyCompleteTask(std::move(params), std::move(inputArg)) }; } @@ -68,7 +98,7 @@ class Mutation service::FieldResult applySetFloat(service::FieldParams&& params, response::FloatType&& valueArg) const final { - if constexpr (MutationStubs::HasSetFloat) + if constexpr (stub::MutationStubs::HasSetFloat) { return { _pimpl->applySetFloat(std::move(params), std::move(valueArg)) }; } @@ -84,6 +114,9 @@ class Mutation Mutation(std::unique_ptr&& pimpl); + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; + const std::unique_ptr _pimpl; public: diff --git a/samples/separate_nointrospection/NestedTypeObject.cpp b/samples/separate_nointrospection/NestedTypeObject.cpp index fc80a6bb..76b9bf57 100644 --- a/samples/separate_nointrospection/NestedTypeObject.cpp +++ b/samples/separate_nointrospection/NestedTypeObject.cpp @@ -30,6 +30,16 @@ NestedType::NestedType(std::unique_ptr&& pimpl) { } +void NestedType::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void NestedType::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} + service::AwaitableResolver NestedType::resolveDepth(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); diff --git a/samples/separate_nointrospection/NestedTypeObject.h b/samples/separate_nointrospection/NestedTypeObject.h index 3278036a..ce9f276e 100644 --- a/samples/separate_nointrospection/NestedTypeObject.h +++ b/samples/separate_nointrospection/NestedTypeObject.h @@ -11,8 +11,7 @@ #include "TodaySchema.h" namespace graphql::today::object { - -namespace NestedTypeStubs { +namespace stub::NestedTypeStubs { template concept HasDepth = requires (TImpl impl, service::FieldParams params) @@ -26,7 +25,19 @@ concept HasNested = requires (TImpl impl, service::FieldParams params) { service::FieldResult> { impl.getNested(std::move(params)) } }; }; -} // namespace NestedTypeStubs +template +concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.beginSelectionSet(params) }; +}; + +template +concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.endSelectionSet(params) }; +}; + +} // namespace stub::NestedTypeStubs class NestedType : public service::Object @@ -41,6 +52,9 @@ class NestedType { virtual ~Concept() = default; + virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual service::FieldResult getDepth(service::FieldParams&& params) const = 0; virtual service::FieldResult> getNested(service::FieldParams&& params) const = 0; }; @@ -54,9 +68,25 @@ class NestedType { } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::NestedTypeStubs::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::NestedTypeStubs::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + service::FieldResult getDepth(service::FieldParams&& params) const final { - if constexpr (NestedTypeStubs::HasDepth) + if constexpr (stub::NestedTypeStubs::HasDepth) { return { _pimpl->getDepth(std::move(params)) }; } @@ -68,7 +98,7 @@ class NestedType service::FieldResult> getNested(service::FieldParams&& params) const final { - if constexpr (NestedTypeStubs::HasNested) + if constexpr (stub::NestedTypeStubs::HasNested) { return { _pimpl->getNested(std::move(params)) }; } @@ -84,6 +114,9 @@ class NestedType NestedType(std::unique_ptr&& pimpl); + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; + const std::unique_ptr _pimpl; public: diff --git a/samples/separate_nointrospection/PageInfoObject.cpp b/samples/separate_nointrospection/PageInfoObject.cpp index d406c9f2..e0cc198f 100644 --- a/samples/separate_nointrospection/PageInfoObject.cpp +++ b/samples/separate_nointrospection/PageInfoObject.cpp @@ -30,6 +30,16 @@ PageInfo::PageInfo(std::unique_ptr&& pimpl) { } +void PageInfo::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void PageInfo::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} + service::AwaitableResolver PageInfo::resolveHasNextPage(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); diff --git a/samples/separate_nointrospection/PageInfoObject.h b/samples/separate_nointrospection/PageInfoObject.h index 2f160b3c..675ff995 100644 --- a/samples/separate_nointrospection/PageInfoObject.h +++ b/samples/separate_nointrospection/PageInfoObject.h @@ -11,8 +11,7 @@ #include "TodaySchema.h" namespace graphql::today::object { - -namespace PageInfoStubs { +namespace stub::PageInfoStubs { template concept HasHasNextPage = requires (TImpl impl, service::FieldParams params) @@ -26,7 +25,19 @@ concept HasHasPreviousPage = requires (TImpl impl, service::FieldParams params) { service::FieldResult { impl.getHasPreviousPage(std::move(params)) } }; }; -} // namespace PageInfoStubs +template +concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.beginSelectionSet(params) }; +}; + +template +concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.endSelectionSet(params) }; +}; + +} // namespace stub::PageInfoStubs class PageInfo : public service::Object @@ -41,6 +52,9 @@ class PageInfo { virtual ~Concept() = default; + virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual service::FieldResult getHasNextPage(service::FieldParams&& params) const = 0; virtual service::FieldResult getHasPreviousPage(service::FieldParams&& params) const = 0; }; @@ -54,9 +68,25 @@ class PageInfo { } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::PageInfoStubs::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::PageInfoStubs::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + service::FieldResult getHasNextPage(service::FieldParams&& params) const final { - if constexpr (PageInfoStubs::HasHasNextPage) + if constexpr (stub::PageInfoStubs::HasHasNextPage) { return { _pimpl->getHasNextPage(std::move(params)) }; } @@ -68,7 +98,7 @@ class PageInfo service::FieldResult getHasPreviousPage(service::FieldParams&& params) const final { - if constexpr (PageInfoStubs::HasHasPreviousPage) + if constexpr (stub::PageInfoStubs::HasHasPreviousPage) { return { _pimpl->getHasPreviousPage(std::move(params)) }; } @@ -84,6 +114,9 @@ class PageInfo PageInfo(std::unique_ptr&& pimpl); + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; + const std::unique_ptr _pimpl; public: diff --git a/samples/separate_nointrospection/QueryObject.cpp b/samples/separate_nointrospection/QueryObject.cpp index dad53db8..76ac8a85 100644 --- a/samples/separate_nointrospection/QueryObject.cpp +++ b/samples/separate_nointrospection/QueryObject.cpp @@ -40,6 +40,16 @@ Query::Query(std::unique_ptr&& pimpl) { } +void Query::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void Query::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} + service::AwaitableResolver Query::resolveNode(service::ResolverParams&& params) { auto argId = service::ModifiedArgument::require("id", params.arguments); diff --git a/samples/separate_nointrospection/QueryObject.h b/samples/separate_nointrospection/QueryObject.h index 0a1db1d0..d703e0c0 100644 --- a/samples/separate_nointrospection/QueryObject.h +++ b/samples/separate_nointrospection/QueryObject.h @@ -11,8 +11,7 @@ #include "TodaySchema.h" namespace graphql::today::object { - -namespace QueryStubs { +namespace stub::QueryStubs { template concept HasNode = requires (TImpl impl, service::FieldParams params, response::IdType idArg) @@ -86,7 +85,19 @@ concept HasAnyType = requires (TImpl impl, service::FieldParams params, std::vec { service::FieldResult>> { impl.getAnyType(std::move(params), std::move(idsArg)) } }; }; -} // namespace QueryStubs +template +concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.beginSelectionSet(params) }; +}; + +template +concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.endSelectionSet(params) }; +}; + +} // namespace stub::QueryStubs class Query : public service::Object @@ -111,6 +122,9 @@ class Query { virtual ~Concept() = default; + virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual service::FieldResult> getNode(service::FieldParams&& params, response::IdType&& idArg) const = 0; virtual service::FieldResult> getAppointments(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const = 0; virtual service::FieldResult> getTasks(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const = 0; @@ -134,9 +148,25 @@ class Query { } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::QueryStubs::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::QueryStubs::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + service::FieldResult> getNode(service::FieldParams&& params, response::IdType&& idArg) const final { - if constexpr (QueryStubs::HasNode) + if constexpr (stub::QueryStubs::HasNode) { return { _pimpl->getNode(std::move(params), std::move(idArg)) }; } @@ -148,7 +178,7 @@ class Query service::FieldResult> getAppointments(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const final { - if constexpr (QueryStubs::HasAppointments) + if constexpr (stub::QueryStubs::HasAppointments) { return { _pimpl->getAppointments(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) }; } @@ -160,7 +190,7 @@ class Query service::FieldResult> getTasks(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const final { - if constexpr (QueryStubs::HasTasks) + if constexpr (stub::QueryStubs::HasTasks) { return { _pimpl->getTasks(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) }; } @@ -172,7 +202,7 @@ class Query service::FieldResult> getUnreadCounts(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const final { - if constexpr (QueryStubs::HasUnreadCounts) + if constexpr (stub::QueryStubs::HasUnreadCounts) { return { _pimpl->getUnreadCounts(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) }; } @@ -184,7 +214,7 @@ class Query service::FieldResult>> getAppointmentsById(service::FieldParams&& params, std::vector&& idsArg) const final { - if constexpr (QueryStubs::HasAppointmentsById) + if constexpr (stub::QueryStubs::HasAppointmentsById) { return { _pimpl->getAppointmentsById(std::move(params), std::move(idsArg)) }; } @@ -196,7 +226,7 @@ class Query service::FieldResult>> getTasksById(service::FieldParams&& params, std::vector&& idsArg) const final { - if constexpr (QueryStubs::HasTasksById) + if constexpr (stub::QueryStubs::HasTasksById) { return { _pimpl->getTasksById(std::move(params), std::move(idsArg)) }; } @@ -208,7 +238,7 @@ class Query service::FieldResult>> getUnreadCountsById(service::FieldParams&& params, std::vector&& idsArg) const final { - if constexpr (QueryStubs::HasUnreadCountsById) + if constexpr (stub::QueryStubs::HasUnreadCountsById) { return { _pimpl->getUnreadCountsById(std::move(params), std::move(idsArg)) }; } @@ -220,7 +250,7 @@ class Query service::FieldResult> getNested(service::FieldParams&& params) const final { - if constexpr (QueryStubs::HasNested) + if constexpr (stub::QueryStubs::HasNested) { return { _pimpl->getNested(std::move(params)) }; } @@ -232,7 +262,7 @@ class Query service::FieldResult getUnimplemented(service::FieldParams&& params) const final { - if constexpr (QueryStubs::HasUnimplemented) + if constexpr (stub::QueryStubs::HasUnimplemented) { return { _pimpl->getUnimplemented(std::move(params)) }; } @@ -244,7 +274,7 @@ class Query service::FieldResult>> getExpensive(service::FieldParams&& params) const final { - if constexpr (QueryStubs::HasExpensive) + if constexpr (stub::QueryStubs::HasExpensive) { return { _pimpl->getExpensive(std::move(params)) }; } @@ -256,7 +286,7 @@ class Query service::FieldResult getTestTaskState(service::FieldParams&& params) const final { - if constexpr (QueryStubs::HasTestTaskState) + if constexpr (stub::QueryStubs::HasTestTaskState) { return { _pimpl->getTestTaskState(std::move(params)) }; } @@ -268,7 +298,7 @@ class Query service::FieldResult>> getAnyType(service::FieldParams&& params, std::vector&& idsArg) const final { - if constexpr (QueryStubs::HasAnyType) + if constexpr (stub::QueryStubs::HasAnyType) { return { _pimpl->getAnyType(std::move(params), std::move(idsArg)) }; } @@ -284,6 +314,9 @@ class Query Query(std::unique_ptr&& pimpl); + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; + const std::unique_ptr _pimpl; public: diff --git a/samples/separate_nointrospection/SubscriptionObject.cpp b/samples/separate_nointrospection/SubscriptionObject.cpp index 949f4914..fa8caecc 100644 --- a/samples/separate_nointrospection/SubscriptionObject.cpp +++ b/samples/separate_nointrospection/SubscriptionObject.cpp @@ -30,6 +30,16 @@ Subscription::Subscription(std::unique_ptr&& pimpl) { } +void Subscription::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void Subscription::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} + service::AwaitableResolver Subscription::resolveNextAppointmentChange(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); diff --git a/samples/separate_nointrospection/SubscriptionObject.h b/samples/separate_nointrospection/SubscriptionObject.h index 62178ef9..252ac8b8 100644 --- a/samples/separate_nointrospection/SubscriptionObject.h +++ b/samples/separate_nointrospection/SubscriptionObject.h @@ -11,8 +11,7 @@ #include "TodaySchema.h" namespace graphql::today::object { - -namespace SubscriptionStubs { +namespace stub::SubscriptionStubs { template concept HasNextAppointmentChange = requires (TImpl impl, service::FieldParams params) @@ -26,7 +25,19 @@ concept HasNodeChange = requires (TImpl impl, service::FieldParams params, respo { service::FieldResult> { impl.getNodeChange(std::move(params), std::move(idArg)) } }; }; -} // namespace SubscriptionStubs +template +concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.beginSelectionSet(params) }; +}; + +template +concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.endSelectionSet(params) }; +}; + +} // namespace stub::SubscriptionStubs class Subscription : public service::Object @@ -41,6 +52,9 @@ class Subscription { virtual ~Concept() = default; + virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual service::FieldResult> getNextAppointmentChange(service::FieldParams&& params) const = 0; virtual service::FieldResult> getNodeChange(service::FieldParams&& params, response::IdType&& idArg) const = 0; }; @@ -54,9 +68,25 @@ class Subscription { } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::SubscriptionStubs::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::SubscriptionStubs::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + service::FieldResult> getNextAppointmentChange(service::FieldParams&& params) const final { - if constexpr (SubscriptionStubs::HasNextAppointmentChange) + if constexpr (stub::SubscriptionStubs::HasNextAppointmentChange) { return { _pimpl->getNextAppointmentChange(std::move(params)) }; } @@ -68,7 +98,7 @@ class Subscription service::FieldResult> getNodeChange(service::FieldParams&& params, response::IdType&& idArg) const final { - if constexpr (SubscriptionStubs::HasNodeChange) + if constexpr (stub::SubscriptionStubs::HasNodeChange) { return { _pimpl->getNodeChange(std::move(params), std::move(idArg)) }; } @@ -84,6 +114,9 @@ class Subscription Subscription(std::unique_ptr&& pimpl); + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; + const std::unique_ptr _pimpl; public: diff --git a/samples/separate_nointrospection/TaskConnectionObject.cpp b/samples/separate_nointrospection/TaskConnectionObject.cpp index b5053add..97f7084a 100644 --- a/samples/separate_nointrospection/TaskConnectionObject.cpp +++ b/samples/separate_nointrospection/TaskConnectionObject.cpp @@ -30,6 +30,16 @@ TaskConnection::TaskConnection(std::unique_ptr&& pimpl) { } +void TaskConnection::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void TaskConnection::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} + service::AwaitableResolver TaskConnection::resolvePageInfo(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); diff --git a/samples/separate_nointrospection/TaskConnectionObject.h b/samples/separate_nointrospection/TaskConnectionObject.h index 50c78c1e..dd2ca872 100644 --- a/samples/separate_nointrospection/TaskConnectionObject.h +++ b/samples/separate_nointrospection/TaskConnectionObject.h @@ -11,8 +11,7 @@ #include "TodaySchema.h" namespace graphql::today::object { - -namespace TaskConnectionStubs { +namespace stub::TaskConnectionStubs { template concept HasPageInfo = requires (TImpl impl, service::FieldParams params) @@ -26,7 +25,19 @@ concept HasEdges = requires (TImpl impl, service::FieldParams params) { service::FieldResult>>> { impl.getEdges(std::move(params)) } }; }; -} // namespace TaskConnectionStubs +template +concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.beginSelectionSet(params) }; +}; + +template +concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.endSelectionSet(params) }; +}; + +} // namespace stub::TaskConnectionStubs class TaskConnection : public service::Object @@ -41,6 +52,9 @@ class TaskConnection { virtual ~Concept() = default; + virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual service::FieldResult> getPageInfo(service::FieldParams&& params) const = 0; virtual service::FieldResult>>> getEdges(service::FieldParams&& params) const = 0; }; @@ -54,9 +68,25 @@ class TaskConnection { } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::TaskConnectionStubs::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::TaskConnectionStubs::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + service::FieldResult> getPageInfo(service::FieldParams&& params) const final { - if constexpr (TaskConnectionStubs::HasPageInfo) + if constexpr (stub::TaskConnectionStubs::HasPageInfo) { return { _pimpl->getPageInfo(std::move(params)) }; } @@ -68,7 +98,7 @@ class TaskConnection service::FieldResult>>> getEdges(service::FieldParams&& params) const final { - if constexpr (TaskConnectionStubs::HasEdges) + if constexpr (stub::TaskConnectionStubs::HasEdges) { return { _pimpl->getEdges(std::move(params)) }; } @@ -84,6 +114,9 @@ class TaskConnection TaskConnection(std::unique_ptr&& pimpl); + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; + const std::unique_ptr _pimpl; public: diff --git a/samples/separate_nointrospection/TaskEdgeObject.cpp b/samples/separate_nointrospection/TaskEdgeObject.cpp index 422506a8..98103a60 100644 --- a/samples/separate_nointrospection/TaskEdgeObject.cpp +++ b/samples/separate_nointrospection/TaskEdgeObject.cpp @@ -30,6 +30,16 @@ TaskEdge::TaskEdge(std::unique_ptr&& pimpl) { } +void TaskEdge::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void TaskEdge::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} + service::AwaitableResolver TaskEdge::resolveNode(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); diff --git a/samples/separate_nointrospection/TaskEdgeObject.h b/samples/separate_nointrospection/TaskEdgeObject.h index fd5e1556..b763ff84 100644 --- a/samples/separate_nointrospection/TaskEdgeObject.h +++ b/samples/separate_nointrospection/TaskEdgeObject.h @@ -11,8 +11,7 @@ #include "TodaySchema.h" namespace graphql::today::object { - -namespace TaskEdgeStubs { +namespace stub::TaskEdgeStubs { template concept HasNode = requires (TImpl impl, service::FieldParams params) @@ -26,7 +25,19 @@ concept HasCursor = requires (TImpl impl, service::FieldParams params) { service::FieldResult { impl.getCursor(std::move(params)) } }; }; -} // namespace TaskEdgeStubs +template +concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.beginSelectionSet(params) }; +}; + +template +concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.endSelectionSet(params) }; +}; + +} // namespace stub::TaskEdgeStubs class TaskEdge : public service::Object @@ -41,6 +52,9 @@ class TaskEdge { virtual ~Concept() = default; + virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual service::FieldResult> getNode(service::FieldParams&& params) const = 0; virtual service::FieldResult getCursor(service::FieldParams&& params) const = 0; }; @@ -54,9 +68,25 @@ class TaskEdge { } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::TaskEdgeStubs::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::TaskEdgeStubs::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + service::FieldResult> getNode(service::FieldParams&& params) const final { - if constexpr (TaskEdgeStubs::HasNode) + if constexpr (stub::TaskEdgeStubs::HasNode) { return { _pimpl->getNode(std::move(params)) }; } @@ -68,7 +98,7 @@ class TaskEdge service::FieldResult getCursor(service::FieldParams&& params) const final { - if constexpr (TaskEdgeStubs::HasCursor) + if constexpr (stub::TaskEdgeStubs::HasCursor) { return { _pimpl->getCursor(std::move(params)) }; } @@ -84,6 +114,9 @@ class TaskEdge TaskEdge(std::unique_ptr&& pimpl); + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; + const std::unique_ptr _pimpl; public: diff --git a/samples/separate_nointrospection/TaskObject.cpp b/samples/separate_nointrospection/TaskObject.cpp index 60742961..94bd1c58 100644 --- a/samples/separate_nointrospection/TaskObject.cpp +++ b/samples/separate_nointrospection/TaskObject.cpp @@ -33,6 +33,16 @@ Task::Task(std::unique_ptr&& pimpl) { } +void Task::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void Task::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} + service::AwaitableResolver Task::resolveId(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); diff --git a/samples/separate_nointrospection/TaskObject.h b/samples/separate_nointrospection/TaskObject.h index 0cbb17b6..c2f77d57 100644 --- a/samples/separate_nointrospection/TaskObject.h +++ b/samples/separate_nointrospection/TaskObject.h @@ -11,8 +11,7 @@ #include "TodaySchema.h" namespace graphql::today::object { - -namespace TaskStubs { +namespace stub::TaskStubs { template concept HasId = requires (TImpl impl, service::FieldParams params) @@ -32,7 +31,19 @@ concept HasIsComplete = requires (TImpl impl, service::FieldParams params) { service::FieldResult { impl.getIsComplete(std::move(params)) } }; }; -} // namespace TaskStubs +template +concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.beginSelectionSet(params) }; +}; + +template +concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.endSelectionSet(params) }; +}; + +} // namespace stub::TaskStubs class Task : public service::Object @@ -49,6 +60,9 @@ class Task { virtual ~Concept() = default; + virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual service::FieldResult> getTitle(service::FieldParams&& params) const = 0; virtual service::FieldResult getIsComplete(service::FieldParams&& params) const = 0; }; @@ -62,9 +76,25 @@ class Task { } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::TaskStubs::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::TaskStubs::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + service::FieldResult getId(service::FieldParams&& params) const final { - if constexpr (TaskStubs::HasId) + if constexpr (stub::TaskStubs::HasId) { return { _pimpl->getId(std::move(params)) }; } @@ -76,7 +106,7 @@ class Task service::FieldResult> getTitle(service::FieldParams&& params) const final { - if constexpr (TaskStubs::HasTitle) + if constexpr (stub::TaskStubs::HasTitle) { return { _pimpl->getTitle(std::move(params)) }; } @@ -88,7 +118,7 @@ class Task service::FieldResult getIsComplete(service::FieldParams&& params) const final { - if constexpr (TaskStubs::HasIsComplete) + if constexpr (stub::TaskStubs::HasIsComplete) { return { _pimpl->getIsComplete(std::move(params)) }; } @@ -104,6 +134,9 @@ class Task Task(std::unique_ptr&& pimpl); + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; + const std::unique_ptr _pimpl; public: diff --git a/samples/unified/TodaySchema.cpp b/samples/unified/TodaySchema.cpp index c3716d3e..c843a1f9 100644 --- a/samples/unified/TodaySchema.cpp +++ b/samples/unified/TodaySchema.cpp @@ -166,6 +166,16 @@ Query::Query(std::unique_ptr&& pimpl) { } +void Query::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void Query::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} + service::AwaitableResolver Query::resolveNode(service::ResolverParams&& params) { auto argId = service::ModifiedArgument::require("id", params.arguments); @@ -356,6 +366,16 @@ PageInfo::PageInfo(std::unique_ptr&& pimpl) { } +void PageInfo::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void PageInfo::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} + service::AwaitableResolver PageInfo::resolveHasNextPage(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); @@ -393,6 +413,16 @@ AppointmentEdge::AppointmentEdge(std::unique_ptr&& pimpl) { } +void AppointmentEdge::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void AppointmentEdge::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} + service::AwaitableResolver AppointmentEdge::resolveNode(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); @@ -430,6 +460,16 @@ AppointmentConnection::AppointmentConnection(std::unique_ptr&& pimpl) { } +void AppointmentConnection::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void AppointmentConnection::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} + service::AwaitableResolver AppointmentConnection::resolvePageInfo(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); @@ -467,6 +507,16 @@ TaskEdge::TaskEdge(std::unique_ptr&& pimpl) { } +void TaskEdge::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void TaskEdge::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} + service::AwaitableResolver TaskEdge::resolveNode(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); @@ -504,6 +554,16 @@ TaskConnection::TaskConnection(std::unique_ptr&& pimpl) { } +void TaskConnection::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void TaskConnection::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} + service::AwaitableResolver TaskConnection::resolvePageInfo(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); @@ -541,6 +601,16 @@ FolderEdge::FolderEdge(std::unique_ptr&& pimpl) { } +void FolderEdge::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void FolderEdge::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} + service::AwaitableResolver FolderEdge::resolveNode(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); @@ -578,6 +648,16 @@ FolderConnection::FolderConnection(std::unique_ptr&& pimpl) { } +void FolderConnection::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void FolderConnection::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} + service::AwaitableResolver FolderConnection::resolvePageInfo(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); @@ -615,6 +695,16 @@ CompleteTaskPayload::CompleteTaskPayload(std::unique_ptr&& pimpl) { } +void CompleteTaskPayload::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void CompleteTaskPayload::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} + service::AwaitableResolver CompleteTaskPayload::resolveTask(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); @@ -652,6 +742,16 @@ Mutation::Mutation(std::unique_ptr&& pimpl) { } +void Mutation::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void Mutation::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} + service::AwaitableResolver Mutation::resolveCompleteTask(service::ResolverParams&& params) { auto argInput = service::ModifiedArgument::require("input", params.arguments); @@ -691,6 +791,16 @@ Subscription::Subscription(std::unique_ptr&& pimpl) { } +void Subscription::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void Subscription::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} + service::AwaitableResolver Subscription::resolveNextAppointmentChange(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); @@ -734,6 +844,16 @@ Appointment::Appointment(std::unique_ptr&& pimpl) { } +void Appointment::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void Appointment::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} + service::AwaitableResolver Appointment::resolveId(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); @@ -804,6 +924,16 @@ Task::Task(std::unique_ptr&& pimpl) { } +void Task::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void Task::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} + service::AwaitableResolver Task::resolveId(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); @@ -854,6 +984,16 @@ Folder::Folder(std::unique_ptr&& pimpl) { } +void Folder::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void Folder::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} + service::AwaitableResolver Folder::resolveId(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); @@ -901,6 +1041,16 @@ NestedType::NestedType(std::unique_ptr&& pimpl) { } +void NestedType::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void NestedType::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} + service::AwaitableResolver NestedType::resolveDepth(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); @@ -937,6 +1087,16 @@ Expensive::Expensive(std::unique_ptr&& pimpl) { } +void Expensive::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void Expensive::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} + service::AwaitableResolver Expensive::resolveOrder(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); diff --git a/samples/unified/TodaySchema.h b/samples/unified/TodaySchema.h index 06ccb574..839e68d0 100644 --- a/samples/unified/TodaySchema.h +++ b/samples/unified/TodaySchema.h @@ -87,49 +87,495 @@ struct Node }; namespace object { +namespace stub { +namespace QueryStubs { + +template +concept HasNode = requires (TImpl impl, service::FieldParams params, response::IdType idArg) +{ + { service::FieldResult> { impl.getNode(std::move(params), std::move(idArg)) } }; +}; + +template +concept HasAppointments = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) +{ + { service::FieldResult> { impl.getAppointments(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; +}; + +template +concept HasTasks = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) +{ + { service::FieldResult> { impl.getTasks(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; +}; + +template +concept HasUnreadCounts = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) +{ + { service::FieldResult> { impl.getUnreadCounts(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; +}; + +template +concept HasAppointmentsById = requires (TImpl impl, service::FieldParams params, std::vector idsArg) +{ + { service::FieldResult>> { impl.getAppointmentsById(std::move(params), std::move(idsArg)) } }; +}; + +template +concept HasTasksById = requires (TImpl impl, service::FieldParams params, std::vector idsArg) +{ + { service::FieldResult>> { impl.getTasksById(std::move(params), std::move(idsArg)) } }; +}; + +template +concept HasUnreadCountsById = requires (TImpl impl, service::FieldParams params, std::vector idsArg) +{ + { service::FieldResult>> { impl.getUnreadCountsById(std::move(params), std::move(idsArg)) } }; +}; + +template +concept HasNested = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult> { impl.getNested(std::move(params)) } }; +}; + +template +concept HasUnimplemented = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult { impl.getUnimplemented(std::move(params)) } }; +}; + +template +concept HasExpensive = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult>> { impl.getExpensive(std::move(params)) } }; +}; + +template +concept HasTestTaskState = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult { impl.getTestTaskState(std::move(params)) } }; +}; + +template +concept HasAnyType = requires (TImpl impl, service::FieldParams params, std::vector idsArg) +{ + { service::FieldResult>> { impl.getAnyType(std::move(params), std::move(idsArg)) } }; +}; + +template +concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.beginSelectionSet(params) }; +}; + +template +concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.endSelectionSet(params) }; +}; + +} // namespace QueryStubs + +namespace PageInfoStubs { + +template +concept HasHasNextPage = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult { impl.getHasNextPage(std::move(params)) } }; +}; + +template +concept HasHasPreviousPage = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult { impl.getHasPreviousPage(std::move(params)) } }; +}; + +template +concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.beginSelectionSet(params) }; +}; + +template +concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.endSelectionSet(params) }; +}; + +} // namespace PageInfoStubs + +namespace AppointmentEdgeStubs { + +template +concept HasNode = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult> { impl.getNode(std::move(params)) } }; +}; + +template +concept HasCursor = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult { impl.getCursor(std::move(params)) } }; +}; + +template +concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.beginSelectionSet(params) }; +}; + +template +concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.endSelectionSet(params) }; +}; + +} // namespace AppointmentEdgeStubs + +namespace AppointmentConnectionStubs { + +template +concept HasPageInfo = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult> { impl.getPageInfo(std::move(params)) } }; +}; + +template +concept HasEdges = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult>>> { impl.getEdges(std::move(params)) } }; +}; + +template +concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.beginSelectionSet(params) }; +}; + +template +concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.endSelectionSet(params) }; +}; + +} // namespace AppointmentConnectionStubs + +namespace TaskEdgeStubs { + +template +concept HasNode = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult> { impl.getNode(std::move(params)) } }; +}; + +template +concept HasCursor = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult { impl.getCursor(std::move(params)) } }; +}; + +template +concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.beginSelectionSet(params) }; +}; + +template +concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.endSelectionSet(params) }; +}; + +} // namespace TaskEdgeStubs + +namespace TaskConnectionStubs { + +template +concept HasPageInfo = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult> { impl.getPageInfo(std::move(params)) } }; +}; + +template +concept HasEdges = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult>>> { impl.getEdges(std::move(params)) } }; +}; + +template +concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.beginSelectionSet(params) }; +}; + +template +concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.endSelectionSet(params) }; +}; + +} // namespace TaskConnectionStubs + +namespace FolderEdgeStubs { + +template +concept HasNode = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult> { impl.getNode(std::move(params)) } }; +}; + +template +concept HasCursor = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult { impl.getCursor(std::move(params)) } }; +}; + +template +concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.beginSelectionSet(params) }; +}; + +template +concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.endSelectionSet(params) }; +}; + +} // namespace FolderEdgeStubs + +namespace FolderConnectionStubs { + +template +concept HasPageInfo = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult> { impl.getPageInfo(std::move(params)) } }; +}; + +template +concept HasEdges = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult>>> { impl.getEdges(std::move(params)) } }; +}; + +template +concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.beginSelectionSet(params) }; +}; + +template +concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.endSelectionSet(params) }; +}; + +} // namespace FolderConnectionStubs + +namespace CompleteTaskPayloadStubs { + +template +concept HasTask = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult> { impl.getTask(std::move(params)) } }; +}; + +template +concept HasClientMutationId = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult> { impl.getClientMutationId(std::move(params)) } }; +}; + +template +concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.beginSelectionSet(params) }; +}; + +template +concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.endSelectionSet(params) }; +}; + +} // namespace CompleteTaskPayloadStubs + +namespace MutationStubs { + +template +concept HasCompleteTask = requires (TImpl impl, service::FieldParams params, CompleteTaskInput inputArg) +{ + { service::FieldResult> { impl.applyCompleteTask(std::move(params), std::move(inputArg)) } }; +}; + +template +concept HasSetFloat = requires (TImpl impl, service::FieldParams params, response::FloatType valueArg) +{ + { service::FieldResult { impl.applySetFloat(std::move(params), std::move(valueArg)) } }; +}; + +template +concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.beginSelectionSet(params) }; +}; + +template +concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.endSelectionSet(params) }; +}; + +} // namespace MutationStubs + +namespace SubscriptionStubs { + +template +concept HasNextAppointmentChange = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult> { impl.getNextAppointmentChange(std::move(params)) } }; +}; + +template +concept HasNodeChange = requires (TImpl impl, service::FieldParams params, response::IdType idArg) +{ + { service::FieldResult> { impl.getNodeChange(std::move(params), std::move(idArg)) } }; +}; + +template +concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.beginSelectionSet(params) }; +}; + +template +concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.endSelectionSet(params) }; +}; + +} // namespace SubscriptionStubs + +namespace AppointmentStubs { + +template +concept HasId = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult { impl.getId(std::move(params)) } }; +}; + +template +concept HasWhen = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult> { impl.getWhen(std::move(params)) } }; +}; + +template +concept HasSubject = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult> { impl.getSubject(std::move(params)) } }; +}; + +template +concept HasIsNow = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult { impl.getIsNow(std::move(params)) } }; +}; + +template +concept HasForceError = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult> { impl.getForceError(std::move(params)) } }; +}; + +template +concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.beginSelectionSet(params) }; +}; + +template +concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.endSelectionSet(params) }; +}; + +} // namespace AppointmentStubs + +namespace TaskStubs { + +template +concept HasId = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult { impl.getId(std::move(params)) } }; +}; + +template +concept HasTitle = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult> { impl.getTitle(std::move(params)) } }; +}; + +template +concept HasIsComplete = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult { impl.getIsComplete(std::move(params)) } }; +}; -namespace QueryStubs { +template +concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.beginSelectionSet(params) }; +}; template -concept HasNode = requires (TImpl impl, service::FieldParams params, response::IdType idArg) +concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { - { service::FieldResult> { impl.getNode(std::move(params), std::move(idArg)) } }; + { impl.endSelectionSet(params) }; }; +} // namespace TaskStubs + +namespace FolderStubs { + template -concept HasAppointments = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) +concept HasId = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult> { impl.getAppointments(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; + { service::FieldResult { impl.getId(std::move(params)) } }; }; template -concept HasTasks = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) +concept HasName = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult> { impl.getTasks(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; + { service::FieldResult> { impl.getName(std::move(params)) } }; }; template -concept HasUnreadCounts = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) +concept HasUnreadCount = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult> { impl.getUnreadCounts(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; + { service::FieldResult { impl.getUnreadCount(std::move(params)) } }; }; template -concept HasAppointmentsById = requires (TImpl impl, service::FieldParams params, std::vector idsArg) +concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { - { service::FieldResult>> { impl.getAppointmentsById(std::move(params), std::move(idsArg)) } }; + { impl.beginSelectionSet(params) }; }; template -concept HasTasksById = requires (TImpl impl, service::FieldParams params, std::vector idsArg) +concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { - { service::FieldResult>> { impl.getTasksById(std::move(params), std::move(idsArg)) } }; + { impl.endSelectionSet(params) }; }; +} // namespace FolderStubs + +namespace NestedTypeStubs { + template -concept HasUnreadCountsById = requires (TImpl impl, service::FieldParams params, std::vector idsArg) +concept HasDepth = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult>> { impl.getUnreadCountsById(std::move(params), std::move(idsArg)) } }; + { service::FieldResult { impl.getDepth(std::move(params)) } }; }; template @@ -139,30 +585,41 @@ concept HasNested = requires (TImpl impl, service::FieldParams params) }; template -concept HasUnimplemented = requires (TImpl impl, service::FieldParams params) +concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { - { service::FieldResult { impl.getUnimplemented(std::move(params)) } }; + { impl.beginSelectionSet(params) }; }; template -concept HasExpensive = requires (TImpl impl, service::FieldParams params) +concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { - { service::FieldResult>> { impl.getExpensive(std::move(params)) } }; + { impl.endSelectionSet(params) }; }; +} // namespace NestedTypeStubs + +namespace ExpensiveStubs { + template -concept HasTestTaskState = requires (TImpl impl, service::FieldParams params) +concept HasOrder = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult { impl.getTestTaskState(std::move(params)) } }; + { service::FieldResult { impl.getOrder(std::move(params)) } }; }; template -concept HasAnyType = requires (TImpl impl, service::FieldParams params, std::vector idsArg) +concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { - { service::FieldResult>> { impl.getAnyType(std::move(params), std::move(idsArg)) } }; + { impl.beginSelectionSet(params) }; }; -} // namespace QueryStubs +template +concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.endSelectionSet(params) }; +}; + +} // namespace ExpensiveStubs +} // namespace stub class Query : public service::Object @@ -191,6 +648,9 @@ class Query { virtual ~Concept() = default; + virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual service::FieldResult> getNode(service::FieldParams&& params, response::IdType&& idArg) const = 0; virtual service::FieldResult> getAppointments(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const = 0; virtual service::FieldResult> getTasks(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const = 0; @@ -214,9 +674,25 @@ class Query { } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::QueryStubs::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::QueryStubs::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + service::FieldResult> getNode(service::FieldParams&& params, response::IdType&& idArg) const final { - if constexpr (QueryStubs::HasNode) + if constexpr (stub::QueryStubs::HasNode) { return { _pimpl->getNode(std::move(params), std::move(idArg)) }; } @@ -228,7 +704,7 @@ class Query service::FieldResult> getAppointments(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const final { - if constexpr (QueryStubs::HasAppointments) + if constexpr (stub::QueryStubs::HasAppointments) { return { _pimpl->getAppointments(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) }; } @@ -240,7 +716,7 @@ class Query service::FieldResult> getTasks(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const final { - if constexpr (QueryStubs::HasTasks) + if constexpr (stub::QueryStubs::HasTasks) { return { _pimpl->getTasks(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) }; } @@ -252,7 +728,7 @@ class Query service::FieldResult> getUnreadCounts(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const final { - if constexpr (QueryStubs::HasUnreadCounts) + if constexpr (stub::QueryStubs::HasUnreadCounts) { return { _pimpl->getUnreadCounts(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) }; } @@ -264,7 +740,7 @@ class Query service::FieldResult>> getAppointmentsById(service::FieldParams&& params, std::vector&& idsArg) const final { - if constexpr (QueryStubs::HasAppointmentsById) + if constexpr (stub::QueryStubs::HasAppointmentsById) { return { _pimpl->getAppointmentsById(std::move(params), std::move(idsArg)) }; } @@ -276,7 +752,7 @@ class Query service::FieldResult>> getTasksById(service::FieldParams&& params, std::vector&& idsArg) const final { - if constexpr (QueryStubs::HasTasksById) + if constexpr (stub::QueryStubs::HasTasksById) { return { _pimpl->getTasksById(std::move(params), std::move(idsArg)) }; } @@ -288,7 +764,7 @@ class Query service::FieldResult>> getUnreadCountsById(service::FieldParams&& params, std::vector&& idsArg) const final { - if constexpr (QueryStubs::HasUnreadCountsById) + if constexpr (stub::QueryStubs::HasUnreadCountsById) { return { _pimpl->getUnreadCountsById(std::move(params), std::move(idsArg)) }; } @@ -300,7 +776,7 @@ class Query service::FieldResult> getNested(service::FieldParams&& params) const final { - if constexpr (QueryStubs::HasNested) + if constexpr (stub::QueryStubs::HasNested) { return { _pimpl->getNested(std::move(params)) }; } @@ -312,7 +788,7 @@ class Query service::FieldResult getUnimplemented(service::FieldParams&& params) const final { - if constexpr (QueryStubs::HasUnimplemented) + if constexpr (stub::QueryStubs::HasUnimplemented) { return { _pimpl->getUnimplemented(std::move(params)) }; } @@ -324,7 +800,7 @@ class Query service::FieldResult>> getExpensive(service::FieldParams&& params) const final { - if constexpr (QueryStubs::HasExpensive) + if constexpr (stub::QueryStubs::HasExpensive) { return { _pimpl->getExpensive(std::move(params)) }; } @@ -336,7 +812,7 @@ class Query service::FieldResult getTestTaskState(service::FieldParams&& params) const final { - if constexpr (QueryStubs::HasTestTaskState) + if constexpr (stub::QueryStubs::HasTestTaskState) { return { _pimpl->getTestTaskState(std::move(params)) }; } @@ -348,7 +824,7 @@ class Query service::FieldResult>> getAnyType(service::FieldParams&& params, std::vector&& idsArg) const final { - if constexpr (QueryStubs::HasAnyType) + if constexpr (stub::QueryStubs::HasAnyType) { return { _pimpl->getAnyType(std::move(params), std::move(idsArg)) }; } @@ -364,6 +840,9 @@ class Query Query(std::unique_ptr&& pimpl); + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; + const std::unique_ptr _pimpl; public: @@ -374,22 +853,6 @@ class Query } }; -namespace PageInfoStubs { - -template -concept HasHasNextPage = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult { impl.getHasNextPage(std::move(params)) } }; -}; - -template -concept HasHasPreviousPage = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult { impl.getHasPreviousPage(std::move(params)) } }; -}; - -} // namespace PageInfoStubs - class PageInfo : public service::Object { @@ -403,6 +866,9 @@ class PageInfo { virtual ~Concept() = default; + virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual service::FieldResult getHasNextPage(service::FieldParams&& params) const = 0; virtual service::FieldResult getHasPreviousPage(service::FieldParams&& params) const = 0; }; @@ -416,9 +882,25 @@ class PageInfo { } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::PageInfoStubs::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::PageInfoStubs::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + service::FieldResult getHasNextPage(service::FieldParams&& params) const final { - if constexpr (PageInfoStubs::HasHasNextPage) + if constexpr (stub::PageInfoStubs::HasHasNextPage) { return { _pimpl->getHasNextPage(std::move(params)) }; } @@ -430,7 +912,7 @@ class PageInfo service::FieldResult getHasPreviousPage(service::FieldParams&& params) const final { - if constexpr (PageInfoStubs::HasHasPreviousPage) + if constexpr (stub::PageInfoStubs::HasHasPreviousPage) { return { _pimpl->getHasPreviousPage(std::move(params)) }; } @@ -446,6 +928,9 @@ class PageInfo PageInfo(std::unique_ptr&& pimpl); + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; + const std::unique_ptr _pimpl; public: @@ -456,22 +941,6 @@ class PageInfo } }; -namespace AppointmentEdgeStubs { - -template -concept HasNode = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getNode(std::move(params)) } }; -}; - -template -concept HasCursor = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult { impl.getCursor(std::move(params)) } }; -}; - -} // namespace AppointmentEdgeStubs - class AppointmentEdge : public service::Object { @@ -485,6 +954,9 @@ class AppointmentEdge { virtual ~Concept() = default; + virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual service::FieldResult> getNode(service::FieldParams&& params) const = 0; virtual service::FieldResult getCursor(service::FieldParams&& params) const = 0; }; @@ -498,9 +970,25 @@ class AppointmentEdge { } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::AppointmentEdgeStubs::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::AppointmentEdgeStubs::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + service::FieldResult> getNode(service::FieldParams&& params) const final { - if constexpr (AppointmentEdgeStubs::HasNode) + if constexpr (stub::AppointmentEdgeStubs::HasNode) { return { _pimpl->getNode(std::move(params)) }; } @@ -512,7 +1000,7 @@ class AppointmentEdge service::FieldResult getCursor(service::FieldParams&& params) const final { - if constexpr (AppointmentEdgeStubs::HasCursor) + if constexpr (stub::AppointmentEdgeStubs::HasCursor) { return { _pimpl->getCursor(std::move(params)) }; } @@ -528,6 +1016,9 @@ class AppointmentEdge AppointmentEdge(std::unique_ptr&& pimpl); + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; + const std::unique_ptr _pimpl; public: @@ -538,22 +1029,6 @@ class AppointmentEdge } }; -namespace AppointmentConnectionStubs { - -template -concept HasPageInfo = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getPageInfo(std::move(params)) } }; -}; - -template -concept HasEdges = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult>>> { impl.getEdges(std::move(params)) } }; -}; - -} // namespace AppointmentConnectionStubs - class AppointmentConnection : public service::Object { @@ -567,6 +1042,9 @@ class AppointmentConnection { virtual ~Concept() = default; + virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual service::FieldResult> getPageInfo(service::FieldParams&& params) const = 0; virtual service::FieldResult>>> getEdges(service::FieldParams&& params) const = 0; }; @@ -580,9 +1058,25 @@ class AppointmentConnection { } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::AppointmentConnectionStubs::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::AppointmentConnectionStubs::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + service::FieldResult> getPageInfo(service::FieldParams&& params) const final { - if constexpr (AppointmentConnectionStubs::HasPageInfo) + if constexpr (stub::AppointmentConnectionStubs::HasPageInfo) { return { _pimpl->getPageInfo(std::move(params)) }; } @@ -594,7 +1088,7 @@ class AppointmentConnection service::FieldResult>>> getEdges(service::FieldParams&& params) const final { - if constexpr (AppointmentConnectionStubs::HasEdges) + if constexpr (stub::AppointmentConnectionStubs::HasEdges) { return { _pimpl->getEdges(std::move(params)) }; } @@ -610,6 +1104,9 @@ class AppointmentConnection AppointmentConnection(std::unique_ptr&& pimpl); + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; + const std::unique_ptr _pimpl; public: @@ -620,22 +1117,6 @@ class AppointmentConnection } }; -namespace TaskEdgeStubs { - -template -concept HasNode = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getNode(std::move(params)) } }; -}; - -template -concept HasCursor = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult { impl.getCursor(std::move(params)) } }; -}; - -} // namespace TaskEdgeStubs - class TaskEdge : public service::Object { @@ -649,6 +1130,9 @@ class TaskEdge { virtual ~Concept() = default; + virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual service::FieldResult> getNode(service::FieldParams&& params) const = 0; virtual service::FieldResult getCursor(service::FieldParams&& params) const = 0; }; @@ -662,9 +1146,25 @@ class TaskEdge { } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::TaskEdgeStubs::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::TaskEdgeStubs::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + service::FieldResult> getNode(service::FieldParams&& params) const final { - if constexpr (TaskEdgeStubs::HasNode) + if constexpr (stub::TaskEdgeStubs::HasNode) { return { _pimpl->getNode(std::move(params)) }; } @@ -676,7 +1176,7 @@ class TaskEdge service::FieldResult getCursor(service::FieldParams&& params) const final { - if constexpr (TaskEdgeStubs::HasCursor) + if constexpr (stub::TaskEdgeStubs::HasCursor) { return { _pimpl->getCursor(std::move(params)) }; } @@ -692,6 +1192,9 @@ class TaskEdge TaskEdge(std::unique_ptr&& pimpl); + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; + const std::unique_ptr _pimpl; public: @@ -702,22 +1205,6 @@ class TaskEdge } }; -namespace TaskConnectionStubs { - -template -concept HasPageInfo = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getPageInfo(std::move(params)) } }; -}; - -template -concept HasEdges = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult>>> { impl.getEdges(std::move(params)) } }; -}; - -} // namespace TaskConnectionStubs - class TaskConnection : public service::Object { @@ -731,6 +1218,9 @@ class TaskConnection { virtual ~Concept() = default; + virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual service::FieldResult> getPageInfo(service::FieldParams&& params) const = 0; virtual service::FieldResult>>> getEdges(service::FieldParams&& params) const = 0; }; @@ -744,9 +1234,25 @@ class TaskConnection { } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::TaskConnectionStubs::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::TaskConnectionStubs::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + service::FieldResult> getPageInfo(service::FieldParams&& params) const final { - if constexpr (TaskConnectionStubs::HasPageInfo) + if constexpr (stub::TaskConnectionStubs::HasPageInfo) { return { _pimpl->getPageInfo(std::move(params)) }; } @@ -758,7 +1264,7 @@ class TaskConnection service::FieldResult>>> getEdges(service::FieldParams&& params) const final { - if constexpr (TaskConnectionStubs::HasEdges) + if constexpr (stub::TaskConnectionStubs::HasEdges) { return { _pimpl->getEdges(std::move(params)) }; } @@ -774,6 +1280,9 @@ class TaskConnection TaskConnection(std::unique_ptr&& pimpl); + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; + const std::unique_ptr _pimpl; public: @@ -784,22 +1293,6 @@ class TaskConnection } }; -namespace FolderEdgeStubs { - -template -concept HasNode = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getNode(std::move(params)) } }; -}; - -template -concept HasCursor = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult { impl.getCursor(std::move(params)) } }; -}; - -} // namespace FolderEdgeStubs - class FolderEdge : public service::Object { @@ -813,6 +1306,9 @@ class FolderEdge { virtual ~Concept() = default; + virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual service::FieldResult> getNode(service::FieldParams&& params) const = 0; virtual service::FieldResult getCursor(service::FieldParams&& params) const = 0; }; @@ -826,9 +1322,25 @@ class FolderEdge { } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::FolderEdgeStubs::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::FolderEdgeStubs::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + service::FieldResult> getNode(service::FieldParams&& params) const final { - if constexpr (FolderEdgeStubs::HasNode) + if constexpr (stub::FolderEdgeStubs::HasNode) { return { _pimpl->getNode(std::move(params)) }; } @@ -840,7 +1352,7 @@ class FolderEdge service::FieldResult getCursor(service::FieldParams&& params) const final { - if constexpr (FolderEdgeStubs::HasCursor) + if constexpr (stub::FolderEdgeStubs::HasCursor) { return { _pimpl->getCursor(std::move(params)) }; } @@ -856,6 +1368,9 @@ class FolderEdge FolderEdge(std::unique_ptr&& pimpl); + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; + const std::unique_ptr _pimpl; public: @@ -866,22 +1381,6 @@ class FolderEdge } }; -namespace FolderConnectionStubs { - -template -concept HasPageInfo = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getPageInfo(std::move(params)) } }; -}; - -template -concept HasEdges = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult>>> { impl.getEdges(std::move(params)) } }; -}; - -} // namespace FolderConnectionStubs - class FolderConnection : public service::Object { @@ -895,6 +1394,9 @@ class FolderConnection { virtual ~Concept() = default; + virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual service::FieldResult> getPageInfo(service::FieldParams&& params) const = 0; virtual service::FieldResult>>> getEdges(service::FieldParams&& params) const = 0; }; @@ -908,9 +1410,25 @@ class FolderConnection { } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::FolderConnectionStubs::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::FolderConnectionStubs::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + service::FieldResult> getPageInfo(service::FieldParams&& params) const final { - if constexpr (FolderConnectionStubs::HasPageInfo) + if constexpr (stub::FolderConnectionStubs::HasPageInfo) { return { _pimpl->getPageInfo(std::move(params)) }; } @@ -922,7 +1440,7 @@ class FolderConnection service::FieldResult>>> getEdges(service::FieldParams&& params) const final { - if constexpr (FolderConnectionStubs::HasEdges) + if constexpr (stub::FolderConnectionStubs::HasEdges) { return { _pimpl->getEdges(std::move(params)) }; } @@ -938,6 +1456,9 @@ class FolderConnection FolderConnection(std::unique_ptr&& pimpl); + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; + const std::unique_ptr _pimpl; public: @@ -948,22 +1469,6 @@ class FolderConnection } }; -namespace CompleteTaskPayloadStubs { - -template -concept HasTask = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getTask(std::move(params)) } }; -}; - -template -concept HasClientMutationId = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getClientMutationId(std::move(params)) } }; -}; - -} // namespace CompleteTaskPayloadStubs - class CompleteTaskPayload : public service::Object { @@ -977,6 +1482,9 @@ class CompleteTaskPayload { virtual ~Concept() = default; + virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual service::FieldResult> getTask(service::FieldParams&& params) const = 0; virtual service::FieldResult> getClientMutationId(service::FieldParams&& params) const = 0; }; @@ -990,9 +1498,25 @@ class CompleteTaskPayload { } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::CompleteTaskPayloadStubs::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::CompleteTaskPayloadStubs::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + service::FieldResult> getTask(service::FieldParams&& params) const final { - if constexpr (CompleteTaskPayloadStubs::HasTask) + if constexpr (stub::CompleteTaskPayloadStubs::HasTask) { return { _pimpl->getTask(std::move(params)) }; } @@ -1004,7 +1528,7 @@ class CompleteTaskPayload service::FieldResult> getClientMutationId(service::FieldParams&& params) const final { - if constexpr (CompleteTaskPayloadStubs::HasClientMutationId) + if constexpr (stub::CompleteTaskPayloadStubs::HasClientMutationId) { return { _pimpl->getClientMutationId(std::move(params)) }; } @@ -1020,6 +1544,9 @@ class CompleteTaskPayload CompleteTaskPayload(std::unique_ptr&& pimpl); + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; + const std::unique_ptr _pimpl; public: @@ -1030,22 +1557,6 @@ class CompleteTaskPayload } }; -namespace MutationStubs { - -template -concept HasCompleteTask = requires (TImpl impl, service::FieldParams params, CompleteTaskInput inputArg) -{ - { service::FieldResult> { impl.applyCompleteTask(std::move(params), std::move(inputArg)) } }; -}; - -template -concept HasSetFloat = requires (TImpl impl, service::FieldParams params, response::FloatType valueArg) -{ - { service::FieldResult { impl.applySetFloat(std::move(params), std::move(valueArg)) } }; -}; - -} // namespace MutationStubs - class Mutation : public service::Object { @@ -1059,6 +1570,9 @@ class Mutation { virtual ~Concept() = default; + virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual service::FieldResult> applyCompleteTask(service::FieldParams&& params, CompleteTaskInput&& inputArg) const = 0; virtual service::FieldResult applySetFloat(service::FieldParams&& params, response::FloatType&& valueArg) const = 0; }; @@ -1072,9 +1586,25 @@ class Mutation { } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::MutationStubs::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::MutationStubs::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + service::FieldResult> applyCompleteTask(service::FieldParams&& params, CompleteTaskInput&& inputArg) const final { - if constexpr (MutationStubs::HasCompleteTask) + if constexpr (stub::MutationStubs::HasCompleteTask) { return { _pimpl->applyCompleteTask(std::move(params), std::move(inputArg)) }; } @@ -1086,7 +1616,7 @@ class Mutation service::FieldResult applySetFloat(service::FieldParams&& params, response::FloatType&& valueArg) const final { - if constexpr (MutationStubs::HasSetFloat) + if constexpr (stub::MutationStubs::HasSetFloat) { return { _pimpl->applySetFloat(std::move(params), std::move(valueArg)) }; } @@ -1102,6 +1632,9 @@ class Mutation Mutation(std::unique_ptr&& pimpl); + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; + const std::unique_ptr _pimpl; public: @@ -1112,22 +1645,6 @@ class Mutation } }; -namespace SubscriptionStubs { - -template -concept HasNextAppointmentChange = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getNextAppointmentChange(std::move(params)) } }; -}; - -template -concept HasNodeChange = requires (TImpl impl, service::FieldParams params, response::IdType idArg) -{ - { service::FieldResult> { impl.getNodeChange(std::move(params), std::move(idArg)) } }; -}; - -} // namespace SubscriptionStubs - class Subscription : public service::Object { @@ -1141,6 +1658,9 @@ class Subscription { virtual ~Concept() = default; + virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual service::FieldResult> getNextAppointmentChange(service::FieldParams&& params) const = 0; virtual service::FieldResult> getNodeChange(service::FieldParams&& params, response::IdType&& idArg) const = 0; }; @@ -1154,9 +1674,25 @@ class Subscription { } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::SubscriptionStubs::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::SubscriptionStubs::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + service::FieldResult> getNextAppointmentChange(service::FieldParams&& params) const final { - if constexpr (SubscriptionStubs::HasNextAppointmentChange) + if constexpr (stub::SubscriptionStubs::HasNextAppointmentChange) { return { _pimpl->getNextAppointmentChange(std::move(params)) }; } @@ -1168,7 +1704,7 @@ class Subscription service::FieldResult> getNodeChange(service::FieldParams&& params, response::IdType&& idArg) const final { - if constexpr (SubscriptionStubs::HasNodeChange) + if constexpr (stub::SubscriptionStubs::HasNodeChange) { return { _pimpl->getNodeChange(std::move(params), std::move(idArg)) }; } @@ -1184,6 +1720,9 @@ class Subscription Subscription(std::unique_ptr&& pimpl); + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; + const std::unique_ptr _pimpl; public: @@ -1194,40 +1733,6 @@ class Subscription } }; -namespace AppointmentStubs { - -template -concept HasId = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult { impl.getId(std::move(params)) } }; -}; - -template -concept HasWhen = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getWhen(std::move(params)) } }; -}; - -template -concept HasSubject = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getSubject(std::move(params)) } }; -}; - -template -concept HasIsNow = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult { impl.getIsNow(std::move(params)) } }; -}; - -template -concept HasForceError = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getForceError(std::move(params)) } }; -}; - -} // namespace AppointmentStubs - class Appointment : public service::Object { @@ -1245,6 +1750,9 @@ class Appointment { virtual ~Concept() = default; + virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual service::FieldResult> getWhen(service::FieldParams&& params) const = 0; virtual service::FieldResult> getSubject(service::FieldParams&& params) const = 0; virtual service::FieldResult getIsNow(service::FieldParams&& params) const = 0; @@ -1260,9 +1768,25 @@ class Appointment { } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::AppointmentStubs::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::AppointmentStubs::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + service::FieldResult getId(service::FieldParams&& params) const final { - if constexpr (AppointmentStubs::HasId) + if constexpr (stub::AppointmentStubs::HasId) { return { _pimpl->getId(std::move(params)) }; } @@ -1274,7 +1798,7 @@ class Appointment service::FieldResult> getWhen(service::FieldParams&& params) const final { - if constexpr (AppointmentStubs::HasWhen) + if constexpr (stub::AppointmentStubs::HasWhen) { return { _pimpl->getWhen(std::move(params)) }; } @@ -1286,7 +1810,7 @@ class Appointment service::FieldResult> getSubject(service::FieldParams&& params) const final { - if constexpr (AppointmentStubs::HasSubject) + if constexpr (stub::AppointmentStubs::HasSubject) { return { _pimpl->getSubject(std::move(params)) }; } @@ -1298,7 +1822,7 @@ class Appointment service::FieldResult getIsNow(service::FieldParams&& params) const final { - if constexpr (AppointmentStubs::HasIsNow) + if constexpr (stub::AppointmentStubs::HasIsNow) { return { _pimpl->getIsNow(std::move(params)) }; } @@ -1310,7 +1834,7 @@ class Appointment service::FieldResult> getForceError(service::FieldParams&& params) const final { - if constexpr (AppointmentStubs::HasForceError) + if constexpr (stub::AppointmentStubs::HasForceError) { return { _pimpl->getForceError(std::move(params)) }; } @@ -1326,6 +1850,9 @@ class Appointment Appointment(std::unique_ptr&& pimpl); + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; + const std::unique_ptr _pimpl; public: @@ -1336,28 +1863,6 @@ class Appointment } }; -namespace TaskStubs { - -template -concept HasId = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult { impl.getId(std::move(params)) } }; -}; - -template -concept HasTitle = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getTitle(std::move(params)) } }; -}; - -template -concept HasIsComplete = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult { impl.getIsComplete(std::move(params)) } }; -}; - -} // namespace TaskStubs - class Task : public service::Object { @@ -1373,6 +1878,9 @@ class Task { virtual ~Concept() = default; + virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual service::FieldResult> getTitle(service::FieldParams&& params) const = 0; virtual service::FieldResult getIsComplete(service::FieldParams&& params) const = 0; }; @@ -1386,9 +1894,25 @@ class Task { } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::TaskStubs::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::TaskStubs::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + service::FieldResult getId(service::FieldParams&& params) const final { - if constexpr (TaskStubs::HasId) + if constexpr (stub::TaskStubs::HasId) { return { _pimpl->getId(std::move(params)) }; } @@ -1400,7 +1924,7 @@ class Task service::FieldResult> getTitle(service::FieldParams&& params) const final { - if constexpr (TaskStubs::HasTitle) + if constexpr (stub::TaskStubs::HasTitle) { return { _pimpl->getTitle(std::move(params)) }; } @@ -1412,7 +1936,7 @@ class Task service::FieldResult getIsComplete(service::FieldParams&& params) const final { - if constexpr (TaskStubs::HasIsComplete) + if constexpr (stub::TaskStubs::HasIsComplete) { return { _pimpl->getIsComplete(std::move(params)) }; } @@ -1428,6 +1952,9 @@ class Task Task(std::unique_ptr&& pimpl); + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; + const std::unique_ptr _pimpl; public: @@ -1438,28 +1965,6 @@ class Task } }; -namespace FolderStubs { - -template -concept HasId = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult { impl.getId(std::move(params)) } }; -}; - -template -concept HasName = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getName(std::move(params)) } }; -}; - -template -concept HasUnreadCount = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult { impl.getUnreadCount(std::move(params)) } }; -}; - -} // namespace FolderStubs - class Folder : public service::Object { @@ -1475,6 +1980,9 @@ class Folder { virtual ~Concept() = default; + virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual service::FieldResult> getName(service::FieldParams&& params) const = 0; virtual service::FieldResult getUnreadCount(service::FieldParams&& params) const = 0; }; @@ -1488,9 +1996,25 @@ class Folder { } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::FolderStubs::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::FolderStubs::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + service::FieldResult getId(service::FieldParams&& params) const final { - if constexpr (FolderStubs::HasId) + if constexpr (stub::FolderStubs::HasId) { return { _pimpl->getId(std::move(params)) }; } @@ -1502,7 +2026,7 @@ class Folder service::FieldResult> getName(service::FieldParams&& params) const final { - if constexpr (FolderStubs::HasName) + if constexpr (stub::FolderStubs::HasName) { return { _pimpl->getName(std::move(params)) }; } @@ -1514,7 +2038,7 @@ class Folder service::FieldResult getUnreadCount(service::FieldParams&& params) const final { - if constexpr (FolderStubs::HasUnreadCount) + if constexpr (stub::FolderStubs::HasUnreadCount) { return { _pimpl->getUnreadCount(std::move(params)) }; } @@ -1530,6 +2054,9 @@ class Folder Folder(std::unique_ptr&& pimpl); + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; + const std::unique_ptr _pimpl; public: @@ -1540,22 +2067,6 @@ class Folder } }; -namespace NestedTypeStubs { - -template -concept HasDepth = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult { impl.getDepth(std::move(params)) } }; -}; - -template -concept HasNested = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getNested(std::move(params)) } }; -}; - -} // namespace NestedTypeStubs - class NestedType : public service::Object { @@ -1569,6 +2080,9 @@ class NestedType { virtual ~Concept() = default; + virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual service::FieldResult getDepth(service::FieldParams&& params) const = 0; virtual service::FieldResult> getNested(service::FieldParams&& params) const = 0; }; @@ -1582,9 +2096,25 @@ class NestedType { } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::NestedTypeStubs::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::NestedTypeStubs::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + service::FieldResult getDepth(service::FieldParams&& params) const final { - if constexpr (NestedTypeStubs::HasDepth) + if constexpr (stub::NestedTypeStubs::HasDepth) { return { _pimpl->getDepth(std::move(params)) }; } @@ -1596,7 +2126,7 @@ class NestedType service::FieldResult> getNested(service::FieldParams&& params) const final { - if constexpr (NestedTypeStubs::HasNested) + if constexpr (stub::NestedTypeStubs::HasNested) { return { _pimpl->getNested(std::move(params)) }; } @@ -1612,6 +2142,9 @@ class NestedType NestedType(std::unique_ptr&& pimpl); + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; + const std::unique_ptr _pimpl; public: @@ -1622,16 +2155,6 @@ class NestedType } }; -namespace ExpensiveStubs { - -template -concept HasOrder = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult { impl.getOrder(std::move(params)) } }; -}; - -} // namespace ExpensiveStubs - class Expensive : public service::Object { @@ -1644,6 +2167,9 @@ class Expensive { virtual ~Concept() = default; + virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual service::FieldResult getOrder(service::FieldParams&& params) const = 0; }; @@ -1656,9 +2182,25 @@ class Expensive { } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::ExpensiveStubs::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::ExpensiveStubs::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + service::FieldResult getOrder(service::FieldParams&& params) const final { - if constexpr (ExpensiveStubs::HasOrder) + if constexpr (stub::ExpensiveStubs::HasOrder) { return { _pimpl->getOrder(std::move(params)) }; } @@ -1674,6 +2216,9 @@ class Expensive Expensive(std::unique_ptr&& pimpl); + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; + const std::unique_ptr _pimpl; public: diff --git a/samples/unified_nointrospection/TodaySchema.cpp b/samples/unified_nointrospection/TodaySchema.cpp index b1a9cdaa..5631f604 100644 --- a/samples/unified_nointrospection/TodaySchema.cpp +++ b/samples/unified_nointrospection/TodaySchema.cpp @@ -163,6 +163,16 @@ Query::Query(std::unique_ptr&& pimpl) { } +void Query::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void Query::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} + service::AwaitableResolver Query::resolveNode(service::ResolverParams&& params) { auto argId = service::ModifiedArgument::require("id", params.arguments); @@ -339,6 +349,16 @@ PageInfo::PageInfo(std::unique_ptr&& pimpl) { } +void PageInfo::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void PageInfo::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} + service::AwaitableResolver PageInfo::resolveHasNextPage(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); @@ -376,6 +396,16 @@ AppointmentEdge::AppointmentEdge(std::unique_ptr&& pimpl) { } +void AppointmentEdge::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void AppointmentEdge::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} + service::AwaitableResolver AppointmentEdge::resolveNode(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); @@ -413,6 +443,16 @@ AppointmentConnection::AppointmentConnection(std::unique_ptr&& pimpl) { } +void AppointmentConnection::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void AppointmentConnection::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} + service::AwaitableResolver AppointmentConnection::resolvePageInfo(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); @@ -450,6 +490,16 @@ TaskEdge::TaskEdge(std::unique_ptr&& pimpl) { } +void TaskEdge::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void TaskEdge::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} + service::AwaitableResolver TaskEdge::resolveNode(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); @@ -487,6 +537,16 @@ TaskConnection::TaskConnection(std::unique_ptr&& pimpl) { } +void TaskConnection::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void TaskConnection::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} + service::AwaitableResolver TaskConnection::resolvePageInfo(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); @@ -524,6 +584,16 @@ FolderEdge::FolderEdge(std::unique_ptr&& pimpl) { } +void FolderEdge::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void FolderEdge::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} + service::AwaitableResolver FolderEdge::resolveNode(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); @@ -561,6 +631,16 @@ FolderConnection::FolderConnection(std::unique_ptr&& pimpl) { } +void FolderConnection::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void FolderConnection::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} + service::AwaitableResolver FolderConnection::resolvePageInfo(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); @@ -598,6 +678,16 @@ CompleteTaskPayload::CompleteTaskPayload(std::unique_ptr&& pimpl) { } +void CompleteTaskPayload::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void CompleteTaskPayload::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} + service::AwaitableResolver CompleteTaskPayload::resolveTask(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); @@ -635,6 +725,16 @@ Mutation::Mutation(std::unique_ptr&& pimpl) { } +void Mutation::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void Mutation::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} + service::AwaitableResolver Mutation::resolveCompleteTask(service::ResolverParams&& params) { auto argInput = service::ModifiedArgument::require("input", params.arguments); @@ -674,6 +774,16 @@ Subscription::Subscription(std::unique_ptr&& pimpl) { } +void Subscription::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void Subscription::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} + service::AwaitableResolver Subscription::resolveNextAppointmentChange(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); @@ -717,6 +827,16 @@ Appointment::Appointment(std::unique_ptr&& pimpl) { } +void Appointment::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void Appointment::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} + service::AwaitableResolver Appointment::resolveId(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); @@ -787,6 +907,16 @@ Task::Task(std::unique_ptr&& pimpl) { } +void Task::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void Task::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} + service::AwaitableResolver Task::resolveId(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); @@ -837,6 +967,16 @@ Folder::Folder(std::unique_ptr&& pimpl) { } +void Folder::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void Folder::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} + service::AwaitableResolver Folder::resolveId(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); @@ -884,6 +1024,16 @@ NestedType::NestedType(std::unique_ptr&& pimpl) { } +void NestedType::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void NestedType::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} + service::AwaitableResolver NestedType::resolveDepth(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); @@ -920,6 +1070,16 @@ Expensive::Expensive(std::unique_ptr&& pimpl) { } +void Expensive::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void Expensive::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} + service::AwaitableResolver Expensive::resolveOrder(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); diff --git a/samples/unified_nointrospection/TodaySchema.h b/samples/unified_nointrospection/TodaySchema.h index 94e36c42..efd717ff 100644 --- a/samples/unified_nointrospection/TodaySchema.h +++ b/samples/unified_nointrospection/TodaySchema.h @@ -87,49 +87,495 @@ struct Node }; namespace object { +namespace stub { +namespace QueryStubs { + +template +concept HasNode = requires (TImpl impl, service::FieldParams params, response::IdType idArg) +{ + { service::FieldResult> { impl.getNode(std::move(params), std::move(idArg)) } }; +}; + +template +concept HasAppointments = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) +{ + { service::FieldResult> { impl.getAppointments(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; +}; + +template +concept HasTasks = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) +{ + { service::FieldResult> { impl.getTasks(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; +}; + +template +concept HasUnreadCounts = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) +{ + { service::FieldResult> { impl.getUnreadCounts(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; +}; + +template +concept HasAppointmentsById = requires (TImpl impl, service::FieldParams params, std::vector idsArg) +{ + { service::FieldResult>> { impl.getAppointmentsById(std::move(params), std::move(idsArg)) } }; +}; + +template +concept HasTasksById = requires (TImpl impl, service::FieldParams params, std::vector idsArg) +{ + { service::FieldResult>> { impl.getTasksById(std::move(params), std::move(idsArg)) } }; +}; + +template +concept HasUnreadCountsById = requires (TImpl impl, service::FieldParams params, std::vector idsArg) +{ + { service::FieldResult>> { impl.getUnreadCountsById(std::move(params), std::move(idsArg)) } }; +}; + +template +concept HasNested = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult> { impl.getNested(std::move(params)) } }; +}; + +template +concept HasUnimplemented = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult { impl.getUnimplemented(std::move(params)) } }; +}; + +template +concept HasExpensive = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult>> { impl.getExpensive(std::move(params)) } }; +}; + +template +concept HasTestTaskState = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult { impl.getTestTaskState(std::move(params)) } }; +}; + +template +concept HasAnyType = requires (TImpl impl, service::FieldParams params, std::vector idsArg) +{ + { service::FieldResult>> { impl.getAnyType(std::move(params), std::move(idsArg)) } }; +}; + +template +concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.beginSelectionSet(params) }; +}; + +template +concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.endSelectionSet(params) }; +}; + +} // namespace QueryStubs + +namespace PageInfoStubs { + +template +concept HasHasNextPage = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult { impl.getHasNextPage(std::move(params)) } }; +}; + +template +concept HasHasPreviousPage = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult { impl.getHasPreviousPage(std::move(params)) } }; +}; + +template +concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.beginSelectionSet(params) }; +}; + +template +concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.endSelectionSet(params) }; +}; + +} // namespace PageInfoStubs + +namespace AppointmentEdgeStubs { + +template +concept HasNode = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult> { impl.getNode(std::move(params)) } }; +}; + +template +concept HasCursor = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult { impl.getCursor(std::move(params)) } }; +}; + +template +concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.beginSelectionSet(params) }; +}; + +template +concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.endSelectionSet(params) }; +}; + +} // namespace AppointmentEdgeStubs + +namespace AppointmentConnectionStubs { + +template +concept HasPageInfo = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult> { impl.getPageInfo(std::move(params)) } }; +}; + +template +concept HasEdges = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult>>> { impl.getEdges(std::move(params)) } }; +}; + +template +concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.beginSelectionSet(params) }; +}; + +template +concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.endSelectionSet(params) }; +}; + +} // namespace AppointmentConnectionStubs + +namespace TaskEdgeStubs { + +template +concept HasNode = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult> { impl.getNode(std::move(params)) } }; +}; + +template +concept HasCursor = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult { impl.getCursor(std::move(params)) } }; +}; + +template +concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.beginSelectionSet(params) }; +}; + +template +concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.endSelectionSet(params) }; +}; + +} // namespace TaskEdgeStubs + +namespace TaskConnectionStubs { + +template +concept HasPageInfo = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult> { impl.getPageInfo(std::move(params)) } }; +}; + +template +concept HasEdges = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult>>> { impl.getEdges(std::move(params)) } }; +}; + +template +concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.beginSelectionSet(params) }; +}; + +template +concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.endSelectionSet(params) }; +}; + +} // namespace TaskConnectionStubs + +namespace FolderEdgeStubs { + +template +concept HasNode = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult> { impl.getNode(std::move(params)) } }; +}; + +template +concept HasCursor = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult { impl.getCursor(std::move(params)) } }; +}; + +template +concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.beginSelectionSet(params) }; +}; + +template +concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.endSelectionSet(params) }; +}; + +} // namespace FolderEdgeStubs + +namespace FolderConnectionStubs { + +template +concept HasPageInfo = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult> { impl.getPageInfo(std::move(params)) } }; +}; + +template +concept HasEdges = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult>>> { impl.getEdges(std::move(params)) } }; +}; + +template +concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.beginSelectionSet(params) }; +}; + +template +concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.endSelectionSet(params) }; +}; + +} // namespace FolderConnectionStubs + +namespace CompleteTaskPayloadStubs { + +template +concept HasTask = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult> { impl.getTask(std::move(params)) } }; +}; + +template +concept HasClientMutationId = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult> { impl.getClientMutationId(std::move(params)) } }; +}; + +template +concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.beginSelectionSet(params) }; +}; + +template +concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.endSelectionSet(params) }; +}; + +} // namespace CompleteTaskPayloadStubs + +namespace MutationStubs { + +template +concept HasCompleteTask = requires (TImpl impl, service::FieldParams params, CompleteTaskInput inputArg) +{ + { service::FieldResult> { impl.applyCompleteTask(std::move(params), std::move(inputArg)) } }; +}; + +template +concept HasSetFloat = requires (TImpl impl, service::FieldParams params, response::FloatType valueArg) +{ + { service::FieldResult { impl.applySetFloat(std::move(params), std::move(valueArg)) } }; +}; + +template +concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.beginSelectionSet(params) }; +}; + +template +concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.endSelectionSet(params) }; +}; + +} // namespace MutationStubs + +namespace SubscriptionStubs { + +template +concept HasNextAppointmentChange = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult> { impl.getNextAppointmentChange(std::move(params)) } }; +}; + +template +concept HasNodeChange = requires (TImpl impl, service::FieldParams params, response::IdType idArg) +{ + { service::FieldResult> { impl.getNodeChange(std::move(params), std::move(idArg)) } }; +}; + +template +concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.beginSelectionSet(params) }; +}; + +template +concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.endSelectionSet(params) }; +}; + +} // namespace SubscriptionStubs + +namespace AppointmentStubs { + +template +concept HasId = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult { impl.getId(std::move(params)) } }; +}; + +template +concept HasWhen = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult> { impl.getWhen(std::move(params)) } }; +}; + +template +concept HasSubject = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult> { impl.getSubject(std::move(params)) } }; +}; + +template +concept HasIsNow = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult { impl.getIsNow(std::move(params)) } }; +}; + +template +concept HasForceError = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult> { impl.getForceError(std::move(params)) } }; +}; + +template +concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.beginSelectionSet(params) }; +}; + +template +concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.endSelectionSet(params) }; +}; + +} // namespace AppointmentStubs + +namespace TaskStubs { + +template +concept HasId = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult { impl.getId(std::move(params)) } }; +}; + +template +concept HasTitle = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult> { impl.getTitle(std::move(params)) } }; +}; + +template +concept HasIsComplete = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult { impl.getIsComplete(std::move(params)) } }; +}; -namespace QueryStubs { +template +concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.beginSelectionSet(params) }; +}; template -concept HasNode = requires (TImpl impl, service::FieldParams params, response::IdType idArg) +concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { - { service::FieldResult> { impl.getNode(std::move(params), std::move(idArg)) } }; + { impl.endSelectionSet(params) }; }; +} // namespace TaskStubs + +namespace FolderStubs { + template -concept HasAppointments = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) +concept HasId = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult> { impl.getAppointments(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; + { service::FieldResult { impl.getId(std::move(params)) } }; }; template -concept HasTasks = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) +concept HasName = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult> { impl.getTasks(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; + { service::FieldResult> { impl.getName(std::move(params)) } }; }; template -concept HasUnreadCounts = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) +concept HasUnreadCount = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult> { impl.getUnreadCounts(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; + { service::FieldResult { impl.getUnreadCount(std::move(params)) } }; }; template -concept HasAppointmentsById = requires (TImpl impl, service::FieldParams params, std::vector idsArg) +concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { - { service::FieldResult>> { impl.getAppointmentsById(std::move(params), std::move(idsArg)) } }; + { impl.beginSelectionSet(params) }; }; template -concept HasTasksById = requires (TImpl impl, service::FieldParams params, std::vector idsArg) +concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { - { service::FieldResult>> { impl.getTasksById(std::move(params), std::move(idsArg)) } }; + { impl.endSelectionSet(params) }; }; +} // namespace FolderStubs + +namespace NestedTypeStubs { + template -concept HasUnreadCountsById = requires (TImpl impl, service::FieldParams params, std::vector idsArg) +concept HasDepth = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult>> { impl.getUnreadCountsById(std::move(params), std::move(idsArg)) } }; + { service::FieldResult { impl.getDepth(std::move(params)) } }; }; template @@ -139,30 +585,41 @@ concept HasNested = requires (TImpl impl, service::FieldParams params) }; template -concept HasUnimplemented = requires (TImpl impl, service::FieldParams params) +concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { - { service::FieldResult { impl.getUnimplemented(std::move(params)) } }; + { impl.beginSelectionSet(params) }; }; template -concept HasExpensive = requires (TImpl impl, service::FieldParams params) +concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { - { service::FieldResult>> { impl.getExpensive(std::move(params)) } }; + { impl.endSelectionSet(params) }; }; +} // namespace NestedTypeStubs + +namespace ExpensiveStubs { + template -concept HasTestTaskState = requires (TImpl impl, service::FieldParams params) +concept HasOrder = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult { impl.getTestTaskState(std::move(params)) } }; + { service::FieldResult { impl.getOrder(std::move(params)) } }; }; template -concept HasAnyType = requires (TImpl impl, service::FieldParams params, std::vector idsArg) +concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { - { service::FieldResult>> { impl.getAnyType(std::move(params), std::move(idsArg)) } }; + { impl.beginSelectionSet(params) }; }; -} // namespace QueryStubs +template +concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.endSelectionSet(params) }; +}; + +} // namespace ExpensiveStubs +} // namespace stub class Query : public service::Object @@ -187,6 +644,9 @@ class Query { virtual ~Concept() = default; + virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual service::FieldResult> getNode(service::FieldParams&& params, response::IdType&& idArg) const = 0; virtual service::FieldResult> getAppointments(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const = 0; virtual service::FieldResult> getTasks(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const = 0; @@ -210,9 +670,25 @@ class Query { } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::QueryStubs::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::QueryStubs::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + service::FieldResult> getNode(service::FieldParams&& params, response::IdType&& idArg) const final { - if constexpr (QueryStubs::HasNode) + if constexpr (stub::QueryStubs::HasNode) { return { _pimpl->getNode(std::move(params), std::move(idArg)) }; } @@ -224,7 +700,7 @@ class Query service::FieldResult> getAppointments(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const final { - if constexpr (QueryStubs::HasAppointments) + if constexpr (stub::QueryStubs::HasAppointments) { return { _pimpl->getAppointments(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) }; } @@ -236,7 +712,7 @@ class Query service::FieldResult> getTasks(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const final { - if constexpr (QueryStubs::HasTasks) + if constexpr (stub::QueryStubs::HasTasks) { return { _pimpl->getTasks(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) }; } @@ -248,7 +724,7 @@ class Query service::FieldResult> getUnreadCounts(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const final { - if constexpr (QueryStubs::HasUnreadCounts) + if constexpr (stub::QueryStubs::HasUnreadCounts) { return { _pimpl->getUnreadCounts(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) }; } @@ -260,7 +736,7 @@ class Query service::FieldResult>> getAppointmentsById(service::FieldParams&& params, std::vector&& idsArg) const final { - if constexpr (QueryStubs::HasAppointmentsById) + if constexpr (stub::QueryStubs::HasAppointmentsById) { return { _pimpl->getAppointmentsById(std::move(params), std::move(idsArg)) }; } @@ -272,7 +748,7 @@ class Query service::FieldResult>> getTasksById(service::FieldParams&& params, std::vector&& idsArg) const final { - if constexpr (QueryStubs::HasTasksById) + if constexpr (stub::QueryStubs::HasTasksById) { return { _pimpl->getTasksById(std::move(params), std::move(idsArg)) }; } @@ -284,7 +760,7 @@ class Query service::FieldResult>> getUnreadCountsById(service::FieldParams&& params, std::vector&& idsArg) const final { - if constexpr (QueryStubs::HasUnreadCountsById) + if constexpr (stub::QueryStubs::HasUnreadCountsById) { return { _pimpl->getUnreadCountsById(std::move(params), std::move(idsArg)) }; } @@ -296,7 +772,7 @@ class Query service::FieldResult> getNested(service::FieldParams&& params) const final { - if constexpr (QueryStubs::HasNested) + if constexpr (stub::QueryStubs::HasNested) { return { _pimpl->getNested(std::move(params)) }; } @@ -308,7 +784,7 @@ class Query service::FieldResult getUnimplemented(service::FieldParams&& params) const final { - if constexpr (QueryStubs::HasUnimplemented) + if constexpr (stub::QueryStubs::HasUnimplemented) { return { _pimpl->getUnimplemented(std::move(params)) }; } @@ -320,7 +796,7 @@ class Query service::FieldResult>> getExpensive(service::FieldParams&& params) const final { - if constexpr (QueryStubs::HasExpensive) + if constexpr (stub::QueryStubs::HasExpensive) { return { _pimpl->getExpensive(std::move(params)) }; } @@ -332,7 +808,7 @@ class Query service::FieldResult getTestTaskState(service::FieldParams&& params) const final { - if constexpr (QueryStubs::HasTestTaskState) + if constexpr (stub::QueryStubs::HasTestTaskState) { return { _pimpl->getTestTaskState(std::move(params)) }; } @@ -344,7 +820,7 @@ class Query service::FieldResult>> getAnyType(service::FieldParams&& params, std::vector&& idsArg) const final { - if constexpr (QueryStubs::HasAnyType) + if constexpr (stub::QueryStubs::HasAnyType) { return { _pimpl->getAnyType(std::move(params), std::move(idsArg)) }; } @@ -360,6 +836,9 @@ class Query Query(std::unique_ptr&& pimpl); + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; + const std::unique_ptr _pimpl; public: @@ -370,22 +849,6 @@ class Query } }; -namespace PageInfoStubs { - -template -concept HasHasNextPage = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult { impl.getHasNextPage(std::move(params)) } }; -}; - -template -concept HasHasPreviousPage = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult { impl.getHasPreviousPage(std::move(params)) } }; -}; - -} // namespace PageInfoStubs - class PageInfo : public service::Object { @@ -399,6 +862,9 @@ class PageInfo { virtual ~Concept() = default; + virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual service::FieldResult getHasNextPage(service::FieldParams&& params) const = 0; virtual service::FieldResult getHasPreviousPage(service::FieldParams&& params) const = 0; }; @@ -412,9 +878,25 @@ class PageInfo { } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::PageInfoStubs::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::PageInfoStubs::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + service::FieldResult getHasNextPage(service::FieldParams&& params) const final { - if constexpr (PageInfoStubs::HasHasNextPage) + if constexpr (stub::PageInfoStubs::HasHasNextPage) { return { _pimpl->getHasNextPage(std::move(params)) }; } @@ -426,7 +908,7 @@ class PageInfo service::FieldResult getHasPreviousPage(service::FieldParams&& params) const final { - if constexpr (PageInfoStubs::HasHasPreviousPage) + if constexpr (stub::PageInfoStubs::HasHasPreviousPage) { return { _pimpl->getHasPreviousPage(std::move(params)) }; } @@ -442,6 +924,9 @@ class PageInfo PageInfo(std::unique_ptr&& pimpl); + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; + const std::unique_ptr _pimpl; public: @@ -452,22 +937,6 @@ class PageInfo } }; -namespace AppointmentEdgeStubs { - -template -concept HasNode = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getNode(std::move(params)) } }; -}; - -template -concept HasCursor = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult { impl.getCursor(std::move(params)) } }; -}; - -} // namespace AppointmentEdgeStubs - class AppointmentEdge : public service::Object { @@ -481,6 +950,9 @@ class AppointmentEdge { virtual ~Concept() = default; + virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual service::FieldResult> getNode(service::FieldParams&& params) const = 0; virtual service::FieldResult getCursor(service::FieldParams&& params) const = 0; }; @@ -494,9 +966,25 @@ class AppointmentEdge { } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::AppointmentEdgeStubs::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::AppointmentEdgeStubs::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + service::FieldResult> getNode(service::FieldParams&& params) const final { - if constexpr (AppointmentEdgeStubs::HasNode) + if constexpr (stub::AppointmentEdgeStubs::HasNode) { return { _pimpl->getNode(std::move(params)) }; } @@ -508,7 +996,7 @@ class AppointmentEdge service::FieldResult getCursor(service::FieldParams&& params) const final { - if constexpr (AppointmentEdgeStubs::HasCursor) + if constexpr (stub::AppointmentEdgeStubs::HasCursor) { return { _pimpl->getCursor(std::move(params)) }; } @@ -524,6 +1012,9 @@ class AppointmentEdge AppointmentEdge(std::unique_ptr&& pimpl); + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; + const std::unique_ptr _pimpl; public: @@ -534,22 +1025,6 @@ class AppointmentEdge } }; -namespace AppointmentConnectionStubs { - -template -concept HasPageInfo = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getPageInfo(std::move(params)) } }; -}; - -template -concept HasEdges = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult>>> { impl.getEdges(std::move(params)) } }; -}; - -} // namespace AppointmentConnectionStubs - class AppointmentConnection : public service::Object { @@ -563,6 +1038,9 @@ class AppointmentConnection { virtual ~Concept() = default; + virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual service::FieldResult> getPageInfo(service::FieldParams&& params) const = 0; virtual service::FieldResult>>> getEdges(service::FieldParams&& params) const = 0; }; @@ -576,9 +1054,25 @@ class AppointmentConnection { } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::AppointmentConnectionStubs::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::AppointmentConnectionStubs::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + service::FieldResult> getPageInfo(service::FieldParams&& params) const final { - if constexpr (AppointmentConnectionStubs::HasPageInfo) + if constexpr (stub::AppointmentConnectionStubs::HasPageInfo) { return { _pimpl->getPageInfo(std::move(params)) }; } @@ -590,7 +1084,7 @@ class AppointmentConnection service::FieldResult>>> getEdges(service::FieldParams&& params) const final { - if constexpr (AppointmentConnectionStubs::HasEdges) + if constexpr (stub::AppointmentConnectionStubs::HasEdges) { return { _pimpl->getEdges(std::move(params)) }; } @@ -606,6 +1100,9 @@ class AppointmentConnection AppointmentConnection(std::unique_ptr&& pimpl); + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; + const std::unique_ptr _pimpl; public: @@ -616,22 +1113,6 @@ class AppointmentConnection } }; -namespace TaskEdgeStubs { - -template -concept HasNode = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getNode(std::move(params)) } }; -}; - -template -concept HasCursor = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult { impl.getCursor(std::move(params)) } }; -}; - -} // namespace TaskEdgeStubs - class TaskEdge : public service::Object { @@ -645,6 +1126,9 @@ class TaskEdge { virtual ~Concept() = default; + virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual service::FieldResult> getNode(service::FieldParams&& params) const = 0; virtual service::FieldResult getCursor(service::FieldParams&& params) const = 0; }; @@ -658,9 +1142,25 @@ class TaskEdge { } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::TaskEdgeStubs::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::TaskEdgeStubs::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + service::FieldResult> getNode(service::FieldParams&& params) const final { - if constexpr (TaskEdgeStubs::HasNode) + if constexpr (stub::TaskEdgeStubs::HasNode) { return { _pimpl->getNode(std::move(params)) }; } @@ -672,7 +1172,7 @@ class TaskEdge service::FieldResult getCursor(service::FieldParams&& params) const final { - if constexpr (TaskEdgeStubs::HasCursor) + if constexpr (stub::TaskEdgeStubs::HasCursor) { return { _pimpl->getCursor(std::move(params)) }; } @@ -688,6 +1188,9 @@ class TaskEdge TaskEdge(std::unique_ptr&& pimpl); + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; + const std::unique_ptr _pimpl; public: @@ -698,22 +1201,6 @@ class TaskEdge } }; -namespace TaskConnectionStubs { - -template -concept HasPageInfo = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getPageInfo(std::move(params)) } }; -}; - -template -concept HasEdges = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult>>> { impl.getEdges(std::move(params)) } }; -}; - -} // namespace TaskConnectionStubs - class TaskConnection : public service::Object { @@ -727,6 +1214,9 @@ class TaskConnection { virtual ~Concept() = default; + virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual service::FieldResult> getPageInfo(service::FieldParams&& params) const = 0; virtual service::FieldResult>>> getEdges(service::FieldParams&& params) const = 0; }; @@ -740,9 +1230,25 @@ class TaskConnection { } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::TaskConnectionStubs::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::TaskConnectionStubs::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + service::FieldResult> getPageInfo(service::FieldParams&& params) const final { - if constexpr (TaskConnectionStubs::HasPageInfo) + if constexpr (stub::TaskConnectionStubs::HasPageInfo) { return { _pimpl->getPageInfo(std::move(params)) }; } @@ -754,7 +1260,7 @@ class TaskConnection service::FieldResult>>> getEdges(service::FieldParams&& params) const final { - if constexpr (TaskConnectionStubs::HasEdges) + if constexpr (stub::TaskConnectionStubs::HasEdges) { return { _pimpl->getEdges(std::move(params)) }; } @@ -770,6 +1276,9 @@ class TaskConnection TaskConnection(std::unique_ptr&& pimpl); + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; + const std::unique_ptr _pimpl; public: @@ -780,22 +1289,6 @@ class TaskConnection } }; -namespace FolderEdgeStubs { - -template -concept HasNode = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getNode(std::move(params)) } }; -}; - -template -concept HasCursor = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult { impl.getCursor(std::move(params)) } }; -}; - -} // namespace FolderEdgeStubs - class FolderEdge : public service::Object { @@ -809,6 +1302,9 @@ class FolderEdge { virtual ~Concept() = default; + virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual service::FieldResult> getNode(service::FieldParams&& params) const = 0; virtual service::FieldResult getCursor(service::FieldParams&& params) const = 0; }; @@ -822,9 +1318,25 @@ class FolderEdge { } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::FolderEdgeStubs::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::FolderEdgeStubs::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + service::FieldResult> getNode(service::FieldParams&& params) const final { - if constexpr (FolderEdgeStubs::HasNode) + if constexpr (stub::FolderEdgeStubs::HasNode) { return { _pimpl->getNode(std::move(params)) }; } @@ -836,7 +1348,7 @@ class FolderEdge service::FieldResult getCursor(service::FieldParams&& params) const final { - if constexpr (FolderEdgeStubs::HasCursor) + if constexpr (stub::FolderEdgeStubs::HasCursor) { return { _pimpl->getCursor(std::move(params)) }; } @@ -852,6 +1364,9 @@ class FolderEdge FolderEdge(std::unique_ptr&& pimpl); + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; + const std::unique_ptr _pimpl; public: @@ -862,22 +1377,6 @@ class FolderEdge } }; -namespace FolderConnectionStubs { - -template -concept HasPageInfo = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getPageInfo(std::move(params)) } }; -}; - -template -concept HasEdges = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult>>> { impl.getEdges(std::move(params)) } }; -}; - -} // namespace FolderConnectionStubs - class FolderConnection : public service::Object { @@ -891,6 +1390,9 @@ class FolderConnection { virtual ~Concept() = default; + virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual service::FieldResult> getPageInfo(service::FieldParams&& params) const = 0; virtual service::FieldResult>>> getEdges(service::FieldParams&& params) const = 0; }; @@ -904,9 +1406,25 @@ class FolderConnection { } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::FolderConnectionStubs::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::FolderConnectionStubs::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + service::FieldResult> getPageInfo(service::FieldParams&& params) const final { - if constexpr (FolderConnectionStubs::HasPageInfo) + if constexpr (stub::FolderConnectionStubs::HasPageInfo) { return { _pimpl->getPageInfo(std::move(params)) }; } @@ -918,7 +1436,7 @@ class FolderConnection service::FieldResult>>> getEdges(service::FieldParams&& params) const final { - if constexpr (FolderConnectionStubs::HasEdges) + if constexpr (stub::FolderConnectionStubs::HasEdges) { return { _pimpl->getEdges(std::move(params)) }; } @@ -934,6 +1452,9 @@ class FolderConnection FolderConnection(std::unique_ptr&& pimpl); + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; + const std::unique_ptr _pimpl; public: @@ -944,22 +1465,6 @@ class FolderConnection } }; -namespace CompleteTaskPayloadStubs { - -template -concept HasTask = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getTask(std::move(params)) } }; -}; - -template -concept HasClientMutationId = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getClientMutationId(std::move(params)) } }; -}; - -} // namespace CompleteTaskPayloadStubs - class CompleteTaskPayload : public service::Object { @@ -973,6 +1478,9 @@ class CompleteTaskPayload { virtual ~Concept() = default; + virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual service::FieldResult> getTask(service::FieldParams&& params) const = 0; virtual service::FieldResult> getClientMutationId(service::FieldParams&& params) const = 0; }; @@ -986,9 +1494,25 @@ class CompleteTaskPayload { } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::CompleteTaskPayloadStubs::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::CompleteTaskPayloadStubs::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + service::FieldResult> getTask(service::FieldParams&& params) const final { - if constexpr (CompleteTaskPayloadStubs::HasTask) + if constexpr (stub::CompleteTaskPayloadStubs::HasTask) { return { _pimpl->getTask(std::move(params)) }; } @@ -1000,7 +1524,7 @@ class CompleteTaskPayload service::FieldResult> getClientMutationId(service::FieldParams&& params) const final { - if constexpr (CompleteTaskPayloadStubs::HasClientMutationId) + if constexpr (stub::CompleteTaskPayloadStubs::HasClientMutationId) { return { _pimpl->getClientMutationId(std::move(params)) }; } @@ -1016,6 +1540,9 @@ class CompleteTaskPayload CompleteTaskPayload(std::unique_ptr&& pimpl); + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; + const std::unique_ptr _pimpl; public: @@ -1026,22 +1553,6 @@ class CompleteTaskPayload } }; -namespace MutationStubs { - -template -concept HasCompleteTask = requires (TImpl impl, service::FieldParams params, CompleteTaskInput inputArg) -{ - { service::FieldResult> { impl.applyCompleteTask(std::move(params), std::move(inputArg)) } }; -}; - -template -concept HasSetFloat = requires (TImpl impl, service::FieldParams params, response::FloatType valueArg) -{ - { service::FieldResult { impl.applySetFloat(std::move(params), std::move(valueArg)) } }; -}; - -} // namespace MutationStubs - class Mutation : public service::Object { @@ -1055,6 +1566,9 @@ class Mutation { virtual ~Concept() = default; + virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual service::FieldResult> applyCompleteTask(service::FieldParams&& params, CompleteTaskInput&& inputArg) const = 0; virtual service::FieldResult applySetFloat(service::FieldParams&& params, response::FloatType&& valueArg) const = 0; }; @@ -1068,9 +1582,25 @@ class Mutation { } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::MutationStubs::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::MutationStubs::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + service::FieldResult> applyCompleteTask(service::FieldParams&& params, CompleteTaskInput&& inputArg) const final { - if constexpr (MutationStubs::HasCompleteTask) + if constexpr (stub::MutationStubs::HasCompleteTask) { return { _pimpl->applyCompleteTask(std::move(params), std::move(inputArg)) }; } @@ -1082,7 +1612,7 @@ class Mutation service::FieldResult applySetFloat(service::FieldParams&& params, response::FloatType&& valueArg) const final { - if constexpr (MutationStubs::HasSetFloat) + if constexpr (stub::MutationStubs::HasSetFloat) { return { _pimpl->applySetFloat(std::move(params), std::move(valueArg)) }; } @@ -1098,6 +1628,9 @@ class Mutation Mutation(std::unique_ptr&& pimpl); + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; + const std::unique_ptr _pimpl; public: @@ -1108,22 +1641,6 @@ class Mutation } }; -namespace SubscriptionStubs { - -template -concept HasNextAppointmentChange = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getNextAppointmentChange(std::move(params)) } }; -}; - -template -concept HasNodeChange = requires (TImpl impl, service::FieldParams params, response::IdType idArg) -{ - { service::FieldResult> { impl.getNodeChange(std::move(params), std::move(idArg)) } }; -}; - -} // namespace SubscriptionStubs - class Subscription : public service::Object { @@ -1137,6 +1654,9 @@ class Subscription { virtual ~Concept() = default; + virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual service::FieldResult> getNextAppointmentChange(service::FieldParams&& params) const = 0; virtual service::FieldResult> getNodeChange(service::FieldParams&& params, response::IdType&& idArg) const = 0; }; @@ -1150,9 +1670,25 @@ class Subscription { } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::SubscriptionStubs::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::SubscriptionStubs::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + service::FieldResult> getNextAppointmentChange(service::FieldParams&& params) const final { - if constexpr (SubscriptionStubs::HasNextAppointmentChange) + if constexpr (stub::SubscriptionStubs::HasNextAppointmentChange) { return { _pimpl->getNextAppointmentChange(std::move(params)) }; } @@ -1164,7 +1700,7 @@ class Subscription service::FieldResult> getNodeChange(service::FieldParams&& params, response::IdType&& idArg) const final { - if constexpr (SubscriptionStubs::HasNodeChange) + if constexpr (stub::SubscriptionStubs::HasNodeChange) { return { _pimpl->getNodeChange(std::move(params), std::move(idArg)) }; } @@ -1180,6 +1716,9 @@ class Subscription Subscription(std::unique_ptr&& pimpl); + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; + const std::unique_ptr _pimpl; public: @@ -1190,40 +1729,6 @@ class Subscription } }; -namespace AppointmentStubs { - -template -concept HasId = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult { impl.getId(std::move(params)) } }; -}; - -template -concept HasWhen = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getWhen(std::move(params)) } }; -}; - -template -concept HasSubject = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getSubject(std::move(params)) } }; -}; - -template -concept HasIsNow = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult { impl.getIsNow(std::move(params)) } }; -}; - -template -concept HasForceError = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getForceError(std::move(params)) } }; -}; - -} // namespace AppointmentStubs - class Appointment : public service::Object { @@ -1241,6 +1746,9 @@ class Appointment { virtual ~Concept() = default; + virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual service::FieldResult> getWhen(service::FieldParams&& params) const = 0; virtual service::FieldResult> getSubject(service::FieldParams&& params) const = 0; virtual service::FieldResult getIsNow(service::FieldParams&& params) const = 0; @@ -1256,9 +1764,25 @@ class Appointment { } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::AppointmentStubs::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::AppointmentStubs::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + service::FieldResult getId(service::FieldParams&& params) const final { - if constexpr (AppointmentStubs::HasId) + if constexpr (stub::AppointmentStubs::HasId) { return { _pimpl->getId(std::move(params)) }; } @@ -1270,7 +1794,7 @@ class Appointment service::FieldResult> getWhen(service::FieldParams&& params) const final { - if constexpr (AppointmentStubs::HasWhen) + if constexpr (stub::AppointmentStubs::HasWhen) { return { _pimpl->getWhen(std::move(params)) }; } @@ -1282,7 +1806,7 @@ class Appointment service::FieldResult> getSubject(service::FieldParams&& params) const final { - if constexpr (AppointmentStubs::HasSubject) + if constexpr (stub::AppointmentStubs::HasSubject) { return { _pimpl->getSubject(std::move(params)) }; } @@ -1294,7 +1818,7 @@ class Appointment service::FieldResult getIsNow(service::FieldParams&& params) const final { - if constexpr (AppointmentStubs::HasIsNow) + if constexpr (stub::AppointmentStubs::HasIsNow) { return { _pimpl->getIsNow(std::move(params)) }; } @@ -1306,7 +1830,7 @@ class Appointment service::FieldResult> getForceError(service::FieldParams&& params) const final { - if constexpr (AppointmentStubs::HasForceError) + if constexpr (stub::AppointmentStubs::HasForceError) { return { _pimpl->getForceError(std::move(params)) }; } @@ -1322,6 +1846,9 @@ class Appointment Appointment(std::unique_ptr&& pimpl); + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; + const std::unique_ptr _pimpl; public: @@ -1332,28 +1859,6 @@ class Appointment } }; -namespace TaskStubs { - -template -concept HasId = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult { impl.getId(std::move(params)) } }; -}; - -template -concept HasTitle = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getTitle(std::move(params)) } }; -}; - -template -concept HasIsComplete = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult { impl.getIsComplete(std::move(params)) } }; -}; - -} // namespace TaskStubs - class Task : public service::Object { @@ -1369,6 +1874,9 @@ class Task { virtual ~Concept() = default; + virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual service::FieldResult> getTitle(service::FieldParams&& params) const = 0; virtual service::FieldResult getIsComplete(service::FieldParams&& params) const = 0; }; @@ -1382,9 +1890,25 @@ class Task { } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::TaskStubs::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::TaskStubs::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + service::FieldResult getId(service::FieldParams&& params) const final { - if constexpr (TaskStubs::HasId) + if constexpr (stub::TaskStubs::HasId) { return { _pimpl->getId(std::move(params)) }; } @@ -1396,7 +1920,7 @@ class Task service::FieldResult> getTitle(service::FieldParams&& params) const final { - if constexpr (TaskStubs::HasTitle) + if constexpr (stub::TaskStubs::HasTitle) { return { _pimpl->getTitle(std::move(params)) }; } @@ -1408,7 +1932,7 @@ class Task service::FieldResult getIsComplete(service::FieldParams&& params) const final { - if constexpr (TaskStubs::HasIsComplete) + if constexpr (stub::TaskStubs::HasIsComplete) { return { _pimpl->getIsComplete(std::move(params)) }; } @@ -1424,6 +1948,9 @@ class Task Task(std::unique_ptr&& pimpl); + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; + const std::unique_ptr _pimpl; public: @@ -1434,28 +1961,6 @@ class Task } }; -namespace FolderStubs { - -template -concept HasId = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult { impl.getId(std::move(params)) } }; -}; - -template -concept HasName = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getName(std::move(params)) } }; -}; - -template -concept HasUnreadCount = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult { impl.getUnreadCount(std::move(params)) } }; -}; - -} // namespace FolderStubs - class Folder : public service::Object { @@ -1471,6 +1976,9 @@ class Folder { virtual ~Concept() = default; + virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual service::FieldResult> getName(service::FieldParams&& params) const = 0; virtual service::FieldResult getUnreadCount(service::FieldParams&& params) const = 0; }; @@ -1484,9 +1992,25 @@ class Folder { } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::FolderStubs::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::FolderStubs::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + service::FieldResult getId(service::FieldParams&& params) const final { - if constexpr (FolderStubs::HasId) + if constexpr (stub::FolderStubs::HasId) { return { _pimpl->getId(std::move(params)) }; } @@ -1498,7 +2022,7 @@ class Folder service::FieldResult> getName(service::FieldParams&& params) const final { - if constexpr (FolderStubs::HasName) + if constexpr (stub::FolderStubs::HasName) { return { _pimpl->getName(std::move(params)) }; } @@ -1510,7 +2034,7 @@ class Folder service::FieldResult getUnreadCount(service::FieldParams&& params) const final { - if constexpr (FolderStubs::HasUnreadCount) + if constexpr (stub::FolderStubs::HasUnreadCount) { return { _pimpl->getUnreadCount(std::move(params)) }; } @@ -1526,6 +2050,9 @@ class Folder Folder(std::unique_ptr&& pimpl); + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; + const std::unique_ptr _pimpl; public: @@ -1536,22 +2063,6 @@ class Folder } }; -namespace NestedTypeStubs { - -template -concept HasDepth = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult { impl.getDepth(std::move(params)) } }; -}; - -template -concept HasNested = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getNested(std::move(params)) } }; -}; - -} // namespace NestedTypeStubs - class NestedType : public service::Object { @@ -1565,6 +2076,9 @@ class NestedType { virtual ~Concept() = default; + virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual service::FieldResult getDepth(service::FieldParams&& params) const = 0; virtual service::FieldResult> getNested(service::FieldParams&& params) const = 0; }; @@ -1578,9 +2092,25 @@ class NestedType { } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::NestedTypeStubs::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::NestedTypeStubs::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + service::FieldResult getDepth(service::FieldParams&& params) const final { - if constexpr (NestedTypeStubs::HasDepth) + if constexpr (stub::NestedTypeStubs::HasDepth) { return { _pimpl->getDepth(std::move(params)) }; } @@ -1592,7 +2122,7 @@ class NestedType service::FieldResult> getNested(service::FieldParams&& params) const final { - if constexpr (NestedTypeStubs::HasNested) + if constexpr (stub::NestedTypeStubs::HasNested) { return { _pimpl->getNested(std::move(params)) }; } @@ -1608,6 +2138,9 @@ class NestedType NestedType(std::unique_ptr&& pimpl); + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; + const std::unique_ptr _pimpl; public: @@ -1618,16 +2151,6 @@ class NestedType } }; -namespace ExpensiveStubs { - -template -concept HasOrder = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult { impl.getOrder(std::move(params)) } }; -}; - -} // namespace ExpensiveStubs - class Expensive : public service::Object { @@ -1640,6 +2163,9 @@ class Expensive { virtual ~Concept() = default; + virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual service::FieldResult getOrder(service::FieldParams&& params) const = 0; }; @@ -1652,9 +2178,25 @@ class Expensive { } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::ExpensiveStubs::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::ExpensiveStubs::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + service::FieldResult getOrder(service::FieldParams&& params) const final { - if constexpr (ExpensiveStubs::HasOrder) + if constexpr (stub::ExpensiveStubs::HasOrder) { return { _pimpl->getOrder(std::move(params)) }; } @@ -1670,6 +2212,9 @@ class Expensive Expensive(std::unique_ptr&& pimpl); + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; + const std::unique_ptr _pimpl; public: diff --git a/samples/validation/ValidationSchema.cpp b/samples/validation/ValidationSchema.cpp index 79f7f324..68e464f8 100644 --- a/samples/validation/ValidationSchema.cpp +++ b/samples/validation/ValidationSchema.cpp @@ -132,6 +132,16 @@ Query::Query(std::unique_ptr&& pimpl) { } +void Query::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void Query::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} + service::AwaitableResolver Query::resolveDog(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); @@ -242,6 +252,16 @@ Dog::Dog(std::unique_ptr&& pimpl) { } +void Dog::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void Dog::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} + service::AwaitableResolver Dog::resolveName(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); @@ -323,6 +343,16 @@ Alien::Alien(std::unique_ptr&& pimpl) { } +void Alien::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void Alien::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} + service::AwaitableResolver Alien::resolveName(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); @@ -363,6 +393,16 @@ Human::Human(std::unique_ptr&& pimpl) { } +void Human::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void Human::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} + service::AwaitableResolver Human::resolveName(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); @@ -404,6 +444,16 @@ Cat::Cat(std::unique_ptr&& pimpl) { } +void Cat::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void Cat::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} + service::AwaitableResolver Cat::resolveName(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); @@ -461,6 +511,16 @@ Mutation::Mutation(std::unique_ptr&& pimpl) { } +void Mutation::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void Mutation::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} + service::AwaitableResolver Mutation::resolveMutateDog(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); @@ -487,6 +547,16 @@ MutateDogResult::MutateDogResult(std::unique_ptr&& pimpl) { } +void MutateDogResult::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void MutateDogResult::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} + service::AwaitableResolver MutateDogResult::resolveId(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); @@ -514,6 +584,16 @@ Subscription::Subscription(std::unique_ptr&& pimpl) { } +void Subscription::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void Subscription::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} + service::AwaitableResolver Subscription::resolveNewMessage(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); @@ -551,6 +631,16 @@ Message::Message(std::unique_ptr&& pimpl) { } +void Message::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void Message::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} + service::AwaitableResolver Message::resolveBody(service::ResolverParams&& params) { std::unique_lock resolverLock(_resolverMutex); @@ -594,6 +684,16 @@ Arguments::Arguments(std::unique_ptr&& pimpl) { } +void Arguments::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void Arguments::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} + service::AwaitableResolver Arguments::resolveMultipleReqs(service::ResolverParams&& params) { auto argX = service::ModifiedArgument::require("x", params.arguments); diff --git a/samples/validation/ValidationSchema.h b/samples/validation/ValidationSchema.h index c918f0ee..2249c115 100644 --- a/samples/validation/ValidationSchema.h +++ b/samples/validation/ValidationSchema.h @@ -68,7 +68,7 @@ struct Pet }; namespace object { - +namespace stub { namespace QueryStubs { template @@ -113,8 +113,333 @@ concept HasBooleanList = requires (TImpl impl, service::FieldParams params, std: { service::FieldResult> { impl.getBooleanList(std::move(params), std::move(booleanListArgArg)) } }; }; +template +concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.beginSelectionSet(params) }; +}; + +template +concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.endSelectionSet(params) }; +}; + } // namespace QueryStubs +namespace DogStubs { + +template +concept HasName = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult { impl.getName(std::move(params)) } }; +}; + +template +concept HasNickname = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult> { impl.getNickname(std::move(params)) } }; +}; + +template +concept HasBarkVolume = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult> { impl.getBarkVolume(std::move(params)) } }; +}; + +template +concept HasDoesKnowCommand = requires (TImpl impl, service::FieldParams params, DogCommand dogCommandArg) +{ + { service::FieldResult { impl.getDoesKnowCommand(std::move(params), std::move(dogCommandArg)) } }; +}; + +template +concept HasIsHousetrained = requires (TImpl impl, service::FieldParams params, std::optional atOtherHomesArg) +{ + { service::FieldResult { impl.getIsHousetrained(std::move(params), std::move(atOtherHomesArg)) } }; +}; + +template +concept HasOwner = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult> { impl.getOwner(std::move(params)) } }; +}; + +template +concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.beginSelectionSet(params) }; +}; + +template +concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.endSelectionSet(params) }; +}; + +} // namespace DogStubs + +namespace AlienStubs { + +template +concept HasName = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult { impl.getName(std::move(params)) } }; +}; + +template +concept HasHomePlanet = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult> { impl.getHomePlanet(std::move(params)) } }; +}; + +template +concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.beginSelectionSet(params) }; +}; + +template +concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.endSelectionSet(params) }; +}; + +} // namespace AlienStubs + +namespace HumanStubs { + +template +concept HasName = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult { impl.getName(std::move(params)) } }; +}; + +template +concept HasPets = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult>> { impl.getPets(std::move(params)) } }; +}; + +template +concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.beginSelectionSet(params) }; +}; + +template +concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.endSelectionSet(params) }; +}; + +} // namespace HumanStubs + +namespace CatStubs { + +template +concept HasName = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult { impl.getName(std::move(params)) } }; +}; + +template +concept HasNickname = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult> { impl.getNickname(std::move(params)) } }; +}; + +template +concept HasDoesKnowCommand = requires (TImpl impl, service::FieldParams params, CatCommand catCommandArg) +{ + { service::FieldResult { impl.getDoesKnowCommand(std::move(params), std::move(catCommandArg)) } }; +}; + +template +concept HasMeowVolume = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult> { impl.getMeowVolume(std::move(params)) } }; +}; + +template +concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.beginSelectionSet(params) }; +}; + +template +concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.endSelectionSet(params) }; +}; + +} // namespace CatStubs + +namespace MutationStubs { + +template +concept HasMutateDog = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult> { impl.applyMutateDog(std::move(params)) } }; +}; + +template +concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.beginSelectionSet(params) }; +}; + +template +concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.endSelectionSet(params) }; +}; + +} // namespace MutationStubs + +namespace MutateDogResultStubs { + +template +concept HasId = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult { impl.getId(std::move(params)) } }; +}; + +template +concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.beginSelectionSet(params) }; +}; + +template +concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.endSelectionSet(params) }; +}; + +} // namespace MutateDogResultStubs + +namespace SubscriptionStubs { + +template +concept HasNewMessage = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult> { impl.getNewMessage(std::move(params)) } }; +}; + +template +concept HasDisallowedSecondRootField = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult { impl.getDisallowedSecondRootField(std::move(params)) } }; +}; + +template +concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.beginSelectionSet(params) }; +}; + +template +concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.endSelectionSet(params) }; +}; + +} // namespace SubscriptionStubs + +namespace MessageStubs { + +template +concept HasBody = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult> { impl.getBody(std::move(params)) } }; +}; + +template +concept HasSender = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult { impl.getSender(std::move(params)) } }; +}; + +template +concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.beginSelectionSet(params) }; +}; + +template +concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.endSelectionSet(params) }; +}; + +} // namespace MessageStubs + +namespace ArgumentsStubs { + +template +concept HasMultipleReqs = requires (TImpl impl, service::FieldParams params, response::IntType xArg, response::IntType yArg) +{ + { service::FieldResult { impl.getMultipleReqs(std::move(params), std::move(xArg), std::move(yArg)) } }; +}; + +template +concept HasBooleanArgField = requires (TImpl impl, service::FieldParams params, std::optional booleanArgArg) +{ + { service::FieldResult> { impl.getBooleanArgField(std::move(params), std::move(booleanArgArg)) } }; +}; + +template +concept HasFloatArgField = requires (TImpl impl, service::FieldParams params, std::optional floatArgArg) +{ + { service::FieldResult> { impl.getFloatArgField(std::move(params), std::move(floatArgArg)) } }; +}; + +template +concept HasIntArgField = requires (TImpl impl, service::FieldParams params, std::optional intArgArg) +{ + { service::FieldResult> { impl.getIntArgField(std::move(params), std::move(intArgArg)) } }; +}; + +template +concept HasNonNullBooleanArgField = requires (TImpl impl, service::FieldParams params, response::BooleanType nonNullBooleanArgArg) +{ + { service::FieldResult { impl.getNonNullBooleanArgField(std::move(params), std::move(nonNullBooleanArgArg)) } }; +}; + +template +concept HasNonNullBooleanListField = requires (TImpl impl, service::FieldParams params, std::optional> nonNullBooleanListArgArg) +{ + { service::FieldResult>> { impl.getNonNullBooleanListField(std::move(params), std::move(nonNullBooleanListArgArg)) } }; +}; + +template +concept HasBooleanListArgField = requires (TImpl impl, service::FieldParams params, std::vector> booleanListArgArg) +{ + { service::FieldResult>>> { impl.getBooleanListArgField(std::move(params), std::move(booleanListArgArg)) } }; +}; + +template +concept HasOptionalNonNullBooleanArgField = requires (TImpl impl, service::FieldParams params, response::BooleanType optionalBooleanArgArg) +{ + { service::FieldResult { impl.getOptionalNonNullBooleanArgField(std::move(params), std::move(optionalBooleanArgArg)) } }; +}; + +template +concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.beginSelectionSet(params) }; +}; + +template +concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.endSelectionSet(params) }; +}; + +} // namespace ArgumentsStubs +} // namespace stub + class Query : public service::Object { @@ -137,6 +462,9 @@ class Query { virtual ~Concept() = default; + virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual service::FieldResult> getDog(service::FieldParams&& params) const = 0; virtual service::FieldResult> getHuman(service::FieldParams&& params) const = 0; virtual service::FieldResult> getPet(service::FieldParams&& params) const = 0; @@ -155,9 +483,25 @@ class Query { } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::QueryStubs::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::QueryStubs::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + service::FieldResult> getDog(service::FieldParams&& params) const final { - if constexpr (QueryStubs::HasDog) + if constexpr (stub::QueryStubs::HasDog) { return { _pimpl->getDog(std::move(params)) }; } @@ -169,7 +513,7 @@ class Query service::FieldResult> getHuman(service::FieldParams&& params) const final { - if constexpr (QueryStubs::HasHuman) + if constexpr (stub::QueryStubs::HasHuman) { return { _pimpl->getHuman(std::move(params)) }; } @@ -181,7 +525,7 @@ class Query service::FieldResult> getPet(service::FieldParams&& params) const final { - if constexpr (QueryStubs::HasPet) + if constexpr (stub::QueryStubs::HasPet) { return { _pimpl->getPet(std::move(params)) }; } @@ -193,7 +537,7 @@ class Query service::FieldResult> getCatOrDog(service::FieldParams&& params) const final { - if constexpr (QueryStubs::HasCatOrDog) + if constexpr (stub::QueryStubs::HasCatOrDog) { return { _pimpl->getCatOrDog(std::move(params)) }; } @@ -205,7 +549,7 @@ class Query service::FieldResult> getArguments(service::FieldParams&& params) const final { - if constexpr (QueryStubs::HasArguments) + if constexpr (stub::QueryStubs::HasArguments) { return { _pimpl->getArguments(std::move(params)) }; } @@ -217,7 +561,7 @@ class Query service::FieldResult> getFindDog(service::FieldParams&& params, std::optional&& complexArg) const final { - if constexpr (QueryStubs::HasFindDog) + if constexpr (stub::QueryStubs::HasFindDog) { return { _pimpl->getFindDog(std::move(params), std::move(complexArg)) }; } @@ -229,7 +573,7 @@ class Query service::FieldResult> getBooleanList(service::FieldParams&& params, std::optional>&& booleanListArgArg) const final { - if constexpr (QueryStubs::HasBooleanList) + if constexpr (stub::QueryStubs::HasBooleanList) { return { _pimpl->getBooleanList(std::move(params), std::move(booleanListArgArg)) }; } @@ -245,6 +589,9 @@ class Query Query(std::unique_ptr&& pimpl); + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; + const std::unique_ptr _pimpl; public: @@ -255,46 +602,6 @@ class Query } }; -namespace DogStubs { - -template -concept HasName = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult { impl.getName(std::move(params)) } }; -}; - -template -concept HasNickname = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getNickname(std::move(params)) } }; -}; - -template -concept HasBarkVolume = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getBarkVolume(std::move(params)) } }; -}; - -template -concept HasDoesKnowCommand = requires (TImpl impl, service::FieldParams params, DogCommand dogCommandArg) -{ - { service::FieldResult { impl.getDoesKnowCommand(std::move(params), std::move(dogCommandArg)) } }; -}; - -template -concept HasIsHousetrained = requires (TImpl impl, service::FieldParams params, std::optional atOtherHomesArg) -{ - { service::FieldResult { impl.getIsHousetrained(std::move(params), std::move(atOtherHomesArg)) } }; -}; - -template -concept HasOwner = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getOwner(std::move(params)) } }; -}; - -} // namespace DogStubs - class Dog : public service::Object { @@ -313,6 +620,9 @@ class Dog { virtual ~Concept() = default; + virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual service::FieldResult> getNickname(service::FieldParams&& params) const = 0; virtual service::FieldResult> getBarkVolume(service::FieldParams&& params) const = 0; virtual service::FieldResult getDoesKnowCommand(service::FieldParams&& params, DogCommand&& dogCommandArg) const = 0; @@ -329,9 +639,25 @@ class Dog { } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::DogStubs::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::DogStubs::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + service::FieldResult getName(service::FieldParams&& params) const final { - if constexpr (DogStubs::HasName) + if constexpr (stub::DogStubs::HasName) { return { _pimpl->getName(std::move(params)) }; } @@ -343,7 +669,7 @@ class Dog service::FieldResult> getNickname(service::FieldParams&& params) const final { - if constexpr (DogStubs::HasNickname) + if constexpr (stub::DogStubs::HasNickname) { return { _pimpl->getNickname(std::move(params)) }; } @@ -355,7 +681,7 @@ class Dog service::FieldResult> getBarkVolume(service::FieldParams&& params) const final { - if constexpr (DogStubs::HasBarkVolume) + if constexpr (stub::DogStubs::HasBarkVolume) { return { _pimpl->getBarkVolume(std::move(params)) }; } @@ -367,7 +693,7 @@ class Dog service::FieldResult getDoesKnowCommand(service::FieldParams&& params, DogCommand&& dogCommandArg) const final { - if constexpr (DogStubs::HasDoesKnowCommand) + if constexpr (stub::DogStubs::HasDoesKnowCommand) { return { _pimpl->getDoesKnowCommand(std::move(params), std::move(dogCommandArg)) }; } @@ -379,7 +705,7 @@ class Dog service::FieldResult getIsHousetrained(service::FieldParams&& params, std::optional&& atOtherHomesArg) const final { - if constexpr (DogStubs::HasIsHousetrained) + if constexpr (stub::DogStubs::HasIsHousetrained) { return { _pimpl->getIsHousetrained(std::move(params), std::move(atOtherHomesArg)) }; } @@ -391,7 +717,7 @@ class Dog service::FieldResult> getOwner(service::FieldParams&& params) const final { - if constexpr (DogStubs::HasOwner) + if constexpr (stub::DogStubs::HasOwner) { return { _pimpl->getOwner(std::move(params)) }; } @@ -407,32 +733,19 @@ class Dog Dog(std::unique_ptr&& pimpl); - const std::unique_ptr _pimpl; - -public: - template - Dog(std::shared_ptr pimpl) - : Dog { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } - { - } -}; - -namespace AlienStubs { + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; -template -concept HasName = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult { impl.getName(std::move(params)) } }; -}; + const std::unique_ptr _pimpl; -template -concept HasHomePlanet = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getHomePlanet(std::move(params)) } }; +public: + template + Dog(std::shared_ptr pimpl) + : Dog { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } + { + } }; -} // namespace AlienStubs - class Alien : public service::Object { @@ -447,6 +760,9 @@ class Alien { virtual ~Concept() = default; + virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual service::FieldResult> getHomePlanet(service::FieldParams&& params) const = 0; }; @@ -459,9 +775,25 @@ class Alien { } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::AlienStubs::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::AlienStubs::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + service::FieldResult getName(service::FieldParams&& params) const final { - if constexpr (AlienStubs::HasName) + if constexpr (stub::AlienStubs::HasName) { return { _pimpl->getName(std::move(params)) }; } @@ -473,7 +805,7 @@ class Alien service::FieldResult> getHomePlanet(service::FieldParams&& params) const final { - if constexpr (AlienStubs::HasHomePlanet) + if constexpr (stub::AlienStubs::HasHomePlanet) { return { _pimpl->getHomePlanet(std::move(params)) }; } @@ -489,6 +821,9 @@ class Alien Alien(std::unique_ptr&& pimpl); + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; + const std::unique_ptr _pimpl; public: @@ -499,22 +834,6 @@ class Alien } }; -namespace HumanStubs { - -template -concept HasName = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult { impl.getName(std::move(params)) } }; -}; - -template -concept HasPets = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult>> { impl.getPets(std::move(params)) } }; -}; - -} // namespace HumanStubs - class Human : public service::Object { @@ -529,6 +848,9 @@ class Human { virtual ~Concept() = default; + virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual service::FieldResult>> getPets(service::FieldParams&& params) const = 0; }; @@ -541,9 +863,25 @@ class Human { } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::HumanStubs::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::HumanStubs::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + service::FieldResult getName(service::FieldParams&& params) const final { - if constexpr (HumanStubs::HasName) + if constexpr (stub::HumanStubs::HasName) { return { _pimpl->getName(std::move(params)) }; } @@ -555,7 +893,7 @@ class Human service::FieldResult>> getPets(service::FieldParams&& params) const final { - if constexpr (HumanStubs::HasPets) + if constexpr (stub::HumanStubs::HasPets) { return { _pimpl->getPets(std::move(params)) }; } @@ -571,6 +909,9 @@ class Human Human(std::unique_ptr&& pimpl); + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; + const std::unique_ptr _pimpl; public: @@ -581,34 +922,6 @@ class Human } }; -namespace CatStubs { - -template -concept HasName = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult { impl.getName(std::move(params)) } }; -}; - -template -concept HasNickname = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getNickname(std::move(params)) } }; -}; - -template -concept HasDoesKnowCommand = requires (TImpl impl, service::FieldParams params, CatCommand catCommandArg) -{ - { service::FieldResult { impl.getDoesKnowCommand(std::move(params), std::move(catCommandArg)) } }; -}; - -template -concept HasMeowVolume = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getMeowVolume(std::move(params)) } }; -}; - -} // namespace CatStubs - class Cat : public service::Object { @@ -625,6 +938,9 @@ class Cat { virtual ~Concept() = default; + virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual service::FieldResult> getNickname(service::FieldParams&& params) const = 0; virtual service::FieldResult getDoesKnowCommand(service::FieldParams&& params, CatCommand&& catCommandArg) const = 0; virtual service::FieldResult> getMeowVolume(service::FieldParams&& params) const = 0; @@ -639,9 +955,25 @@ class Cat { } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::CatStubs::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::CatStubs::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + service::FieldResult getName(service::FieldParams&& params) const final { - if constexpr (CatStubs::HasName) + if constexpr (stub::CatStubs::HasName) { return { _pimpl->getName(std::move(params)) }; } @@ -653,7 +985,7 @@ class Cat service::FieldResult> getNickname(service::FieldParams&& params) const final { - if constexpr (CatStubs::HasNickname) + if constexpr (stub::CatStubs::HasNickname) { return { _pimpl->getNickname(std::move(params)) }; } @@ -665,7 +997,7 @@ class Cat service::FieldResult getDoesKnowCommand(service::FieldParams&& params, CatCommand&& catCommandArg) const final { - if constexpr (CatStubs::HasDoesKnowCommand) + if constexpr (stub::CatStubs::HasDoesKnowCommand) { return { _pimpl->getDoesKnowCommand(std::move(params), std::move(catCommandArg)) }; } @@ -677,7 +1009,7 @@ class Cat service::FieldResult> getMeowVolume(service::FieldParams&& params) const final { - if constexpr (CatStubs::HasMeowVolume) + if constexpr (stub::CatStubs::HasMeowVolume) { return { _pimpl->getMeowVolume(std::move(params)) }; } @@ -693,6 +1025,9 @@ class Cat Cat(std::unique_ptr&& pimpl); + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; + const std::unique_ptr _pimpl; public: @@ -703,16 +1038,6 @@ class Cat } }; -namespace MutationStubs { - -template -concept HasMutateDog = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.applyMutateDog(std::move(params)) } }; -}; - -} // namespace MutationStubs - class Mutation : public service::Object { @@ -725,6 +1050,9 @@ class Mutation { virtual ~Concept() = default; + virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual service::FieldResult> applyMutateDog(service::FieldParams&& params) const = 0; }; @@ -737,9 +1065,25 @@ class Mutation { } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::MutationStubs::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::MutationStubs::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + service::FieldResult> applyMutateDog(service::FieldParams&& params) const final { - if constexpr (MutationStubs::HasMutateDog) + if constexpr (stub::MutationStubs::HasMutateDog) { return { _pimpl->applyMutateDog(std::move(params)) }; } @@ -755,6 +1099,9 @@ class Mutation Mutation(std::unique_ptr&& pimpl); + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; + const std::unique_ptr _pimpl; public: @@ -765,16 +1112,6 @@ class Mutation } }; -namespace MutateDogResultStubs { - -template -concept HasId = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult { impl.getId(std::move(params)) } }; -}; - -} // namespace MutateDogResultStubs - class MutateDogResult : public service::Object { @@ -787,6 +1124,9 @@ class MutateDogResult { virtual ~Concept() = default; + virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual service::FieldResult getId(service::FieldParams&& params) const = 0; }; @@ -799,9 +1139,25 @@ class MutateDogResult { } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::MutateDogResultStubs::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::MutateDogResultStubs::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + service::FieldResult getId(service::FieldParams&& params) const final { - if constexpr (MutateDogResultStubs::HasId) + if constexpr (stub::MutateDogResultStubs::HasId) { return { _pimpl->getId(std::move(params)) }; } @@ -817,6 +1173,9 @@ class MutateDogResult MutateDogResult(std::unique_ptr&& pimpl); + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; + const std::unique_ptr _pimpl; public: @@ -827,22 +1186,6 @@ class MutateDogResult } }; -namespace SubscriptionStubs { - -template -concept HasNewMessage = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getNewMessage(std::move(params)) } }; -}; - -template -concept HasDisallowedSecondRootField = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult { impl.getDisallowedSecondRootField(std::move(params)) } }; -}; - -} // namespace SubscriptionStubs - class Subscription : public service::Object { @@ -856,6 +1199,9 @@ class Subscription { virtual ~Concept() = default; + virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual service::FieldResult> getNewMessage(service::FieldParams&& params) const = 0; virtual service::FieldResult getDisallowedSecondRootField(service::FieldParams&& params) const = 0; }; @@ -869,9 +1215,25 @@ class Subscription { } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::SubscriptionStubs::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::SubscriptionStubs::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + service::FieldResult> getNewMessage(service::FieldParams&& params) const final { - if constexpr (SubscriptionStubs::HasNewMessage) + if constexpr (stub::SubscriptionStubs::HasNewMessage) { return { _pimpl->getNewMessage(std::move(params)) }; } @@ -883,7 +1245,7 @@ class Subscription service::FieldResult getDisallowedSecondRootField(service::FieldParams&& params) const final { - if constexpr (SubscriptionStubs::HasDisallowedSecondRootField) + if constexpr (stub::SubscriptionStubs::HasDisallowedSecondRootField) { return { _pimpl->getDisallowedSecondRootField(std::move(params)) }; } @@ -899,6 +1261,9 @@ class Subscription Subscription(std::unique_ptr&& pimpl); + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; + const std::unique_ptr _pimpl; public: @@ -909,22 +1274,6 @@ class Subscription } }; -namespace MessageStubs { - -template -concept HasBody = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getBody(std::move(params)) } }; -}; - -template -concept HasSender = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult { impl.getSender(std::move(params)) } }; -}; - -} // namespace MessageStubs - class Message : public service::Object { @@ -938,6 +1287,9 @@ class Message { virtual ~Concept() = default; + virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual service::FieldResult> getBody(service::FieldParams&& params) const = 0; virtual service::FieldResult getSender(service::FieldParams&& params) const = 0; }; @@ -951,9 +1303,25 @@ class Message { } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::MessageStubs::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::MessageStubs::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + service::FieldResult> getBody(service::FieldParams&& params) const final { - if constexpr (MessageStubs::HasBody) + if constexpr (stub::MessageStubs::HasBody) { return { _pimpl->getBody(std::move(params)) }; } @@ -965,7 +1333,7 @@ class Message service::FieldResult getSender(service::FieldParams&& params) const final { - if constexpr (MessageStubs::HasSender) + if constexpr (stub::MessageStubs::HasSender) { return { _pimpl->getSender(std::move(params)) }; } @@ -981,6 +1349,9 @@ class Message Message(std::unique_ptr&& pimpl); + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; + const std::unique_ptr _pimpl; public: @@ -991,58 +1362,6 @@ class Message } }; -namespace ArgumentsStubs { - -template -concept HasMultipleReqs = requires (TImpl impl, service::FieldParams params, response::IntType xArg, response::IntType yArg) -{ - { service::FieldResult { impl.getMultipleReqs(std::move(params), std::move(xArg), std::move(yArg)) } }; -}; - -template -concept HasBooleanArgField = requires (TImpl impl, service::FieldParams params, std::optional booleanArgArg) -{ - { service::FieldResult> { impl.getBooleanArgField(std::move(params), std::move(booleanArgArg)) } }; -}; - -template -concept HasFloatArgField = requires (TImpl impl, service::FieldParams params, std::optional floatArgArg) -{ - { service::FieldResult> { impl.getFloatArgField(std::move(params), std::move(floatArgArg)) } }; -}; - -template -concept HasIntArgField = requires (TImpl impl, service::FieldParams params, std::optional intArgArg) -{ - { service::FieldResult> { impl.getIntArgField(std::move(params), std::move(intArgArg)) } }; -}; - -template -concept HasNonNullBooleanArgField = requires (TImpl impl, service::FieldParams params, response::BooleanType nonNullBooleanArgArg) -{ - { service::FieldResult { impl.getNonNullBooleanArgField(std::move(params), std::move(nonNullBooleanArgArg)) } }; -}; - -template -concept HasNonNullBooleanListField = requires (TImpl impl, service::FieldParams params, std::optional> nonNullBooleanListArgArg) -{ - { service::FieldResult>> { impl.getNonNullBooleanListField(std::move(params), std::move(nonNullBooleanListArgArg)) } }; -}; - -template -concept HasBooleanListArgField = requires (TImpl impl, service::FieldParams params, std::vector> booleanListArgArg) -{ - { service::FieldResult>>> { impl.getBooleanListArgField(std::move(params), std::move(booleanListArgArg)) } }; -}; - -template -concept HasOptionalNonNullBooleanArgField = requires (TImpl impl, service::FieldParams params, response::BooleanType optionalBooleanArgArg) -{ - { service::FieldResult { impl.getOptionalNonNullBooleanArgField(std::move(params), std::move(optionalBooleanArgArg)) } }; -}; - -} // namespace ArgumentsStubs - class Arguments : public service::Object { @@ -1062,6 +1381,9 @@ class Arguments { virtual ~Concept() = default; + virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual service::FieldResult getMultipleReqs(service::FieldParams&& params, response::IntType&& xArg, response::IntType&& yArg) const = 0; virtual service::FieldResult> getBooleanArgField(service::FieldParams&& params, std::optional&& booleanArgArg) const = 0; virtual service::FieldResult> getFloatArgField(service::FieldParams&& params, std::optional&& floatArgArg) const = 0; @@ -1081,9 +1403,25 @@ class Arguments { } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::ArgumentsStubs::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::ArgumentsStubs::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + service::FieldResult getMultipleReqs(service::FieldParams&& params, response::IntType&& xArg, response::IntType&& yArg) const final { - if constexpr (ArgumentsStubs::HasMultipleReqs) + if constexpr (stub::ArgumentsStubs::HasMultipleReqs) { return { _pimpl->getMultipleReqs(std::move(params), std::move(xArg), std::move(yArg)) }; } @@ -1095,7 +1433,7 @@ class Arguments service::FieldResult> getBooleanArgField(service::FieldParams&& params, std::optional&& booleanArgArg) const final { - if constexpr (ArgumentsStubs::HasBooleanArgField) + if constexpr (stub::ArgumentsStubs::HasBooleanArgField) { return { _pimpl->getBooleanArgField(std::move(params), std::move(booleanArgArg)) }; } @@ -1107,7 +1445,7 @@ class Arguments service::FieldResult> getFloatArgField(service::FieldParams&& params, std::optional&& floatArgArg) const final { - if constexpr (ArgumentsStubs::HasFloatArgField) + if constexpr (stub::ArgumentsStubs::HasFloatArgField) { return { _pimpl->getFloatArgField(std::move(params), std::move(floatArgArg)) }; } @@ -1119,7 +1457,7 @@ class Arguments service::FieldResult> getIntArgField(service::FieldParams&& params, std::optional&& intArgArg) const final { - if constexpr (ArgumentsStubs::HasIntArgField) + if constexpr (stub::ArgumentsStubs::HasIntArgField) { return { _pimpl->getIntArgField(std::move(params), std::move(intArgArg)) }; } @@ -1131,7 +1469,7 @@ class Arguments service::FieldResult getNonNullBooleanArgField(service::FieldParams&& params, response::BooleanType&& nonNullBooleanArgArg) const final { - if constexpr (ArgumentsStubs::HasNonNullBooleanArgField) + if constexpr (stub::ArgumentsStubs::HasNonNullBooleanArgField) { return { _pimpl->getNonNullBooleanArgField(std::move(params), std::move(nonNullBooleanArgArg)) }; } @@ -1143,7 +1481,7 @@ class Arguments service::FieldResult>> getNonNullBooleanListField(service::FieldParams&& params, std::optional>&& nonNullBooleanListArgArg) const final { - if constexpr (ArgumentsStubs::HasNonNullBooleanListField) + if constexpr (stub::ArgumentsStubs::HasNonNullBooleanListField) { return { _pimpl->getNonNullBooleanListField(std::move(params), std::move(nonNullBooleanListArgArg)) }; } @@ -1155,7 +1493,7 @@ class Arguments service::FieldResult>>> getBooleanListArgField(service::FieldParams&& params, std::vector>&& booleanListArgArg) const final { - if constexpr (ArgumentsStubs::HasBooleanListArgField) + if constexpr (stub::ArgumentsStubs::HasBooleanListArgField) { return { _pimpl->getBooleanListArgField(std::move(params), std::move(booleanListArgArg)) }; } @@ -1167,7 +1505,7 @@ class Arguments service::FieldResult getOptionalNonNullBooleanArgField(service::FieldParams&& params, response::BooleanType&& optionalBooleanArgArg) const final { - if constexpr (ArgumentsStubs::HasOptionalNonNullBooleanArgField) + if constexpr (stub::ArgumentsStubs::HasOptionalNonNullBooleanArgField) { return { _pimpl->getOptionalNonNullBooleanArgField(std::move(params), std::move(optionalBooleanArgArg)) }; } @@ -1183,6 +1521,9 @@ class Arguments Arguments(std::unique_ptr&& pimpl); + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; + const std::unique_ptr _pimpl; public: diff --git a/src/SchemaGenerator.cpp b/src/SchemaGenerator.cpp index 3c008812..9145c3fe 100644 --- a/src/SchemaGenerator.cpp +++ b/src/SchemaGenerator.cpp @@ -254,14 +254,6 @@ static_assert(graphql::internal::MinorVersion == )cpp" { if (_loader.isIntrospection()) { - // Forward declare all of the concrete types for the Introspection schema - for (const auto& objectType : _loader.getObjectTypes()) - { - headerFile << R"cpp(class )cpp" << objectType.cppType << R"cpp(; -)cpp"; - } - - headerFile << std::endl; } objectNamespace.enter(); @@ -316,8 +308,49 @@ static_assert(graphql::internal::MinorVersion == )cpp" if (!_loader.getObjectTypes().empty() && !_options.separateFiles) { - if (objectNamespace.enter()) + if (_loader.isIntrospection()) { + if (objectNamespace.exit()) + { + headerFile << std::endl; + } + + // Forward declare all of the concrete types for the Introspection schema + for (const auto& objectType : _loader.getObjectTypes()) + { + headerFile << R"cpp(class )cpp" << objectType.cppType << R"cpp(; +)cpp"; + } + + headerFile << std::endl; + objectNamespace.enter(); + headerFile << std::endl; + } + else + { + objectNamespace.enter(); + + NamespaceScope stubNamespace { headerFile, "stub", true }; + + // Output the stub concept declarations + for (const auto& objectType : _loader.getObjectTypes()) + { + if (!stubNamespace.enter()) + { + headerFile << std::endl; + } + + std::ostringstream ossConceptNamespace; + + ossConceptNamespace << objectType.cppType << R"cpp(Stubs)cpp"; + + const auto conceptNamespace = ossConceptNamespace.str(); + NamespaceScope conceptSubNamespace { headerFile, conceptNamespace }; + + outputObjectStubs(headerFile, objectType); + } + + stubNamespace.exit(); headerFile << std::endl; } @@ -511,21 +544,10 @@ GRAPHQLINTROSPECTION_EXPORT )cpp" return true; } -void Generator::outputObjectDeclaration( - std::ostream& headerFile, const ObjectType& objectType, bool isQueryType) const +void Generator::outputObjectStubs(std::ostream& headerFile, const ObjectType& objectType) const { - std::ostringstream ossNamespace; - - ossNamespace << objectType.cppType << "Stubs"; - - const auto stubNamespace = ossNamespace.str(); - if (!_options.noStubs && !_loader.isIntrospection()) { - NamespaceScope conceptsNamespace { headerFile, stubNamespace }; - - headerFile << std::endl; - for (const auto& outputField : objectType.fields) { std::string fieldName(outputField.cppName); @@ -533,7 +555,8 @@ void Generator::outputObjectDeclaration( fieldName[0] = static_cast(std::toupper(static_cast(fieldName[0]))); - headerFile << R"cpp(template + headerFile << R"cpp( +template concept Has)cpp" << fieldName << R"cpp( = requires (TImpl impl, service::FieldParams params)cpp"; for (const auto& argument : outputField.arguments) @@ -554,16 +577,36 @@ concept Has)cpp" << fieldName headerFile << R"cpp() } }; }; - )cpp"; } + } - if (conceptsNamespace.exit()) - { - headerFile << std::endl; - } + if (_loader.isIntrospection()) + { + headerFile << std::endl; + } + else + { + headerFile << R"cpp( +template +concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.beginSelectionSet(params) }; +}; + +template +concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.endSelectionSet(params) }; +}; + +)cpp"; } +} +void Generator::outputObjectDeclaration( + std::ostream& headerFile, const ObjectType& objectType, bool isQueryType) const +{ headerFile << R"cpp(class )cpp" << objectType.cppType << R"cpp( : public service::Object { @@ -621,6 +664,15 @@ concept Has)cpp" << fieldName )cpp"; + if (!_loader.isIntrospection()) + { + headerFile + << R"cpp( virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + +)cpp"; + } + for (const auto& outputField : objectType.fields) { if (outputField.inheritedField) @@ -643,6 +695,29 @@ concept Has)cpp" << fieldName } )cpp"; + if (!_loader.isIntrospection()) + { + headerFile << R"cpp( + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::)cpp" + << objectType.cppType << R"cpp(Stubs::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (stub::)cpp" + << objectType.cppType << R"cpp(Stubs::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } +)cpp"; + } + for (const auto& outputField : objectType.fields) { std::string fieldName(outputField.cppName); @@ -665,14 +740,14 @@ concept Has)cpp" << fieldName if (!_options.noStubs && !_loader.isIntrospection()) { - headerFile << R"cpp(if constexpr ()cpp" << stubNamespace << R"cpp(::Has)cpp" - << fieldName << R"cpp() + headerFile << R"cpp(if constexpr (stub::)cpp" << objectType.cppType + << R"cpp(Stubs::Has)cpp" << fieldName << R"cpp() { )cpp"; } - headerFile << R"cpp(return { _pimpl->)cpp" - << outputField.accessor << fieldName << R"cpp((std::move(params))cpp"; + headerFile << R"cpp(return { _pimpl->)cpp" << outputField.accessor << fieldName + << R"cpp((std::move(params))cpp"; for (const auto& argument : outputField.arguments) { @@ -724,6 +799,9 @@ concept Has)cpp" << fieldName headerFile << objectType.cppType << R"cpp((std::unique_ptr&& pimpl); + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; + const std::unique_ptr _pimpl; public: @@ -1325,8 +1403,7 @@ Operations::Operations()cpp"; { bool firstValue = true; - sourceFile << R"cpp( type)cpp" << unionType.cppType - << R"cpp(->AddPossibleTypes({ + sourceFile << R"cpp( type)cpp" << unionType.cppType << R"cpp(->AddPossibleTypes({ )cpp"; for (const auto& unionOption : unionType.options) @@ -1707,6 +1784,22 @@ void Generator::outputObjectImplementation( // This is empty, but explicitly defined here so that it can access the un-exported destructor // of the implementation type. } +)cpp"; + } + else + { + sourceFile << R"cpp( +void )cpp" << objectType.cppType + << R"cpp(::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void )cpp" << objectType.cppType + << R"cpp(::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} )cpp"; } @@ -2348,10 +2441,6 @@ std::vector Generator::outputSeparateFiles() const noexcept ossNamespace << R"cpp(graphql::)cpp" << _loader.getSchemaNamespace(); const auto schemaNamespace = ossNamespace.str(); - - ossNamespace << R"cpp(::object)cpp"; - - const auto objectNamespace = ossNamespace.str(); const bool isQueryType = objectType.type == queryType; const auto headerFilename = std::string(objectType.cppType) + "Object.h"; auto headerPath = (headerDir / headerFilename).string(); @@ -2362,8 +2451,24 @@ std::vector Generator::outputSeparateFiles() const noexcept )cpp"; + std::ostringstream ossObjectNamespace; + + ossObjectNamespace << schemaNamespace << R"cpp(::object)cpp"; + + const auto objectNamespace = ossObjectNamespace.str(); NamespaceScope headerNamespace { headerFile, objectNamespace }; + // Output the stub concepts + std::ostringstream ossConceptNamespace; + + ossConceptNamespace << R"cpp(stub::)cpp" << objectType.cppType << R"cpp(Stubs)cpp"; + + const auto conceptNamespace = ossConceptNamespace.str(); + NamespaceScope stubNamespace { headerFile, conceptNamespace }; + + outputObjectStubs(headerFile, objectType); + stubNamespace.exit(); + // Output the full declaration headerFile << std::endl; outputObjectDeclaration(headerFile, objectType, isQueryType); From 24a7c981db0fe187633ddafdd91f9532853eaba9 Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Tue, 30 Nov 2021 23:54:54 -0800 Subject: [PATCH 034/119] Decouple TodayMock types from objects --- samples/today/TodayMock.cpp | 72 +++++++-------- samples/today/TodayMock.h | 177 +++++++++++++++++------------------- 2 files changed, 116 insertions(+), 133 deletions(-) diff --git a/samples/today/TodayMock.cpp b/samples/today/TodayMock.cpp index eceae4a6..97fdea48 100644 --- a/samples/today/TodayMock.cpp +++ b/samples/today/TodayMock.cpp @@ -41,7 +41,7 @@ Query::Query(appointmentsLoader&& getAppointments, tasksLoader&& getTasks, { } -void Query::loadAppointments(const std::shared_ptr& state) const +void Query::loadAppointments(const std::shared_ptr& state) { if (_getAppointments) { @@ -59,7 +59,7 @@ void Query::loadAppointments(const std::shared_ptr& state } std::shared_ptr Query::findAppointment( - const service::FieldParams& params, const response::IdType& id) const + const service::FieldParams& params, const response::IdType& id) { loadAppointments(params.state); @@ -74,7 +74,7 @@ std::shared_ptr Query::findAppointment( return nullptr; } -void Query::loadTasks(const std::shared_ptr& state) const +void Query::loadTasks(const std::shared_ptr& state) { if (_getTasks) { @@ -92,7 +92,7 @@ void Query::loadTasks(const std::shared_ptr& state) const } std::shared_ptr Query::findTask( - const service::FieldParams& params, const response::IdType& id) const + const service::FieldParams& params, const response::IdType& id) { loadTasks(params.state); @@ -107,7 +107,7 @@ std::shared_ptr Query::findTask( return nullptr; } -void Query::loadUnreadCounts(const std::shared_ptr& state) const +void Query::loadUnreadCounts(const std::shared_ptr& state) { if (_getUnreadCounts) { @@ -125,7 +125,7 @@ void Query::loadUnreadCounts(const std::shared_ptr& state } std::shared_ptr Query::findUnreadCount( - const service::FieldParams& params, const response::IdType& id) const + const service::FieldParams& params, const response::IdType& id) { loadUnreadCounts(params.state); @@ -167,7 +167,7 @@ auto operator co_await(std::chrono::duration<_Rep, _Period> delay) } service::FieldResult> Query::getNode( - service::FieldParams&& params, response::IdType&& id) const + service::FieldParams&& params, response::IdType&& id) { // query { node(id: "ZmFrZVRhc2tJZA==") { ...on Task { title } } } using namespace std::literals; @@ -290,10 +290,10 @@ struct EdgeConstraints const vec_type& _objects; }; -service::FieldResult> Query::getAppointments( +std::future> Query::getAppointments( service::FieldParams&& params, std::optional&& first, std::optional&& after, std::optional&& last, - std::optional&& before) const + std::optional&& before) { auto spThis = shared_from_this(); auto state = params.state; @@ -319,10 +319,9 @@ service::FieldResult> Query::getA std::move(before)); } -service::FieldResult> Query::getTasks( - service::FieldParams&& params, std::optional&& first, - std::optional&& after, std::optional&& last, - std::optional&& before) const +std::future> Query::getTasks(service::FieldParams&& params, + std::optional&& first, std::optional&& after, std::optional&& last, + std::optional&& before) { auto spThis = shared_from_this(); auto state = params.state; @@ -348,10 +347,10 @@ service::FieldResult> Query::getTasks( std::move(before)); } -service::FieldResult> Query::getUnreadCounts( +std::future> Query::getUnreadCounts( service::FieldParams&& params, std::optional&& first, std::optional&& after, std::optional&& last, - std::optional&& before) const + std::optional&& before) { auto spThis = shared_from_this(); auto state = params.state; @@ -377,8 +376,8 @@ service::FieldResult> Query::getUnread std::move(before)); } -service::FieldResult>> Query::getAppointmentsById( - service::FieldParams&& params, std::vector&& ids) const +std::future>> Query::getAppointmentsById( + service::FieldParams&& params, std::vector&& ids) { std::promise>> promise; std::vector> result(ids.size()); @@ -394,8 +393,8 @@ service::FieldResult>> Query::g return promise.get_future(); } -service::FieldResult>> Query::getTasksById( - service::FieldParams&& params, std::vector&& ids) const +std::future>> Query::getTasksById( + service::FieldParams&& params, std::vector&& ids) { std::promise>> promise; std::vector> result(ids.size()); @@ -411,8 +410,8 @@ service::FieldResult>> Query::getTasks return promise.get_future(); } -service::FieldResult>> Query::getUnreadCountsById( - service::FieldParams&& params, std::vector&& ids) const +std::future>> Query::getUnreadCountsById( + service::FieldParams&& params, std::vector&& ids) { std::promise>> promise; std::vector> result(ids.size()); @@ -428,8 +427,7 @@ service::FieldResult>> Query::getUnr return promise.get_future(); } -service::FieldResult> Query::getNested( - service::FieldParams&& params) const +std::future> Query::getNested(service::FieldParams&& params) { std::promise> promise; @@ -439,8 +437,8 @@ service::FieldResult> Query::getNested( return promise.get_future(); } -service::FieldResult>> Query::getExpensive( - service::FieldParams&& /*params*/) const +std::vector> Query::getExpensive( + service::FieldParams&& /*params*/) { std::vector> result(Expensive::count); @@ -452,13 +450,13 @@ service::FieldResult>> Query::get return result; } -service::FieldResult Query::getTestTaskState(service::FieldParams&& /*params*/) const +TaskState Query::getTestTaskState(service::FieldParams&& /*params*/) { return TaskState::Unassigned; } -service::FieldResult>> Query::getAnyType( - service::FieldParams&& params, std::vector&& idsArg) const +std::vector> Query::getAnyType( + service::FieldParams&& params, std::vector&& idsArg) { loadAppointments(params.state); @@ -480,8 +478,8 @@ Mutation::Mutation(completeTaskMutation&& mutateCompleteTask) { } -service::FieldResult> Mutation::applyCompleteTask( - service::FieldParams&& params, CompleteTaskInput&& input) +std::future> Mutation::applyCompleteTask( + service::FieldParams&& params, CompleteTaskInput&& input) noexcept { std::promise> promise; @@ -498,8 +496,8 @@ double Mutation::getFloat() noexcept return *_setFloat; } -service::FieldResult Mutation::applySetFloat( - service::FieldParams&& params, response::FloatType&& valueArg) +response::FloatType Mutation::applySetFloat( + service::FieldParams&& params, response::FloatType&& valueArg) noexcept { _setFloat = std::make_optional(valueArg); return valueArg; @@ -517,7 +515,7 @@ NestedType::NestedType(service::FieldParams&& params, int depth) std::move(params.fieldDirectives) }); } -service::FieldResult NestedType::getDepth(service::FieldParams&& params) const +std::future NestedType::getDepth(service::FieldParams&& params) const noexcept { std::promise promise; @@ -526,8 +524,8 @@ service::FieldResult NestedType::getDepth(service::FieldParam return promise.get_future(); } -service::FieldResult> NestedType::getNested( - service::FieldParams&& params) const +std::future> NestedType::getNested( + service::FieldParams&& params) const noexcept { std::promise> promise; @@ -537,7 +535,7 @@ service::FieldResult> NestedType::getNested( return promise.get_future(); } -std::stack NestedType::getCapturedParams() +std::stack NestedType::getCapturedParams() noexcept { auto result = std::move(_capturedParams); @@ -571,7 +569,7 @@ Expensive::~Expensive() --instances; } -service::FieldResult Expensive::getOrder(service::FieldParams&& params) const +std::future Expensive::getOrder(service::FieldParams&& params) const noexcept { return std::async( params.launch, diff --git a/samples/today/TodayMock.h b/samples/today/TodayMock.h index 455bc34e..73e1573f 100644 --- a/samples/today/TodayMock.h +++ b/samples/today/TodayMock.h @@ -51,53 +51,49 @@ class Query : public std::enable_shared_from_this unreadCountsLoader&& getUnreadCounts); service::FieldResult> getNode( - service::FieldParams&& params, response::IdType&& id) const; - service::FieldResult> getAppointments( + service::FieldParams&& params, response::IdType&& id); + std::future> getAppointments( service::FieldParams&& params, std::optional&& first, std::optional&& after, std::optional&& last, - std::optional&& before) const; - service::FieldResult> getTasks( + std::optional&& before); + std::future> getTasks(service::FieldParams&& params, + std::optional&& first, std::optional&& after, + std::optional&& last, std::optional&& before); + std::future> getUnreadCounts( service::FieldParams&& params, std::optional&& first, std::optional&& after, std::optional&& last, - std::optional&& before) const; - service::FieldResult> getUnreadCounts( - service::FieldParams&& params, std::optional&& first, - std::optional&& after, std::optional&& last, - std::optional&& before) const; - service::FieldResult>> getAppointmentsById( - service::FieldParams&& params, std::vector&& ids) const; - service::FieldResult>> getTasksById( - service::FieldParams&& params, std::vector&& ids) const; - service::FieldResult>> getUnreadCountsById( - service::FieldParams&& params, std::vector&& ids) const; - service::FieldResult> getNested( - service::FieldParams&& params) const; - service::FieldResult>> getExpensive( - service::FieldParams&& params) const; - service::FieldResult getTestTaskState(service::FieldParams&& params) const; - service::FieldResult>> getAnyType( - service::FieldParams&& params, std::vector&& idsArg) const; + std::optional&& before); + std::future>> getAppointmentsById( + service::FieldParams&& params, std::vector&& ids); + std::future>> getTasksById( + service::FieldParams&& params, std::vector&& ids); + std::future>> getUnreadCountsById( + service::FieldParams&& params, std::vector&& ids); + std::future> getNested(service::FieldParams&& params); + std::vector> getExpensive(service::FieldParams&& params); + TaskState getTestTaskState(service::FieldParams&& params); + std::vector> getAnyType( + service::FieldParams&& params, std::vector&& idsArg); private: std::shared_ptr findAppointment( - const service::FieldParams& params, const response::IdType& id) const; - std::shared_ptr findTask( - const service::FieldParams& params, const response::IdType& id) const; + const service::FieldParams& params, const response::IdType& id); + std::shared_ptr findTask(const service::FieldParams& params, const response::IdType& id); std::shared_ptr findUnreadCount( - const service::FieldParams& params, const response::IdType& id) const; + const service::FieldParams& params, const response::IdType& id); // Lazy load the fields in each query - void loadAppointments(const std::shared_ptr& state) const; - void loadTasks(const std::shared_ptr& state) const; - void loadUnreadCounts(const std::shared_ptr& state) const; + void loadAppointments(const std::shared_ptr& state); + void loadTasks(const std::shared_ptr& state); + void loadUnreadCounts(const std::shared_ptr& state); - mutable appointmentsLoader _getAppointments; - mutable tasksLoader _getTasks; - mutable unreadCountsLoader _getUnreadCounts; + appointmentsLoader _getAppointments; + tasksLoader _getTasks; + unreadCountsLoader _getUnreadCounts; - mutable std::vector> _appointments; - mutable std::vector> _tasks; - mutable std::vector> _unreadCounts; + std::vector> _appointments; + std::vector> _tasks; + std::vector> _unreadCounts; }; class PageInfo @@ -109,12 +105,12 @@ class PageInfo { } - service::FieldResult getHasNextPage(service::FieldParams&&) const + bool getHasNextPage(service::FieldParams) const noexcept { return _hasNextPage; } - service::FieldResult getHasPreviousPage(service::FieldParams&&) const + bool getHasPreviousPage(service::FieldParams) const noexcept { return _hasPreviousPage; } @@ -131,34 +127,32 @@ class Appointment response::IdType&& id, std::string&& when, std::string&& subject, bool isNow); // EdgeConstraints accessor - const response::IdType& id() const + const response::IdType& id() const noexcept { return _id; } - service::FieldResult getId(service::FieldParams&&) const + service::FieldResult getId(service::FieldParams) const noexcept { return _id; } - service::FieldResult> getWhen(service::FieldParams&&) const + std::optional getWhen(service::FieldParams) const noexcept { return std::make_optional(std::string(_when)); } - service::FieldResult> getSubject( - service::FieldParams&&) const + std::optional getSubject(service::FieldParams) const noexcept { return std::make_optional(_subject); } - service::FieldResult getIsNow(service::FieldParams&&) const + bool getIsNow(service::FieldParams) const noexcept { return _isNow; } - service::FieldResult> getForceError( - service::FieldParams&&) const + std::optional getForceError(service::FieldParams) const { throw std::runtime_error(R"ex(this error was forced)ex"); } @@ -178,7 +172,7 @@ class AppointmentEdge { } - service::FieldResult> getNode(service::FieldParams&&) const + std::shared_ptr getNode(service::FieldParams) const noexcept { return std::make_shared(_appointment); } @@ -202,14 +196,13 @@ class AppointmentConnection { } - service::FieldResult> getPageInfo( - service::FieldParams&&) const + std::shared_ptr getPageInfo(service::FieldParams) const noexcept { return std::make_shared(_pageInfo); } - service::FieldResult>>> - getEdges(service::FieldParams&&) const + std::optional>> getEdges( + service::FieldParams) const noexcept { auto result = std::make_optional>>( _appointments.size()); @@ -222,7 +215,7 @@ class AppointmentConnection std::make_shared(node)); }); - return { std::move(result) }; + return result; } private: @@ -241,17 +234,17 @@ class Task return _id; } - service::FieldResult getId(service::FieldParams&&) const + service::FieldResult getId(service::FieldParams) const noexcept { return _id; } - service::FieldResult> getTitle(service::FieldParams&&) const + std::optional getTitle(service::FieldParams) const noexcept { return std::make_optional(_title); } - service::FieldResult getIsComplete(service::FieldParams&&) const + bool getIsComplete(service::FieldParams) const noexcept { return _isComplete; } @@ -271,12 +264,12 @@ class TaskEdge { } - service::FieldResult> getNode(service::FieldParams&&) const + std::shared_ptr getNode(service::FieldParams) const noexcept { return std::make_shared(_task); } - service::FieldResult getCursor(service::FieldParams&& params) const + service::FieldResult getCursor(service::FieldParams&& params) const noexcept { co_return response::Value(co_await _task->getId(std::move(params))); } @@ -295,14 +288,13 @@ class TaskConnection { } - service::FieldResult> getPageInfo( - service::FieldParams&&) const + std::shared_ptr getPageInfo(service::FieldParams) const noexcept { return std::make_shared(_pageInfo); } - service::FieldResult>>> getEdges( - service::FieldParams&&) const + std::optional>> getEdges( + service::FieldParams) const noexcept { auto result = std::make_optional>>(_tasks.size()); @@ -314,7 +306,7 @@ class TaskConnection return std::make_shared(std::make_shared(node)); }); - return { std::move(result) }; + return result; } private: @@ -328,22 +320,22 @@ class Folder explicit Folder(response::IdType&& id, std::string&& name, int unreadCount); // EdgeConstraints accessor - const response::IdType& id() const + const response::IdType& id() const noexcept { return _id; } - service::FieldResult getId(service::FieldParams&&) const + service::FieldResult getId(service::FieldParams) const noexcept { return _id; } - service::FieldResult> getName(service::FieldParams&&) const + std::optional getName(service::FieldParams) const noexcept { return std::make_optional(_name); } - service::FieldResult getUnreadCount(service::FieldParams&&) const + int getUnreadCount(service::FieldParams) const noexcept { return _unreadCount; } @@ -362,12 +354,12 @@ class FolderEdge { } - service::FieldResult> getNode(service::FieldParams&&) const + std::shared_ptr getNode(service::FieldParams) const noexcept { return std::make_shared(_folder); } - service::FieldResult getCursor(service::FieldParams&& params) const + service::FieldResult getCursor(service::FieldParams&& params) const noexcept { co_return response::Value(co_await _folder->getId(std::move(params))); } @@ -386,14 +378,13 @@ class FolderConnection { } - service::FieldResult> getPageInfo( - service::FieldParams&&) const + std::shared_ptr getPageInfo(service::FieldParams) const noexcept { return std::make_shared(_pageInfo); } - service::FieldResult>>> getEdges( - service::FieldParams&&) const + std::optional>> getEdges( + service::FieldParams) const noexcept { auto result = std::make_optional>>(_folders.size()); @@ -405,7 +396,7 @@ class FolderConnection return std::make_shared(std::make_shared(node)); }); - return { std::move(result) }; + return result; } private: @@ -423,16 +414,14 @@ class CompleteTaskPayload { } - service::FieldResult> getTask(service::FieldParams&&) const + std::shared_ptr getTask(service::FieldParams) const noexcept { return std::make_shared(_task); } - service::FieldResult> getClientMutationId( - service::FieldParams&&) const + std::optional getClientMutationId(service::FieldParams) const noexcept { - return { _clientMutationId ? std::make_optional(*_clientMutationId) - : std::nullopt }; + return _clientMutationId; } private: @@ -450,10 +439,10 @@ class Mutation static double getFloat() noexcept; - service::FieldResult> applyCompleteTask( - service::FieldParams&& params, CompleteTaskInput&& input); - service::FieldResult applySetFloat( - service::FieldParams&& params, response::FloatType&& valueArg); + std::future> applyCompleteTask( + service::FieldParams&& params, CompleteTaskInput&& input) noexcept; + response::FloatType applySetFloat( + service::FieldParams&& params, response::FloatType&& valueArg) noexcept; private: completeTaskMutation _mutateCompleteTask; @@ -465,14 +454,12 @@ class Subscription public: explicit Subscription() = default; - service::FieldResult> getNextAppointmentChange( - service::FieldParams&&) const + std::shared_ptr getNextAppointmentChange(service::FieldParams) const { throw std::runtime_error("Unexpected call to getNextAppointmentChange"); } - service::FieldResult> getNodeChange( - service::FieldParams&&, response::IdType&&) const + std::shared_ptr getNodeChange(service::FieldParams&&, response::IdType&&) const { throw std::runtime_error("Unexpected call to getNodeChange"); } @@ -507,7 +494,7 @@ class NextAppointmentChange } } - service::FieldResult> getNextAppointmentChange( + std::shared_ptr getNextAppointmentChange( service::FieldParams&& params) const { switch (params.resolverContext) @@ -537,8 +524,7 @@ class NextAppointmentChange return std::make_shared(_changeNextAppointment(params.state)); } - service::FieldResult> getNodeChange( - service::FieldParams&&, response::IdType&&) const + std::shared_ptr getNodeChange(service::FieldParams&&, response::IdType&&) const { throw std::runtime_error("Unexpected call to getNodeChange"); } @@ -562,13 +548,12 @@ class NodeChange { } - service::FieldResult> getNextAppointmentChange( - service::FieldParams&&) const + std::shared_ptr getNextAppointmentChange(service::FieldParams) const { throw std::runtime_error("Unexpected call to getNextAppointmentChange"); } - service::FieldResult> getNodeChange( + std::shared_ptr getNodeChange( service::FieldParams&& params, response::IdType&& idArg) const { return std::static_pointer_cast( @@ -596,11 +581,11 @@ class NestedType public: explicit NestedType(service::FieldParams&& params, int depth); - service::FieldResult getDepth(service::FieldParams&& params) const; - service::FieldResult> getNested( - service::FieldParams&& params) const; + std::future getDepth(service::FieldParams&& params) const noexcept; + std::future> getNested( + service::FieldParams&& params) const noexcept; - static std::stack getCapturedParams(); + static std::stack getCapturedParams() noexcept; private: static std::stack _capturedParams; @@ -617,7 +602,7 @@ class Expensive explicit Expensive(); ~Expensive(); - service::FieldResult getOrder(service::FieldParams&& params) const; + std::future getOrder(service::FieldParams&& params) const noexcept; static constexpr size_t count = 5; static std::mutex testMutex; From 09d17049e77bc5087d83246f476e38d1bcf97749 Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Wed, 1 Dec 2021 11:40:33 -0800 Subject: [PATCH 035/119] Make the service::FieldParams argument optional --- samples/learn/DroidObject.h | 151 +- samples/learn/HumanObject.h | 151 +- samples/learn/MutationObject.h | 41 +- samples/learn/QueryObject.h | 97 +- samples/learn/ReviewObject.h | 70 +- .../separate/AppointmentConnectionObject.h | 64 +- samples/separate/AppointmentEdgeObject.h | 64 +- samples/separate/AppointmentObject.h | 106 +- samples/separate/CompleteTaskPayloadObject.h | 64 +- samples/separate/ExpensiveObject.h | 42 +- samples/separate/FolderConnectionObject.h | 64 +- samples/separate/FolderEdgeObject.h | 64 +- samples/separate/FolderObject.h | 78 +- samples/separate/MutationObject.h | 64 +- samples/separate/NestedTypeObject.h | 64 +- samples/separate/PageInfoObject.h | 64 +- samples/separate/QueryObject.h | 204 ++- samples/separate/SubscriptionObject.h | 64 +- samples/separate/TaskConnectionObject.h | 64 +- samples/separate/TaskEdgeObject.h | 64 +- samples/separate/TaskObject.h | 78 +- .../AppointmentConnectionObject.h | 64 +- .../AppointmentEdgeObject.h | 64 +- .../AppointmentObject.h | 106 +- .../CompleteTaskPayloadObject.h | 64 +- .../ExpensiveObject.h | 42 +- .../FolderConnectionObject.h | 64 +- .../FolderEdgeObject.h | 64 +- .../separate_nointrospection/FolderObject.h | 78 +- .../separate_nointrospection/MutationObject.h | 64 +- .../NestedTypeObject.h | 64 +- .../separate_nointrospection/PageInfoObject.h | 64 +- .../separate_nointrospection/QueryObject.h | 204 ++- .../SubscriptionObject.h | 64 +- .../TaskConnectionObject.h | 64 +- .../separate_nointrospection/TaskEdgeObject.h | 64 +- samples/separate_nointrospection/TaskObject.h | 78 +- samples/star_wars/DroidData.cpp | 13 +- samples/star_wars/DroidData.h | 13 +- samples/star_wars/HumanData.cpp | 13 +- samples/star_wars/HumanData.h | 12 +- samples/star_wars/MutationData.cpp | 2 +- samples/star_wars/MutationData.h | 2 +- samples/star_wars/QueryData.cpp | 9 +- samples/star_wars/QueryData.h | 9 +- samples/star_wars/ReviewData.cpp | 5 +- samples/star_wars/ReviewData.h | 4 +- samples/today/TodayMock.cpp | 98 +- samples/today/TodayMock.h | 130 +- samples/unified/TodaySchema.h | 1220 ++++++++++++----- samples/unified_nointrospection/TodaySchema.h | 1220 ++++++++++++----- samples/validation/ValidationSchema.h | 838 +++++++---- src/SchemaGenerator.cpp | 179 ++- 53 files changed, 4651 insertions(+), 2050 deletions(-) diff --git a/samples/learn/DroidObject.h b/samples/learn/DroidObject.h index fc88af1f..77582c94 100644 --- a/samples/learn/DroidObject.h +++ b/samples/learn/DroidObject.h @@ -11,7 +11,67 @@ #include "StarWarsSchema.h" namespace graphql::learn::object { -namespace stub::DroidStubs { +namespace methods::DroidMethod { + +template +concept WithParamsId = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult { impl.getId(std::move(params)) } }; +}; + +template +concept NoParamsId = requires (TImpl impl) +{ + { service::FieldResult { impl.getId() } }; +}; + +template +concept WithParamsName = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult> { impl.getName(std::move(params)) } }; +}; + +template +concept NoParamsName = requires (TImpl impl) +{ + { service::FieldResult> { impl.getName() } }; +}; + +template +concept WithParamsFriends = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult>>> { impl.getFriends(std::move(params)) } }; +}; + +template +concept NoParamsFriends = requires (TImpl impl) +{ + { service::FieldResult>>> { impl.getFriends() } }; +}; + +template +concept WithParamsAppearsIn = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult>>> { impl.getAppearsIn(std::move(params)) } }; +}; + +template +concept NoParamsAppearsIn = requires (TImpl impl) +{ + { service::FieldResult>>> { impl.getAppearsIn() } }; +}; + +template +concept WithParamsPrimaryFunction = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult> { impl.getPrimaryFunction(std::move(params)) } }; +}; + +template +concept NoParamsPrimaryFunction = requires (TImpl impl) +{ + { service::FieldResult> { impl.getPrimaryFunction() } }; +}; template concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) @@ -25,7 +85,7 @@ concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetPa { impl.endSelectionSet(params) }; }; -} // namespace stub::DroidStubs +} // namespace methods::DroidMethod class Droid : public service::Object @@ -59,45 +119,100 @@ class Droid { } - void beginSelectionSet(const service::SelectionSetParams& params) const final + service::FieldResult getId(service::FieldParams&& params) const final { - if constexpr (stub::DroidStubs::HasBeginSelectionSet) + if constexpr (methods::DroidMethod::WithParamsId) { - _pimpl->beginSelectionSet(params); + return { _pimpl->getId(std::move(params)) }; + } + else if constexpr (methods::DroidMethod::NoParamsId) + { + return { _pimpl->getId() }; + } + else + { + static_assert(false, R"msg(Droid::getId is not implemented)msg"); } } - void endSelectionSet(const service::SelectionSetParams& params) const final + service::FieldResult> getName(service::FieldParams&& params) const final { - if constexpr (stub::DroidStubs::HasEndSelectionSet) + if constexpr (methods::DroidMethod::WithParamsName) { - _pimpl->endSelectionSet(params); + return { _pimpl->getName(std::move(params)) }; + } + else if constexpr (methods::DroidMethod::NoParamsName) + { + return { _pimpl->getName() }; + } + else + { + static_assert(false, R"msg(Droid::getName is not implemented)msg"); } } - service::FieldResult getId(service::FieldParams&& params) const final + service::FieldResult>>> getFriends(service::FieldParams&& params) const final { - return { _pimpl->getId(std::move(params)) }; + if constexpr (methods::DroidMethod::WithParamsFriends) + { + return { _pimpl->getFriends(std::move(params)) }; + } + else if constexpr (methods::DroidMethod::NoParamsFriends) + { + return { _pimpl->getFriends() }; + } + else + { + static_assert(false, R"msg(Droid::getFriends is not implemented)msg"); + } } - service::FieldResult> getName(service::FieldParams&& params) const final + service::FieldResult>>> getAppearsIn(service::FieldParams&& params) const final { - return { _pimpl->getName(std::move(params)) }; + if constexpr (methods::DroidMethod::WithParamsAppearsIn) + { + return { _pimpl->getAppearsIn(std::move(params)) }; + } + else if constexpr (methods::DroidMethod::NoParamsAppearsIn) + { + return { _pimpl->getAppearsIn() }; + } + else + { + static_assert(false, R"msg(Droid::getAppearsIn is not implemented)msg"); + } } - service::FieldResult>>> getFriends(service::FieldParams&& params) const final + service::FieldResult> getPrimaryFunction(service::FieldParams&& params) const final { - return { _pimpl->getFriends(std::move(params)) }; + if constexpr (methods::DroidMethod::WithParamsPrimaryFunction) + { + return { _pimpl->getPrimaryFunction(std::move(params)) }; + } + else if constexpr (methods::DroidMethod::NoParamsPrimaryFunction) + { + return { _pimpl->getPrimaryFunction() }; + } + else + { + static_assert(false, R"msg(Droid::getPrimaryFunction is not implemented)msg"); + } } - service::FieldResult>>> getAppearsIn(service::FieldParams&& params) const final + void beginSelectionSet(const service::SelectionSetParams& params) const final { - return { _pimpl->getAppearsIn(std::move(params)) }; + if constexpr (methods::DroidMethod::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } } - service::FieldResult> getPrimaryFunction(service::FieldParams&& params) const final + void endSelectionSet(const service::SelectionSetParams& params) const final { - return { _pimpl->getPrimaryFunction(std::move(params)) }; + if constexpr (methods::DroidMethod::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } } private: diff --git a/samples/learn/HumanObject.h b/samples/learn/HumanObject.h index 06fcdb90..1ed2c164 100644 --- a/samples/learn/HumanObject.h +++ b/samples/learn/HumanObject.h @@ -11,7 +11,67 @@ #include "StarWarsSchema.h" namespace graphql::learn::object { -namespace stub::HumanStubs { +namespace methods::HumanMethod { + +template +concept WithParamsId = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult { impl.getId(std::move(params)) } }; +}; + +template +concept NoParamsId = requires (TImpl impl) +{ + { service::FieldResult { impl.getId() } }; +}; + +template +concept WithParamsName = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult> { impl.getName(std::move(params)) } }; +}; + +template +concept NoParamsName = requires (TImpl impl) +{ + { service::FieldResult> { impl.getName() } }; +}; + +template +concept WithParamsFriends = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult>>> { impl.getFriends(std::move(params)) } }; +}; + +template +concept NoParamsFriends = requires (TImpl impl) +{ + { service::FieldResult>>> { impl.getFriends() } }; +}; + +template +concept WithParamsAppearsIn = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult>>> { impl.getAppearsIn(std::move(params)) } }; +}; + +template +concept NoParamsAppearsIn = requires (TImpl impl) +{ + { service::FieldResult>>> { impl.getAppearsIn() } }; +}; + +template +concept WithParamsHomePlanet = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult> { impl.getHomePlanet(std::move(params)) } }; +}; + +template +concept NoParamsHomePlanet = requires (TImpl impl) +{ + { service::FieldResult> { impl.getHomePlanet() } }; +}; template concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) @@ -25,7 +85,7 @@ concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetPa { impl.endSelectionSet(params) }; }; -} // namespace stub::HumanStubs +} // namespace methods::HumanMethod class Human : public service::Object @@ -59,45 +119,100 @@ class Human { } - void beginSelectionSet(const service::SelectionSetParams& params) const final + service::FieldResult getId(service::FieldParams&& params) const final { - if constexpr (stub::HumanStubs::HasBeginSelectionSet) + if constexpr (methods::HumanMethod::WithParamsId) { - _pimpl->beginSelectionSet(params); + return { _pimpl->getId(std::move(params)) }; + } + else if constexpr (methods::HumanMethod::NoParamsId) + { + return { _pimpl->getId() }; + } + else + { + static_assert(false, R"msg(Human::getId is not implemented)msg"); } } - void endSelectionSet(const service::SelectionSetParams& params) const final + service::FieldResult> getName(service::FieldParams&& params) const final { - if constexpr (stub::HumanStubs::HasEndSelectionSet) + if constexpr (methods::HumanMethod::WithParamsName) { - _pimpl->endSelectionSet(params); + return { _pimpl->getName(std::move(params)) }; + } + else if constexpr (methods::HumanMethod::NoParamsName) + { + return { _pimpl->getName() }; + } + else + { + static_assert(false, R"msg(Human::getName is not implemented)msg"); } } - service::FieldResult getId(service::FieldParams&& params) const final + service::FieldResult>>> getFriends(service::FieldParams&& params) const final { - return { _pimpl->getId(std::move(params)) }; + if constexpr (methods::HumanMethod::WithParamsFriends) + { + return { _pimpl->getFriends(std::move(params)) }; + } + else if constexpr (methods::HumanMethod::NoParamsFriends) + { + return { _pimpl->getFriends() }; + } + else + { + static_assert(false, R"msg(Human::getFriends is not implemented)msg"); + } } - service::FieldResult> getName(service::FieldParams&& params) const final + service::FieldResult>>> getAppearsIn(service::FieldParams&& params) const final { - return { _pimpl->getName(std::move(params)) }; + if constexpr (methods::HumanMethod::WithParamsAppearsIn) + { + return { _pimpl->getAppearsIn(std::move(params)) }; + } + else if constexpr (methods::HumanMethod::NoParamsAppearsIn) + { + return { _pimpl->getAppearsIn() }; + } + else + { + static_assert(false, R"msg(Human::getAppearsIn is not implemented)msg"); + } } - service::FieldResult>>> getFriends(service::FieldParams&& params) const final + service::FieldResult> getHomePlanet(service::FieldParams&& params) const final { - return { _pimpl->getFriends(std::move(params)) }; + if constexpr (methods::HumanMethod::WithParamsHomePlanet) + { + return { _pimpl->getHomePlanet(std::move(params)) }; + } + else if constexpr (methods::HumanMethod::NoParamsHomePlanet) + { + return { _pimpl->getHomePlanet() }; + } + else + { + static_assert(false, R"msg(Human::getHomePlanet is not implemented)msg"); + } } - service::FieldResult>>> getAppearsIn(service::FieldParams&& params) const final + void beginSelectionSet(const service::SelectionSetParams& params) const final { - return { _pimpl->getAppearsIn(std::move(params)) }; + if constexpr (methods::HumanMethod::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } } - service::FieldResult> getHomePlanet(service::FieldParams&& params) const final + void endSelectionSet(const service::SelectionSetParams& params) const final { - return { _pimpl->getHomePlanet(std::move(params)) }; + if constexpr (methods::HumanMethod::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } } private: diff --git a/samples/learn/MutationObject.h b/samples/learn/MutationObject.h index 2024ef5b..33913fd5 100644 --- a/samples/learn/MutationObject.h +++ b/samples/learn/MutationObject.h @@ -11,7 +11,19 @@ #include "StarWarsSchema.h" namespace graphql::learn::object { -namespace stub::MutationStubs { +namespace methods::MutationMethod { + +template +concept WithParamsCreateReview = requires (TImpl impl, service::FieldParams params, Episode epArg, ReviewInput reviewArg) +{ + { service::FieldResult> { impl.applyCreateReview(std::move(params), std::move(epArg), std::move(reviewArg)) } }; +}; + +template +concept NoParamsCreateReview = requires (TImpl impl, Episode epArg, ReviewInput reviewArg) +{ + { service::FieldResult> { impl.applyCreateReview(std::move(epArg), std::move(reviewArg)) } }; +}; template concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) @@ -25,7 +37,7 @@ concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetPa { impl.endSelectionSet(params) }; }; -} // namespace stub::MutationStubs +} // namespace methods::MutationMethod class Mutation : public service::Object @@ -54,9 +66,25 @@ class Mutation { } + service::FieldResult> applyCreateReview(service::FieldParams&& params, Episode&& epArg, ReviewInput&& reviewArg) const final + { + if constexpr (methods::MutationMethod::WithParamsCreateReview) + { + return { _pimpl->applyCreateReview(std::move(params), std::move(epArg), std::move(reviewArg)) }; + } + else if constexpr (methods::MutationMethod::NoParamsCreateReview) + { + return { _pimpl->applyCreateReview(std::move(epArg), std::move(reviewArg)) }; + } + else + { + static_assert(false, R"msg(Mutation::applyCreateReview is not implemented)msg"); + } + } + void beginSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (stub::MutationStubs::HasBeginSelectionSet) + if constexpr (methods::MutationMethod::HasBeginSelectionSet) { _pimpl->beginSelectionSet(params); } @@ -64,17 +92,12 @@ class Mutation void endSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (stub::MutationStubs::HasEndSelectionSet) + if constexpr (methods::MutationMethod::HasEndSelectionSet) { _pimpl->endSelectionSet(params); } } - service::FieldResult> applyCreateReview(service::FieldParams&& params, Episode&& epArg, ReviewInput&& reviewArg) const final - { - return { _pimpl->applyCreateReview(std::move(params), std::move(epArg), std::move(reviewArg)) }; - } - private: const std::shared_ptr _pimpl; }; diff --git a/samples/learn/QueryObject.h b/samples/learn/QueryObject.h index 871a59fc..3515a964 100644 --- a/samples/learn/QueryObject.h +++ b/samples/learn/QueryObject.h @@ -11,7 +11,43 @@ #include "StarWarsSchema.h" namespace graphql::learn::object { -namespace stub::QueryStubs { +namespace methods::QueryMethod { + +template +concept WithParamsHero = requires (TImpl impl, service::FieldParams params, std::optional episodeArg) +{ + { service::FieldResult> { impl.getHero(std::move(params), std::move(episodeArg)) } }; +}; + +template +concept NoParamsHero = requires (TImpl impl, std::optional episodeArg) +{ + { service::FieldResult> { impl.getHero(std::move(episodeArg)) } }; +}; + +template +concept WithParamsHuman = requires (TImpl impl, service::FieldParams params, response::StringType idArg) +{ + { service::FieldResult> { impl.getHuman(std::move(params), std::move(idArg)) } }; +}; + +template +concept NoParamsHuman = requires (TImpl impl, response::StringType idArg) +{ + { service::FieldResult> { impl.getHuman(std::move(idArg)) } }; +}; + +template +concept WithParamsDroid = requires (TImpl impl, service::FieldParams params, response::StringType idArg) +{ + { service::FieldResult> { impl.getDroid(std::move(params), std::move(idArg)) } }; +}; + +template +concept NoParamsDroid = requires (TImpl impl, response::StringType idArg) +{ + { service::FieldResult> { impl.getDroid(std::move(idArg)) } }; +}; template concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) @@ -25,7 +61,7 @@ concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetPa { impl.endSelectionSet(params) }; }; -} // namespace stub::QueryStubs +} // namespace methods::QueryMethod class Query : public service::Object @@ -62,35 +98,68 @@ class Query { } - void beginSelectionSet(const service::SelectionSetParams& params) const final + service::FieldResult> getHero(service::FieldParams&& params, std::optional&& episodeArg) const final { - if constexpr (stub::QueryStubs::HasBeginSelectionSet) + if constexpr (methods::QueryMethod::WithParamsHero) { - _pimpl->beginSelectionSet(params); + return { _pimpl->getHero(std::move(params), std::move(episodeArg)) }; + } + else if constexpr (methods::QueryMethod::NoParamsHero) + { + return { _pimpl->getHero(std::move(episodeArg)) }; + } + else + { + static_assert(false, R"msg(Query::getHero is not implemented)msg"); } } - void endSelectionSet(const service::SelectionSetParams& params) const final + service::FieldResult> getHuman(service::FieldParams&& params, response::StringType&& idArg) const final { - if constexpr (stub::QueryStubs::HasEndSelectionSet) + if constexpr (methods::QueryMethod::WithParamsHuman) { - _pimpl->endSelectionSet(params); + return { _pimpl->getHuman(std::move(params), std::move(idArg)) }; + } + else if constexpr (methods::QueryMethod::NoParamsHuman) + { + return { _pimpl->getHuman(std::move(idArg)) }; + } + else + { + static_assert(false, R"msg(Query::getHuman is not implemented)msg"); } } - service::FieldResult> getHero(service::FieldParams&& params, std::optional&& episodeArg) const final + service::FieldResult> getDroid(service::FieldParams&& params, response::StringType&& idArg) const final { - return { _pimpl->getHero(std::move(params), std::move(episodeArg)) }; + if constexpr (methods::QueryMethod::WithParamsDroid) + { + return { _pimpl->getDroid(std::move(params), std::move(idArg)) }; + } + else if constexpr (methods::QueryMethod::NoParamsDroid) + { + return { _pimpl->getDroid(std::move(idArg)) }; + } + else + { + static_assert(false, R"msg(Query::getDroid is not implemented)msg"); + } } - service::FieldResult> getHuman(service::FieldParams&& params, response::StringType&& idArg) const final + void beginSelectionSet(const service::SelectionSetParams& params) const final { - return { _pimpl->getHuman(std::move(params), std::move(idArg)) }; + if constexpr (methods::QueryMethod::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } } - service::FieldResult> getDroid(service::FieldParams&& params, response::StringType&& idArg) const final + void endSelectionSet(const service::SelectionSetParams& params) const final { - return { _pimpl->getDroid(std::move(params), std::move(idArg)) }; + if constexpr (methods::QueryMethod::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } } private: diff --git a/samples/learn/ReviewObject.h b/samples/learn/ReviewObject.h index d112b59c..03ce6379 100644 --- a/samples/learn/ReviewObject.h +++ b/samples/learn/ReviewObject.h @@ -11,7 +11,31 @@ #include "StarWarsSchema.h" namespace graphql::learn::object { -namespace stub::ReviewStubs { +namespace methods::ReviewMethod { + +template +concept WithParamsStars = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult { impl.getStars(std::move(params)) } }; +}; + +template +concept NoParamsStars = requires (TImpl impl) +{ + { service::FieldResult { impl.getStars() } }; +}; + +template +concept WithParamsCommentary = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult> { impl.getCommentary(std::move(params)) } }; +}; + +template +concept NoParamsCommentary = requires (TImpl impl) +{ + { service::FieldResult> { impl.getCommentary() } }; +}; template concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) @@ -25,7 +49,7 @@ concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetPa { impl.endSelectionSet(params) }; }; -} // namespace stub::ReviewStubs +} // namespace methods::ReviewMethod class Review : public service::Object @@ -56,30 +80,52 @@ class Review { } - void beginSelectionSet(const service::SelectionSetParams& params) const final + service::FieldResult getStars(service::FieldParams&& params) const final { - if constexpr (stub::ReviewStubs::HasBeginSelectionSet) + if constexpr (methods::ReviewMethod::WithParamsStars) { - _pimpl->beginSelectionSet(params); + return { _pimpl->getStars(std::move(params)) }; + } + else if constexpr (methods::ReviewMethod::NoParamsStars) + { + return { _pimpl->getStars() }; + } + else + { + static_assert(false, R"msg(Review::getStars is not implemented)msg"); } } - void endSelectionSet(const service::SelectionSetParams& params) const final + service::FieldResult> getCommentary(service::FieldParams&& params) const final { - if constexpr (stub::ReviewStubs::HasEndSelectionSet) + if constexpr (methods::ReviewMethod::WithParamsCommentary) { - _pimpl->endSelectionSet(params); + return { _pimpl->getCommentary(std::move(params)) }; + } + else if constexpr (methods::ReviewMethod::NoParamsCommentary) + { + return { _pimpl->getCommentary() }; + } + else + { + static_assert(false, R"msg(Review::getCommentary is not implemented)msg"); } } - service::FieldResult getStars(service::FieldParams&& params) const final + void beginSelectionSet(const service::SelectionSetParams& params) const final { - return { _pimpl->getStars(std::move(params)) }; + if constexpr (methods::ReviewMethod::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } } - service::FieldResult> getCommentary(service::FieldParams&& params) const final + void endSelectionSet(const service::SelectionSetParams& params) const final { - return { _pimpl->getCommentary(std::move(params)) }; + if constexpr (methods::ReviewMethod::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } } private: diff --git a/samples/separate/AppointmentConnectionObject.h b/samples/separate/AppointmentConnectionObject.h index b1769e29..20146fdf 100644 --- a/samples/separate/AppointmentConnectionObject.h +++ b/samples/separate/AppointmentConnectionObject.h @@ -11,20 +11,32 @@ #include "TodaySchema.h" namespace graphql::today::object { -namespace stub::AppointmentConnectionStubs { +namespace methods::AppointmentConnectionMethod { template -concept HasPageInfo = requires (TImpl impl, service::FieldParams params) +concept WithParamsPageInfo = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getPageInfo(std::move(params)) } }; }; template -concept HasEdges = requires (TImpl impl, service::FieldParams params) +concept NoParamsPageInfo = requires (TImpl impl) +{ + { service::FieldResult> { impl.getPageInfo() } }; +}; + +template +concept WithParamsEdges = requires (TImpl impl, service::FieldParams params) { { service::FieldResult>>> { impl.getEdges(std::move(params)) } }; }; +template +concept NoParamsEdges = requires (TImpl impl) +{ + { service::FieldResult>>> { impl.getEdges() } }; +}; + template concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { @@ -37,7 +49,7 @@ concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetPa { impl.endSelectionSet(params) }; }; -} // namespace stub::AppointmentConnectionStubs +} // namespace methods::AppointmentConnectionMethod class AppointmentConnection : public service::Object @@ -68,28 +80,16 @@ class AppointmentConnection { } - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::AppointmentConnectionStubs::HasBeginSelectionSet) - { - _pimpl->beginSelectionSet(params); - } - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::AppointmentConnectionStubs::HasEndSelectionSet) - { - _pimpl->endSelectionSet(params); - } - } - service::FieldResult> getPageInfo(service::FieldParams&& params) const final { - if constexpr (stub::AppointmentConnectionStubs::HasPageInfo) + if constexpr (methods::AppointmentConnectionMethod::WithParamsPageInfo) { return { _pimpl->getPageInfo(std::move(params)) }; } + else if constexpr (methods::AppointmentConnectionMethod::NoParamsPageInfo) + { + return { _pimpl->getPageInfo() }; + } else { throw std::runtime_error(R"ex(AppointmentConnection::getPageInfo is not implemented)ex"); @@ -98,16 +98,36 @@ class AppointmentConnection service::FieldResult>>> getEdges(service::FieldParams&& params) const final { - if constexpr (stub::AppointmentConnectionStubs::HasEdges) + if constexpr (methods::AppointmentConnectionMethod::WithParamsEdges) { return { _pimpl->getEdges(std::move(params)) }; } + else if constexpr (methods::AppointmentConnectionMethod::NoParamsEdges) + { + return { _pimpl->getEdges() }; + } else { throw std::runtime_error(R"ex(AppointmentConnection::getEdges is not implemented)ex"); } } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::AppointmentConnectionMethod::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::AppointmentConnectionMethod::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + private: const std::shared_ptr _pimpl; }; diff --git a/samples/separate/AppointmentEdgeObject.h b/samples/separate/AppointmentEdgeObject.h index 75b15875..893a704d 100644 --- a/samples/separate/AppointmentEdgeObject.h +++ b/samples/separate/AppointmentEdgeObject.h @@ -11,20 +11,32 @@ #include "TodaySchema.h" namespace graphql::today::object { -namespace stub::AppointmentEdgeStubs { +namespace methods::AppointmentEdgeMethod { template -concept HasNode = requires (TImpl impl, service::FieldParams params) +concept WithParamsNode = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getNode(std::move(params)) } }; }; template -concept HasCursor = requires (TImpl impl, service::FieldParams params) +concept NoParamsNode = requires (TImpl impl) +{ + { service::FieldResult> { impl.getNode() } }; +}; + +template +concept WithParamsCursor = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getCursor(std::move(params)) } }; }; +template +concept NoParamsCursor = requires (TImpl impl) +{ + { service::FieldResult { impl.getCursor() } }; +}; + template concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { @@ -37,7 +49,7 @@ concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetPa { impl.endSelectionSet(params) }; }; -} // namespace stub::AppointmentEdgeStubs +} // namespace methods::AppointmentEdgeMethod class AppointmentEdge : public service::Object @@ -68,28 +80,16 @@ class AppointmentEdge { } - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::AppointmentEdgeStubs::HasBeginSelectionSet) - { - _pimpl->beginSelectionSet(params); - } - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::AppointmentEdgeStubs::HasEndSelectionSet) - { - _pimpl->endSelectionSet(params); - } - } - service::FieldResult> getNode(service::FieldParams&& params) const final { - if constexpr (stub::AppointmentEdgeStubs::HasNode) + if constexpr (methods::AppointmentEdgeMethod::WithParamsNode) { return { _pimpl->getNode(std::move(params)) }; } + else if constexpr (methods::AppointmentEdgeMethod::NoParamsNode) + { + return { _pimpl->getNode() }; + } else { throw std::runtime_error(R"ex(AppointmentEdge::getNode is not implemented)ex"); @@ -98,16 +98,36 @@ class AppointmentEdge service::FieldResult getCursor(service::FieldParams&& params) const final { - if constexpr (stub::AppointmentEdgeStubs::HasCursor) + if constexpr (methods::AppointmentEdgeMethod::WithParamsCursor) { return { _pimpl->getCursor(std::move(params)) }; } + else if constexpr (methods::AppointmentEdgeMethod::NoParamsCursor) + { + return { _pimpl->getCursor() }; + } else { throw std::runtime_error(R"ex(AppointmentEdge::getCursor is not implemented)ex"); } } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::AppointmentEdgeMethod::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::AppointmentEdgeMethod::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + private: const std::shared_ptr _pimpl; }; diff --git a/samples/separate/AppointmentObject.h b/samples/separate/AppointmentObject.h index e20b8661..002c99c7 100644 --- a/samples/separate/AppointmentObject.h +++ b/samples/separate/AppointmentObject.h @@ -11,38 +11,68 @@ #include "TodaySchema.h" namespace graphql::today::object { -namespace stub::AppointmentStubs { +namespace methods::AppointmentMethod { template -concept HasId = requires (TImpl impl, service::FieldParams params) +concept WithParamsId = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getId(std::move(params)) } }; }; template -concept HasWhen = requires (TImpl impl, service::FieldParams params) +concept NoParamsId = requires (TImpl impl) +{ + { service::FieldResult { impl.getId() } }; +}; + +template +concept WithParamsWhen = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getWhen(std::move(params)) } }; }; template -concept HasSubject = requires (TImpl impl, service::FieldParams params) +concept NoParamsWhen = requires (TImpl impl) +{ + { service::FieldResult> { impl.getWhen() } }; +}; + +template +concept WithParamsSubject = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getSubject(std::move(params)) } }; }; template -concept HasIsNow = requires (TImpl impl, service::FieldParams params) +concept NoParamsSubject = requires (TImpl impl) +{ + { service::FieldResult> { impl.getSubject() } }; +}; + +template +concept WithParamsIsNow = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getIsNow(std::move(params)) } }; }; template -concept HasForceError = requires (TImpl impl, service::FieldParams params) +concept NoParamsIsNow = requires (TImpl impl) +{ + { service::FieldResult { impl.getIsNow() } }; +}; + +template +concept WithParamsForceError = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getForceError(std::move(params)) } }; }; +template +concept NoParamsForceError = requires (TImpl impl) +{ + { service::FieldResult> { impl.getForceError() } }; +}; + template concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { @@ -55,7 +85,7 @@ concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetPa { impl.endSelectionSet(params) }; }; -} // namespace stub::AppointmentStubs +} // namespace methods::AppointmentMethod class Appointment : public service::Object @@ -92,28 +122,16 @@ class Appointment { } - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::AppointmentStubs::HasBeginSelectionSet) - { - _pimpl->beginSelectionSet(params); - } - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::AppointmentStubs::HasEndSelectionSet) - { - _pimpl->endSelectionSet(params); - } - } - service::FieldResult getId(service::FieldParams&& params) const final { - if constexpr (stub::AppointmentStubs::HasId) + if constexpr (methods::AppointmentMethod::WithParamsId) { return { _pimpl->getId(std::move(params)) }; } + else if constexpr (methods::AppointmentMethod::NoParamsId) + { + return { _pimpl->getId() }; + } else { throw std::runtime_error(R"ex(Appointment::getId is not implemented)ex"); @@ -122,10 +140,14 @@ class Appointment service::FieldResult> getWhen(service::FieldParams&& params) const final { - if constexpr (stub::AppointmentStubs::HasWhen) + if constexpr (methods::AppointmentMethod::WithParamsWhen) { return { _pimpl->getWhen(std::move(params)) }; } + else if constexpr (methods::AppointmentMethod::NoParamsWhen) + { + return { _pimpl->getWhen() }; + } else { throw std::runtime_error(R"ex(Appointment::getWhen is not implemented)ex"); @@ -134,10 +156,14 @@ class Appointment service::FieldResult> getSubject(service::FieldParams&& params) const final { - if constexpr (stub::AppointmentStubs::HasSubject) + if constexpr (methods::AppointmentMethod::WithParamsSubject) { return { _pimpl->getSubject(std::move(params)) }; } + else if constexpr (methods::AppointmentMethod::NoParamsSubject) + { + return { _pimpl->getSubject() }; + } else { throw std::runtime_error(R"ex(Appointment::getSubject is not implemented)ex"); @@ -146,10 +172,14 @@ class Appointment service::FieldResult getIsNow(service::FieldParams&& params) const final { - if constexpr (stub::AppointmentStubs::HasIsNow) + if constexpr (methods::AppointmentMethod::WithParamsIsNow) { return { _pimpl->getIsNow(std::move(params)) }; } + else if constexpr (methods::AppointmentMethod::NoParamsIsNow) + { + return { _pimpl->getIsNow() }; + } else { throw std::runtime_error(R"ex(Appointment::getIsNow is not implemented)ex"); @@ -158,16 +188,36 @@ class Appointment service::FieldResult> getForceError(service::FieldParams&& params) const final { - if constexpr (stub::AppointmentStubs::HasForceError) + if constexpr (methods::AppointmentMethod::WithParamsForceError) { return { _pimpl->getForceError(std::move(params)) }; } + else if constexpr (methods::AppointmentMethod::NoParamsForceError) + { + return { _pimpl->getForceError() }; + } else { throw std::runtime_error(R"ex(Appointment::getForceError is not implemented)ex"); } } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::AppointmentMethod::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::AppointmentMethod::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + private: const std::shared_ptr _pimpl; }; diff --git a/samples/separate/CompleteTaskPayloadObject.h b/samples/separate/CompleteTaskPayloadObject.h index c3ae3927..054b0c9a 100644 --- a/samples/separate/CompleteTaskPayloadObject.h +++ b/samples/separate/CompleteTaskPayloadObject.h @@ -11,20 +11,32 @@ #include "TodaySchema.h" namespace graphql::today::object { -namespace stub::CompleteTaskPayloadStubs { +namespace methods::CompleteTaskPayloadMethod { template -concept HasTask = requires (TImpl impl, service::FieldParams params) +concept WithParamsTask = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getTask(std::move(params)) } }; }; template -concept HasClientMutationId = requires (TImpl impl, service::FieldParams params) +concept NoParamsTask = requires (TImpl impl) +{ + { service::FieldResult> { impl.getTask() } }; +}; + +template +concept WithParamsClientMutationId = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getClientMutationId(std::move(params)) } }; }; +template +concept NoParamsClientMutationId = requires (TImpl impl) +{ + { service::FieldResult> { impl.getClientMutationId() } }; +}; + template concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { @@ -37,7 +49,7 @@ concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetPa { impl.endSelectionSet(params) }; }; -} // namespace stub::CompleteTaskPayloadStubs +} // namespace methods::CompleteTaskPayloadMethod class CompleteTaskPayload : public service::Object @@ -68,28 +80,16 @@ class CompleteTaskPayload { } - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::CompleteTaskPayloadStubs::HasBeginSelectionSet) - { - _pimpl->beginSelectionSet(params); - } - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::CompleteTaskPayloadStubs::HasEndSelectionSet) - { - _pimpl->endSelectionSet(params); - } - } - service::FieldResult> getTask(service::FieldParams&& params) const final { - if constexpr (stub::CompleteTaskPayloadStubs::HasTask) + if constexpr (methods::CompleteTaskPayloadMethod::WithParamsTask) { return { _pimpl->getTask(std::move(params)) }; } + else if constexpr (methods::CompleteTaskPayloadMethod::NoParamsTask) + { + return { _pimpl->getTask() }; + } else { throw std::runtime_error(R"ex(CompleteTaskPayload::getTask is not implemented)ex"); @@ -98,16 +98,36 @@ class CompleteTaskPayload service::FieldResult> getClientMutationId(service::FieldParams&& params) const final { - if constexpr (stub::CompleteTaskPayloadStubs::HasClientMutationId) + if constexpr (methods::CompleteTaskPayloadMethod::WithParamsClientMutationId) { return { _pimpl->getClientMutationId(std::move(params)) }; } + else if constexpr (methods::CompleteTaskPayloadMethod::NoParamsClientMutationId) + { + return { _pimpl->getClientMutationId() }; + } else { throw std::runtime_error(R"ex(CompleteTaskPayload::getClientMutationId is not implemented)ex"); } } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::CompleteTaskPayloadMethod::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::CompleteTaskPayloadMethod::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + private: const std::shared_ptr _pimpl; }; diff --git a/samples/separate/ExpensiveObject.h b/samples/separate/ExpensiveObject.h index 5a388c99..d34236b8 100644 --- a/samples/separate/ExpensiveObject.h +++ b/samples/separate/ExpensiveObject.h @@ -11,14 +11,20 @@ #include "TodaySchema.h" namespace graphql::today::object { -namespace stub::ExpensiveStubs { +namespace methods::ExpensiveMethod { template -concept HasOrder = requires (TImpl impl, service::FieldParams params) +concept WithParamsOrder = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getOrder(std::move(params)) } }; }; +template +concept NoParamsOrder = requires (TImpl impl) +{ + { service::FieldResult { impl.getOrder() } }; +}; + template concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { @@ -31,7 +37,7 @@ concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetPa { impl.endSelectionSet(params) }; }; -} // namespace stub::ExpensiveStubs +} // namespace methods::ExpensiveMethod class Expensive : public service::Object @@ -60,31 +66,35 @@ class Expensive { } - void beginSelectionSet(const service::SelectionSetParams& params) const final + service::FieldResult getOrder(service::FieldParams&& params) const final { - if constexpr (stub::ExpensiveStubs::HasBeginSelectionSet) + if constexpr (methods::ExpensiveMethod::WithParamsOrder) { - _pimpl->beginSelectionSet(params); + return { _pimpl->getOrder(std::move(params)) }; + } + else if constexpr (methods::ExpensiveMethod::NoParamsOrder) + { + return { _pimpl->getOrder() }; + } + else + { + throw std::runtime_error(R"ex(Expensive::getOrder is not implemented)ex"); } } - void endSelectionSet(const service::SelectionSetParams& params) const final + void beginSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (stub::ExpensiveStubs::HasEndSelectionSet) + if constexpr (methods::ExpensiveMethod::HasBeginSelectionSet) { - _pimpl->endSelectionSet(params); + _pimpl->beginSelectionSet(params); } } - service::FieldResult getOrder(service::FieldParams&& params) const final + void endSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (stub::ExpensiveStubs::HasOrder) + if constexpr (methods::ExpensiveMethod::HasEndSelectionSet) { - return { _pimpl->getOrder(std::move(params)) }; - } - else - { - throw std::runtime_error(R"ex(Expensive::getOrder is not implemented)ex"); + _pimpl->endSelectionSet(params); } } diff --git a/samples/separate/FolderConnectionObject.h b/samples/separate/FolderConnectionObject.h index ffa4a7f0..f1dc10b1 100644 --- a/samples/separate/FolderConnectionObject.h +++ b/samples/separate/FolderConnectionObject.h @@ -11,20 +11,32 @@ #include "TodaySchema.h" namespace graphql::today::object { -namespace stub::FolderConnectionStubs { +namespace methods::FolderConnectionMethod { template -concept HasPageInfo = requires (TImpl impl, service::FieldParams params) +concept WithParamsPageInfo = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getPageInfo(std::move(params)) } }; }; template -concept HasEdges = requires (TImpl impl, service::FieldParams params) +concept NoParamsPageInfo = requires (TImpl impl) +{ + { service::FieldResult> { impl.getPageInfo() } }; +}; + +template +concept WithParamsEdges = requires (TImpl impl, service::FieldParams params) { { service::FieldResult>>> { impl.getEdges(std::move(params)) } }; }; +template +concept NoParamsEdges = requires (TImpl impl) +{ + { service::FieldResult>>> { impl.getEdges() } }; +}; + template concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { @@ -37,7 +49,7 @@ concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetPa { impl.endSelectionSet(params) }; }; -} // namespace stub::FolderConnectionStubs +} // namespace methods::FolderConnectionMethod class FolderConnection : public service::Object @@ -68,28 +80,16 @@ class FolderConnection { } - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::FolderConnectionStubs::HasBeginSelectionSet) - { - _pimpl->beginSelectionSet(params); - } - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::FolderConnectionStubs::HasEndSelectionSet) - { - _pimpl->endSelectionSet(params); - } - } - service::FieldResult> getPageInfo(service::FieldParams&& params) const final { - if constexpr (stub::FolderConnectionStubs::HasPageInfo) + if constexpr (methods::FolderConnectionMethod::WithParamsPageInfo) { return { _pimpl->getPageInfo(std::move(params)) }; } + else if constexpr (methods::FolderConnectionMethod::NoParamsPageInfo) + { + return { _pimpl->getPageInfo() }; + } else { throw std::runtime_error(R"ex(FolderConnection::getPageInfo is not implemented)ex"); @@ -98,16 +98,36 @@ class FolderConnection service::FieldResult>>> getEdges(service::FieldParams&& params) const final { - if constexpr (stub::FolderConnectionStubs::HasEdges) + if constexpr (methods::FolderConnectionMethod::WithParamsEdges) { return { _pimpl->getEdges(std::move(params)) }; } + else if constexpr (methods::FolderConnectionMethod::NoParamsEdges) + { + return { _pimpl->getEdges() }; + } else { throw std::runtime_error(R"ex(FolderConnection::getEdges is not implemented)ex"); } } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::FolderConnectionMethod::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::FolderConnectionMethod::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + private: const std::shared_ptr _pimpl; }; diff --git a/samples/separate/FolderEdgeObject.h b/samples/separate/FolderEdgeObject.h index f030a84f..6fbd7499 100644 --- a/samples/separate/FolderEdgeObject.h +++ b/samples/separate/FolderEdgeObject.h @@ -11,20 +11,32 @@ #include "TodaySchema.h" namespace graphql::today::object { -namespace stub::FolderEdgeStubs { +namespace methods::FolderEdgeMethod { template -concept HasNode = requires (TImpl impl, service::FieldParams params) +concept WithParamsNode = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getNode(std::move(params)) } }; }; template -concept HasCursor = requires (TImpl impl, service::FieldParams params) +concept NoParamsNode = requires (TImpl impl) +{ + { service::FieldResult> { impl.getNode() } }; +}; + +template +concept WithParamsCursor = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getCursor(std::move(params)) } }; }; +template +concept NoParamsCursor = requires (TImpl impl) +{ + { service::FieldResult { impl.getCursor() } }; +}; + template concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { @@ -37,7 +49,7 @@ concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetPa { impl.endSelectionSet(params) }; }; -} // namespace stub::FolderEdgeStubs +} // namespace methods::FolderEdgeMethod class FolderEdge : public service::Object @@ -68,28 +80,16 @@ class FolderEdge { } - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::FolderEdgeStubs::HasBeginSelectionSet) - { - _pimpl->beginSelectionSet(params); - } - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::FolderEdgeStubs::HasEndSelectionSet) - { - _pimpl->endSelectionSet(params); - } - } - service::FieldResult> getNode(service::FieldParams&& params) const final { - if constexpr (stub::FolderEdgeStubs::HasNode) + if constexpr (methods::FolderEdgeMethod::WithParamsNode) { return { _pimpl->getNode(std::move(params)) }; } + else if constexpr (methods::FolderEdgeMethod::NoParamsNode) + { + return { _pimpl->getNode() }; + } else { throw std::runtime_error(R"ex(FolderEdge::getNode is not implemented)ex"); @@ -98,16 +98,36 @@ class FolderEdge service::FieldResult getCursor(service::FieldParams&& params) const final { - if constexpr (stub::FolderEdgeStubs::HasCursor) + if constexpr (methods::FolderEdgeMethod::WithParamsCursor) { return { _pimpl->getCursor(std::move(params)) }; } + else if constexpr (methods::FolderEdgeMethod::NoParamsCursor) + { + return { _pimpl->getCursor() }; + } else { throw std::runtime_error(R"ex(FolderEdge::getCursor is not implemented)ex"); } } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::FolderEdgeMethod::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::FolderEdgeMethod::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + private: const std::shared_ptr _pimpl; }; diff --git a/samples/separate/FolderObject.h b/samples/separate/FolderObject.h index 64c2882b..e96ba675 100644 --- a/samples/separate/FolderObject.h +++ b/samples/separate/FolderObject.h @@ -11,26 +11,44 @@ #include "TodaySchema.h" namespace graphql::today::object { -namespace stub::FolderStubs { +namespace methods::FolderMethod { template -concept HasId = requires (TImpl impl, service::FieldParams params) +concept WithParamsId = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getId(std::move(params)) } }; }; template -concept HasName = requires (TImpl impl, service::FieldParams params) +concept NoParamsId = requires (TImpl impl) +{ + { service::FieldResult { impl.getId() } }; +}; + +template +concept WithParamsName = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getName(std::move(params)) } }; }; template -concept HasUnreadCount = requires (TImpl impl, service::FieldParams params) +concept NoParamsName = requires (TImpl impl) +{ + { service::FieldResult> { impl.getName() } }; +}; + +template +concept WithParamsUnreadCount = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getUnreadCount(std::move(params)) } }; }; +template +concept NoParamsUnreadCount = requires (TImpl impl) +{ + { service::FieldResult { impl.getUnreadCount() } }; +}; + template concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { @@ -43,7 +61,7 @@ concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetPa { impl.endSelectionSet(params) }; }; -} // namespace stub::FolderStubs +} // namespace methods::FolderMethod class Folder : public service::Object @@ -76,28 +94,16 @@ class Folder { } - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::FolderStubs::HasBeginSelectionSet) - { - _pimpl->beginSelectionSet(params); - } - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::FolderStubs::HasEndSelectionSet) - { - _pimpl->endSelectionSet(params); - } - } - service::FieldResult getId(service::FieldParams&& params) const final { - if constexpr (stub::FolderStubs::HasId) + if constexpr (methods::FolderMethod::WithParamsId) { return { _pimpl->getId(std::move(params)) }; } + else if constexpr (methods::FolderMethod::NoParamsId) + { + return { _pimpl->getId() }; + } else { throw std::runtime_error(R"ex(Folder::getId is not implemented)ex"); @@ -106,10 +112,14 @@ class Folder service::FieldResult> getName(service::FieldParams&& params) const final { - if constexpr (stub::FolderStubs::HasName) + if constexpr (methods::FolderMethod::WithParamsName) { return { _pimpl->getName(std::move(params)) }; } + else if constexpr (methods::FolderMethod::NoParamsName) + { + return { _pimpl->getName() }; + } else { throw std::runtime_error(R"ex(Folder::getName is not implemented)ex"); @@ -118,16 +128,36 @@ class Folder service::FieldResult getUnreadCount(service::FieldParams&& params) const final { - if constexpr (stub::FolderStubs::HasUnreadCount) + if constexpr (methods::FolderMethod::WithParamsUnreadCount) { return { _pimpl->getUnreadCount(std::move(params)) }; } + else if constexpr (methods::FolderMethod::NoParamsUnreadCount) + { + return { _pimpl->getUnreadCount() }; + } else { throw std::runtime_error(R"ex(Folder::getUnreadCount is not implemented)ex"); } } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::FolderMethod::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::FolderMethod::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + private: const std::shared_ptr _pimpl; }; diff --git a/samples/separate/MutationObject.h b/samples/separate/MutationObject.h index f1ecd666..be61f359 100644 --- a/samples/separate/MutationObject.h +++ b/samples/separate/MutationObject.h @@ -11,20 +11,32 @@ #include "TodaySchema.h" namespace graphql::today::object { -namespace stub::MutationStubs { +namespace methods::MutationMethod { template -concept HasCompleteTask = requires (TImpl impl, service::FieldParams params, CompleteTaskInput inputArg) +concept WithParamsCompleteTask = requires (TImpl impl, service::FieldParams params, CompleteTaskInput inputArg) { { service::FieldResult> { impl.applyCompleteTask(std::move(params), std::move(inputArg)) } }; }; template -concept HasSetFloat = requires (TImpl impl, service::FieldParams params, response::FloatType valueArg) +concept NoParamsCompleteTask = requires (TImpl impl, CompleteTaskInput inputArg) +{ + { service::FieldResult> { impl.applyCompleteTask(std::move(inputArg)) } }; +}; + +template +concept WithParamsSetFloat = requires (TImpl impl, service::FieldParams params, response::FloatType valueArg) { { service::FieldResult { impl.applySetFloat(std::move(params), std::move(valueArg)) } }; }; +template +concept NoParamsSetFloat = requires (TImpl impl, response::FloatType valueArg) +{ + { service::FieldResult { impl.applySetFloat(std::move(valueArg)) } }; +}; + template concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { @@ -37,7 +49,7 @@ concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetPa { impl.endSelectionSet(params) }; }; -} // namespace stub::MutationStubs +} // namespace methods::MutationMethod class Mutation : public service::Object @@ -68,28 +80,16 @@ class Mutation { } - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::MutationStubs::HasBeginSelectionSet) - { - _pimpl->beginSelectionSet(params); - } - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::MutationStubs::HasEndSelectionSet) - { - _pimpl->endSelectionSet(params); - } - } - service::FieldResult> applyCompleteTask(service::FieldParams&& params, CompleteTaskInput&& inputArg) const final { - if constexpr (stub::MutationStubs::HasCompleteTask) + if constexpr (methods::MutationMethod::WithParamsCompleteTask) { return { _pimpl->applyCompleteTask(std::move(params), std::move(inputArg)) }; } + else if constexpr (methods::MutationMethod::NoParamsCompleteTask) + { + return { _pimpl->applyCompleteTask(std::move(inputArg)) }; + } else { throw std::runtime_error(R"ex(Mutation::applyCompleteTask is not implemented)ex"); @@ -98,16 +98,36 @@ class Mutation service::FieldResult applySetFloat(service::FieldParams&& params, response::FloatType&& valueArg) const final { - if constexpr (stub::MutationStubs::HasSetFloat) + if constexpr (methods::MutationMethod::WithParamsSetFloat) { return { _pimpl->applySetFloat(std::move(params), std::move(valueArg)) }; } + else if constexpr (methods::MutationMethod::NoParamsSetFloat) + { + return { _pimpl->applySetFloat(std::move(valueArg)) }; + } else { throw std::runtime_error(R"ex(Mutation::applySetFloat is not implemented)ex"); } } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::MutationMethod::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::MutationMethod::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + private: const std::shared_ptr _pimpl; }; diff --git a/samples/separate/NestedTypeObject.h b/samples/separate/NestedTypeObject.h index ce9f276e..d4f2551f 100644 --- a/samples/separate/NestedTypeObject.h +++ b/samples/separate/NestedTypeObject.h @@ -11,20 +11,32 @@ #include "TodaySchema.h" namespace graphql::today::object { -namespace stub::NestedTypeStubs { +namespace methods::NestedTypeMethod { template -concept HasDepth = requires (TImpl impl, service::FieldParams params) +concept WithParamsDepth = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getDepth(std::move(params)) } }; }; template -concept HasNested = requires (TImpl impl, service::FieldParams params) +concept NoParamsDepth = requires (TImpl impl) +{ + { service::FieldResult { impl.getDepth() } }; +}; + +template +concept WithParamsNested = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getNested(std::move(params)) } }; }; +template +concept NoParamsNested = requires (TImpl impl) +{ + { service::FieldResult> { impl.getNested() } }; +}; + template concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { @@ -37,7 +49,7 @@ concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetPa { impl.endSelectionSet(params) }; }; -} // namespace stub::NestedTypeStubs +} // namespace methods::NestedTypeMethod class NestedType : public service::Object @@ -68,28 +80,16 @@ class NestedType { } - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::NestedTypeStubs::HasBeginSelectionSet) - { - _pimpl->beginSelectionSet(params); - } - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::NestedTypeStubs::HasEndSelectionSet) - { - _pimpl->endSelectionSet(params); - } - } - service::FieldResult getDepth(service::FieldParams&& params) const final { - if constexpr (stub::NestedTypeStubs::HasDepth) + if constexpr (methods::NestedTypeMethod::WithParamsDepth) { return { _pimpl->getDepth(std::move(params)) }; } + else if constexpr (methods::NestedTypeMethod::NoParamsDepth) + { + return { _pimpl->getDepth() }; + } else { throw std::runtime_error(R"ex(NestedType::getDepth is not implemented)ex"); @@ -98,16 +98,36 @@ class NestedType service::FieldResult> getNested(service::FieldParams&& params) const final { - if constexpr (stub::NestedTypeStubs::HasNested) + if constexpr (methods::NestedTypeMethod::WithParamsNested) { return { _pimpl->getNested(std::move(params)) }; } + else if constexpr (methods::NestedTypeMethod::NoParamsNested) + { + return { _pimpl->getNested() }; + } else { throw std::runtime_error(R"ex(NestedType::getNested is not implemented)ex"); } } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::NestedTypeMethod::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::NestedTypeMethod::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + private: const std::shared_ptr _pimpl; }; diff --git a/samples/separate/PageInfoObject.h b/samples/separate/PageInfoObject.h index 675ff995..cf4a8158 100644 --- a/samples/separate/PageInfoObject.h +++ b/samples/separate/PageInfoObject.h @@ -11,20 +11,32 @@ #include "TodaySchema.h" namespace graphql::today::object { -namespace stub::PageInfoStubs { +namespace methods::PageInfoMethod { template -concept HasHasNextPage = requires (TImpl impl, service::FieldParams params) +concept WithParamsHasNextPage = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getHasNextPage(std::move(params)) } }; }; template -concept HasHasPreviousPage = requires (TImpl impl, service::FieldParams params) +concept NoParamsHasNextPage = requires (TImpl impl) +{ + { service::FieldResult { impl.getHasNextPage() } }; +}; + +template +concept WithParamsHasPreviousPage = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getHasPreviousPage(std::move(params)) } }; }; +template +concept NoParamsHasPreviousPage = requires (TImpl impl) +{ + { service::FieldResult { impl.getHasPreviousPage() } }; +}; + template concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { @@ -37,7 +49,7 @@ concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetPa { impl.endSelectionSet(params) }; }; -} // namespace stub::PageInfoStubs +} // namespace methods::PageInfoMethod class PageInfo : public service::Object @@ -68,28 +80,16 @@ class PageInfo { } - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::PageInfoStubs::HasBeginSelectionSet) - { - _pimpl->beginSelectionSet(params); - } - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::PageInfoStubs::HasEndSelectionSet) - { - _pimpl->endSelectionSet(params); - } - } - service::FieldResult getHasNextPage(service::FieldParams&& params) const final { - if constexpr (stub::PageInfoStubs::HasHasNextPage) + if constexpr (methods::PageInfoMethod::WithParamsHasNextPage) { return { _pimpl->getHasNextPage(std::move(params)) }; } + else if constexpr (methods::PageInfoMethod::NoParamsHasNextPage) + { + return { _pimpl->getHasNextPage() }; + } else { throw std::runtime_error(R"ex(PageInfo::getHasNextPage is not implemented)ex"); @@ -98,16 +98,36 @@ class PageInfo service::FieldResult getHasPreviousPage(service::FieldParams&& params) const final { - if constexpr (stub::PageInfoStubs::HasHasPreviousPage) + if constexpr (methods::PageInfoMethod::WithParamsHasPreviousPage) { return { _pimpl->getHasPreviousPage(std::move(params)) }; } + else if constexpr (methods::PageInfoMethod::NoParamsHasPreviousPage) + { + return { _pimpl->getHasPreviousPage() }; + } else { throw std::runtime_error(R"ex(PageInfo::getHasPreviousPage is not implemented)ex"); } } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::PageInfoMethod::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::PageInfoMethod::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + private: const std::shared_ptr _pimpl; }; diff --git a/samples/separate/QueryObject.h b/samples/separate/QueryObject.h index 6098c42a..6be9b278 100644 --- a/samples/separate/QueryObject.h +++ b/samples/separate/QueryObject.h @@ -11,80 +11,152 @@ #include "TodaySchema.h" namespace graphql::today::object { -namespace stub::QueryStubs { +namespace methods::QueryMethod { template -concept HasNode = requires (TImpl impl, service::FieldParams params, response::IdType idArg) +concept WithParamsNode = requires (TImpl impl, service::FieldParams params, response::IdType idArg) { { service::FieldResult> { impl.getNode(std::move(params), std::move(idArg)) } }; }; template -concept HasAppointments = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) +concept NoParamsNode = requires (TImpl impl, response::IdType idArg) +{ + { service::FieldResult> { impl.getNode(std::move(idArg)) } }; +}; + +template +concept WithParamsAppointments = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) { { service::FieldResult> { impl.getAppointments(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; }; template -concept HasTasks = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) +concept NoParamsAppointments = requires (TImpl impl, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) +{ + { service::FieldResult> { impl.getAppointments(std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; +}; + +template +concept WithParamsTasks = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) { { service::FieldResult> { impl.getTasks(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; }; template -concept HasUnreadCounts = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) +concept NoParamsTasks = requires (TImpl impl, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) +{ + { service::FieldResult> { impl.getTasks(std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; +}; + +template +concept WithParamsUnreadCounts = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) { { service::FieldResult> { impl.getUnreadCounts(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; }; template -concept HasAppointmentsById = requires (TImpl impl, service::FieldParams params, std::vector idsArg) +concept NoParamsUnreadCounts = requires (TImpl impl, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) +{ + { service::FieldResult> { impl.getUnreadCounts(std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; +}; + +template +concept WithParamsAppointmentsById = requires (TImpl impl, service::FieldParams params, std::vector idsArg) { { service::FieldResult>> { impl.getAppointmentsById(std::move(params), std::move(idsArg)) } }; }; template -concept HasTasksById = requires (TImpl impl, service::FieldParams params, std::vector idsArg) +concept NoParamsAppointmentsById = requires (TImpl impl, std::vector idsArg) +{ + { service::FieldResult>> { impl.getAppointmentsById(std::move(idsArg)) } }; +}; + +template +concept WithParamsTasksById = requires (TImpl impl, service::FieldParams params, std::vector idsArg) { { service::FieldResult>> { impl.getTasksById(std::move(params), std::move(idsArg)) } }; }; template -concept HasUnreadCountsById = requires (TImpl impl, service::FieldParams params, std::vector idsArg) +concept NoParamsTasksById = requires (TImpl impl, std::vector idsArg) +{ + { service::FieldResult>> { impl.getTasksById(std::move(idsArg)) } }; +}; + +template +concept WithParamsUnreadCountsById = requires (TImpl impl, service::FieldParams params, std::vector idsArg) { { service::FieldResult>> { impl.getUnreadCountsById(std::move(params), std::move(idsArg)) } }; }; template -concept HasNested = requires (TImpl impl, service::FieldParams params) +concept NoParamsUnreadCountsById = requires (TImpl impl, std::vector idsArg) +{ + { service::FieldResult>> { impl.getUnreadCountsById(std::move(idsArg)) } }; +}; + +template +concept WithParamsNested = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getNested(std::move(params)) } }; }; template -concept HasUnimplemented = requires (TImpl impl, service::FieldParams params) +concept NoParamsNested = requires (TImpl impl) +{ + { service::FieldResult> { impl.getNested() } }; +}; + +template +concept WithParamsUnimplemented = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getUnimplemented(std::move(params)) } }; }; template -concept HasExpensive = requires (TImpl impl, service::FieldParams params) +concept NoParamsUnimplemented = requires (TImpl impl) +{ + { service::FieldResult { impl.getUnimplemented() } }; +}; + +template +concept WithParamsExpensive = requires (TImpl impl, service::FieldParams params) { { service::FieldResult>> { impl.getExpensive(std::move(params)) } }; }; template -concept HasTestTaskState = requires (TImpl impl, service::FieldParams params) +concept NoParamsExpensive = requires (TImpl impl) +{ + { service::FieldResult>> { impl.getExpensive() } }; +}; + +template +concept WithParamsTestTaskState = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getTestTaskState(std::move(params)) } }; }; template -concept HasAnyType = requires (TImpl impl, service::FieldParams params, std::vector idsArg) +concept NoParamsTestTaskState = requires (TImpl impl) +{ + { service::FieldResult { impl.getTestTaskState() } }; +}; + +template +concept WithParamsAnyType = requires (TImpl impl, service::FieldParams params, std::vector idsArg) { { service::FieldResult>> { impl.getAnyType(std::move(params), std::move(idsArg)) } }; }; +template +concept NoParamsAnyType = requires (TImpl impl, std::vector idsArg) +{ + { service::FieldResult>> { impl.getAnyType(std::move(idsArg)) } }; +}; + template concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { @@ -97,7 +169,7 @@ concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetPa { impl.endSelectionSet(params) }; }; -} // namespace stub::QueryStubs +} // namespace methods::QueryMethod class Query : public service::Object @@ -152,28 +224,16 @@ class Query { } - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::QueryStubs::HasBeginSelectionSet) - { - _pimpl->beginSelectionSet(params); - } - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::QueryStubs::HasEndSelectionSet) - { - _pimpl->endSelectionSet(params); - } - } - service::FieldResult> getNode(service::FieldParams&& params, response::IdType&& idArg) const final { - if constexpr (stub::QueryStubs::HasNode) + if constexpr (methods::QueryMethod::WithParamsNode) { return { _pimpl->getNode(std::move(params), std::move(idArg)) }; } + else if constexpr (methods::QueryMethod::NoParamsNode) + { + return { _pimpl->getNode(std::move(idArg)) }; + } else { throw std::runtime_error(R"ex(Query::getNode is not implemented)ex"); @@ -182,10 +242,14 @@ class Query service::FieldResult> getAppointments(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const final { - if constexpr (stub::QueryStubs::HasAppointments) + if constexpr (methods::QueryMethod::WithParamsAppointments) { return { _pimpl->getAppointments(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) }; } + else if constexpr (methods::QueryMethod::NoParamsAppointments) + { + return { _pimpl->getAppointments(std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) }; + } else { throw std::runtime_error(R"ex(Query::getAppointments is not implemented)ex"); @@ -194,10 +258,14 @@ class Query service::FieldResult> getTasks(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const final { - if constexpr (stub::QueryStubs::HasTasks) + if constexpr (methods::QueryMethod::WithParamsTasks) { return { _pimpl->getTasks(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) }; } + else if constexpr (methods::QueryMethod::NoParamsTasks) + { + return { _pimpl->getTasks(std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) }; + } else { throw std::runtime_error(R"ex(Query::getTasks is not implemented)ex"); @@ -206,10 +274,14 @@ class Query service::FieldResult> getUnreadCounts(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const final { - if constexpr (stub::QueryStubs::HasUnreadCounts) + if constexpr (methods::QueryMethod::WithParamsUnreadCounts) { return { _pimpl->getUnreadCounts(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) }; } + else if constexpr (methods::QueryMethod::NoParamsUnreadCounts) + { + return { _pimpl->getUnreadCounts(std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) }; + } else { throw std::runtime_error(R"ex(Query::getUnreadCounts is not implemented)ex"); @@ -218,10 +290,14 @@ class Query service::FieldResult>> getAppointmentsById(service::FieldParams&& params, std::vector&& idsArg) const final { - if constexpr (stub::QueryStubs::HasAppointmentsById) + if constexpr (methods::QueryMethod::WithParamsAppointmentsById) { return { _pimpl->getAppointmentsById(std::move(params), std::move(idsArg)) }; } + else if constexpr (methods::QueryMethod::NoParamsAppointmentsById) + { + return { _pimpl->getAppointmentsById(std::move(idsArg)) }; + } else { throw std::runtime_error(R"ex(Query::getAppointmentsById is not implemented)ex"); @@ -230,10 +306,14 @@ class Query service::FieldResult>> getTasksById(service::FieldParams&& params, std::vector&& idsArg) const final { - if constexpr (stub::QueryStubs::HasTasksById) + if constexpr (methods::QueryMethod::WithParamsTasksById) { return { _pimpl->getTasksById(std::move(params), std::move(idsArg)) }; } + else if constexpr (methods::QueryMethod::NoParamsTasksById) + { + return { _pimpl->getTasksById(std::move(idsArg)) }; + } else { throw std::runtime_error(R"ex(Query::getTasksById is not implemented)ex"); @@ -242,10 +322,14 @@ class Query service::FieldResult>> getUnreadCountsById(service::FieldParams&& params, std::vector&& idsArg) const final { - if constexpr (stub::QueryStubs::HasUnreadCountsById) + if constexpr (methods::QueryMethod::WithParamsUnreadCountsById) { return { _pimpl->getUnreadCountsById(std::move(params), std::move(idsArg)) }; } + else if constexpr (methods::QueryMethod::NoParamsUnreadCountsById) + { + return { _pimpl->getUnreadCountsById(std::move(idsArg)) }; + } else { throw std::runtime_error(R"ex(Query::getUnreadCountsById is not implemented)ex"); @@ -254,10 +338,14 @@ class Query service::FieldResult> getNested(service::FieldParams&& params) const final { - if constexpr (stub::QueryStubs::HasNested) + if constexpr (methods::QueryMethod::WithParamsNested) { return { _pimpl->getNested(std::move(params)) }; } + else if constexpr (methods::QueryMethod::NoParamsNested) + { + return { _pimpl->getNested() }; + } else { throw std::runtime_error(R"ex(Query::getNested is not implemented)ex"); @@ -266,10 +354,14 @@ class Query service::FieldResult getUnimplemented(service::FieldParams&& params) const final { - if constexpr (stub::QueryStubs::HasUnimplemented) + if constexpr (methods::QueryMethod::WithParamsUnimplemented) { return { _pimpl->getUnimplemented(std::move(params)) }; } + else if constexpr (methods::QueryMethod::NoParamsUnimplemented) + { + return { _pimpl->getUnimplemented() }; + } else { throw std::runtime_error(R"ex(Query::getUnimplemented is not implemented)ex"); @@ -278,10 +370,14 @@ class Query service::FieldResult>> getExpensive(service::FieldParams&& params) const final { - if constexpr (stub::QueryStubs::HasExpensive) + if constexpr (methods::QueryMethod::WithParamsExpensive) { return { _pimpl->getExpensive(std::move(params)) }; } + else if constexpr (methods::QueryMethod::NoParamsExpensive) + { + return { _pimpl->getExpensive() }; + } else { throw std::runtime_error(R"ex(Query::getExpensive is not implemented)ex"); @@ -290,10 +386,14 @@ class Query service::FieldResult getTestTaskState(service::FieldParams&& params) const final { - if constexpr (stub::QueryStubs::HasTestTaskState) + if constexpr (methods::QueryMethod::WithParamsTestTaskState) { return { _pimpl->getTestTaskState(std::move(params)) }; } + else if constexpr (methods::QueryMethod::NoParamsTestTaskState) + { + return { _pimpl->getTestTaskState() }; + } else { throw std::runtime_error(R"ex(Query::getTestTaskState is not implemented)ex"); @@ -302,16 +402,36 @@ class Query service::FieldResult>> getAnyType(service::FieldParams&& params, std::vector&& idsArg) const final { - if constexpr (stub::QueryStubs::HasAnyType) + if constexpr (methods::QueryMethod::WithParamsAnyType) { return { _pimpl->getAnyType(std::move(params), std::move(idsArg)) }; } + else if constexpr (methods::QueryMethod::NoParamsAnyType) + { + return { _pimpl->getAnyType(std::move(idsArg)) }; + } else { throw std::runtime_error(R"ex(Query::getAnyType is not implemented)ex"); } } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::QueryMethod::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::QueryMethod::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + private: const std::shared_ptr _pimpl; }; diff --git a/samples/separate/SubscriptionObject.h b/samples/separate/SubscriptionObject.h index 252ac8b8..21db5c1b 100644 --- a/samples/separate/SubscriptionObject.h +++ b/samples/separate/SubscriptionObject.h @@ -11,20 +11,32 @@ #include "TodaySchema.h" namespace graphql::today::object { -namespace stub::SubscriptionStubs { +namespace methods::SubscriptionMethod { template -concept HasNextAppointmentChange = requires (TImpl impl, service::FieldParams params) +concept WithParamsNextAppointmentChange = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getNextAppointmentChange(std::move(params)) } }; }; template -concept HasNodeChange = requires (TImpl impl, service::FieldParams params, response::IdType idArg) +concept NoParamsNextAppointmentChange = requires (TImpl impl) +{ + { service::FieldResult> { impl.getNextAppointmentChange() } }; +}; + +template +concept WithParamsNodeChange = requires (TImpl impl, service::FieldParams params, response::IdType idArg) { { service::FieldResult> { impl.getNodeChange(std::move(params), std::move(idArg)) } }; }; +template +concept NoParamsNodeChange = requires (TImpl impl, response::IdType idArg) +{ + { service::FieldResult> { impl.getNodeChange(std::move(idArg)) } }; +}; + template concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { @@ -37,7 +49,7 @@ concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetPa { impl.endSelectionSet(params) }; }; -} // namespace stub::SubscriptionStubs +} // namespace methods::SubscriptionMethod class Subscription : public service::Object @@ -68,28 +80,16 @@ class Subscription { } - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::SubscriptionStubs::HasBeginSelectionSet) - { - _pimpl->beginSelectionSet(params); - } - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::SubscriptionStubs::HasEndSelectionSet) - { - _pimpl->endSelectionSet(params); - } - } - service::FieldResult> getNextAppointmentChange(service::FieldParams&& params) const final { - if constexpr (stub::SubscriptionStubs::HasNextAppointmentChange) + if constexpr (methods::SubscriptionMethod::WithParamsNextAppointmentChange) { return { _pimpl->getNextAppointmentChange(std::move(params)) }; } + else if constexpr (methods::SubscriptionMethod::NoParamsNextAppointmentChange) + { + return { _pimpl->getNextAppointmentChange() }; + } else { throw std::runtime_error(R"ex(Subscription::getNextAppointmentChange is not implemented)ex"); @@ -98,16 +98,36 @@ class Subscription service::FieldResult> getNodeChange(service::FieldParams&& params, response::IdType&& idArg) const final { - if constexpr (stub::SubscriptionStubs::HasNodeChange) + if constexpr (methods::SubscriptionMethod::WithParamsNodeChange) { return { _pimpl->getNodeChange(std::move(params), std::move(idArg)) }; } + else if constexpr (methods::SubscriptionMethod::NoParamsNodeChange) + { + return { _pimpl->getNodeChange(std::move(idArg)) }; + } else { throw std::runtime_error(R"ex(Subscription::getNodeChange is not implemented)ex"); } } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::SubscriptionMethod::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::SubscriptionMethod::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + private: const std::shared_ptr _pimpl; }; diff --git a/samples/separate/TaskConnectionObject.h b/samples/separate/TaskConnectionObject.h index dd2ca872..362183f2 100644 --- a/samples/separate/TaskConnectionObject.h +++ b/samples/separate/TaskConnectionObject.h @@ -11,20 +11,32 @@ #include "TodaySchema.h" namespace graphql::today::object { -namespace stub::TaskConnectionStubs { +namespace methods::TaskConnectionMethod { template -concept HasPageInfo = requires (TImpl impl, service::FieldParams params) +concept WithParamsPageInfo = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getPageInfo(std::move(params)) } }; }; template -concept HasEdges = requires (TImpl impl, service::FieldParams params) +concept NoParamsPageInfo = requires (TImpl impl) +{ + { service::FieldResult> { impl.getPageInfo() } }; +}; + +template +concept WithParamsEdges = requires (TImpl impl, service::FieldParams params) { { service::FieldResult>>> { impl.getEdges(std::move(params)) } }; }; +template +concept NoParamsEdges = requires (TImpl impl) +{ + { service::FieldResult>>> { impl.getEdges() } }; +}; + template concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { @@ -37,7 +49,7 @@ concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetPa { impl.endSelectionSet(params) }; }; -} // namespace stub::TaskConnectionStubs +} // namespace methods::TaskConnectionMethod class TaskConnection : public service::Object @@ -68,28 +80,16 @@ class TaskConnection { } - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::TaskConnectionStubs::HasBeginSelectionSet) - { - _pimpl->beginSelectionSet(params); - } - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::TaskConnectionStubs::HasEndSelectionSet) - { - _pimpl->endSelectionSet(params); - } - } - service::FieldResult> getPageInfo(service::FieldParams&& params) const final { - if constexpr (stub::TaskConnectionStubs::HasPageInfo) + if constexpr (methods::TaskConnectionMethod::WithParamsPageInfo) { return { _pimpl->getPageInfo(std::move(params)) }; } + else if constexpr (methods::TaskConnectionMethod::NoParamsPageInfo) + { + return { _pimpl->getPageInfo() }; + } else { throw std::runtime_error(R"ex(TaskConnection::getPageInfo is not implemented)ex"); @@ -98,16 +98,36 @@ class TaskConnection service::FieldResult>>> getEdges(service::FieldParams&& params) const final { - if constexpr (stub::TaskConnectionStubs::HasEdges) + if constexpr (methods::TaskConnectionMethod::WithParamsEdges) { return { _pimpl->getEdges(std::move(params)) }; } + else if constexpr (methods::TaskConnectionMethod::NoParamsEdges) + { + return { _pimpl->getEdges() }; + } else { throw std::runtime_error(R"ex(TaskConnection::getEdges is not implemented)ex"); } } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::TaskConnectionMethod::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::TaskConnectionMethod::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + private: const std::shared_ptr _pimpl; }; diff --git a/samples/separate/TaskEdgeObject.h b/samples/separate/TaskEdgeObject.h index b763ff84..45d77ab9 100644 --- a/samples/separate/TaskEdgeObject.h +++ b/samples/separate/TaskEdgeObject.h @@ -11,20 +11,32 @@ #include "TodaySchema.h" namespace graphql::today::object { -namespace stub::TaskEdgeStubs { +namespace methods::TaskEdgeMethod { template -concept HasNode = requires (TImpl impl, service::FieldParams params) +concept WithParamsNode = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getNode(std::move(params)) } }; }; template -concept HasCursor = requires (TImpl impl, service::FieldParams params) +concept NoParamsNode = requires (TImpl impl) +{ + { service::FieldResult> { impl.getNode() } }; +}; + +template +concept WithParamsCursor = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getCursor(std::move(params)) } }; }; +template +concept NoParamsCursor = requires (TImpl impl) +{ + { service::FieldResult { impl.getCursor() } }; +}; + template concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { @@ -37,7 +49,7 @@ concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetPa { impl.endSelectionSet(params) }; }; -} // namespace stub::TaskEdgeStubs +} // namespace methods::TaskEdgeMethod class TaskEdge : public service::Object @@ -68,28 +80,16 @@ class TaskEdge { } - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::TaskEdgeStubs::HasBeginSelectionSet) - { - _pimpl->beginSelectionSet(params); - } - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::TaskEdgeStubs::HasEndSelectionSet) - { - _pimpl->endSelectionSet(params); - } - } - service::FieldResult> getNode(service::FieldParams&& params) const final { - if constexpr (stub::TaskEdgeStubs::HasNode) + if constexpr (methods::TaskEdgeMethod::WithParamsNode) { return { _pimpl->getNode(std::move(params)) }; } + else if constexpr (methods::TaskEdgeMethod::NoParamsNode) + { + return { _pimpl->getNode() }; + } else { throw std::runtime_error(R"ex(TaskEdge::getNode is not implemented)ex"); @@ -98,16 +98,36 @@ class TaskEdge service::FieldResult getCursor(service::FieldParams&& params) const final { - if constexpr (stub::TaskEdgeStubs::HasCursor) + if constexpr (methods::TaskEdgeMethod::WithParamsCursor) { return { _pimpl->getCursor(std::move(params)) }; } + else if constexpr (methods::TaskEdgeMethod::NoParamsCursor) + { + return { _pimpl->getCursor() }; + } else { throw std::runtime_error(R"ex(TaskEdge::getCursor is not implemented)ex"); } } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::TaskEdgeMethod::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::TaskEdgeMethod::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + private: const std::shared_ptr _pimpl; }; diff --git a/samples/separate/TaskObject.h b/samples/separate/TaskObject.h index c2f77d57..780d9d63 100644 --- a/samples/separate/TaskObject.h +++ b/samples/separate/TaskObject.h @@ -11,26 +11,44 @@ #include "TodaySchema.h" namespace graphql::today::object { -namespace stub::TaskStubs { +namespace methods::TaskMethod { template -concept HasId = requires (TImpl impl, service::FieldParams params) +concept WithParamsId = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getId(std::move(params)) } }; }; template -concept HasTitle = requires (TImpl impl, service::FieldParams params) +concept NoParamsId = requires (TImpl impl) +{ + { service::FieldResult { impl.getId() } }; +}; + +template +concept WithParamsTitle = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getTitle(std::move(params)) } }; }; template -concept HasIsComplete = requires (TImpl impl, service::FieldParams params) +concept NoParamsTitle = requires (TImpl impl) +{ + { service::FieldResult> { impl.getTitle() } }; +}; + +template +concept WithParamsIsComplete = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getIsComplete(std::move(params)) } }; }; +template +concept NoParamsIsComplete = requires (TImpl impl) +{ + { service::FieldResult { impl.getIsComplete() } }; +}; + template concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { @@ -43,7 +61,7 @@ concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetPa { impl.endSelectionSet(params) }; }; -} // namespace stub::TaskStubs +} // namespace methods::TaskMethod class Task : public service::Object @@ -76,28 +94,16 @@ class Task { } - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::TaskStubs::HasBeginSelectionSet) - { - _pimpl->beginSelectionSet(params); - } - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::TaskStubs::HasEndSelectionSet) - { - _pimpl->endSelectionSet(params); - } - } - service::FieldResult getId(service::FieldParams&& params) const final { - if constexpr (stub::TaskStubs::HasId) + if constexpr (methods::TaskMethod::WithParamsId) { return { _pimpl->getId(std::move(params)) }; } + else if constexpr (methods::TaskMethod::NoParamsId) + { + return { _pimpl->getId() }; + } else { throw std::runtime_error(R"ex(Task::getId is not implemented)ex"); @@ -106,10 +112,14 @@ class Task service::FieldResult> getTitle(service::FieldParams&& params) const final { - if constexpr (stub::TaskStubs::HasTitle) + if constexpr (methods::TaskMethod::WithParamsTitle) { return { _pimpl->getTitle(std::move(params)) }; } + else if constexpr (methods::TaskMethod::NoParamsTitle) + { + return { _pimpl->getTitle() }; + } else { throw std::runtime_error(R"ex(Task::getTitle is not implemented)ex"); @@ -118,16 +128,36 @@ class Task service::FieldResult getIsComplete(service::FieldParams&& params) const final { - if constexpr (stub::TaskStubs::HasIsComplete) + if constexpr (methods::TaskMethod::WithParamsIsComplete) { return { _pimpl->getIsComplete(std::move(params)) }; } + else if constexpr (methods::TaskMethod::NoParamsIsComplete) + { + return { _pimpl->getIsComplete() }; + } else { throw std::runtime_error(R"ex(Task::getIsComplete is not implemented)ex"); } } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::TaskMethod::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::TaskMethod::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + private: const std::shared_ptr _pimpl; }; diff --git a/samples/separate_nointrospection/AppointmentConnectionObject.h b/samples/separate_nointrospection/AppointmentConnectionObject.h index b1769e29..20146fdf 100644 --- a/samples/separate_nointrospection/AppointmentConnectionObject.h +++ b/samples/separate_nointrospection/AppointmentConnectionObject.h @@ -11,20 +11,32 @@ #include "TodaySchema.h" namespace graphql::today::object { -namespace stub::AppointmentConnectionStubs { +namespace methods::AppointmentConnectionMethod { template -concept HasPageInfo = requires (TImpl impl, service::FieldParams params) +concept WithParamsPageInfo = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getPageInfo(std::move(params)) } }; }; template -concept HasEdges = requires (TImpl impl, service::FieldParams params) +concept NoParamsPageInfo = requires (TImpl impl) +{ + { service::FieldResult> { impl.getPageInfo() } }; +}; + +template +concept WithParamsEdges = requires (TImpl impl, service::FieldParams params) { { service::FieldResult>>> { impl.getEdges(std::move(params)) } }; }; +template +concept NoParamsEdges = requires (TImpl impl) +{ + { service::FieldResult>>> { impl.getEdges() } }; +}; + template concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { @@ -37,7 +49,7 @@ concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetPa { impl.endSelectionSet(params) }; }; -} // namespace stub::AppointmentConnectionStubs +} // namespace methods::AppointmentConnectionMethod class AppointmentConnection : public service::Object @@ -68,28 +80,16 @@ class AppointmentConnection { } - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::AppointmentConnectionStubs::HasBeginSelectionSet) - { - _pimpl->beginSelectionSet(params); - } - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::AppointmentConnectionStubs::HasEndSelectionSet) - { - _pimpl->endSelectionSet(params); - } - } - service::FieldResult> getPageInfo(service::FieldParams&& params) const final { - if constexpr (stub::AppointmentConnectionStubs::HasPageInfo) + if constexpr (methods::AppointmentConnectionMethod::WithParamsPageInfo) { return { _pimpl->getPageInfo(std::move(params)) }; } + else if constexpr (methods::AppointmentConnectionMethod::NoParamsPageInfo) + { + return { _pimpl->getPageInfo() }; + } else { throw std::runtime_error(R"ex(AppointmentConnection::getPageInfo is not implemented)ex"); @@ -98,16 +98,36 @@ class AppointmentConnection service::FieldResult>>> getEdges(service::FieldParams&& params) const final { - if constexpr (stub::AppointmentConnectionStubs::HasEdges) + if constexpr (methods::AppointmentConnectionMethod::WithParamsEdges) { return { _pimpl->getEdges(std::move(params)) }; } + else if constexpr (methods::AppointmentConnectionMethod::NoParamsEdges) + { + return { _pimpl->getEdges() }; + } else { throw std::runtime_error(R"ex(AppointmentConnection::getEdges is not implemented)ex"); } } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::AppointmentConnectionMethod::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::AppointmentConnectionMethod::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + private: const std::shared_ptr _pimpl; }; diff --git a/samples/separate_nointrospection/AppointmentEdgeObject.h b/samples/separate_nointrospection/AppointmentEdgeObject.h index 75b15875..893a704d 100644 --- a/samples/separate_nointrospection/AppointmentEdgeObject.h +++ b/samples/separate_nointrospection/AppointmentEdgeObject.h @@ -11,20 +11,32 @@ #include "TodaySchema.h" namespace graphql::today::object { -namespace stub::AppointmentEdgeStubs { +namespace methods::AppointmentEdgeMethod { template -concept HasNode = requires (TImpl impl, service::FieldParams params) +concept WithParamsNode = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getNode(std::move(params)) } }; }; template -concept HasCursor = requires (TImpl impl, service::FieldParams params) +concept NoParamsNode = requires (TImpl impl) +{ + { service::FieldResult> { impl.getNode() } }; +}; + +template +concept WithParamsCursor = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getCursor(std::move(params)) } }; }; +template +concept NoParamsCursor = requires (TImpl impl) +{ + { service::FieldResult { impl.getCursor() } }; +}; + template concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { @@ -37,7 +49,7 @@ concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetPa { impl.endSelectionSet(params) }; }; -} // namespace stub::AppointmentEdgeStubs +} // namespace methods::AppointmentEdgeMethod class AppointmentEdge : public service::Object @@ -68,28 +80,16 @@ class AppointmentEdge { } - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::AppointmentEdgeStubs::HasBeginSelectionSet) - { - _pimpl->beginSelectionSet(params); - } - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::AppointmentEdgeStubs::HasEndSelectionSet) - { - _pimpl->endSelectionSet(params); - } - } - service::FieldResult> getNode(service::FieldParams&& params) const final { - if constexpr (stub::AppointmentEdgeStubs::HasNode) + if constexpr (methods::AppointmentEdgeMethod::WithParamsNode) { return { _pimpl->getNode(std::move(params)) }; } + else if constexpr (methods::AppointmentEdgeMethod::NoParamsNode) + { + return { _pimpl->getNode() }; + } else { throw std::runtime_error(R"ex(AppointmentEdge::getNode is not implemented)ex"); @@ -98,16 +98,36 @@ class AppointmentEdge service::FieldResult getCursor(service::FieldParams&& params) const final { - if constexpr (stub::AppointmentEdgeStubs::HasCursor) + if constexpr (methods::AppointmentEdgeMethod::WithParamsCursor) { return { _pimpl->getCursor(std::move(params)) }; } + else if constexpr (methods::AppointmentEdgeMethod::NoParamsCursor) + { + return { _pimpl->getCursor() }; + } else { throw std::runtime_error(R"ex(AppointmentEdge::getCursor is not implemented)ex"); } } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::AppointmentEdgeMethod::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::AppointmentEdgeMethod::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + private: const std::shared_ptr _pimpl; }; diff --git a/samples/separate_nointrospection/AppointmentObject.h b/samples/separate_nointrospection/AppointmentObject.h index e20b8661..002c99c7 100644 --- a/samples/separate_nointrospection/AppointmentObject.h +++ b/samples/separate_nointrospection/AppointmentObject.h @@ -11,38 +11,68 @@ #include "TodaySchema.h" namespace graphql::today::object { -namespace stub::AppointmentStubs { +namespace methods::AppointmentMethod { template -concept HasId = requires (TImpl impl, service::FieldParams params) +concept WithParamsId = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getId(std::move(params)) } }; }; template -concept HasWhen = requires (TImpl impl, service::FieldParams params) +concept NoParamsId = requires (TImpl impl) +{ + { service::FieldResult { impl.getId() } }; +}; + +template +concept WithParamsWhen = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getWhen(std::move(params)) } }; }; template -concept HasSubject = requires (TImpl impl, service::FieldParams params) +concept NoParamsWhen = requires (TImpl impl) +{ + { service::FieldResult> { impl.getWhen() } }; +}; + +template +concept WithParamsSubject = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getSubject(std::move(params)) } }; }; template -concept HasIsNow = requires (TImpl impl, service::FieldParams params) +concept NoParamsSubject = requires (TImpl impl) +{ + { service::FieldResult> { impl.getSubject() } }; +}; + +template +concept WithParamsIsNow = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getIsNow(std::move(params)) } }; }; template -concept HasForceError = requires (TImpl impl, service::FieldParams params) +concept NoParamsIsNow = requires (TImpl impl) +{ + { service::FieldResult { impl.getIsNow() } }; +}; + +template +concept WithParamsForceError = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getForceError(std::move(params)) } }; }; +template +concept NoParamsForceError = requires (TImpl impl) +{ + { service::FieldResult> { impl.getForceError() } }; +}; + template concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { @@ -55,7 +85,7 @@ concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetPa { impl.endSelectionSet(params) }; }; -} // namespace stub::AppointmentStubs +} // namespace methods::AppointmentMethod class Appointment : public service::Object @@ -92,28 +122,16 @@ class Appointment { } - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::AppointmentStubs::HasBeginSelectionSet) - { - _pimpl->beginSelectionSet(params); - } - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::AppointmentStubs::HasEndSelectionSet) - { - _pimpl->endSelectionSet(params); - } - } - service::FieldResult getId(service::FieldParams&& params) const final { - if constexpr (stub::AppointmentStubs::HasId) + if constexpr (methods::AppointmentMethod::WithParamsId) { return { _pimpl->getId(std::move(params)) }; } + else if constexpr (methods::AppointmentMethod::NoParamsId) + { + return { _pimpl->getId() }; + } else { throw std::runtime_error(R"ex(Appointment::getId is not implemented)ex"); @@ -122,10 +140,14 @@ class Appointment service::FieldResult> getWhen(service::FieldParams&& params) const final { - if constexpr (stub::AppointmentStubs::HasWhen) + if constexpr (methods::AppointmentMethod::WithParamsWhen) { return { _pimpl->getWhen(std::move(params)) }; } + else if constexpr (methods::AppointmentMethod::NoParamsWhen) + { + return { _pimpl->getWhen() }; + } else { throw std::runtime_error(R"ex(Appointment::getWhen is not implemented)ex"); @@ -134,10 +156,14 @@ class Appointment service::FieldResult> getSubject(service::FieldParams&& params) const final { - if constexpr (stub::AppointmentStubs::HasSubject) + if constexpr (methods::AppointmentMethod::WithParamsSubject) { return { _pimpl->getSubject(std::move(params)) }; } + else if constexpr (methods::AppointmentMethod::NoParamsSubject) + { + return { _pimpl->getSubject() }; + } else { throw std::runtime_error(R"ex(Appointment::getSubject is not implemented)ex"); @@ -146,10 +172,14 @@ class Appointment service::FieldResult getIsNow(service::FieldParams&& params) const final { - if constexpr (stub::AppointmentStubs::HasIsNow) + if constexpr (methods::AppointmentMethod::WithParamsIsNow) { return { _pimpl->getIsNow(std::move(params)) }; } + else if constexpr (methods::AppointmentMethod::NoParamsIsNow) + { + return { _pimpl->getIsNow() }; + } else { throw std::runtime_error(R"ex(Appointment::getIsNow is not implemented)ex"); @@ -158,16 +188,36 @@ class Appointment service::FieldResult> getForceError(service::FieldParams&& params) const final { - if constexpr (stub::AppointmentStubs::HasForceError) + if constexpr (methods::AppointmentMethod::WithParamsForceError) { return { _pimpl->getForceError(std::move(params)) }; } + else if constexpr (methods::AppointmentMethod::NoParamsForceError) + { + return { _pimpl->getForceError() }; + } else { throw std::runtime_error(R"ex(Appointment::getForceError is not implemented)ex"); } } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::AppointmentMethod::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::AppointmentMethod::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + private: const std::shared_ptr _pimpl; }; diff --git a/samples/separate_nointrospection/CompleteTaskPayloadObject.h b/samples/separate_nointrospection/CompleteTaskPayloadObject.h index c3ae3927..054b0c9a 100644 --- a/samples/separate_nointrospection/CompleteTaskPayloadObject.h +++ b/samples/separate_nointrospection/CompleteTaskPayloadObject.h @@ -11,20 +11,32 @@ #include "TodaySchema.h" namespace graphql::today::object { -namespace stub::CompleteTaskPayloadStubs { +namespace methods::CompleteTaskPayloadMethod { template -concept HasTask = requires (TImpl impl, service::FieldParams params) +concept WithParamsTask = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getTask(std::move(params)) } }; }; template -concept HasClientMutationId = requires (TImpl impl, service::FieldParams params) +concept NoParamsTask = requires (TImpl impl) +{ + { service::FieldResult> { impl.getTask() } }; +}; + +template +concept WithParamsClientMutationId = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getClientMutationId(std::move(params)) } }; }; +template +concept NoParamsClientMutationId = requires (TImpl impl) +{ + { service::FieldResult> { impl.getClientMutationId() } }; +}; + template concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { @@ -37,7 +49,7 @@ concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetPa { impl.endSelectionSet(params) }; }; -} // namespace stub::CompleteTaskPayloadStubs +} // namespace methods::CompleteTaskPayloadMethod class CompleteTaskPayload : public service::Object @@ -68,28 +80,16 @@ class CompleteTaskPayload { } - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::CompleteTaskPayloadStubs::HasBeginSelectionSet) - { - _pimpl->beginSelectionSet(params); - } - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::CompleteTaskPayloadStubs::HasEndSelectionSet) - { - _pimpl->endSelectionSet(params); - } - } - service::FieldResult> getTask(service::FieldParams&& params) const final { - if constexpr (stub::CompleteTaskPayloadStubs::HasTask) + if constexpr (methods::CompleteTaskPayloadMethod::WithParamsTask) { return { _pimpl->getTask(std::move(params)) }; } + else if constexpr (methods::CompleteTaskPayloadMethod::NoParamsTask) + { + return { _pimpl->getTask() }; + } else { throw std::runtime_error(R"ex(CompleteTaskPayload::getTask is not implemented)ex"); @@ -98,16 +98,36 @@ class CompleteTaskPayload service::FieldResult> getClientMutationId(service::FieldParams&& params) const final { - if constexpr (stub::CompleteTaskPayloadStubs::HasClientMutationId) + if constexpr (methods::CompleteTaskPayloadMethod::WithParamsClientMutationId) { return { _pimpl->getClientMutationId(std::move(params)) }; } + else if constexpr (methods::CompleteTaskPayloadMethod::NoParamsClientMutationId) + { + return { _pimpl->getClientMutationId() }; + } else { throw std::runtime_error(R"ex(CompleteTaskPayload::getClientMutationId is not implemented)ex"); } } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::CompleteTaskPayloadMethod::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::CompleteTaskPayloadMethod::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + private: const std::shared_ptr _pimpl; }; diff --git a/samples/separate_nointrospection/ExpensiveObject.h b/samples/separate_nointrospection/ExpensiveObject.h index 5a388c99..d34236b8 100644 --- a/samples/separate_nointrospection/ExpensiveObject.h +++ b/samples/separate_nointrospection/ExpensiveObject.h @@ -11,14 +11,20 @@ #include "TodaySchema.h" namespace graphql::today::object { -namespace stub::ExpensiveStubs { +namespace methods::ExpensiveMethod { template -concept HasOrder = requires (TImpl impl, service::FieldParams params) +concept WithParamsOrder = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getOrder(std::move(params)) } }; }; +template +concept NoParamsOrder = requires (TImpl impl) +{ + { service::FieldResult { impl.getOrder() } }; +}; + template concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { @@ -31,7 +37,7 @@ concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetPa { impl.endSelectionSet(params) }; }; -} // namespace stub::ExpensiveStubs +} // namespace methods::ExpensiveMethod class Expensive : public service::Object @@ -60,31 +66,35 @@ class Expensive { } - void beginSelectionSet(const service::SelectionSetParams& params) const final + service::FieldResult getOrder(service::FieldParams&& params) const final { - if constexpr (stub::ExpensiveStubs::HasBeginSelectionSet) + if constexpr (methods::ExpensiveMethod::WithParamsOrder) { - _pimpl->beginSelectionSet(params); + return { _pimpl->getOrder(std::move(params)) }; + } + else if constexpr (methods::ExpensiveMethod::NoParamsOrder) + { + return { _pimpl->getOrder() }; + } + else + { + throw std::runtime_error(R"ex(Expensive::getOrder is not implemented)ex"); } } - void endSelectionSet(const service::SelectionSetParams& params) const final + void beginSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (stub::ExpensiveStubs::HasEndSelectionSet) + if constexpr (methods::ExpensiveMethod::HasBeginSelectionSet) { - _pimpl->endSelectionSet(params); + _pimpl->beginSelectionSet(params); } } - service::FieldResult getOrder(service::FieldParams&& params) const final + void endSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (stub::ExpensiveStubs::HasOrder) + if constexpr (methods::ExpensiveMethod::HasEndSelectionSet) { - return { _pimpl->getOrder(std::move(params)) }; - } - else - { - throw std::runtime_error(R"ex(Expensive::getOrder is not implemented)ex"); + _pimpl->endSelectionSet(params); } } diff --git a/samples/separate_nointrospection/FolderConnectionObject.h b/samples/separate_nointrospection/FolderConnectionObject.h index ffa4a7f0..f1dc10b1 100644 --- a/samples/separate_nointrospection/FolderConnectionObject.h +++ b/samples/separate_nointrospection/FolderConnectionObject.h @@ -11,20 +11,32 @@ #include "TodaySchema.h" namespace graphql::today::object { -namespace stub::FolderConnectionStubs { +namespace methods::FolderConnectionMethod { template -concept HasPageInfo = requires (TImpl impl, service::FieldParams params) +concept WithParamsPageInfo = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getPageInfo(std::move(params)) } }; }; template -concept HasEdges = requires (TImpl impl, service::FieldParams params) +concept NoParamsPageInfo = requires (TImpl impl) +{ + { service::FieldResult> { impl.getPageInfo() } }; +}; + +template +concept WithParamsEdges = requires (TImpl impl, service::FieldParams params) { { service::FieldResult>>> { impl.getEdges(std::move(params)) } }; }; +template +concept NoParamsEdges = requires (TImpl impl) +{ + { service::FieldResult>>> { impl.getEdges() } }; +}; + template concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { @@ -37,7 +49,7 @@ concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetPa { impl.endSelectionSet(params) }; }; -} // namespace stub::FolderConnectionStubs +} // namespace methods::FolderConnectionMethod class FolderConnection : public service::Object @@ -68,28 +80,16 @@ class FolderConnection { } - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::FolderConnectionStubs::HasBeginSelectionSet) - { - _pimpl->beginSelectionSet(params); - } - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::FolderConnectionStubs::HasEndSelectionSet) - { - _pimpl->endSelectionSet(params); - } - } - service::FieldResult> getPageInfo(service::FieldParams&& params) const final { - if constexpr (stub::FolderConnectionStubs::HasPageInfo) + if constexpr (methods::FolderConnectionMethod::WithParamsPageInfo) { return { _pimpl->getPageInfo(std::move(params)) }; } + else if constexpr (methods::FolderConnectionMethod::NoParamsPageInfo) + { + return { _pimpl->getPageInfo() }; + } else { throw std::runtime_error(R"ex(FolderConnection::getPageInfo is not implemented)ex"); @@ -98,16 +98,36 @@ class FolderConnection service::FieldResult>>> getEdges(service::FieldParams&& params) const final { - if constexpr (stub::FolderConnectionStubs::HasEdges) + if constexpr (methods::FolderConnectionMethod::WithParamsEdges) { return { _pimpl->getEdges(std::move(params)) }; } + else if constexpr (methods::FolderConnectionMethod::NoParamsEdges) + { + return { _pimpl->getEdges() }; + } else { throw std::runtime_error(R"ex(FolderConnection::getEdges is not implemented)ex"); } } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::FolderConnectionMethod::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::FolderConnectionMethod::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + private: const std::shared_ptr _pimpl; }; diff --git a/samples/separate_nointrospection/FolderEdgeObject.h b/samples/separate_nointrospection/FolderEdgeObject.h index f030a84f..6fbd7499 100644 --- a/samples/separate_nointrospection/FolderEdgeObject.h +++ b/samples/separate_nointrospection/FolderEdgeObject.h @@ -11,20 +11,32 @@ #include "TodaySchema.h" namespace graphql::today::object { -namespace stub::FolderEdgeStubs { +namespace methods::FolderEdgeMethod { template -concept HasNode = requires (TImpl impl, service::FieldParams params) +concept WithParamsNode = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getNode(std::move(params)) } }; }; template -concept HasCursor = requires (TImpl impl, service::FieldParams params) +concept NoParamsNode = requires (TImpl impl) +{ + { service::FieldResult> { impl.getNode() } }; +}; + +template +concept WithParamsCursor = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getCursor(std::move(params)) } }; }; +template +concept NoParamsCursor = requires (TImpl impl) +{ + { service::FieldResult { impl.getCursor() } }; +}; + template concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { @@ -37,7 +49,7 @@ concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetPa { impl.endSelectionSet(params) }; }; -} // namespace stub::FolderEdgeStubs +} // namespace methods::FolderEdgeMethod class FolderEdge : public service::Object @@ -68,28 +80,16 @@ class FolderEdge { } - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::FolderEdgeStubs::HasBeginSelectionSet) - { - _pimpl->beginSelectionSet(params); - } - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::FolderEdgeStubs::HasEndSelectionSet) - { - _pimpl->endSelectionSet(params); - } - } - service::FieldResult> getNode(service::FieldParams&& params) const final { - if constexpr (stub::FolderEdgeStubs::HasNode) + if constexpr (methods::FolderEdgeMethod::WithParamsNode) { return { _pimpl->getNode(std::move(params)) }; } + else if constexpr (methods::FolderEdgeMethod::NoParamsNode) + { + return { _pimpl->getNode() }; + } else { throw std::runtime_error(R"ex(FolderEdge::getNode is not implemented)ex"); @@ -98,16 +98,36 @@ class FolderEdge service::FieldResult getCursor(service::FieldParams&& params) const final { - if constexpr (stub::FolderEdgeStubs::HasCursor) + if constexpr (methods::FolderEdgeMethod::WithParamsCursor) { return { _pimpl->getCursor(std::move(params)) }; } + else if constexpr (methods::FolderEdgeMethod::NoParamsCursor) + { + return { _pimpl->getCursor() }; + } else { throw std::runtime_error(R"ex(FolderEdge::getCursor is not implemented)ex"); } } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::FolderEdgeMethod::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::FolderEdgeMethod::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + private: const std::shared_ptr _pimpl; }; diff --git a/samples/separate_nointrospection/FolderObject.h b/samples/separate_nointrospection/FolderObject.h index 64c2882b..e96ba675 100644 --- a/samples/separate_nointrospection/FolderObject.h +++ b/samples/separate_nointrospection/FolderObject.h @@ -11,26 +11,44 @@ #include "TodaySchema.h" namespace graphql::today::object { -namespace stub::FolderStubs { +namespace methods::FolderMethod { template -concept HasId = requires (TImpl impl, service::FieldParams params) +concept WithParamsId = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getId(std::move(params)) } }; }; template -concept HasName = requires (TImpl impl, service::FieldParams params) +concept NoParamsId = requires (TImpl impl) +{ + { service::FieldResult { impl.getId() } }; +}; + +template +concept WithParamsName = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getName(std::move(params)) } }; }; template -concept HasUnreadCount = requires (TImpl impl, service::FieldParams params) +concept NoParamsName = requires (TImpl impl) +{ + { service::FieldResult> { impl.getName() } }; +}; + +template +concept WithParamsUnreadCount = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getUnreadCount(std::move(params)) } }; }; +template +concept NoParamsUnreadCount = requires (TImpl impl) +{ + { service::FieldResult { impl.getUnreadCount() } }; +}; + template concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { @@ -43,7 +61,7 @@ concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetPa { impl.endSelectionSet(params) }; }; -} // namespace stub::FolderStubs +} // namespace methods::FolderMethod class Folder : public service::Object @@ -76,28 +94,16 @@ class Folder { } - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::FolderStubs::HasBeginSelectionSet) - { - _pimpl->beginSelectionSet(params); - } - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::FolderStubs::HasEndSelectionSet) - { - _pimpl->endSelectionSet(params); - } - } - service::FieldResult getId(service::FieldParams&& params) const final { - if constexpr (stub::FolderStubs::HasId) + if constexpr (methods::FolderMethod::WithParamsId) { return { _pimpl->getId(std::move(params)) }; } + else if constexpr (methods::FolderMethod::NoParamsId) + { + return { _pimpl->getId() }; + } else { throw std::runtime_error(R"ex(Folder::getId is not implemented)ex"); @@ -106,10 +112,14 @@ class Folder service::FieldResult> getName(service::FieldParams&& params) const final { - if constexpr (stub::FolderStubs::HasName) + if constexpr (methods::FolderMethod::WithParamsName) { return { _pimpl->getName(std::move(params)) }; } + else if constexpr (methods::FolderMethod::NoParamsName) + { + return { _pimpl->getName() }; + } else { throw std::runtime_error(R"ex(Folder::getName is not implemented)ex"); @@ -118,16 +128,36 @@ class Folder service::FieldResult getUnreadCount(service::FieldParams&& params) const final { - if constexpr (stub::FolderStubs::HasUnreadCount) + if constexpr (methods::FolderMethod::WithParamsUnreadCount) { return { _pimpl->getUnreadCount(std::move(params)) }; } + else if constexpr (methods::FolderMethod::NoParamsUnreadCount) + { + return { _pimpl->getUnreadCount() }; + } else { throw std::runtime_error(R"ex(Folder::getUnreadCount is not implemented)ex"); } } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::FolderMethod::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::FolderMethod::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + private: const std::shared_ptr _pimpl; }; diff --git a/samples/separate_nointrospection/MutationObject.h b/samples/separate_nointrospection/MutationObject.h index f1ecd666..be61f359 100644 --- a/samples/separate_nointrospection/MutationObject.h +++ b/samples/separate_nointrospection/MutationObject.h @@ -11,20 +11,32 @@ #include "TodaySchema.h" namespace graphql::today::object { -namespace stub::MutationStubs { +namespace methods::MutationMethod { template -concept HasCompleteTask = requires (TImpl impl, service::FieldParams params, CompleteTaskInput inputArg) +concept WithParamsCompleteTask = requires (TImpl impl, service::FieldParams params, CompleteTaskInput inputArg) { { service::FieldResult> { impl.applyCompleteTask(std::move(params), std::move(inputArg)) } }; }; template -concept HasSetFloat = requires (TImpl impl, service::FieldParams params, response::FloatType valueArg) +concept NoParamsCompleteTask = requires (TImpl impl, CompleteTaskInput inputArg) +{ + { service::FieldResult> { impl.applyCompleteTask(std::move(inputArg)) } }; +}; + +template +concept WithParamsSetFloat = requires (TImpl impl, service::FieldParams params, response::FloatType valueArg) { { service::FieldResult { impl.applySetFloat(std::move(params), std::move(valueArg)) } }; }; +template +concept NoParamsSetFloat = requires (TImpl impl, response::FloatType valueArg) +{ + { service::FieldResult { impl.applySetFloat(std::move(valueArg)) } }; +}; + template concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { @@ -37,7 +49,7 @@ concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetPa { impl.endSelectionSet(params) }; }; -} // namespace stub::MutationStubs +} // namespace methods::MutationMethod class Mutation : public service::Object @@ -68,28 +80,16 @@ class Mutation { } - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::MutationStubs::HasBeginSelectionSet) - { - _pimpl->beginSelectionSet(params); - } - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::MutationStubs::HasEndSelectionSet) - { - _pimpl->endSelectionSet(params); - } - } - service::FieldResult> applyCompleteTask(service::FieldParams&& params, CompleteTaskInput&& inputArg) const final { - if constexpr (stub::MutationStubs::HasCompleteTask) + if constexpr (methods::MutationMethod::WithParamsCompleteTask) { return { _pimpl->applyCompleteTask(std::move(params), std::move(inputArg)) }; } + else if constexpr (methods::MutationMethod::NoParamsCompleteTask) + { + return { _pimpl->applyCompleteTask(std::move(inputArg)) }; + } else { throw std::runtime_error(R"ex(Mutation::applyCompleteTask is not implemented)ex"); @@ -98,16 +98,36 @@ class Mutation service::FieldResult applySetFloat(service::FieldParams&& params, response::FloatType&& valueArg) const final { - if constexpr (stub::MutationStubs::HasSetFloat) + if constexpr (methods::MutationMethod::WithParamsSetFloat) { return { _pimpl->applySetFloat(std::move(params), std::move(valueArg)) }; } + else if constexpr (methods::MutationMethod::NoParamsSetFloat) + { + return { _pimpl->applySetFloat(std::move(valueArg)) }; + } else { throw std::runtime_error(R"ex(Mutation::applySetFloat is not implemented)ex"); } } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::MutationMethod::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::MutationMethod::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + private: const std::shared_ptr _pimpl; }; diff --git a/samples/separate_nointrospection/NestedTypeObject.h b/samples/separate_nointrospection/NestedTypeObject.h index ce9f276e..d4f2551f 100644 --- a/samples/separate_nointrospection/NestedTypeObject.h +++ b/samples/separate_nointrospection/NestedTypeObject.h @@ -11,20 +11,32 @@ #include "TodaySchema.h" namespace graphql::today::object { -namespace stub::NestedTypeStubs { +namespace methods::NestedTypeMethod { template -concept HasDepth = requires (TImpl impl, service::FieldParams params) +concept WithParamsDepth = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getDepth(std::move(params)) } }; }; template -concept HasNested = requires (TImpl impl, service::FieldParams params) +concept NoParamsDepth = requires (TImpl impl) +{ + { service::FieldResult { impl.getDepth() } }; +}; + +template +concept WithParamsNested = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getNested(std::move(params)) } }; }; +template +concept NoParamsNested = requires (TImpl impl) +{ + { service::FieldResult> { impl.getNested() } }; +}; + template concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { @@ -37,7 +49,7 @@ concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetPa { impl.endSelectionSet(params) }; }; -} // namespace stub::NestedTypeStubs +} // namespace methods::NestedTypeMethod class NestedType : public service::Object @@ -68,28 +80,16 @@ class NestedType { } - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::NestedTypeStubs::HasBeginSelectionSet) - { - _pimpl->beginSelectionSet(params); - } - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::NestedTypeStubs::HasEndSelectionSet) - { - _pimpl->endSelectionSet(params); - } - } - service::FieldResult getDepth(service::FieldParams&& params) const final { - if constexpr (stub::NestedTypeStubs::HasDepth) + if constexpr (methods::NestedTypeMethod::WithParamsDepth) { return { _pimpl->getDepth(std::move(params)) }; } + else if constexpr (methods::NestedTypeMethod::NoParamsDepth) + { + return { _pimpl->getDepth() }; + } else { throw std::runtime_error(R"ex(NestedType::getDepth is not implemented)ex"); @@ -98,16 +98,36 @@ class NestedType service::FieldResult> getNested(service::FieldParams&& params) const final { - if constexpr (stub::NestedTypeStubs::HasNested) + if constexpr (methods::NestedTypeMethod::WithParamsNested) { return { _pimpl->getNested(std::move(params)) }; } + else if constexpr (methods::NestedTypeMethod::NoParamsNested) + { + return { _pimpl->getNested() }; + } else { throw std::runtime_error(R"ex(NestedType::getNested is not implemented)ex"); } } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::NestedTypeMethod::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::NestedTypeMethod::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + private: const std::shared_ptr _pimpl; }; diff --git a/samples/separate_nointrospection/PageInfoObject.h b/samples/separate_nointrospection/PageInfoObject.h index 675ff995..cf4a8158 100644 --- a/samples/separate_nointrospection/PageInfoObject.h +++ b/samples/separate_nointrospection/PageInfoObject.h @@ -11,20 +11,32 @@ #include "TodaySchema.h" namespace graphql::today::object { -namespace stub::PageInfoStubs { +namespace methods::PageInfoMethod { template -concept HasHasNextPage = requires (TImpl impl, service::FieldParams params) +concept WithParamsHasNextPage = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getHasNextPage(std::move(params)) } }; }; template -concept HasHasPreviousPage = requires (TImpl impl, service::FieldParams params) +concept NoParamsHasNextPage = requires (TImpl impl) +{ + { service::FieldResult { impl.getHasNextPage() } }; +}; + +template +concept WithParamsHasPreviousPage = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getHasPreviousPage(std::move(params)) } }; }; +template +concept NoParamsHasPreviousPage = requires (TImpl impl) +{ + { service::FieldResult { impl.getHasPreviousPage() } }; +}; + template concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { @@ -37,7 +49,7 @@ concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetPa { impl.endSelectionSet(params) }; }; -} // namespace stub::PageInfoStubs +} // namespace methods::PageInfoMethod class PageInfo : public service::Object @@ -68,28 +80,16 @@ class PageInfo { } - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::PageInfoStubs::HasBeginSelectionSet) - { - _pimpl->beginSelectionSet(params); - } - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::PageInfoStubs::HasEndSelectionSet) - { - _pimpl->endSelectionSet(params); - } - } - service::FieldResult getHasNextPage(service::FieldParams&& params) const final { - if constexpr (stub::PageInfoStubs::HasHasNextPage) + if constexpr (methods::PageInfoMethod::WithParamsHasNextPage) { return { _pimpl->getHasNextPage(std::move(params)) }; } + else if constexpr (methods::PageInfoMethod::NoParamsHasNextPage) + { + return { _pimpl->getHasNextPage() }; + } else { throw std::runtime_error(R"ex(PageInfo::getHasNextPage is not implemented)ex"); @@ -98,16 +98,36 @@ class PageInfo service::FieldResult getHasPreviousPage(service::FieldParams&& params) const final { - if constexpr (stub::PageInfoStubs::HasHasPreviousPage) + if constexpr (methods::PageInfoMethod::WithParamsHasPreviousPage) { return { _pimpl->getHasPreviousPage(std::move(params)) }; } + else if constexpr (methods::PageInfoMethod::NoParamsHasPreviousPage) + { + return { _pimpl->getHasPreviousPage() }; + } else { throw std::runtime_error(R"ex(PageInfo::getHasPreviousPage is not implemented)ex"); } } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::PageInfoMethod::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::PageInfoMethod::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + private: const std::shared_ptr _pimpl; }; diff --git a/samples/separate_nointrospection/QueryObject.h b/samples/separate_nointrospection/QueryObject.h index d703e0c0..b1a867fa 100644 --- a/samples/separate_nointrospection/QueryObject.h +++ b/samples/separate_nointrospection/QueryObject.h @@ -11,80 +11,152 @@ #include "TodaySchema.h" namespace graphql::today::object { -namespace stub::QueryStubs { +namespace methods::QueryMethod { template -concept HasNode = requires (TImpl impl, service::FieldParams params, response::IdType idArg) +concept WithParamsNode = requires (TImpl impl, service::FieldParams params, response::IdType idArg) { { service::FieldResult> { impl.getNode(std::move(params), std::move(idArg)) } }; }; template -concept HasAppointments = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) +concept NoParamsNode = requires (TImpl impl, response::IdType idArg) +{ + { service::FieldResult> { impl.getNode(std::move(idArg)) } }; +}; + +template +concept WithParamsAppointments = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) { { service::FieldResult> { impl.getAppointments(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; }; template -concept HasTasks = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) +concept NoParamsAppointments = requires (TImpl impl, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) +{ + { service::FieldResult> { impl.getAppointments(std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; +}; + +template +concept WithParamsTasks = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) { { service::FieldResult> { impl.getTasks(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; }; template -concept HasUnreadCounts = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) +concept NoParamsTasks = requires (TImpl impl, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) +{ + { service::FieldResult> { impl.getTasks(std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; +}; + +template +concept WithParamsUnreadCounts = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) { { service::FieldResult> { impl.getUnreadCounts(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; }; template -concept HasAppointmentsById = requires (TImpl impl, service::FieldParams params, std::vector idsArg) +concept NoParamsUnreadCounts = requires (TImpl impl, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) +{ + { service::FieldResult> { impl.getUnreadCounts(std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; +}; + +template +concept WithParamsAppointmentsById = requires (TImpl impl, service::FieldParams params, std::vector idsArg) { { service::FieldResult>> { impl.getAppointmentsById(std::move(params), std::move(idsArg)) } }; }; template -concept HasTasksById = requires (TImpl impl, service::FieldParams params, std::vector idsArg) +concept NoParamsAppointmentsById = requires (TImpl impl, std::vector idsArg) +{ + { service::FieldResult>> { impl.getAppointmentsById(std::move(idsArg)) } }; +}; + +template +concept WithParamsTasksById = requires (TImpl impl, service::FieldParams params, std::vector idsArg) { { service::FieldResult>> { impl.getTasksById(std::move(params), std::move(idsArg)) } }; }; template -concept HasUnreadCountsById = requires (TImpl impl, service::FieldParams params, std::vector idsArg) +concept NoParamsTasksById = requires (TImpl impl, std::vector idsArg) +{ + { service::FieldResult>> { impl.getTasksById(std::move(idsArg)) } }; +}; + +template +concept WithParamsUnreadCountsById = requires (TImpl impl, service::FieldParams params, std::vector idsArg) { { service::FieldResult>> { impl.getUnreadCountsById(std::move(params), std::move(idsArg)) } }; }; template -concept HasNested = requires (TImpl impl, service::FieldParams params) +concept NoParamsUnreadCountsById = requires (TImpl impl, std::vector idsArg) +{ + { service::FieldResult>> { impl.getUnreadCountsById(std::move(idsArg)) } }; +}; + +template +concept WithParamsNested = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getNested(std::move(params)) } }; }; template -concept HasUnimplemented = requires (TImpl impl, service::FieldParams params) +concept NoParamsNested = requires (TImpl impl) +{ + { service::FieldResult> { impl.getNested() } }; +}; + +template +concept WithParamsUnimplemented = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getUnimplemented(std::move(params)) } }; }; template -concept HasExpensive = requires (TImpl impl, service::FieldParams params) +concept NoParamsUnimplemented = requires (TImpl impl) +{ + { service::FieldResult { impl.getUnimplemented() } }; +}; + +template +concept WithParamsExpensive = requires (TImpl impl, service::FieldParams params) { { service::FieldResult>> { impl.getExpensive(std::move(params)) } }; }; template -concept HasTestTaskState = requires (TImpl impl, service::FieldParams params) +concept NoParamsExpensive = requires (TImpl impl) +{ + { service::FieldResult>> { impl.getExpensive() } }; +}; + +template +concept WithParamsTestTaskState = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getTestTaskState(std::move(params)) } }; }; template -concept HasAnyType = requires (TImpl impl, service::FieldParams params, std::vector idsArg) +concept NoParamsTestTaskState = requires (TImpl impl) +{ + { service::FieldResult { impl.getTestTaskState() } }; +}; + +template +concept WithParamsAnyType = requires (TImpl impl, service::FieldParams params, std::vector idsArg) { { service::FieldResult>> { impl.getAnyType(std::move(params), std::move(idsArg)) } }; }; +template +concept NoParamsAnyType = requires (TImpl impl, std::vector idsArg) +{ + { service::FieldResult>> { impl.getAnyType(std::move(idsArg)) } }; +}; + template concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { @@ -97,7 +169,7 @@ concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetPa { impl.endSelectionSet(params) }; }; -} // namespace stub::QueryStubs +} // namespace methods::QueryMethod class Query : public service::Object @@ -148,28 +220,16 @@ class Query { } - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::QueryStubs::HasBeginSelectionSet) - { - _pimpl->beginSelectionSet(params); - } - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::QueryStubs::HasEndSelectionSet) - { - _pimpl->endSelectionSet(params); - } - } - service::FieldResult> getNode(service::FieldParams&& params, response::IdType&& idArg) const final { - if constexpr (stub::QueryStubs::HasNode) + if constexpr (methods::QueryMethod::WithParamsNode) { return { _pimpl->getNode(std::move(params), std::move(idArg)) }; } + else if constexpr (methods::QueryMethod::NoParamsNode) + { + return { _pimpl->getNode(std::move(idArg)) }; + } else { throw std::runtime_error(R"ex(Query::getNode is not implemented)ex"); @@ -178,10 +238,14 @@ class Query service::FieldResult> getAppointments(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const final { - if constexpr (stub::QueryStubs::HasAppointments) + if constexpr (methods::QueryMethod::WithParamsAppointments) { return { _pimpl->getAppointments(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) }; } + else if constexpr (methods::QueryMethod::NoParamsAppointments) + { + return { _pimpl->getAppointments(std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) }; + } else { throw std::runtime_error(R"ex(Query::getAppointments is not implemented)ex"); @@ -190,10 +254,14 @@ class Query service::FieldResult> getTasks(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const final { - if constexpr (stub::QueryStubs::HasTasks) + if constexpr (methods::QueryMethod::WithParamsTasks) { return { _pimpl->getTasks(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) }; } + else if constexpr (methods::QueryMethod::NoParamsTasks) + { + return { _pimpl->getTasks(std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) }; + } else { throw std::runtime_error(R"ex(Query::getTasks is not implemented)ex"); @@ -202,10 +270,14 @@ class Query service::FieldResult> getUnreadCounts(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const final { - if constexpr (stub::QueryStubs::HasUnreadCounts) + if constexpr (methods::QueryMethod::WithParamsUnreadCounts) { return { _pimpl->getUnreadCounts(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) }; } + else if constexpr (methods::QueryMethod::NoParamsUnreadCounts) + { + return { _pimpl->getUnreadCounts(std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) }; + } else { throw std::runtime_error(R"ex(Query::getUnreadCounts is not implemented)ex"); @@ -214,10 +286,14 @@ class Query service::FieldResult>> getAppointmentsById(service::FieldParams&& params, std::vector&& idsArg) const final { - if constexpr (stub::QueryStubs::HasAppointmentsById) + if constexpr (methods::QueryMethod::WithParamsAppointmentsById) { return { _pimpl->getAppointmentsById(std::move(params), std::move(idsArg)) }; } + else if constexpr (methods::QueryMethod::NoParamsAppointmentsById) + { + return { _pimpl->getAppointmentsById(std::move(idsArg)) }; + } else { throw std::runtime_error(R"ex(Query::getAppointmentsById is not implemented)ex"); @@ -226,10 +302,14 @@ class Query service::FieldResult>> getTasksById(service::FieldParams&& params, std::vector&& idsArg) const final { - if constexpr (stub::QueryStubs::HasTasksById) + if constexpr (methods::QueryMethod::WithParamsTasksById) { return { _pimpl->getTasksById(std::move(params), std::move(idsArg)) }; } + else if constexpr (methods::QueryMethod::NoParamsTasksById) + { + return { _pimpl->getTasksById(std::move(idsArg)) }; + } else { throw std::runtime_error(R"ex(Query::getTasksById is not implemented)ex"); @@ -238,10 +318,14 @@ class Query service::FieldResult>> getUnreadCountsById(service::FieldParams&& params, std::vector&& idsArg) const final { - if constexpr (stub::QueryStubs::HasUnreadCountsById) + if constexpr (methods::QueryMethod::WithParamsUnreadCountsById) { return { _pimpl->getUnreadCountsById(std::move(params), std::move(idsArg)) }; } + else if constexpr (methods::QueryMethod::NoParamsUnreadCountsById) + { + return { _pimpl->getUnreadCountsById(std::move(idsArg)) }; + } else { throw std::runtime_error(R"ex(Query::getUnreadCountsById is not implemented)ex"); @@ -250,10 +334,14 @@ class Query service::FieldResult> getNested(service::FieldParams&& params) const final { - if constexpr (stub::QueryStubs::HasNested) + if constexpr (methods::QueryMethod::WithParamsNested) { return { _pimpl->getNested(std::move(params)) }; } + else if constexpr (methods::QueryMethod::NoParamsNested) + { + return { _pimpl->getNested() }; + } else { throw std::runtime_error(R"ex(Query::getNested is not implemented)ex"); @@ -262,10 +350,14 @@ class Query service::FieldResult getUnimplemented(service::FieldParams&& params) const final { - if constexpr (stub::QueryStubs::HasUnimplemented) + if constexpr (methods::QueryMethod::WithParamsUnimplemented) { return { _pimpl->getUnimplemented(std::move(params)) }; } + else if constexpr (methods::QueryMethod::NoParamsUnimplemented) + { + return { _pimpl->getUnimplemented() }; + } else { throw std::runtime_error(R"ex(Query::getUnimplemented is not implemented)ex"); @@ -274,10 +366,14 @@ class Query service::FieldResult>> getExpensive(service::FieldParams&& params) const final { - if constexpr (stub::QueryStubs::HasExpensive) + if constexpr (methods::QueryMethod::WithParamsExpensive) { return { _pimpl->getExpensive(std::move(params)) }; } + else if constexpr (methods::QueryMethod::NoParamsExpensive) + { + return { _pimpl->getExpensive() }; + } else { throw std::runtime_error(R"ex(Query::getExpensive is not implemented)ex"); @@ -286,10 +382,14 @@ class Query service::FieldResult getTestTaskState(service::FieldParams&& params) const final { - if constexpr (stub::QueryStubs::HasTestTaskState) + if constexpr (methods::QueryMethod::WithParamsTestTaskState) { return { _pimpl->getTestTaskState(std::move(params)) }; } + else if constexpr (methods::QueryMethod::NoParamsTestTaskState) + { + return { _pimpl->getTestTaskState() }; + } else { throw std::runtime_error(R"ex(Query::getTestTaskState is not implemented)ex"); @@ -298,16 +398,36 @@ class Query service::FieldResult>> getAnyType(service::FieldParams&& params, std::vector&& idsArg) const final { - if constexpr (stub::QueryStubs::HasAnyType) + if constexpr (methods::QueryMethod::WithParamsAnyType) { return { _pimpl->getAnyType(std::move(params), std::move(idsArg)) }; } + else if constexpr (methods::QueryMethod::NoParamsAnyType) + { + return { _pimpl->getAnyType(std::move(idsArg)) }; + } else { throw std::runtime_error(R"ex(Query::getAnyType is not implemented)ex"); } } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::QueryMethod::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::QueryMethod::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + private: const std::shared_ptr _pimpl; }; diff --git a/samples/separate_nointrospection/SubscriptionObject.h b/samples/separate_nointrospection/SubscriptionObject.h index 252ac8b8..21db5c1b 100644 --- a/samples/separate_nointrospection/SubscriptionObject.h +++ b/samples/separate_nointrospection/SubscriptionObject.h @@ -11,20 +11,32 @@ #include "TodaySchema.h" namespace graphql::today::object { -namespace stub::SubscriptionStubs { +namespace methods::SubscriptionMethod { template -concept HasNextAppointmentChange = requires (TImpl impl, service::FieldParams params) +concept WithParamsNextAppointmentChange = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getNextAppointmentChange(std::move(params)) } }; }; template -concept HasNodeChange = requires (TImpl impl, service::FieldParams params, response::IdType idArg) +concept NoParamsNextAppointmentChange = requires (TImpl impl) +{ + { service::FieldResult> { impl.getNextAppointmentChange() } }; +}; + +template +concept WithParamsNodeChange = requires (TImpl impl, service::FieldParams params, response::IdType idArg) { { service::FieldResult> { impl.getNodeChange(std::move(params), std::move(idArg)) } }; }; +template +concept NoParamsNodeChange = requires (TImpl impl, response::IdType idArg) +{ + { service::FieldResult> { impl.getNodeChange(std::move(idArg)) } }; +}; + template concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { @@ -37,7 +49,7 @@ concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetPa { impl.endSelectionSet(params) }; }; -} // namespace stub::SubscriptionStubs +} // namespace methods::SubscriptionMethod class Subscription : public service::Object @@ -68,28 +80,16 @@ class Subscription { } - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::SubscriptionStubs::HasBeginSelectionSet) - { - _pimpl->beginSelectionSet(params); - } - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::SubscriptionStubs::HasEndSelectionSet) - { - _pimpl->endSelectionSet(params); - } - } - service::FieldResult> getNextAppointmentChange(service::FieldParams&& params) const final { - if constexpr (stub::SubscriptionStubs::HasNextAppointmentChange) + if constexpr (methods::SubscriptionMethod::WithParamsNextAppointmentChange) { return { _pimpl->getNextAppointmentChange(std::move(params)) }; } + else if constexpr (methods::SubscriptionMethod::NoParamsNextAppointmentChange) + { + return { _pimpl->getNextAppointmentChange() }; + } else { throw std::runtime_error(R"ex(Subscription::getNextAppointmentChange is not implemented)ex"); @@ -98,16 +98,36 @@ class Subscription service::FieldResult> getNodeChange(service::FieldParams&& params, response::IdType&& idArg) const final { - if constexpr (stub::SubscriptionStubs::HasNodeChange) + if constexpr (methods::SubscriptionMethod::WithParamsNodeChange) { return { _pimpl->getNodeChange(std::move(params), std::move(idArg)) }; } + else if constexpr (methods::SubscriptionMethod::NoParamsNodeChange) + { + return { _pimpl->getNodeChange(std::move(idArg)) }; + } else { throw std::runtime_error(R"ex(Subscription::getNodeChange is not implemented)ex"); } } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::SubscriptionMethod::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::SubscriptionMethod::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + private: const std::shared_ptr _pimpl; }; diff --git a/samples/separate_nointrospection/TaskConnectionObject.h b/samples/separate_nointrospection/TaskConnectionObject.h index dd2ca872..362183f2 100644 --- a/samples/separate_nointrospection/TaskConnectionObject.h +++ b/samples/separate_nointrospection/TaskConnectionObject.h @@ -11,20 +11,32 @@ #include "TodaySchema.h" namespace graphql::today::object { -namespace stub::TaskConnectionStubs { +namespace methods::TaskConnectionMethod { template -concept HasPageInfo = requires (TImpl impl, service::FieldParams params) +concept WithParamsPageInfo = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getPageInfo(std::move(params)) } }; }; template -concept HasEdges = requires (TImpl impl, service::FieldParams params) +concept NoParamsPageInfo = requires (TImpl impl) +{ + { service::FieldResult> { impl.getPageInfo() } }; +}; + +template +concept WithParamsEdges = requires (TImpl impl, service::FieldParams params) { { service::FieldResult>>> { impl.getEdges(std::move(params)) } }; }; +template +concept NoParamsEdges = requires (TImpl impl) +{ + { service::FieldResult>>> { impl.getEdges() } }; +}; + template concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { @@ -37,7 +49,7 @@ concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetPa { impl.endSelectionSet(params) }; }; -} // namespace stub::TaskConnectionStubs +} // namespace methods::TaskConnectionMethod class TaskConnection : public service::Object @@ -68,28 +80,16 @@ class TaskConnection { } - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::TaskConnectionStubs::HasBeginSelectionSet) - { - _pimpl->beginSelectionSet(params); - } - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::TaskConnectionStubs::HasEndSelectionSet) - { - _pimpl->endSelectionSet(params); - } - } - service::FieldResult> getPageInfo(service::FieldParams&& params) const final { - if constexpr (stub::TaskConnectionStubs::HasPageInfo) + if constexpr (methods::TaskConnectionMethod::WithParamsPageInfo) { return { _pimpl->getPageInfo(std::move(params)) }; } + else if constexpr (methods::TaskConnectionMethod::NoParamsPageInfo) + { + return { _pimpl->getPageInfo() }; + } else { throw std::runtime_error(R"ex(TaskConnection::getPageInfo is not implemented)ex"); @@ -98,16 +98,36 @@ class TaskConnection service::FieldResult>>> getEdges(service::FieldParams&& params) const final { - if constexpr (stub::TaskConnectionStubs::HasEdges) + if constexpr (methods::TaskConnectionMethod::WithParamsEdges) { return { _pimpl->getEdges(std::move(params)) }; } + else if constexpr (methods::TaskConnectionMethod::NoParamsEdges) + { + return { _pimpl->getEdges() }; + } else { throw std::runtime_error(R"ex(TaskConnection::getEdges is not implemented)ex"); } } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::TaskConnectionMethod::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::TaskConnectionMethod::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + private: const std::shared_ptr _pimpl; }; diff --git a/samples/separate_nointrospection/TaskEdgeObject.h b/samples/separate_nointrospection/TaskEdgeObject.h index b763ff84..45d77ab9 100644 --- a/samples/separate_nointrospection/TaskEdgeObject.h +++ b/samples/separate_nointrospection/TaskEdgeObject.h @@ -11,20 +11,32 @@ #include "TodaySchema.h" namespace graphql::today::object { -namespace stub::TaskEdgeStubs { +namespace methods::TaskEdgeMethod { template -concept HasNode = requires (TImpl impl, service::FieldParams params) +concept WithParamsNode = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getNode(std::move(params)) } }; }; template -concept HasCursor = requires (TImpl impl, service::FieldParams params) +concept NoParamsNode = requires (TImpl impl) +{ + { service::FieldResult> { impl.getNode() } }; +}; + +template +concept WithParamsCursor = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getCursor(std::move(params)) } }; }; +template +concept NoParamsCursor = requires (TImpl impl) +{ + { service::FieldResult { impl.getCursor() } }; +}; + template concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { @@ -37,7 +49,7 @@ concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetPa { impl.endSelectionSet(params) }; }; -} // namespace stub::TaskEdgeStubs +} // namespace methods::TaskEdgeMethod class TaskEdge : public service::Object @@ -68,28 +80,16 @@ class TaskEdge { } - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::TaskEdgeStubs::HasBeginSelectionSet) - { - _pimpl->beginSelectionSet(params); - } - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::TaskEdgeStubs::HasEndSelectionSet) - { - _pimpl->endSelectionSet(params); - } - } - service::FieldResult> getNode(service::FieldParams&& params) const final { - if constexpr (stub::TaskEdgeStubs::HasNode) + if constexpr (methods::TaskEdgeMethod::WithParamsNode) { return { _pimpl->getNode(std::move(params)) }; } + else if constexpr (methods::TaskEdgeMethod::NoParamsNode) + { + return { _pimpl->getNode() }; + } else { throw std::runtime_error(R"ex(TaskEdge::getNode is not implemented)ex"); @@ -98,16 +98,36 @@ class TaskEdge service::FieldResult getCursor(service::FieldParams&& params) const final { - if constexpr (stub::TaskEdgeStubs::HasCursor) + if constexpr (methods::TaskEdgeMethod::WithParamsCursor) { return { _pimpl->getCursor(std::move(params)) }; } + else if constexpr (methods::TaskEdgeMethod::NoParamsCursor) + { + return { _pimpl->getCursor() }; + } else { throw std::runtime_error(R"ex(TaskEdge::getCursor is not implemented)ex"); } } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::TaskEdgeMethod::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::TaskEdgeMethod::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + private: const std::shared_ptr _pimpl; }; diff --git a/samples/separate_nointrospection/TaskObject.h b/samples/separate_nointrospection/TaskObject.h index c2f77d57..780d9d63 100644 --- a/samples/separate_nointrospection/TaskObject.h +++ b/samples/separate_nointrospection/TaskObject.h @@ -11,26 +11,44 @@ #include "TodaySchema.h" namespace graphql::today::object { -namespace stub::TaskStubs { +namespace methods::TaskMethod { template -concept HasId = requires (TImpl impl, service::FieldParams params) +concept WithParamsId = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getId(std::move(params)) } }; }; template -concept HasTitle = requires (TImpl impl, service::FieldParams params) +concept NoParamsId = requires (TImpl impl) +{ + { service::FieldResult { impl.getId() } }; +}; + +template +concept WithParamsTitle = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getTitle(std::move(params)) } }; }; template -concept HasIsComplete = requires (TImpl impl, service::FieldParams params) +concept NoParamsTitle = requires (TImpl impl) +{ + { service::FieldResult> { impl.getTitle() } }; +}; + +template +concept WithParamsIsComplete = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getIsComplete(std::move(params)) } }; }; +template +concept NoParamsIsComplete = requires (TImpl impl) +{ + { service::FieldResult { impl.getIsComplete() } }; +}; + template concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { @@ -43,7 +61,7 @@ concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetPa { impl.endSelectionSet(params) }; }; -} // namespace stub::TaskStubs +} // namespace methods::TaskMethod class Task : public service::Object @@ -76,28 +94,16 @@ class Task { } - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::TaskStubs::HasBeginSelectionSet) - { - _pimpl->beginSelectionSet(params); - } - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::TaskStubs::HasEndSelectionSet) - { - _pimpl->endSelectionSet(params); - } - } - service::FieldResult getId(service::FieldParams&& params) const final { - if constexpr (stub::TaskStubs::HasId) + if constexpr (methods::TaskMethod::WithParamsId) { return { _pimpl->getId(std::move(params)) }; } + else if constexpr (methods::TaskMethod::NoParamsId) + { + return { _pimpl->getId() }; + } else { throw std::runtime_error(R"ex(Task::getId is not implemented)ex"); @@ -106,10 +112,14 @@ class Task service::FieldResult> getTitle(service::FieldParams&& params) const final { - if constexpr (stub::TaskStubs::HasTitle) + if constexpr (methods::TaskMethod::WithParamsTitle) { return { _pimpl->getTitle(std::move(params)) }; } + else if constexpr (methods::TaskMethod::NoParamsTitle) + { + return { _pimpl->getTitle() }; + } else { throw std::runtime_error(R"ex(Task::getTitle is not implemented)ex"); @@ -118,16 +128,36 @@ class Task service::FieldResult getIsComplete(service::FieldParams&& params) const final { - if constexpr (stub::TaskStubs::HasIsComplete) + if constexpr (methods::TaskMethod::WithParamsIsComplete) { return { _pimpl->getIsComplete(std::move(params)) }; } + else if constexpr (methods::TaskMethod::NoParamsIsComplete) + { + return { _pimpl->getIsComplete() }; + } else { throw std::runtime_error(R"ex(Task::getIsComplete is not implemented)ex"); } } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::TaskMethod::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::TaskMethod::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + private: const std::shared_ptr _pimpl; }; diff --git a/samples/star_wars/DroidData.cpp b/samples/star_wars/DroidData.cpp index 1cff1c94..4e8fcb98 100644 --- a/samples/star_wars/DroidData.cpp +++ b/samples/star_wars/DroidData.cpp @@ -40,18 +40,17 @@ void Droid::addFriends( }); } -response::StringType Droid::getId(service::FieldParams&& params) const noexcept +response::StringType Droid::getId() const noexcept { return id_; } -std::optional Droid::getName(service::FieldParams&& params) const noexcept +std::optional Droid::getName() const noexcept { return name_; } -std::optional>> Droid::getFriends( - service::FieldParams&& params) const noexcept +std::optional>> Droid::getFriends() const noexcept { std::vector> result(friends_.size()); @@ -86,8 +85,7 @@ std::optional>> Droid::getFriends( return result.empty() ? std::nullopt : std::make_optional(std::move(result)); } -std::optional>> Droid::getAppearsIn( - service::FieldParams&& params) const noexcept +std::optional>> Droid::getAppearsIn() const noexcept { std::vector> result(appearsIn_.size()); @@ -101,8 +99,7 @@ std::optional>> Droid::getAppearsIn( return result.empty() ? std::nullopt : std::make_optional(std::move(result)); } -std::optional Droid::getPrimaryFunction( - service::FieldParams&& params) const noexcept +std::optional Droid::getPrimaryFunction() const noexcept { return primaryFunction_; } diff --git a/samples/star_wars/DroidData.h b/samples/star_wars/DroidData.h index 89024fdc..525887b9 100644 --- a/samples/star_wars/DroidData.h +++ b/samples/star_wars/DroidData.h @@ -24,14 +24,11 @@ class Droid const response::StringType& id() const noexcept; void addFriends(std::vector friends) noexcept; - response::StringType getId(service::FieldParams&& params) const noexcept; - std::optional getName(service::FieldParams&& params) const noexcept; - std::optional>> getFriends( - service::FieldParams&& params) const noexcept; - std::optional>> getAppearsIn( - service::FieldParams&& params) const noexcept; - std::optional getPrimaryFunction( - service::FieldParams&& params) const noexcept; + response::StringType getId() const noexcept; + std::optional getName() const noexcept; + std::optional>> getFriends() const noexcept; + std::optional>> getAppearsIn() const noexcept; + std::optional getPrimaryFunction() const noexcept; private: const response::StringType id_; diff --git a/samples/star_wars/HumanData.cpp b/samples/star_wars/HumanData.cpp index 01866231..c145ad56 100644 --- a/samples/star_wars/HumanData.cpp +++ b/samples/star_wars/HumanData.cpp @@ -39,18 +39,17 @@ void Human::addFriends(std::vector friends) noexcept }); } -response::StringType Human::getId(service::FieldParams&& params) const noexcept +response::StringType Human::getId() const noexcept { return id_; } -std::optional Human::getName(service::FieldParams&& params) const noexcept +std::optional Human::getName() const noexcept { return name_; } -std::optional>> Human::getFriends( - service::FieldParams&& params) const noexcept +std::optional>> Human::getFriends() const noexcept { std::vector> result(friends_.size()); @@ -85,8 +84,7 @@ std::optional>> Human::getFriends( return result.empty() ? std::nullopt : std::make_optional(std::move(result)); } -std::optional>> Human::getAppearsIn( - service::FieldParams&& params) const noexcept +std::optional>> Human::getAppearsIn() const noexcept { std::vector> result(appearsIn_.size()); @@ -100,8 +98,7 @@ std::optional>> Human::getAppearsIn( return result.empty() ? std::nullopt : std::make_optional(std::move(result)); } -std::optional Human::getHomePlanet( - service::FieldParams&& params) const noexcept +std::optional Human::getHomePlanet() const noexcept { return homePlanet_; } diff --git a/samples/star_wars/HumanData.h b/samples/star_wars/HumanData.h index bf6b99ad..7dff6ebf 100644 --- a/samples/star_wars/HumanData.h +++ b/samples/star_wars/HumanData.h @@ -21,13 +21,11 @@ class Human const response::StringType& id() const noexcept; void addFriends(std::vector friends) noexcept; - response::StringType getId(service::FieldParams&& params) const noexcept; - std::optional getName(service::FieldParams&& params) const noexcept; - std::optional>> getFriends( - service::FieldParams&& params) const noexcept; - std::optional>> getAppearsIn( - service::FieldParams&& params) const noexcept; - std::optional getHomePlanet(service::FieldParams&& params) const noexcept; + response::StringType getId() const noexcept; + std::optional getName() const noexcept; + std::optional>> getFriends() const noexcept; + std::optional>> getAppearsIn() const noexcept; + std::optional getHomePlanet() const noexcept; private: const response::StringType id_; diff --git a/samples/star_wars/MutationData.cpp b/samples/star_wars/MutationData.cpp index a3dd20b3..9a7284f0 100644 --- a/samples/star_wars/MutationData.cpp +++ b/samples/star_wars/MutationData.cpp @@ -10,7 +10,7 @@ Mutation::Mutation() noexcept } std::shared_ptr Mutation::applyCreateReview( - service::FieldParams&& params, Episode&& epArg, ReviewInput&& reviewArg) noexcept + Episode epArg, ReviewInput reviewArg) noexcept { auto review = std::make_shared(reviewArg.stars, std::move(reviewArg.commentary)); diff --git a/samples/star_wars/MutationData.h b/samples/star_wars/MutationData.h index 4cf62b24..313dde27 100644 --- a/samples/star_wars/MutationData.h +++ b/samples/star_wars/MutationData.h @@ -18,7 +18,7 @@ class Mutation explicit Mutation() noexcept; std::shared_ptr applyCreateReview( - service::FieldParams&& params, Episode&& epArg, ReviewInput&& reviewArg) noexcept; + Episode epArg, ReviewInput reviewArg) noexcept; private: // This is just an example, the Mutation object probably shouldn't own a mutable store for the diff --git a/samples/star_wars/QueryData.cpp b/samples/star_wars/QueryData.cpp index db9079a8..9a921eb6 100644 --- a/samples/star_wars/QueryData.cpp +++ b/samples/star_wars/QueryData.cpp @@ -14,8 +14,7 @@ Query::Query(std::map heroes, { } -std::shared_ptr Query::getHero( - service::FieldParams&&, std::optional&& episodeArg) const noexcept +std::shared_ptr Query::getHero(std::optional episodeArg) const noexcept { std::shared_ptr result; const auto episode = episodeArg ? *episodeArg : Episode::NEW_HOPE; @@ -43,8 +42,7 @@ std::shared_ptr Query::getHero( return result; } -std::shared_ptr Query::getHuman( - service::FieldParams&&, response::StringType&& idArg) const noexcept +std::shared_ptr Query::getHuman(response::StringType idArg) const noexcept { std::shared_ptr result; @@ -56,8 +54,7 @@ std::shared_ptr Query::getHuman( return std::make_shared(std::move(result)); } -std::shared_ptr Query::getDroid( - service::FieldParams&&, response::StringType&& idArg) const noexcept +std::shared_ptr Query::getDroid(response::StringType idArg) const noexcept { std::shared_ptr result; diff --git a/samples/star_wars/QueryData.h b/samples/star_wars/QueryData.h index 8025d054..2f31ac70 100644 --- a/samples/star_wars/QueryData.h +++ b/samples/star_wars/QueryData.h @@ -20,12 +20,9 @@ class Query std::map> humans, std::map> droids) noexcept; - std::shared_ptr getHero( - service::FieldParams&& params, std::optional&& episodeArg) const noexcept; - std::shared_ptr getHuman( - service::FieldParams&& params, response::StringType&& idArg) const noexcept; - std::shared_ptr getDroid( - service::FieldParams&& params, response::StringType&& idArg) const noexcept; + std::shared_ptr getHero(std::optional episodeArg) const noexcept; + std::shared_ptr getHuman(response::StringType idArg) const noexcept; + std::shared_ptr getDroid(response::StringType idArg) const noexcept; private: const std::map heroes_; diff --git a/samples/star_wars/ReviewData.cpp b/samples/star_wars/ReviewData.cpp index dd986efc..c16f24aa 100644 --- a/samples/star_wars/ReviewData.cpp +++ b/samples/star_wars/ReviewData.cpp @@ -11,13 +11,12 @@ Review::Review(response::IntType stars, std::optional comm { } -response::IntType Review::getStars(service::FieldParams&& params) const noexcept +response::IntType Review::getStars() const noexcept { return stars_; } -std::optional Review::getCommentary( - service::FieldParams&& params) const noexcept +std::optional Review::getCommentary() const noexcept { return commentary_; } diff --git a/samples/star_wars/ReviewData.h b/samples/star_wars/ReviewData.h index f701fc37..199cda2c 100644 --- a/samples/star_wars/ReviewData.h +++ b/samples/star_wars/ReviewData.h @@ -16,8 +16,8 @@ class Review explicit Review( response::IntType stars, std::optional commentary) noexcept; - response::IntType getStars(service::FieldParams&& params) const noexcept; - std::optional getCommentary(service::FieldParams&& params) const noexcept; + response::IntType getStars() const noexcept; + std::optional getCommentary() const noexcept; private: const response::IntType stars_; diff --git a/samples/today/TodayMock.cpp b/samples/today/TodayMock.cpp index 97fdea48..9932d4a7 100644 --- a/samples/today/TodayMock.cpp +++ b/samples/today/TodayMock.cpp @@ -167,7 +167,7 @@ auto operator co_await(std::chrono::duration<_Rep, _Period> delay) } service::FieldResult> Query::getNode( - service::FieldParams&& params, response::IdType&& id) + service::FieldParams params, response::IdType id) { // query { node(id: "ZmFrZVRhc2tJZA==") { ...on Task { title } } } using namespace std::literals; @@ -291,9 +291,9 @@ struct EdgeConstraints }; std::future> Query::getAppointments( - service::FieldParams&& params, std::optional&& first, - std::optional&& after, std::optional&& last, - std::optional&& before) + const service::FieldParams& params, std::optional first, + std::optional after, std::optional last, + std::optional before) { auto spThis = shared_from_this(); auto state = params.state; @@ -319,9 +319,10 @@ std::future> Query::getAppointmen std::move(before)); } -std::future> Query::getTasks(service::FieldParams&& params, - std::optional&& first, std::optional&& after, std::optional&& last, - std::optional&& before) +std::future> Query::getTasks( + const service::FieldParams& params, std::optional first, + std::optional after, std::optional last, + std::optional before) { auto spThis = shared_from_this(); auto state = params.state; @@ -348,9 +349,9 @@ std::future> Query::getTasks(service::Fi } std::future> Query::getUnreadCounts( - service::FieldParams&& params, std::optional&& first, - std::optional&& after, std::optional&& last, - std::optional&& before) + const service::FieldParams& params, std::optional first, + std::optional after, std::optional last, + std::optional before) { auto spThis = shared_from_this(); auto state = params.state; @@ -376,10 +377,9 @@ std::future> Query::getUnreadCounts( std::move(before)); } -std::future>> Query::getAppointmentsById( - service::FieldParams&& params, std::vector&& ids) +std::vector> Query::getAppointmentsById( + const service::FieldParams& params, std::vector&& ids) { - std::promise>> promise; std::vector> result(ids.size()); std::transform(ids.cbegin(), @@ -388,15 +388,13 @@ std::future>> Query::getAppoint [this, ¶ms](const response::IdType& id) { return std::make_shared(findAppointment(params, id)); }); - promise.set_value(std::move(result)); - return promise.get_future(); + return result; } -std::future>> Query::getTasksById( - service::FieldParams&& params, std::vector&& ids) +std::vector> Query::getTasksById( + const service::FieldParams& params, std::vector&& ids) { - std::promise>> promise; std::vector> result(ids.size()); std::transform(ids.cbegin(), @@ -405,15 +403,13 @@ std::future>> Query::getTasksById( [this, ¶ms](const response::IdType& id) { return std::make_shared(findTask(params, id)); }); - promise.set_value(std::move(result)); - return promise.get_future(); + return result; } -std::future>> Query::getUnreadCountsById( - service::FieldParams&& params, std::vector&& ids) +std::vector> Query::getUnreadCountsById( + const service::FieldParams& params, std::vector&& ids) { - std::promise>> promise; std::vector> result(ids.size()); std::transform(ids.cbegin(), @@ -422,23 +418,16 @@ std::future>> Query::getUnreadCounts [this, ¶ms](const response::IdType& id) { return std::make_shared(findUnreadCount(params, id)); }); - promise.set_value(std::move(result)); - return promise.get_future(); + return result; } -std::future> Query::getNested(service::FieldParams&& params) +std::shared_ptr Query::getNested(service::FieldParams params) { - std::promise> promise; - - promise.set_value( - std::make_shared(std::make_shared(std::move(params), 1))); - - return promise.get_future(); + return std::make_shared(std::make_shared(std::move(params), 1)); } -std::vector> Query::getExpensive( - service::FieldParams&& /*params*/) +std::vector> Query::getExpensive() { std::vector> result(Expensive::count); @@ -450,13 +439,13 @@ std::vector> Query::getExpensive( return result; } -TaskState Query::getTestTaskState(service::FieldParams&& /*params*/) +TaskState Query::getTestTaskState() { return TaskState::Unassigned; } std::vector> Query::getAnyType( - service::FieldParams&& params, std::vector&& idsArg) + const service::FieldParams& params, std::vector&& idsArg) { loadAppointments(params.state); @@ -478,15 +467,10 @@ Mutation::Mutation(completeTaskMutation&& mutateCompleteTask) { } -std::future> Mutation::applyCompleteTask( - service::FieldParams&& params, CompleteTaskInput&& input) noexcept +std::shared_ptr Mutation::applyCompleteTask( + CompleteTaskInput input) noexcept { - std::promise> promise; - - promise.set_value( - std::make_shared(_mutateCompleteTask(std::move(input)))); - - return promise.get_future(); + return std::make_shared(_mutateCompleteTask(std::move(input))); } std::optional Mutation::_setFloat = std::nullopt; @@ -496,8 +480,7 @@ double Mutation::getFloat() noexcept return *_setFloat; } -response::FloatType Mutation::applySetFloat( - service::FieldParams&& params, response::FloatType&& valueArg) noexcept +response::FloatType Mutation::applySetFloat(response::FloatType valueArg) noexcept { _setFloat = std::make_optional(valueArg); return valueArg; @@ -515,24 +498,16 @@ NestedType::NestedType(service::FieldParams&& params, int depth) std::move(params.fieldDirectives) }); } -std::future NestedType::getDepth(service::FieldParams&& params) const noexcept +response::IntType NestedType::getDepth() const noexcept { - std::promise promise; - - promise.set_value(depth); - - return promise.get_future(); + return depth; } -std::future> NestedType::getNested( - service::FieldParams&& params) const noexcept +std::shared_ptr NestedType::getNested( + service::FieldParams params) const noexcept { - std::promise> promise; - - promise.set_value(std::make_shared( - std::make_shared(std::move(params), depth + 1))); - - return promise.get_future(); + return std::make_shared( + std::make_shared(std::move(params), depth + 1)); } std::stack NestedType::getCapturedParams() noexcept @@ -569,7 +544,8 @@ Expensive::~Expensive() --instances; } -std::future Expensive::getOrder(service::FieldParams&& params) const noexcept +std::future Expensive::getOrder( + const service::FieldParams& params) const noexcept { return std::async( params.launch, diff --git a/samples/today/TodayMock.h b/samples/today/TodayMock.h index 73e1573f..60699934 100644 --- a/samples/today/TodayMock.h +++ b/samples/today/TodayMock.h @@ -51,29 +51,30 @@ class Query : public std::enable_shared_from_this unreadCountsLoader&& getUnreadCounts); service::FieldResult> getNode( - service::FieldParams&& params, response::IdType&& id); + service::FieldParams params, response::IdType id); std::future> getAppointments( - service::FieldParams&& params, std::optional&& first, - std::optional&& after, std::optional&& last, - std::optional&& before); - std::future> getTasks(service::FieldParams&& params, - std::optional&& first, std::optional&& after, - std::optional&& last, std::optional&& before); + const service::FieldParams& params, std::optional first, + std::optional after, std::optional last, + std::optional before); + std::future> getTasks( + const service::FieldParams& params, std::optional first, + std::optional after, std::optional last, + std::optional before); std::future> getUnreadCounts( - service::FieldParams&& params, std::optional&& first, - std::optional&& after, std::optional&& last, - std::optional&& before); - std::future>> getAppointmentsById( - service::FieldParams&& params, std::vector&& ids); - std::future>> getTasksById( - service::FieldParams&& params, std::vector&& ids); - std::future>> getUnreadCountsById( - service::FieldParams&& params, std::vector&& ids); - std::future> getNested(service::FieldParams&& params); - std::vector> getExpensive(service::FieldParams&& params); - TaskState getTestTaskState(service::FieldParams&& params); + const service::FieldParams& params, std::optional first, + std::optional after, std::optional last, + std::optional before); + std::vector> getAppointmentsById( + const service::FieldParams& params, std::vector&& ids); + std::vector> getTasksById( + const service::FieldParams& params, std::vector&& ids); + std::vector> getUnreadCountsById( + const service::FieldParams& params, std::vector&& ids); + std::shared_ptr getNested(service::FieldParams params); + std::vector> getExpensive(); + TaskState getTestTaskState(); std::vector> getAnyType( - service::FieldParams&& params, std::vector&& idsArg); + const service::FieldParams& params, std::vector&& idsArg); private: std::shared_ptr findAppointment( @@ -105,12 +106,12 @@ class PageInfo { } - bool getHasNextPage(service::FieldParams) const noexcept + bool getHasNextPage() const noexcept { return _hasNextPage; } - bool getHasPreviousPage(service::FieldParams) const noexcept + bool getHasPreviousPage() const noexcept { return _hasPreviousPage; } @@ -132,27 +133,27 @@ class Appointment return _id; } - service::FieldResult getId(service::FieldParams) const noexcept + service::FieldResult getId() const noexcept { return _id; } - std::optional getWhen(service::FieldParams) const noexcept + std::optional getWhen() const noexcept { return std::make_optional(std::string(_when)); } - std::optional getSubject(service::FieldParams) const noexcept + std::optional getSubject() const noexcept { return std::make_optional(_subject); } - bool getIsNow(service::FieldParams) const noexcept + bool getIsNow() const noexcept { return _isNow; } - std::optional getForceError(service::FieldParams) const + std::optional getForceError() const { throw std::runtime_error(R"ex(this error was forced)ex"); } @@ -172,14 +173,14 @@ class AppointmentEdge { } - std::shared_ptr getNode(service::FieldParams) const noexcept + std::shared_ptr getNode() const noexcept { return std::make_shared(_appointment); } - service::FieldResult getCursor(service::FieldParams&& params) const + service::FieldResult getCursor() const { - co_return response::Value(co_await _appointment->getId(std::move(params))); + co_return response::Value(co_await _appointment->getId()); } private: @@ -196,13 +197,12 @@ class AppointmentConnection { } - std::shared_ptr getPageInfo(service::FieldParams) const noexcept + std::shared_ptr getPageInfo() const noexcept { return std::make_shared(_pageInfo); } - std::optional>> getEdges( - service::FieldParams) const noexcept + std::optional>> getEdges() const noexcept { auto result = std::make_optional>>( _appointments.size()); @@ -234,17 +234,17 @@ class Task return _id; } - service::FieldResult getId(service::FieldParams) const noexcept + service::FieldResult getId() const noexcept { return _id; } - std::optional getTitle(service::FieldParams) const noexcept + std::optional getTitle() const noexcept { return std::make_optional(_title); } - bool getIsComplete(service::FieldParams) const noexcept + bool getIsComplete() const noexcept { return _isComplete; } @@ -264,14 +264,14 @@ class TaskEdge { } - std::shared_ptr getNode(service::FieldParams) const noexcept + std::shared_ptr getNode() const noexcept { return std::make_shared(_task); } - service::FieldResult getCursor(service::FieldParams&& params) const noexcept + service::FieldResult getCursor() const noexcept { - co_return response::Value(co_await _task->getId(std::move(params))); + co_return response::Value(co_await _task->getId()); } private: @@ -288,13 +288,12 @@ class TaskConnection { } - std::shared_ptr getPageInfo(service::FieldParams) const noexcept + std::shared_ptr getPageInfo() const noexcept { return std::make_shared(_pageInfo); } - std::optional>> getEdges( - service::FieldParams) const noexcept + std::optional>> getEdges() const noexcept { auto result = std::make_optional>>(_tasks.size()); @@ -325,17 +324,17 @@ class Folder return _id; } - service::FieldResult getId(service::FieldParams) const noexcept + service::FieldResult getId() const noexcept { return _id; } - std::optional getName(service::FieldParams) const noexcept + std::optional getName() const noexcept { return std::make_optional(_name); } - int getUnreadCount(service::FieldParams) const noexcept + int getUnreadCount() const noexcept { return _unreadCount; } @@ -354,14 +353,14 @@ class FolderEdge { } - std::shared_ptr getNode(service::FieldParams) const noexcept + std::shared_ptr getNode() const noexcept { return std::make_shared(_folder); } - service::FieldResult getCursor(service::FieldParams&& params) const noexcept + service::FieldResult getCursor() const noexcept { - co_return response::Value(co_await _folder->getId(std::move(params))); + co_return response::Value(co_await _folder->getId()); } private: @@ -378,13 +377,12 @@ class FolderConnection { } - std::shared_ptr getPageInfo(service::FieldParams) const noexcept + std::shared_ptr getPageInfo() const noexcept { return std::make_shared(_pageInfo); } - std::optional>> getEdges( - service::FieldParams) const noexcept + std::optional>> getEdges() const noexcept { auto result = std::make_optional>>(_folders.size()); @@ -414,12 +412,12 @@ class CompleteTaskPayload { } - std::shared_ptr getTask(service::FieldParams) const noexcept + std::shared_ptr getTask() const noexcept { return std::make_shared(_task); } - std::optional getClientMutationId(service::FieldParams) const noexcept + std::optional getClientMutationId() const noexcept { return _clientMutationId; } @@ -439,10 +437,9 @@ class Mutation static double getFloat() noexcept; - std::future> applyCompleteTask( - service::FieldParams&& params, CompleteTaskInput&& input) noexcept; - response::FloatType applySetFloat( - service::FieldParams&& params, response::FloatType&& valueArg) noexcept; + std::shared_ptr applyCompleteTask( + CompleteTaskInput input) noexcept; + response::FloatType applySetFloat(response::FloatType valueArg) noexcept; private: completeTaskMutation _mutateCompleteTask; @@ -454,12 +451,12 @@ class Subscription public: explicit Subscription() = default; - std::shared_ptr getNextAppointmentChange(service::FieldParams) const + std::shared_ptr getNextAppointmentChange() const { throw std::runtime_error("Unexpected call to getNextAppointmentChange"); } - std::shared_ptr getNodeChange(service::FieldParams&&, response::IdType&&) const + std::shared_ptr getNodeChange(const response::IdType&) const { throw std::runtime_error("Unexpected call to getNodeChange"); } @@ -495,7 +492,7 @@ class NextAppointmentChange } std::shared_ptr getNextAppointmentChange( - service::FieldParams&& params) const + const service::FieldParams& params) const { switch (params.resolverContext) { @@ -524,7 +521,7 @@ class NextAppointmentChange return std::make_shared(_changeNextAppointment(params.state)); } - std::shared_ptr getNodeChange(service::FieldParams&&, response::IdType&&) const + std::shared_ptr getNodeChange(const response::IdType&) const { throw std::runtime_error("Unexpected call to getNodeChange"); } @@ -548,13 +545,13 @@ class NodeChange { } - std::shared_ptr getNextAppointmentChange(service::FieldParams) const + std::shared_ptr getNextAppointmentChange() const { throw std::runtime_error("Unexpected call to getNextAppointmentChange"); } std::shared_ptr getNodeChange( - service::FieldParams&& params, response::IdType&& idArg) const + const service::FieldParams& params, response::IdType idArg) const { return std::static_pointer_cast( _changeNode(params.state, std::move(idArg))); @@ -581,9 +578,8 @@ class NestedType public: explicit NestedType(service::FieldParams&& params, int depth); - std::future getDepth(service::FieldParams&& params) const noexcept; - std::future> getNested( - service::FieldParams&& params) const noexcept; + response::IntType getDepth() const noexcept; + std::shared_ptr getNested(service::FieldParams params) const noexcept; static std::stack getCapturedParams() noexcept; @@ -602,7 +598,7 @@ class Expensive explicit Expensive(); ~Expensive(); - std::future getOrder(service::FieldParams&& params) const noexcept; + std::future getOrder(const service::FieldParams& params) const noexcept; static constexpr size_t count = 5; static std::mutex testMutex; diff --git a/samples/unified/TodaySchema.h b/samples/unified/TodaySchema.h index 839e68d0..f527696a 100644 --- a/samples/unified/TodaySchema.h +++ b/samples/unified/TodaySchema.h @@ -87,81 +87,153 @@ struct Node }; namespace object { -namespace stub { -namespace QueryStubs { +namespace methods { +namespace QueryMethod { template -concept HasNode = requires (TImpl impl, service::FieldParams params, response::IdType idArg) +concept WithParamsNode = requires (TImpl impl, service::FieldParams params, response::IdType idArg) { { service::FieldResult> { impl.getNode(std::move(params), std::move(idArg)) } }; }; template -concept HasAppointments = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) +concept NoParamsNode = requires (TImpl impl, response::IdType idArg) +{ + { service::FieldResult> { impl.getNode(std::move(idArg)) } }; +}; + +template +concept WithParamsAppointments = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) { { service::FieldResult> { impl.getAppointments(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; }; template -concept HasTasks = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) +concept NoParamsAppointments = requires (TImpl impl, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) +{ + { service::FieldResult> { impl.getAppointments(std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; +}; + +template +concept WithParamsTasks = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) { { service::FieldResult> { impl.getTasks(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; }; template -concept HasUnreadCounts = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) +concept NoParamsTasks = requires (TImpl impl, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) +{ + { service::FieldResult> { impl.getTasks(std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; +}; + +template +concept WithParamsUnreadCounts = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) { { service::FieldResult> { impl.getUnreadCounts(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; }; template -concept HasAppointmentsById = requires (TImpl impl, service::FieldParams params, std::vector idsArg) +concept NoParamsUnreadCounts = requires (TImpl impl, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) +{ + { service::FieldResult> { impl.getUnreadCounts(std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; +}; + +template +concept WithParamsAppointmentsById = requires (TImpl impl, service::FieldParams params, std::vector idsArg) { { service::FieldResult>> { impl.getAppointmentsById(std::move(params), std::move(idsArg)) } }; }; template -concept HasTasksById = requires (TImpl impl, service::FieldParams params, std::vector idsArg) +concept NoParamsAppointmentsById = requires (TImpl impl, std::vector idsArg) +{ + { service::FieldResult>> { impl.getAppointmentsById(std::move(idsArg)) } }; +}; + +template +concept WithParamsTasksById = requires (TImpl impl, service::FieldParams params, std::vector idsArg) { { service::FieldResult>> { impl.getTasksById(std::move(params), std::move(idsArg)) } }; }; template -concept HasUnreadCountsById = requires (TImpl impl, service::FieldParams params, std::vector idsArg) +concept NoParamsTasksById = requires (TImpl impl, std::vector idsArg) +{ + { service::FieldResult>> { impl.getTasksById(std::move(idsArg)) } }; +}; + +template +concept WithParamsUnreadCountsById = requires (TImpl impl, service::FieldParams params, std::vector idsArg) { { service::FieldResult>> { impl.getUnreadCountsById(std::move(params), std::move(idsArg)) } }; }; template -concept HasNested = requires (TImpl impl, service::FieldParams params) +concept NoParamsUnreadCountsById = requires (TImpl impl, std::vector idsArg) +{ + { service::FieldResult>> { impl.getUnreadCountsById(std::move(idsArg)) } }; +}; + +template +concept WithParamsNested = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getNested(std::move(params)) } }; }; template -concept HasUnimplemented = requires (TImpl impl, service::FieldParams params) +concept NoParamsNested = requires (TImpl impl) +{ + { service::FieldResult> { impl.getNested() } }; +}; + +template +concept WithParamsUnimplemented = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getUnimplemented(std::move(params)) } }; }; template -concept HasExpensive = requires (TImpl impl, service::FieldParams params) +concept NoParamsUnimplemented = requires (TImpl impl) +{ + { service::FieldResult { impl.getUnimplemented() } }; +}; + +template +concept WithParamsExpensive = requires (TImpl impl, service::FieldParams params) { { service::FieldResult>> { impl.getExpensive(std::move(params)) } }; }; template -concept HasTestTaskState = requires (TImpl impl, service::FieldParams params) +concept NoParamsExpensive = requires (TImpl impl) +{ + { service::FieldResult>> { impl.getExpensive() } }; +}; + +template +concept WithParamsTestTaskState = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getTestTaskState(std::move(params)) } }; }; template -concept HasAnyType = requires (TImpl impl, service::FieldParams params, std::vector idsArg) +concept NoParamsTestTaskState = requires (TImpl impl) +{ + { service::FieldResult { impl.getTestTaskState() } }; +}; + +template +concept WithParamsAnyType = requires (TImpl impl, service::FieldParams params, std::vector idsArg) { { service::FieldResult>> { impl.getAnyType(std::move(params), std::move(idsArg)) } }; }; +template +concept NoParamsAnyType = requires (TImpl impl, std::vector idsArg) +{ + { service::FieldResult>> { impl.getAnyType(std::move(idsArg)) } }; +}; + template concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { @@ -174,22 +246,34 @@ concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetPa { impl.endSelectionSet(params) }; }; -} // namespace QueryStubs +} // namespace QueryMethod -namespace PageInfoStubs { +namespace PageInfoMethod { template -concept HasHasNextPage = requires (TImpl impl, service::FieldParams params) +concept WithParamsHasNextPage = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getHasNextPage(std::move(params)) } }; }; template -concept HasHasPreviousPage = requires (TImpl impl, service::FieldParams params) +concept NoParamsHasNextPage = requires (TImpl impl) +{ + { service::FieldResult { impl.getHasNextPage() } }; +}; + +template +concept WithParamsHasPreviousPage = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getHasPreviousPage(std::move(params)) } }; }; +template +concept NoParamsHasPreviousPage = requires (TImpl impl) +{ + { service::FieldResult { impl.getHasPreviousPage() } }; +}; + template concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { @@ -202,22 +286,34 @@ concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetPa { impl.endSelectionSet(params) }; }; -} // namespace PageInfoStubs +} // namespace PageInfoMethod -namespace AppointmentEdgeStubs { +namespace AppointmentEdgeMethod { template -concept HasNode = requires (TImpl impl, service::FieldParams params) +concept WithParamsNode = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getNode(std::move(params)) } }; }; template -concept HasCursor = requires (TImpl impl, service::FieldParams params) +concept NoParamsNode = requires (TImpl impl) +{ + { service::FieldResult> { impl.getNode() } }; +}; + +template +concept WithParamsCursor = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getCursor(std::move(params)) } }; }; +template +concept NoParamsCursor = requires (TImpl impl) +{ + { service::FieldResult { impl.getCursor() } }; +}; + template concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { @@ -230,22 +326,34 @@ concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetPa { impl.endSelectionSet(params) }; }; -} // namespace AppointmentEdgeStubs +} // namespace AppointmentEdgeMethod -namespace AppointmentConnectionStubs { +namespace AppointmentConnectionMethod { template -concept HasPageInfo = requires (TImpl impl, service::FieldParams params) +concept WithParamsPageInfo = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getPageInfo(std::move(params)) } }; }; template -concept HasEdges = requires (TImpl impl, service::FieldParams params) +concept NoParamsPageInfo = requires (TImpl impl) +{ + { service::FieldResult> { impl.getPageInfo() } }; +}; + +template +concept WithParamsEdges = requires (TImpl impl, service::FieldParams params) { { service::FieldResult>>> { impl.getEdges(std::move(params)) } }; }; +template +concept NoParamsEdges = requires (TImpl impl) +{ + { service::FieldResult>>> { impl.getEdges() } }; +}; + template concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { @@ -258,22 +366,34 @@ concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetPa { impl.endSelectionSet(params) }; }; -} // namespace AppointmentConnectionStubs +} // namespace AppointmentConnectionMethod -namespace TaskEdgeStubs { +namespace TaskEdgeMethod { template -concept HasNode = requires (TImpl impl, service::FieldParams params) +concept WithParamsNode = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getNode(std::move(params)) } }; }; template -concept HasCursor = requires (TImpl impl, service::FieldParams params) +concept NoParamsNode = requires (TImpl impl) +{ + { service::FieldResult> { impl.getNode() } }; +}; + +template +concept WithParamsCursor = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getCursor(std::move(params)) } }; }; +template +concept NoParamsCursor = requires (TImpl impl) +{ + { service::FieldResult { impl.getCursor() } }; +}; + template concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { @@ -286,22 +406,34 @@ concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetPa { impl.endSelectionSet(params) }; }; -} // namespace TaskEdgeStubs +} // namespace TaskEdgeMethod -namespace TaskConnectionStubs { +namespace TaskConnectionMethod { template -concept HasPageInfo = requires (TImpl impl, service::FieldParams params) +concept WithParamsPageInfo = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getPageInfo(std::move(params)) } }; }; template -concept HasEdges = requires (TImpl impl, service::FieldParams params) +concept NoParamsPageInfo = requires (TImpl impl) +{ + { service::FieldResult> { impl.getPageInfo() } }; +}; + +template +concept WithParamsEdges = requires (TImpl impl, service::FieldParams params) { { service::FieldResult>>> { impl.getEdges(std::move(params)) } }; }; +template +concept NoParamsEdges = requires (TImpl impl) +{ + { service::FieldResult>>> { impl.getEdges() } }; +}; + template concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { @@ -314,22 +446,34 @@ concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetPa { impl.endSelectionSet(params) }; }; -} // namespace TaskConnectionStubs +} // namespace TaskConnectionMethod -namespace FolderEdgeStubs { +namespace FolderEdgeMethod { template -concept HasNode = requires (TImpl impl, service::FieldParams params) +concept WithParamsNode = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getNode(std::move(params)) } }; }; template -concept HasCursor = requires (TImpl impl, service::FieldParams params) +concept NoParamsNode = requires (TImpl impl) +{ + { service::FieldResult> { impl.getNode() } }; +}; + +template +concept WithParamsCursor = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getCursor(std::move(params)) } }; }; +template +concept NoParamsCursor = requires (TImpl impl) +{ + { service::FieldResult { impl.getCursor() } }; +}; + template concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { @@ -342,22 +486,34 @@ concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetPa { impl.endSelectionSet(params) }; }; -} // namespace FolderEdgeStubs +} // namespace FolderEdgeMethod -namespace FolderConnectionStubs { +namespace FolderConnectionMethod { template -concept HasPageInfo = requires (TImpl impl, service::FieldParams params) +concept WithParamsPageInfo = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getPageInfo(std::move(params)) } }; }; template -concept HasEdges = requires (TImpl impl, service::FieldParams params) +concept NoParamsPageInfo = requires (TImpl impl) +{ + { service::FieldResult> { impl.getPageInfo() } }; +}; + +template +concept WithParamsEdges = requires (TImpl impl, service::FieldParams params) { { service::FieldResult>>> { impl.getEdges(std::move(params)) } }; }; +template +concept NoParamsEdges = requires (TImpl impl) +{ + { service::FieldResult>>> { impl.getEdges() } }; +}; + template concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { @@ -370,22 +526,34 @@ concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetPa { impl.endSelectionSet(params) }; }; -} // namespace FolderConnectionStubs +} // namespace FolderConnectionMethod -namespace CompleteTaskPayloadStubs { +namespace CompleteTaskPayloadMethod { template -concept HasTask = requires (TImpl impl, service::FieldParams params) +concept WithParamsTask = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getTask(std::move(params)) } }; }; template -concept HasClientMutationId = requires (TImpl impl, service::FieldParams params) +concept NoParamsTask = requires (TImpl impl) +{ + { service::FieldResult> { impl.getTask() } }; +}; + +template +concept WithParamsClientMutationId = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getClientMutationId(std::move(params)) } }; }; +template +concept NoParamsClientMutationId = requires (TImpl impl) +{ + { service::FieldResult> { impl.getClientMutationId() } }; +}; + template concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { @@ -398,22 +566,34 @@ concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetPa { impl.endSelectionSet(params) }; }; -} // namespace CompleteTaskPayloadStubs +} // namespace CompleteTaskPayloadMethod -namespace MutationStubs { +namespace MutationMethod { template -concept HasCompleteTask = requires (TImpl impl, service::FieldParams params, CompleteTaskInput inputArg) +concept WithParamsCompleteTask = requires (TImpl impl, service::FieldParams params, CompleteTaskInput inputArg) { { service::FieldResult> { impl.applyCompleteTask(std::move(params), std::move(inputArg)) } }; }; template -concept HasSetFloat = requires (TImpl impl, service::FieldParams params, response::FloatType valueArg) +concept NoParamsCompleteTask = requires (TImpl impl, CompleteTaskInput inputArg) +{ + { service::FieldResult> { impl.applyCompleteTask(std::move(inputArg)) } }; +}; + +template +concept WithParamsSetFloat = requires (TImpl impl, service::FieldParams params, response::FloatType valueArg) { { service::FieldResult { impl.applySetFloat(std::move(params), std::move(valueArg)) } }; }; +template +concept NoParamsSetFloat = requires (TImpl impl, response::FloatType valueArg) +{ + { service::FieldResult { impl.applySetFloat(std::move(valueArg)) } }; +}; + template concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { @@ -426,22 +606,34 @@ concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetPa { impl.endSelectionSet(params) }; }; -} // namespace MutationStubs +} // namespace MutationMethod -namespace SubscriptionStubs { +namespace SubscriptionMethod { template -concept HasNextAppointmentChange = requires (TImpl impl, service::FieldParams params) +concept WithParamsNextAppointmentChange = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getNextAppointmentChange(std::move(params)) } }; }; template -concept HasNodeChange = requires (TImpl impl, service::FieldParams params, response::IdType idArg) +concept NoParamsNextAppointmentChange = requires (TImpl impl) +{ + { service::FieldResult> { impl.getNextAppointmentChange() } }; +}; + +template +concept WithParamsNodeChange = requires (TImpl impl, service::FieldParams params, response::IdType idArg) { { service::FieldResult> { impl.getNodeChange(std::move(params), std::move(idArg)) } }; }; +template +concept NoParamsNodeChange = requires (TImpl impl, response::IdType idArg) +{ + { service::FieldResult> { impl.getNodeChange(std::move(idArg)) } }; +}; + template concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { @@ -454,40 +646,70 @@ concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetPa { impl.endSelectionSet(params) }; }; -} // namespace SubscriptionStubs +} // namespace SubscriptionMethod -namespace AppointmentStubs { +namespace AppointmentMethod { template -concept HasId = requires (TImpl impl, service::FieldParams params) +concept WithParamsId = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getId(std::move(params)) } }; }; template -concept HasWhen = requires (TImpl impl, service::FieldParams params) +concept NoParamsId = requires (TImpl impl) +{ + { service::FieldResult { impl.getId() } }; +}; + +template +concept WithParamsWhen = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getWhen(std::move(params)) } }; }; template -concept HasSubject = requires (TImpl impl, service::FieldParams params) +concept NoParamsWhen = requires (TImpl impl) +{ + { service::FieldResult> { impl.getWhen() } }; +}; + +template +concept WithParamsSubject = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getSubject(std::move(params)) } }; }; template -concept HasIsNow = requires (TImpl impl, service::FieldParams params) +concept NoParamsSubject = requires (TImpl impl) +{ + { service::FieldResult> { impl.getSubject() } }; +}; + +template +concept WithParamsIsNow = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getIsNow(std::move(params)) } }; }; template -concept HasForceError = requires (TImpl impl, service::FieldParams params) +concept NoParamsIsNow = requires (TImpl impl) +{ + { service::FieldResult { impl.getIsNow() } }; +}; + +template +concept WithParamsForceError = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getForceError(std::move(params)) } }; }; +template +concept NoParamsForceError = requires (TImpl impl) +{ + { service::FieldResult> { impl.getForceError() } }; +}; + template concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { @@ -500,28 +722,46 @@ concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetPa { impl.endSelectionSet(params) }; }; -} // namespace AppointmentStubs +} // namespace AppointmentMethod -namespace TaskStubs { +namespace TaskMethod { template -concept HasId = requires (TImpl impl, service::FieldParams params) +concept WithParamsId = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getId(std::move(params)) } }; }; template -concept HasTitle = requires (TImpl impl, service::FieldParams params) +concept NoParamsId = requires (TImpl impl) +{ + { service::FieldResult { impl.getId() } }; +}; + +template +concept WithParamsTitle = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getTitle(std::move(params)) } }; }; template -concept HasIsComplete = requires (TImpl impl, service::FieldParams params) +concept NoParamsTitle = requires (TImpl impl) +{ + { service::FieldResult> { impl.getTitle() } }; +}; + +template +concept WithParamsIsComplete = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getIsComplete(std::move(params)) } }; }; +template +concept NoParamsIsComplete = requires (TImpl impl) +{ + { service::FieldResult { impl.getIsComplete() } }; +}; + template concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { @@ -534,28 +774,46 @@ concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetPa { impl.endSelectionSet(params) }; }; -} // namespace TaskStubs +} // namespace TaskMethod -namespace FolderStubs { +namespace FolderMethod { template -concept HasId = requires (TImpl impl, service::FieldParams params) +concept WithParamsId = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getId(std::move(params)) } }; }; template -concept HasName = requires (TImpl impl, service::FieldParams params) +concept NoParamsId = requires (TImpl impl) +{ + { service::FieldResult { impl.getId() } }; +}; + +template +concept WithParamsName = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getName(std::move(params)) } }; }; template -concept HasUnreadCount = requires (TImpl impl, service::FieldParams params) +concept NoParamsName = requires (TImpl impl) +{ + { service::FieldResult> { impl.getName() } }; +}; + +template +concept WithParamsUnreadCount = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getUnreadCount(std::move(params)) } }; }; +template +concept NoParamsUnreadCount = requires (TImpl impl) +{ + { service::FieldResult { impl.getUnreadCount() } }; +}; + template concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { @@ -568,22 +826,34 @@ concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetPa { impl.endSelectionSet(params) }; }; -} // namespace FolderStubs +} // namespace FolderMethod -namespace NestedTypeStubs { +namespace NestedTypeMethod { template -concept HasDepth = requires (TImpl impl, service::FieldParams params) +concept WithParamsDepth = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getDepth(std::move(params)) } }; }; template -concept HasNested = requires (TImpl impl, service::FieldParams params) +concept NoParamsDepth = requires (TImpl impl) +{ + { service::FieldResult { impl.getDepth() } }; +}; + +template +concept WithParamsNested = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getNested(std::move(params)) } }; }; +template +concept NoParamsNested = requires (TImpl impl) +{ + { service::FieldResult> { impl.getNested() } }; +}; + template concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { @@ -596,16 +866,22 @@ concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetPa { impl.endSelectionSet(params) }; }; -} // namespace NestedTypeStubs +} // namespace NestedTypeMethod -namespace ExpensiveStubs { +namespace ExpensiveMethod { template -concept HasOrder = requires (TImpl impl, service::FieldParams params) +concept WithParamsOrder = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getOrder(std::move(params)) } }; }; +template +concept NoParamsOrder = requires (TImpl impl) +{ + { service::FieldResult { impl.getOrder() } }; +}; + template concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { @@ -618,8 +894,8 @@ concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetPa { impl.endSelectionSet(params) }; }; -} // namespace ExpensiveStubs -} // namespace stub +} // namespace ExpensiveMethod +} // namespace methods class Query : public service::Object @@ -674,28 +950,16 @@ class Query { } - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::QueryStubs::HasBeginSelectionSet) - { - _pimpl->beginSelectionSet(params); - } - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::QueryStubs::HasEndSelectionSet) - { - _pimpl->endSelectionSet(params); - } - } - service::FieldResult> getNode(service::FieldParams&& params, response::IdType&& idArg) const final { - if constexpr (stub::QueryStubs::HasNode) + if constexpr (methods::QueryMethod::WithParamsNode) { return { _pimpl->getNode(std::move(params), std::move(idArg)) }; } + else if constexpr (methods::QueryMethod::NoParamsNode) + { + return { _pimpl->getNode(std::move(idArg)) }; + } else { throw std::runtime_error(R"ex(Query::getNode is not implemented)ex"); @@ -704,10 +968,14 @@ class Query service::FieldResult> getAppointments(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const final { - if constexpr (stub::QueryStubs::HasAppointments) + if constexpr (methods::QueryMethod::WithParamsAppointments) { return { _pimpl->getAppointments(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) }; } + else if constexpr (methods::QueryMethod::NoParamsAppointments) + { + return { _pimpl->getAppointments(std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) }; + } else { throw std::runtime_error(R"ex(Query::getAppointments is not implemented)ex"); @@ -716,10 +984,14 @@ class Query service::FieldResult> getTasks(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const final { - if constexpr (stub::QueryStubs::HasTasks) + if constexpr (methods::QueryMethod::WithParamsTasks) { return { _pimpl->getTasks(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) }; } + else if constexpr (methods::QueryMethod::NoParamsTasks) + { + return { _pimpl->getTasks(std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) }; + } else { throw std::runtime_error(R"ex(Query::getTasks is not implemented)ex"); @@ -728,10 +1000,14 @@ class Query service::FieldResult> getUnreadCounts(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const final { - if constexpr (stub::QueryStubs::HasUnreadCounts) + if constexpr (methods::QueryMethod::WithParamsUnreadCounts) { return { _pimpl->getUnreadCounts(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) }; } + else if constexpr (methods::QueryMethod::NoParamsUnreadCounts) + { + return { _pimpl->getUnreadCounts(std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) }; + } else { throw std::runtime_error(R"ex(Query::getUnreadCounts is not implemented)ex"); @@ -740,10 +1016,14 @@ class Query service::FieldResult>> getAppointmentsById(service::FieldParams&& params, std::vector&& idsArg) const final { - if constexpr (stub::QueryStubs::HasAppointmentsById) + if constexpr (methods::QueryMethod::WithParamsAppointmentsById) { return { _pimpl->getAppointmentsById(std::move(params), std::move(idsArg)) }; } + else if constexpr (methods::QueryMethod::NoParamsAppointmentsById) + { + return { _pimpl->getAppointmentsById(std::move(idsArg)) }; + } else { throw std::runtime_error(R"ex(Query::getAppointmentsById is not implemented)ex"); @@ -752,10 +1032,14 @@ class Query service::FieldResult>> getTasksById(service::FieldParams&& params, std::vector&& idsArg) const final { - if constexpr (stub::QueryStubs::HasTasksById) + if constexpr (methods::QueryMethod::WithParamsTasksById) { return { _pimpl->getTasksById(std::move(params), std::move(idsArg)) }; } + else if constexpr (methods::QueryMethod::NoParamsTasksById) + { + return { _pimpl->getTasksById(std::move(idsArg)) }; + } else { throw std::runtime_error(R"ex(Query::getTasksById is not implemented)ex"); @@ -764,10 +1048,14 @@ class Query service::FieldResult>> getUnreadCountsById(service::FieldParams&& params, std::vector&& idsArg) const final { - if constexpr (stub::QueryStubs::HasUnreadCountsById) + if constexpr (methods::QueryMethod::WithParamsUnreadCountsById) { return { _pimpl->getUnreadCountsById(std::move(params), std::move(idsArg)) }; } + else if constexpr (methods::QueryMethod::NoParamsUnreadCountsById) + { + return { _pimpl->getUnreadCountsById(std::move(idsArg)) }; + } else { throw std::runtime_error(R"ex(Query::getUnreadCountsById is not implemented)ex"); @@ -776,10 +1064,14 @@ class Query service::FieldResult> getNested(service::FieldParams&& params) const final { - if constexpr (stub::QueryStubs::HasNested) + if constexpr (methods::QueryMethod::WithParamsNested) { return { _pimpl->getNested(std::move(params)) }; } + else if constexpr (methods::QueryMethod::NoParamsNested) + { + return { _pimpl->getNested() }; + } else { throw std::runtime_error(R"ex(Query::getNested is not implemented)ex"); @@ -788,10 +1080,14 @@ class Query service::FieldResult getUnimplemented(service::FieldParams&& params) const final { - if constexpr (stub::QueryStubs::HasUnimplemented) + if constexpr (methods::QueryMethod::WithParamsUnimplemented) { return { _pimpl->getUnimplemented(std::move(params)) }; } + else if constexpr (methods::QueryMethod::NoParamsUnimplemented) + { + return { _pimpl->getUnimplemented() }; + } else { throw std::runtime_error(R"ex(Query::getUnimplemented is not implemented)ex"); @@ -800,10 +1096,14 @@ class Query service::FieldResult>> getExpensive(service::FieldParams&& params) const final { - if constexpr (stub::QueryStubs::HasExpensive) + if constexpr (methods::QueryMethod::WithParamsExpensive) { return { _pimpl->getExpensive(std::move(params)) }; } + else if constexpr (methods::QueryMethod::NoParamsExpensive) + { + return { _pimpl->getExpensive() }; + } else { throw std::runtime_error(R"ex(Query::getExpensive is not implemented)ex"); @@ -812,10 +1112,14 @@ class Query service::FieldResult getTestTaskState(service::FieldParams&& params) const final { - if constexpr (stub::QueryStubs::HasTestTaskState) + if constexpr (methods::QueryMethod::WithParamsTestTaskState) { return { _pimpl->getTestTaskState(std::move(params)) }; } + else if constexpr (methods::QueryMethod::NoParamsTestTaskState) + { + return { _pimpl->getTestTaskState() }; + } else { throw std::runtime_error(R"ex(Query::getTestTaskState is not implemented)ex"); @@ -824,16 +1128,36 @@ class Query service::FieldResult>> getAnyType(service::FieldParams&& params, std::vector&& idsArg) const final { - if constexpr (stub::QueryStubs::HasAnyType) + if constexpr (methods::QueryMethod::WithParamsAnyType) { return { _pimpl->getAnyType(std::move(params), std::move(idsArg)) }; } + else if constexpr (methods::QueryMethod::NoParamsAnyType) + { + return { _pimpl->getAnyType(std::move(idsArg)) }; + } else { throw std::runtime_error(R"ex(Query::getAnyType is not implemented)ex"); } } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::QueryMethod::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::QueryMethod::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + private: const std::shared_ptr _pimpl; }; @@ -882,28 +1206,16 @@ class PageInfo { } - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::PageInfoStubs::HasBeginSelectionSet) - { - _pimpl->beginSelectionSet(params); - } - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::PageInfoStubs::HasEndSelectionSet) - { - _pimpl->endSelectionSet(params); - } - } - service::FieldResult getHasNextPage(service::FieldParams&& params) const final { - if constexpr (stub::PageInfoStubs::HasHasNextPage) + if constexpr (methods::PageInfoMethod::WithParamsHasNextPage) { return { _pimpl->getHasNextPage(std::move(params)) }; } + else if constexpr (methods::PageInfoMethod::NoParamsHasNextPage) + { + return { _pimpl->getHasNextPage() }; + } else { throw std::runtime_error(R"ex(PageInfo::getHasNextPage is not implemented)ex"); @@ -912,18 +1224,38 @@ class PageInfo service::FieldResult getHasPreviousPage(service::FieldParams&& params) const final { - if constexpr (stub::PageInfoStubs::HasHasPreviousPage) + if constexpr (methods::PageInfoMethod::WithParamsHasPreviousPage) { return { _pimpl->getHasPreviousPage(std::move(params)) }; } + else if constexpr (methods::PageInfoMethod::NoParamsHasPreviousPage) + { + return { _pimpl->getHasPreviousPage() }; + } else { throw std::runtime_error(R"ex(PageInfo::getHasPreviousPage is not implemented)ex"); } } - private: - const std::shared_ptr _pimpl; + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::PageInfoMethod::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::PageInfoMethod::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + + private: + const std::shared_ptr _pimpl; }; PageInfo(std::unique_ptr&& pimpl); @@ -970,28 +1302,16 @@ class AppointmentEdge { } - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::AppointmentEdgeStubs::HasBeginSelectionSet) - { - _pimpl->beginSelectionSet(params); - } - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::AppointmentEdgeStubs::HasEndSelectionSet) - { - _pimpl->endSelectionSet(params); - } - } - service::FieldResult> getNode(service::FieldParams&& params) const final { - if constexpr (stub::AppointmentEdgeStubs::HasNode) + if constexpr (methods::AppointmentEdgeMethod::WithParamsNode) { return { _pimpl->getNode(std::move(params)) }; } + else if constexpr (methods::AppointmentEdgeMethod::NoParamsNode) + { + return { _pimpl->getNode() }; + } else { throw std::runtime_error(R"ex(AppointmentEdge::getNode is not implemented)ex"); @@ -1000,16 +1320,36 @@ class AppointmentEdge service::FieldResult getCursor(service::FieldParams&& params) const final { - if constexpr (stub::AppointmentEdgeStubs::HasCursor) + if constexpr (methods::AppointmentEdgeMethod::WithParamsCursor) { return { _pimpl->getCursor(std::move(params)) }; } + else if constexpr (methods::AppointmentEdgeMethod::NoParamsCursor) + { + return { _pimpl->getCursor() }; + } else { throw std::runtime_error(R"ex(AppointmentEdge::getCursor is not implemented)ex"); } } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::AppointmentEdgeMethod::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::AppointmentEdgeMethod::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + private: const std::shared_ptr _pimpl; }; @@ -1058,28 +1398,16 @@ class AppointmentConnection { } - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::AppointmentConnectionStubs::HasBeginSelectionSet) - { - _pimpl->beginSelectionSet(params); - } - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::AppointmentConnectionStubs::HasEndSelectionSet) - { - _pimpl->endSelectionSet(params); - } - } - service::FieldResult> getPageInfo(service::FieldParams&& params) const final { - if constexpr (stub::AppointmentConnectionStubs::HasPageInfo) + if constexpr (methods::AppointmentConnectionMethod::WithParamsPageInfo) { return { _pimpl->getPageInfo(std::move(params)) }; } + else if constexpr (methods::AppointmentConnectionMethod::NoParamsPageInfo) + { + return { _pimpl->getPageInfo() }; + } else { throw std::runtime_error(R"ex(AppointmentConnection::getPageInfo is not implemented)ex"); @@ -1088,16 +1416,36 @@ class AppointmentConnection service::FieldResult>>> getEdges(service::FieldParams&& params) const final { - if constexpr (stub::AppointmentConnectionStubs::HasEdges) + if constexpr (methods::AppointmentConnectionMethod::WithParamsEdges) { return { _pimpl->getEdges(std::move(params)) }; } + else if constexpr (methods::AppointmentConnectionMethod::NoParamsEdges) + { + return { _pimpl->getEdges() }; + } else { throw std::runtime_error(R"ex(AppointmentConnection::getEdges is not implemented)ex"); } } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::AppointmentConnectionMethod::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::AppointmentConnectionMethod::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + private: const std::shared_ptr _pimpl; }; @@ -1146,28 +1494,16 @@ class TaskEdge { } - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::TaskEdgeStubs::HasBeginSelectionSet) - { - _pimpl->beginSelectionSet(params); - } - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::TaskEdgeStubs::HasEndSelectionSet) - { - _pimpl->endSelectionSet(params); - } - } - service::FieldResult> getNode(service::FieldParams&& params) const final { - if constexpr (stub::TaskEdgeStubs::HasNode) + if constexpr (methods::TaskEdgeMethod::WithParamsNode) { return { _pimpl->getNode(std::move(params)) }; } + else if constexpr (methods::TaskEdgeMethod::NoParamsNode) + { + return { _pimpl->getNode() }; + } else { throw std::runtime_error(R"ex(TaskEdge::getNode is not implemented)ex"); @@ -1176,16 +1512,36 @@ class TaskEdge service::FieldResult getCursor(service::FieldParams&& params) const final { - if constexpr (stub::TaskEdgeStubs::HasCursor) + if constexpr (methods::TaskEdgeMethod::WithParamsCursor) { return { _pimpl->getCursor(std::move(params)) }; } + else if constexpr (methods::TaskEdgeMethod::NoParamsCursor) + { + return { _pimpl->getCursor() }; + } else { throw std::runtime_error(R"ex(TaskEdge::getCursor is not implemented)ex"); } } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::TaskEdgeMethod::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::TaskEdgeMethod::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + private: const std::shared_ptr _pimpl; }; @@ -1234,28 +1590,16 @@ class TaskConnection { } - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::TaskConnectionStubs::HasBeginSelectionSet) - { - _pimpl->beginSelectionSet(params); - } - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::TaskConnectionStubs::HasEndSelectionSet) - { - _pimpl->endSelectionSet(params); - } - } - service::FieldResult> getPageInfo(service::FieldParams&& params) const final { - if constexpr (stub::TaskConnectionStubs::HasPageInfo) + if constexpr (methods::TaskConnectionMethod::WithParamsPageInfo) { return { _pimpl->getPageInfo(std::move(params)) }; } + else if constexpr (methods::TaskConnectionMethod::NoParamsPageInfo) + { + return { _pimpl->getPageInfo() }; + } else { throw std::runtime_error(R"ex(TaskConnection::getPageInfo is not implemented)ex"); @@ -1264,16 +1608,36 @@ class TaskConnection service::FieldResult>>> getEdges(service::FieldParams&& params) const final { - if constexpr (stub::TaskConnectionStubs::HasEdges) + if constexpr (methods::TaskConnectionMethod::WithParamsEdges) { return { _pimpl->getEdges(std::move(params)) }; } + else if constexpr (methods::TaskConnectionMethod::NoParamsEdges) + { + return { _pimpl->getEdges() }; + } else { throw std::runtime_error(R"ex(TaskConnection::getEdges is not implemented)ex"); } } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::TaskConnectionMethod::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::TaskConnectionMethod::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + private: const std::shared_ptr _pimpl; }; @@ -1322,28 +1686,16 @@ class FolderEdge { } - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::FolderEdgeStubs::HasBeginSelectionSet) - { - _pimpl->beginSelectionSet(params); - } - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::FolderEdgeStubs::HasEndSelectionSet) - { - _pimpl->endSelectionSet(params); - } - } - service::FieldResult> getNode(service::FieldParams&& params) const final { - if constexpr (stub::FolderEdgeStubs::HasNode) + if constexpr (methods::FolderEdgeMethod::WithParamsNode) { return { _pimpl->getNode(std::move(params)) }; } + else if constexpr (methods::FolderEdgeMethod::NoParamsNode) + { + return { _pimpl->getNode() }; + } else { throw std::runtime_error(R"ex(FolderEdge::getNode is not implemented)ex"); @@ -1352,16 +1704,36 @@ class FolderEdge service::FieldResult getCursor(service::FieldParams&& params) const final { - if constexpr (stub::FolderEdgeStubs::HasCursor) + if constexpr (methods::FolderEdgeMethod::WithParamsCursor) { return { _pimpl->getCursor(std::move(params)) }; } + else if constexpr (methods::FolderEdgeMethod::NoParamsCursor) + { + return { _pimpl->getCursor() }; + } else { throw std::runtime_error(R"ex(FolderEdge::getCursor is not implemented)ex"); } } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::FolderEdgeMethod::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::FolderEdgeMethod::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + private: const std::shared_ptr _pimpl; }; @@ -1410,28 +1782,16 @@ class FolderConnection { } - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::FolderConnectionStubs::HasBeginSelectionSet) - { - _pimpl->beginSelectionSet(params); - } - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::FolderConnectionStubs::HasEndSelectionSet) - { - _pimpl->endSelectionSet(params); - } - } - service::FieldResult> getPageInfo(service::FieldParams&& params) const final { - if constexpr (stub::FolderConnectionStubs::HasPageInfo) + if constexpr (methods::FolderConnectionMethod::WithParamsPageInfo) { return { _pimpl->getPageInfo(std::move(params)) }; } + else if constexpr (methods::FolderConnectionMethod::NoParamsPageInfo) + { + return { _pimpl->getPageInfo() }; + } else { throw std::runtime_error(R"ex(FolderConnection::getPageInfo is not implemented)ex"); @@ -1440,16 +1800,36 @@ class FolderConnection service::FieldResult>>> getEdges(service::FieldParams&& params) const final { - if constexpr (stub::FolderConnectionStubs::HasEdges) + if constexpr (methods::FolderConnectionMethod::WithParamsEdges) { return { _pimpl->getEdges(std::move(params)) }; } + else if constexpr (methods::FolderConnectionMethod::NoParamsEdges) + { + return { _pimpl->getEdges() }; + } else { throw std::runtime_error(R"ex(FolderConnection::getEdges is not implemented)ex"); } } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::FolderConnectionMethod::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::FolderConnectionMethod::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + private: const std::shared_ptr _pimpl; }; @@ -1498,28 +1878,16 @@ class CompleteTaskPayload { } - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::CompleteTaskPayloadStubs::HasBeginSelectionSet) - { - _pimpl->beginSelectionSet(params); - } - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::CompleteTaskPayloadStubs::HasEndSelectionSet) - { - _pimpl->endSelectionSet(params); - } - } - service::FieldResult> getTask(service::FieldParams&& params) const final { - if constexpr (stub::CompleteTaskPayloadStubs::HasTask) + if constexpr (methods::CompleteTaskPayloadMethod::WithParamsTask) { return { _pimpl->getTask(std::move(params)) }; } + else if constexpr (methods::CompleteTaskPayloadMethod::NoParamsTask) + { + return { _pimpl->getTask() }; + } else { throw std::runtime_error(R"ex(CompleteTaskPayload::getTask is not implemented)ex"); @@ -1528,16 +1896,36 @@ class CompleteTaskPayload service::FieldResult> getClientMutationId(service::FieldParams&& params) const final { - if constexpr (stub::CompleteTaskPayloadStubs::HasClientMutationId) + if constexpr (methods::CompleteTaskPayloadMethod::WithParamsClientMutationId) { return { _pimpl->getClientMutationId(std::move(params)) }; } + else if constexpr (methods::CompleteTaskPayloadMethod::NoParamsClientMutationId) + { + return { _pimpl->getClientMutationId() }; + } else { throw std::runtime_error(R"ex(CompleteTaskPayload::getClientMutationId is not implemented)ex"); } } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::CompleteTaskPayloadMethod::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::CompleteTaskPayloadMethod::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + private: const std::shared_ptr _pimpl; }; @@ -1586,28 +1974,16 @@ class Mutation { } - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::MutationStubs::HasBeginSelectionSet) - { - _pimpl->beginSelectionSet(params); - } - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::MutationStubs::HasEndSelectionSet) - { - _pimpl->endSelectionSet(params); - } - } - service::FieldResult> applyCompleteTask(service::FieldParams&& params, CompleteTaskInput&& inputArg) const final { - if constexpr (stub::MutationStubs::HasCompleteTask) + if constexpr (methods::MutationMethod::WithParamsCompleteTask) { return { _pimpl->applyCompleteTask(std::move(params), std::move(inputArg)) }; } + else if constexpr (methods::MutationMethod::NoParamsCompleteTask) + { + return { _pimpl->applyCompleteTask(std::move(inputArg)) }; + } else { throw std::runtime_error(R"ex(Mutation::applyCompleteTask is not implemented)ex"); @@ -1616,16 +1992,36 @@ class Mutation service::FieldResult applySetFloat(service::FieldParams&& params, response::FloatType&& valueArg) const final { - if constexpr (stub::MutationStubs::HasSetFloat) + if constexpr (methods::MutationMethod::WithParamsSetFloat) { return { _pimpl->applySetFloat(std::move(params), std::move(valueArg)) }; } + else if constexpr (methods::MutationMethod::NoParamsSetFloat) + { + return { _pimpl->applySetFloat(std::move(valueArg)) }; + } else { throw std::runtime_error(R"ex(Mutation::applySetFloat is not implemented)ex"); } } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::MutationMethod::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::MutationMethod::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + private: const std::shared_ptr _pimpl; }; @@ -1674,28 +2070,16 @@ class Subscription { } - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::SubscriptionStubs::HasBeginSelectionSet) - { - _pimpl->beginSelectionSet(params); - } - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::SubscriptionStubs::HasEndSelectionSet) - { - _pimpl->endSelectionSet(params); - } - } - service::FieldResult> getNextAppointmentChange(service::FieldParams&& params) const final { - if constexpr (stub::SubscriptionStubs::HasNextAppointmentChange) + if constexpr (methods::SubscriptionMethod::WithParamsNextAppointmentChange) { return { _pimpl->getNextAppointmentChange(std::move(params)) }; } + else if constexpr (methods::SubscriptionMethod::NoParamsNextAppointmentChange) + { + return { _pimpl->getNextAppointmentChange() }; + } else { throw std::runtime_error(R"ex(Subscription::getNextAppointmentChange is not implemented)ex"); @@ -1704,16 +2088,36 @@ class Subscription service::FieldResult> getNodeChange(service::FieldParams&& params, response::IdType&& idArg) const final { - if constexpr (stub::SubscriptionStubs::HasNodeChange) + if constexpr (methods::SubscriptionMethod::WithParamsNodeChange) { return { _pimpl->getNodeChange(std::move(params), std::move(idArg)) }; } + else if constexpr (methods::SubscriptionMethod::NoParamsNodeChange) + { + return { _pimpl->getNodeChange(std::move(idArg)) }; + } else { throw std::runtime_error(R"ex(Subscription::getNodeChange is not implemented)ex"); } } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::SubscriptionMethod::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::SubscriptionMethod::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + private: const std::shared_ptr _pimpl; }; @@ -1768,28 +2172,16 @@ class Appointment { } - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::AppointmentStubs::HasBeginSelectionSet) - { - _pimpl->beginSelectionSet(params); - } - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::AppointmentStubs::HasEndSelectionSet) - { - _pimpl->endSelectionSet(params); - } - } - service::FieldResult getId(service::FieldParams&& params) const final { - if constexpr (stub::AppointmentStubs::HasId) + if constexpr (methods::AppointmentMethod::WithParamsId) { return { _pimpl->getId(std::move(params)) }; } + else if constexpr (methods::AppointmentMethod::NoParamsId) + { + return { _pimpl->getId() }; + } else { throw std::runtime_error(R"ex(Appointment::getId is not implemented)ex"); @@ -1798,10 +2190,14 @@ class Appointment service::FieldResult> getWhen(service::FieldParams&& params) const final { - if constexpr (stub::AppointmentStubs::HasWhen) + if constexpr (methods::AppointmentMethod::WithParamsWhen) { return { _pimpl->getWhen(std::move(params)) }; } + else if constexpr (methods::AppointmentMethod::NoParamsWhen) + { + return { _pimpl->getWhen() }; + } else { throw std::runtime_error(R"ex(Appointment::getWhen is not implemented)ex"); @@ -1810,10 +2206,14 @@ class Appointment service::FieldResult> getSubject(service::FieldParams&& params) const final { - if constexpr (stub::AppointmentStubs::HasSubject) + if constexpr (methods::AppointmentMethod::WithParamsSubject) { return { _pimpl->getSubject(std::move(params)) }; } + else if constexpr (methods::AppointmentMethod::NoParamsSubject) + { + return { _pimpl->getSubject() }; + } else { throw std::runtime_error(R"ex(Appointment::getSubject is not implemented)ex"); @@ -1822,10 +2222,14 @@ class Appointment service::FieldResult getIsNow(service::FieldParams&& params) const final { - if constexpr (stub::AppointmentStubs::HasIsNow) + if constexpr (methods::AppointmentMethod::WithParamsIsNow) { return { _pimpl->getIsNow(std::move(params)) }; } + else if constexpr (methods::AppointmentMethod::NoParamsIsNow) + { + return { _pimpl->getIsNow() }; + } else { throw std::runtime_error(R"ex(Appointment::getIsNow is not implemented)ex"); @@ -1834,16 +2238,36 @@ class Appointment service::FieldResult> getForceError(service::FieldParams&& params) const final { - if constexpr (stub::AppointmentStubs::HasForceError) + if constexpr (methods::AppointmentMethod::WithParamsForceError) { return { _pimpl->getForceError(std::move(params)) }; } + else if constexpr (methods::AppointmentMethod::NoParamsForceError) + { + return { _pimpl->getForceError() }; + } else { throw std::runtime_error(R"ex(Appointment::getForceError is not implemented)ex"); } } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::AppointmentMethod::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::AppointmentMethod::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + private: const std::shared_ptr _pimpl; }; @@ -1894,28 +2318,16 @@ class Task { } - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::TaskStubs::HasBeginSelectionSet) - { - _pimpl->beginSelectionSet(params); - } - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::TaskStubs::HasEndSelectionSet) - { - _pimpl->endSelectionSet(params); - } - } - service::FieldResult getId(service::FieldParams&& params) const final { - if constexpr (stub::TaskStubs::HasId) + if constexpr (methods::TaskMethod::WithParamsId) { return { _pimpl->getId(std::move(params)) }; } + else if constexpr (methods::TaskMethod::NoParamsId) + { + return { _pimpl->getId() }; + } else { throw std::runtime_error(R"ex(Task::getId is not implemented)ex"); @@ -1924,10 +2336,14 @@ class Task service::FieldResult> getTitle(service::FieldParams&& params) const final { - if constexpr (stub::TaskStubs::HasTitle) + if constexpr (methods::TaskMethod::WithParamsTitle) { return { _pimpl->getTitle(std::move(params)) }; } + else if constexpr (methods::TaskMethod::NoParamsTitle) + { + return { _pimpl->getTitle() }; + } else { throw std::runtime_error(R"ex(Task::getTitle is not implemented)ex"); @@ -1936,16 +2352,36 @@ class Task service::FieldResult getIsComplete(service::FieldParams&& params) const final { - if constexpr (stub::TaskStubs::HasIsComplete) + if constexpr (methods::TaskMethod::WithParamsIsComplete) { return { _pimpl->getIsComplete(std::move(params)) }; } + else if constexpr (methods::TaskMethod::NoParamsIsComplete) + { + return { _pimpl->getIsComplete() }; + } else { throw std::runtime_error(R"ex(Task::getIsComplete is not implemented)ex"); } } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::TaskMethod::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::TaskMethod::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + private: const std::shared_ptr _pimpl; }; @@ -1996,28 +2432,16 @@ class Folder { } - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::FolderStubs::HasBeginSelectionSet) - { - _pimpl->beginSelectionSet(params); - } - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::FolderStubs::HasEndSelectionSet) - { - _pimpl->endSelectionSet(params); - } - } - service::FieldResult getId(service::FieldParams&& params) const final { - if constexpr (stub::FolderStubs::HasId) + if constexpr (methods::FolderMethod::WithParamsId) { return { _pimpl->getId(std::move(params)) }; } + else if constexpr (methods::FolderMethod::NoParamsId) + { + return { _pimpl->getId() }; + } else { throw std::runtime_error(R"ex(Folder::getId is not implemented)ex"); @@ -2026,10 +2450,14 @@ class Folder service::FieldResult> getName(service::FieldParams&& params) const final { - if constexpr (stub::FolderStubs::HasName) + if constexpr (methods::FolderMethod::WithParamsName) { return { _pimpl->getName(std::move(params)) }; } + else if constexpr (methods::FolderMethod::NoParamsName) + { + return { _pimpl->getName() }; + } else { throw std::runtime_error(R"ex(Folder::getName is not implemented)ex"); @@ -2038,16 +2466,36 @@ class Folder service::FieldResult getUnreadCount(service::FieldParams&& params) const final { - if constexpr (stub::FolderStubs::HasUnreadCount) + if constexpr (methods::FolderMethod::WithParamsUnreadCount) { return { _pimpl->getUnreadCount(std::move(params)) }; } + else if constexpr (methods::FolderMethod::NoParamsUnreadCount) + { + return { _pimpl->getUnreadCount() }; + } else { throw std::runtime_error(R"ex(Folder::getUnreadCount is not implemented)ex"); } } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::FolderMethod::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::FolderMethod::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + private: const std::shared_ptr _pimpl; }; @@ -2096,28 +2544,16 @@ class NestedType { } - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::NestedTypeStubs::HasBeginSelectionSet) - { - _pimpl->beginSelectionSet(params); - } - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::NestedTypeStubs::HasEndSelectionSet) - { - _pimpl->endSelectionSet(params); - } - } - service::FieldResult getDepth(service::FieldParams&& params) const final { - if constexpr (stub::NestedTypeStubs::HasDepth) + if constexpr (methods::NestedTypeMethod::WithParamsDepth) { return { _pimpl->getDepth(std::move(params)) }; } + else if constexpr (methods::NestedTypeMethod::NoParamsDepth) + { + return { _pimpl->getDepth() }; + } else { throw std::runtime_error(R"ex(NestedType::getDepth is not implemented)ex"); @@ -2126,16 +2562,36 @@ class NestedType service::FieldResult> getNested(service::FieldParams&& params) const final { - if constexpr (stub::NestedTypeStubs::HasNested) + if constexpr (methods::NestedTypeMethod::WithParamsNested) { return { _pimpl->getNested(std::move(params)) }; } + else if constexpr (methods::NestedTypeMethod::NoParamsNested) + { + return { _pimpl->getNested() }; + } else { throw std::runtime_error(R"ex(NestedType::getNested is not implemented)ex"); } } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::NestedTypeMethod::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::NestedTypeMethod::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + private: const std::shared_ptr _pimpl; }; @@ -2182,31 +2638,35 @@ class Expensive { } - void beginSelectionSet(const service::SelectionSetParams& params) const final + service::FieldResult getOrder(service::FieldParams&& params) const final { - if constexpr (stub::ExpensiveStubs::HasBeginSelectionSet) + if constexpr (methods::ExpensiveMethod::WithParamsOrder) { - _pimpl->beginSelectionSet(params); + return { _pimpl->getOrder(std::move(params)) }; + } + else if constexpr (methods::ExpensiveMethod::NoParamsOrder) + { + return { _pimpl->getOrder() }; + } + else + { + throw std::runtime_error(R"ex(Expensive::getOrder is not implemented)ex"); } } - void endSelectionSet(const service::SelectionSetParams& params) const final + void beginSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (stub::ExpensiveStubs::HasEndSelectionSet) + if constexpr (methods::ExpensiveMethod::HasBeginSelectionSet) { - _pimpl->endSelectionSet(params); + _pimpl->beginSelectionSet(params); } } - service::FieldResult getOrder(service::FieldParams&& params) const final + void endSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (stub::ExpensiveStubs::HasOrder) + if constexpr (methods::ExpensiveMethod::HasEndSelectionSet) { - return { _pimpl->getOrder(std::move(params)) }; - } - else - { - throw std::runtime_error(R"ex(Expensive::getOrder is not implemented)ex"); + _pimpl->endSelectionSet(params); } } diff --git a/samples/unified_nointrospection/TodaySchema.h b/samples/unified_nointrospection/TodaySchema.h index efd717ff..462fef19 100644 --- a/samples/unified_nointrospection/TodaySchema.h +++ b/samples/unified_nointrospection/TodaySchema.h @@ -87,81 +87,153 @@ struct Node }; namespace object { -namespace stub { -namespace QueryStubs { +namespace methods { +namespace QueryMethod { template -concept HasNode = requires (TImpl impl, service::FieldParams params, response::IdType idArg) +concept WithParamsNode = requires (TImpl impl, service::FieldParams params, response::IdType idArg) { { service::FieldResult> { impl.getNode(std::move(params), std::move(idArg)) } }; }; template -concept HasAppointments = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) +concept NoParamsNode = requires (TImpl impl, response::IdType idArg) +{ + { service::FieldResult> { impl.getNode(std::move(idArg)) } }; +}; + +template +concept WithParamsAppointments = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) { { service::FieldResult> { impl.getAppointments(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; }; template -concept HasTasks = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) +concept NoParamsAppointments = requires (TImpl impl, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) +{ + { service::FieldResult> { impl.getAppointments(std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; +}; + +template +concept WithParamsTasks = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) { { service::FieldResult> { impl.getTasks(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; }; template -concept HasUnreadCounts = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) +concept NoParamsTasks = requires (TImpl impl, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) +{ + { service::FieldResult> { impl.getTasks(std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; +}; + +template +concept WithParamsUnreadCounts = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) { { service::FieldResult> { impl.getUnreadCounts(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; }; template -concept HasAppointmentsById = requires (TImpl impl, service::FieldParams params, std::vector idsArg) +concept NoParamsUnreadCounts = requires (TImpl impl, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) +{ + { service::FieldResult> { impl.getUnreadCounts(std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; +}; + +template +concept WithParamsAppointmentsById = requires (TImpl impl, service::FieldParams params, std::vector idsArg) { { service::FieldResult>> { impl.getAppointmentsById(std::move(params), std::move(idsArg)) } }; }; template -concept HasTasksById = requires (TImpl impl, service::FieldParams params, std::vector idsArg) +concept NoParamsAppointmentsById = requires (TImpl impl, std::vector idsArg) +{ + { service::FieldResult>> { impl.getAppointmentsById(std::move(idsArg)) } }; +}; + +template +concept WithParamsTasksById = requires (TImpl impl, service::FieldParams params, std::vector idsArg) { { service::FieldResult>> { impl.getTasksById(std::move(params), std::move(idsArg)) } }; }; template -concept HasUnreadCountsById = requires (TImpl impl, service::FieldParams params, std::vector idsArg) +concept NoParamsTasksById = requires (TImpl impl, std::vector idsArg) +{ + { service::FieldResult>> { impl.getTasksById(std::move(idsArg)) } }; +}; + +template +concept WithParamsUnreadCountsById = requires (TImpl impl, service::FieldParams params, std::vector idsArg) { { service::FieldResult>> { impl.getUnreadCountsById(std::move(params), std::move(idsArg)) } }; }; template -concept HasNested = requires (TImpl impl, service::FieldParams params) +concept NoParamsUnreadCountsById = requires (TImpl impl, std::vector idsArg) +{ + { service::FieldResult>> { impl.getUnreadCountsById(std::move(idsArg)) } }; +}; + +template +concept WithParamsNested = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getNested(std::move(params)) } }; }; template -concept HasUnimplemented = requires (TImpl impl, service::FieldParams params) +concept NoParamsNested = requires (TImpl impl) +{ + { service::FieldResult> { impl.getNested() } }; +}; + +template +concept WithParamsUnimplemented = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getUnimplemented(std::move(params)) } }; }; template -concept HasExpensive = requires (TImpl impl, service::FieldParams params) +concept NoParamsUnimplemented = requires (TImpl impl) +{ + { service::FieldResult { impl.getUnimplemented() } }; +}; + +template +concept WithParamsExpensive = requires (TImpl impl, service::FieldParams params) { { service::FieldResult>> { impl.getExpensive(std::move(params)) } }; }; template -concept HasTestTaskState = requires (TImpl impl, service::FieldParams params) +concept NoParamsExpensive = requires (TImpl impl) +{ + { service::FieldResult>> { impl.getExpensive() } }; +}; + +template +concept WithParamsTestTaskState = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getTestTaskState(std::move(params)) } }; }; template -concept HasAnyType = requires (TImpl impl, service::FieldParams params, std::vector idsArg) +concept NoParamsTestTaskState = requires (TImpl impl) +{ + { service::FieldResult { impl.getTestTaskState() } }; +}; + +template +concept WithParamsAnyType = requires (TImpl impl, service::FieldParams params, std::vector idsArg) { { service::FieldResult>> { impl.getAnyType(std::move(params), std::move(idsArg)) } }; }; +template +concept NoParamsAnyType = requires (TImpl impl, std::vector idsArg) +{ + { service::FieldResult>> { impl.getAnyType(std::move(idsArg)) } }; +}; + template concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { @@ -174,22 +246,34 @@ concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetPa { impl.endSelectionSet(params) }; }; -} // namespace QueryStubs +} // namespace QueryMethod -namespace PageInfoStubs { +namespace PageInfoMethod { template -concept HasHasNextPage = requires (TImpl impl, service::FieldParams params) +concept WithParamsHasNextPage = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getHasNextPage(std::move(params)) } }; }; template -concept HasHasPreviousPage = requires (TImpl impl, service::FieldParams params) +concept NoParamsHasNextPage = requires (TImpl impl) +{ + { service::FieldResult { impl.getHasNextPage() } }; +}; + +template +concept WithParamsHasPreviousPage = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getHasPreviousPage(std::move(params)) } }; }; +template +concept NoParamsHasPreviousPage = requires (TImpl impl) +{ + { service::FieldResult { impl.getHasPreviousPage() } }; +}; + template concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { @@ -202,22 +286,34 @@ concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetPa { impl.endSelectionSet(params) }; }; -} // namespace PageInfoStubs +} // namespace PageInfoMethod -namespace AppointmentEdgeStubs { +namespace AppointmentEdgeMethod { template -concept HasNode = requires (TImpl impl, service::FieldParams params) +concept WithParamsNode = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getNode(std::move(params)) } }; }; template -concept HasCursor = requires (TImpl impl, service::FieldParams params) +concept NoParamsNode = requires (TImpl impl) +{ + { service::FieldResult> { impl.getNode() } }; +}; + +template +concept WithParamsCursor = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getCursor(std::move(params)) } }; }; +template +concept NoParamsCursor = requires (TImpl impl) +{ + { service::FieldResult { impl.getCursor() } }; +}; + template concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { @@ -230,22 +326,34 @@ concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetPa { impl.endSelectionSet(params) }; }; -} // namespace AppointmentEdgeStubs +} // namespace AppointmentEdgeMethod -namespace AppointmentConnectionStubs { +namespace AppointmentConnectionMethod { template -concept HasPageInfo = requires (TImpl impl, service::FieldParams params) +concept WithParamsPageInfo = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getPageInfo(std::move(params)) } }; }; template -concept HasEdges = requires (TImpl impl, service::FieldParams params) +concept NoParamsPageInfo = requires (TImpl impl) +{ + { service::FieldResult> { impl.getPageInfo() } }; +}; + +template +concept WithParamsEdges = requires (TImpl impl, service::FieldParams params) { { service::FieldResult>>> { impl.getEdges(std::move(params)) } }; }; +template +concept NoParamsEdges = requires (TImpl impl) +{ + { service::FieldResult>>> { impl.getEdges() } }; +}; + template concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { @@ -258,22 +366,34 @@ concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetPa { impl.endSelectionSet(params) }; }; -} // namespace AppointmentConnectionStubs +} // namespace AppointmentConnectionMethod -namespace TaskEdgeStubs { +namespace TaskEdgeMethod { template -concept HasNode = requires (TImpl impl, service::FieldParams params) +concept WithParamsNode = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getNode(std::move(params)) } }; }; template -concept HasCursor = requires (TImpl impl, service::FieldParams params) +concept NoParamsNode = requires (TImpl impl) +{ + { service::FieldResult> { impl.getNode() } }; +}; + +template +concept WithParamsCursor = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getCursor(std::move(params)) } }; }; +template +concept NoParamsCursor = requires (TImpl impl) +{ + { service::FieldResult { impl.getCursor() } }; +}; + template concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { @@ -286,22 +406,34 @@ concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetPa { impl.endSelectionSet(params) }; }; -} // namespace TaskEdgeStubs +} // namespace TaskEdgeMethod -namespace TaskConnectionStubs { +namespace TaskConnectionMethod { template -concept HasPageInfo = requires (TImpl impl, service::FieldParams params) +concept WithParamsPageInfo = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getPageInfo(std::move(params)) } }; }; template -concept HasEdges = requires (TImpl impl, service::FieldParams params) +concept NoParamsPageInfo = requires (TImpl impl) +{ + { service::FieldResult> { impl.getPageInfo() } }; +}; + +template +concept WithParamsEdges = requires (TImpl impl, service::FieldParams params) { { service::FieldResult>>> { impl.getEdges(std::move(params)) } }; }; +template +concept NoParamsEdges = requires (TImpl impl) +{ + { service::FieldResult>>> { impl.getEdges() } }; +}; + template concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { @@ -314,22 +446,34 @@ concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetPa { impl.endSelectionSet(params) }; }; -} // namespace TaskConnectionStubs +} // namespace TaskConnectionMethod -namespace FolderEdgeStubs { +namespace FolderEdgeMethod { template -concept HasNode = requires (TImpl impl, service::FieldParams params) +concept WithParamsNode = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getNode(std::move(params)) } }; }; template -concept HasCursor = requires (TImpl impl, service::FieldParams params) +concept NoParamsNode = requires (TImpl impl) +{ + { service::FieldResult> { impl.getNode() } }; +}; + +template +concept WithParamsCursor = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getCursor(std::move(params)) } }; }; +template +concept NoParamsCursor = requires (TImpl impl) +{ + { service::FieldResult { impl.getCursor() } }; +}; + template concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { @@ -342,22 +486,34 @@ concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetPa { impl.endSelectionSet(params) }; }; -} // namespace FolderEdgeStubs +} // namespace FolderEdgeMethod -namespace FolderConnectionStubs { +namespace FolderConnectionMethod { template -concept HasPageInfo = requires (TImpl impl, service::FieldParams params) +concept WithParamsPageInfo = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getPageInfo(std::move(params)) } }; }; template -concept HasEdges = requires (TImpl impl, service::FieldParams params) +concept NoParamsPageInfo = requires (TImpl impl) +{ + { service::FieldResult> { impl.getPageInfo() } }; +}; + +template +concept WithParamsEdges = requires (TImpl impl, service::FieldParams params) { { service::FieldResult>>> { impl.getEdges(std::move(params)) } }; }; +template +concept NoParamsEdges = requires (TImpl impl) +{ + { service::FieldResult>>> { impl.getEdges() } }; +}; + template concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { @@ -370,22 +526,34 @@ concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetPa { impl.endSelectionSet(params) }; }; -} // namespace FolderConnectionStubs +} // namespace FolderConnectionMethod -namespace CompleteTaskPayloadStubs { +namespace CompleteTaskPayloadMethod { template -concept HasTask = requires (TImpl impl, service::FieldParams params) +concept WithParamsTask = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getTask(std::move(params)) } }; }; template -concept HasClientMutationId = requires (TImpl impl, service::FieldParams params) +concept NoParamsTask = requires (TImpl impl) +{ + { service::FieldResult> { impl.getTask() } }; +}; + +template +concept WithParamsClientMutationId = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getClientMutationId(std::move(params)) } }; }; +template +concept NoParamsClientMutationId = requires (TImpl impl) +{ + { service::FieldResult> { impl.getClientMutationId() } }; +}; + template concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { @@ -398,22 +566,34 @@ concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetPa { impl.endSelectionSet(params) }; }; -} // namespace CompleteTaskPayloadStubs +} // namespace CompleteTaskPayloadMethod -namespace MutationStubs { +namespace MutationMethod { template -concept HasCompleteTask = requires (TImpl impl, service::FieldParams params, CompleteTaskInput inputArg) +concept WithParamsCompleteTask = requires (TImpl impl, service::FieldParams params, CompleteTaskInput inputArg) { { service::FieldResult> { impl.applyCompleteTask(std::move(params), std::move(inputArg)) } }; }; template -concept HasSetFloat = requires (TImpl impl, service::FieldParams params, response::FloatType valueArg) +concept NoParamsCompleteTask = requires (TImpl impl, CompleteTaskInput inputArg) +{ + { service::FieldResult> { impl.applyCompleteTask(std::move(inputArg)) } }; +}; + +template +concept WithParamsSetFloat = requires (TImpl impl, service::FieldParams params, response::FloatType valueArg) { { service::FieldResult { impl.applySetFloat(std::move(params), std::move(valueArg)) } }; }; +template +concept NoParamsSetFloat = requires (TImpl impl, response::FloatType valueArg) +{ + { service::FieldResult { impl.applySetFloat(std::move(valueArg)) } }; +}; + template concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { @@ -426,22 +606,34 @@ concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetPa { impl.endSelectionSet(params) }; }; -} // namespace MutationStubs +} // namespace MutationMethod -namespace SubscriptionStubs { +namespace SubscriptionMethod { template -concept HasNextAppointmentChange = requires (TImpl impl, service::FieldParams params) +concept WithParamsNextAppointmentChange = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getNextAppointmentChange(std::move(params)) } }; }; template -concept HasNodeChange = requires (TImpl impl, service::FieldParams params, response::IdType idArg) +concept NoParamsNextAppointmentChange = requires (TImpl impl) +{ + { service::FieldResult> { impl.getNextAppointmentChange() } }; +}; + +template +concept WithParamsNodeChange = requires (TImpl impl, service::FieldParams params, response::IdType idArg) { { service::FieldResult> { impl.getNodeChange(std::move(params), std::move(idArg)) } }; }; +template +concept NoParamsNodeChange = requires (TImpl impl, response::IdType idArg) +{ + { service::FieldResult> { impl.getNodeChange(std::move(idArg)) } }; +}; + template concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { @@ -454,40 +646,70 @@ concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetPa { impl.endSelectionSet(params) }; }; -} // namespace SubscriptionStubs +} // namespace SubscriptionMethod -namespace AppointmentStubs { +namespace AppointmentMethod { template -concept HasId = requires (TImpl impl, service::FieldParams params) +concept WithParamsId = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getId(std::move(params)) } }; }; template -concept HasWhen = requires (TImpl impl, service::FieldParams params) +concept NoParamsId = requires (TImpl impl) +{ + { service::FieldResult { impl.getId() } }; +}; + +template +concept WithParamsWhen = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getWhen(std::move(params)) } }; }; template -concept HasSubject = requires (TImpl impl, service::FieldParams params) +concept NoParamsWhen = requires (TImpl impl) +{ + { service::FieldResult> { impl.getWhen() } }; +}; + +template +concept WithParamsSubject = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getSubject(std::move(params)) } }; }; template -concept HasIsNow = requires (TImpl impl, service::FieldParams params) +concept NoParamsSubject = requires (TImpl impl) +{ + { service::FieldResult> { impl.getSubject() } }; +}; + +template +concept WithParamsIsNow = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getIsNow(std::move(params)) } }; }; template -concept HasForceError = requires (TImpl impl, service::FieldParams params) +concept NoParamsIsNow = requires (TImpl impl) +{ + { service::FieldResult { impl.getIsNow() } }; +}; + +template +concept WithParamsForceError = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getForceError(std::move(params)) } }; }; +template +concept NoParamsForceError = requires (TImpl impl) +{ + { service::FieldResult> { impl.getForceError() } }; +}; + template concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { @@ -500,28 +722,46 @@ concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetPa { impl.endSelectionSet(params) }; }; -} // namespace AppointmentStubs +} // namespace AppointmentMethod -namespace TaskStubs { +namespace TaskMethod { template -concept HasId = requires (TImpl impl, service::FieldParams params) +concept WithParamsId = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getId(std::move(params)) } }; }; template -concept HasTitle = requires (TImpl impl, service::FieldParams params) +concept NoParamsId = requires (TImpl impl) +{ + { service::FieldResult { impl.getId() } }; +}; + +template +concept WithParamsTitle = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getTitle(std::move(params)) } }; }; template -concept HasIsComplete = requires (TImpl impl, service::FieldParams params) +concept NoParamsTitle = requires (TImpl impl) +{ + { service::FieldResult> { impl.getTitle() } }; +}; + +template +concept WithParamsIsComplete = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getIsComplete(std::move(params)) } }; }; +template +concept NoParamsIsComplete = requires (TImpl impl) +{ + { service::FieldResult { impl.getIsComplete() } }; +}; + template concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { @@ -534,28 +774,46 @@ concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetPa { impl.endSelectionSet(params) }; }; -} // namespace TaskStubs +} // namespace TaskMethod -namespace FolderStubs { +namespace FolderMethod { template -concept HasId = requires (TImpl impl, service::FieldParams params) +concept WithParamsId = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getId(std::move(params)) } }; }; template -concept HasName = requires (TImpl impl, service::FieldParams params) +concept NoParamsId = requires (TImpl impl) +{ + { service::FieldResult { impl.getId() } }; +}; + +template +concept WithParamsName = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getName(std::move(params)) } }; }; template -concept HasUnreadCount = requires (TImpl impl, service::FieldParams params) +concept NoParamsName = requires (TImpl impl) +{ + { service::FieldResult> { impl.getName() } }; +}; + +template +concept WithParamsUnreadCount = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getUnreadCount(std::move(params)) } }; }; +template +concept NoParamsUnreadCount = requires (TImpl impl) +{ + { service::FieldResult { impl.getUnreadCount() } }; +}; + template concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { @@ -568,22 +826,34 @@ concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetPa { impl.endSelectionSet(params) }; }; -} // namespace FolderStubs +} // namespace FolderMethod -namespace NestedTypeStubs { +namespace NestedTypeMethod { template -concept HasDepth = requires (TImpl impl, service::FieldParams params) +concept WithParamsDepth = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getDepth(std::move(params)) } }; }; template -concept HasNested = requires (TImpl impl, service::FieldParams params) +concept NoParamsDepth = requires (TImpl impl) +{ + { service::FieldResult { impl.getDepth() } }; +}; + +template +concept WithParamsNested = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getNested(std::move(params)) } }; }; +template +concept NoParamsNested = requires (TImpl impl) +{ + { service::FieldResult> { impl.getNested() } }; +}; + template concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { @@ -596,16 +866,22 @@ concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetPa { impl.endSelectionSet(params) }; }; -} // namespace NestedTypeStubs +} // namespace NestedTypeMethod -namespace ExpensiveStubs { +namespace ExpensiveMethod { template -concept HasOrder = requires (TImpl impl, service::FieldParams params) +concept WithParamsOrder = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getOrder(std::move(params)) } }; }; +template +concept NoParamsOrder = requires (TImpl impl) +{ + { service::FieldResult { impl.getOrder() } }; +}; + template concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { @@ -618,8 +894,8 @@ concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetPa { impl.endSelectionSet(params) }; }; -} // namespace ExpensiveStubs -} // namespace stub +} // namespace ExpensiveMethod +} // namespace methods class Query : public service::Object @@ -670,28 +946,16 @@ class Query { } - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::QueryStubs::HasBeginSelectionSet) - { - _pimpl->beginSelectionSet(params); - } - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::QueryStubs::HasEndSelectionSet) - { - _pimpl->endSelectionSet(params); - } - } - service::FieldResult> getNode(service::FieldParams&& params, response::IdType&& idArg) const final { - if constexpr (stub::QueryStubs::HasNode) + if constexpr (methods::QueryMethod::WithParamsNode) { return { _pimpl->getNode(std::move(params), std::move(idArg)) }; } + else if constexpr (methods::QueryMethod::NoParamsNode) + { + return { _pimpl->getNode(std::move(idArg)) }; + } else { throw std::runtime_error(R"ex(Query::getNode is not implemented)ex"); @@ -700,10 +964,14 @@ class Query service::FieldResult> getAppointments(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const final { - if constexpr (stub::QueryStubs::HasAppointments) + if constexpr (methods::QueryMethod::WithParamsAppointments) { return { _pimpl->getAppointments(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) }; } + else if constexpr (methods::QueryMethod::NoParamsAppointments) + { + return { _pimpl->getAppointments(std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) }; + } else { throw std::runtime_error(R"ex(Query::getAppointments is not implemented)ex"); @@ -712,10 +980,14 @@ class Query service::FieldResult> getTasks(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const final { - if constexpr (stub::QueryStubs::HasTasks) + if constexpr (methods::QueryMethod::WithParamsTasks) { return { _pimpl->getTasks(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) }; } + else if constexpr (methods::QueryMethod::NoParamsTasks) + { + return { _pimpl->getTasks(std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) }; + } else { throw std::runtime_error(R"ex(Query::getTasks is not implemented)ex"); @@ -724,10 +996,14 @@ class Query service::FieldResult> getUnreadCounts(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const final { - if constexpr (stub::QueryStubs::HasUnreadCounts) + if constexpr (methods::QueryMethod::WithParamsUnreadCounts) { return { _pimpl->getUnreadCounts(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) }; } + else if constexpr (methods::QueryMethod::NoParamsUnreadCounts) + { + return { _pimpl->getUnreadCounts(std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) }; + } else { throw std::runtime_error(R"ex(Query::getUnreadCounts is not implemented)ex"); @@ -736,10 +1012,14 @@ class Query service::FieldResult>> getAppointmentsById(service::FieldParams&& params, std::vector&& idsArg) const final { - if constexpr (stub::QueryStubs::HasAppointmentsById) + if constexpr (methods::QueryMethod::WithParamsAppointmentsById) { return { _pimpl->getAppointmentsById(std::move(params), std::move(idsArg)) }; } + else if constexpr (methods::QueryMethod::NoParamsAppointmentsById) + { + return { _pimpl->getAppointmentsById(std::move(idsArg)) }; + } else { throw std::runtime_error(R"ex(Query::getAppointmentsById is not implemented)ex"); @@ -748,10 +1028,14 @@ class Query service::FieldResult>> getTasksById(service::FieldParams&& params, std::vector&& idsArg) const final { - if constexpr (stub::QueryStubs::HasTasksById) + if constexpr (methods::QueryMethod::WithParamsTasksById) { return { _pimpl->getTasksById(std::move(params), std::move(idsArg)) }; } + else if constexpr (methods::QueryMethod::NoParamsTasksById) + { + return { _pimpl->getTasksById(std::move(idsArg)) }; + } else { throw std::runtime_error(R"ex(Query::getTasksById is not implemented)ex"); @@ -760,10 +1044,14 @@ class Query service::FieldResult>> getUnreadCountsById(service::FieldParams&& params, std::vector&& idsArg) const final { - if constexpr (stub::QueryStubs::HasUnreadCountsById) + if constexpr (methods::QueryMethod::WithParamsUnreadCountsById) { return { _pimpl->getUnreadCountsById(std::move(params), std::move(idsArg)) }; } + else if constexpr (methods::QueryMethod::NoParamsUnreadCountsById) + { + return { _pimpl->getUnreadCountsById(std::move(idsArg)) }; + } else { throw std::runtime_error(R"ex(Query::getUnreadCountsById is not implemented)ex"); @@ -772,10 +1060,14 @@ class Query service::FieldResult> getNested(service::FieldParams&& params) const final { - if constexpr (stub::QueryStubs::HasNested) + if constexpr (methods::QueryMethod::WithParamsNested) { return { _pimpl->getNested(std::move(params)) }; } + else if constexpr (methods::QueryMethod::NoParamsNested) + { + return { _pimpl->getNested() }; + } else { throw std::runtime_error(R"ex(Query::getNested is not implemented)ex"); @@ -784,10 +1076,14 @@ class Query service::FieldResult getUnimplemented(service::FieldParams&& params) const final { - if constexpr (stub::QueryStubs::HasUnimplemented) + if constexpr (methods::QueryMethod::WithParamsUnimplemented) { return { _pimpl->getUnimplemented(std::move(params)) }; } + else if constexpr (methods::QueryMethod::NoParamsUnimplemented) + { + return { _pimpl->getUnimplemented() }; + } else { throw std::runtime_error(R"ex(Query::getUnimplemented is not implemented)ex"); @@ -796,10 +1092,14 @@ class Query service::FieldResult>> getExpensive(service::FieldParams&& params) const final { - if constexpr (stub::QueryStubs::HasExpensive) + if constexpr (methods::QueryMethod::WithParamsExpensive) { return { _pimpl->getExpensive(std::move(params)) }; } + else if constexpr (methods::QueryMethod::NoParamsExpensive) + { + return { _pimpl->getExpensive() }; + } else { throw std::runtime_error(R"ex(Query::getExpensive is not implemented)ex"); @@ -808,10 +1108,14 @@ class Query service::FieldResult getTestTaskState(service::FieldParams&& params) const final { - if constexpr (stub::QueryStubs::HasTestTaskState) + if constexpr (methods::QueryMethod::WithParamsTestTaskState) { return { _pimpl->getTestTaskState(std::move(params)) }; } + else if constexpr (methods::QueryMethod::NoParamsTestTaskState) + { + return { _pimpl->getTestTaskState() }; + } else { throw std::runtime_error(R"ex(Query::getTestTaskState is not implemented)ex"); @@ -820,16 +1124,36 @@ class Query service::FieldResult>> getAnyType(service::FieldParams&& params, std::vector&& idsArg) const final { - if constexpr (stub::QueryStubs::HasAnyType) + if constexpr (methods::QueryMethod::WithParamsAnyType) { return { _pimpl->getAnyType(std::move(params), std::move(idsArg)) }; } + else if constexpr (methods::QueryMethod::NoParamsAnyType) + { + return { _pimpl->getAnyType(std::move(idsArg)) }; + } else { throw std::runtime_error(R"ex(Query::getAnyType is not implemented)ex"); } } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::QueryMethod::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::QueryMethod::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + private: const std::shared_ptr _pimpl; }; @@ -878,28 +1202,16 @@ class PageInfo { } - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::PageInfoStubs::HasBeginSelectionSet) - { - _pimpl->beginSelectionSet(params); - } - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::PageInfoStubs::HasEndSelectionSet) - { - _pimpl->endSelectionSet(params); - } - } - service::FieldResult getHasNextPage(service::FieldParams&& params) const final { - if constexpr (stub::PageInfoStubs::HasHasNextPage) + if constexpr (methods::PageInfoMethod::WithParamsHasNextPage) { return { _pimpl->getHasNextPage(std::move(params)) }; } + else if constexpr (methods::PageInfoMethod::NoParamsHasNextPage) + { + return { _pimpl->getHasNextPage() }; + } else { throw std::runtime_error(R"ex(PageInfo::getHasNextPage is not implemented)ex"); @@ -908,18 +1220,38 @@ class PageInfo service::FieldResult getHasPreviousPage(service::FieldParams&& params) const final { - if constexpr (stub::PageInfoStubs::HasHasPreviousPage) + if constexpr (methods::PageInfoMethod::WithParamsHasPreviousPage) { return { _pimpl->getHasPreviousPage(std::move(params)) }; } + else if constexpr (methods::PageInfoMethod::NoParamsHasPreviousPage) + { + return { _pimpl->getHasPreviousPage() }; + } else { throw std::runtime_error(R"ex(PageInfo::getHasPreviousPage is not implemented)ex"); } } - private: - const std::shared_ptr _pimpl; + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::PageInfoMethod::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::PageInfoMethod::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + + private: + const std::shared_ptr _pimpl; }; PageInfo(std::unique_ptr&& pimpl); @@ -966,28 +1298,16 @@ class AppointmentEdge { } - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::AppointmentEdgeStubs::HasBeginSelectionSet) - { - _pimpl->beginSelectionSet(params); - } - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::AppointmentEdgeStubs::HasEndSelectionSet) - { - _pimpl->endSelectionSet(params); - } - } - service::FieldResult> getNode(service::FieldParams&& params) const final { - if constexpr (stub::AppointmentEdgeStubs::HasNode) + if constexpr (methods::AppointmentEdgeMethod::WithParamsNode) { return { _pimpl->getNode(std::move(params)) }; } + else if constexpr (methods::AppointmentEdgeMethod::NoParamsNode) + { + return { _pimpl->getNode() }; + } else { throw std::runtime_error(R"ex(AppointmentEdge::getNode is not implemented)ex"); @@ -996,16 +1316,36 @@ class AppointmentEdge service::FieldResult getCursor(service::FieldParams&& params) const final { - if constexpr (stub::AppointmentEdgeStubs::HasCursor) + if constexpr (methods::AppointmentEdgeMethod::WithParamsCursor) { return { _pimpl->getCursor(std::move(params)) }; } + else if constexpr (methods::AppointmentEdgeMethod::NoParamsCursor) + { + return { _pimpl->getCursor() }; + } else { throw std::runtime_error(R"ex(AppointmentEdge::getCursor is not implemented)ex"); } } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::AppointmentEdgeMethod::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::AppointmentEdgeMethod::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + private: const std::shared_ptr _pimpl; }; @@ -1054,28 +1394,16 @@ class AppointmentConnection { } - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::AppointmentConnectionStubs::HasBeginSelectionSet) - { - _pimpl->beginSelectionSet(params); - } - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::AppointmentConnectionStubs::HasEndSelectionSet) - { - _pimpl->endSelectionSet(params); - } - } - service::FieldResult> getPageInfo(service::FieldParams&& params) const final { - if constexpr (stub::AppointmentConnectionStubs::HasPageInfo) + if constexpr (methods::AppointmentConnectionMethod::WithParamsPageInfo) { return { _pimpl->getPageInfo(std::move(params)) }; } + else if constexpr (methods::AppointmentConnectionMethod::NoParamsPageInfo) + { + return { _pimpl->getPageInfo() }; + } else { throw std::runtime_error(R"ex(AppointmentConnection::getPageInfo is not implemented)ex"); @@ -1084,16 +1412,36 @@ class AppointmentConnection service::FieldResult>>> getEdges(service::FieldParams&& params) const final { - if constexpr (stub::AppointmentConnectionStubs::HasEdges) + if constexpr (methods::AppointmentConnectionMethod::WithParamsEdges) { return { _pimpl->getEdges(std::move(params)) }; } + else if constexpr (methods::AppointmentConnectionMethod::NoParamsEdges) + { + return { _pimpl->getEdges() }; + } else { throw std::runtime_error(R"ex(AppointmentConnection::getEdges is not implemented)ex"); } } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::AppointmentConnectionMethod::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::AppointmentConnectionMethod::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + private: const std::shared_ptr _pimpl; }; @@ -1142,28 +1490,16 @@ class TaskEdge { } - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::TaskEdgeStubs::HasBeginSelectionSet) - { - _pimpl->beginSelectionSet(params); - } - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::TaskEdgeStubs::HasEndSelectionSet) - { - _pimpl->endSelectionSet(params); - } - } - service::FieldResult> getNode(service::FieldParams&& params) const final { - if constexpr (stub::TaskEdgeStubs::HasNode) + if constexpr (methods::TaskEdgeMethod::WithParamsNode) { return { _pimpl->getNode(std::move(params)) }; } + else if constexpr (methods::TaskEdgeMethod::NoParamsNode) + { + return { _pimpl->getNode() }; + } else { throw std::runtime_error(R"ex(TaskEdge::getNode is not implemented)ex"); @@ -1172,16 +1508,36 @@ class TaskEdge service::FieldResult getCursor(service::FieldParams&& params) const final { - if constexpr (stub::TaskEdgeStubs::HasCursor) + if constexpr (methods::TaskEdgeMethod::WithParamsCursor) { return { _pimpl->getCursor(std::move(params)) }; } + else if constexpr (methods::TaskEdgeMethod::NoParamsCursor) + { + return { _pimpl->getCursor() }; + } else { throw std::runtime_error(R"ex(TaskEdge::getCursor is not implemented)ex"); } } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::TaskEdgeMethod::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::TaskEdgeMethod::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + private: const std::shared_ptr _pimpl; }; @@ -1230,28 +1586,16 @@ class TaskConnection { } - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::TaskConnectionStubs::HasBeginSelectionSet) - { - _pimpl->beginSelectionSet(params); - } - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::TaskConnectionStubs::HasEndSelectionSet) - { - _pimpl->endSelectionSet(params); - } - } - service::FieldResult> getPageInfo(service::FieldParams&& params) const final { - if constexpr (stub::TaskConnectionStubs::HasPageInfo) + if constexpr (methods::TaskConnectionMethod::WithParamsPageInfo) { return { _pimpl->getPageInfo(std::move(params)) }; } + else if constexpr (methods::TaskConnectionMethod::NoParamsPageInfo) + { + return { _pimpl->getPageInfo() }; + } else { throw std::runtime_error(R"ex(TaskConnection::getPageInfo is not implemented)ex"); @@ -1260,16 +1604,36 @@ class TaskConnection service::FieldResult>>> getEdges(service::FieldParams&& params) const final { - if constexpr (stub::TaskConnectionStubs::HasEdges) + if constexpr (methods::TaskConnectionMethod::WithParamsEdges) { return { _pimpl->getEdges(std::move(params)) }; } + else if constexpr (methods::TaskConnectionMethod::NoParamsEdges) + { + return { _pimpl->getEdges() }; + } else { throw std::runtime_error(R"ex(TaskConnection::getEdges is not implemented)ex"); } } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::TaskConnectionMethod::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::TaskConnectionMethod::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + private: const std::shared_ptr _pimpl; }; @@ -1318,28 +1682,16 @@ class FolderEdge { } - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::FolderEdgeStubs::HasBeginSelectionSet) - { - _pimpl->beginSelectionSet(params); - } - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::FolderEdgeStubs::HasEndSelectionSet) - { - _pimpl->endSelectionSet(params); - } - } - service::FieldResult> getNode(service::FieldParams&& params) const final { - if constexpr (stub::FolderEdgeStubs::HasNode) + if constexpr (methods::FolderEdgeMethod::WithParamsNode) { return { _pimpl->getNode(std::move(params)) }; } + else if constexpr (methods::FolderEdgeMethod::NoParamsNode) + { + return { _pimpl->getNode() }; + } else { throw std::runtime_error(R"ex(FolderEdge::getNode is not implemented)ex"); @@ -1348,16 +1700,36 @@ class FolderEdge service::FieldResult getCursor(service::FieldParams&& params) const final { - if constexpr (stub::FolderEdgeStubs::HasCursor) + if constexpr (methods::FolderEdgeMethod::WithParamsCursor) { return { _pimpl->getCursor(std::move(params)) }; } + else if constexpr (methods::FolderEdgeMethod::NoParamsCursor) + { + return { _pimpl->getCursor() }; + } else { throw std::runtime_error(R"ex(FolderEdge::getCursor is not implemented)ex"); } } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::FolderEdgeMethod::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::FolderEdgeMethod::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + private: const std::shared_ptr _pimpl; }; @@ -1406,28 +1778,16 @@ class FolderConnection { } - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::FolderConnectionStubs::HasBeginSelectionSet) - { - _pimpl->beginSelectionSet(params); - } - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::FolderConnectionStubs::HasEndSelectionSet) - { - _pimpl->endSelectionSet(params); - } - } - service::FieldResult> getPageInfo(service::FieldParams&& params) const final { - if constexpr (stub::FolderConnectionStubs::HasPageInfo) + if constexpr (methods::FolderConnectionMethod::WithParamsPageInfo) { return { _pimpl->getPageInfo(std::move(params)) }; } + else if constexpr (methods::FolderConnectionMethod::NoParamsPageInfo) + { + return { _pimpl->getPageInfo() }; + } else { throw std::runtime_error(R"ex(FolderConnection::getPageInfo is not implemented)ex"); @@ -1436,16 +1796,36 @@ class FolderConnection service::FieldResult>>> getEdges(service::FieldParams&& params) const final { - if constexpr (stub::FolderConnectionStubs::HasEdges) + if constexpr (methods::FolderConnectionMethod::WithParamsEdges) { return { _pimpl->getEdges(std::move(params)) }; } + else if constexpr (methods::FolderConnectionMethod::NoParamsEdges) + { + return { _pimpl->getEdges() }; + } else { throw std::runtime_error(R"ex(FolderConnection::getEdges is not implemented)ex"); } } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::FolderConnectionMethod::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::FolderConnectionMethod::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + private: const std::shared_ptr _pimpl; }; @@ -1494,28 +1874,16 @@ class CompleteTaskPayload { } - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::CompleteTaskPayloadStubs::HasBeginSelectionSet) - { - _pimpl->beginSelectionSet(params); - } - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::CompleteTaskPayloadStubs::HasEndSelectionSet) - { - _pimpl->endSelectionSet(params); - } - } - service::FieldResult> getTask(service::FieldParams&& params) const final { - if constexpr (stub::CompleteTaskPayloadStubs::HasTask) + if constexpr (methods::CompleteTaskPayloadMethod::WithParamsTask) { return { _pimpl->getTask(std::move(params)) }; } + else if constexpr (methods::CompleteTaskPayloadMethod::NoParamsTask) + { + return { _pimpl->getTask() }; + } else { throw std::runtime_error(R"ex(CompleteTaskPayload::getTask is not implemented)ex"); @@ -1524,16 +1892,36 @@ class CompleteTaskPayload service::FieldResult> getClientMutationId(service::FieldParams&& params) const final { - if constexpr (stub::CompleteTaskPayloadStubs::HasClientMutationId) + if constexpr (methods::CompleteTaskPayloadMethod::WithParamsClientMutationId) { return { _pimpl->getClientMutationId(std::move(params)) }; } + else if constexpr (methods::CompleteTaskPayloadMethod::NoParamsClientMutationId) + { + return { _pimpl->getClientMutationId() }; + } else { throw std::runtime_error(R"ex(CompleteTaskPayload::getClientMutationId is not implemented)ex"); } } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::CompleteTaskPayloadMethod::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::CompleteTaskPayloadMethod::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + private: const std::shared_ptr _pimpl; }; @@ -1582,28 +1970,16 @@ class Mutation { } - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::MutationStubs::HasBeginSelectionSet) - { - _pimpl->beginSelectionSet(params); - } - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::MutationStubs::HasEndSelectionSet) - { - _pimpl->endSelectionSet(params); - } - } - service::FieldResult> applyCompleteTask(service::FieldParams&& params, CompleteTaskInput&& inputArg) const final { - if constexpr (stub::MutationStubs::HasCompleteTask) + if constexpr (methods::MutationMethod::WithParamsCompleteTask) { return { _pimpl->applyCompleteTask(std::move(params), std::move(inputArg)) }; } + else if constexpr (methods::MutationMethod::NoParamsCompleteTask) + { + return { _pimpl->applyCompleteTask(std::move(inputArg)) }; + } else { throw std::runtime_error(R"ex(Mutation::applyCompleteTask is not implemented)ex"); @@ -1612,16 +1988,36 @@ class Mutation service::FieldResult applySetFloat(service::FieldParams&& params, response::FloatType&& valueArg) const final { - if constexpr (stub::MutationStubs::HasSetFloat) + if constexpr (methods::MutationMethod::WithParamsSetFloat) { return { _pimpl->applySetFloat(std::move(params), std::move(valueArg)) }; } + else if constexpr (methods::MutationMethod::NoParamsSetFloat) + { + return { _pimpl->applySetFloat(std::move(valueArg)) }; + } else { throw std::runtime_error(R"ex(Mutation::applySetFloat is not implemented)ex"); } } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::MutationMethod::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::MutationMethod::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + private: const std::shared_ptr _pimpl; }; @@ -1670,28 +2066,16 @@ class Subscription { } - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::SubscriptionStubs::HasBeginSelectionSet) - { - _pimpl->beginSelectionSet(params); - } - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::SubscriptionStubs::HasEndSelectionSet) - { - _pimpl->endSelectionSet(params); - } - } - service::FieldResult> getNextAppointmentChange(service::FieldParams&& params) const final { - if constexpr (stub::SubscriptionStubs::HasNextAppointmentChange) + if constexpr (methods::SubscriptionMethod::WithParamsNextAppointmentChange) { return { _pimpl->getNextAppointmentChange(std::move(params)) }; } + else if constexpr (methods::SubscriptionMethod::NoParamsNextAppointmentChange) + { + return { _pimpl->getNextAppointmentChange() }; + } else { throw std::runtime_error(R"ex(Subscription::getNextAppointmentChange is not implemented)ex"); @@ -1700,16 +2084,36 @@ class Subscription service::FieldResult> getNodeChange(service::FieldParams&& params, response::IdType&& idArg) const final { - if constexpr (stub::SubscriptionStubs::HasNodeChange) + if constexpr (methods::SubscriptionMethod::WithParamsNodeChange) { return { _pimpl->getNodeChange(std::move(params), std::move(idArg)) }; } + else if constexpr (methods::SubscriptionMethod::NoParamsNodeChange) + { + return { _pimpl->getNodeChange(std::move(idArg)) }; + } else { throw std::runtime_error(R"ex(Subscription::getNodeChange is not implemented)ex"); } } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::SubscriptionMethod::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::SubscriptionMethod::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + private: const std::shared_ptr _pimpl; }; @@ -1764,28 +2168,16 @@ class Appointment { } - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::AppointmentStubs::HasBeginSelectionSet) - { - _pimpl->beginSelectionSet(params); - } - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::AppointmentStubs::HasEndSelectionSet) - { - _pimpl->endSelectionSet(params); - } - } - service::FieldResult getId(service::FieldParams&& params) const final { - if constexpr (stub::AppointmentStubs::HasId) + if constexpr (methods::AppointmentMethod::WithParamsId) { return { _pimpl->getId(std::move(params)) }; } + else if constexpr (methods::AppointmentMethod::NoParamsId) + { + return { _pimpl->getId() }; + } else { throw std::runtime_error(R"ex(Appointment::getId is not implemented)ex"); @@ -1794,10 +2186,14 @@ class Appointment service::FieldResult> getWhen(service::FieldParams&& params) const final { - if constexpr (stub::AppointmentStubs::HasWhen) + if constexpr (methods::AppointmentMethod::WithParamsWhen) { return { _pimpl->getWhen(std::move(params)) }; } + else if constexpr (methods::AppointmentMethod::NoParamsWhen) + { + return { _pimpl->getWhen() }; + } else { throw std::runtime_error(R"ex(Appointment::getWhen is not implemented)ex"); @@ -1806,10 +2202,14 @@ class Appointment service::FieldResult> getSubject(service::FieldParams&& params) const final { - if constexpr (stub::AppointmentStubs::HasSubject) + if constexpr (methods::AppointmentMethod::WithParamsSubject) { return { _pimpl->getSubject(std::move(params)) }; } + else if constexpr (methods::AppointmentMethod::NoParamsSubject) + { + return { _pimpl->getSubject() }; + } else { throw std::runtime_error(R"ex(Appointment::getSubject is not implemented)ex"); @@ -1818,10 +2218,14 @@ class Appointment service::FieldResult getIsNow(service::FieldParams&& params) const final { - if constexpr (stub::AppointmentStubs::HasIsNow) + if constexpr (methods::AppointmentMethod::WithParamsIsNow) { return { _pimpl->getIsNow(std::move(params)) }; } + else if constexpr (methods::AppointmentMethod::NoParamsIsNow) + { + return { _pimpl->getIsNow() }; + } else { throw std::runtime_error(R"ex(Appointment::getIsNow is not implemented)ex"); @@ -1830,16 +2234,36 @@ class Appointment service::FieldResult> getForceError(service::FieldParams&& params) const final { - if constexpr (stub::AppointmentStubs::HasForceError) + if constexpr (methods::AppointmentMethod::WithParamsForceError) { return { _pimpl->getForceError(std::move(params)) }; } + else if constexpr (methods::AppointmentMethod::NoParamsForceError) + { + return { _pimpl->getForceError() }; + } else { throw std::runtime_error(R"ex(Appointment::getForceError is not implemented)ex"); } } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::AppointmentMethod::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::AppointmentMethod::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + private: const std::shared_ptr _pimpl; }; @@ -1890,28 +2314,16 @@ class Task { } - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::TaskStubs::HasBeginSelectionSet) - { - _pimpl->beginSelectionSet(params); - } - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::TaskStubs::HasEndSelectionSet) - { - _pimpl->endSelectionSet(params); - } - } - service::FieldResult getId(service::FieldParams&& params) const final { - if constexpr (stub::TaskStubs::HasId) + if constexpr (methods::TaskMethod::WithParamsId) { return { _pimpl->getId(std::move(params)) }; } + else if constexpr (methods::TaskMethod::NoParamsId) + { + return { _pimpl->getId() }; + } else { throw std::runtime_error(R"ex(Task::getId is not implemented)ex"); @@ -1920,10 +2332,14 @@ class Task service::FieldResult> getTitle(service::FieldParams&& params) const final { - if constexpr (stub::TaskStubs::HasTitle) + if constexpr (methods::TaskMethod::WithParamsTitle) { return { _pimpl->getTitle(std::move(params)) }; } + else if constexpr (methods::TaskMethod::NoParamsTitle) + { + return { _pimpl->getTitle() }; + } else { throw std::runtime_error(R"ex(Task::getTitle is not implemented)ex"); @@ -1932,16 +2348,36 @@ class Task service::FieldResult getIsComplete(service::FieldParams&& params) const final { - if constexpr (stub::TaskStubs::HasIsComplete) + if constexpr (methods::TaskMethod::WithParamsIsComplete) { return { _pimpl->getIsComplete(std::move(params)) }; } + else if constexpr (methods::TaskMethod::NoParamsIsComplete) + { + return { _pimpl->getIsComplete() }; + } else { throw std::runtime_error(R"ex(Task::getIsComplete is not implemented)ex"); } } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::TaskMethod::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::TaskMethod::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + private: const std::shared_ptr _pimpl; }; @@ -1992,28 +2428,16 @@ class Folder { } - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::FolderStubs::HasBeginSelectionSet) - { - _pimpl->beginSelectionSet(params); - } - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::FolderStubs::HasEndSelectionSet) - { - _pimpl->endSelectionSet(params); - } - } - service::FieldResult getId(service::FieldParams&& params) const final { - if constexpr (stub::FolderStubs::HasId) + if constexpr (methods::FolderMethod::WithParamsId) { return { _pimpl->getId(std::move(params)) }; } + else if constexpr (methods::FolderMethod::NoParamsId) + { + return { _pimpl->getId() }; + } else { throw std::runtime_error(R"ex(Folder::getId is not implemented)ex"); @@ -2022,10 +2446,14 @@ class Folder service::FieldResult> getName(service::FieldParams&& params) const final { - if constexpr (stub::FolderStubs::HasName) + if constexpr (methods::FolderMethod::WithParamsName) { return { _pimpl->getName(std::move(params)) }; } + else if constexpr (methods::FolderMethod::NoParamsName) + { + return { _pimpl->getName() }; + } else { throw std::runtime_error(R"ex(Folder::getName is not implemented)ex"); @@ -2034,16 +2462,36 @@ class Folder service::FieldResult getUnreadCount(service::FieldParams&& params) const final { - if constexpr (stub::FolderStubs::HasUnreadCount) + if constexpr (methods::FolderMethod::WithParamsUnreadCount) { return { _pimpl->getUnreadCount(std::move(params)) }; } + else if constexpr (methods::FolderMethod::NoParamsUnreadCount) + { + return { _pimpl->getUnreadCount() }; + } else { throw std::runtime_error(R"ex(Folder::getUnreadCount is not implemented)ex"); } } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::FolderMethod::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::FolderMethod::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + private: const std::shared_ptr _pimpl; }; @@ -2092,28 +2540,16 @@ class NestedType { } - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::NestedTypeStubs::HasBeginSelectionSet) - { - _pimpl->beginSelectionSet(params); - } - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::NestedTypeStubs::HasEndSelectionSet) - { - _pimpl->endSelectionSet(params); - } - } - service::FieldResult getDepth(service::FieldParams&& params) const final { - if constexpr (stub::NestedTypeStubs::HasDepth) + if constexpr (methods::NestedTypeMethod::WithParamsDepth) { return { _pimpl->getDepth(std::move(params)) }; } + else if constexpr (methods::NestedTypeMethod::NoParamsDepth) + { + return { _pimpl->getDepth() }; + } else { throw std::runtime_error(R"ex(NestedType::getDepth is not implemented)ex"); @@ -2122,16 +2558,36 @@ class NestedType service::FieldResult> getNested(service::FieldParams&& params) const final { - if constexpr (stub::NestedTypeStubs::HasNested) + if constexpr (methods::NestedTypeMethod::WithParamsNested) { return { _pimpl->getNested(std::move(params)) }; } + else if constexpr (methods::NestedTypeMethod::NoParamsNested) + { + return { _pimpl->getNested() }; + } else { throw std::runtime_error(R"ex(NestedType::getNested is not implemented)ex"); } } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::NestedTypeMethod::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::NestedTypeMethod::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + private: const std::shared_ptr _pimpl; }; @@ -2178,31 +2634,35 @@ class Expensive { } - void beginSelectionSet(const service::SelectionSetParams& params) const final + service::FieldResult getOrder(service::FieldParams&& params) const final { - if constexpr (stub::ExpensiveStubs::HasBeginSelectionSet) + if constexpr (methods::ExpensiveMethod::WithParamsOrder) { - _pimpl->beginSelectionSet(params); + return { _pimpl->getOrder(std::move(params)) }; + } + else if constexpr (methods::ExpensiveMethod::NoParamsOrder) + { + return { _pimpl->getOrder() }; + } + else + { + throw std::runtime_error(R"ex(Expensive::getOrder is not implemented)ex"); } } - void endSelectionSet(const service::SelectionSetParams& params) const final + void beginSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (stub::ExpensiveStubs::HasEndSelectionSet) + if constexpr (methods::ExpensiveMethod::HasBeginSelectionSet) { - _pimpl->endSelectionSet(params); + _pimpl->beginSelectionSet(params); } } - service::FieldResult getOrder(service::FieldParams&& params) const final + void endSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (stub::ExpensiveStubs::HasOrder) + if constexpr (methods::ExpensiveMethod::HasEndSelectionSet) { - return { _pimpl->getOrder(std::move(params)) }; - } - else - { - throw std::runtime_error(R"ex(Expensive::getOrder is not implemented)ex"); + _pimpl->endSelectionSet(params); } } diff --git a/samples/validation/ValidationSchema.h b/samples/validation/ValidationSchema.h index 2249c115..d8b0876e 100644 --- a/samples/validation/ValidationSchema.h +++ b/samples/validation/ValidationSchema.h @@ -68,51 +68,93 @@ struct Pet }; namespace object { -namespace stub { -namespace QueryStubs { +namespace methods { +namespace QueryMethod { template -concept HasDog = requires (TImpl impl, service::FieldParams params) +concept WithParamsDog = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getDog(std::move(params)) } }; }; template -concept HasHuman = requires (TImpl impl, service::FieldParams params) +concept NoParamsDog = requires (TImpl impl) +{ + { service::FieldResult> { impl.getDog() } }; +}; + +template +concept WithParamsHuman = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getHuman(std::move(params)) } }; }; template -concept HasPet = requires (TImpl impl, service::FieldParams params) +concept NoParamsHuman = requires (TImpl impl) +{ + { service::FieldResult> { impl.getHuman() } }; +}; + +template +concept WithParamsPet = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getPet(std::move(params)) } }; }; template -concept HasCatOrDog = requires (TImpl impl, service::FieldParams params) +concept NoParamsPet = requires (TImpl impl) +{ + { service::FieldResult> { impl.getPet() } }; +}; + +template +concept WithParamsCatOrDog = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getCatOrDog(std::move(params)) } }; }; template -concept HasArguments = requires (TImpl impl, service::FieldParams params) +concept NoParamsCatOrDog = requires (TImpl impl) +{ + { service::FieldResult> { impl.getCatOrDog() } }; +}; + +template +concept WithParamsArguments = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getArguments(std::move(params)) } }; }; template -concept HasFindDog = requires (TImpl impl, service::FieldParams params, std::optional complexArg) +concept NoParamsArguments = requires (TImpl impl) +{ + { service::FieldResult> { impl.getArguments() } }; +}; + +template +concept WithParamsFindDog = requires (TImpl impl, service::FieldParams params, std::optional complexArg) { { service::FieldResult> { impl.getFindDog(std::move(params), std::move(complexArg)) } }; }; template -concept HasBooleanList = requires (TImpl impl, service::FieldParams params, std::optional> booleanListArgArg) +concept NoParamsFindDog = requires (TImpl impl, std::optional complexArg) +{ + { service::FieldResult> { impl.getFindDog(std::move(complexArg)) } }; +}; + +template +concept WithParamsBooleanList = requires (TImpl impl, service::FieldParams params, std::optional> booleanListArgArg) { { service::FieldResult> { impl.getBooleanList(std::move(params), std::move(booleanListArgArg)) } }; }; +template +concept NoParamsBooleanList = requires (TImpl impl, std::optional> booleanListArgArg) +{ + { service::FieldResult> { impl.getBooleanList(std::move(booleanListArgArg)) } }; +}; + template concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { @@ -125,46 +167,82 @@ concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetPa { impl.endSelectionSet(params) }; }; -} // namespace QueryStubs +} // namespace QueryMethod -namespace DogStubs { +namespace DogMethod { template -concept HasName = requires (TImpl impl, service::FieldParams params) +concept WithParamsName = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getName(std::move(params)) } }; }; template -concept HasNickname = requires (TImpl impl, service::FieldParams params) +concept NoParamsName = requires (TImpl impl) +{ + { service::FieldResult { impl.getName() } }; +}; + +template +concept WithParamsNickname = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getNickname(std::move(params)) } }; }; template -concept HasBarkVolume = requires (TImpl impl, service::FieldParams params) +concept NoParamsNickname = requires (TImpl impl) +{ + { service::FieldResult> { impl.getNickname() } }; +}; + +template +concept WithParamsBarkVolume = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getBarkVolume(std::move(params)) } }; }; template -concept HasDoesKnowCommand = requires (TImpl impl, service::FieldParams params, DogCommand dogCommandArg) +concept NoParamsBarkVolume = requires (TImpl impl) +{ + { service::FieldResult> { impl.getBarkVolume() } }; +}; + +template +concept WithParamsDoesKnowCommand = requires (TImpl impl, service::FieldParams params, DogCommand dogCommandArg) { { service::FieldResult { impl.getDoesKnowCommand(std::move(params), std::move(dogCommandArg)) } }; }; template -concept HasIsHousetrained = requires (TImpl impl, service::FieldParams params, std::optional atOtherHomesArg) +concept NoParamsDoesKnowCommand = requires (TImpl impl, DogCommand dogCommandArg) +{ + { service::FieldResult { impl.getDoesKnowCommand(std::move(dogCommandArg)) } }; +}; + +template +concept WithParamsIsHousetrained = requires (TImpl impl, service::FieldParams params, std::optional atOtherHomesArg) { { service::FieldResult { impl.getIsHousetrained(std::move(params), std::move(atOtherHomesArg)) } }; }; template -concept HasOwner = requires (TImpl impl, service::FieldParams params) +concept NoParamsIsHousetrained = requires (TImpl impl, std::optional atOtherHomesArg) +{ + { service::FieldResult { impl.getIsHousetrained(std::move(atOtherHomesArg)) } }; +}; + +template +concept WithParamsOwner = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getOwner(std::move(params)) } }; }; +template +concept NoParamsOwner = requires (TImpl impl) +{ + { service::FieldResult> { impl.getOwner() } }; +}; + template concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { @@ -177,22 +255,34 @@ concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetPa { impl.endSelectionSet(params) }; }; -} // namespace DogStubs +} // namespace DogMethod -namespace AlienStubs { +namespace AlienMethod { template -concept HasName = requires (TImpl impl, service::FieldParams params) +concept WithParamsName = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getName(std::move(params)) } }; }; template -concept HasHomePlanet = requires (TImpl impl, service::FieldParams params) +concept NoParamsName = requires (TImpl impl) +{ + { service::FieldResult { impl.getName() } }; +}; + +template +concept WithParamsHomePlanet = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getHomePlanet(std::move(params)) } }; }; +template +concept NoParamsHomePlanet = requires (TImpl impl) +{ + { service::FieldResult> { impl.getHomePlanet() } }; +}; + template concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { @@ -205,22 +295,34 @@ concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetPa { impl.endSelectionSet(params) }; }; -} // namespace AlienStubs +} // namespace AlienMethod -namespace HumanStubs { +namespace HumanMethod { template -concept HasName = requires (TImpl impl, service::FieldParams params) +concept WithParamsName = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getName(std::move(params)) } }; }; template -concept HasPets = requires (TImpl impl, service::FieldParams params) +concept NoParamsName = requires (TImpl impl) +{ + { service::FieldResult { impl.getName() } }; +}; + +template +concept WithParamsPets = requires (TImpl impl, service::FieldParams params) { { service::FieldResult>> { impl.getPets(std::move(params)) } }; }; +template +concept NoParamsPets = requires (TImpl impl) +{ + { service::FieldResult>> { impl.getPets() } }; +}; + template concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { @@ -233,34 +335,58 @@ concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetPa { impl.endSelectionSet(params) }; }; -} // namespace HumanStubs +} // namespace HumanMethod -namespace CatStubs { +namespace CatMethod { template -concept HasName = requires (TImpl impl, service::FieldParams params) +concept WithParamsName = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getName(std::move(params)) } }; }; template -concept HasNickname = requires (TImpl impl, service::FieldParams params) +concept NoParamsName = requires (TImpl impl) +{ + { service::FieldResult { impl.getName() } }; +}; + +template +concept WithParamsNickname = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getNickname(std::move(params)) } }; }; template -concept HasDoesKnowCommand = requires (TImpl impl, service::FieldParams params, CatCommand catCommandArg) +concept NoParamsNickname = requires (TImpl impl) +{ + { service::FieldResult> { impl.getNickname() } }; +}; + +template +concept WithParamsDoesKnowCommand = requires (TImpl impl, service::FieldParams params, CatCommand catCommandArg) { { service::FieldResult { impl.getDoesKnowCommand(std::move(params), std::move(catCommandArg)) } }; }; template -concept HasMeowVolume = requires (TImpl impl, service::FieldParams params) +concept NoParamsDoesKnowCommand = requires (TImpl impl, CatCommand catCommandArg) +{ + { service::FieldResult { impl.getDoesKnowCommand(std::move(catCommandArg)) } }; +}; + +template +concept WithParamsMeowVolume = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getMeowVolume(std::move(params)) } }; }; +template +concept NoParamsMeowVolume = requires (TImpl impl) +{ + { service::FieldResult> { impl.getMeowVolume() } }; +}; + template concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { @@ -273,16 +399,22 @@ concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetPa { impl.endSelectionSet(params) }; }; -} // namespace CatStubs +} // namespace CatMethod -namespace MutationStubs { +namespace MutationMethod { template -concept HasMutateDog = requires (TImpl impl, service::FieldParams params) +concept WithParamsMutateDog = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.applyMutateDog(std::move(params)) } }; }; +template +concept NoParamsMutateDog = requires (TImpl impl) +{ + { service::FieldResult> { impl.applyMutateDog() } }; +}; + template concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { @@ -295,16 +427,22 @@ concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetPa { impl.endSelectionSet(params) }; }; -} // namespace MutationStubs +} // namespace MutationMethod -namespace MutateDogResultStubs { +namespace MutateDogResultMethod { template -concept HasId = requires (TImpl impl, service::FieldParams params) +concept WithParamsId = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getId(std::move(params)) } }; }; +template +concept NoParamsId = requires (TImpl impl) +{ + { service::FieldResult { impl.getId() } }; +}; + template concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { @@ -317,22 +455,34 @@ concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetPa { impl.endSelectionSet(params) }; }; -} // namespace MutateDogResultStubs +} // namespace MutateDogResultMethod -namespace SubscriptionStubs { +namespace SubscriptionMethod { template -concept HasNewMessage = requires (TImpl impl, service::FieldParams params) +concept WithParamsNewMessage = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getNewMessage(std::move(params)) } }; }; template -concept HasDisallowedSecondRootField = requires (TImpl impl, service::FieldParams params) +concept NoParamsNewMessage = requires (TImpl impl) +{ + { service::FieldResult> { impl.getNewMessage() } }; +}; + +template +concept WithParamsDisallowedSecondRootField = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getDisallowedSecondRootField(std::move(params)) } }; }; +template +concept NoParamsDisallowedSecondRootField = requires (TImpl impl) +{ + { service::FieldResult { impl.getDisallowedSecondRootField() } }; +}; + template concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { @@ -345,22 +495,34 @@ concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetPa { impl.endSelectionSet(params) }; }; -} // namespace SubscriptionStubs +} // namespace SubscriptionMethod -namespace MessageStubs { +namespace MessageMethod { template -concept HasBody = requires (TImpl impl, service::FieldParams params) +concept WithParamsBody = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getBody(std::move(params)) } }; }; template -concept HasSender = requires (TImpl impl, service::FieldParams params) +concept NoParamsBody = requires (TImpl impl) +{ + { service::FieldResult> { impl.getBody() } }; +}; + +template +concept WithParamsSender = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getSender(std::move(params)) } }; }; +template +concept NoParamsSender = requires (TImpl impl) +{ + { service::FieldResult { impl.getSender() } }; +}; + template concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { @@ -373,58 +535,106 @@ concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetPa { impl.endSelectionSet(params) }; }; -} // namespace MessageStubs +} // namespace MessageMethod -namespace ArgumentsStubs { +namespace ArgumentsMethod { template -concept HasMultipleReqs = requires (TImpl impl, service::FieldParams params, response::IntType xArg, response::IntType yArg) +concept WithParamsMultipleReqs = requires (TImpl impl, service::FieldParams params, response::IntType xArg, response::IntType yArg) { { service::FieldResult { impl.getMultipleReqs(std::move(params), std::move(xArg), std::move(yArg)) } }; }; template -concept HasBooleanArgField = requires (TImpl impl, service::FieldParams params, std::optional booleanArgArg) +concept NoParamsMultipleReqs = requires (TImpl impl, response::IntType xArg, response::IntType yArg) +{ + { service::FieldResult { impl.getMultipleReqs(std::move(xArg), std::move(yArg)) } }; +}; + +template +concept WithParamsBooleanArgField = requires (TImpl impl, service::FieldParams params, std::optional booleanArgArg) { { service::FieldResult> { impl.getBooleanArgField(std::move(params), std::move(booleanArgArg)) } }; }; template -concept HasFloatArgField = requires (TImpl impl, service::FieldParams params, std::optional floatArgArg) +concept NoParamsBooleanArgField = requires (TImpl impl, std::optional booleanArgArg) +{ + { service::FieldResult> { impl.getBooleanArgField(std::move(booleanArgArg)) } }; +}; + +template +concept WithParamsFloatArgField = requires (TImpl impl, service::FieldParams params, std::optional floatArgArg) { { service::FieldResult> { impl.getFloatArgField(std::move(params), std::move(floatArgArg)) } }; }; template -concept HasIntArgField = requires (TImpl impl, service::FieldParams params, std::optional intArgArg) +concept NoParamsFloatArgField = requires (TImpl impl, std::optional floatArgArg) +{ + { service::FieldResult> { impl.getFloatArgField(std::move(floatArgArg)) } }; +}; + +template +concept WithParamsIntArgField = requires (TImpl impl, service::FieldParams params, std::optional intArgArg) { { service::FieldResult> { impl.getIntArgField(std::move(params), std::move(intArgArg)) } }; }; template -concept HasNonNullBooleanArgField = requires (TImpl impl, service::FieldParams params, response::BooleanType nonNullBooleanArgArg) +concept NoParamsIntArgField = requires (TImpl impl, std::optional intArgArg) +{ + { service::FieldResult> { impl.getIntArgField(std::move(intArgArg)) } }; +}; + +template +concept WithParamsNonNullBooleanArgField = requires (TImpl impl, service::FieldParams params, response::BooleanType nonNullBooleanArgArg) { { service::FieldResult { impl.getNonNullBooleanArgField(std::move(params), std::move(nonNullBooleanArgArg)) } }; }; template -concept HasNonNullBooleanListField = requires (TImpl impl, service::FieldParams params, std::optional> nonNullBooleanListArgArg) +concept NoParamsNonNullBooleanArgField = requires (TImpl impl, response::BooleanType nonNullBooleanArgArg) +{ + { service::FieldResult { impl.getNonNullBooleanArgField(std::move(nonNullBooleanArgArg)) } }; +}; + +template +concept WithParamsNonNullBooleanListField = requires (TImpl impl, service::FieldParams params, std::optional> nonNullBooleanListArgArg) { { service::FieldResult>> { impl.getNonNullBooleanListField(std::move(params), std::move(nonNullBooleanListArgArg)) } }; }; template -concept HasBooleanListArgField = requires (TImpl impl, service::FieldParams params, std::vector> booleanListArgArg) +concept NoParamsNonNullBooleanListField = requires (TImpl impl, std::optional> nonNullBooleanListArgArg) +{ + { service::FieldResult>> { impl.getNonNullBooleanListField(std::move(nonNullBooleanListArgArg)) } }; +}; + +template +concept WithParamsBooleanListArgField = requires (TImpl impl, service::FieldParams params, std::vector> booleanListArgArg) { { service::FieldResult>>> { impl.getBooleanListArgField(std::move(params), std::move(booleanListArgArg)) } }; }; template -concept HasOptionalNonNullBooleanArgField = requires (TImpl impl, service::FieldParams params, response::BooleanType optionalBooleanArgArg) +concept NoParamsBooleanListArgField = requires (TImpl impl, std::vector> booleanListArgArg) +{ + { service::FieldResult>>> { impl.getBooleanListArgField(std::move(booleanListArgArg)) } }; +}; + +template +concept WithParamsOptionalNonNullBooleanArgField = requires (TImpl impl, service::FieldParams params, response::BooleanType optionalBooleanArgArg) { { service::FieldResult { impl.getOptionalNonNullBooleanArgField(std::move(params), std::move(optionalBooleanArgArg)) } }; }; +template +concept NoParamsOptionalNonNullBooleanArgField = requires (TImpl impl, response::BooleanType optionalBooleanArgArg) +{ + { service::FieldResult { impl.getOptionalNonNullBooleanArgField(std::move(optionalBooleanArgArg)) } }; +}; + template concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { @@ -437,8 +647,8 @@ concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetPa { impl.endSelectionSet(params) }; }; -} // namespace ArgumentsStubs -} // namespace stub +} // namespace ArgumentsMethod +} // namespace methods class Query : public service::Object @@ -483,28 +693,16 @@ class Query { } - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::QueryStubs::HasBeginSelectionSet) - { - _pimpl->beginSelectionSet(params); - } - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::QueryStubs::HasEndSelectionSet) - { - _pimpl->endSelectionSet(params); - } - } - service::FieldResult> getDog(service::FieldParams&& params) const final { - if constexpr (stub::QueryStubs::HasDog) + if constexpr (methods::QueryMethod::WithParamsDog) { return { _pimpl->getDog(std::move(params)) }; } + else if constexpr (methods::QueryMethod::NoParamsDog) + { + return { _pimpl->getDog() }; + } else { throw std::runtime_error(R"ex(Query::getDog is not implemented)ex"); @@ -513,10 +711,14 @@ class Query service::FieldResult> getHuman(service::FieldParams&& params) const final { - if constexpr (stub::QueryStubs::HasHuman) + if constexpr (methods::QueryMethod::WithParamsHuman) { return { _pimpl->getHuman(std::move(params)) }; } + else if constexpr (methods::QueryMethod::NoParamsHuman) + { + return { _pimpl->getHuman() }; + } else { throw std::runtime_error(R"ex(Query::getHuman is not implemented)ex"); @@ -525,10 +727,14 @@ class Query service::FieldResult> getPet(service::FieldParams&& params) const final { - if constexpr (stub::QueryStubs::HasPet) + if constexpr (methods::QueryMethod::WithParamsPet) { return { _pimpl->getPet(std::move(params)) }; } + else if constexpr (methods::QueryMethod::NoParamsPet) + { + return { _pimpl->getPet() }; + } else { throw std::runtime_error(R"ex(Query::getPet is not implemented)ex"); @@ -537,10 +743,14 @@ class Query service::FieldResult> getCatOrDog(service::FieldParams&& params) const final { - if constexpr (stub::QueryStubs::HasCatOrDog) + if constexpr (methods::QueryMethod::WithParamsCatOrDog) { return { _pimpl->getCatOrDog(std::move(params)) }; } + else if constexpr (methods::QueryMethod::NoParamsCatOrDog) + { + return { _pimpl->getCatOrDog() }; + } else { throw std::runtime_error(R"ex(Query::getCatOrDog is not implemented)ex"); @@ -549,10 +759,14 @@ class Query service::FieldResult> getArguments(service::FieldParams&& params) const final { - if constexpr (stub::QueryStubs::HasArguments) + if constexpr (methods::QueryMethod::WithParamsArguments) { return { _pimpl->getArguments(std::move(params)) }; } + else if constexpr (methods::QueryMethod::NoParamsArguments) + { + return { _pimpl->getArguments() }; + } else { throw std::runtime_error(R"ex(Query::getArguments is not implemented)ex"); @@ -561,10 +775,14 @@ class Query service::FieldResult> getFindDog(service::FieldParams&& params, std::optional&& complexArg) const final { - if constexpr (stub::QueryStubs::HasFindDog) + if constexpr (methods::QueryMethod::WithParamsFindDog) { return { _pimpl->getFindDog(std::move(params), std::move(complexArg)) }; } + else if constexpr (methods::QueryMethod::NoParamsFindDog) + { + return { _pimpl->getFindDog(std::move(complexArg)) }; + } else { throw std::runtime_error(R"ex(Query::getFindDog is not implemented)ex"); @@ -573,16 +791,36 @@ class Query service::FieldResult> getBooleanList(service::FieldParams&& params, std::optional>&& booleanListArgArg) const final { - if constexpr (stub::QueryStubs::HasBooleanList) + if constexpr (methods::QueryMethod::WithParamsBooleanList) { return { _pimpl->getBooleanList(std::move(params), std::move(booleanListArgArg)) }; } + else if constexpr (methods::QueryMethod::NoParamsBooleanList) + { + return { _pimpl->getBooleanList(std::move(booleanListArgArg)) }; + } else { throw std::runtime_error(R"ex(Query::getBooleanList is not implemented)ex"); } } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::QueryMethod::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::QueryMethod::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + private: const std::shared_ptr _pimpl; }; @@ -639,28 +877,16 @@ class Dog { } - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::DogStubs::HasBeginSelectionSet) - { - _pimpl->beginSelectionSet(params); - } - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::DogStubs::HasEndSelectionSet) - { - _pimpl->endSelectionSet(params); - } - } - service::FieldResult getName(service::FieldParams&& params) const final { - if constexpr (stub::DogStubs::HasName) + if constexpr (methods::DogMethod::WithParamsName) { return { _pimpl->getName(std::move(params)) }; } + else if constexpr (methods::DogMethod::NoParamsName) + { + return { _pimpl->getName() }; + } else { throw std::runtime_error(R"ex(Dog::getName is not implemented)ex"); @@ -669,10 +895,14 @@ class Dog service::FieldResult> getNickname(service::FieldParams&& params) const final { - if constexpr (stub::DogStubs::HasNickname) + if constexpr (methods::DogMethod::WithParamsNickname) { return { _pimpl->getNickname(std::move(params)) }; } + else if constexpr (methods::DogMethod::NoParamsNickname) + { + return { _pimpl->getNickname() }; + } else { throw std::runtime_error(R"ex(Dog::getNickname is not implemented)ex"); @@ -681,10 +911,14 @@ class Dog service::FieldResult> getBarkVolume(service::FieldParams&& params) const final { - if constexpr (stub::DogStubs::HasBarkVolume) + if constexpr (methods::DogMethod::WithParamsBarkVolume) { return { _pimpl->getBarkVolume(std::move(params)) }; } + else if constexpr (methods::DogMethod::NoParamsBarkVolume) + { + return { _pimpl->getBarkVolume() }; + } else { throw std::runtime_error(R"ex(Dog::getBarkVolume is not implemented)ex"); @@ -693,10 +927,14 @@ class Dog service::FieldResult getDoesKnowCommand(service::FieldParams&& params, DogCommand&& dogCommandArg) const final { - if constexpr (stub::DogStubs::HasDoesKnowCommand) + if constexpr (methods::DogMethod::WithParamsDoesKnowCommand) { return { _pimpl->getDoesKnowCommand(std::move(params), std::move(dogCommandArg)) }; } + else if constexpr (methods::DogMethod::NoParamsDoesKnowCommand) + { + return { _pimpl->getDoesKnowCommand(std::move(dogCommandArg)) }; + } else { throw std::runtime_error(R"ex(Dog::getDoesKnowCommand is not implemented)ex"); @@ -705,10 +943,14 @@ class Dog service::FieldResult getIsHousetrained(service::FieldParams&& params, std::optional&& atOtherHomesArg) const final { - if constexpr (stub::DogStubs::HasIsHousetrained) + if constexpr (methods::DogMethod::WithParamsIsHousetrained) { return { _pimpl->getIsHousetrained(std::move(params), std::move(atOtherHomesArg)) }; } + else if constexpr (methods::DogMethod::NoParamsIsHousetrained) + { + return { _pimpl->getIsHousetrained(std::move(atOtherHomesArg)) }; + } else { throw std::runtime_error(R"ex(Dog::getIsHousetrained is not implemented)ex"); @@ -717,16 +959,36 @@ class Dog service::FieldResult> getOwner(service::FieldParams&& params) const final { - if constexpr (stub::DogStubs::HasOwner) + if constexpr (methods::DogMethod::WithParamsOwner) { return { _pimpl->getOwner(std::move(params)) }; } + else if constexpr (methods::DogMethod::NoParamsOwner) + { + return { _pimpl->getOwner() }; + } else { throw std::runtime_error(R"ex(Dog::getOwner is not implemented)ex"); } } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::DogMethod::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::DogMethod::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + private: const std::shared_ptr _pimpl; }; @@ -775,28 +1037,16 @@ class Alien { } - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::AlienStubs::HasBeginSelectionSet) - { - _pimpl->beginSelectionSet(params); - } - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::AlienStubs::HasEndSelectionSet) - { - _pimpl->endSelectionSet(params); - } - } - service::FieldResult getName(service::FieldParams&& params) const final { - if constexpr (stub::AlienStubs::HasName) + if constexpr (methods::AlienMethod::WithParamsName) { return { _pimpl->getName(std::move(params)) }; } + else if constexpr (methods::AlienMethod::NoParamsName) + { + return { _pimpl->getName() }; + } else { throw std::runtime_error(R"ex(Alien::getName is not implemented)ex"); @@ -805,16 +1055,36 @@ class Alien service::FieldResult> getHomePlanet(service::FieldParams&& params) const final { - if constexpr (stub::AlienStubs::HasHomePlanet) + if constexpr (methods::AlienMethod::WithParamsHomePlanet) { return { _pimpl->getHomePlanet(std::move(params)) }; } + else if constexpr (methods::AlienMethod::NoParamsHomePlanet) + { + return { _pimpl->getHomePlanet() }; + } else { throw std::runtime_error(R"ex(Alien::getHomePlanet is not implemented)ex"); } } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::AlienMethod::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::AlienMethod::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + private: const std::shared_ptr _pimpl; }; @@ -863,28 +1133,16 @@ class Human { } - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::HumanStubs::HasBeginSelectionSet) - { - _pimpl->beginSelectionSet(params); - } - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::HumanStubs::HasEndSelectionSet) - { - _pimpl->endSelectionSet(params); - } - } - service::FieldResult getName(service::FieldParams&& params) const final { - if constexpr (stub::HumanStubs::HasName) + if constexpr (methods::HumanMethod::WithParamsName) { return { _pimpl->getName(std::move(params)) }; } + else if constexpr (methods::HumanMethod::NoParamsName) + { + return { _pimpl->getName() }; + } else { throw std::runtime_error(R"ex(Human::getName is not implemented)ex"); @@ -893,16 +1151,36 @@ class Human service::FieldResult>> getPets(service::FieldParams&& params) const final { - if constexpr (stub::HumanStubs::HasPets) + if constexpr (methods::HumanMethod::WithParamsPets) { return { _pimpl->getPets(std::move(params)) }; } + else if constexpr (methods::HumanMethod::NoParamsPets) + { + return { _pimpl->getPets() }; + } else { throw std::runtime_error(R"ex(Human::getPets is not implemented)ex"); } } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::HumanMethod::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::HumanMethod::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + private: const std::shared_ptr _pimpl; }; @@ -955,28 +1233,16 @@ class Cat { } - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::CatStubs::HasBeginSelectionSet) - { - _pimpl->beginSelectionSet(params); - } - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::CatStubs::HasEndSelectionSet) - { - _pimpl->endSelectionSet(params); - } - } - service::FieldResult getName(service::FieldParams&& params) const final { - if constexpr (stub::CatStubs::HasName) + if constexpr (methods::CatMethod::WithParamsName) { return { _pimpl->getName(std::move(params)) }; } + else if constexpr (methods::CatMethod::NoParamsName) + { + return { _pimpl->getName() }; + } else { throw std::runtime_error(R"ex(Cat::getName is not implemented)ex"); @@ -985,10 +1251,14 @@ class Cat service::FieldResult> getNickname(service::FieldParams&& params) const final { - if constexpr (stub::CatStubs::HasNickname) + if constexpr (methods::CatMethod::WithParamsNickname) { return { _pimpl->getNickname(std::move(params)) }; } + else if constexpr (methods::CatMethod::NoParamsNickname) + { + return { _pimpl->getNickname() }; + } else { throw std::runtime_error(R"ex(Cat::getNickname is not implemented)ex"); @@ -997,10 +1267,14 @@ class Cat service::FieldResult getDoesKnowCommand(service::FieldParams&& params, CatCommand&& catCommandArg) const final { - if constexpr (stub::CatStubs::HasDoesKnowCommand) + if constexpr (methods::CatMethod::WithParamsDoesKnowCommand) { return { _pimpl->getDoesKnowCommand(std::move(params), std::move(catCommandArg)) }; } + else if constexpr (methods::CatMethod::NoParamsDoesKnowCommand) + { + return { _pimpl->getDoesKnowCommand(std::move(catCommandArg)) }; + } else { throw std::runtime_error(R"ex(Cat::getDoesKnowCommand is not implemented)ex"); @@ -1009,16 +1283,36 @@ class Cat service::FieldResult> getMeowVolume(service::FieldParams&& params) const final { - if constexpr (stub::CatStubs::HasMeowVolume) + if constexpr (methods::CatMethod::WithParamsMeowVolume) { return { _pimpl->getMeowVolume(std::move(params)) }; } + else if constexpr (methods::CatMethod::NoParamsMeowVolume) + { + return { _pimpl->getMeowVolume() }; + } else { throw std::runtime_error(R"ex(Cat::getMeowVolume is not implemented)ex"); } } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::CatMethod::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::CatMethod::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + private: const std::shared_ptr _pimpl; }; @@ -1065,31 +1359,35 @@ class Mutation { } - void beginSelectionSet(const service::SelectionSetParams& params) const final + service::FieldResult> applyMutateDog(service::FieldParams&& params) const final { - if constexpr (stub::MutationStubs::HasBeginSelectionSet) + if constexpr (methods::MutationMethod::WithParamsMutateDog) { - _pimpl->beginSelectionSet(params); + return { _pimpl->applyMutateDog(std::move(params)) }; + } + else if constexpr (methods::MutationMethod::NoParamsMutateDog) + { + return { _pimpl->applyMutateDog() }; + } + else + { + throw std::runtime_error(R"ex(Mutation::applyMutateDog is not implemented)ex"); } } - void endSelectionSet(const service::SelectionSetParams& params) const final + void beginSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (stub::MutationStubs::HasEndSelectionSet) + if constexpr (methods::MutationMethod::HasBeginSelectionSet) { - _pimpl->endSelectionSet(params); + _pimpl->beginSelectionSet(params); } } - service::FieldResult> applyMutateDog(service::FieldParams&& params) const final + void endSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (stub::MutationStubs::HasMutateDog) - { - return { _pimpl->applyMutateDog(std::move(params)) }; - } - else + if constexpr (methods::MutationMethod::HasEndSelectionSet) { - throw std::runtime_error(R"ex(Mutation::applyMutateDog is not implemented)ex"); + _pimpl->endSelectionSet(params); } } @@ -1139,31 +1437,35 @@ class MutateDogResult { } - void beginSelectionSet(const service::SelectionSetParams& params) const final + service::FieldResult getId(service::FieldParams&& params) const final { - if constexpr (stub::MutateDogResultStubs::HasBeginSelectionSet) + if constexpr (methods::MutateDogResultMethod::WithParamsId) { - _pimpl->beginSelectionSet(params); + return { _pimpl->getId(std::move(params)) }; + } + else if constexpr (methods::MutateDogResultMethod::NoParamsId) + { + return { _pimpl->getId() }; + } + else + { + throw std::runtime_error(R"ex(MutateDogResult::getId is not implemented)ex"); } } - void endSelectionSet(const service::SelectionSetParams& params) const final + void beginSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (stub::MutateDogResultStubs::HasEndSelectionSet) + if constexpr (methods::MutateDogResultMethod::HasBeginSelectionSet) { - _pimpl->endSelectionSet(params); + _pimpl->beginSelectionSet(params); } } - service::FieldResult getId(service::FieldParams&& params) const final + void endSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (stub::MutateDogResultStubs::HasId) - { - return { _pimpl->getId(std::move(params)) }; - } - else + if constexpr (methods::MutateDogResultMethod::HasEndSelectionSet) { - throw std::runtime_error(R"ex(MutateDogResult::getId is not implemented)ex"); + _pimpl->endSelectionSet(params); } } @@ -1215,28 +1517,16 @@ class Subscription { } - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::SubscriptionStubs::HasBeginSelectionSet) - { - _pimpl->beginSelectionSet(params); - } - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::SubscriptionStubs::HasEndSelectionSet) - { - _pimpl->endSelectionSet(params); - } - } - service::FieldResult> getNewMessage(service::FieldParams&& params) const final { - if constexpr (stub::SubscriptionStubs::HasNewMessage) + if constexpr (methods::SubscriptionMethod::WithParamsNewMessage) { return { _pimpl->getNewMessage(std::move(params)) }; } + else if constexpr (methods::SubscriptionMethod::NoParamsNewMessage) + { + return { _pimpl->getNewMessage() }; + } else { throw std::runtime_error(R"ex(Subscription::getNewMessage is not implemented)ex"); @@ -1245,16 +1535,36 @@ class Subscription service::FieldResult getDisallowedSecondRootField(service::FieldParams&& params) const final { - if constexpr (stub::SubscriptionStubs::HasDisallowedSecondRootField) + if constexpr (methods::SubscriptionMethod::WithParamsDisallowedSecondRootField) { return { _pimpl->getDisallowedSecondRootField(std::move(params)) }; } + else if constexpr (methods::SubscriptionMethod::NoParamsDisallowedSecondRootField) + { + return { _pimpl->getDisallowedSecondRootField() }; + } else { throw std::runtime_error(R"ex(Subscription::getDisallowedSecondRootField is not implemented)ex"); } } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::SubscriptionMethod::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::SubscriptionMethod::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + private: const std::shared_ptr _pimpl; }; @@ -1303,28 +1613,16 @@ class Message { } - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::MessageStubs::HasBeginSelectionSet) - { - _pimpl->beginSelectionSet(params); - } - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::MessageStubs::HasEndSelectionSet) - { - _pimpl->endSelectionSet(params); - } - } - service::FieldResult> getBody(service::FieldParams&& params) const final { - if constexpr (stub::MessageStubs::HasBody) + if constexpr (methods::MessageMethod::WithParamsBody) { return { _pimpl->getBody(std::move(params)) }; } + else if constexpr (methods::MessageMethod::NoParamsBody) + { + return { _pimpl->getBody() }; + } else { throw std::runtime_error(R"ex(Message::getBody is not implemented)ex"); @@ -1333,16 +1631,36 @@ class Message service::FieldResult getSender(service::FieldParams&& params) const final { - if constexpr (stub::MessageStubs::HasSender) + if constexpr (methods::MessageMethod::WithParamsSender) { return { _pimpl->getSender(std::move(params)) }; } + else if constexpr (methods::MessageMethod::NoParamsSender) + { + return { _pimpl->getSender() }; + } else { throw std::runtime_error(R"ex(Message::getSender is not implemented)ex"); } } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::MessageMethod::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::MessageMethod::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + private: const std::shared_ptr _pimpl; }; @@ -1403,28 +1721,16 @@ class Arguments { } - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::ArgumentsStubs::HasBeginSelectionSet) - { - _pimpl->beginSelectionSet(params); - } - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::ArgumentsStubs::HasEndSelectionSet) - { - _pimpl->endSelectionSet(params); - } - } - service::FieldResult getMultipleReqs(service::FieldParams&& params, response::IntType&& xArg, response::IntType&& yArg) const final { - if constexpr (stub::ArgumentsStubs::HasMultipleReqs) + if constexpr (methods::ArgumentsMethod::WithParamsMultipleReqs) { return { _pimpl->getMultipleReqs(std::move(params), std::move(xArg), std::move(yArg)) }; } + else if constexpr (methods::ArgumentsMethod::NoParamsMultipleReqs) + { + return { _pimpl->getMultipleReqs(std::move(xArg), std::move(yArg)) }; + } else { throw std::runtime_error(R"ex(Arguments::getMultipleReqs is not implemented)ex"); @@ -1433,10 +1739,14 @@ class Arguments service::FieldResult> getBooleanArgField(service::FieldParams&& params, std::optional&& booleanArgArg) const final { - if constexpr (stub::ArgumentsStubs::HasBooleanArgField) + if constexpr (methods::ArgumentsMethod::WithParamsBooleanArgField) { return { _pimpl->getBooleanArgField(std::move(params), std::move(booleanArgArg)) }; } + else if constexpr (methods::ArgumentsMethod::NoParamsBooleanArgField) + { + return { _pimpl->getBooleanArgField(std::move(booleanArgArg)) }; + } else { throw std::runtime_error(R"ex(Arguments::getBooleanArgField is not implemented)ex"); @@ -1445,10 +1755,14 @@ class Arguments service::FieldResult> getFloatArgField(service::FieldParams&& params, std::optional&& floatArgArg) const final { - if constexpr (stub::ArgumentsStubs::HasFloatArgField) + if constexpr (methods::ArgumentsMethod::WithParamsFloatArgField) { return { _pimpl->getFloatArgField(std::move(params), std::move(floatArgArg)) }; } + else if constexpr (methods::ArgumentsMethod::NoParamsFloatArgField) + { + return { _pimpl->getFloatArgField(std::move(floatArgArg)) }; + } else { throw std::runtime_error(R"ex(Arguments::getFloatArgField is not implemented)ex"); @@ -1457,10 +1771,14 @@ class Arguments service::FieldResult> getIntArgField(service::FieldParams&& params, std::optional&& intArgArg) const final { - if constexpr (stub::ArgumentsStubs::HasIntArgField) + if constexpr (methods::ArgumentsMethod::WithParamsIntArgField) { return { _pimpl->getIntArgField(std::move(params), std::move(intArgArg)) }; } + else if constexpr (methods::ArgumentsMethod::NoParamsIntArgField) + { + return { _pimpl->getIntArgField(std::move(intArgArg)) }; + } else { throw std::runtime_error(R"ex(Arguments::getIntArgField is not implemented)ex"); @@ -1469,10 +1787,14 @@ class Arguments service::FieldResult getNonNullBooleanArgField(service::FieldParams&& params, response::BooleanType&& nonNullBooleanArgArg) const final { - if constexpr (stub::ArgumentsStubs::HasNonNullBooleanArgField) + if constexpr (methods::ArgumentsMethod::WithParamsNonNullBooleanArgField) { return { _pimpl->getNonNullBooleanArgField(std::move(params), std::move(nonNullBooleanArgArg)) }; } + else if constexpr (methods::ArgumentsMethod::NoParamsNonNullBooleanArgField) + { + return { _pimpl->getNonNullBooleanArgField(std::move(nonNullBooleanArgArg)) }; + } else { throw std::runtime_error(R"ex(Arguments::getNonNullBooleanArgField is not implemented)ex"); @@ -1481,10 +1803,14 @@ class Arguments service::FieldResult>> getNonNullBooleanListField(service::FieldParams&& params, std::optional>&& nonNullBooleanListArgArg) const final { - if constexpr (stub::ArgumentsStubs::HasNonNullBooleanListField) + if constexpr (methods::ArgumentsMethod::WithParamsNonNullBooleanListField) { return { _pimpl->getNonNullBooleanListField(std::move(params), std::move(nonNullBooleanListArgArg)) }; } + else if constexpr (methods::ArgumentsMethod::NoParamsNonNullBooleanListField) + { + return { _pimpl->getNonNullBooleanListField(std::move(nonNullBooleanListArgArg)) }; + } else { throw std::runtime_error(R"ex(Arguments::getNonNullBooleanListField is not implemented)ex"); @@ -1493,10 +1819,14 @@ class Arguments service::FieldResult>>> getBooleanListArgField(service::FieldParams&& params, std::vector>&& booleanListArgArg) const final { - if constexpr (stub::ArgumentsStubs::HasBooleanListArgField) + if constexpr (methods::ArgumentsMethod::WithParamsBooleanListArgField) { return { _pimpl->getBooleanListArgField(std::move(params), std::move(booleanListArgArg)) }; } + else if constexpr (methods::ArgumentsMethod::NoParamsBooleanListArgField) + { + return { _pimpl->getBooleanListArgField(std::move(booleanListArgArg)) }; + } else { throw std::runtime_error(R"ex(Arguments::getBooleanListArgField is not implemented)ex"); @@ -1505,16 +1835,36 @@ class Arguments service::FieldResult getOptionalNonNullBooleanArgField(service::FieldParams&& params, response::BooleanType&& optionalBooleanArgArg) const final { - if constexpr (stub::ArgumentsStubs::HasOptionalNonNullBooleanArgField) + if constexpr (methods::ArgumentsMethod::WithParamsOptionalNonNullBooleanArgField) { return { _pimpl->getOptionalNonNullBooleanArgField(std::move(params), std::move(optionalBooleanArgArg)) }; } + else if constexpr (methods::ArgumentsMethod::NoParamsOptionalNonNullBooleanArgField) + { + return { _pimpl->getOptionalNonNullBooleanArgField(std::move(optionalBooleanArgArg)) }; + } else { throw std::runtime_error(R"ex(Arguments::getOptionalNonNullBooleanArgField is not implemented)ex"); } } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::ArgumentsMethod::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::ArgumentsMethod::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + private: const std::shared_ptr _pimpl; }; diff --git a/src/SchemaGenerator.cpp b/src/SchemaGenerator.cpp index 9145c3fe..7bbc59bc 100644 --- a/src/SchemaGenerator.cpp +++ b/src/SchemaGenerator.cpp @@ -330,7 +330,7 @@ static_assert(graphql::internal::MinorVersion == )cpp" { objectNamespace.enter(); - NamespaceScope stubNamespace { headerFile, "stub", true }; + NamespaceScope stubNamespace { headerFile, "methods", true }; // Output the stub concept declarations for (const auto& objectType : _loader.getObjectTypes()) @@ -342,7 +342,7 @@ static_assert(graphql::internal::MinorVersion == )cpp" std::ostringstream ossConceptNamespace; - ossConceptNamespace << objectType.cppType << R"cpp(Stubs)cpp"; + ossConceptNamespace << objectType.cppType << R"cpp(Method)cpp"; const auto conceptNamespace = ossConceptNamespace.str(); NamespaceScope conceptSubNamespace { headerFile, conceptNamespace }; @@ -546,7 +546,7 @@ GRAPHQLINTROSPECTION_EXPORT )cpp" void Generator::outputObjectStubs(std::ostream& headerFile, const ObjectType& objectType) const { - if (!_options.noStubs && !_loader.isIntrospection()) + if (!_loader.isIntrospection()) { for (const auto& outputField : objectType.fields) { @@ -555,9 +555,25 @@ void Generator::outputObjectStubs(std::ostream& headerFile, const ObjectType& ob fieldName[0] = static_cast(std::toupper(static_cast(fieldName[0]))); + std::ostringstream ossPassedArguments; + bool firstArgument = true; + + for (const auto& argument : outputField.arguments) + { + if (!firstArgument) + { + ossPassedArguments << R"cpp(, )cpp"; + } + + ossPassedArguments << R"cpp(std::move()cpp" << argument.cppName << R"cpp(Arg))cpp"; + firstArgument = false; + } + + const auto passedArguments = ossPassedArguments.str(); + headerFile << R"cpp( template -concept Has)cpp" << fieldName +concept WithParams)cpp" << fieldName << R"cpp( = requires (TImpl impl, service::FieldParams params)cpp"; for (const auto& argument : outputField.arguments) { @@ -570,9 +586,33 @@ concept Has)cpp" << fieldName { service::FieldResult<)cpp" << _loader.getOutputCppType(outputField) << R"cpp(> { impl.)cpp" << outputField.accessor << fieldName << R"cpp((std::move(params))cpp"; + + if (!passedArguments.empty()) + { + headerFile << R"cpp(, )cpp" << passedArguments; + } + + headerFile << R"cpp() } }; +}; + +template +concept NoParams)cpp" << fieldName + << R"cpp( = requires (TImpl impl)cpp"; for (const auto& argument : outputField.arguments) { - headerFile << R"cpp(, std::move()cpp" << argument.cppName << R"cpp(Arg))cpp"; + headerFile << R"cpp(, )cpp" << _loader.getInputCppType(argument) << R"cpp( )cpp" + << argument.cppName << R"cpp(Arg)cpp"; + } + + headerFile << R"cpp() +{ + { service::FieldResult<)cpp" + << _loader.getOutputCppType(outputField) << R"cpp(> { impl.)cpp" + << outputField.accessor << fieldName << R"cpp(()cpp"; + + if (!passedArguments.empty()) + { + headerFile << passedArguments; } headerFile << R"cpp() } }; @@ -695,29 +735,6 @@ void Generator::outputObjectDeclaration( } )cpp"; - if (!_loader.isIntrospection()) - { - headerFile << R"cpp( - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::)cpp" - << objectType.cppType << R"cpp(Stubs::HasBeginSelectionSet) - { - _pimpl->beginSelectionSet(params); - } - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (stub::)cpp" - << objectType.cppType << R"cpp(Stubs::HasEndSelectionSet) - { - _pimpl->endSelectionSet(params); - } - } -)cpp"; - } - for (const auto& outputField : objectType.fields) { std::string fieldName(outputField.cppName); @@ -738,33 +755,81 @@ void Generator::outputObjectDeclaration( { )cpp"; - if (!_options.noStubs && !_loader.isIntrospection()) + std::ostringstream ossPassedArguments; + bool firstArgument = true; + + for (const auto& argument : outputField.arguments) { - headerFile << R"cpp(if constexpr (stub::)cpp" << objectType.cppType - << R"cpp(Stubs::Has)cpp" << fieldName << R"cpp() + if (!firstArgument) { - )cpp"; + ossPassedArguments << R"cpp(, )cpp"; + } + + ossPassedArguments << R"cpp(std::move()cpp" << argument.cppName << R"cpp(Arg))cpp"; + firstArgument = false; } - headerFile << R"cpp(return { _pimpl->)cpp" << outputField.accessor << fieldName - << R"cpp((std::move(params))cpp"; + const auto passedArguments = ossPassedArguments.str(); - for (const auto& argument : outputField.arguments) + if (_loader.isIntrospection()) { - headerFile << R"cpp(, std::move()cpp" << argument.cppName << R"cpp(Arg))cpp"; - } + headerFile << R"cpp(return { _pimpl->)cpp" << outputField.accessor << fieldName + << R"cpp((std::move(params))cpp"; - headerFile << R"cpp() };)cpp"; + if (!passedArguments.empty()) + { + headerFile << R"cpp(, )cpp" << passedArguments; + } - if (!_options.noStubs && !_loader.isIntrospection()) + headerFile << R"cpp() };)cpp"; + } + else { - headerFile << R"cpp( + headerFile << R"cpp(if constexpr (methods::)cpp" << objectType.cppType + << R"cpp(Method::WithParams)cpp" << fieldName << R"cpp() + { + return { _pimpl->)cpp" + << outputField.accessor << fieldName << R"cpp((std::move(params))cpp"; + + if (!passedArguments.empty()) + { + headerFile << R"cpp(, )cpp" << passedArguments; + } + + headerFile << R"cpp() }; + } + else if constexpr (methods::)cpp" + << objectType.cppType << R"cpp(Method::NoParams)cpp" << fieldName + << R"cpp() + { + return { _pimpl->)cpp" + << outputField.accessor << fieldName << R"cpp(()cpp"; + + if (!passedArguments.empty()) + { + headerFile << passedArguments; + } + + headerFile << R"cpp() }; } else { - throw std::runtime_error(R"ex()cpp" - << objectType.cppType << R"cpp(::)cpp" << outputField.accessor << fieldName - << R"cpp( is not implemented)ex"); + )cpp"; + + if (_options.noStubs) + { + headerFile << R"cpp(static_assert(false, R"msg()cpp" << objectType.cppType + << R"cpp(::)cpp" << outputField.accessor << fieldName + << R"cpp( is not implemented)msg");)cpp"; + } + else + { + headerFile << R"cpp(throw std::runtime_error(R"ex()cpp" + << objectType.cppType << R"cpp(::)cpp" << outputField.accessor + << fieldName << R"cpp( is not implemented)ex");)cpp"; + } + + headerFile << R"cpp( })cpp"; } @@ -773,6 +838,29 @@ void Generator::outputObjectDeclaration( )cpp"; } + if (!_loader.isIntrospection()) + { + headerFile << R"cpp( + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::)cpp" + << objectType.cppType << R"cpp(Method::HasBeginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::)cpp" + << objectType.cppType << R"cpp(Method::HasEndSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } +)cpp"; + } + headerFile << R"cpp( private: const std::shared_ptr _pimpl; @@ -1403,7 +1491,8 @@ Operations::Operations()cpp"; { bool firstValue = true; - sourceFile << R"cpp( type)cpp" << unionType.cppType << R"cpp(->AddPossibleTypes({ + sourceFile << R"cpp( type)cpp" << unionType.cppType + << R"cpp(->AddPossibleTypes({ )cpp"; for (const auto& unionOption : unionType.options) @@ -2461,7 +2550,7 @@ std::vector Generator::outputSeparateFiles() const noexcept // Output the stub concepts std::ostringstream ossConceptNamespace; - ossConceptNamespace << R"cpp(stub::)cpp" << objectType.cppType << R"cpp(Stubs)cpp"; + ossConceptNamespace << R"cpp(methods::)cpp" << objectType.cppType << R"cpp(Method)cpp"; const auto conceptNamespace = ossConceptNamespace.str(); NamespaceScope stubNamespace { headerFile, conceptNamespace }; From ce83f7104edc2f31fb4348f1126b29b8fadfb4b2 Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Wed, 1 Dec 2021 11:55:08 -0800 Subject: [PATCH 036/119] Restore r-value reference parameters where it makes sense --- samples/today/TodayMock.cpp | 26 +++++++++++++------------- samples/today/TodayMock.h | 28 ++++++++++++++-------------- 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/samples/today/TodayMock.cpp b/samples/today/TodayMock.cpp index 9932d4a7..68cd7b3d 100644 --- a/samples/today/TodayMock.cpp +++ b/samples/today/TodayMock.cpp @@ -292,8 +292,8 @@ struct EdgeConstraints std::future> Query::getAppointments( const service::FieldParams& params, std::optional first, - std::optional after, std::optional last, - std::optional before) + std::optional&& after, std::optional last, + std::optional&& before) { auto spThis = shared_from_this(); auto state = params.state; @@ -321,8 +321,8 @@ std::future> Query::getAppointmen std::future> Query::getTasks( const service::FieldParams& params, std::optional first, - std::optional after, std::optional last, - std::optional before) + std::optional&& after, std::optional last, + std::optional&& before) { auto spThis = shared_from_this(); auto state = params.state; @@ -350,8 +350,8 @@ std::future> Query::getTasks( std::future> Query::getUnreadCounts( const service::FieldParams& params, std::optional first, - std::optional after, std::optional last, - std::optional before) + std::optional&& after, std::optional last, + std::optional&& before) { auto spThis = shared_from_this(); auto state = params.state; @@ -378,7 +378,7 @@ std::future> Query::getUnreadCounts( } std::vector> Query::getAppointmentsById( - const service::FieldParams& params, std::vector&& ids) + const service::FieldParams& params, const std::vector& ids) { std::vector> result(ids.size()); @@ -393,7 +393,7 @@ std::vector> Query::getAppointmentsById( } std::vector> Query::getTasksById( - const service::FieldParams& params, std::vector&& ids) + const service::FieldParams& params, const std::vector& ids) { std::vector> result(ids.size()); @@ -408,7 +408,7 @@ std::vector> Query::getTasksById( } std::vector> Query::getUnreadCountsById( - const service::FieldParams& params, std::vector&& ids) + const service::FieldParams& params, const std::vector& ids) { std::vector> result(ids.size()); @@ -422,7 +422,7 @@ std::vector> Query::getUnreadCountsById( return result; } -std::shared_ptr Query::getNested(service::FieldParams params) +std::shared_ptr Query::getNested(service::FieldParams&& params) { return std::make_shared(std::make_shared(std::move(params), 1)); } @@ -445,7 +445,7 @@ TaskState Query::getTestTaskState() } std::vector> Query::getAnyType( - const service::FieldParams& params, std::vector&& idsArg) + const service::FieldParams& params, const std::vector&) { loadAppointments(params.state); @@ -468,7 +468,7 @@ Mutation::Mutation(completeTaskMutation&& mutateCompleteTask) } std::shared_ptr Mutation::applyCompleteTask( - CompleteTaskInput input) noexcept + CompleteTaskInput&& input) noexcept { return std::make_shared(_mutateCompleteTask(std::move(input))); } @@ -504,7 +504,7 @@ response::IntType NestedType::getDepth() const noexcept } std::shared_ptr NestedType::getNested( - service::FieldParams params) const noexcept + service::FieldParams&& params) const noexcept { return std::make_shared( std::make_shared(std::move(params), depth + 1)); diff --git a/samples/today/TodayMock.h b/samples/today/TodayMock.h index 60699934..b8b157ca 100644 --- a/samples/today/TodayMock.h +++ b/samples/today/TodayMock.h @@ -54,27 +54,27 @@ class Query : public std::enable_shared_from_this service::FieldParams params, response::IdType id); std::future> getAppointments( const service::FieldParams& params, std::optional first, - std::optional after, std::optional last, - std::optional before); + std::optional&& after, std::optional last, + std::optional&& before); std::future> getTasks( const service::FieldParams& params, std::optional first, - std::optional after, std::optional last, - std::optional before); + std::optional&& after, std::optional last, + std::optional&& before); std::future> getUnreadCounts( const service::FieldParams& params, std::optional first, - std::optional after, std::optional last, - std::optional before); + std::optional&& after, std::optional last, + std::optional&& before); std::vector> getAppointmentsById( - const service::FieldParams& params, std::vector&& ids); + const service::FieldParams& params, const std::vector& ids); std::vector> getTasksById( - const service::FieldParams& params, std::vector&& ids); + const service::FieldParams& params, const std::vector& ids); std::vector> getUnreadCountsById( - const service::FieldParams& params, std::vector&& ids); - std::shared_ptr getNested(service::FieldParams params); + const service::FieldParams& params, const std::vector& ids); + std::shared_ptr getNested(service::FieldParams&& params); std::vector> getExpensive(); TaskState getTestTaskState(); std::vector> getAnyType( - const service::FieldParams& params, std::vector&& idsArg); + const service::FieldParams& params, const std::vector& ids); private: std::shared_ptr findAppointment( @@ -438,7 +438,7 @@ class Mutation static double getFloat() noexcept; std::shared_ptr applyCompleteTask( - CompleteTaskInput input) noexcept; + CompleteTaskInput&& input) noexcept; response::FloatType applySetFloat(response::FloatType valueArg) noexcept; private: @@ -551,7 +551,7 @@ class NodeChange } std::shared_ptr getNodeChange( - const service::FieldParams& params, response::IdType idArg) const + const service::FieldParams& params, response::IdType&& idArg) const { return std::static_pointer_cast( _changeNode(params.state, std::move(idArg))); @@ -579,7 +579,7 @@ class NestedType explicit NestedType(service::FieldParams&& params, int depth); response::IntType getDepth() const noexcept; - std::shared_ptr getNested(service::FieldParams params) const noexcept; + std::shared_ptr getNested(service::FieldParams&& params) const noexcept; static std::stack getCapturedParams() noexcept; From 6233f756fdb135083e5aae550bfb387249d487b3 Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Wed, 1 Dec 2021 12:02:35 -0800 Subject: [PATCH 037/119] Use references for large parameters --- samples/star_wars/DroidData.cpp | 5 +++-- samples/star_wars/DroidData.h | 6 +++--- samples/star_wars/HumanData.cpp | 4 ++-- samples/star_wars/HumanData.h | 5 +++-- samples/star_wars/MutationData.cpp | 2 +- samples/star_wars/MutationData.h | 2 +- samples/star_wars/QueryData.cpp | 10 +++++----- samples/star_wars/QueryData.h | 10 +++++----- samples/star_wars/ReviewData.cpp | 2 +- samples/star_wars/ReviewData.h | 2 +- 10 files changed, 25 insertions(+), 23 deletions(-) diff --git a/samples/star_wars/DroidData.cpp b/samples/star_wars/DroidData.cpp index 4e8fcb98..7323f3cd 100644 --- a/samples/star_wars/DroidData.cpp +++ b/samples/star_wars/DroidData.cpp @@ -7,8 +7,9 @@ namespace graphql::learn { -Droid::Droid(response::StringType id, std::optional name, - std::vector appearsIn, std::optional primaryFunction) noexcept +Droid::Droid(response::StringType&& id, std::optional&& name, + std::vector&& appearsIn, + std::optional&& primaryFunction) noexcept : id_ { std::move(id) } , name_ { std::move(name) } , appearsIn_ { std::move(appearsIn) } diff --git a/samples/star_wars/DroidData.h b/samples/star_wars/DroidData.h index 525887b9..9d587529 100644 --- a/samples/star_wars/DroidData.h +++ b/samples/star_wars/DroidData.h @@ -17,9 +17,9 @@ class Human; class Droid { public: - explicit Droid(response::StringType id, std::optional name, - std::vector appearsIn, - std::optional primaryFunction) noexcept; + explicit Droid(response::StringType&& id, std::optional&& name, + std::vector&& appearsIn, + std::optional&& primaryFunction) noexcept; const response::StringType& id() const noexcept; void addFriends(std::vector friends) noexcept; diff --git a/samples/star_wars/HumanData.cpp b/samples/star_wars/HumanData.cpp index c145ad56..84685383 100644 --- a/samples/star_wars/HumanData.cpp +++ b/samples/star_wars/HumanData.cpp @@ -7,8 +7,8 @@ namespace graphql::learn { -Human::Human(response::StringType id, std::optional name, - std::vector appearsIn, std::optional homePlanet) noexcept +Human::Human(response::StringType&& id, std::optional&& name, + std::vector&& appearsIn, std::optional&& homePlanet) noexcept : id_ { std::move(id) } , name_ { std::move(name) } , appearsIn_ { std::move(appearsIn) } diff --git a/samples/star_wars/HumanData.h b/samples/star_wars/HumanData.h index 7dff6ebf..10048bee 100644 --- a/samples/star_wars/HumanData.h +++ b/samples/star_wars/HumanData.h @@ -15,8 +15,9 @@ namespace graphql::learn { class Human { public: - explicit Human(response::StringType id, std::optional name, - std::vector appearsIn, std::optional homePlanet) noexcept; + explicit Human(response::StringType&& id, std::optional&& name, + std::vector&& appearsIn, + std::optional&& homePlanet) noexcept; const response::StringType& id() const noexcept; void addFriends(std::vector friends) noexcept; diff --git a/samples/star_wars/MutationData.cpp b/samples/star_wars/MutationData.cpp index 9a7284f0..a9212d5b 100644 --- a/samples/star_wars/MutationData.cpp +++ b/samples/star_wars/MutationData.cpp @@ -10,7 +10,7 @@ Mutation::Mutation() noexcept } std::shared_ptr Mutation::applyCreateReview( - Episode epArg, ReviewInput reviewArg) noexcept + Episode epArg, ReviewInput&& reviewArg) noexcept { auto review = std::make_shared(reviewArg.stars, std::move(reviewArg.commentary)); diff --git a/samples/star_wars/MutationData.h b/samples/star_wars/MutationData.h index 313dde27..3b3fc9c0 100644 --- a/samples/star_wars/MutationData.h +++ b/samples/star_wars/MutationData.h @@ -18,7 +18,7 @@ class Mutation explicit Mutation() noexcept; std::shared_ptr applyCreateReview( - Episode epArg, ReviewInput reviewArg) noexcept; + Episode epArg, ReviewInput&& reviewArg) noexcept; private: // This is just an example, the Mutation object probably shouldn't own a mutable store for the diff --git a/samples/star_wars/QueryData.cpp b/samples/star_wars/QueryData.cpp index 9a921eb6..799fca5a 100644 --- a/samples/star_wars/QueryData.cpp +++ b/samples/star_wars/QueryData.cpp @@ -5,9 +5,9 @@ namespace graphql::learn { -Query::Query(std::map heroes, - std::map> humans, - std::map> droids) noexcept +Query::Query(std::map&& heroes, + std::map>&& humans, + std::map>&& droids) noexcept : heroes_ { std::move(heroes) } , humans_ { std::move(humans) } , droids_ { std::move(droids) } @@ -42,7 +42,7 @@ std::shared_ptr Query::getHero(std::optional episodeAr return result; } -std::shared_ptr Query::getHuman(response::StringType idArg) const noexcept +std::shared_ptr Query::getHuman(const response::StringType& idArg) const noexcept { std::shared_ptr result; @@ -54,7 +54,7 @@ std::shared_ptr Query::getHuman(response::StringType idArg) const return std::make_shared(std::move(result)); } -std::shared_ptr Query::getDroid(response::StringType idArg) const noexcept +std::shared_ptr Query::getDroid(const response::StringType& idArg) const noexcept { std::shared_ptr result; diff --git a/samples/star_wars/QueryData.h b/samples/star_wars/QueryData.h index 2f31ac70..bcc96989 100644 --- a/samples/star_wars/QueryData.h +++ b/samples/star_wars/QueryData.h @@ -16,13 +16,13 @@ namespace graphql::learn { class Query { public: - explicit Query(std::map heroes, - std::map> humans, - std::map> droids) noexcept; + explicit Query(std::map&& heroes, + std::map>&& humans, + std::map>&& droids) noexcept; std::shared_ptr getHero(std::optional episodeArg) const noexcept; - std::shared_ptr getHuman(response::StringType idArg) const noexcept; - std::shared_ptr getDroid(response::StringType idArg) const noexcept; + std::shared_ptr getHuman(const response::StringType& idArg) const noexcept; + std::shared_ptr getDroid(const response::StringType& idArg) const noexcept; private: const std::map heroes_; diff --git a/samples/star_wars/ReviewData.cpp b/samples/star_wars/ReviewData.cpp index c16f24aa..9d7ff4e0 100644 --- a/samples/star_wars/ReviewData.cpp +++ b/samples/star_wars/ReviewData.cpp @@ -5,7 +5,7 @@ namespace graphql::learn { -Review::Review(response::IntType stars, std::optional commentary) noexcept +Review::Review(response::IntType stars, std::optional&& commentary) noexcept : stars_ { stars } , commentary_ { std::move(commentary) } { diff --git a/samples/star_wars/ReviewData.h b/samples/star_wars/ReviewData.h index 199cda2c..69f2195b 100644 --- a/samples/star_wars/ReviewData.h +++ b/samples/star_wars/ReviewData.h @@ -14,7 +14,7 @@ class Review { public: explicit Review( - response::IntType stars, std::optional commentary) noexcept; + response::IntType stars, std::optional&& commentary) noexcept; response::IntType getStars() const noexcept; std::optional getCommentary() const noexcept; From 65ed7b79c32da7668a7d69d5b141fb5dfc1b4ff6 Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Wed, 1 Dec 2021 12:25:20 -0800 Subject: [PATCH 038/119] Update static_assert for missing methods without stubs --- samples/learn/DroidObject.h | 35 +++++++++-------------------- samples/learn/HumanObject.h | 35 +++++++++-------------------- samples/learn/MutationObject.h | 7 ++---- samples/learn/QueryObject.h | 21 +++++------------- samples/learn/ReviewObject.h | 14 ++++-------- src/SchemaGenerator.cpp | 40 +++++++++++++++++++--------------- 6 files changed, 55 insertions(+), 97 deletions(-) diff --git a/samples/learn/DroidObject.h b/samples/learn/DroidObject.h index 77582c94..532d491d 100644 --- a/samples/learn/DroidObject.h +++ b/samples/learn/DroidObject.h @@ -125,13 +125,10 @@ class Droid { return { _pimpl->getId(std::move(params)) }; } - else if constexpr (methods::DroidMethod::NoParamsId) - { - return { _pimpl->getId() }; - } else { - static_assert(false, R"msg(Droid::getId is not implemented)msg"); + static_assert(methods::DroidMethod::NoParamsId); + return { _pimpl->getId() }; } } @@ -141,13 +138,10 @@ class Droid { return { _pimpl->getName(std::move(params)) }; } - else if constexpr (methods::DroidMethod::NoParamsName) - { - return { _pimpl->getName() }; - } else { - static_assert(false, R"msg(Droid::getName is not implemented)msg"); + static_assert(methods::DroidMethod::NoParamsName); + return { _pimpl->getName() }; } } @@ -157,13 +151,10 @@ class Droid { return { _pimpl->getFriends(std::move(params)) }; } - else if constexpr (methods::DroidMethod::NoParamsFriends) - { - return { _pimpl->getFriends() }; - } else { - static_assert(false, R"msg(Droid::getFriends is not implemented)msg"); + static_assert(methods::DroidMethod::NoParamsFriends); + return { _pimpl->getFriends() }; } } @@ -173,13 +164,10 @@ class Droid { return { _pimpl->getAppearsIn(std::move(params)) }; } - else if constexpr (methods::DroidMethod::NoParamsAppearsIn) - { - return { _pimpl->getAppearsIn() }; - } else { - static_assert(false, R"msg(Droid::getAppearsIn is not implemented)msg"); + static_assert(methods::DroidMethod::NoParamsAppearsIn); + return { _pimpl->getAppearsIn() }; } } @@ -189,13 +177,10 @@ class Droid { return { _pimpl->getPrimaryFunction(std::move(params)) }; } - else if constexpr (methods::DroidMethod::NoParamsPrimaryFunction) - { - return { _pimpl->getPrimaryFunction() }; - } else { - static_assert(false, R"msg(Droid::getPrimaryFunction is not implemented)msg"); + static_assert(methods::DroidMethod::NoParamsPrimaryFunction); + return { _pimpl->getPrimaryFunction() }; } } diff --git a/samples/learn/HumanObject.h b/samples/learn/HumanObject.h index 1ed2c164..aa943cc2 100644 --- a/samples/learn/HumanObject.h +++ b/samples/learn/HumanObject.h @@ -125,13 +125,10 @@ class Human { return { _pimpl->getId(std::move(params)) }; } - else if constexpr (methods::HumanMethod::NoParamsId) - { - return { _pimpl->getId() }; - } else { - static_assert(false, R"msg(Human::getId is not implemented)msg"); + static_assert(methods::HumanMethod::NoParamsId); + return { _pimpl->getId() }; } } @@ -141,13 +138,10 @@ class Human { return { _pimpl->getName(std::move(params)) }; } - else if constexpr (methods::HumanMethod::NoParamsName) - { - return { _pimpl->getName() }; - } else { - static_assert(false, R"msg(Human::getName is not implemented)msg"); + static_assert(methods::HumanMethod::NoParamsName); + return { _pimpl->getName() }; } } @@ -157,13 +151,10 @@ class Human { return { _pimpl->getFriends(std::move(params)) }; } - else if constexpr (methods::HumanMethod::NoParamsFriends) - { - return { _pimpl->getFriends() }; - } else { - static_assert(false, R"msg(Human::getFriends is not implemented)msg"); + static_assert(methods::HumanMethod::NoParamsFriends); + return { _pimpl->getFriends() }; } } @@ -173,13 +164,10 @@ class Human { return { _pimpl->getAppearsIn(std::move(params)) }; } - else if constexpr (methods::HumanMethod::NoParamsAppearsIn) - { - return { _pimpl->getAppearsIn() }; - } else { - static_assert(false, R"msg(Human::getAppearsIn is not implemented)msg"); + static_assert(methods::HumanMethod::NoParamsAppearsIn); + return { _pimpl->getAppearsIn() }; } } @@ -189,13 +177,10 @@ class Human { return { _pimpl->getHomePlanet(std::move(params)) }; } - else if constexpr (methods::HumanMethod::NoParamsHomePlanet) - { - return { _pimpl->getHomePlanet() }; - } else { - static_assert(false, R"msg(Human::getHomePlanet is not implemented)msg"); + static_assert(methods::HumanMethod::NoParamsHomePlanet); + return { _pimpl->getHomePlanet() }; } } diff --git a/samples/learn/MutationObject.h b/samples/learn/MutationObject.h index 33913fd5..f7cc1bc0 100644 --- a/samples/learn/MutationObject.h +++ b/samples/learn/MutationObject.h @@ -72,13 +72,10 @@ class Mutation { return { _pimpl->applyCreateReview(std::move(params), std::move(epArg), std::move(reviewArg)) }; } - else if constexpr (methods::MutationMethod::NoParamsCreateReview) - { - return { _pimpl->applyCreateReview(std::move(epArg), std::move(reviewArg)) }; - } else { - static_assert(false, R"msg(Mutation::applyCreateReview is not implemented)msg"); + static_assert(methods::MutationMethod::NoParamsCreateReview); + return { _pimpl->applyCreateReview(std::move(epArg), std::move(reviewArg)) }; } } diff --git a/samples/learn/QueryObject.h b/samples/learn/QueryObject.h index 3515a964..cd681e01 100644 --- a/samples/learn/QueryObject.h +++ b/samples/learn/QueryObject.h @@ -104,13 +104,10 @@ class Query { return { _pimpl->getHero(std::move(params), std::move(episodeArg)) }; } - else if constexpr (methods::QueryMethod::NoParamsHero) - { - return { _pimpl->getHero(std::move(episodeArg)) }; - } else { - static_assert(false, R"msg(Query::getHero is not implemented)msg"); + static_assert(methods::QueryMethod::NoParamsHero); + return { _pimpl->getHero(std::move(episodeArg)) }; } } @@ -120,13 +117,10 @@ class Query { return { _pimpl->getHuman(std::move(params), std::move(idArg)) }; } - else if constexpr (methods::QueryMethod::NoParamsHuman) - { - return { _pimpl->getHuman(std::move(idArg)) }; - } else { - static_assert(false, R"msg(Query::getHuman is not implemented)msg"); + static_assert(methods::QueryMethod::NoParamsHuman); + return { _pimpl->getHuman(std::move(idArg)) }; } } @@ -136,13 +130,10 @@ class Query { return { _pimpl->getDroid(std::move(params), std::move(idArg)) }; } - else if constexpr (methods::QueryMethod::NoParamsDroid) - { - return { _pimpl->getDroid(std::move(idArg)) }; - } else { - static_assert(false, R"msg(Query::getDroid is not implemented)msg"); + static_assert(methods::QueryMethod::NoParamsDroid); + return { _pimpl->getDroid(std::move(idArg)) }; } } diff --git a/samples/learn/ReviewObject.h b/samples/learn/ReviewObject.h index 03ce6379..1ea068ad 100644 --- a/samples/learn/ReviewObject.h +++ b/samples/learn/ReviewObject.h @@ -86,13 +86,10 @@ class Review { return { _pimpl->getStars(std::move(params)) }; } - else if constexpr (methods::ReviewMethod::NoParamsStars) - { - return { _pimpl->getStars() }; - } else { - static_assert(false, R"msg(Review::getStars is not implemented)msg"); + static_assert(methods::ReviewMethod::NoParamsStars); + return { _pimpl->getStars() }; } } @@ -102,13 +99,10 @@ class Review { return { _pimpl->getCommentary(std::move(params)) }; } - else if constexpr (methods::ReviewMethod::NoParamsCommentary) - { - return { _pimpl->getCommentary() }; - } else { - static_assert(false, R"msg(Review::getCommentary is not implemented)msg"); + static_assert(methods::ReviewMethod::NoParamsCommentary); + return { _pimpl->getCommentary() }; } } diff --git a/src/SchemaGenerator.cpp b/src/SchemaGenerator.cpp index 7bbc59bc..04fe3c46 100644 --- a/src/SchemaGenerator.cpp +++ b/src/SchemaGenerator.cpp @@ -798,10 +798,24 @@ void Generator::outputObjectDeclaration( headerFile << R"cpp() }; } - else if constexpr (methods::)cpp" - << objectType.cppType << R"cpp(Method::NoParams)cpp" << fieldName - << R"cpp() + else)cpp"; + + if (_options.noStubs) + { + headerFile << R"cpp( + { + static_assert(methods::)cpp" + << objectType.cppType << R"cpp(Method::NoParams)cpp" << fieldName + << R"cpp();)cpp"; + } + else { + headerFile << R"cpp( if constexpr (methods::)cpp" << objectType.cppType + << R"cpp(Method::NoParams)cpp" << fieldName << R"cpp() + {)cpp"; + } + + headerFile << R"cpp( return { _pimpl->)cpp" << outputField.accessor << fieldName << R"cpp(()cpp"; @@ -811,26 +825,18 @@ void Generator::outputObjectDeclaration( } headerFile << R"cpp() }; - } - else - { - )cpp"; + })cpp"; - if (_options.noStubs) + if (!_options.noStubs) { - headerFile << R"cpp(static_assert(false, R"msg()cpp" << objectType.cppType - << R"cpp(::)cpp" << outputField.accessor << fieldName - << R"cpp( is not implemented)msg");)cpp"; - } + headerFile << R"cpp( else { - headerFile << R"cpp(throw std::runtime_error(R"ex()cpp" + throw std::runtime_error(R"ex()cpp" << objectType.cppType << R"cpp(::)cpp" << outputField.accessor - << fieldName << R"cpp( is not implemented)ex");)cpp"; - } - - headerFile << R"cpp( + << fieldName << R"cpp( is not implemented)ex"); })cpp"; + } } headerFile << R"cpp( From d735105aca0ce26db19e3188bc36118fad99a2ef Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Wed, 1 Dec 2021 13:14:24 -0800 Subject: [PATCH 039/119] Return by const reference where applicable --- samples/star_wars/DroidData.cpp | 11 +++-------- samples/star_wars/DroidData.h | 7 +++---- samples/star_wars/HumanData.cpp | 11 +++-------- samples/star_wars/HumanData.h | 7 +++---- samples/star_wars/ReviewData.cpp | 2 +- samples/star_wars/ReviewData.h | 2 +- samples/star_wars/StarWarsData.cpp | 14 +++++++------- samples/today/TodayMock.h | 2 +- 8 files changed, 22 insertions(+), 34 deletions(-) diff --git a/samples/star_wars/DroidData.cpp b/samples/star_wars/DroidData.cpp index 7323f3cd..ea47c43a 100644 --- a/samples/star_wars/DroidData.cpp +++ b/samples/star_wars/DroidData.cpp @@ -17,11 +17,6 @@ Droid::Droid(response::StringType&& id, std::optional&& na { } -const response::StringType& Droid::id() const noexcept -{ - return id_; -} - void Droid::addFriends( std::vector, std::shared_ptr>> friends) noexcept { @@ -41,12 +36,12 @@ void Droid::addFriends( }); } -response::StringType Droid::getId() const noexcept +const response::StringType& Droid::getId() const noexcept { return id_; } -std::optional Droid::getName() const noexcept +const std::optional& Droid::getName() const noexcept { return name_; } @@ -100,7 +95,7 @@ std::optional>> Droid::getAppearsIn() const n return result.empty() ? std::nullopt : std::make_optional(std::move(result)); } -std::optional Droid::getPrimaryFunction() const noexcept +const std::optional& Droid::getPrimaryFunction() const noexcept { return primaryFunction_; } diff --git a/samples/star_wars/DroidData.h b/samples/star_wars/DroidData.h index 9d587529..346ee067 100644 --- a/samples/star_wars/DroidData.h +++ b/samples/star_wars/DroidData.h @@ -21,14 +21,13 @@ class Droid std::vector&& appearsIn, std::optional&& primaryFunction) noexcept; - const response::StringType& id() const noexcept; void addFriends(std::vector friends) noexcept; - response::StringType getId() const noexcept; - std::optional getName() const noexcept; + const response::StringType& getId() const noexcept; + const std::optional& getName() const noexcept; std::optional>> getFriends() const noexcept; std::optional>> getAppearsIn() const noexcept; - std::optional getPrimaryFunction() const noexcept; + const std::optional& getPrimaryFunction() const noexcept; private: const response::StringType id_; diff --git a/samples/star_wars/HumanData.cpp b/samples/star_wars/HumanData.cpp index 84685383..5ce519d2 100644 --- a/samples/star_wars/HumanData.cpp +++ b/samples/star_wars/HumanData.cpp @@ -16,11 +16,6 @@ Human::Human(response::StringType&& id, std::optional&& na { } -const response::StringType& Human::id() const noexcept -{ - return id_; -} - void Human::addFriends(std::vector friends) noexcept { friends_.resize(friends.size()); @@ -39,12 +34,12 @@ void Human::addFriends(std::vector friends) noexcept }); } -response::StringType Human::getId() const noexcept +const response::StringType& Human::getId() const noexcept { return id_; } -std::optional Human::getName() const noexcept +const std::optional& Human::getName() const noexcept { return name_; } @@ -98,7 +93,7 @@ std::optional>> Human::getAppearsIn() const n return result.empty() ? std::nullopt : std::make_optional(std::move(result)); } -std::optional Human::getHomePlanet() const noexcept +const std::optional& Human::getHomePlanet() const noexcept { return homePlanet_; } diff --git a/samples/star_wars/HumanData.h b/samples/star_wars/HumanData.h index 10048bee..1c46d8eb 100644 --- a/samples/star_wars/HumanData.h +++ b/samples/star_wars/HumanData.h @@ -19,14 +19,13 @@ class Human std::vector&& appearsIn, std::optional&& homePlanet) noexcept; - const response::StringType& id() const noexcept; void addFriends(std::vector friends) noexcept; - response::StringType getId() const noexcept; - std::optional getName() const noexcept; + const response::StringType& getId() const noexcept; + const std::optional& getName() const noexcept; std::optional>> getFriends() const noexcept; std::optional>> getAppearsIn() const noexcept; - std::optional getHomePlanet() const noexcept; + const std::optional& getHomePlanet() const noexcept; private: const response::StringType id_; diff --git a/samples/star_wars/ReviewData.cpp b/samples/star_wars/ReviewData.cpp index 9d7ff4e0..814b53f4 100644 --- a/samples/star_wars/ReviewData.cpp +++ b/samples/star_wars/ReviewData.cpp @@ -16,7 +16,7 @@ response::IntType Review::getStars() const noexcept return stars_; } -std::optional Review::getCommentary() const noexcept +const std::optional& Review::getCommentary() const noexcept { return commentary_; } diff --git a/samples/star_wars/ReviewData.h b/samples/star_wars/ReviewData.h index 69f2195b..f10565fe 100644 --- a/samples/star_wars/ReviewData.h +++ b/samples/star_wars/ReviewData.h @@ -17,7 +17,7 @@ class Review response::IntType stars, std::optional&& commentary) noexcept; response::IntType getStars() const noexcept; - std::optional getCommentary() const noexcept; + const std::optional& getCommentary() const noexcept; private: const response::IntType stars_; diff --git a/samples/star_wars/StarWarsData.cpp b/samples/star_wars/StarWarsData.cpp index d5e8457d..46013225 100644 --- a/samples/star_wars/StarWarsData.cpp +++ b/samples/star_wars/StarWarsData.cpp @@ -100,16 +100,16 @@ std::shared_ptr GetService() noexcept }; std::map> humans { - { luke->id(), luke }, - { vader->id(), vader }, - { han->id(), han }, - { leia->id(), leia }, - { tarkin->id(), tarkin }, + { luke->getId(), luke }, + { vader->getId(), vader }, + { han->getId(), han }, + { leia->getId(), leia }, + { tarkin->getId(), tarkin }, }; std::map> droids { - { threepio->id(), threepio }, - { artoo->id(), artoo }, + { threepio->getId(), threepio }, + { artoo->getId(), artoo }, }; auto query = diff --git a/samples/today/TodayMock.h b/samples/today/TodayMock.h index b8b157ca..96fbe1b6 100644 --- a/samples/today/TodayMock.h +++ b/samples/today/TodayMock.h @@ -417,7 +417,7 @@ class CompleteTaskPayload return std::make_shared(_task); } - std::optional getClientMutationId() const noexcept + const std::optional& getClientMutationId() const noexcept { return _clientMutationId; } From 006e46f3b20564280fedec40e440a1a19dfaf6bd Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Wed, 1 Dec 2021 13:18:32 -0800 Subject: [PATCH 040/119] Put back error messages on missing getter static_asserts --- samples/learn/DroidObject.h | 10 +++++----- samples/learn/HumanObject.h | 10 +++++----- samples/learn/MutationObject.h | 2 +- samples/learn/QueryObject.h | 6 +++--- samples/learn/ReviewObject.h | 4 ++-- src/SchemaGenerator.cpp | 4 +++- 6 files changed, 19 insertions(+), 17 deletions(-) diff --git a/samples/learn/DroidObject.h b/samples/learn/DroidObject.h index 532d491d..4bc06caf 100644 --- a/samples/learn/DroidObject.h +++ b/samples/learn/DroidObject.h @@ -127,7 +127,7 @@ class Droid } else { - static_assert(methods::DroidMethod::NoParamsId); + static_assert(methods::DroidMethod::NoParamsId, R"msg(Droid::getId is not implemented)msg"); return { _pimpl->getId() }; } } @@ -140,7 +140,7 @@ class Droid } else { - static_assert(methods::DroidMethod::NoParamsName); + static_assert(methods::DroidMethod::NoParamsName, R"msg(Droid::getName is not implemented)msg"); return { _pimpl->getName() }; } } @@ -153,7 +153,7 @@ class Droid } else { - static_assert(methods::DroidMethod::NoParamsFriends); + static_assert(methods::DroidMethod::NoParamsFriends, R"msg(Droid::getFriends is not implemented)msg"); return { _pimpl->getFriends() }; } } @@ -166,7 +166,7 @@ class Droid } else { - static_assert(methods::DroidMethod::NoParamsAppearsIn); + static_assert(methods::DroidMethod::NoParamsAppearsIn, R"msg(Droid::getAppearsIn is not implemented)msg"); return { _pimpl->getAppearsIn() }; } } @@ -179,7 +179,7 @@ class Droid } else { - static_assert(methods::DroidMethod::NoParamsPrimaryFunction); + static_assert(methods::DroidMethod::NoParamsPrimaryFunction, R"msg(Droid::getPrimaryFunction is not implemented)msg"); return { _pimpl->getPrimaryFunction() }; } } diff --git a/samples/learn/HumanObject.h b/samples/learn/HumanObject.h index aa943cc2..8e974b00 100644 --- a/samples/learn/HumanObject.h +++ b/samples/learn/HumanObject.h @@ -127,7 +127,7 @@ class Human } else { - static_assert(methods::HumanMethod::NoParamsId); + static_assert(methods::HumanMethod::NoParamsId, R"msg(Human::getId is not implemented)msg"); return { _pimpl->getId() }; } } @@ -140,7 +140,7 @@ class Human } else { - static_assert(methods::HumanMethod::NoParamsName); + static_assert(methods::HumanMethod::NoParamsName, R"msg(Human::getName is not implemented)msg"); return { _pimpl->getName() }; } } @@ -153,7 +153,7 @@ class Human } else { - static_assert(methods::HumanMethod::NoParamsFriends); + static_assert(methods::HumanMethod::NoParamsFriends, R"msg(Human::getFriends is not implemented)msg"); return { _pimpl->getFriends() }; } } @@ -166,7 +166,7 @@ class Human } else { - static_assert(methods::HumanMethod::NoParamsAppearsIn); + static_assert(methods::HumanMethod::NoParamsAppearsIn, R"msg(Human::getAppearsIn is not implemented)msg"); return { _pimpl->getAppearsIn() }; } } @@ -179,7 +179,7 @@ class Human } else { - static_assert(methods::HumanMethod::NoParamsHomePlanet); + static_assert(methods::HumanMethod::NoParamsHomePlanet, R"msg(Human::getHomePlanet is not implemented)msg"); return { _pimpl->getHomePlanet() }; } } diff --git a/samples/learn/MutationObject.h b/samples/learn/MutationObject.h index f7cc1bc0..12313ca4 100644 --- a/samples/learn/MutationObject.h +++ b/samples/learn/MutationObject.h @@ -74,7 +74,7 @@ class Mutation } else { - static_assert(methods::MutationMethod::NoParamsCreateReview); + static_assert(methods::MutationMethod::NoParamsCreateReview, R"msg(Mutation::applyCreateReview is not implemented)msg"); return { _pimpl->applyCreateReview(std::move(epArg), std::move(reviewArg)) }; } } diff --git a/samples/learn/QueryObject.h b/samples/learn/QueryObject.h index cd681e01..d1ad8889 100644 --- a/samples/learn/QueryObject.h +++ b/samples/learn/QueryObject.h @@ -106,7 +106,7 @@ class Query } else { - static_assert(methods::QueryMethod::NoParamsHero); + static_assert(methods::QueryMethod::NoParamsHero, R"msg(Query::getHero is not implemented)msg"); return { _pimpl->getHero(std::move(episodeArg)) }; } } @@ -119,7 +119,7 @@ class Query } else { - static_assert(methods::QueryMethod::NoParamsHuman); + static_assert(methods::QueryMethod::NoParamsHuman, R"msg(Query::getHuman is not implemented)msg"); return { _pimpl->getHuman(std::move(idArg)) }; } } @@ -132,7 +132,7 @@ class Query } else { - static_assert(methods::QueryMethod::NoParamsDroid); + static_assert(methods::QueryMethod::NoParamsDroid, R"msg(Query::getDroid is not implemented)msg"); return { _pimpl->getDroid(std::move(idArg)) }; } } diff --git a/samples/learn/ReviewObject.h b/samples/learn/ReviewObject.h index 1ea068ad..f67eec85 100644 --- a/samples/learn/ReviewObject.h +++ b/samples/learn/ReviewObject.h @@ -88,7 +88,7 @@ class Review } else { - static_assert(methods::ReviewMethod::NoParamsStars); + static_assert(methods::ReviewMethod::NoParamsStars, R"msg(Review::getStars is not implemented)msg"); return { _pimpl->getStars() }; } } @@ -101,7 +101,7 @@ class Review } else { - static_assert(methods::ReviewMethod::NoParamsCommentary); + static_assert(methods::ReviewMethod::NoParamsCommentary, R"msg(Review::getCommentary is not implemented)msg"); return { _pimpl->getCommentary() }; } } diff --git a/src/SchemaGenerator.cpp b/src/SchemaGenerator.cpp index 04fe3c46..bc026f55 100644 --- a/src/SchemaGenerator.cpp +++ b/src/SchemaGenerator.cpp @@ -806,7 +806,9 @@ void Generator::outputObjectDeclaration( { static_assert(methods::)cpp" << objectType.cppType << R"cpp(Method::NoParams)cpp" << fieldName - << R"cpp();)cpp"; + << R"cpp(, R"msg()cpp" << objectType.cppType << R"cpp(::)cpp" + << outputField.accessor << fieldName + << R"cpp( is not implemented)msg");)cpp"; } else { From eadbea90dfa9752dc57313b88fdd8eefbb9f97e4 Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Wed, 1 Dec 2021 14:11:12 -0800 Subject: [PATCH 041/119] Simplify the Introspection implementation --- .../introspection/Introspection.h | 112 ++++++--------- .../introspection/IntrospectionSchema.h | 128 +++++++++--------- src/Introspection.cpp | 90 +++++------- src/SchemaGenerator.cpp | 12 +- 4 files changed, 145 insertions(+), 197 deletions(-) diff --git a/include/graphqlservice/introspection/Introspection.h b/include/graphqlservice/introspection/Introspection.h index dbce12cc..0b76083e 100644 --- a/include/graphqlservice/introspection/Introspection.h +++ b/include/graphqlservice/introspection/Introspection.h @@ -25,17 +25,12 @@ class Schema GRAPHQLINTROSPECTION_EXPORT explicit Schema(const std::shared_ptr& schema); // Accessors - GRAPHQLINTROSPECTION_EXPORT service::FieldResult>> - getTypes(service::FieldParams&& params) const; - GRAPHQLINTROSPECTION_EXPORT service::FieldResult> getQueryType( - service::FieldParams&& params) const; - GRAPHQLINTROSPECTION_EXPORT service::FieldResult> getMutationType( - service::FieldParams&& params) const; - GRAPHQLINTROSPECTION_EXPORT service::FieldResult> - getSubscriptionType(service::FieldParams&& params) const; - GRAPHQLINTROSPECTION_EXPORT service::FieldResult< - std::vector>> - getDirectives(service::FieldParams&& params) const; + GRAPHQLINTROSPECTION_EXPORT std::vector> getTypes() const; + GRAPHQLINTROSPECTION_EXPORT std::shared_ptr getQueryType() const; + GRAPHQLINTROSPECTION_EXPORT std::shared_ptr getMutationType() const; + GRAPHQLINTROSPECTION_EXPORT std::shared_ptr getSubscriptionType() const; + GRAPHQLINTROSPECTION_EXPORT std::vector> getDirectives() + const; private: const std::shared_ptr _schema; @@ -47,31 +42,20 @@ class Type GRAPHQLINTROSPECTION_EXPORT explicit Type(const std::shared_ptr& type); // Accessors - GRAPHQLINTROSPECTION_EXPORT service::FieldResult getKind( - service::FieldParams&&) const; - GRAPHQLINTROSPECTION_EXPORT service::FieldResult> getName( - service::FieldParams&& params) const; - GRAPHQLINTROSPECTION_EXPORT service::FieldResult> - getDescription(service::FieldParams&& params) const; - GRAPHQLINTROSPECTION_EXPORT service::FieldResult< - std::optional>>> - getFields(service::FieldParams&& params, - std::optional&& includeDeprecatedArg) const; - GRAPHQLINTROSPECTION_EXPORT service::FieldResult< - std::optional>>> - getInterfaces(service::FieldParams&& params) const; - GRAPHQLINTROSPECTION_EXPORT service::FieldResult< - std::optional>>> - getPossibleTypes(service::FieldParams&& params) const; - GRAPHQLINTROSPECTION_EXPORT service::FieldResult< - std::optional>>> - getEnumValues(service::FieldParams&& params, - std::optional&& includeDeprecatedArg) const; - GRAPHQLINTROSPECTION_EXPORT service::FieldResult< - std::optional>>> - getInputFields(service::FieldParams&& params) const; - GRAPHQLINTROSPECTION_EXPORT service::FieldResult> getOfType( - service::FieldParams&& params) const; + GRAPHQLINTROSPECTION_EXPORT TypeKind getKind() const; + GRAPHQLINTROSPECTION_EXPORT std::optional getName() const; + GRAPHQLINTROSPECTION_EXPORT std::optional getDescription() const; + GRAPHQLINTROSPECTION_EXPORT std::optional>> + getFields(std::optional&& includeDeprecatedArg) const; + GRAPHQLINTROSPECTION_EXPORT std::optional>> + getInterfaces() const; + GRAPHQLINTROSPECTION_EXPORT std::optional>> + getPossibleTypes() const; + GRAPHQLINTROSPECTION_EXPORT std::optional>> + getEnumValues(std::optional&& includeDeprecatedArg) const; + GRAPHQLINTROSPECTION_EXPORT std::optional>> + getInputFields() const; + GRAPHQLINTROSPECTION_EXPORT std::shared_ptr getOfType() const; private: const std::shared_ptr _type; @@ -83,19 +67,12 @@ class Field GRAPHQLINTROSPECTION_EXPORT explicit Field(const std::shared_ptr& field); // Accessors - GRAPHQLINTROSPECTION_EXPORT service::FieldResult getName( - service::FieldParams&& params) const; - GRAPHQLINTROSPECTION_EXPORT service::FieldResult> - getDescription(service::FieldParams&& params) const; - GRAPHQLINTROSPECTION_EXPORT service::FieldResult< - std::vector>> - getArgs(service::FieldParams&& params) const; - GRAPHQLINTROSPECTION_EXPORT service::FieldResult> getType( - service::FieldParams&& params) const; - GRAPHQLINTROSPECTION_EXPORT service::FieldResult getIsDeprecated( - service::FieldParams&& params) const; - GRAPHQLINTROSPECTION_EXPORT service::FieldResult> - getDeprecationReason(service::FieldParams&& params) const; + GRAPHQLINTROSPECTION_EXPORT response::StringType getName() const; + GRAPHQLINTROSPECTION_EXPORT std::optional getDescription() const; + GRAPHQLINTROSPECTION_EXPORT std::vector> getArgs() const; + GRAPHQLINTROSPECTION_EXPORT std::shared_ptr getType() const; + GRAPHQLINTROSPECTION_EXPORT response::BooleanType getIsDeprecated() const; + GRAPHQLINTROSPECTION_EXPORT std::optional getDeprecationReason() const; private: const std::shared_ptr _field; @@ -108,14 +85,10 @@ class InputValue const std::shared_ptr& inputValue); // Accessors - GRAPHQLINTROSPECTION_EXPORT service::FieldResult getName( - service::FieldParams&& params) const; - GRAPHQLINTROSPECTION_EXPORT service::FieldResult> - getDescription(service::FieldParams&& params) const; - GRAPHQLINTROSPECTION_EXPORT service::FieldResult> getType( - service::FieldParams&& params) const; - GRAPHQLINTROSPECTION_EXPORT service::FieldResult> - getDefaultValue(service::FieldParams&& params) const; + GRAPHQLINTROSPECTION_EXPORT response::StringType getName() const; + GRAPHQLINTROSPECTION_EXPORT std::optional getDescription() const; + GRAPHQLINTROSPECTION_EXPORT std::shared_ptr getType() const; + GRAPHQLINTROSPECTION_EXPORT std::optional getDefaultValue() const; private: const std::shared_ptr _inputValue; @@ -128,14 +101,10 @@ class EnumValue const std::shared_ptr& enumValue); // Accessors - GRAPHQLINTROSPECTION_EXPORT service::FieldResult getName( - service::FieldParams&& params) const; - GRAPHQLINTROSPECTION_EXPORT service::FieldResult> - getDescription(service::FieldParams&& params) const; - GRAPHQLINTROSPECTION_EXPORT service::FieldResult getIsDeprecated( - service::FieldParams&& params) const; - GRAPHQLINTROSPECTION_EXPORT service::FieldResult> - getDeprecationReason(service::FieldParams&& params) const; + GRAPHQLINTROSPECTION_EXPORT response::StringType getName() const; + GRAPHQLINTROSPECTION_EXPORT std::optional getDescription() const; + GRAPHQLINTROSPECTION_EXPORT response::BooleanType getIsDeprecated() const; + GRAPHQLINTROSPECTION_EXPORT std::optional getDeprecationReason() const; private: const std::shared_ptr _enumValue; @@ -148,15 +117,10 @@ class Directive const std::shared_ptr& directive); // Accessors - GRAPHQLINTROSPECTION_EXPORT service::FieldResult getName( - service::FieldParams&& params) const; - GRAPHQLINTROSPECTION_EXPORT service::FieldResult> - getDescription(service::FieldParams&& params) const; - GRAPHQLINTROSPECTION_EXPORT service::FieldResult> getLocations( - service::FieldParams&& params) const; - GRAPHQLINTROSPECTION_EXPORT service::FieldResult< - std::vector>> - getArgs(service::FieldParams&& params) const; + GRAPHQLINTROSPECTION_EXPORT response::StringType getName() const; + GRAPHQLINTROSPECTION_EXPORT std::optional getDescription() const; + GRAPHQLINTROSPECTION_EXPORT std::vector getLocations() const; + GRAPHQLINTROSPECTION_EXPORT std::vector> getArgs() const; private: const std::shared_ptr _directive; diff --git a/include/graphqlservice/introspection/IntrospectionSchema.h b/include/graphqlservice/introspection/IntrospectionSchema.h index 548433d3..a5aaed02 100644 --- a/include/graphqlservice/introspection/IntrospectionSchema.h +++ b/include/graphqlservice/introspection/IntrospectionSchema.h @@ -119,29 +119,29 @@ class Schema { } - service::FieldResult>> getTypes(service::FieldParams&& params) const final + service::FieldResult>> getTypes(service::FieldParams&&) const final { - return { _pimpl->getTypes(std::move(params)) }; + return { _pimpl->getTypes() }; } - service::FieldResult> getQueryType(service::FieldParams&& params) const final + service::FieldResult> getQueryType(service::FieldParams&&) const final { - return { _pimpl->getQueryType(std::move(params)) }; + return { _pimpl->getQueryType() }; } - service::FieldResult> getMutationType(service::FieldParams&& params) const final + service::FieldResult> getMutationType(service::FieldParams&&) const final { - return { _pimpl->getMutationType(std::move(params)) }; + return { _pimpl->getMutationType() }; } - service::FieldResult> getSubscriptionType(service::FieldParams&& params) const final + service::FieldResult> getSubscriptionType(service::FieldParams&&) const final { - return { _pimpl->getSubscriptionType(std::move(params)) }; + return { _pimpl->getSubscriptionType() }; } - service::FieldResult>> getDirectives(service::FieldParams&& params) const final + service::FieldResult>> getDirectives(service::FieldParams&&) const final { - return { _pimpl->getDirectives(std::move(params)) }; + return { _pimpl->getDirectives() }; } private: @@ -195,49 +195,49 @@ class Type { } - service::FieldResult getKind(service::FieldParams&& params) const final + service::FieldResult getKind(service::FieldParams&&) const final { - return { _pimpl->getKind(std::move(params)) }; + return { _pimpl->getKind() }; } - service::FieldResult> getName(service::FieldParams&& params) const final + service::FieldResult> getName(service::FieldParams&&) const final { - return { _pimpl->getName(std::move(params)) }; + return { _pimpl->getName() }; } - service::FieldResult> getDescription(service::FieldParams&& params) const final + service::FieldResult> getDescription(service::FieldParams&&) const final { - return { _pimpl->getDescription(std::move(params)) }; + return { _pimpl->getDescription() }; } - service::FieldResult>>> getFields(service::FieldParams&& params, std::optional&& includeDeprecatedArg) const final + service::FieldResult>>> getFields(service::FieldParams&&, std::optional&& includeDeprecatedArg) const final { - return { _pimpl->getFields(std::move(params), std::move(includeDeprecatedArg)) }; + return { _pimpl->getFields(std::move(includeDeprecatedArg)) }; } - service::FieldResult>>> getInterfaces(service::FieldParams&& params) const final + service::FieldResult>>> getInterfaces(service::FieldParams&&) const final { - return { _pimpl->getInterfaces(std::move(params)) }; + return { _pimpl->getInterfaces() }; } - service::FieldResult>>> getPossibleTypes(service::FieldParams&& params) const final + service::FieldResult>>> getPossibleTypes(service::FieldParams&&) const final { - return { _pimpl->getPossibleTypes(std::move(params)) }; + return { _pimpl->getPossibleTypes() }; } - service::FieldResult>>> getEnumValues(service::FieldParams&& params, std::optional&& includeDeprecatedArg) const final + service::FieldResult>>> getEnumValues(service::FieldParams&&, std::optional&& includeDeprecatedArg) const final { - return { _pimpl->getEnumValues(std::move(params), std::move(includeDeprecatedArg)) }; + return { _pimpl->getEnumValues(std::move(includeDeprecatedArg)) }; } - service::FieldResult>>> getInputFields(service::FieldParams&& params) const final + service::FieldResult>>> getInputFields(service::FieldParams&&) const final { - return { _pimpl->getInputFields(std::move(params)) }; + return { _pimpl->getInputFields() }; } - service::FieldResult> getOfType(service::FieldParams&& params) const final + service::FieldResult> getOfType(service::FieldParams&&) const final { - return { _pimpl->getOfType(std::move(params)) }; + return { _pimpl->getOfType() }; } private: @@ -285,34 +285,34 @@ class Field { } - service::FieldResult getName(service::FieldParams&& params) const final + service::FieldResult getName(service::FieldParams&&) const final { - return { _pimpl->getName(std::move(params)) }; + return { _pimpl->getName() }; } - service::FieldResult> getDescription(service::FieldParams&& params) const final + service::FieldResult> getDescription(service::FieldParams&&) const final { - return { _pimpl->getDescription(std::move(params)) }; + return { _pimpl->getDescription() }; } - service::FieldResult>> getArgs(service::FieldParams&& params) const final + service::FieldResult>> getArgs(service::FieldParams&&) const final { - return { _pimpl->getArgs(std::move(params)) }; + return { _pimpl->getArgs() }; } - service::FieldResult> getType(service::FieldParams&& params) const final + service::FieldResult> getType(service::FieldParams&&) const final { - return { _pimpl->getType(std::move(params)) }; + return { _pimpl->getType() }; } - service::FieldResult getIsDeprecated(service::FieldParams&& params) const final + service::FieldResult getIsDeprecated(service::FieldParams&&) const final { - return { _pimpl->getIsDeprecated(std::move(params)) }; + return { _pimpl->getIsDeprecated() }; } - service::FieldResult> getDeprecationReason(service::FieldParams&& params) const final + service::FieldResult> getDeprecationReason(service::FieldParams&&) const final { - return { _pimpl->getDeprecationReason(std::move(params)) }; + return { _pimpl->getDeprecationReason() }; } private: @@ -356,24 +356,24 @@ class InputValue { } - service::FieldResult getName(service::FieldParams&& params) const final + service::FieldResult getName(service::FieldParams&&) const final { - return { _pimpl->getName(std::move(params)) }; + return { _pimpl->getName() }; } - service::FieldResult> getDescription(service::FieldParams&& params) const final + service::FieldResult> getDescription(service::FieldParams&&) const final { - return { _pimpl->getDescription(std::move(params)) }; + return { _pimpl->getDescription() }; } - service::FieldResult> getType(service::FieldParams&& params) const final + service::FieldResult> getType(service::FieldParams&&) const final { - return { _pimpl->getType(std::move(params)) }; + return { _pimpl->getType() }; } - service::FieldResult> getDefaultValue(service::FieldParams&& params) const final + service::FieldResult> getDefaultValue(service::FieldParams&&) const final { - return { _pimpl->getDefaultValue(std::move(params)) }; + return { _pimpl->getDefaultValue() }; } private: @@ -417,24 +417,24 @@ class EnumValue { } - service::FieldResult getName(service::FieldParams&& params) const final + service::FieldResult getName(service::FieldParams&&) const final { - return { _pimpl->getName(std::move(params)) }; + return { _pimpl->getName() }; } - service::FieldResult> getDescription(service::FieldParams&& params) const final + service::FieldResult> getDescription(service::FieldParams&&) const final { - return { _pimpl->getDescription(std::move(params)) }; + return { _pimpl->getDescription() }; } - service::FieldResult getIsDeprecated(service::FieldParams&& params) const final + service::FieldResult getIsDeprecated(service::FieldParams&&) const final { - return { _pimpl->getIsDeprecated(std::move(params)) }; + return { _pimpl->getIsDeprecated() }; } - service::FieldResult> getDeprecationReason(service::FieldParams&& params) const final + service::FieldResult> getDeprecationReason(service::FieldParams&&) const final { - return { _pimpl->getDeprecationReason(std::move(params)) }; + return { _pimpl->getDeprecationReason() }; } private: @@ -478,24 +478,24 @@ class Directive { } - service::FieldResult getName(service::FieldParams&& params) const final + service::FieldResult getName(service::FieldParams&&) const final { - return { _pimpl->getName(std::move(params)) }; + return { _pimpl->getName() }; } - service::FieldResult> getDescription(service::FieldParams&& params) const final + service::FieldResult> getDescription(service::FieldParams&&) const final { - return { _pimpl->getDescription(std::move(params)) }; + return { _pimpl->getDescription() }; } - service::FieldResult> getLocations(service::FieldParams&& params) const final + service::FieldResult> getLocations(service::FieldParams&&) const final { - return { _pimpl->getLocations(std::move(params)) }; + return { _pimpl->getLocations() }; } - service::FieldResult>> getArgs(service::FieldParams&& params) const final + service::FieldResult>> getArgs(service::FieldParams&&) const final { - return { _pimpl->getArgs(std::move(params)) }; + return { _pimpl->getArgs() }; } private: diff --git a/src/Introspection.cpp b/src/Introspection.cpp index 63691f7d..dc797eb1 100644 --- a/src/Introspection.cpp +++ b/src/Introspection.cpp @@ -10,8 +10,7 @@ Schema::Schema(const std::shared_ptr& schema) { } -service::FieldResult>> Schema::getTypes( - service::FieldParams&&) const +std::vector> Schema::getTypes() const { const auto& types = _schema->types(); std::vector> result(types.size()); @@ -23,16 +22,14 @@ service::FieldResult>> Schema::getType return result; } -service::FieldResult> Schema::getQueryType( - service::FieldParams&&) const +std::shared_ptr Schema::getQueryType() const { const auto& queryType = _schema->queryType(); return queryType ? std::make_shared(std::make_shared(queryType)) : nullptr; } -service::FieldResult> Schema::getMutationType( - service::FieldParams&&) const +std::shared_ptr Schema::getMutationType() const { const auto& mutationType = _schema->mutationType(); @@ -40,8 +37,7 @@ service::FieldResult> Schema::getMutationType( : nullptr; } -service::FieldResult> Schema::getSubscriptionType( - service::FieldParams&&) const +std::shared_ptr Schema::getSubscriptionType() const { const auto& subscriptionType = _schema->subscriptionType(); @@ -50,8 +46,7 @@ service::FieldResult> Schema::getSubscriptionType( : nullptr; } -service::FieldResult>> Schema::getDirectives( - service::FieldParams&&) const +std::vector> Schema::getDirectives() const { const auto& directives = _schema->directives(); std::vector> result(directives.size()); @@ -68,21 +63,19 @@ Type::Type(const std::shared_ptr& type) { } -service::FieldResult Type::getKind(service::FieldParams&&) const +TypeKind Type::getKind() const { return _type->kind(); } -service::FieldResult> Type::getName( - service::FieldParams&&) const +std::optional Type::getName() const { const auto name = _type->name(); return { name.empty() ? std::nullopt : std::make_optional(name) }; } -service::FieldResult> Type::getDescription( - service::FieldParams&&) const +std::optional Type::getDescription() const { const auto description = _type->description(); @@ -90,8 +83,8 @@ service::FieldResult> Type::getDescription( : std::make_optional(description) }; } -service::FieldResult>>> Type::getFields( - service::FieldParams&&, std::optional&& includeDeprecatedArg) const +std::optional>> Type::getFields( + std::optional&& includeDeprecatedArg) const { switch (_type->kind()) { @@ -119,8 +112,7 @@ service::FieldResult>>> return result; } -service::FieldResult>>> Type::getInterfaces( - service::FieldParams&&) const +std::optional>> Type::getInterfaces() const { switch (_type->kind()) { @@ -141,8 +133,7 @@ service::FieldResult>>> return result; } -service::FieldResult>>> Type:: - getPossibleTypes(service::FieldParams&&) const +std::optional>> Type::getPossibleTypes() const { switch (_type->kind()) { @@ -168,9 +159,8 @@ service::FieldResult>>> return result; } -service::FieldResult>>> Type:: - getEnumValues( - service::FieldParams&&, std::optional&& includeDeprecatedArg) const +std::optional>> Type::getEnumValues( + std::optional&& includeDeprecatedArg) const { switch (_type->kind()) { @@ -198,8 +188,7 @@ service::FieldResult>>> Type:: - getInputFields(service::FieldParams&&) const +std::optional>> Type::getInputFields() const { switch (_type->kind()) { @@ -221,7 +210,7 @@ service::FieldResult> Type::getOfType(service::FieldParams&&) const +std::shared_ptr Type::getOfType() const { switch (_type->kind()) { @@ -243,13 +232,12 @@ Field::Field(const std::shared_ptr& field) { } -service::FieldResult Field::getName(service::FieldParams&&) const +response::StringType Field::getName() const { return response::StringType { _field->name() }; } -service::FieldResult> Field::getDescription( - service::FieldParams&&) const +std::optional Field::getDescription() const { const auto description = _field->description(); @@ -257,8 +245,7 @@ service::FieldResult> Field::getDescription( : std::make_optional(description) }; } -service::FieldResult>> Field::getArgs( - service::FieldParams&&) const +std::vector> Field::getArgs() const { const auto& args = _field->args(); std::vector> result(args.size()); @@ -270,20 +257,19 @@ service::FieldResult>> Field::ge return result; } -service::FieldResult> Field::getType(service::FieldParams&&) const +std::shared_ptr Field::getType() const { const auto type = _field->type().lock(); return type ? std::make_shared(std::make_shared(type)) : nullptr; } -service::FieldResult Field::getIsDeprecated(service::FieldParams&&) const +response::BooleanType Field::getIsDeprecated() const { return _field->deprecationReason().has_value(); } -service::FieldResult> Field::getDeprecationReason( - service::FieldParams&&) const +std::optional Field::getDeprecationReason() const { const auto& deprecationReason = _field->deprecationReason(); @@ -296,13 +282,12 @@ InputValue::InputValue(const std::shared_ptr& inputVal { } -service::FieldResult InputValue::getName(service::FieldParams&&) const +response::StringType InputValue::getName() const { return response::StringType { _inputValue->name() }; } -service::FieldResult> InputValue::getDescription( - service::FieldParams&&) const +std::optional InputValue::getDescription() const { const auto description = _inputValue->description(); @@ -310,16 +295,14 @@ service::FieldResult> InputValue::getDescrip : std::make_optional(description) }; } -service::FieldResult> InputValue::getType( - service::FieldParams&&) const +std::shared_ptr InputValue::getType() const { const auto type = _inputValue->type().lock(); return type ? std::make_shared(std::make_shared(type)) : nullptr; } -service::FieldResult> InputValue::getDefaultValue( - service::FieldParams&&) const +std::optional InputValue::getDefaultValue() const { const auto defaultValue = _inputValue->defaultValue(); @@ -332,13 +315,12 @@ EnumValue::EnumValue(const std::shared_ptr& enumValue) { } -service::FieldResult EnumValue::getName(service::FieldParams&&) const +response::StringType EnumValue::getName() const { return response::StringType { _enumValue->name() }; } -service::FieldResult> EnumValue::getDescription( - service::FieldParams&&) const +std::optional EnumValue::getDescription() const { const auto description = _enumValue->description(); @@ -346,13 +328,12 @@ service::FieldResult> EnumValue::getDescript : std::make_optional(description) }; } -service::FieldResult EnumValue::getIsDeprecated(service::FieldParams&&) const +response::BooleanType EnumValue::getIsDeprecated() const { return _enumValue->deprecationReason().has_value(); } -service::FieldResult> EnumValue::getDeprecationReason( - service::FieldParams&&) const +std::optional EnumValue::getDeprecationReason() const { const auto& deprecationReason = _enumValue->deprecationReason(); @@ -365,13 +346,12 @@ Directive::Directive(const std::shared_ptr& directive) { } -service::FieldResult Directive::getName(service::FieldParams&&) const +response::StringType Directive::getName() const { return response::StringType { _directive->name() }; } -service::FieldResult> Directive::getDescription( - service::FieldParams&&) const +std::optional Directive::getDescription() const { const auto description = _directive->description(); @@ -379,14 +359,12 @@ service::FieldResult> Directive::getDescript : std::make_optional(description) }; } -service::FieldResult> Directive::getLocations( - service::FieldParams&&) const +std::vector Directive::getLocations() const { return { _directive->locations() }; } -service::FieldResult>> Directive::getArgs( - service::FieldParams&&) const +std::vector> Directive::getArgs() const { const auto& args = _directive->args(); std::vector> result(args.size()); diff --git a/src/SchemaGenerator.cpp b/src/SchemaGenerator.cpp index bc026f55..5f073a1f 100644 --- a/src/SchemaGenerator.cpp +++ b/src/SchemaGenerator.cpp @@ -744,7 +744,13 @@ void Generator::outputObjectDeclaration( headerFile << R"cpp( service::FieldResult<)cpp" << _loader.getOutputCppType(outputField) << R"cpp(> )cpp" << outputField.accessor - << fieldName << R"cpp((service::FieldParams&& params)cpp"; + << fieldName << R"cpp((service::FieldParams&&)cpp"; + + if (!_loader.isIntrospection()) + { + headerFile << R"cpp( params)cpp"; + } + for (const auto& argument : outputField.arguments) { headerFile << R"cpp(, )cpp" << _loader.getInputCppType(argument) << R"cpp(&& )cpp" @@ -774,11 +780,11 @@ void Generator::outputObjectDeclaration( if (_loader.isIntrospection()) { headerFile << R"cpp(return { _pimpl->)cpp" << outputField.accessor << fieldName - << R"cpp((std::move(params))cpp"; + << R"cpp(()cpp"; if (!passedArguments.empty()) { - headerFile << R"cpp(, )cpp" << passedArguments; + headerFile << passedArguments; } headerFile << R"cpp() };)cpp"; From c623c00739838759ecfe8c48812b05cff69899b5 Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Wed, 1 Dec 2021 15:38:17 -0800 Subject: [PATCH 042/119] Favor underlying non-template standard types --- include/Validation.h | 11 +- include/graphqlservice/GraphQLClient.h | 46 ++-- include/graphqlservice/GraphQLService.h | 43 ++-- .../introspection/Introspection.h | 34 +-- .../introspection/IntrospectionSchema.h | 68 +++--- samples/client/BenchmarkClient.cpp | 8 +- samples/client/BenchmarkClient.h | 6 +- samples/client/MutateClient.cpp | 16 +- samples/client/MutateClient.h | 10 +- samples/client/QueryClient.cpp | 32 +-- samples/client/QueryClient.h | 28 +-- samples/client/SubscribeClient.cpp | 6 +- samples/client/SubscribeClient.h | 4 +- samples/learn/DroidObject.cpp | 8 +- samples/learn/DroidObject.h | 20 +- samples/learn/HumanObject.cpp | 8 +- samples/learn/HumanObject.h | 20 +- samples/learn/MutationObject.cpp | 2 +- samples/learn/QueryObject.cpp | 8 +- samples/learn/QueryObject.h | 16 +- samples/learn/ReviewObject.cpp | 6 +- samples/learn/ReviewObject.h | 16 +- samples/learn/StarWarsSchema.cpp | 8 +- samples/learn/StarWarsSchema.h | 8 +- .../separate/AppointmentConnectionObject.cpp | 2 +- samples/separate/AppointmentEdgeObject.cpp | 2 +- samples/separate/AppointmentObject.cpp | 8 +- samples/separate/AppointmentObject.h | 24 +- .../separate/CompleteTaskPayloadObject.cpp | 4 +- samples/separate/CompleteTaskPayloadObject.h | 8 +- samples/separate/ExpensiveObject.cpp | 4 +- samples/separate/ExpensiveObject.h | 8 +- samples/separate/FolderConnectionObject.cpp | 2 +- samples/separate/FolderEdgeObject.cpp | 2 +- samples/separate/FolderObject.cpp | 6 +- samples/separate/FolderObject.h | 16 +- samples/separate/MutationObject.cpp | 6 +- samples/separate/MutationObject.h | 12 +- samples/separate/NestedTypeObject.cpp | 4 +- samples/separate/NestedTypeObject.h | 8 +- samples/separate/PageInfoObject.cpp | 6 +- samples/separate/PageInfoObject.h | 16 +- samples/separate/QueryObject.cpp | 18 +- samples/separate/QueryObject.h | 32 +-- samples/separate/SubscriptionObject.cpp | 2 +- samples/separate/TaskConnectionObject.cpp | 2 +- samples/separate/TaskEdgeObject.cpp | 2 +- samples/separate/TaskObject.cpp | 6 +- samples/separate/TaskObject.h | 16 +- samples/separate/TodaySchema.cpp | 10 +- samples/separate/TodaySchema.h | 4 +- .../AppointmentConnectionObject.cpp | 2 +- .../AppointmentEdgeObject.cpp | 2 +- .../AppointmentObject.cpp | 8 +- .../AppointmentObject.h | 24 +- .../CompleteTaskPayloadObject.cpp | 4 +- .../CompleteTaskPayloadObject.h | 8 +- .../ExpensiveObject.cpp | 4 +- .../ExpensiveObject.h | 8 +- .../FolderConnectionObject.cpp | 2 +- .../FolderEdgeObject.cpp | 2 +- .../separate_nointrospection/FolderObject.cpp | 6 +- .../separate_nointrospection/FolderObject.h | 16 +- .../MutationObject.cpp | 6 +- .../separate_nointrospection/MutationObject.h | 12 +- .../NestedTypeObject.cpp | 4 +- .../NestedTypeObject.h | 8 +- .../PageInfoObject.cpp | 6 +- .../separate_nointrospection/PageInfoObject.h | 16 +- .../separate_nointrospection/QueryObject.cpp | 16 +- .../separate_nointrospection/QueryObject.h | 32 +-- .../SubscriptionObject.cpp | 2 +- .../TaskConnectionObject.cpp | 2 +- .../TaskEdgeObject.cpp | 2 +- .../separate_nointrospection/TaskObject.cpp | 6 +- samples/separate_nointrospection/TaskObject.h | 16 +- .../separate_nointrospection/TodaySchema.cpp | 10 +- .../separate_nointrospection/TodaySchema.h | 4 +- samples/star_wars/DroidData.cpp | 11 +- samples/star_wars/DroidData.h | 17 +- samples/star_wars/HumanData.cpp | 10 +- samples/star_wars/HumanData.h | 17 +- samples/star_wars/QueryData.cpp | 8 +- samples/star_wars/QueryData.h | 12 +- samples/star_wars/ReviewData.cpp | 6 +- samples/star_wars/ReviewData.h | 11 +- samples/star_wars/StarWarsData.cpp | 4 +- samples/today/TodayMock.cpp | 13 +- samples/today/TodayMock.h | 40 ++-- samples/unified/TodaySchema.cpp | 86 +++---- samples/unified/TodaySchema.h | 144 +++++------ .../unified_nointrospection/TodaySchema.cpp | 84 +++---- samples/unified_nointrospection/TodaySchema.h | 144 +++++------ samples/validation/ValidationSchema.cpp | 104 ++++---- samples/validation/ValidationSchema.h | 224 +++++++++--------- src/ClientGenerator.cpp | 9 +- src/GeneratorLoader.cpp | 2 +- src/GraphQLClient.cpp | 50 ++-- src/GraphQLService.cpp | 66 +++--- src/Introspection.cpp | 66 +++--- src/IntrospectionSchema.cpp | 58 ++--- src/RequestLoader.cpp | 2 +- src/SchemaGenerator.cpp | 31 ++- src/SchemaLoader.cpp | 8 +- src/Validation.cpp | 20 +- test/ArgumentTests.cpp | 14 +- test/ClientTests.cpp | 8 +- test/ResponseTests.cpp | 2 +- test/TodayTests.cpp | 4 +- 109 files changed, 1063 insertions(+), 1102 deletions(-) diff --git a/include/Validation.h b/include/Validation.h index 8adeb579..b109cb7c 100644 --- a/include/Validation.h +++ b/include/Validation.h @@ -79,17 +79,16 @@ struct ValidateArgumentMap internal::string_view_map values; }; -using ValidateArgumentVariant = std::variant; +using ValidateArgumentVariant = std::variant; struct ValidateArgumentValue { ValidateArgumentValue(ValidateArgumentVariable&& value); - ValidateArgumentValue(response::IntType value); - ValidateArgumentValue(response::FloatType value); + ValidateArgumentValue(int value); + ValidateArgumentValue(double value); ValidateArgumentValue(std::string_view value); - ValidateArgumentValue(response::BooleanType value); + ValidateArgumentValue(bool value); ValidateArgumentValue(ValidateArgumentEnumValue&& value); ValidateArgumentValue(ValidateArgumentList&& value); ValidateArgumentValue(ValidateArgumentMap&& value); diff --git a/include/graphqlservice/GraphQLClient.h b/include/graphqlservice/GraphQLClient.h index 1b2e46e7..efdfe3be 100644 --- a/include/graphqlservice/GraphQLClient.h +++ b/include/graphqlservice/GraphQLClient.h @@ -34,13 +34,13 @@ namespace graphql::client { // Errors may specify the line number and column number where the error occurred. struct ErrorLocation { - response::IntType line {}; - response::IntType column {}; + int line {}; + int column {}; }; // Errors may specify a path to the field which triggered the error. The path consists of // field names and the indices of elements in a list. -using ErrorPathSegment = std::variant; +using ErrorPathSegment = std::variant; // Error returned from the service. struct Error @@ -141,27 +141,23 @@ struct ModifiedVariable // Convenient type aliases for testing, generated code won't actually use these. These are also // the specializations which are implemented in the GraphQLClient library, other specializations // for input types should be generated in schemagen. -using IntVariable = ModifiedVariable; -using FloatVariable = ModifiedVariable; -using StringVariable = ModifiedVariable; -using BooleanVariable = ModifiedVariable; +using IntVariable = ModifiedVariable; +using FloatVariable = ModifiedVariable; +using StringVariable = ModifiedVariable; +using BooleanVariable = ModifiedVariable; using IdVariable = ModifiedVariable; using ScalarVariable = ModifiedVariable; #ifdef GRAPHQL_DLLEXPORTS // Export all of the built-in converters template <> -GRAPHQLCLIENT_EXPORT response::Value ModifiedVariable::serialize( - response::IntType&& value); +GRAPHQLCLIENT_EXPORT response::Value ModifiedVariable::serialize(int&& value); template <> -GRAPHQLCLIENT_EXPORT response::Value ModifiedVariable::serialize( - response::FloatType&& value); +GRAPHQLCLIENT_EXPORT response::Value ModifiedVariable::serialize(double&& value); template <> -GRAPHQLCLIENT_EXPORT response::Value ModifiedVariable::serialize( - response::StringType&& value); +GRAPHQLCLIENT_EXPORT response::Value ModifiedVariable::serialize(std::string&& value); template <> -GRAPHQLCLIENT_EXPORT response::Value ModifiedVariable::serialize( - response::BooleanType&& value); +GRAPHQLCLIENT_EXPORT response::Value ModifiedVariable::serialize(bool&& value); template <> GRAPHQLCLIENT_EXPORT response::Value ModifiedVariable::serialize( response::IdType&& value); @@ -245,27 +241,23 @@ struct ModifiedResponse // Convenient type aliases for testing, generated code won't actually use these. These are also // the specializations which are implemented in the GraphQLClient library, other specializations // for output types should be generated in schemagen. -using IntResponse = ModifiedResponse; -using FloatResponse = ModifiedResponse; -using StringResponse = ModifiedResponse; -using BooleanResponse = ModifiedResponse; +using IntResponse = ModifiedResponse; +using FloatResponse = ModifiedResponse; +using StringResponse = ModifiedResponse; +using BooleanResponse = ModifiedResponse; using IdResponse = ModifiedResponse; using ScalarResponse = ModifiedResponse; #ifdef GRAPHQL_DLLEXPORTS // Export all of the built-in converters template <> -GRAPHQLCLIENT_EXPORT response::IntType ModifiedResponse::parse( - response::Value response); +GRAPHQLCLIENT_EXPORT int ModifiedResponse::parse(response::Value response); template <> -GRAPHQLCLIENT_EXPORT response::FloatType ModifiedResponse::parse( - response::Value response); +GRAPHQLCLIENT_EXPORT double ModifiedResponse::parse(response::Value response); template <> -GRAPHQLCLIENT_EXPORT response::StringType ModifiedResponse::parse( - response::Value response); +GRAPHQLCLIENT_EXPORT std::string ModifiedResponse::parse(response::Value response); template <> -GRAPHQLCLIENT_EXPORT response::BooleanType ModifiedResponse::parse( - response::Value response); +GRAPHQLCLIENT_EXPORT bool ModifiedResponse::parse(response::Value response); template <> GRAPHQLCLIENT_EXPORT response::IdType ModifiedResponse::parse( response::Value response); diff --git a/include/graphqlservice/GraphQLService.h b/include/graphqlservice/GraphQLService.h index c9aa1640..5f6013c1 100644 --- a/include/graphqlservice/GraphQLService.h +++ b/include/graphqlservice/GraphQLService.h @@ -494,27 +494,24 @@ struct ModifiedArgument // Convenient type aliases for testing, generated code won't actually use these. These are also // the specializations which are implemented in the GraphQLService library, other specializations // for input types should be generated in schemagen. -using IntArgument = ModifiedArgument; -using FloatArgument = ModifiedArgument; -using StringArgument = ModifiedArgument; -using BooleanArgument = ModifiedArgument; +using IntArgument = ModifiedArgument; +using FloatArgument = ModifiedArgument; +using StringArgument = ModifiedArgument; +using BooleanArgument = ModifiedArgument; using IdArgument = ModifiedArgument; using ScalarArgument = ModifiedArgument; #ifdef GRAPHQL_DLLEXPORTS // Export all of the built-in converters template <> -GRAPHQLSERVICE_EXPORT response::IntType ModifiedArgument::convert( - const response::Value& value); +GRAPHQLSERVICE_EXPORT int ModifiedArgument::convert(const response::Value& value); template <> -GRAPHQLSERVICE_EXPORT response::FloatType ModifiedArgument::convert( - const response::Value& value); +GRAPHQLSERVICE_EXPORT double ModifiedArgument::convert(const response::Value& value); template <> -GRAPHQLSERVICE_EXPORT response::StringType ModifiedArgument::convert( +GRAPHQLSERVICE_EXPORT std::string ModifiedArgument::convert( const response::Value& value); template <> -GRAPHQLSERVICE_EXPORT response::BooleanType ModifiedArgument::convert( - const response::Value& value); +GRAPHQLSERVICE_EXPORT bool ModifiedArgument::convert(const response::Value& value); template <> GRAPHQLSERVICE_EXPORT response::IdType ModifiedArgument::convert( const response::Value& value); @@ -829,10 +826,10 @@ struct ModifiedResult // Convenient type aliases for testing, generated code won't actually use these. These are also // the specializations which are implemented in the GraphQLService library, other specializations // for output types should be generated in schemagen. -using IntResult = ModifiedResult; -using FloatResult = ModifiedResult; -using StringResult = ModifiedResult; -using BooleanResult = ModifiedResult; +using IntResult = ModifiedResult; +using FloatResult = ModifiedResult; +using StringResult = ModifiedResult; +using BooleanResult = ModifiedResult; using IdResult = ModifiedResult; using ScalarResult = ModifiedResult; using ObjectResult = ModifiedResult; @@ -840,17 +837,17 @@ using ObjectResult = ModifiedResult; #ifdef GRAPHQL_DLLEXPORTS // Export all of the built-in converters template <> -GRAPHQLSERVICE_EXPORT AwaitableResolver ModifiedResult::convert( - FieldResult result, ResolverParams params); +GRAPHQLSERVICE_EXPORT AwaitableResolver ModifiedResult::convert( + FieldResult result, ResolverParams params); template <> -GRAPHQLSERVICE_EXPORT AwaitableResolver ModifiedResult::convert( - FieldResult result, ResolverParams params); +GRAPHQLSERVICE_EXPORT AwaitableResolver ModifiedResult::convert( + FieldResult result, ResolverParams params); template <> -GRAPHQLSERVICE_EXPORT AwaitableResolver ModifiedResult::convert( - FieldResult result, ResolverParams params); +GRAPHQLSERVICE_EXPORT AwaitableResolver ModifiedResult::convert( + FieldResult result, ResolverParams params); template <> -GRAPHQLSERVICE_EXPORT AwaitableResolver ModifiedResult::convert( - FieldResult result, ResolverParams params); +GRAPHQLSERVICE_EXPORT AwaitableResolver ModifiedResult::convert( + FieldResult result, ResolverParams params); template <> GRAPHQLSERVICE_EXPORT AwaitableResolver ModifiedResult::convert( FieldResult result, ResolverParams params); diff --git a/include/graphqlservice/introspection/Introspection.h b/include/graphqlservice/introspection/Introspection.h index 0b76083e..114e878f 100644 --- a/include/graphqlservice/introspection/Introspection.h +++ b/include/graphqlservice/introspection/Introspection.h @@ -43,16 +43,16 @@ class Type // Accessors GRAPHQLINTROSPECTION_EXPORT TypeKind getKind() const; - GRAPHQLINTROSPECTION_EXPORT std::optional getName() const; - GRAPHQLINTROSPECTION_EXPORT std::optional getDescription() const; + GRAPHQLINTROSPECTION_EXPORT std::optional getName() const; + GRAPHQLINTROSPECTION_EXPORT std::optional getDescription() const; GRAPHQLINTROSPECTION_EXPORT std::optional>> - getFields(std::optional&& includeDeprecatedArg) const; + getFields(std::optional&& includeDeprecatedArg) const; GRAPHQLINTROSPECTION_EXPORT std::optional>> getInterfaces() const; GRAPHQLINTROSPECTION_EXPORT std::optional>> getPossibleTypes() const; GRAPHQLINTROSPECTION_EXPORT std::optional>> - getEnumValues(std::optional&& includeDeprecatedArg) const; + getEnumValues(std::optional&& includeDeprecatedArg) const; GRAPHQLINTROSPECTION_EXPORT std::optional>> getInputFields() const; GRAPHQLINTROSPECTION_EXPORT std::shared_ptr getOfType() const; @@ -67,12 +67,12 @@ class Field GRAPHQLINTROSPECTION_EXPORT explicit Field(const std::shared_ptr& field); // Accessors - GRAPHQLINTROSPECTION_EXPORT response::StringType getName() const; - GRAPHQLINTROSPECTION_EXPORT std::optional getDescription() const; + GRAPHQLINTROSPECTION_EXPORT std::string getName() const; + GRAPHQLINTROSPECTION_EXPORT std::optional getDescription() const; GRAPHQLINTROSPECTION_EXPORT std::vector> getArgs() const; GRAPHQLINTROSPECTION_EXPORT std::shared_ptr getType() const; - GRAPHQLINTROSPECTION_EXPORT response::BooleanType getIsDeprecated() const; - GRAPHQLINTROSPECTION_EXPORT std::optional getDeprecationReason() const; + GRAPHQLINTROSPECTION_EXPORT bool getIsDeprecated() const; + GRAPHQLINTROSPECTION_EXPORT std::optional getDeprecationReason() const; private: const std::shared_ptr _field; @@ -85,10 +85,10 @@ class InputValue const std::shared_ptr& inputValue); // Accessors - GRAPHQLINTROSPECTION_EXPORT response::StringType getName() const; - GRAPHQLINTROSPECTION_EXPORT std::optional getDescription() const; + GRAPHQLINTROSPECTION_EXPORT std::string getName() const; + GRAPHQLINTROSPECTION_EXPORT std::optional getDescription() const; GRAPHQLINTROSPECTION_EXPORT std::shared_ptr getType() const; - GRAPHQLINTROSPECTION_EXPORT std::optional getDefaultValue() const; + GRAPHQLINTROSPECTION_EXPORT std::optional getDefaultValue() const; private: const std::shared_ptr _inputValue; @@ -101,10 +101,10 @@ class EnumValue const std::shared_ptr& enumValue); // Accessors - GRAPHQLINTROSPECTION_EXPORT response::StringType getName() const; - GRAPHQLINTROSPECTION_EXPORT std::optional getDescription() const; - GRAPHQLINTROSPECTION_EXPORT response::BooleanType getIsDeprecated() const; - GRAPHQLINTROSPECTION_EXPORT std::optional getDeprecationReason() const; + GRAPHQLINTROSPECTION_EXPORT std::string getName() const; + GRAPHQLINTROSPECTION_EXPORT std::optional getDescription() const; + GRAPHQLINTROSPECTION_EXPORT bool getIsDeprecated() const; + GRAPHQLINTROSPECTION_EXPORT std::optional getDeprecationReason() const; private: const std::shared_ptr _enumValue; @@ -117,8 +117,8 @@ class Directive const std::shared_ptr& directive); // Accessors - GRAPHQLINTROSPECTION_EXPORT response::StringType getName() const; - GRAPHQLINTROSPECTION_EXPORT std::optional getDescription() const; + GRAPHQLINTROSPECTION_EXPORT std::string getName() const; + GRAPHQLINTROSPECTION_EXPORT std::optional getDescription() const; GRAPHQLINTROSPECTION_EXPORT std::vector getLocations() const; GRAPHQLINTROSPECTION_EXPORT std::vector> getArgs() const; diff --git a/include/graphqlservice/introspection/IntrospectionSchema.h b/include/graphqlservice/introspection/IntrospectionSchema.h index a5aaed02..55e732ca 100644 --- a/include/graphqlservice/introspection/IntrospectionSchema.h +++ b/include/graphqlservice/introspection/IntrospectionSchema.h @@ -176,12 +176,12 @@ class Type virtual ~Concept() = default; virtual service::FieldResult getKind(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getName(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getDescription(service::FieldParams&& params) const = 0; - virtual service::FieldResult>>> getFields(service::FieldParams&& params, std::optional&& includeDeprecatedArg) const = 0; + virtual service::FieldResult> getName(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getDescription(service::FieldParams&& params) const = 0; + virtual service::FieldResult>>> getFields(service::FieldParams&& params, std::optional&& includeDeprecatedArg) const = 0; virtual service::FieldResult>>> getInterfaces(service::FieldParams&& params) const = 0; virtual service::FieldResult>>> getPossibleTypes(service::FieldParams&& params) const = 0; - virtual service::FieldResult>>> getEnumValues(service::FieldParams&& params, std::optional&& includeDeprecatedArg) const = 0; + virtual service::FieldResult>>> getEnumValues(service::FieldParams&& params, std::optional&& includeDeprecatedArg) const = 0; virtual service::FieldResult>>> getInputFields(service::FieldParams&& params) const = 0; virtual service::FieldResult> getOfType(service::FieldParams&& params) const = 0; }; @@ -200,17 +200,17 @@ class Type return { _pimpl->getKind() }; } - service::FieldResult> getName(service::FieldParams&&) const final + service::FieldResult> getName(service::FieldParams&&) const final { return { _pimpl->getName() }; } - service::FieldResult> getDescription(service::FieldParams&&) const final + service::FieldResult> getDescription(service::FieldParams&&) const final { return { _pimpl->getDescription() }; } - service::FieldResult>>> getFields(service::FieldParams&&, std::optional&& includeDeprecatedArg) const final + service::FieldResult>>> getFields(service::FieldParams&&, std::optional&& includeDeprecatedArg) const final { return { _pimpl->getFields(std::move(includeDeprecatedArg)) }; } @@ -225,7 +225,7 @@ class Type return { _pimpl->getPossibleTypes() }; } - service::FieldResult>>> getEnumValues(service::FieldParams&&, std::optional&& includeDeprecatedArg) const final + service::FieldResult>>> getEnumValues(service::FieldParams&&, std::optional&& includeDeprecatedArg) const final { return { _pimpl->getEnumValues(std::move(includeDeprecatedArg)) }; } @@ -268,12 +268,12 @@ class Field { virtual ~Concept() = default; - virtual service::FieldResult getName(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getDescription(service::FieldParams&& params) const = 0; + virtual service::FieldResult getName(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getDescription(service::FieldParams&& params) const = 0; virtual service::FieldResult>> getArgs(service::FieldParams&& params) const = 0; virtual service::FieldResult> getType(service::FieldParams&& params) const = 0; - virtual service::FieldResult getIsDeprecated(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getDeprecationReason(service::FieldParams&& params) const = 0; + virtual service::FieldResult getIsDeprecated(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getDeprecationReason(service::FieldParams&& params) const = 0; }; template @@ -285,12 +285,12 @@ class Field { } - service::FieldResult getName(service::FieldParams&&) const final + service::FieldResult getName(service::FieldParams&&) const final { return { _pimpl->getName() }; } - service::FieldResult> getDescription(service::FieldParams&&) const final + service::FieldResult> getDescription(service::FieldParams&&) const final { return { _pimpl->getDescription() }; } @@ -305,12 +305,12 @@ class Field return { _pimpl->getType() }; } - service::FieldResult getIsDeprecated(service::FieldParams&&) const final + service::FieldResult getIsDeprecated(service::FieldParams&&) const final { return { _pimpl->getIsDeprecated() }; } - service::FieldResult> getDeprecationReason(service::FieldParams&&) const final + service::FieldResult> getDeprecationReason(service::FieldParams&&) const final { return { _pimpl->getDeprecationReason() }; } @@ -341,10 +341,10 @@ class InputValue { virtual ~Concept() = default; - virtual service::FieldResult getName(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getDescription(service::FieldParams&& params) const = 0; + virtual service::FieldResult getName(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getDescription(service::FieldParams&& params) const = 0; virtual service::FieldResult> getType(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getDefaultValue(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getDefaultValue(service::FieldParams&& params) const = 0; }; template @@ -356,12 +356,12 @@ class InputValue { } - service::FieldResult getName(service::FieldParams&&) const final + service::FieldResult getName(service::FieldParams&&) const final { return { _pimpl->getName() }; } - service::FieldResult> getDescription(service::FieldParams&&) const final + service::FieldResult> getDescription(service::FieldParams&&) const final { return { _pimpl->getDescription() }; } @@ -371,7 +371,7 @@ class InputValue return { _pimpl->getType() }; } - service::FieldResult> getDefaultValue(service::FieldParams&&) const final + service::FieldResult> getDefaultValue(service::FieldParams&&) const final { return { _pimpl->getDefaultValue() }; } @@ -402,10 +402,10 @@ class EnumValue { virtual ~Concept() = default; - virtual service::FieldResult getName(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getDescription(service::FieldParams&& params) const = 0; - virtual service::FieldResult getIsDeprecated(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getDeprecationReason(service::FieldParams&& params) const = 0; + virtual service::FieldResult getName(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getDescription(service::FieldParams&& params) const = 0; + virtual service::FieldResult getIsDeprecated(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getDeprecationReason(service::FieldParams&& params) const = 0; }; template @@ -417,22 +417,22 @@ class EnumValue { } - service::FieldResult getName(service::FieldParams&&) const final + service::FieldResult getName(service::FieldParams&&) const final { return { _pimpl->getName() }; } - service::FieldResult> getDescription(service::FieldParams&&) const final + service::FieldResult> getDescription(service::FieldParams&&) const final { return { _pimpl->getDescription() }; } - service::FieldResult getIsDeprecated(service::FieldParams&&) const final + service::FieldResult getIsDeprecated(service::FieldParams&&) const final { return { _pimpl->getIsDeprecated() }; } - service::FieldResult> getDeprecationReason(service::FieldParams&&) const final + service::FieldResult> getDeprecationReason(service::FieldParams&&) const final { return { _pimpl->getDeprecationReason() }; } @@ -463,8 +463,8 @@ class Directive { virtual ~Concept() = default; - virtual service::FieldResult getName(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getDescription(service::FieldParams&& params) const = 0; + virtual service::FieldResult getName(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getDescription(service::FieldParams&& params) const = 0; virtual service::FieldResult> getLocations(service::FieldParams&& params) const = 0; virtual service::FieldResult>> getArgs(service::FieldParams&& params) const = 0; }; @@ -478,12 +478,12 @@ class Directive { } - service::FieldResult getName(service::FieldParams&&) const final + service::FieldResult getName(service::FieldParams&&) const final { return { _pimpl->getName() }; } - service::FieldResult> getDescription(service::FieldParams&&) const final + service::FieldResult> getDescription(service::FieldParams&&) const final { return { _pimpl->getDescription() }; } diff --git a/samples/client/BenchmarkClient.cpp b/samples/client/BenchmarkClient.cpp index 1d2f5d4b..11900a89 100644 --- a/samples/client/BenchmarkClient.cpp +++ b/samples/client/BenchmarkClient.cpp @@ -7,8 +7,8 @@ #include #include -#include #include +#include #include using namespace std::literals; @@ -30,7 +30,7 @@ Response::appointments_AppointmentConnection::pageInfo_PageInfo ModifiedResponse { if (member.first == R"js(hasNextPage)js"sv) { - result.hasNextPage = ModifiedResponse::parse(std::move(member.second)); + result.hasNextPage = ModifiedResponse::parse(std::move(member.second)); continue; } } @@ -62,12 +62,12 @@ Response::appointments_AppointmentConnection::edges_AppointmentEdge::node_Appoin } if (member.first == R"js(subject)js"sv) { - result.subject = ModifiedResponse::parse(std::move(member.second)); + result.subject = ModifiedResponse::parse(std::move(member.second)); continue; } if (member.first == R"js(isNow)js"sv) { - result.isNow = ModifiedResponse::parse(std::move(member.second)); + result.isNow = ModifiedResponse::parse(std::move(member.second)); continue; } } diff --git a/samples/client/BenchmarkClient.h b/samples/client/BenchmarkClient.h index 1e142216..14b7849e 100644 --- a/samples/client/BenchmarkClient.h +++ b/samples/client/BenchmarkClient.h @@ -59,7 +59,7 @@ struct Response { struct pageInfo_PageInfo { - response::BooleanType hasNextPage {}; + bool hasNextPage {}; }; struct edges_AppointmentEdge @@ -68,8 +68,8 @@ struct Response { response::IdType id {}; std::optional when {}; - std::optional subject {}; - response::BooleanType isNow {}; + std::optional subject {}; + bool isNow {}; }; std::optional node {}; diff --git a/samples/client/MutateClient.cpp b/samples/client/MutateClient.cpp index d9a8fc3a..2eb9325c 100644 --- a/samples/client/MutateClient.cpp +++ b/samples/client/MutateClient.cpp @@ -7,8 +7,8 @@ #include #include -#include #include +#include #include using namespace std::literals; @@ -29,7 +29,7 @@ response::Value ModifiedVariable::serialize(TaskState&& value) { response::Value result { response::Type::EnumValue }; - result.set(response::StringType { s_namesTaskState[static_cast(value)] }); + result.set(std::string { s_namesTaskState[static_cast(value)] }); return result; } @@ -41,8 +41,8 @@ response::Value ModifiedVariable::serialize(Variab result.emplace_back(R"js(id)js"s, ModifiedVariable::serialize(std::move(inputValue.id))); result.emplace_back(R"js(testTaskState)js"s, ModifiedVariable::serialize(std::move(inputValue.testTaskState))); - result.emplace_back(R"js(isComplete)js"s, ModifiedVariable::serialize(std::move(inputValue.isComplete))); - result.emplace_back(R"js(clientMutationId)js"s, ModifiedVariable::serialize(std::move(inputValue.clientMutationId))); + result.emplace_back(R"js(isComplete)js"s, ModifiedVariable::serialize(std::move(inputValue.isComplete))); + result.emplace_back(R"js(clientMutationId)js"s, ModifiedVariable::serialize(std::move(inputValue.clientMutationId))); return result; } @@ -55,7 +55,7 @@ TaskState ModifiedResponse::parse(response::Value value) throw std::logic_error { "not a valid TaskState value" }; } - const auto itr = std::find(s_namesTaskState.cbegin(), s_namesTaskState.cend(), value.release()); + const auto itr = std::find(s_namesTaskState.cbegin(), s_namesTaskState.cend(), value.release()); if (itr == s_namesTaskState.cend()) { @@ -83,12 +83,12 @@ Response::completedTask_CompleteTaskPayload::completedTask_Task ModifiedResponse } if (member.first == R"js(title)js"sv) { - result.title = ModifiedResponse::parse(std::move(member.second)); + result.title = ModifiedResponse::parse(std::move(member.second)); continue; } if (member.first == R"js(isComplete)js"sv) { - result.isComplete = ModifiedResponse::parse(std::move(member.second)); + result.isComplete = ModifiedResponse::parse(std::move(member.second)); continue; } } @@ -115,7 +115,7 @@ Response::completedTask_CompleteTaskPayload ModifiedResponse::parse(std::move(member.second)); + result.clientMutationId = ModifiedResponse::parse(std::move(member.second)); continue; } } diff --git a/samples/client/MutateClient.h b/samples/client/MutateClient.h index b7565961..61947c0b 100644 --- a/samples/client/MutateClient.h +++ b/samples/client/MutateClient.h @@ -62,8 +62,8 @@ struct Variables { response::IdType id {}; std::optional testTaskState {}; - std::optional isComplete {}; - std::optional clientMutationId {}; + std::optional isComplete {}; + std::optional clientMutationId {}; }; CompleteTaskInput input {}; @@ -78,12 +78,12 @@ struct Response struct completedTask_Task { response::IdType completedTaskId {}; - std::optional title {}; - response::BooleanType isComplete {}; + std::optional title {}; + bool isComplete {}; }; std::optional completedTask {}; - std::optional clientMutationId {}; + std::optional clientMutationId {}; }; completedTask_CompleteTaskPayload completedTask {}; diff --git a/samples/client/QueryClient.cpp b/samples/client/QueryClient.cpp index 684ecbde..60e260df 100644 --- a/samples/client/QueryClient.cpp +++ b/samples/client/QueryClient.cpp @@ -7,8 +7,8 @@ #include #include -#include #include +#include #include using namespace std::literals; @@ -32,7 +32,7 @@ TaskState ModifiedResponse::parse(response::Value value) throw std::logic_error { "not a valid TaskState value" }; } - const auto itr = std::find(s_namesTaskState.cbegin(), s_namesTaskState.cend(), value.release()); + const auto itr = std::find(s_namesTaskState.cbegin(), s_namesTaskState.cend(), value.release()); if (itr == s_namesTaskState.cend()) { @@ -60,7 +60,7 @@ Response::appointments_AppointmentConnection::edges_AppointmentEdge::node_Appoin } if (member.first == R"js(subject)js"sv) { - result.subject = ModifiedResponse::parse(std::move(member.second)); + result.subject = ModifiedResponse::parse(std::move(member.second)); continue; } if (member.first == R"js(when)js"sv) @@ -70,12 +70,12 @@ Response::appointments_AppointmentConnection::edges_AppointmentEdge::node_Appoin } if (member.first == R"js(isNow)js"sv) { - result.isNow = ModifiedResponse::parse(std::move(member.second)); + result.isNow = ModifiedResponse::parse(std::move(member.second)); continue; } if (member.first == R"js(__typename)js"sv) { - result._typename = ModifiedResponse::parse(std::move(member.second)); + result._typename = ModifiedResponse::parse(std::move(member.second)); continue; } } @@ -146,17 +146,17 @@ Response::tasks_TaskConnection::edges_TaskEdge::node_Task ModifiedResponse::parse(std::move(member.second)); + result.title = ModifiedResponse::parse(std::move(member.second)); continue; } if (member.first == R"js(isComplete)js"sv) { - result.isComplete = ModifiedResponse::parse(std::move(member.second)); + result.isComplete = ModifiedResponse::parse(std::move(member.second)); continue; } if (member.first == R"js(__typename)js"sv) { - result._typename = ModifiedResponse::parse(std::move(member.second)); + result._typename = ModifiedResponse::parse(std::move(member.second)); continue; } } @@ -227,17 +227,17 @@ Response::unreadCounts_FolderConnection::edges_FolderEdge::node_Folder ModifiedR } if (member.first == R"js(name)js"sv) { - result.name = ModifiedResponse::parse(std::move(member.second)); + result.name = ModifiedResponse::parse(std::move(member.second)); continue; } if (member.first == R"js(unreadCount)js"sv) { - result.unreadCount = ModifiedResponse::parse(std::move(member.second)); + result.unreadCount = ModifiedResponse::parse(std::move(member.second)); continue; } if (member.first == R"js(__typename)js"sv) { - result._typename = ModifiedResponse::parse(std::move(member.second)); + result._typename = ModifiedResponse::parse(std::move(member.second)); continue; } } @@ -303,7 +303,7 @@ Response::anyType_UnionType ModifiedResponse::parse { if (member.first == R"js(__typename)js"sv) { - result._typename = ModifiedResponse::parse(std::move(member.second)); + result._typename = ModifiedResponse::parse(std::move(member.second)); continue; } if (member.first == R"js(id)js"sv) @@ -313,17 +313,17 @@ Response::anyType_UnionType ModifiedResponse::parse } if (member.first == R"js(title)js"sv) { - result.title = ModifiedResponse::parse(std::move(member.second)); + result.title = ModifiedResponse::parse(std::move(member.second)); continue; } if (member.first == R"js(isComplete)js"sv) { - result.isComplete = ModifiedResponse::parse(std::move(member.second)); + result.isComplete = ModifiedResponse::parse(std::move(member.second)); continue; } if (member.first == R"js(subject)js"sv) { - result.subject = ModifiedResponse::parse(std::move(member.second)); + result.subject = ModifiedResponse::parse(std::move(member.second)); continue; } if (member.first == R"js(when)js"sv) @@ -333,7 +333,7 @@ Response::anyType_UnionType ModifiedResponse::parse } if (member.first == R"js(isNow)js"sv) { - result.isNow = ModifiedResponse::parse(std::move(member.second)); + result.isNow = ModifiedResponse::parse(std::move(member.second)); continue; } } diff --git a/samples/client/QueryClient.h b/samples/client/QueryClient.h index deab57a5..35c24bb9 100644 --- a/samples/client/QueryClient.h +++ b/samples/client/QueryClient.h @@ -110,10 +110,10 @@ struct Response struct node_Appointment { response::IdType id {}; - std::optional subject {}; + std::optional subject {}; std::optional when {}; - response::BooleanType isNow {}; - response::StringType _typename {}; + bool isNow {}; + std::string _typename {}; }; std::optional node {}; @@ -129,9 +129,9 @@ struct Response struct node_Task { response::IdType id {}; - std::optional title {}; - response::BooleanType isComplete {}; - response::StringType _typename {}; + std::optional title {}; + bool isComplete {}; + std::string _typename {}; }; std::optional node {}; @@ -147,9 +147,9 @@ struct Response struct node_Folder { response::IdType id {}; - std::optional name {}; - response::IntType unreadCount {}; - response::StringType _typename {}; + std::optional name {}; + int unreadCount {}; + std::string _typename {}; }; std::optional node {}; @@ -160,13 +160,13 @@ struct Response struct anyType_UnionType { - response::StringType _typename {}; + std::string _typename {}; response::IdType id {}; - std::optional title {}; - response::BooleanType isComplete {}; - std::optional subject {}; + std::optional title {}; + bool isComplete {}; + std::optional subject {}; std::optional when {}; - response::BooleanType isNow {}; + bool isNow {}; }; appointments_AppointmentConnection appointments {}; diff --git a/samples/client/SubscribeClient.cpp b/samples/client/SubscribeClient.cpp index 9444e9e1..c2b250ef 100644 --- a/samples/client/SubscribeClient.cpp +++ b/samples/client/SubscribeClient.cpp @@ -7,8 +7,8 @@ #include #include -#include #include +#include #include using namespace std::literals; @@ -40,12 +40,12 @@ Response::nextAppointment_Appointment ModifiedResponse::parse(std::move(member.second)); + result.subject = ModifiedResponse::parse(std::move(member.second)); continue; } if (member.first == R"js(isNow)js"sv) { - result.isNow = ModifiedResponse::parse(std::move(member.second)); + result.isNow = ModifiedResponse::parse(std::move(member.second)); continue; } } diff --git a/samples/client/SubscribeClient.h b/samples/client/SubscribeClient.h index 3bd49085..c915885f 100644 --- a/samples/client/SubscribeClient.h +++ b/samples/client/SubscribeClient.h @@ -52,8 +52,8 @@ struct Response { response::IdType nextAppointmentId {}; std::optional when {}; - std::optional subject {}; - response::BooleanType isNow {}; + std::optional subject {}; + bool isNow {}; }; std::optional nextAppointment {}; diff --git a/samples/learn/DroidObject.cpp b/samples/learn/DroidObject.cpp index 87484db1..c3a8aa02 100644 --- a/samples/learn/DroidObject.cpp +++ b/samples/learn/DroidObject.cpp @@ -51,7 +51,7 @@ service::AwaitableResolver Droid::resolveId(service::ResolverParams&& params) auto result = _pimpl->getId(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } service::AwaitableResolver Droid::resolveName(service::ResolverParams&& params) @@ -61,7 +61,7 @@ service::AwaitableResolver Droid::resolveName(service::ResolverParams&& params) auto result = _pimpl->getName(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } service::AwaitableResolver Droid::resolveFriends(service::ResolverParams&& params) @@ -91,12 +91,12 @@ service::AwaitableResolver Droid::resolvePrimaryFunction(service::ResolverParams auto result = _pimpl->getPrimaryFunction(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } service::AwaitableResolver Droid::resolve_typename(service::ResolverParams&& params) { - return service::ModifiedResult::convert(response::StringType{ R"gql(Droid)gql" }, std::move(params)); + return service::ModifiedResult::convert(std::string{ R"gql(Droid)gql" }, std::move(params)); } } // namespace object diff --git a/samples/learn/DroidObject.h b/samples/learn/DroidObject.h index 4bc06caf..4a68ccd3 100644 --- a/samples/learn/DroidObject.h +++ b/samples/learn/DroidObject.h @@ -16,25 +16,25 @@ namespace methods::DroidMethod { template concept WithParamsId = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult { impl.getId(std::move(params)) } }; + { service::FieldResult { impl.getId(std::move(params)) } }; }; template concept NoParamsId = requires (TImpl impl) { - { service::FieldResult { impl.getId() } }; + { service::FieldResult { impl.getId() } }; }; template concept WithParamsName = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult> { impl.getName(std::move(params)) } }; + { service::FieldResult> { impl.getName(std::move(params)) } }; }; template concept NoParamsName = requires (TImpl impl) { - { service::FieldResult> { impl.getName() } }; + { service::FieldResult> { impl.getName() } }; }; template @@ -64,13 +64,13 @@ concept NoParamsAppearsIn = requires (TImpl impl) template concept WithParamsPrimaryFunction = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult> { impl.getPrimaryFunction(std::move(params)) } }; + { service::FieldResult> { impl.getPrimaryFunction(std::move(params)) } }; }; template concept NoParamsPrimaryFunction = requires (TImpl impl) { - { service::FieldResult> { impl.getPrimaryFunction() } }; + { service::FieldResult> { impl.getPrimaryFunction() } }; }; template @@ -107,7 +107,7 @@ class Droid virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual service::FieldResult> getPrimaryFunction(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getPrimaryFunction(service::FieldParams&& params) const = 0; }; template @@ -119,7 +119,7 @@ class Droid { } - service::FieldResult getId(service::FieldParams&& params) const final + service::FieldResult getId(service::FieldParams&& params) const final { if constexpr (methods::DroidMethod::WithParamsId) { @@ -132,7 +132,7 @@ class Droid } } - service::FieldResult> getName(service::FieldParams&& params) const final + service::FieldResult> getName(service::FieldParams&& params) const final { if constexpr (methods::DroidMethod::WithParamsName) { @@ -171,7 +171,7 @@ class Droid } } - service::FieldResult> getPrimaryFunction(service::FieldParams&& params) const final + service::FieldResult> getPrimaryFunction(service::FieldParams&& params) const final { if constexpr (methods::DroidMethod::WithParamsPrimaryFunction) { diff --git a/samples/learn/HumanObject.cpp b/samples/learn/HumanObject.cpp index 4a4920cb..9c293201 100644 --- a/samples/learn/HumanObject.cpp +++ b/samples/learn/HumanObject.cpp @@ -51,7 +51,7 @@ service::AwaitableResolver Human::resolveId(service::ResolverParams&& params) auto result = _pimpl->getId(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } service::AwaitableResolver Human::resolveName(service::ResolverParams&& params) @@ -61,7 +61,7 @@ service::AwaitableResolver Human::resolveName(service::ResolverParams&& params) auto result = _pimpl->getName(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } service::AwaitableResolver Human::resolveFriends(service::ResolverParams&& params) @@ -91,12 +91,12 @@ service::AwaitableResolver Human::resolveHomePlanet(service::ResolverParams&& pa auto result = _pimpl->getHomePlanet(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } service::AwaitableResolver Human::resolve_typename(service::ResolverParams&& params) { - return service::ModifiedResult::convert(response::StringType{ R"gql(Human)gql" }, std::move(params)); + return service::ModifiedResult::convert(std::string{ R"gql(Human)gql" }, std::move(params)); } } // namespace object diff --git a/samples/learn/HumanObject.h b/samples/learn/HumanObject.h index 8e974b00..aab00461 100644 --- a/samples/learn/HumanObject.h +++ b/samples/learn/HumanObject.h @@ -16,25 +16,25 @@ namespace methods::HumanMethod { template concept WithParamsId = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult { impl.getId(std::move(params)) } }; + { service::FieldResult { impl.getId(std::move(params)) } }; }; template concept NoParamsId = requires (TImpl impl) { - { service::FieldResult { impl.getId() } }; + { service::FieldResult { impl.getId() } }; }; template concept WithParamsName = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult> { impl.getName(std::move(params)) } }; + { service::FieldResult> { impl.getName(std::move(params)) } }; }; template concept NoParamsName = requires (TImpl impl) { - { service::FieldResult> { impl.getName() } }; + { service::FieldResult> { impl.getName() } }; }; template @@ -64,13 +64,13 @@ concept NoParamsAppearsIn = requires (TImpl impl) template concept WithParamsHomePlanet = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult> { impl.getHomePlanet(std::move(params)) } }; + { service::FieldResult> { impl.getHomePlanet(std::move(params)) } }; }; template concept NoParamsHomePlanet = requires (TImpl impl) { - { service::FieldResult> { impl.getHomePlanet() } }; + { service::FieldResult> { impl.getHomePlanet() } }; }; template @@ -107,7 +107,7 @@ class Human virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual service::FieldResult> getHomePlanet(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getHomePlanet(service::FieldParams&& params) const = 0; }; template @@ -119,7 +119,7 @@ class Human { } - service::FieldResult getId(service::FieldParams&& params) const final + service::FieldResult getId(service::FieldParams&& params) const final { if constexpr (methods::HumanMethod::WithParamsId) { @@ -132,7 +132,7 @@ class Human } } - service::FieldResult> getName(service::FieldParams&& params) const final + service::FieldResult> getName(service::FieldParams&& params) const final { if constexpr (methods::HumanMethod::WithParamsName) { @@ -171,7 +171,7 @@ class Human } } - service::FieldResult> getHomePlanet(service::FieldParams&& params) const final + service::FieldResult> getHomePlanet(service::FieldParams&& params) const final { if constexpr (methods::HumanMethod::WithParamsHomePlanet) { diff --git a/samples/learn/MutationObject.cpp b/samples/learn/MutationObject.cpp index 299dd904..608b3293 100644 --- a/samples/learn/MutationObject.cpp +++ b/samples/learn/MutationObject.cpp @@ -53,7 +53,7 @@ service::AwaitableResolver Mutation::resolveCreateReview(service::ResolverParams service::AwaitableResolver Mutation::resolve_typename(service::ResolverParams&& params) { - return service::ModifiedResult::convert(response::StringType{ R"gql(Mutation)gql" }, std::move(params)); + return service::ModifiedResult::convert(std::string{ R"gql(Mutation)gql" }, std::move(params)); } } // namespace object diff --git a/samples/learn/QueryObject.cpp b/samples/learn/QueryObject.cpp index 7ee362f9..b31490e0 100644 --- a/samples/learn/QueryObject.cpp +++ b/samples/learn/QueryObject.cpp @@ -57,7 +57,7 @@ service::AwaitableResolver Query::resolveHero(service::ResolverParams&& params) service::AwaitableResolver Query::resolveHuman(service::ResolverParams&& params) { - auto argId = service::ModifiedArgument::require("id", params.arguments); + auto argId = service::ModifiedArgument::require("id", params.arguments); std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); auto result = _pimpl->getHuman(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argId)); @@ -68,7 +68,7 @@ service::AwaitableResolver Query::resolveHuman(service::ResolverParams&& params) service::AwaitableResolver Query::resolveDroid(service::ResolverParams&& params) { - auto argId = service::ModifiedArgument::require("id", params.arguments); + auto argId = service::ModifiedArgument::require("id", params.arguments); std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); auto result = _pimpl->getDroid(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argId)); @@ -79,7 +79,7 @@ service::AwaitableResolver Query::resolveDroid(service::ResolverParams&& params) service::AwaitableResolver Query::resolve_typename(service::ResolverParams&& params) { - return service::ModifiedResult::convert(response::StringType{ R"gql(Query)gql" }, std::move(params)); + return service::ModifiedResult::convert(std::string{ R"gql(Query)gql" }, std::move(params)); } service::AwaitableResolver Query::resolve_schema(service::ResolverParams&& params) @@ -89,7 +89,7 @@ service::AwaitableResolver Query::resolve_schema(service::ResolverParams&& param service::AwaitableResolver Query::resolve_type(service::ResolverParams&& params) { - auto argName = service::ModifiedArgument::require("name", params.arguments); + auto argName = service::ModifiedArgument::require("name", params.arguments); const auto& baseType = _schema->LookupType(argName); std::shared_ptr result { baseType ? std::make_shared(std::make_shared(baseType)) : nullptr }; diff --git a/samples/learn/QueryObject.h b/samples/learn/QueryObject.h index d1ad8889..059bbefa 100644 --- a/samples/learn/QueryObject.h +++ b/samples/learn/QueryObject.h @@ -26,25 +26,25 @@ concept NoParamsHero = requires (TImpl impl, std::optional episodeArg) }; template -concept WithParamsHuman = requires (TImpl impl, service::FieldParams params, response::StringType idArg) +concept WithParamsHuman = requires (TImpl impl, service::FieldParams params, std::string idArg) { { service::FieldResult> { impl.getHuman(std::move(params), std::move(idArg)) } }; }; template -concept NoParamsHuman = requires (TImpl impl, response::StringType idArg) +concept NoParamsHuman = requires (TImpl impl, std::string idArg) { { service::FieldResult> { impl.getHuman(std::move(idArg)) } }; }; template -concept WithParamsDroid = requires (TImpl impl, service::FieldParams params, response::StringType idArg) +concept WithParamsDroid = requires (TImpl impl, service::FieldParams params, std::string idArg) { { service::FieldResult> { impl.getDroid(std::move(params), std::move(idArg)) } }; }; template -concept NoParamsDroid = requires (TImpl impl, response::StringType idArg) +concept NoParamsDroid = requires (TImpl impl, std::string idArg) { { service::FieldResult> { impl.getDroid(std::move(idArg)) } }; }; @@ -85,8 +85,8 @@ class Query virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; virtual service::FieldResult> getHero(service::FieldParams&& params, std::optional&& episodeArg) const = 0; - virtual service::FieldResult> getHuman(service::FieldParams&& params, response::StringType&& idArg) const = 0; - virtual service::FieldResult> getDroid(service::FieldParams&& params, response::StringType&& idArg) const = 0; + virtual service::FieldResult> getHuman(service::FieldParams&& params, std::string&& idArg) const = 0; + virtual service::FieldResult> getDroid(service::FieldParams&& params, std::string&& idArg) const = 0; }; template @@ -111,7 +111,7 @@ class Query } } - service::FieldResult> getHuman(service::FieldParams&& params, response::StringType&& idArg) const final + service::FieldResult> getHuman(service::FieldParams&& params, std::string&& idArg) const final { if constexpr (methods::QueryMethod::WithParamsHuman) { @@ -124,7 +124,7 @@ class Query } } - service::FieldResult> getDroid(service::FieldParams&& params, response::StringType&& idArg) const final + service::FieldResult> getDroid(service::FieldParams&& params, std::string&& idArg) const final { if constexpr (methods::QueryMethod::WithParamsDroid) { diff --git a/samples/learn/ReviewObject.cpp b/samples/learn/ReviewObject.cpp index 29831c44..ac9daf40 100644 --- a/samples/learn/ReviewObject.cpp +++ b/samples/learn/ReviewObject.cpp @@ -47,7 +47,7 @@ service::AwaitableResolver Review::resolveStars(service::ResolverParams&& params auto result = _pimpl->getStars(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } service::AwaitableResolver Review::resolveCommentary(service::ResolverParams&& params) @@ -57,12 +57,12 @@ service::AwaitableResolver Review::resolveCommentary(service::ResolverParams&& p auto result = _pimpl->getCommentary(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } service::AwaitableResolver Review::resolve_typename(service::ResolverParams&& params) { - return service::ModifiedResult::convert(response::StringType{ R"gql(Review)gql" }, std::move(params)); + return service::ModifiedResult::convert(std::string{ R"gql(Review)gql" }, std::move(params)); } } // namespace object diff --git a/samples/learn/ReviewObject.h b/samples/learn/ReviewObject.h index f67eec85..aac678ca 100644 --- a/samples/learn/ReviewObject.h +++ b/samples/learn/ReviewObject.h @@ -16,25 +16,25 @@ namespace methods::ReviewMethod { template concept WithParamsStars = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult { impl.getStars(std::move(params)) } }; + { service::FieldResult { impl.getStars(std::move(params)) } }; }; template concept NoParamsStars = requires (TImpl impl) { - { service::FieldResult { impl.getStars() } }; + { service::FieldResult { impl.getStars() } }; }; template concept WithParamsCommentary = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult> { impl.getCommentary(std::move(params)) } }; + { service::FieldResult> { impl.getCommentary(std::move(params)) } }; }; template concept NoParamsCommentary = requires (TImpl impl) { - { service::FieldResult> { impl.getCommentary() } }; + { service::FieldResult> { impl.getCommentary() } }; }; template @@ -67,8 +67,8 @@ class Review virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual service::FieldResult getStars(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getCommentary(service::FieldParams&& params) const = 0; + virtual service::FieldResult getStars(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getCommentary(service::FieldParams&& params) const = 0; }; template @@ -80,7 +80,7 @@ class Review { } - service::FieldResult getStars(service::FieldParams&& params) const final + service::FieldResult getStars(service::FieldParams&& params) const final { if constexpr (methods::ReviewMethod::WithParamsStars) { @@ -93,7 +93,7 @@ class Review } } - service::FieldResult> getCommentary(service::FieldParams&& params) const final + service::FieldResult> getCommentary(service::FieldParams&& params) const final { if constexpr (methods::ReviewMethod::WithParamsCommentary) { diff --git a/samples/learn/StarWarsSchema.cpp b/samples/learn/StarWarsSchema.cpp index d8704cc6..26ce5b3c 100644 --- a/samples/learn/StarWarsSchema.cpp +++ b/samples/learn/StarWarsSchema.cpp @@ -35,7 +35,7 @@ learn::Episode ModifiedArgument::convert(const response::Value& throw service::schema_exception { { "not a valid Episode value" } }; } - const auto itr = std::find(s_namesEpisode.cbegin(), s_namesEpisode.cend(), value.get()); + const auto itr = std::find(s_namesEpisode.cbegin(), s_namesEpisode.cend(), value.get()); if (itr == s_namesEpisode.cend()) { @@ -53,7 +53,7 @@ service::AwaitableResolver ModifiedResult::convert(service::Fiel { response::Value result(response::Type::EnumValue); - result.set(response::StringType { s_namesEpisode[static_cast(value)] }); + result.set(std::string { s_namesEpisode[static_cast(value)] }); return result; }); @@ -62,8 +62,8 @@ service::AwaitableResolver ModifiedResult::convert(service::Fiel template <> learn::ReviewInput ModifiedArgument::convert(const response::Value& value) { - auto valueStars = service::ModifiedArgument::require("stars", value); - auto valueCommentary = service::ModifiedArgument::require("commentary", value); + auto valueStars = service::ModifiedArgument::require("stars", value); + auto valueCommentary = service::ModifiedArgument::require("commentary", value); return { std::move(valueStars), diff --git a/samples/learn/StarWarsSchema.h b/samples/learn/StarWarsSchema.h index 076397c3..38dc21c2 100644 --- a/samples/learn/StarWarsSchema.h +++ b/samples/learn/StarWarsSchema.h @@ -30,8 +30,8 @@ enum class Episode struct ReviewInput { - response::IntType stars; - std::optional commentary; + int stars; + std::optional commentary; }; namespace object { @@ -46,8 +46,8 @@ class Mutation; struct Character { - virtual service::FieldResult getId(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getName(service::FieldParams&& params) const = 0; + virtual service::FieldResult getId(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getName(service::FieldParams&& params) const = 0; virtual service::FieldResult>>> getFriends(service::FieldParams&& params) const = 0; virtual service::FieldResult>>> getAppearsIn(service::FieldParams&& params) const = 0; }; diff --git a/samples/separate/AppointmentConnectionObject.cpp b/samples/separate/AppointmentConnectionObject.cpp index 4925c263..4a97fb36 100644 --- a/samples/separate/AppointmentConnectionObject.cpp +++ b/samples/separate/AppointmentConnectionObject.cpp @@ -62,7 +62,7 @@ service::AwaitableResolver AppointmentConnection::resolveEdges(service::Resolver service::AwaitableResolver AppointmentConnection::resolve_typename(service::ResolverParams&& params) { - return service::ModifiedResult::convert(response::StringType{ R"gql(AppointmentConnection)gql" }, std::move(params)); + return service::ModifiedResult::convert(std::string{ R"gql(AppointmentConnection)gql" }, std::move(params)); } } // namespace object diff --git a/samples/separate/AppointmentEdgeObject.cpp b/samples/separate/AppointmentEdgeObject.cpp index eff163fc..05a5d795 100644 --- a/samples/separate/AppointmentEdgeObject.cpp +++ b/samples/separate/AppointmentEdgeObject.cpp @@ -62,7 +62,7 @@ service::AwaitableResolver AppointmentEdge::resolveCursor(service::ResolverParam service::AwaitableResolver AppointmentEdge::resolve_typename(service::ResolverParams&& params) { - return service::ModifiedResult::convert(response::StringType{ R"gql(AppointmentEdge)gql" }, std::move(params)); + return service::ModifiedResult::convert(std::string{ R"gql(AppointmentEdge)gql" }, std::move(params)); } } // namespace object diff --git a/samples/separate/AppointmentObject.cpp b/samples/separate/AppointmentObject.cpp index 228bdcff..338ab608 100644 --- a/samples/separate/AppointmentObject.cpp +++ b/samples/separate/AppointmentObject.cpp @@ -72,7 +72,7 @@ service::AwaitableResolver Appointment::resolveSubject(service::ResolverParams&& auto result = _pimpl->getSubject(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } service::AwaitableResolver Appointment::resolveIsNow(service::ResolverParams&& params) @@ -82,7 +82,7 @@ service::AwaitableResolver Appointment::resolveIsNow(service::ResolverParams&& p auto result = _pimpl->getIsNow(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } service::AwaitableResolver Appointment::resolveForceError(service::ResolverParams&& params) @@ -92,12 +92,12 @@ service::AwaitableResolver Appointment::resolveForceError(service::ResolverParam auto result = _pimpl->getForceError(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } service::AwaitableResolver Appointment::resolve_typename(service::ResolverParams&& params) { - return service::ModifiedResult::convert(response::StringType{ R"gql(Appointment)gql" }, std::move(params)); + return service::ModifiedResult::convert(std::string{ R"gql(Appointment)gql" }, std::move(params)); } } // namespace object diff --git a/samples/separate/AppointmentObject.h b/samples/separate/AppointmentObject.h index 002c99c7..fd49dd1d 100644 --- a/samples/separate/AppointmentObject.h +++ b/samples/separate/AppointmentObject.h @@ -40,37 +40,37 @@ concept NoParamsWhen = requires (TImpl impl) template concept WithParamsSubject = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult> { impl.getSubject(std::move(params)) } }; + { service::FieldResult> { impl.getSubject(std::move(params)) } }; }; template concept NoParamsSubject = requires (TImpl impl) { - { service::FieldResult> { impl.getSubject() } }; + { service::FieldResult> { impl.getSubject() } }; }; template concept WithParamsIsNow = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult { impl.getIsNow(std::move(params)) } }; + { service::FieldResult { impl.getIsNow(std::move(params)) } }; }; template concept NoParamsIsNow = requires (TImpl impl) { - { service::FieldResult { impl.getIsNow() } }; + { service::FieldResult { impl.getIsNow() } }; }; template concept WithParamsForceError = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult> { impl.getForceError(std::move(params)) } }; + { service::FieldResult> { impl.getForceError(std::move(params)) } }; }; template concept NoParamsForceError = requires (TImpl impl) { - { service::FieldResult> { impl.getForceError() } }; + { service::FieldResult> { impl.getForceError() } }; }; template @@ -108,9 +108,9 @@ class Appointment virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; virtual service::FieldResult> getWhen(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getSubject(service::FieldParams&& params) const = 0; - virtual service::FieldResult getIsNow(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getForceError(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getSubject(service::FieldParams&& params) const = 0; + virtual service::FieldResult getIsNow(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getForceError(service::FieldParams&& params) const = 0; }; template @@ -154,7 +154,7 @@ class Appointment } } - service::FieldResult> getSubject(service::FieldParams&& params) const final + service::FieldResult> getSubject(service::FieldParams&& params) const final { if constexpr (methods::AppointmentMethod::WithParamsSubject) { @@ -170,7 +170,7 @@ class Appointment } } - service::FieldResult getIsNow(service::FieldParams&& params) const final + service::FieldResult getIsNow(service::FieldParams&& params) const final { if constexpr (methods::AppointmentMethod::WithParamsIsNow) { @@ -186,7 +186,7 @@ class Appointment } } - service::FieldResult> getForceError(service::FieldParams&& params) const final + service::FieldResult> getForceError(service::FieldParams&& params) const final { if constexpr (methods::AppointmentMethod::WithParamsForceError) { diff --git a/samples/separate/CompleteTaskPayloadObject.cpp b/samples/separate/CompleteTaskPayloadObject.cpp index b6b85919..0c8036f8 100644 --- a/samples/separate/CompleteTaskPayloadObject.cpp +++ b/samples/separate/CompleteTaskPayloadObject.cpp @@ -57,12 +57,12 @@ service::AwaitableResolver CompleteTaskPayload::resolveClientMutationId(service: auto result = _pimpl->getClientMutationId(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } service::AwaitableResolver CompleteTaskPayload::resolve_typename(service::ResolverParams&& params) { - return service::ModifiedResult::convert(response::StringType{ R"gql(CompleteTaskPayload)gql" }, std::move(params)); + return service::ModifiedResult::convert(std::string{ R"gql(CompleteTaskPayload)gql" }, std::move(params)); } } // namespace object diff --git a/samples/separate/CompleteTaskPayloadObject.h b/samples/separate/CompleteTaskPayloadObject.h index 054b0c9a..3411230d 100644 --- a/samples/separate/CompleteTaskPayloadObject.h +++ b/samples/separate/CompleteTaskPayloadObject.h @@ -28,13 +28,13 @@ concept NoParamsTask = requires (TImpl impl) template concept WithParamsClientMutationId = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult> { impl.getClientMutationId(std::move(params)) } }; + { service::FieldResult> { impl.getClientMutationId(std::move(params)) } }; }; template concept NoParamsClientMutationId = requires (TImpl impl) { - { service::FieldResult> { impl.getClientMutationId() } }; + { service::FieldResult> { impl.getClientMutationId() } }; }; template @@ -68,7 +68,7 @@ class CompleteTaskPayload virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; virtual service::FieldResult> getTask(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getClientMutationId(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getClientMutationId(service::FieldParams&& params) const = 0; }; template @@ -96,7 +96,7 @@ class CompleteTaskPayload } } - service::FieldResult> getClientMutationId(service::FieldParams&& params) const final + service::FieldResult> getClientMutationId(service::FieldParams&& params) const final { if constexpr (methods::CompleteTaskPayloadMethod::WithParamsClientMutationId) { diff --git a/samples/separate/ExpensiveObject.cpp b/samples/separate/ExpensiveObject.cpp index 16528213..4e036d1f 100644 --- a/samples/separate/ExpensiveObject.cpp +++ b/samples/separate/ExpensiveObject.cpp @@ -46,12 +46,12 @@ service::AwaitableResolver Expensive::resolveOrder(service::ResolverParams&& par auto result = _pimpl->getOrder(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } service::AwaitableResolver Expensive::resolve_typename(service::ResolverParams&& params) { - return service::ModifiedResult::convert(response::StringType{ R"gql(Expensive)gql" }, std::move(params)); + return service::ModifiedResult::convert(std::string{ R"gql(Expensive)gql" }, std::move(params)); } } // namespace object diff --git a/samples/separate/ExpensiveObject.h b/samples/separate/ExpensiveObject.h index d34236b8..7fd5d538 100644 --- a/samples/separate/ExpensiveObject.h +++ b/samples/separate/ExpensiveObject.h @@ -16,13 +16,13 @@ namespace methods::ExpensiveMethod { template concept WithParamsOrder = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult { impl.getOrder(std::move(params)) } }; + { service::FieldResult { impl.getOrder(std::move(params)) } }; }; template concept NoParamsOrder = requires (TImpl impl) { - { service::FieldResult { impl.getOrder() } }; + { service::FieldResult { impl.getOrder() } }; }; template @@ -54,7 +54,7 @@ class Expensive virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual service::FieldResult getOrder(service::FieldParams&& params) const = 0; + virtual service::FieldResult getOrder(service::FieldParams&& params) const = 0; }; template @@ -66,7 +66,7 @@ class Expensive { } - service::FieldResult getOrder(service::FieldParams&& params) const final + service::FieldResult getOrder(service::FieldParams&& params) const final { if constexpr (methods::ExpensiveMethod::WithParamsOrder) { diff --git a/samples/separate/FolderConnectionObject.cpp b/samples/separate/FolderConnectionObject.cpp index a9ac2ff5..b47dd28d 100644 --- a/samples/separate/FolderConnectionObject.cpp +++ b/samples/separate/FolderConnectionObject.cpp @@ -62,7 +62,7 @@ service::AwaitableResolver FolderConnection::resolveEdges(service::ResolverParam service::AwaitableResolver FolderConnection::resolve_typename(service::ResolverParams&& params) { - return service::ModifiedResult::convert(response::StringType{ R"gql(FolderConnection)gql" }, std::move(params)); + return service::ModifiedResult::convert(std::string{ R"gql(FolderConnection)gql" }, std::move(params)); } } // namespace object diff --git a/samples/separate/FolderEdgeObject.cpp b/samples/separate/FolderEdgeObject.cpp index bd741d44..95ed2c21 100644 --- a/samples/separate/FolderEdgeObject.cpp +++ b/samples/separate/FolderEdgeObject.cpp @@ -62,7 +62,7 @@ service::AwaitableResolver FolderEdge::resolveCursor(service::ResolverParams&& p service::AwaitableResolver FolderEdge::resolve_typename(service::ResolverParams&& params) { - return service::ModifiedResult::convert(response::StringType{ R"gql(FolderEdge)gql" }, std::move(params)); + return service::ModifiedResult::convert(std::string{ R"gql(FolderEdge)gql" }, std::move(params)); } } // namespace object diff --git a/samples/separate/FolderObject.cpp b/samples/separate/FolderObject.cpp index c425c3ff..dfe25974 100644 --- a/samples/separate/FolderObject.cpp +++ b/samples/separate/FolderObject.cpp @@ -60,7 +60,7 @@ service::AwaitableResolver Folder::resolveName(service::ResolverParams&& params) auto result = _pimpl->getName(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } service::AwaitableResolver Folder::resolveUnreadCount(service::ResolverParams&& params) @@ -70,12 +70,12 @@ service::AwaitableResolver Folder::resolveUnreadCount(service::ResolverParams&& auto result = _pimpl->getUnreadCount(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } service::AwaitableResolver Folder::resolve_typename(service::ResolverParams&& params) { - return service::ModifiedResult::convert(response::StringType{ R"gql(Folder)gql" }, std::move(params)); + return service::ModifiedResult::convert(std::string{ R"gql(Folder)gql" }, std::move(params)); } } // namespace object diff --git a/samples/separate/FolderObject.h b/samples/separate/FolderObject.h index e96ba675..940f1190 100644 --- a/samples/separate/FolderObject.h +++ b/samples/separate/FolderObject.h @@ -28,25 +28,25 @@ concept NoParamsId = requires (TImpl impl) template concept WithParamsName = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult> { impl.getName(std::move(params)) } }; + { service::FieldResult> { impl.getName(std::move(params)) } }; }; template concept NoParamsName = requires (TImpl impl) { - { service::FieldResult> { impl.getName() } }; + { service::FieldResult> { impl.getName() } }; }; template concept WithParamsUnreadCount = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult { impl.getUnreadCount(std::move(params)) } }; + { service::FieldResult { impl.getUnreadCount(std::move(params)) } }; }; template concept NoParamsUnreadCount = requires (TImpl impl) { - { service::FieldResult { impl.getUnreadCount() } }; + { service::FieldResult { impl.getUnreadCount() } }; }; template @@ -81,8 +81,8 @@ class Folder virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual service::FieldResult> getName(service::FieldParams&& params) const = 0; - virtual service::FieldResult getUnreadCount(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getName(service::FieldParams&& params) const = 0; + virtual service::FieldResult getUnreadCount(service::FieldParams&& params) const = 0; }; template @@ -110,7 +110,7 @@ class Folder } } - service::FieldResult> getName(service::FieldParams&& params) const final + service::FieldResult> getName(service::FieldParams&& params) const final { if constexpr (methods::FolderMethod::WithParamsName) { @@ -126,7 +126,7 @@ class Folder } } - service::FieldResult getUnreadCount(service::FieldParams&& params) const final + service::FieldResult getUnreadCount(service::FieldParams&& params) const final { if constexpr (methods::FolderMethod::WithParamsUnreadCount) { diff --git a/samples/separate/MutationObject.cpp b/samples/separate/MutationObject.cpp index 6f41f9a0..5d80c817 100644 --- a/samples/separate/MutationObject.cpp +++ b/samples/separate/MutationObject.cpp @@ -53,18 +53,18 @@ service::AwaitableResolver Mutation::resolveCompleteTask(service::ResolverParams service::AwaitableResolver Mutation::resolveSetFloat(service::ResolverParams&& params) { - auto argValue = service::ModifiedArgument::require("value", params.arguments); + auto argValue = service::ModifiedArgument::require("value", params.arguments); std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); auto result = _pimpl->applySetFloat(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argValue)); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } service::AwaitableResolver Mutation::resolve_typename(service::ResolverParams&& params) { - return service::ModifiedResult::convert(response::StringType{ R"gql(Mutation)gql" }, std::move(params)); + return service::ModifiedResult::convert(std::string{ R"gql(Mutation)gql" }, std::move(params)); } } // namespace object diff --git a/samples/separate/MutationObject.h b/samples/separate/MutationObject.h index be61f359..c78f0ac3 100644 --- a/samples/separate/MutationObject.h +++ b/samples/separate/MutationObject.h @@ -26,15 +26,15 @@ concept NoParamsCompleteTask = requires (TImpl impl, CompleteTaskInput inputArg) }; template -concept WithParamsSetFloat = requires (TImpl impl, service::FieldParams params, response::FloatType valueArg) +concept WithParamsSetFloat = requires (TImpl impl, service::FieldParams params, double valueArg) { - { service::FieldResult { impl.applySetFloat(std::move(params), std::move(valueArg)) } }; + { service::FieldResult { impl.applySetFloat(std::move(params), std::move(valueArg)) } }; }; template -concept NoParamsSetFloat = requires (TImpl impl, response::FloatType valueArg) +concept NoParamsSetFloat = requires (TImpl impl, double valueArg) { - { service::FieldResult { impl.applySetFloat(std::move(valueArg)) } }; + { service::FieldResult { impl.applySetFloat(std::move(valueArg)) } }; }; template @@ -68,7 +68,7 @@ class Mutation virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; virtual service::FieldResult> applyCompleteTask(service::FieldParams&& params, CompleteTaskInput&& inputArg) const = 0; - virtual service::FieldResult applySetFloat(service::FieldParams&& params, response::FloatType&& valueArg) const = 0; + virtual service::FieldResult applySetFloat(service::FieldParams&& params, double&& valueArg) const = 0; }; template @@ -96,7 +96,7 @@ class Mutation } } - service::FieldResult applySetFloat(service::FieldParams&& params, response::FloatType&& valueArg) const final + service::FieldResult applySetFloat(service::FieldParams&& params, double&& valueArg) const final { if constexpr (methods::MutationMethod::WithParamsSetFloat) { diff --git a/samples/separate/NestedTypeObject.cpp b/samples/separate/NestedTypeObject.cpp index 54a027b3..797d562a 100644 --- a/samples/separate/NestedTypeObject.cpp +++ b/samples/separate/NestedTypeObject.cpp @@ -47,7 +47,7 @@ service::AwaitableResolver NestedType::resolveDepth(service::ResolverParams&& pa auto result = _pimpl->getDepth(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } service::AwaitableResolver NestedType::resolveNested(service::ResolverParams&& params) @@ -62,7 +62,7 @@ service::AwaitableResolver NestedType::resolveNested(service::ResolverParams&& p service::AwaitableResolver NestedType::resolve_typename(service::ResolverParams&& params) { - return service::ModifiedResult::convert(response::StringType{ R"gql(NestedType)gql" }, std::move(params)); + return service::ModifiedResult::convert(std::string{ R"gql(NestedType)gql" }, std::move(params)); } } // namespace object diff --git a/samples/separate/NestedTypeObject.h b/samples/separate/NestedTypeObject.h index d4f2551f..3ef0292a 100644 --- a/samples/separate/NestedTypeObject.h +++ b/samples/separate/NestedTypeObject.h @@ -16,13 +16,13 @@ namespace methods::NestedTypeMethod { template concept WithParamsDepth = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult { impl.getDepth(std::move(params)) } }; + { service::FieldResult { impl.getDepth(std::move(params)) } }; }; template concept NoParamsDepth = requires (TImpl impl) { - { service::FieldResult { impl.getDepth() } }; + { service::FieldResult { impl.getDepth() } }; }; template @@ -67,7 +67,7 @@ class NestedType virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual service::FieldResult getDepth(service::FieldParams&& params) const = 0; + virtual service::FieldResult getDepth(service::FieldParams&& params) const = 0; virtual service::FieldResult> getNested(service::FieldParams&& params) const = 0; }; @@ -80,7 +80,7 @@ class NestedType { } - service::FieldResult getDepth(service::FieldParams&& params) const final + service::FieldResult getDepth(service::FieldParams&& params) const final { if constexpr (methods::NestedTypeMethod::WithParamsDepth) { diff --git a/samples/separate/PageInfoObject.cpp b/samples/separate/PageInfoObject.cpp index e0cc198f..e9677c85 100644 --- a/samples/separate/PageInfoObject.cpp +++ b/samples/separate/PageInfoObject.cpp @@ -47,7 +47,7 @@ service::AwaitableResolver PageInfo::resolveHasNextPage(service::ResolverParams& auto result = _pimpl->getHasNextPage(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } service::AwaitableResolver PageInfo::resolveHasPreviousPage(service::ResolverParams&& params) @@ -57,12 +57,12 @@ service::AwaitableResolver PageInfo::resolveHasPreviousPage(service::ResolverPar auto result = _pimpl->getHasPreviousPage(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } service::AwaitableResolver PageInfo::resolve_typename(service::ResolverParams&& params) { - return service::ModifiedResult::convert(response::StringType{ R"gql(PageInfo)gql" }, std::move(params)); + return service::ModifiedResult::convert(std::string{ R"gql(PageInfo)gql" }, std::move(params)); } } // namespace object diff --git a/samples/separate/PageInfoObject.h b/samples/separate/PageInfoObject.h index cf4a8158..ca851ed1 100644 --- a/samples/separate/PageInfoObject.h +++ b/samples/separate/PageInfoObject.h @@ -16,25 +16,25 @@ namespace methods::PageInfoMethod { template concept WithParamsHasNextPage = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult { impl.getHasNextPage(std::move(params)) } }; + { service::FieldResult { impl.getHasNextPage(std::move(params)) } }; }; template concept NoParamsHasNextPage = requires (TImpl impl) { - { service::FieldResult { impl.getHasNextPage() } }; + { service::FieldResult { impl.getHasNextPage() } }; }; template concept WithParamsHasPreviousPage = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult { impl.getHasPreviousPage(std::move(params)) } }; + { service::FieldResult { impl.getHasPreviousPage(std::move(params)) } }; }; template concept NoParamsHasPreviousPage = requires (TImpl impl) { - { service::FieldResult { impl.getHasPreviousPage() } }; + { service::FieldResult { impl.getHasPreviousPage() } }; }; template @@ -67,8 +67,8 @@ class PageInfo virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual service::FieldResult getHasNextPage(service::FieldParams&& params) const = 0; - virtual service::FieldResult getHasPreviousPage(service::FieldParams&& params) const = 0; + virtual service::FieldResult getHasNextPage(service::FieldParams&& params) const = 0; + virtual service::FieldResult getHasPreviousPage(service::FieldParams&& params) const = 0; }; template @@ -80,7 +80,7 @@ class PageInfo { } - service::FieldResult getHasNextPage(service::FieldParams&& params) const final + service::FieldResult getHasNextPage(service::FieldParams&& params) const final { if constexpr (methods::PageInfoMethod::WithParamsHasNextPage) { @@ -96,7 +96,7 @@ class PageInfo } } - service::FieldResult getHasPreviousPage(service::FieldParams&& params) const final + service::FieldResult getHasPreviousPage(service::FieldParams&& params) const final { if constexpr (methods::PageInfoMethod::WithParamsHasPreviousPage) { diff --git a/samples/separate/QueryObject.cpp b/samples/separate/QueryObject.cpp index 0b395e44..3ce1de65 100644 --- a/samples/separate/QueryObject.cpp +++ b/samples/separate/QueryObject.cpp @@ -66,9 +66,9 @@ service::AwaitableResolver Query::resolveNode(service::ResolverParams&& params) service::AwaitableResolver Query::resolveAppointments(service::ResolverParams&& params) { - auto argFirst = service::ModifiedArgument::require("first", params.arguments); + auto argFirst = service::ModifiedArgument::require("first", params.arguments); auto argAfter = service::ModifiedArgument::require("after", params.arguments); - auto argLast = service::ModifiedArgument::require("last", params.arguments); + auto argLast = service::ModifiedArgument::require("last", params.arguments); auto argBefore = service::ModifiedArgument::require("before", params.arguments); std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -80,9 +80,9 @@ service::AwaitableResolver Query::resolveAppointments(service::ResolverParams&& service::AwaitableResolver Query::resolveTasks(service::ResolverParams&& params) { - auto argFirst = service::ModifiedArgument::require("first", params.arguments); + auto argFirst = service::ModifiedArgument::require("first", params.arguments); auto argAfter = service::ModifiedArgument::require("after", params.arguments); - auto argLast = service::ModifiedArgument::require("last", params.arguments); + auto argLast = service::ModifiedArgument::require("last", params.arguments); auto argBefore = service::ModifiedArgument::require("before", params.arguments); std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -94,9 +94,9 @@ service::AwaitableResolver Query::resolveTasks(service::ResolverParams&& params) service::AwaitableResolver Query::resolveUnreadCounts(service::ResolverParams&& params) { - auto argFirst = service::ModifiedArgument::require("first", params.arguments); + auto argFirst = service::ModifiedArgument::require("first", params.arguments); auto argAfter = service::ModifiedArgument::require("after", params.arguments); - auto argLast = service::ModifiedArgument::require("last", params.arguments); + auto argLast = service::ModifiedArgument::require("last", params.arguments); auto argBefore = service::ModifiedArgument::require("before", params.arguments); std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -178,7 +178,7 @@ service::AwaitableResolver Query::resolveUnimplemented(service::ResolverParams&& auto result = _pimpl->getUnimplemented(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } service::AwaitableResolver Query::resolveExpensive(service::ResolverParams&& params) @@ -214,7 +214,7 @@ service::AwaitableResolver Query::resolveAnyType(service::ResolverParams&& param service::AwaitableResolver Query::resolve_typename(service::ResolverParams&& params) { - return service::ModifiedResult::convert(response::StringType{ R"gql(Query)gql" }, std::move(params)); + return service::ModifiedResult::convert(std::string{ R"gql(Query)gql" }, std::move(params)); } service::AwaitableResolver Query::resolve_schema(service::ResolverParams&& params) @@ -224,7 +224,7 @@ service::AwaitableResolver Query::resolve_schema(service::ResolverParams&& param service::AwaitableResolver Query::resolve_type(service::ResolverParams&& params) { - auto argName = service::ModifiedArgument::require("name", params.arguments); + auto argName = service::ModifiedArgument::require("name", params.arguments); const auto& baseType = _schema->LookupType(argName); std::shared_ptr result { baseType ? std::make_shared(std::make_shared(baseType)) : nullptr }; diff --git a/samples/separate/QueryObject.h b/samples/separate/QueryObject.h index 6be9b278..878ad986 100644 --- a/samples/separate/QueryObject.h +++ b/samples/separate/QueryObject.h @@ -26,37 +26,37 @@ concept NoParamsNode = requires (TImpl impl, response::IdType idArg) }; template -concept WithParamsAppointments = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) +concept WithParamsAppointments = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) { { service::FieldResult> { impl.getAppointments(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; }; template -concept NoParamsAppointments = requires (TImpl impl, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) +concept NoParamsAppointments = requires (TImpl impl, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) { { service::FieldResult> { impl.getAppointments(std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; }; template -concept WithParamsTasks = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) +concept WithParamsTasks = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) { { service::FieldResult> { impl.getTasks(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; }; template -concept NoParamsTasks = requires (TImpl impl, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) +concept NoParamsTasks = requires (TImpl impl, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) { { service::FieldResult> { impl.getTasks(std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; }; template -concept WithParamsUnreadCounts = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) +concept WithParamsUnreadCounts = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) { { service::FieldResult> { impl.getUnreadCounts(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; }; template -concept NoParamsUnreadCounts = requires (TImpl impl, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) +concept NoParamsUnreadCounts = requires (TImpl impl, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) { { service::FieldResult> { impl.getUnreadCounts(std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; }; @@ -112,13 +112,13 @@ concept NoParamsNested = requires (TImpl impl) template concept WithParamsUnimplemented = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult { impl.getUnimplemented(std::move(params)) } }; + { service::FieldResult { impl.getUnimplemented(std::move(params)) } }; }; template concept NoParamsUnimplemented = requires (TImpl impl) { - { service::FieldResult { impl.getUnimplemented() } }; + { service::FieldResult { impl.getUnimplemented() } }; }; template @@ -202,14 +202,14 @@ class Query virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; virtual service::FieldResult> getNode(service::FieldParams&& params, response::IdType&& idArg) const = 0; - virtual service::FieldResult> getAppointments(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const = 0; - virtual service::FieldResult> getTasks(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const = 0; - virtual service::FieldResult> getUnreadCounts(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const = 0; + virtual service::FieldResult> getAppointments(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const = 0; + virtual service::FieldResult> getTasks(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const = 0; + virtual service::FieldResult> getUnreadCounts(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const = 0; virtual service::FieldResult>> getAppointmentsById(service::FieldParams&& params, std::vector&& idsArg) const = 0; virtual service::FieldResult>> getTasksById(service::FieldParams&& params, std::vector&& idsArg) const = 0; virtual service::FieldResult>> getUnreadCountsById(service::FieldParams&& params, std::vector&& idsArg) const = 0; virtual service::FieldResult> getNested(service::FieldParams&& params) const = 0; - virtual service::FieldResult getUnimplemented(service::FieldParams&& params) const = 0; + virtual service::FieldResult getUnimplemented(service::FieldParams&& params) const = 0; virtual service::FieldResult>> getExpensive(service::FieldParams&& params) const = 0; virtual service::FieldResult getTestTaskState(service::FieldParams&& params) const = 0; virtual service::FieldResult>> getAnyType(service::FieldParams&& params, std::vector&& idsArg) const = 0; @@ -240,7 +240,7 @@ class Query } } - service::FieldResult> getAppointments(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const final + service::FieldResult> getAppointments(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const final { if constexpr (methods::QueryMethod::WithParamsAppointments) { @@ -256,7 +256,7 @@ class Query } } - service::FieldResult> getTasks(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const final + service::FieldResult> getTasks(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const final { if constexpr (methods::QueryMethod::WithParamsTasks) { @@ -272,7 +272,7 @@ class Query } } - service::FieldResult> getUnreadCounts(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const final + service::FieldResult> getUnreadCounts(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const final { if constexpr (methods::QueryMethod::WithParamsUnreadCounts) { @@ -352,7 +352,7 @@ class Query } } - service::FieldResult getUnimplemented(service::FieldParams&& params) const final + service::FieldResult getUnimplemented(service::FieldParams&& params) const final { if constexpr (methods::QueryMethod::WithParamsUnimplemented) { diff --git a/samples/separate/SubscriptionObject.cpp b/samples/separate/SubscriptionObject.cpp index fa8caecc..d5e4d4cd 100644 --- a/samples/separate/SubscriptionObject.cpp +++ b/samples/separate/SubscriptionObject.cpp @@ -63,7 +63,7 @@ service::AwaitableResolver Subscription::resolveNodeChange(service::ResolverPara service::AwaitableResolver Subscription::resolve_typename(service::ResolverParams&& params) { - return service::ModifiedResult::convert(response::StringType{ R"gql(Subscription)gql" }, std::move(params)); + return service::ModifiedResult::convert(std::string{ R"gql(Subscription)gql" }, std::move(params)); } } // namespace object diff --git a/samples/separate/TaskConnectionObject.cpp b/samples/separate/TaskConnectionObject.cpp index 97f7084a..ac3fc259 100644 --- a/samples/separate/TaskConnectionObject.cpp +++ b/samples/separate/TaskConnectionObject.cpp @@ -62,7 +62,7 @@ service::AwaitableResolver TaskConnection::resolveEdges(service::ResolverParams& service::AwaitableResolver TaskConnection::resolve_typename(service::ResolverParams&& params) { - return service::ModifiedResult::convert(response::StringType{ R"gql(TaskConnection)gql" }, std::move(params)); + return service::ModifiedResult::convert(std::string{ R"gql(TaskConnection)gql" }, std::move(params)); } } // namespace object diff --git a/samples/separate/TaskEdgeObject.cpp b/samples/separate/TaskEdgeObject.cpp index 98103a60..6a96ec40 100644 --- a/samples/separate/TaskEdgeObject.cpp +++ b/samples/separate/TaskEdgeObject.cpp @@ -62,7 +62,7 @@ service::AwaitableResolver TaskEdge::resolveCursor(service::ResolverParams&& par service::AwaitableResolver TaskEdge::resolve_typename(service::ResolverParams&& params) { - return service::ModifiedResult::convert(response::StringType{ R"gql(TaskEdge)gql" }, std::move(params)); + return service::ModifiedResult::convert(std::string{ R"gql(TaskEdge)gql" }, std::move(params)); } } // namespace object diff --git a/samples/separate/TaskObject.cpp b/samples/separate/TaskObject.cpp index 94bd1c58..39272e88 100644 --- a/samples/separate/TaskObject.cpp +++ b/samples/separate/TaskObject.cpp @@ -60,7 +60,7 @@ service::AwaitableResolver Task::resolveTitle(service::ResolverParams&& params) auto result = _pimpl->getTitle(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } service::AwaitableResolver Task::resolveIsComplete(service::ResolverParams&& params) @@ -70,12 +70,12 @@ service::AwaitableResolver Task::resolveIsComplete(service::ResolverParams&& par auto result = _pimpl->getIsComplete(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } service::AwaitableResolver Task::resolve_typename(service::ResolverParams&& params) { - return service::ModifiedResult::convert(response::StringType{ R"gql(Task)gql" }, std::move(params)); + return service::ModifiedResult::convert(std::string{ R"gql(Task)gql" }, std::move(params)); } } // namespace object diff --git a/samples/separate/TaskObject.h b/samples/separate/TaskObject.h index 780d9d63..cbf1457c 100644 --- a/samples/separate/TaskObject.h +++ b/samples/separate/TaskObject.h @@ -28,25 +28,25 @@ concept NoParamsId = requires (TImpl impl) template concept WithParamsTitle = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult> { impl.getTitle(std::move(params)) } }; + { service::FieldResult> { impl.getTitle(std::move(params)) } }; }; template concept NoParamsTitle = requires (TImpl impl) { - { service::FieldResult> { impl.getTitle() } }; + { service::FieldResult> { impl.getTitle() } }; }; template concept WithParamsIsComplete = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult { impl.getIsComplete(std::move(params)) } }; + { service::FieldResult { impl.getIsComplete(std::move(params)) } }; }; template concept NoParamsIsComplete = requires (TImpl impl) { - { service::FieldResult { impl.getIsComplete() } }; + { service::FieldResult { impl.getIsComplete() } }; }; template @@ -81,8 +81,8 @@ class Task virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual service::FieldResult> getTitle(service::FieldParams&& params) const = 0; - virtual service::FieldResult getIsComplete(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getTitle(service::FieldParams&& params) const = 0; + virtual service::FieldResult getIsComplete(service::FieldParams&& params) const = 0; }; template @@ -110,7 +110,7 @@ class Task } } - service::FieldResult> getTitle(service::FieldParams&& params) const final + service::FieldResult> getTitle(service::FieldParams&& params) const final { if constexpr (methods::TaskMethod::WithParamsTitle) { @@ -126,7 +126,7 @@ class Task } } - service::FieldResult getIsComplete(service::FieldParams&& params) const final + service::FieldResult getIsComplete(service::FieldParams&& params) const final { if constexpr (methods::TaskMethod::WithParamsIsComplete) { diff --git a/samples/separate/TodaySchema.cpp b/samples/separate/TodaySchema.cpp index 1492b3f8..7eb8375b 100644 --- a/samples/separate/TodaySchema.cpp +++ b/samples/separate/TodaySchema.cpp @@ -36,7 +36,7 @@ today::TaskState ModifiedArgument::convert(const response::Val throw service::schema_exception { { "not a valid TaskState value" } }; } - const auto itr = std::find(s_namesTaskState.cbegin(), s_namesTaskState.cend(), value.get()); + const auto itr = std::find(s_namesTaskState.cbegin(), s_namesTaskState.cend(), value.get()); if (itr == s_namesTaskState.cend()) { @@ -54,7 +54,7 @@ service::AwaitableResolver ModifiedResult::convert(service::Fi { response::Value result(response::Type::EnumValue); - result.set(response::StringType { s_namesTaskState[static_cast(value)] }); + result.set(std::string { s_namesTaskState[static_cast(value)] }); return result; }); @@ -76,11 +76,11 @@ today::CompleteTaskInput ModifiedArgument::convert(con auto valueId = service::ModifiedArgument::require("id", value); auto valueTestTaskState = service::ModifiedArgument::require("testTaskState", value); - auto pairIsComplete = service::ModifiedArgument::find("isComplete", value); + auto pairIsComplete = service::ModifiedArgument::find("isComplete", value); auto valueIsComplete = (pairIsComplete.second ? std::move(pairIsComplete.first) - : service::ModifiedArgument::require("isComplete", defaultValue)); - auto valueClientMutationId = service::ModifiedArgument::require("clientMutationId", value); + : service::ModifiedArgument::require("isComplete", defaultValue)); + auto valueClientMutationId = service::ModifiedArgument::require("clientMutationId", value); return { std::move(valueId), diff --git a/samples/separate/TodaySchema.h b/samples/separate/TodaySchema.h index 9f979a6e..f7afa110 100644 --- a/samples/separate/TodaySchema.h +++ b/samples/separate/TodaySchema.h @@ -33,8 +33,8 @@ struct CompleteTaskInput { response::IdType id; std::optional testTaskState; - std::optional isComplete; - std::optional clientMutationId; + std::optional isComplete; + std::optional clientMutationId; }; struct ThirdNestedInput diff --git a/samples/separate_nointrospection/AppointmentConnectionObject.cpp b/samples/separate_nointrospection/AppointmentConnectionObject.cpp index 4925c263..4a97fb36 100644 --- a/samples/separate_nointrospection/AppointmentConnectionObject.cpp +++ b/samples/separate_nointrospection/AppointmentConnectionObject.cpp @@ -62,7 +62,7 @@ service::AwaitableResolver AppointmentConnection::resolveEdges(service::Resolver service::AwaitableResolver AppointmentConnection::resolve_typename(service::ResolverParams&& params) { - return service::ModifiedResult::convert(response::StringType{ R"gql(AppointmentConnection)gql" }, std::move(params)); + return service::ModifiedResult::convert(std::string{ R"gql(AppointmentConnection)gql" }, std::move(params)); } } // namespace object diff --git a/samples/separate_nointrospection/AppointmentEdgeObject.cpp b/samples/separate_nointrospection/AppointmentEdgeObject.cpp index eff163fc..05a5d795 100644 --- a/samples/separate_nointrospection/AppointmentEdgeObject.cpp +++ b/samples/separate_nointrospection/AppointmentEdgeObject.cpp @@ -62,7 +62,7 @@ service::AwaitableResolver AppointmentEdge::resolveCursor(service::ResolverParam service::AwaitableResolver AppointmentEdge::resolve_typename(service::ResolverParams&& params) { - return service::ModifiedResult::convert(response::StringType{ R"gql(AppointmentEdge)gql" }, std::move(params)); + return service::ModifiedResult::convert(std::string{ R"gql(AppointmentEdge)gql" }, std::move(params)); } } // namespace object diff --git a/samples/separate_nointrospection/AppointmentObject.cpp b/samples/separate_nointrospection/AppointmentObject.cpp index 228bdcff..338ab608 100644 --- a/samples/separate_nointrospection/AppointmentObject.cpp +++ b/samples/separate_nointrospection/AppointmentObject.cpp @@ -72,7 +72,7 @@ service::AwaitableResolver Appointment::resolveSubject(service::ResolverParams&& auto result = _pimpl->getSubject(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } service::AwaitableResolver Appointment::resolveIsNow(service::ResolverParams&& params) @@ -82,7 +82,7 @@ service::AwaitableResolver Appointment::resolveIsNow(service::ResolverParams&& p auto result = _pimpl->getIsNow(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } service::AwaitableResolver Appointment::resolveForceError(service::ResolverParams&& params) @@ -92,12 +92,12 @@ service::AwaitableResolver Appointment::resolveForceError(service::ResolverParam auto result = _pimpl->getForceError(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } service::AwaitableResolver Appointment::resolve_typename(service::ResolverParams&& params) { - return service::ModifiedResult::convert(response::StringType{ R"gql(Appointment)gql" }, std::move(params)); + return service::ModifiedResult::convert(std::string{ R"gql(Appointment)gql" }, std::move(params)); } } // namespace object diff --git a/samples/separate_nointrospection/AppointmentObject.h b/samples/separate_nointrospection/AppointmentObject.h index 002c99c7..fd49dd1d 100644 --- a/samples/separate_nointrospection/AppointmentObject.h +++ b/samples/separate_nointrospection/AppointmentObject.h @@ -40,37 +40,37 @@ concept NoParamsWhen = requires (TImpl impl) template concept WithParamsSubject = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult> { impl.getSubject(std::move(params)) } }; + { service::FieldResult> { impl.getSubject(std::move(params)) } }; }; template concept NoParamsSubject = requires (TImpl impl) { - { service::FieldResult> { impl.getSubject() } }; + { service::FieldResult> { impl.getSubject() } }; }; template concept WithParamsIsNow = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult { impl.getIsNow(std::move(params)) } }; + { service::FieldResult { impl.getIsNow(std::move(params)) } }; }; template concept NoParamsIsNow = requires (TImpl impl) { - { service::FieldResult { impl.getIsNow() } }; + { service::FieldResult { impl.getIsNow() } }; }; template concept WithParamsForceError = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult> { impl.getForceError(std::move(params)) } }; + { service::FieldResult> { impl.getForceError(std::move(params)) } }; }; template concept NoParamsForceError = requires (TImpl impl) { - { service::FieldResult> { impl.getForceError() } }; + { service::FieldResult> { impl.getForceError() } }; }; template @@ -108,9 +108,9 @@ class Appointment virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; virtual service::FieldResult> getWhen(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getSubject(service::FieldParams&& params) const = 0; - virtual service::FieldResult getIsNow(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getForceError(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getSubject(service::FieldParams&& params) const = 0; + virtual service::FieldResult getIsNow(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getForceError(service::FieldParams&& params) const = 0; }; template @@ -154,7 +154,7 @@ class Appointment } } - service::FieldResult> getSubject(service::FieldParams&& params) const final + service::FieldResult> getSubject(service::FieldParams&& params) const final { if constexpr (methods::AppointmentMethod::WithParamsSubject) { @@ -170,7 +170,7 @@ class Appointment } } - service::FieldResult getIsNow(service::FieldParams&& params) const final + service::FieldResult getIsNow(service::FieldParams&& params) const final { if constexpr (methods::AppointmentMethod::WithParamsIsNow) { @@ -186,7 +186,7 @@ class Appointment } } - service::FieldResult> getForceError(service::FieldParams&& params) const final + service::FieldResult> getForceError(service::FieldParams&& params) const final { if constexpr (methods::AppointmentMethod::WithParamsForceError) { diff --git a/samples/separate_nointrospection/CompleteTaskPayloadObject.cpp b/samples/separate_nointrospection/CompleteTaskPayloadObject.cpp index b6b85919..0c8036f8 100644 --- a/samples/separate_nointrospection/CompleteTaskPayloadObject.cpp +++ b/samples/separate_nointrospection/CompleteTaskPayloadObject.cpp @@ -57,12 +57,12 @@ service::AwaitableResolver CompleteTaskPayload::resolveClientMutationId(service: auto result = _pimpl->getClientMutationId(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } service::AwaitableResolver CompleteTaskPayload::resolve_typename(service::ResolverParams&& params) { - return service::ModifiedResult::convert(response::StringType{ R"gql(CompleteTaskPayload)gql" }, std::move(params)); + return service::ModifiedResult::convert(std::string{ R"gql(CompleteTaskPayload)gql" }, std::move(params)); } } // namespace object diff --git a/samples/separate_nointrospection/CompleteTaskPayloadObject.h b/samples/separate_nointrospection/CompleteTaskPayloadObject.h index 054b0c9a..3411230d 100644 --- a/samples/separate_nointrospection/CompleteTaskPayloadObject.h +++ b/samples/separate_nointrospection/CompleteTaskPayloadObject.h @@ -28,13 +28,13 @@ concept NoParamsTask = requires (TImpl impl) template concept WithParamsClientMutationId = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult> { impl.getClientMutationId(std::move(params)) } }; + { service::FieldResult> { impl.getClientMutationId(std::move(params)) } }; }; template concept NoParamsClientMutationId = requires (TImpl impl) { - { service::FieldResult> { impl.getClientMutationId() } }; + { service::FieldResult> { impl.getClientMutationId() } }; }; template @@ -68,7 +68,7 @@ class CompleteTaskPayload virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; virtual service::FieldResult> getTask(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getClientMutationId(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getClientMutationId(service::FieldParams&& params) const = 0; }; template @@ -96,7 +96,7 @@ class CompleteTaskPayload } } - service::FieldResult> getClientMutationId(service::FieldParams&& params) const final + service::FieldResult> getClientMutationId(service::FieldParams&& params) const final { if constexpr (methods::CompleteTaskPayloadMethod::WithParamsClientMutationId) { diff --git a/samples/separate_nointrospection/ExpensiveObject.cpp b/samples/separate_nointrospection/ExpensiveObject.cpp index 16528213..4e036d1f 100644 --- a/samples/separate_nointrospection/ExpensiveObject.cpp +++ b/samples/separate_nointrospection/ExpensiveObject.cpp @@ -46,12 +46,12 @@ service::AwaitableResolver Expensive::resolveOrder(service::ResolverParams&& par auto result = _pimpl->getOrder(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } service::AwaitableResolver Expensive::resolve_typename(service::ResolverParams&& params) { - return service::ModifiedResult::convert(response::StringType{ R"gql(Expensive)gql" }, std::move(params)); + return service::ModifiedResult::convert(std::string{ R"gql(Expensive)gql" }, std::move(params)); } } // namespace object diff --git a/samples/separate_nointrospection/ExpensiveObject.h b/samples/separate_nointrospection/ExpensiveObject.h index d34236b8..7fd5d538 100644 --- a/samples/separate_nointrospection/ExpensiveObject.h +++ b/samples/separate_nointrospection/ExpensiveObject.h @@ -16,13 +16,13 @@ namespace methods::ExpensiveMethod { template concept WithParamsOrder = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult { impl.getOrder(std::move(params)) } }; + { service::FieldResult { impl.getOrder(std::move(params)) } }; }; template concept NoParamsOrder = requires (TImpl impl) { - { service::FieldResult { impl.getOrder() } }; + { service::FieldResult { impl.getOrder() } }; }; template @@ -54,7 +54,7 @@ class Expensive virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual service::FieldResult getOrder(service::FieldParams&& params) const = 0; + virtual service::FieldResult getOrder(service::FieldParams&& params) const = 0; }; template @@ -66,7 +66,7 @@ class Expensive { } - service::FieldResult getOrder(service::FieldParams&& params) const final + service::FieldResult getOrder(service::FieldParams&& params) const final { if constexpr (methods::ExpensiveMethod::WithParamsOrder) { diff --git a/samples/separate_nointrospection/FolderConnectionObject.cpp b/samples/separate_nointrospection/FolderConnectionObject.cpp index a9ac2ff5..b47dd28d 100644 --- a/samples/separate_nointrospection/FolderConnectionObject.cpp +++ b/samples/separate_nointrospection/FolderConnectionObject.cpp @@ -62,7 +62,7 @@ service::AwaitableResolver FolderConnection::resolveEdges(service::ResolverParam service::AwaitableResolver FolderConnection::resolve_typename(service::ResolverParams&& params) { - return service::ModifiedResult::convert(response::StringType{ R"gql(FolderConnection)gql" }, std::move(params)); + return service::ModifiedResult::convert(std::string{ R"gql(FolderConnection)gql" }, std::move(params)); } } // namespace object diff --git a/samples/separate_nointrospection/FolderEdgeObject.cpp b/samples/separate_nointrospection/FolderEdgeObject.cpp index bd741d44..95ed2c21 100644 --- a/samples/separate_nointrospection/FolderEdgeObject.cpp +++ b/samples/separate_nointrospection/FolderEdgeObject.cpp @@ -62,7 +62,7 @@ service::AwaitableResolver FolderEdge::resolveCursor(service::ResolverParams&& p service::AwaitableResolver FolderEdge::resolve_typename(service::ResolverParams&& params) { - return service::ModifiedResult::convert(response::StringType{ R"gql(FolderEdge)gql" }, std::move(params)); + return service::ModifiedResult::convert(std::string{ R"gql(FolderEdge)gql" }, std::move(params)); } } // namespace object diff --git a/samples/separate_nointrospection/FolderObject.cpp b/samples/separate_nointrospection/FolderObject.cpp index c425c3ff..dfe25974 100644 --- a/samples/separate_nointrospection/FolderObject.cpp +++ b/samples/separate_nointrospection/FolderObject.cpp @@ -60,7 +60,7 @@ service::AwaitableResolver Folder::resolveName(service::ResolverParams&& params) auto result = _pimpl->getName(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } service::AwaitableResolver Folder::resolveUnreadCount(service::ResolverParams&& params) @@ -70,12 +70,12 @@ service::AwaitableResolver Folder::resolveUnreadCount(service::ResolverParams&& auto result = _pimpl->getUnreadCount(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } service::AwaitableResolver Folder::resolve_typename(service::ResolverParams&& params) { - return service::ModifiedResult::convert(response::StringType{ R"gql(Folder)gql" }, std::move(params)); + return service::ModifiedResult::convert(std::string{ R"gql(Folder)gql" }, std::move(params)); } } // namespace object diff --git a/samples/separate_nointrospection/FolderObject.h b/samples/separate_nointrospection/FolderObject.h index e96ba675..940f1190 100644 --- a/samples/separate_nointrospection/FolderObject.h +++ b/samples/separate_nointrospection/FolderObject.h @@ -28,25 +28,25 @@ concept NoParamsId = requires (TImpl impl) template concept WithParamsName = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult> { impl.getName(std::move(params)) } }; + { service::FieldResult> { impl.getName(std::move(params)) } }; }; template concept NoParamsName = requires (TImpl impl) { - { service::FieldResult> { impl.getName() } }; + { service::FieldResult> { impl.getName() } }; }; template concept WithParamsUnreadCount = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult { impl.getUnreadCount(std::move(params)) } }; + { service::FieldResult { impl.getUnreadCount(std::move(params)) } }; }; template concept NoParamsUnreadCount = requires (TImpl impl) { - { service::FieldResult { impl.getUnreadCount() } }; + { service::FieldResult { impl.getUnreadCount() } }; }; template @@ -81,8 +81,8 @@ class Folder virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual service::FieldResult> getName(service::FieldParams&& params) const = 0; - virtual service::FieldResult getUnreadCount(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getName(service::FieldParams&& params) const = 0; + virtual service::FieldResult getUnreadCount(service::FieldParams&& params) const = 0; }; template @@ -110,7 +110,7 @@ class Folder } } - service::FieldResult> getName(service::FieldParams&& params) const final + service::FieldResult> getName(service::FieldParams&& params) const final { if constexpr (methods::FolderMethod::WithParamsName) { @@ -126,7 +126,7 @@ class Folder } } - service::FieldResult getUnreadCount(service::FieldParams&& params) const final + service::FieldResult getUnreadCount(service::FieldParams&& params) const final { if constexpr (methods::FolderMethod::WithParamsUnreadCount) { diff --git a/samples/separate_nointrospection/MutationObject.cpp b/samples/separate_nointrospection/MutationObject.cpp index 6f41f9a0..5d80c817 100644 --- a/samples/separate_nointrospection/MutationObject.cpp +++ b/samples/separate_nointrospection/MutationObject.cpp @@ -53,18 +53,18 @@ service::AwaitableResolver Mutation::resolveCompleteTask(service::ResolverParams service::AwaitableResolver Mutation::resolveSetFloat(service::ResolverParams&& params) { - auto argValue = service::ModifiedArgument::require("value", params.arguments); + auto argValue = service::ModifiedArgument::require("value", params.arguments); std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); auto result = _pimpl->applySetFloat(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argValue)); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } service::AwaitableResolver Mutation::resolve_typename(service::ResolverParams&& params) { - return service::ModifiedResult::convert(response::StringType{ R"gql(Mutation)gql" }, std::move(params)); + return service::ModifiedResult::convert(std::string{ R"gql(Mutation)gql" }, std::move(params)); } } // namespace object diff --git a/samples/separate_nointrospection/MutationObject.h b/samples/separate_nointrospection/MutationObject.h index be61f359..c78f0ac3 100644 --- a/samples/separate_nointrospection/MutationObject.h +++ b/samples/separate_nointrospection/MutationObject.h @@ -26,15 +26,15 @@ concept NoParamsCompleteTask = requires (TImpl impl, CompleteTaskInput inputArg) }; template -concept WithParamsSetFloat = requires (TImpl impl, service::FieldParams params, response::FloatType valueArg) +concept WithParamsSetFloat = requires (TImpl impl, service::FieldParams params, double valueArg) { - { service::FieldResult { impl.applySetFloat(std::move(params), std::move(valueArg)) } }; + { service::FieldResult { impl.applySetFloat(std::move(params), std::move(valueArg)) } }; }; template -concept NoParamsSetFloat = requires (TImpl impl, response::FloatType valueArg) +concept NoParamsSetFloat = requires (TImpl impl, double valueArg) { - { service::FieldResult { impl.applySetFloat(std::move(valueArg)) } }; + { service::FieldResult { impl.applySetFloat(std::move(valueArg)) } }; }; template @@ -68,7 +68,7 @@ class Mutation virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; virtual service::FieldResult> applyCompleteTask(service::FieldParams&& params, CompleteTaskInput&& inputArg) const = 0; - virtual service::FieldResult applySetFloat(service::FieldParams&& params, response::FloatType&& valueArg) const = 0; + virtual service::FieldResult applySetFloat(service::FieldParams&& params, double&& valueArg) const = 0; }; template @@ -96,7 +96,7 @@ class Mutation } } - service::FieldResult applySetFloat(service::FieldParams&& params, response::FloatType&& valueArg) const final + service::FieldResult applySetFloat(service::FieldParams&& params, double&& valueArg) const final { if constexpr (methods::MutationMethod::WithParamsSetFloat) { diff --git a/samples/separate_nointrospection/NestedTypeObject.cpp b/samples/separate_nointrospection/NestedTypeObject.cpp index 76b9bf57..acb8adb4 100644 --- a/samples/separate_nointrospection/NestedTypeObject.cpp +++ b/samples/separate_nointrospection/NestedTypeObject.cpp @@ -47,7 +47,7 @@ service::AwaitableResolver NestedType::resolveDepth(service::ResolverParams&& pa auto result = _pimpl->getDepth(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } service::AwaitableResolver NestedType::resolveNested(service::ResolverParams&& params) @@ -62,7 +62,7 @@ service::AwaitableResolver NestedType::resolveNested(service::ResolverParams&& p service::AwaitableResolver NestedType::resolve_typename(service::ResolverParams&& params) { - return service::ModifiedResult::convert(response::StringType{ R"gql(NestedType)gql" }, std::move(params)); + return service::ModifiedResult::convert(std::string{ R"gql(NestedType)gql" }, std::move(params)); } } // namespace object diff --git a/samples/separate_nointrospection/NestedTypeObject.h b/samples/separate_nointrospection/NestedTypeObject.h index d4f2551f..3ef0292a 100644 --- a/samples/separate_nointrospection/NestedTypeObject.h +++ b/samples/separate_nointrospection/NestedTypeObject.h @@ -16,13 +16,13 @@ namespace methods::NestedTypeMethod { template concept WithParamsDepth = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult { impl.getDepth(std::move(params)) } }; + { service::FieldResult { impl.getDepth(std::move(params)) } }; }; template concept NoParamsDepth = requires (TImpl impl) { - { service::FieldResult { impl.getDepth() } }; + { service::FieldResult { impl.getDepth() } }; }; template @@ -67,7 +67,7 @@ class NestedType virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual service::FieldResult getDepth(service::FieldParams&& params) const = 0; + virtual service::FieldResult getDepth(service::FieldParams&& params) const = 0; virtual service::FieldResult> getNested(service::FieldParams&& params) const = 0; }; @@ -80,7 +80,7 @@ class NestedType { } - service::FieldResult getDepth(service::FieldParams&& params) const final + service::FieldResult getDepth(service::FieldParams&& params) const final { if constexpr (methods::NestedTypeMethod::WithParamsDepth) { diff --git a/samples/separate_nointrospection/PageInfoObject.cpp b/samples/separate_nointrospection/PageInfoObject.cpp index e0cc198f..e9677c85 100644 --- a/samples/separate_nointrospection/PageInfoObject.cpp +++ b/samples/separate_nointrospection/PageInfoObject.cpp @@ -47,7 +47,7 @@ service::AwaitableResolver PageInfo::resolveHasNextPage(service::ResolverParams& auto result = _pimpl->getHasNextPage(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } service::AwaitableResolver PageInfo::resolveHasPreviousPage(service::ResolverParams&& params) @@ -57,12 +57,12 @@ service::AwaitableResolver PageInfo::resolveHasPreviousPage(service::ResolverPar auto result = _pimpl->getHasPreviousPage(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } service::AwaitableResolver PageInfo::resolve_typename(service::ResolverParams&& params) { - return service::ModifiedResult::convert(response::StringType{ R"gql(PageInfo)gql" }, std::move(params)); + return service::ModifiedResult::convert(std::string{ R"gql(PageInfo)gql" }, std::move(params)); } } // namespace object diff --git a/samples/separate_nointrospection/PageInfoObject.h b/samples/separate_nointrospection/PageInfoObject.h index cf4a8158..ca851ed1 100644 --- a/samples/separate_nointrospection/PageInfoObject.h +++ b/samples/separate_nointrospection/PageInfoObject.h @@ -16,25 +16,25 @@ namespace methods::PageInfoMethod { template concept WithParamsHasNextPage = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult { impl.getHasNextPage(std::move(params)) } }; + { service::FieldResult { impl.getHasNextPage(std::move(params)) } }; }; template concept NoParamsHasNextPage = requires (TImpl impl) { - { service::FieldResult { impl.getHasNextPage() } }; + { service::FieldResult { impl.getHasNextPage() } }; }; template concept WithParamsHasPreviousPage = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult { impl.getHasPreviousPage(std::move(params)) } }; + { service::FieldResult { impl.getHasPreviousPage(std::move(params)) } }; }; template concept NoParamsHasPreviousPage = requires (TImpl impl) { - { service::FieldResult { impl.getHasPreviousPage() } }; + { service::FieldResult { impl.getHasPreviousPage() } }; }; template @@ -67,8 +67,8 @@ class PageInfo virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual service::FieldResult getHasNextPage(service::FieldParams&& params) const = 0; - virtual service::FieldResult getHasPreviousPage(service::FieldParams&& params) const = 0; + virtual service::FieldResult getHasNextPage(service::FieldParams&& params) const = 0; + virtual service::FieldResult getHasPreviousPage(service::FieldParams&& params) const = 0; }; template @@ -80,7 +80,7 @@ class PageInfo { } - service::FieldResult getHasNextPage(service::FieldParams&& params) const final + service::FieldResult getHasNextPage(service::FieldParams&& params) const final { if constexpr (methods::PageInfoMethod::WithParamsHasNextPage) { @@ -96,7 +96,7 @@ class PageInfo } } - service::FieldResult getHasPreviousPage(service::FieldParams&& params) const final + service::FieldResult getHasPreviousPage(service::FieldParams&& params) const final { if constexpr (methods::PageInfoMethod::WithParamsHasPreviousPage) { diff --git a/samples/separate_nointrospection/QueryObject.cpp b/samples/separate_nointrospection/QueryObject.cpp index 76ac8a85..a7c2a563 100644 --- a/samples/separate_nointrospection/QueryObject.cpp +++ b/samples/separate_nointrospection/QueryObject.cpp @@ -63,9 +63,9 @@ service::AwaitableResolver Query::resolveNode(service::ResolverParams&& params) service::AwaitableResolver Query::resolveAppointments(service::ResolverParams&& params) { - auto argFirst = service::ModifiedArgument::require("first", params.arguments); + auto argFirst = service::ModifiedArgument::require("first", params.arguments); auto argAfter = service::ModifiedArgument::require("after", params.arguments); - auto argLast = service::ModifiedArgument::require("last", params.arguments); + auto argLast = service::ModifiedArgument::require("last", params.arguments); auto argBefore = service::ModifiedArgument::require("before", params.arguments); std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -77,9 +77,9 @@ service::AwaitableResolver Query::resolveAppointments(service::ResolverParams&& service::AwaitableResolver Query::resolveTasks(service::ResolverParams&& params) { - auto argFirst = service::ModifiedArgument::require("first", params.arguments); + auto argFirst = service::ModifiedArgument::require("first", params.arguments); auto argAfter = service::ModifiedArgument::require("after", params.arguments); - auto argLast = service::ModifiedArgument::require("last", params.arguments); + auto argLast = service::ModifiedArgument::require("last", params.arguments); auto argBefore = service::ModifiedArgument::require("before", params.arguments); std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -91,9 +91,9 @@ service::AwaitableResolver Query::resolveTasks(service::ResolverParams&& params) service::AwaitableResolver Query::resolveUnreadCounts(service::ResolverParams&& params) { - auto argFirst = service::ModifiedArgument::require("first", params.arguments); + auto argFirst = service::ModifiedArgument::require("first", params.arguments); auto argAfter = service::ModifiedArgument::require("after", params.arguments); - auto argLast = service::ModifiedArgument::require("last", params.arguments); + auto argLast = service::ModifiedArgument::require("last", params.arguments); auto argBefore = service::ModifiedArgument::require("before", params.arguments); std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -175,7 +175,7 @@ service::AwaitableResolver Query::resolveUnimplemented(service::ResolverParams&& auto result = _pimpl->getUnimplemented(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } service::AwaitableResolver Query::resolveExpensive(service::ResolverParams&& params) @@ -211,7 +211,7 @@ service::AwaitableResolver Query::resolveAnyType(service::ResolverParams&& param service::AwaitableResolver Query::resolve_typename(service::ResolverParams&& params) { - return service::ModifiedResult::convert(response::StringType{ R"gql(Query)gql" }, std::move(params)); + return service::ModifiedResult::convert(std::string{ R"gql(Query)gql" }, std::move(params)); } } // namespace object diff --git a/samples/separate_nointrospection/QueryObject.h b/samples/separate_nointrospection/QueryObject.h index b1a867fa..8f75ddbb 100644 --- a/samples/separate_nointrospection/QueryObject.h +++ b/samples/separate_nointrospection/QueryObject.h @@ -26,37 +26,37 @@ concept NoParamsNode = requires (TImpl impl, response::IdType idArg) }; template -concept WithParamsAppointments = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) +concept WithParamsAppointments = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) { { service::FieldResult> { impl.getAppointments(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; }; template -concept NoParamsAppointments = requires (TImpl impl, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) +concept NoParamsAppointments = requires (TImpl impl, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) { { service::FieldResult> { impl.getAppointments(std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; }; template -concept WithParamsTasks = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) +concept WithParamsTasks = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) { { service::FieldResult> { impl.getTasks(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; }; template -concept NoParamsTasks = requires (TImpl impl, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) +concept NoParamsTasks = requires (TImpl impl, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) { { service::FieldResult> { impl.getTasks(std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; }; template -concept WithParamsUnreadCounts = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) +concept WithParamsUnreadCounts = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) { { service::FieldResult> { impl.getUnreadCounts(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; }; template -concept NoParamsUnreadCounts = requires (TImpl impl, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) +concept NoParamsUnreadCounts = requires (TImpl impl, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) { { service::FieldResult> { impl.getUnreadCounts(std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; }; @@ -112,13 +112,13 @@ concept NoParamsNested = requires (TImpl impl) template concept WithParamsUnimplemented = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult { impl.getUnimplemented(std::move(params)) } }; + { service::FieldResult { impl.getUnimplemented(std::move(params)) } }; }; template concept NoParamsUnimplemented = requires (TImpl impl) { - { service::FieldResult { impl.getUnimplemented() } }; + { service::FieldResult { impl.getUnimplemented() } }; }; template @@ -198,14 +198,14 @@ class Query virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; virtual service::FieldResult> getNode(service::FieldParams&& params, response::IdType&& idArg) const = 0; - virtual service::FieldResult> getAppointments(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const = 0; - virtual service::FieldResult> getTasks(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const = 0; - virtual service::FieldResult> getUnreadCounts(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const = 0; + virtual service::FieldResult> getAppointments(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const = 0; + virtual service::FieldResult> getTasks(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const = 0; + virtual service::FieldResult> getUnreadCounts(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const = 0; virtual service::FieldResult>> getAppointmentsById(service::FieldParams&& params, std::vector&& idsArg) const = 0; virtual service::FieldResult>> getTasksById(service::FieldParams&& params, std::vector&& idsArg) const = 0; virtual service::FieldResult>> getUnreadCountsById(service::FieldParams&& params, std::vector&& idsArg) const = 0; virtual service::FieldResult> getNested(service::FieldParams&& params) const = 0; - virtual service::FieldResult getUnimplemented(service::FieldParams&& params) const = 0; + virtual service::FieldResult getUnimplemented(service::FieldParams&& params) const = 0; virtual service::FieldResult>> getExpensive(service::FieldParams&& params) const = 0; virtual service::FieldResult getTestTaskState(service::FieldParams&& params) const = 0; virtual service::FieldResult>> getAnyType(service::FieldParams&& params, std::vector&& idsArg) const = 0; @@ -236,7 +236,7 @@ class Query } } - service::FieldResult> getAppointments(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const final + service::FieldResult> getAppointments(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const final { if constexpr (methods::QueryMethod::WithParamsAppointments) { @@ -252,7 +252,7 @@ class Query } } - service::FieldResult> getTasks(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const final + service::FieldResult> getTasks(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const final { if constexpr (methods::QueryMethod::WithParamsTasks) { @@ -268,7 +268,7 @@ class Query } } - service::FieldResult> getUnreadCounts(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const final + service::FieldResult> getUnreadCounts(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const final { if constexpr (methods::QueryMethod::WithParamsUnreadCounts) { @@ -348,7 +348,7 @@ class Query } } - service::FieldResult getUnimplemented(service::FieldParams&& params) const final + service::FieldResult getUnimplemented(service::FieldParams&& params) const final { if constexpr (methods::QueryMethod::WithParamsUnimplemented) { diff --git a/samples/separate_nointrospection/SubscriptionObject.cpp b/samples/separate_nointrospection/SubscriptionObject.cpp index fa8caecc..d5e4d4cd 100644 --- a/samples/separate_nointrospection/SubscriptionObject.cpp +++ b/samples/separate_nointrospection/SubscriptionObject.cpp @@ -63,7 +63,7 @@ service::AwaitableResolver Subscription::resolveNodeChange(service::ResolverPara service::AwaitableResolver Subscription::resolve_typename(service::ResolverParams&& params) { - return service::ModifiedResult::convert(response::StringType{ R"gql(Subscription)gql" }, std::move(params)); + return service::ModifiedResult::convert(std::string{ R"gql(Subscription)gql" }, std::move(params)); } } // namespace object diff --git a/samples/separate_nointrospection/TaskConnectionObject.cpp b/samples/separate_nointrospection/TaskConnectionObject.cpp index 97f7084a..ac3fc259 100644 --- a/samples/separate_nointrospection/TaskConnectionObject.cpp +++ b/samples/separate_nointrospection/TaskConnectionObject.cpp @@ -62,7 +62,7 @@ service::AwaitableResolver TaskConnection::resolveEdges(service::ResolverParams& service::AwaitableResolver TaskConnection::resolve_typename(service::ResolverParams&& params) { - return service::ModifiedResult::convert(response::StringType{ R"gql(TaskConnection)gql" }, std::move(params)); + return service::ModifiedResult::convert(std::string{ R"gql(TaskConnection)gql" }, std::move(params)); } } // namespace object diff --git a/samples/separate_nointrospection/TaskEdgeObject.cpp b/samples/separate_nointrospection/TaskEdgeObject.cpp index 98103a60..6a96ec40 100644 --- a/samples/separate_nointrospection/TaskEdgeObject.cpp +++ b/samples/separate_nointrospection/TaskEdgeObject.cpp @@ -62,7 +62,7 @@ service::AwaitableResolver TaskEdge::resolveCursor(service::ResolverParams&& par service::AwaitableResolver TaskEdge::resolve_typename(service::ResolverParams&& params) { - return service::ModifiedResult::convert(response::StringType{ R"gql(TaskEdge)gql" }, std::move(params)); + return service::ModifiedResult::convert(std::string{ R"gql(TaskEdge)gql" }, std::move(params)); } } // namespace object diff --git a/samples/separate_nointrospection/TaskObject.cpp b/samples/separate_nointrospection/TaskObject.cpp index 94bd1c58..39272e88 100644 --- a/samples/separate_nointrospection/TaskObject.cpp +++ b/samples/separate_nointrospection/TaskObject.cpp @@ -60,7 +60,7 @@ service::AwaitableResolver Task::resolveTitle(service::ResolverParams&& params) auto result = _pimpl->getTitle(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } service::AwaitableResolver Task::resolveIsComplete(service::ResolverParams&& params) @@ -70,12 +70,12 @@ service::AwaitableResolver Task::resolveIsComplete(service::ResolverParams&& par auto result = _pimpl->getIsComplete(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } service::AwaitableResolver Task::resolve_typename(service::ResolverParams&& params) { - return service::ModifiedResult::convert(response::StringType{ R"gql(Task)gql" }, std::move(params)); + return service::ModifiedResult::convert(std::string{ R"gql(Task)gql" }, std::move(params)); } } // namespace object diff --git a/samples/separate_nointrospection/TaskObject.h b/samples/separate_nointrospection/TaskObject.h index 780d9d63..cbf1457c 100644 --- a/samples/separate_nointrospection/TaskObject.h +++ b/samples/separate_nointrospection/TaskObject.h @@ -28,25 +28,25 @@ concept NoParamsId = requires (TImpl impl) template concept WithParamsTitle = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult> { impl.getTitle(std::move(params)) } }; + { service::FieldResult> { impl.getTitle(std::move(params)) } }; }; template concept NoParamsTitle = requires (TImpl impl) { - { service::FieldResult> { impl.getTitle() } }; + { service::FieldResult> { impl.getTitle() } }; }; template concept WithParamsIsComplete = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult { impl.getIsComplete(std::move(params)) } }; + { service::FieldResult { impl.getIsComplete(std::move(params)) } }; }; template concept NoParamsIsComplete = requires (TImpl impl) { - { service::FieldResult { impl.getIsComplete() } }; + { service::FieldResult { impl.getIsComplete() } }; }; template @@ -81,8 +81,8 @@ class Task virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual service::FieldResult> getTitle(service::FieldParams&& params) const = 0; - virtual service::FieldResult getIsComplete(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getTitle(service::FieldParams&& params) const = 0; + virtual service::FieldResult getIsComplete(service::FieldParams&& params) const = 0; }; template @@ -110,7 +110,7 @@ class Task } } - service::FieldResult> getTitle(service::FieldParams&& params) const final + service::FieldResult> getTitle(service::FieldParams&& params) const final { if constexpr (methods::TaskMethod::WithParamsTitle) { @@ -126,7 +126,7 @@ class Task } } - service::FieldResult getIsComplete(service::FieldParams&& params) const final + service::FieldResult getIsComplete(service::FieldParams&& params) const final { if constexpr (methods::TaskMethod::WithParamsIsComplete) { diff --git a/samples/separate_nointrospection/TodaySchema.cpp b/samples/separate_nointrospection/TodaySchema.cpp index 46d4fab0..a3ba328b 100644 --- a/samples/separate_nointrospection/TodaySchema.cpp +++ b/samples/separate_nointrospection/TodaySchema.cpp @@ -36,7 +36,7 @@ today::TaskState ModifiedArgument::convert(const response::Val throw service::schema_exception { { "not a valid TaskState value" } }; } - const auto itr = std::find(s_namesTaskState.cbegin(), s_namesTaskState.cend(), value.get()); + const auto itr = std::find(s_namesTaskState.cbegin(), s_namesTaskState.cend(), value.get()); if (itr == s_namesTaskState.cend()) { @@ -54,7 +54,7 @@ service::AwaitableResolver ModifiedResult::convert(service::Fi { response::Value result(response::Type::EnumValue); - result.set(response::StringType { s_namesTaskState[static_cast(value)] }); + result.set(std::string { s_namesTaskState[static_cast(value)] }); return result; }); @@ -76,11 +76,11 @@ today::CompleteTaskInput ModifiedArgument::convert(con auto valueId = service::ModifiedArgument::require("id", value); auto valueTestTaskState = service::ModifiedArgument::require("testTaskState", value); - auto pairIsComplete = service::ModifiedArgument::find("isComplete", value); + auto pairIsComplete = service::ModifiedArgument::find("isComplete", value); auto valueIsComplete = (pairIsComplete.second ? std::move(pairIsComplete.first) - : service::ModifiedArgument::require("isComplete", defaultValue)); - auto valueClientMutationId = service::ModifiedArgument::require("clientMutationId", value); + : service::ModifiedArgument::require("isComplete", defaultValue)); + auto valueClientMutationId = service::ModifiedArgument::require("clientMutationId", value); return { std::move(valueId), diff --git a/samples/separate_nointrospection/TodaySchema.h b/samples/separate_nointrospection/TodaySchema.h index 9f979a6e..f7afa110 100644 --- a/samples/separate_nointrospection/TodaySchema.h +++ b/samples/separate_nointrospection/TodaySchema.h @@ -33,8 +33,8 @@ struct CompleteTaskInput { response::IdType id; std::optional testTaskState; - std::optional isComplete; - std::optional clientMutationId; + std::optional isComplete; + std::optional clientMutationId; }; struct ThirdNestedInput diff --git a/samples/star_wars/DroidData.cpp b/samples/star_wars/DroidData.cpp index ea47c43a..7a115420 100644 --- a/samples/star_wars/DroidData.cpp +++ b/samples/star_wars/DroidData.cpp @@ -7,9 +7,8 @@ namespace graphql::learn { -Droid::Droid(response::StringType&& id, std::optional&& name, - std::vector&& appearsIn, - std::optional&& primaryFunction) noexcept +Droid::Droid(std::string&& id, std::optional&& name, std::vector&& appearsIn, + std::optional&& primaryFunction) noexcept : id_ { std::move(id) } , name_ { std::move(name) } , appearsIn_ { std::move(appearsIn) } @@ -36,12 +35,12 @@ void Droid::addFriends( }); } -const response::StringType& Droid::getId() const noexcept +const std::string& Droid::getId() const noexcept { return id_; } -const std::optional& Droid::getName() const noexcept +const std::optional& Droid::getName() const noexcept { return name_; } @@ -95,7 +94,7 @@ std::optional>> Droid::getAppearsIn() const n return result.empty() ? std::nullopt : std::make_optional(std::move(result)); } -const std::optional& Droid::getPrimaryFunction() const noexcept +const std::optional& Droid::getPrimaryFunction() const noexcept { return primaryFunction_; } diff --git a/samples/star_wars/DroidData.h b/samples/star_wars/DroidData.h index 346ee067..0cc4df11 100644 --- a/samples/star_wars/DroidData.h +++ b/samples/star_wars/DroidData.h @@ -17,23 +17,22 @@ class Human; class Droid { public: - explicit Droid(response::StringType&& id, std::optional&& name, - std::vector&& appearsIn, - std::optional&& primaryFunction) noexcept; + explicit Droid(std::string&& id, std::optional&& name, + std::vector&& appearsIn, std::optional&& primaryFunction) noexcept; void addFriends(std::vector friends) noexcept; - const response::StringType& getId() const noexcept; - const std::optional& getName() const noexcept; + const std::string& getId() const noexcept; + const std::optional& getName() const noexcept; std::optional>> getFriends() const noexcept; std::optional>> getAppearsIn() const noexcept; - const std::optional& getPrimaryFunction() const noexcept; + const std::optional& getPrimaryFunction() const noexcept; private: - const response::StringType id_; - const std::optional name_; + const std::string id_; + const std::optional name_; const std::vector appearsIn_; - const std::optional primaryFunction_; + const std::optional primaryFunction_; std::vector friends_; }; diff --git a/samples/star_wars/HumanData.cpp b/samples/star_wars/HumanData.cpp index 5ce519d2..c8623937 100644 --- a/samples/star_wars/HumanData.cpp +++ b/samples/star_wars/HumanData.cpp @@ -7,8 +7,8 @@ namespace graphql::learn { -Human::Human(response::StringType&& id, std::optional&& name, - std::vector&& appearsIn, std::optional&& homePlanet) noexcept +Human::Human(std::string&& id, std::optional&& name, std::vector&& appearsIn, + std::optional&& homePlanet) noexcept : id_ { std::move(id) } , name_ { std::move(name) } , appearsIn_ { std::move(appearsIn) } @@ -34,12 +34,12 @@ void Human::addFriends(std::vector friends) noexcept }); } -const response::StringType& Human::getId() const noexcept +const std::string& Human::getId() const noexcept { return id_; } -const std::optional& Human::getName() const noexcept +const std::optional& Human::getName() const noexcept { return name_; } @@ -93,7 +93,7 @@ std::optional>> Human::getAppearsIn() const n return result.empty() ? std::nullopt : std::make_optional(std::move(result)); } -const std::optional& Human::getHomePlanet() const noexcept +const std::optional& Human::getHomePlanet() const noexcept { return homePlanet_; } diff --git a/samples/star_wars/HumanData.h b/samples/star_wars/HumanData.h index 1c46d8eb..53f9b7c6 100644 --- a/samples/star_wars/HumanData.h +++ b/samples/star_wars/HumanData.h @@ -15,23 +15,22 @@ namespace graphql::learn { class Human { public: - explicit Human(response::StringType&& id, std::optional&& name, - std::vector&& appearsIn, - std::optional&& homePlanet) noexcept; + explicit Human(std::string&& id, std::optional&& name, + std::vector&& appearsIn, std::optional&& homePlanet) noexcept; void addFriends(std::vector friends) noexcept; - const response::StringType& getId() const noexcept; - const std::optional& getName() const noexcept; + const std::string& getId() const noexcept; + const std::optional& getName() const noexcept; std::optional>> getFriends() const noexcept; std::optional>> getAppearsIn() const noexcept; - const std::optional& getHomePlanet() const noexcept; + const std::optional& getHomePlanet() const noexcept; private: - const response::StringType id_; - const std::optional name_; + const std::string id_; + const std::optional name_; const std::vector appearsIn_; - const std::optional homePlanet_; + const std::optional homePlanet_; std::vector friends_; }; diff --git a/samples/star_wars/QueryData.cpp b/samples/star_wars/QueryData.cpp index 799fca5a..8d9f9747 100644 --- a/samples/star_wars/QueryData.cpp +++ b/samples/star_wars/QueryData.cpp @@ -6,8 +6,8 @@ namespace graphql::learn { Query::Query(std::map&& heroes, - std::map>&& humans, - std::map>&& droids) noexcept + std::map>&& humans, + std::map>&& droids) noexcept : heroes_ { std::move(heroes) } , humans_ { std::move(humans) } , droids_ { std::move(droids) } @@ -42,7 +42,7 @@ std::shared_ptr Query::getHero(std::optional episodeAr return result; } -std::shared_ptr Query::getHuman(const response::StringType& idArg) const noexcept +std::shared_ptr Query::getHuman(const std::string& idArg) const noexcept { std::shared_ptr result; @@ -54,7 +54,7 @@ std::shared_ptr Query::getHuman(const response::StringType& idArg return std::make_shared(std::move(result)); } -std::shared_ptr Query::getDroid(const response::StringType& idArg) const noexcept +std::shared_ptr Query::getDroid(const std::string& idArg) const noexcept { std::shared_ptr result; diff --git a/samples/star_wars/QueryData.h b/samples/star_wars/QueryData.h index bcc96989..9efb7c31 100644 --- a/samples/star_wars/QueryData.h +++ b/samples/star_wars/QueryData.h @@ -17,17 +17,17 @@ class Query { public: explicit Query(std::map&& heroes, - std::map>&& humans, - std::map>&& droids) noexcept; + std::map>&& humans, + std::map>&& droids) noexcept; std::shared_ptr getHero(std::optional episodeArg) const noexcept; - std::shared_ptr getHuman(const response::StringType& idArg) const noexcept; - std::shared_ptr getDroid(const response::StringType& idArg) const noexcept; + std::shared_ptr getHuman(const std::string& idArg) const noexcept; + std::shared_ptr getDroid(const std::string& idArg) const noexcept; private: const std::map heroes_; - const std::map> humans_; - const std::map> droids_; + const std::map> humans_; + const std::map> droids_; }; } // namespace graphql::learn diff --git a/samples/star_wars/ReviewData.cpp b/samples/star_wars/ReviewData.cpp index 814b53f4..276b3e0a 100644 --- a/samples/star_wars/ReviewData.cpp +++ b/samples/star_wars/ReviewData.cpp @@ -5,18 +5,18 @@ namespace graphql::learn { -Review::Review(response::IntType stars, std::optional&& commentary) noexcept +Review::Review(int stars, std::optional&& commentary) noexcept : stars_ { stars } , commentary_ { std::move(commentary) } { } -response::IntType Review::getStars() const noexcept +int Review::getStars() const noexcept { return stars_; } -const std::optional& Review::getCommentary() const noexcept +const std::optional& Review::getCommentary() const noexcept { return commentary_; } diff --git a/samples/star_wars/ReviewData.h b/samples/star_wars/ReviewData.h index f10565fe..4d75959e 100644 --- a/samples/star_wars/ReviewData.h +++ b/samples/star_wars/ReviewData.h @@ -13,15 +13,14 @@ namespace graphql::learn { class Review { public: - explicit Review( - response::IntType stars, std::optional&& commentary) noexcept; + explicit Review(int stars, std::optional&& commentary) noexcept; - response::IntType getStars() const noexcept; - const std::optional& getCommentary() const noexcept; + int getStars() const noexcept; + const std::optional& getCommentary() const noexcept; private: - const response::IntType stars_; - const std::optional commentary_; + const int stars_; + const std::optional commentary_; }; } // namespace graphql::learn diff --git a/samples/star_wars/StarWarsData.cpp b/samples/star_wars/StarWarsData.cpp index 46013225..7f85383c 100644 --- a/samples/star_wars/StarWarsData.cpp +++ b/samples/star_wars/StarWarsData.cpp @@ -99,7 +99,7 @@ std::shared_ptr GetService() noexcept { learn::Episode::JEDI, { artoo } }, }; - std::map> humans { + std::map> humans { { luke->getId(), luke }, { vader->getId(), vader }, { han->getId(), han }, @@ -107,7 +107,7 @@ std::shared_ptr GetService() noexcept { tarkin->getId(), tarkin }, }; - std::map> droids { + std::map> droids { { threepio->getId(), threepio }, { artoo->getId(), artoo }, }; diff --git a/samples/today/TodayMock.cpp b/samples/today/TodayMock.cpp index 68cd7b3d..e329e396 100644 --- a/samples/today/TodayMock.cpp +++ b/samples/today/TodayMock.cpp @@ -473,14 +473,14 @@ std::shared_ptr Mutation::applyCompleteTask( return std::make_shared(_mutateCompleteTask(std::move(input))); } -std::optional Mutation::_setFloat = std::nullopt; +std::optional Mutation::_setFloat = std::nullopt; double Mutation::getFloat() noexcept { return *_setFloat; } -response::FloatType Mutation::applySetFloat(response::FloatType valueArg) noexcept +double Mutation::applySetFloat(double valueArg) noexcept { _setFloat = std::make_optional(valueArg); return valueArg; @@ -498,7 +498,7 @@ NestedType::NestedType(service::FieldParams&& params, int depth) std::move(params.fieldDirectives) }); } -response::IntType NestedType::getDepth() const noexcept +int NestedType::getDepth() const noexcept { return depth; } @@ -544,12 +544,11 @@ Expensive::~Expensive() --instances; } -std::future Expensive::getOrder( - const service::FieldParams& params) const noexcept +std::future Expensive::getOrder(const service::FieldParams& params) const noexcept { return std::async( params.launch, - [](bool blockAsync, response::IntType instanceOrder) noexcept { + [](bool blockAsync, int instanceOrder) noexcept { if (blockAsync) { // Block all of the Expensive objects in async mode until the count is reached. @@ -570,7 +569,7 @@ std::future Expensive::getOrder( return instanceOrder; }, params.launch == std::launch::async, - static_cast(order)); + static_cast(order)); } EmptyOperations::EmptyOperations() diff --git a/samples/today/TodayMock.h b/samples/today/TodayMock.h index 96fbe1b6..dcea0f50 100644 --- a/samples/today/TodayMock.h +++ b/samples/today/TodayMock.h @@ -53,16 +53,16 @@ class Query : public std::enable_shared_from_this service::FieldResult> getNode( service::FieldParams params, response::IdType id); std::future> getAppointments( - const service::FieldParams& params, std::optional first, - std::optional&& after, std::optional last, + const service::FieldParams& params, std::optional first, + std::optional&& after, std::optional last, std::optional&& before); std::future> getTasks( - const service::FieldParams& params, std::optional first, - std::optional&& after, std::optional last, + const service::FieldParams& params, std::optional first, + std::optional&& after, std::optional last, std::optional&& before); std::future> getUnreadCounts( - const service::FieldParams& params, std::optional first, - std::optional&& after, std::optional last, + const service::FieldParams& params, std::optional first, + std::optional&& after, std::optional last, std::optional&& before); std::vector> getAppointmentsById( const service::FieldParams& params, const std::vector& ids); @@ -143,9 +143,9 @@ class Appointment return std::make_optional(std::string(_when)); } - std::optional getSubject() const noexcept + std::optional getSubject() const noexcept { - return std::make_optional(_subject); + return std::make_optional(_subject); } bool getIsNow() const noexcept @@ -153,7 +153,7 @@ class Appointment return _isNow; } - std::optional getForceError() const + std::optional getForceError() const { throw std::runtime_error(R"ex(this error was forced)ex"); } @@ -239,9 +239,9 @@ class Task return _id; } - std::optional getTitle() const noexcept + std::optional getTitle() const noexcept { - return std::make_optional(_title); + return std::make_optional(_title); } bool getIsComplete() const noexcept @@ -329,9 +329,9 @@ class Folder return _id; } - std::optional getName() const noexcept + std::optional getName() const noexcept { - return std::make_optional(_name); + return std::make_optional(_name); } int getUnreadCount() const noexcept @@ -406,7 +406,7 @@ class CompleteTaskPayload { public: explicit CompleteTaskPayload( - std::shared_ptr task, std::optional&& clientMutationId) + std::shared_ptr task, std::optional&& clientMutationId) : _task(std::move(task)) , _clientMutationId(std::move(clientMutationId)) { @@ -417,14 +417,14 @@ class CompleteTaskPayload return std::make_shared(_task); } - const std::optional& getClientMutationId() const noexcept + const std::optional& getClientMutationId() const noexcept { return _clientMutationId; } private: std::shared_ptr _task; - std::optional _clientMutationId; + std::optional _clientMutationId; }; class Mutation @@ -439,11 +439,11 @@ class Mutation std::shared_ptr applyCompleteTask( CompleteTaskInput&& input) noexcept; - response::FloatType applySetFloat(response::FloatType valueArg) noexcept; + double applySetFloat(double valueArg) noexcept; private: completeTaskMutation _mutateCompleteTask; - static std::optional _setFloat; + static std::optional _setFloat; }; class Subscription @@ -578,7 +578,7 @@ class NestedType public: explicit NestedType(service::FieldParams&& params, int depth); - response::IntType getDepth() const noexcept; + int getDepth() const noexcept; std::shared_ptr getNested(service::FieldParams&& params) const noexcept; static std::stack getCapturedParams() noexcept; @@ -598,7 +598,7 @@ class Expensive explicit Expensive(); ~Expensive(); - std::future getOrder(const service::FieldParams& params) const noexcept; + std::future getOrder(const service::FieldParams& params) const noexcept; static constexpr size_t count = 5; static std::mutex testMutex; diff --git a/samples/unified/TodaySchema.cpp b/samples/unified/TodaySchema.cpp index c843a1f9..d399d22f 100644 --- a/samples/unified/TodaySchema.cpp +++ b/samples/unified/TodaySchema.cpp @@ -36,7 +36,7 @@ today::TaskState ModifiedArgument::convert(const response::Val throw service::schema_exception { { "not a valid TaskState value" } }; } - const auto itr = std::find(s_namesTaskState.cbegin(), s_namesTaskState.cend(), value.get()); + const auto itr = std::find(s_namesTaskState.cbegin(), s_namesTaskState.cend(), value.get()); if (itr == s_namesTaskState.cend()) { @@ -54,7 +54,7 @@ service::AwaitableResolver ModifiedResult::convert(service::Fi { response::Value result(response::Type::EnumValue); - result.set(response::StringType { s_namesTaskState[static_cast(value)] }); + result.set(std::string { s_namesTaskState[static_cast(value)] }); return result; }); @@ -76,11 +76,11 @@ today::CompleteTaskInput ModifiedArgument::convert(con auto valueId = service::ModifiedArgument::require("id", value); auto valueTestTaskState = service::ModifiedArgument::require("testTaskState", value); - auto pairIsComplete = service::ModifiedArgument::find("isComplete", value); + auto pairIsComplete = service::ModifiedArgument::find("isComplete", value); auto valueIsComplete = (pairIsComplete.second ? std::move(pairIsComplete.first) - : service::ModifiedArgument::require("isComplete", defaultValue)); - auto valueClientMutationId = service::ModifiedArgument::require("clientMutationId", value); + : service::ModifiedArgument::require("isComplete", defaultValue)); + auto valueClientMutationId = service::ModifiedArgument::require("clientMutationId", value); return { std::move(valueId), @@ -189,9 +189,9 @@ service::AwaitableResolver Query::resolveNode(service::ResolverParams&& params) service::AwaitableResolver Query::resolveAppointments(service::ResolverParams&& params) { - auto argFirst = service::ModifiedArgument::require("first", params.arguments); + auto argFirst = service::ModifiedArgument::require("first", params.arguments); auto argAfter = service::ModifiedArgument::require("after", params.arguments); - auto argLast = service::ModifiedArgument::require("last", params.arguments); + auto argLast = service::ModifiedArgument::require("last", params.arguments); auto argBefore = service::ModifiedArgument::require("before", params.arguments); std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -203,9 +203,9 @@ service::AwaitableResolver Query::resolveAppointments(service::ResolverParams&& service::AwaitableResolver Query::resolveTasks(service::ResolverParams&& params) { - auto argFirst = service::ModifiedArgument::require("first", params.arguments); + auto argFirst = service::ModifiedArgument::require("first", params.arguments); auto argAfter = service::ModifiedArgument::require("after", params.arguments); - auto argLast = service::ModifiedArgument::require("last", params.arguments); + auto argLast = service::ModifiedArgument::require("last", params.arguments); auto argBefore = service::ModifiedArgument::require("before", params.arguments); std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -217,9 +217,9 @@ service::AwaitableResolver Query::resolveTasks(service::ResolverParams&& params) service::AwaitableResolver Query::resolveUnreadCounts(service::ResolverParams&& params) { - auto argFirst = service::ModifiedArgument::require("first", params.arguments); + auto argFirst = service::ModifiedArgument::require("first", params.arguments); auto argAfter = service::ModifiedArgument::require("after", params.arguments); - auto argLast = service::ModifiedArgument::require("last", params.arguments); + auto argLast = service::ModifiedArgument::require("last", params.arguments); auto argBefore = service::ModifiedArgument::require("before", params.arguments); std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -301,7 +301,7 @@ service::AwaitableResolver Query::resolveUnimplemented(service::ResolverParams&& auto result = _pimpl->getUnimplemented(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } service::AwaitableResolver Query::resolveExpensive(service::ResolverParams&& params) @@ -337,7 +337,7 @@ service::AwaitableResolver Query::resolveAnyType(service::ResolverParams&& param service::AwaitableResolver Query::resolve_typename(service::ResolverParams&& params) { - return service::ModifiedResult::convert(response::StringType{ R"gql(Query)gql" }, std::move(params)); + return service::ModifiedResult::convert(std::string{ R"gql(Query)gql" }, std::move(params)); } service::AwaitableResolver Query::resolve_schema(service::ResolverParams&& params) @@ -347,7 +347,7 @@ service::AwaitableResolver Query::resolve_schema(service::ResolverParams&& param service::AwaitableResolver Query::resolve_type(service::ResolverParams&& params) { - auto argName = service::ModifiedArgument::require("name", params.arguments); + auto argName = service::ModifiedArgument::require("name", params.arguments); const auto& baseType = _schema->LookupType(argName); std::shared_ptr result { baseType ? std::make_shared(std::make_shared(baseType)) : nullptr }; @@ -383,7 +383,7 @@ service::AwaitableResolver PageInfo::resolveHasNextPage(service::ResolverParams& auto result = _pimpl->getHasNextPage(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } service::AwaitableResolver PageInfo::resolveHasPreviousPage(service::ResolverParams&& params) @@ -393,12 +393,12 @@ service::AwaitableResolver PageInfo::resolveHasPreviousPage(service::ResolverPar auto result = _pimpl->getHasPreviousPage(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } service::AwaitableResolver PageInfo::resolve_typename(service::ResolverParams&& params) { - return service::ModifiedResult::convert(response::StringType{ R"gql(PageInfo)gql" }, std::move(params)); + return service::ModifiedResult::convert(std::string{ R"gql(PageInfo)gql" }, std::move(params)); } AppointmentEdge::AppointmentEdge(std::unique_ptr&& pimpl) @@ -445,7 +445,7 @@ service::AwaitableResolver AppointmentEdge::resolveCursor(service::ResolverParam service::AwaitableResolver AppointmentEdge::resolve_typename(service::ResolverParams&& params) { - return service::ModifiedResult::convert(response::StringType{ R"gql(AppointmentEdge)gql" }, std::move(params)); + return service::ModifiedResult::convert(std::string{ R"gql(AppointmentEdge)gql" }, std::move(params)); } AppointmentConnection::AppointmentConnection(std::unique_ptr&& pimpl) @@ -492,7 +492,7 @@ service::AwaitableResolver AppointmentConnection::resolveEdges(service::Resolver service::AwaitableResolver AppointmentConnection::resolve_typename(service::ResolverParams&& params) { - return service::ModifiedResult::convert(response::StringType{ R"gql(AppointmentConnection)gql" }, std::move(params)); + return service::ModifiedResult::convert(std::string{ R"gql(AppointmentConnection)gql" }, std::move(params)); } TaskEdge::TaskEdge(std::unique_ptr&& pimpl) @@ -539,7 +539,7 @@ service::AwaitableResolver TaskEdge::resolveCursor(service::ResolverParams&& par service::AwaitableResolver TaskEdge::resolve_typename(service::ResolverParams&& params) { - return service::ModifiedResult::convert(response::StringType{ R"gql(TaskEdge)gql" }, std::move(params)); + return service::ModifiedResult::convert(std::string{ R"gql(TaskEdge)gql" }, std::move(params)); } TaskConnection::TaskConnection(std::unique_ptr&& pimpl) @@ -586,7 +586,7 @@ service::AwaitableResolver TaskConnection::resolveEdges(service::ResolverParams& service::AwaitableResolver TaskConnection::resolve_typename(service::ResolverParams&& params) { - return service::ModifiedResult::convert(response::StringType{ R"gql(TaskConnection)gql" }, std::move(params)); + return service::ModifiedResult::convert(std::string{ R"gql(TaskConnection)gql" }, std::move(params)); } FolderEdge::FolderEdge(std::unique_ptr&& pimpl) @@ -633,7 +633,7 @@ service::AwaitableResolver FolderEdge::resolveCursor(service::ResolverParams&& p service::AwaitableResolver FolderEdge::resolve_typename(service::ResolverParams&& params) { - return service::ModifiedResult::convert(response::StringType{ R"gql(FolderEdge)gql" }, std::move(params)); + return service::ModifiedResult::convert(std::string{ R"gql(FolderEdge)gql" }, std::move(params)); } FolderConnection::FolderConnection(std::unique_ptr&& pimpl) @@ -680,7 +680,7 @@ service::AwaitableResolver FolderConnection::resolveEdges(service::ResolverParam service::AwaitableResolver FolderConnection::resolve_typename(service::ResolverParams&& params) { - return service::ModifiedResult::convert(response::StringType{ R"gql(FolderConnection)gql" }, std::move(params)); + return service::ModifiedResult::convert(std::string{ R"gql(FolderConnection)gql" }, std::move(params)); } CompleteTaskPayload::CompleteTaskPayload(std::unique_ptr&& pimpl) @@ -722,12 +722,12 @@ service::AwaitableResolver CompleteTaskPayload::resolveClientMutationId(service: auto result = _pimpl->getClientMutationId(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } service::AwaitableResolver CompleteTaskPayload::resolve_typename(service::ResolverParams&& params) { - return service::ModifiedResult::convert(response::StringType{ R"gql(CompleteTaskPayload)gql" }, std::move(params)); + return service::ModifiedResult::convert(std::string{ R"gql(CompleteTaskPayload)gql" }, std::move(params)); } Mutation::Mutation(std::unique_ptr&& pimpl) @@ -765,18 +765,18 @@ service::AwaitableResolver Mutation::resolveCompleteTask(service::ResolverParams service::AwaitableResolver Mutation::resolveSetFloat(service::ResolverParams&& params) { - auto argValue = service::ModifiedArgument::require("value", params.arguments); + auto argValue = service::ModifiedArgument::require("value", params.arguments); std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); auto result = _pimpl->applySetFloat(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argValue)); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } service::AwaitableResolver Mutation::resolve_typename(service::ResolverParams&& params) { - return service::ModifiedResult::convert(response::StringType{ R"gql(Mutation)gql" }, std::move(params)); + return service::ModifiedResult::convert(std::string{ R"gql(Mutation)gql" }, std::move(params)); } Subscription::Subscription(std::unique_ptr&& pimpl) @@ -824,7 +824,7 @@ service::AwaitableResolver Subscription::resolveNodeChange(service::ResolverPara service::AwaitableResolver Subscription::resolve_typename(service::ResolverParams&& params) { - return service::ModifiedResult::convert(response::StringType{ R"gql(Subscription)gql" }, std::move(params)); + return service::ModifiedResult::convert(std::string{ R"gql(Subscription)gql" }, std::move(params)); } Appointment::Appointment(std::unique_ptr&& pimpl) @@ -881,7 +881,7 @@ service::AwaitableResolver Appointment::resolveSubject(service::ResolverParams&& auto result = _pimpl->getSubject(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } service::AwaitableResolver Appointment::resolveIsNow(service::ResolverParams&& params) @@ -891,7 +891,7 @@ service::AwaitableResolver Appointment::resolveIsNow(service::ResolverParams&& p auto result = _pimpl->getIsNow(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } service::AwaitableResolver Appointment::resolveForceError(service::ResolverParams&& params) @@ -901,12 +901,12 @@ service::AwaitableResolver Appointment::resolveForceError(service::ResolverParam auto result = _pimpl->getForceError(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } service::AwaitableResolver Appointment::resolve_typename(service::ResolverParams&& params) { - return service::ModifiedResult::convert(response::StringType{ R"gql(Appointment)gql" }, std::move(params)); + return service::ModifiedResult::convert(std::string{ R"gql(Appointment)gql" }, std::move(params)); } Task::Task(std::unique_ptr&& pimpl) @@ -951,7 +951,7 @@ service::AwaitableResolver Task::resolveTitle(service::ResolverParams&& params) auto result = _pimpl->getTitle(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } service::AwaitableResolver Task::resolveIsComplete(service::ResolverParams&& params) @@ -961,12 +961,12 @@ service::AwaitableResolver Task::resolveIsComplete(service::ResolverParams&& par auto result = _pimpl->getIsComplete(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } service::AwaitableResolver Task::resolve_typename(service::ResolverParams&& params) { - return service::ModifiedResult::convert(response::StringType{ R"gql(Task)gql" }, std::move(params)); + return service::ModifiedResult::convert(std::string{ R"gql(Task)gql" }, std::move(params)); } Folder::Folder(std::unique_ptr&& pimpl) @@ -1011,7 +1011,7 @@ service::AwaitableResolver Folder::resolveName(service::ResolverParams&& params) auto result = _pimpl->getName(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } service::AwaitableResolver Folder::resolveUnreadCount(service::ResolverParams&& params) @@ -1021,12 +1021,12 @@ service::AwaitableResolver Folder::resolveUnreadCount(service::ResolverParams&& auto result = _pimpl->getUnreadCount(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } service::AwaitableResolver Folder::resolve_typename(service::ResolverParams&& params) { - return service::ModifiedResult::convert(response::StringType{ R"gql(Folder)gql" }, std::move(params)); + return service::ModifiedResult::convert(std::string{ R"gql(Folder)gql" }, std::move(params)); } NestedType::NestedType(std::unique_ptr&& pimpl) @@ -1058,7 +1058,7 @@ service::AwaitableResolver NestedType::resolveDepth(service::ResolverParams&& pa auto result = _pimpl->getDepth(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } service::AwaitableResolver NestedType::resolveNested(service::ResolverParams&& params) @@ -1073,7 +1073,7 @@ service::AwaitableResolver NestedType::resolveNested(service::ResolverParams&& p service::AwaitableResolver NestedType::resolve_typename(service::ResolverParams&& params) { - return service::ModifiedResult::convert(response::StringType{ R"gql(NestedType)gql" }, std::move(params)); + return service::ModifiedResult::convert(std::string{ R"gql(NestedType)gql" }, std::move(params)); } Expensive::Expensive(std::unique_ptr&& pimpl) @@ -1104,12 +1104,12 @@ service::AwaitableResolver Expensive::resolveOrder(service::ResolverParams&& par auto result = _pimpl->getOrder(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } service::AwaitableResolver Expensive::resolve_typename(service::ResolverParams&& params) { - return service::ModifiedResult::convert(response::StringType{ R"gql(Expensive)gql" }, std::move(params)); + return service::ModifiedResult::convert(std::string{ R"gql(Expensive)gql" }, std::move(params)); } } // namespace object diff --git a/samples/unified/TodaySchema.h b/samples/unified/TodaySchema.h index f527696a..4dfaa0ef 100644 --- a/samples/unified/TodaySchema.h +++ b/samples/unified/TodaySchema.h @@ -33,8 +33,8 @@ struct CompleteTaskInput { response::IdType id; std::optional testTaskState; - std::optional isComplete; - std::optional clientMutationId; + std::optional isComplete; + std::optional clientMutationId; }; struct ThirdNestedInput @@ -103,37 +103,37 @@ concept NoParamsNode = requires (TImpl impl, response::IdType idArg) }; template -concept WithParamsAppointments = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) +concept WithParamsAppointments = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) { { service::FieldResult> { impl.getAppointments(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; }; template -concept NoParamsAppointments = requires (TImpl impl, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) +concept NoParamsAppointments = requires (TImpl impl, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) { { service::FieldResult> { impl.getAppointments(std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; }; template -concept WithParamsTasks = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) +concept WithParamsTasks = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) { { service::FieldResult> { impl.getTasks(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; }; template -concept NoParamsTasks = requires (TImpl impl, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) +concept NoParamsTasks = requires (TImpl impl, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) { { service::FieldResult> { impl.getTasks(std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; }; template -concept WithParamsUnreadCounts = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) +concept WithParamsUnreadCounts = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) { { service::FieldResult> { impl.getUnreadCounts(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; }; template -concept NoParamsUnreadCounts = requires (TImpl impl, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) +concept NoParamsUnreadCounts = requires (TImpl impl, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) { { service::FieldResult> { impl.getUnreadCounts(std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; }; @@ -189,13 +189,13 @@ concept NoParamsNested = requires (TImpl impl) template concept WithParamsUnimplemented = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult { impl.getUnimplemented(std::move(params)) } }; + { service::FieldResult { impl.getUnimplemented(std::move(params)) } }; }; template concept NoParamsUnimplemented = requires (TImpl impl) { - { service::FieldResult { impl.getUnimplemented() } }; + { service::FieldResult { impl.getUnimplemented() } }; }; template @@ -253,25 +253,25 @@ namespace PageInfoMethod { template concept WithParamsHasNextPage = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult { impl.getHasNextPage(std::move(params)) } }; + { service::FieldResult { impl.getHasNextPage(std::move(params)) } }; }; template concept NoParamsHasNextPage = requires (TImpl impl) { - { service::FieldResult { impl.getHasNextPage() } }; + { service::FieldResult { impl.getHasNextPage() } }; }; template concept WithParamsHasPreviousPage = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult { impl.getHasPreviousPage(std::move(params)) } }; + { service::FieldResult { impl.getHasPreviousPage(std::move(params)) } }; }; template concept NoParamsHasPreviousPage = requires (TImpl impl) { - { service::FieldResult { impl.getHasPreviousPage() } }; + { service::FieldResult { impl.getHasPreviousPage() } }; }; template @@ -545,13 +545,13 @@ concept NoParamsTask = requires (TImpl impl) template concept WithParamsClientMutationId = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult> { impl.getClientMutationId(std::move(params)) } }; + { service::FieldResult> { impl.getClientMutationId(std::move(params)) } }; }; template concept NoParamsClientMutationId = requires (TImpl impl) { - { service::FieldResult> { impl.getClientMutationId() } }; + { service::FieldResult> { impl.getClientMutationId() } }; }; template @@ -583,15 +583,15 @@ concept NoParamsCompleteTask = requires (TImpl impl, CompleteTaskInput inputArg) }; template -concept WithParamsSetFloat = requires (TImpl impl, service::FieldParams params, response::FloatType valueArg) +concept WithParamsSetFloat = requires (TImpl impl, service::FieldParams params, double valueArg) { - { service::FieldResult { impl.applySetFloat(std::move(params), std::move(valueArg)) } }; + { service::FieldResult { impl.applySetFloat(std::move(params), std::move(valueArg)) } }; }; template -concept NoParamsSetFloat = requires (TImpl impl, response::FloatType valueArg) +concept NoParamsSetFloat = requires (TImpl impl, double valueArg) { - { service::FieldResult { impl.applySetFloat(std::move(valueArg)) } }; + { service::FieldResult { impl.applySetFloat(std::move(valueArg)) } }; }; template @@ -677,37 +677,37 @@ concept NoParamsWhen = requires (TImpl impl) template concept WithParamsSubject = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult> { impl.getSubject(std::move(params)) } }; + { service::FieldResult> { impl.getSubject(std::move(params)) } }; }; template concept NoParamsSubject = requires (TImpl impl) { - { service::FieldResult> { impl.getSubject() } }; + { service::FieldResult> { impl.getSubject() } }; }; template concept WithParamsIsNow = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult { impl.getIsNow(std::move(params)) } }; + { service::FieldResult { impl.getIsNow(std::move(params)) } }; }; template concept NoParamsIsNow = requires (TImpl impl) { - { service::FieldResult { impl.getIsNow() } }; + { service::FieldResult { impl.getIsNow() } }; }; template concept WithParamsForceError = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult> { impl.getForceError(std::move(params)) } }; + { service::FieldResult> { impl.getForceError(std::move(params)) } }; }; template concept NoParamsForceError = requires (TImpl impl) { - { service::FieldResult> { impl.getForceError() } }; + { service::FieldResult> { impl.getForceError() } }; }; template @@ -741,25 +741,25 @@ concept NoParamsId = requires (TImpl impl) template concept WithParamsTitle = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult> { impl.getTitle(std::move(params)) } }; + { service::FieldResult> { impl.getTitle(std::move(params)) } }; }; template concept NoParamsTitle = requires (TImpl impl) { - { service::FieldResult> { impl.getTitle() } }; + { service::FieldResult> { impl.getTitle() } }; }; template concept WithParamsIsComplete = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult { impl.getIsComplete(std::move(params)) } }; + { service::FieldResult { impl.getIsComplete(std::move(params)) } }; }; template concept NoParamsIsComplete = requires (TImpl impl) { - { service::FieldResult { impl.getIsComplete() } }; + { service::FieldResult { impl.getIsComplete() } }; }; template @@ -793,25 +793,25 @@ concept NoParamsId = requires (TImpl impl) template concept WithParamsName = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult> { impl.getName(std::move(params)) } }; + { service::FieldResult> { impl.getName(std::move(params)) } }; }; template concept NoParamsName = requires (TImpl impl) { - { service::FieldResult> { impl.getName() } }; + { service::FieldResult> { impl.getName() } }; }; template concept WithParamsUnreadCount = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult { impl.getUnreadCount(std::move(params)) } }; + { service::FieldResult { impl.getUnreadCount(std::move(params)) } }; }; template concept NoParamsUnreadCount = requires (TImpl impl) { - { service::FieldResult { impl.getUnreadCount() } }; + { service::FieldResult { impl.getUnreadCount() } }; }; template @@ -833,13 +833,13 @@ namespace NestedTypeMethod { template concept WithParamsDepth = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult { impl.getDepth(std::move(params)) } }; + { service::FieldResult { impl.getDepth(std::move(params)) } }; }; template concept NoParamsDepth = requires (TImpl impl) { - { service::FieldResult { impl.getDepth() } }; + { service::FieldResult { impl.getDepth() } }; }; template @@ -873,13 +873,13 @@ namespace ExpensiveMethod { template concept WithParamsOrder = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult { impl.getOrder(std::move(params)) } }; + { service::FieldResult { impl.getOrder(std::move(params)) } }; }; template concept NoParamsOrder = requires (TImpl impl) { - { service::FieldResult { impl.getOrder() } }; + { service::FieldResult { impl.getOrder() } }; }; template @@ -928,14 +928,14 @@ class Query virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; virtual service::FieldResult> getNode(service::FieldParams&& params, response::IdType&& idArg) const = 0; - virtual service::FieldResult> getAppointments(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const = 0; - virtual service::FieldResult> getTasks(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const = 0; - virtual service::FieldResult> getUnreadCounts(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const = 0; + virtual service::FieldResult> getAppointments(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const = 0; + virtual service::FieldResult> getTasks(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const = 0; + virtual service::FieldResult> getUnreadCounts(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const = 0; virtual service::FieldResult>> getAppointmentsById(service::FieldParams&& params, std::vector&& idsArg) const = 0; virtual service::FieldResult>> getTasksById(service::FieldParams&& params, std::vector&& idsArg) const = 0; virtual service::FieldResult>> getUnreadCountsById(service::FieldParams&& params, std::vector&& idsArg) const = 0; virtual service::FieldResult> getNested(service::FieldParams&& params) const = 0; - virtual service::FieldResult getUnimplemented(service::FieldParams&& params) const = 0; + virtual service::FieldResult getUnimplemented(service::FieldParams&& params) const = 0; virtual service::FieldResult>> getExpensive(service::FieldParams&& params) const = 0; virtual service::FieldResult getTestTaskState(service::FieldParams&& params) const = 0; virtual service::FieldResult>> getAnyType(service::FieldParams&& params, std::vector&& idsArg) const = 0; @@ -966,7 +966,7 @@ class Query } } - service::FieldResult> getAppointments(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const final + service::FieldResult> getAppointments(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const final { if constexpr (methods::QueryMethod::WithParamsAppointments) { @@ -982,7 +982,7 @@ class Query } } - service::FieldResult> getTasks(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const final + service::FieldResult> getTasks(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const final { if constexpr (methods::QueryMethod::WithParamsTasks) { @@ -998,7 +998,7 @@ class Query } } - service::FieldResult> getUnreadCounts(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const final + service::FieldResult> getUnreadCounts(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const final { if constexpr (methods::QueryMethod::WithParamsUnreadCounts) { @@ -1078,7 +1078,7 @@ class Query } } - service::FieldResult getUnimplemented(service::FieldParams&& params) const final + service::FieldResult getUnimplemented(service::FieldParams&& params) const final { if constexpr (methods::QueryMethod::WithParamsUnimplemented) { @@ -1193,8 +1193,8 @@ class PageInfo virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual service::FieldResult getHasNextPage(service::FieldParams&& params) const = 0; - virtual service::FieldResult getHasPreviousPage(service::FieldParams&& params) const = 0; + virtual service::FieldResult getHasNextPage(service::FieldParams&& params) const = 0; + virtual service::FieldResult getHasPreviousPage(service::FieldParams&& params) const = 0; }; template @@ -1206,7 +1206,7 @@ class PageInfo { } - service::FieldResult getHasNextPage(service::FieldParams&& params) const final + service::FieldResult getHasNextPage(service::FieldParams&& params) const final { if constexpr (methods::PageInfoMethod::WithParamsHasNextPage) { @@ -1222,7 +1222,7 @@ class PageInfo } } - service::FieldResult getHasPreviousPage(service::FieldParams&& params) const final + service::FieldResult getHasPreviousPage(service::FieldParams&& params) const final { if constexpr (methods::PageInfoMethod::WithParamsHasPreviousPage) { @@ -1866,7 +1866,7 @@ class CompleteTaskPayload virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; virtual service::FieldResult> getTask(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getClientMutationId(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getClientMutationId(service::FieldParams&& params) const = 0; }; template @@ -1894,7 +1894,7 @@ class CompleteTaskPayload } } - service::FieldResult> getClientMutationId(service::FieldParams&& params) const final + service::FieldResult> getClientMutationId(service::FieldParams&& params) const final { if constexpr (methods::CompleteTaskPayloadMethod::WithParamsClientMutationId) { @@ -1962,7 +1962,7 @@ class Mutation virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; virtual service::FieldResult> applyCompleteTask(service::FieldParams&& params, CompleteTaskInput&& inputArg) const = 0; - virtual service::FieldResult applySetFloat(service::FieldParams&& params, response::FloatType&& valueArg) const = 0; + virtual service::FieldResult applySetFloat(service::FieldParams&& params, double&& valueArg) const = 0; }; template @@ -1990,7 +1990,7 @@ class Mutation } } - service::FieldResult applySetFloat(service::FieldParams&& params, response::FloatType&& valueArg) const final + service::FieldResult applySetFloat(service::FieldParams&& params, double&& valueArg) const final { if constexpr (methods::MutationMethod::WithParamsSetFloat) { @@ -2158,9 +2158,9 @@ class Appointment virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; virtual service::FieldResult> getWhen(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getSubject(service::FieldParams&& params) const = 0; - virtual service::FieldResult getIsNow(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getForceError(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getSubject(service::FieldParams&& params) const = 0; + virtual service::FieldResult getIsNow(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getForceError(service::FieldParams&& params) const = 0; }; template @@ -2204,7 +2204,7 @@ class Appointment } } - service::FieldResult> getSubject(service::FieldParams&& params) const final + service::FieldResult> getSubject(service::FieldParams&& params) const final { if constexpr (methods::AppointmentMethod::WithParamsSubject) { @@ -2220,7 +2220,7 @@ class Appointment } } - service::FieldResult getIsNow(service::FieldParams&& params) const final + service::FieldResult getIsNow(service::FieldParams&& params) const final { if constexpr (methods::AppointmentMethod::WithParamsIsNow) { @@ -2236,7 +2236,7 @@ class Appointment } } - service::FieldResult> getForceError(service::FieldParams&& params) const final + service::FieldResult> getForceError(service::FieldParams&& params) const final { if constexpr (methods::AppointmentMethod::WithParamsForceError) { @@ -2305,8 +2305,8 @@ class Task virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual service::FieldResult> getTitle(service::FieldParams&& params) const = 0; - virtual service::FieldResult getIsComplete(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getTitle(service::FieldParams&& params) const = 0; + virtual service::FieldResult getIsComplete(service::FieldParams&& params) const = 0; }; template @@ -2334,7 +2334,7 @@ class Task } } - service::FieldResult> getTitle(service::FieldParams&& params) const final + service::FieldResult> getTitle(service::FieldParams&& params) const final { if constexpr (methods::TaskMethod::WithParamsTitle) { @@ -2350,7 +2350,7 @@ class Task } } - service::FieldResult getIsComplete(service::FieldParams&& params) const final + service::FieldResult getIsComplete(service::FieldParams&& params) const final { if constexpr (methods::TaskMethod::WithParamsIsComplete) { @@ -2419,8 +2419,8 @@ class Folder virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual service::FieldResult> getName(service::FieldParams&& params) const = 0; - virtual service::FieldResult getUnreadCount(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getName(service::FieldParams&& params) const = 0; + virtual service::FieldResult getUnreadCount(service::FieldParams&& params) const = 0; }; template @@ -2448,7 +2448,7 @@ class Folder } } - service::FieldResult> getName(service::FieldParams&& params) const final + service::FieldResult> getName(service::FieldParams&& params) const final { if constexpr (methods::FolderMethod::WithParamsName) { @@ -2464,7 +2464,7 @@ class Folder } } - service::FieldResult getUnreadCount(service::FieldParams&& params) const final + service::FieldResult getUnreadCount(service::FieldParams&& params) const final { if constexpr (methods::FolderMethod::WithParamsUnreadCount) { @@ -2531,7 +2531,7 @@ class NestedType virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual service::FieldResult getDepth(service::FieldParams&& params) const = 0; + virtual service::FieldResult getDepth(service::FieldParams&& params) const = 0; virtual service::FieldResult> getNested(service::FieldParams&& params) const = 0; }; @@ -2544,7 +2544,7 @@ class NestedType { } - service::FieldResult getDepth(service::FieldParams&& params) const final + service::FieldResult getDepth(service::FieldParams&& params) const final { if constexpr (methods::NestedTypeMethod::WithParamsDepth) { @@ -2626,7 +2626,7 @@ class Expensive virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual service::FieldResult getOrder(service::FieldParams&& params) const = 0; + virtual service::FieldResult getOrder(service::FieldParams&& params) const = 0; }; template @@ -2638,7 +2638,7 @@ class Expensive { } - service::FieldResult getOrder(service::FieldParams&& params) const final + service::FieldResult getOrder(service::FieldParams&& params) const final { if constexpr (methods::ExpensiveMethod::WithParamsOrder) { diff --git a/samples/unified_nointrospection/TodaySchema.cpp b/samples/unified_nointrospection/TodaySchema.cpp index 5631f604..21315b43 100644 --- a/samples/unified_nointrospection/TodaySchema.cpp +++ b/samples/unified_nointrospection/TodaySchema.cpp @@ -36,7 +36,7 @@ today::TaskState ModifiedArgument::convert(const response::Val throw service::schema_exception { { "not a valid TaskState value" } }; } - const auto itr = std::find(s_namesTaskState.cbegin(), s_namesTaskState.cend(), value.get()); + const auto itr = std::find(s_namesTaskState.cbegin(), s_namesTaskState.cend(), value.get()); if (itr == s_namesTaskState.cend()) { @@ -54,7 +54,7 @@ service::AwaitableResolver ModifiedResult::convert(service::Fi { response::Value result(response::Type::EnumValue); - result.set(response::StringType { s_namesTaskState[static_cast(value)] }); + result.set(std::string { s_namesTaskState[static_cast(value)] }); return result; }); @@ -76,11 +76,11 @@ today::CompleteTaskInput ModifiedArgument::convert(con auto valueId = service::ModifiedArgument::require("id", value); auto valueTestTaskState = service::ModifiedArgument::require("testTaskState", value); - auto pairIsComplete = service::ModifiedArgument::find("isComplete", value); + auto pairIsComplete = service::ModifiedArgument::find("isComplete", value); auto valueIsComplete = (pairIsComplete.second ? std::move(pairIsComplete.first) - : service::ModifiedArgument::require("isComplete", defaultValue)); - auto valueClientMutationId = service::ModifiedArgument::require("clientMutationId", value); + : service::ModifiedArgument::require("isComplete", defaultValue)); + auto valueClientMutationId = service::ModifiedArgument::require("clientMutationId", value); return { std::move(valueId), @@ -186,9 +186,9 @@ service::AwaitableResolver Query::resolveNode(service::ResolverParams&& params) service::AwaitableResolver Query::resolveAppointments(service::ResolverParams&& params) { - auto argFirst = service::ModifiedArgument::require("first", params.arguments); + auto argFirst = service::ModifiedArgument::require("first", params.arguments); auto argAfter = service::ModifiedArgument::require("after", params.arguments); - auto argLast = service::ModifiedArgument::require("last", params.arguments); + auto argLast = service::ModifiedArgument::require("last", params.arguments); auto argBefore = service::ModifiedArgument::require("before", params.arguments); std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -200,9 +200,9 @@ service::AwaitableResolver Query::resolveAppointments(service::ResolverParams&& service::AwaitableResolver Query::resolveTasks(service::ResolverParams&& params) { - auto argFirst = service::ModifiedArgument::require("first", params.arguments); + auto argFirst = service::ModifiedArgument::require("first", params.arguments); auto argAfter = service::ModifiedArgument::require("after", params.arguments); - auto argLast = service::ModifiedArgument::require("last", params.arguments); + auto argLast = service::ModifiedArgument::require("last", params.arguments); auto argBefore = service::ModifiedArgument::require("before", params.arguments); std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -214,9 +214,9 @@ service::AwaitableResolver Query::resolveTasks(service::ResolverParams&& params) service::AwaitableResolver Query::resolveUnreadCounts(service::ResolverParams&& params) { - auto argFirst = service::ModifiedArgument::require("first", params.arguments); + auto argFirst = service::ModifiedArgument::require("first", params.arguments); auto argAfter = service::ModifiedArgument::require("after", params.arguments); - auto argLast = service::ModifiedArgument::require("last", params.arguments); + auto argLast = service::ModifiedArgument::require("last", params.arguments); auto argBefore = service::ModifiedArgument::require("before", params.arguments); std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -298,7 +298,7 @@ service::AwaitableResolver Query::resolveUnimplemented(service::ResolverParams&& auto result = _pimpl->getUnimplemented(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } service::AwaitableResolver Query::resolveExpensive(service::ResolverParams&& params) @@ -334,7 +334,7 @@ service::AwaitableResolver Query::resolveAnyType(service::ResolverParams&& param service::AwaitableResolver Query::resolve_typename(service::ResolverParams&& params) { - return service::ModifiedResult::convert(response::StringType{ R"gql(Query)gql" }, std::move(params)); + return service::ModifiedResult::convert(std::string{ R"gql(Query)gql" }, std::move(params)); } PageInfo::PageInfo(std::unique_ptr&& pimpl) @@ -366,7 +366,7 @@ service::AwaitableResolver PageInfo::resolveHasNextPage(service::ResolverParams& auto result = _pimpl->getHasNextPage(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } service::AwaitableResolver PageInfo::resolveHasPreviousPage(service::ResolverParams&& params) @@ -376,12 +376,12 @@ service::AwaitableResolver PageInfo::resolveHasPreviousPage(service::ResolverPar auto result = _pimpl->getHasPreviousPage(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } service::AwaitableResolver PageInfo::resolve_typename(service::ResolverParams&& params) { - return service::ModifiedResult::convert(response::StringType{ R"gql(PageInfo)gql" }, std::move(params)); + return service::ModifiedResult::convert(std::string{ R"gql(PageInfo)gql" }, std::move(params)); } AppointmentEdge::AppointmentEdge(std::unique_ptr&& pimpl) @@ -428,7 +428,7 @@ service::AwaitableResolver AppointmentEdge::resolveCursor(service::ResolverParam service::AwaitableResolver AppointmentEdge::resolve_typename(service::ResolverParams&& params) { - return service::ModifiedResult::convert(response::StringType{ R"gql(AppointmentEdge)gql" }, std::move(params)); + return service::ModifiedResult::convert(std::string{ R"gql(AppointmentEdge)gql" }, std::move(params)); } AppointmentConnection::AppointmentConnection(std::unique_ptr&& pimpl) @@ -475,7 +475,7 @@ service::AwaitableResolver AppointmentConnection::resolveEdges(service::Resolver service::AwaitableResolver AppointmentConnection::resolve_typename(service::ResolverParams&& params) { - return service::ModifiedResult::convert(response::StringType{ R"gql(AppointmentConnection)gql" }, std::move(params)); + return service::ModifiedResult::convert(std::string{ R"gql(AppointmentConnection)gql" }, std::move(params)); } TaskEdge::TaskEdge(std::unique_ptr&& pimpl) @@ -522,7 +522,7 @@ service::AwaitableResolver TaskEdge::resolveCursor(service::ResolverParams&& par service::AwaitableResolver TaskEdge::resolve_typename(service::ResolverParams&& params) { - return service::ModifiedResult::convert(response::StringType{ R"gql(TaskEdge)gql" }, std::move(params)); + return service::ModifiedResult::convert(std::string{ R"gql(TaskEdge)gql" }, std::move(params)); } TaskConnection::TaskConnection(std::unique_ptr&& pimpl) @@ -569,7 +569,7 @@ service::AwaitableResolver TaskConnection::resolveEdges(service::ResolverParams& service::AwaitableResolver TaskConnection::resolve_typename(service::ResolverParams&& params) { - return service::ModifiedResult::convert(response::StringType{ R"gql(TaskConnection)gql" }, std::move(params)); + return service::ModifiedResult::convert(std::string{ R"gql(TaskConnection)gql" }, std::move(params)); } FolderEdge::FolderEdge(std::unique_ptr&& pimpl) @@ -616,7 +616,7 @@ service::AwaitableResolver FolderEdge::resolveCursor(service::ResolverParams&& p service::AwaitableResolver FolderEdge::resolve_typename(service::ResolverParams&& params) { - return service::ModifiedResult::convert(response::StringType{ R"gql(FolderEdge)gql" }, std::move(params)); + return service::ModifiedResult::convert(std::string{ R"gql(FolderEdge)gql" }, std::move(params)); } FolderConnection::FolderConnection(std::unique_ptr&& pimpl) @@ -663,7 +663,7 @@ service::AwaitableResolver FolderConnection::resolveEdges(service::ResolverParam service::AwaitableResolver FolderConnection::resolve_typename(service::ResolverParams&& params) { - return service::ModifiedResult::convert(response::StringType{ R"gql(FolderConnection)gql" }, std::move(params)); + return service::ModifiedResult::convert(std::string{ R"gql(FolderConnection)gql" }, std::move(params)); } CompleteTaskPayload::CompleteTaskPayload(std::unique_ptr&& pimpl) @@ -705,12 +705,12 @@ service::AwaitableResolver CompleteTaskPayload::resolveClientMutationId(service: auto result = _pimpl->getClientMutationId(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } service::AwaitableResolver CompleteTaskPayload::resolve_typename(service::ResolverParams&& params) { - return service::ModifiedResult::convert(response::StringType{ R"gql(CompleteTaskPayload)gql" }, std::move(params)); + return service::ModifiedResult::convert(std::string{ R"gql(CompleteTaskPayload)gql" }, std::move(params)); } Mutation::Mutation(std::unique_ptr&& pimpl) @@ -748,18 +748,18 @@ service::AwaitableResolver Mutation::resolveCompleteTask(service::ResolverParams service::AwaitableResolver Mutation::resolveSetFloat(service::ResolverParams&& params) { - auto argValue = service::ModifiedArgument::require("value", params.arguments); + auto argValue = service::ModifiedArgument::require("value", params.arguments); std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); auto result = _pimpl->applySetFloat(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argValue)); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } service::AwaitableResolver Mutation::resolve_typename(service::ResolverParams&& params) { - return service::ModifiedResult::convert(response::StringType{ R"gql(Mutation)gql" }, std::move(params)); + return service::ModifiedResult::convert(std::string{ R"gql(Mutation)gql" }, std::move(params)); } Subscription::Subscription(std::unique_ptr&& pimpl) @@ -807,7 +807,7 @@ service::AwaitableResolver Subscription::resolveNodeChange(service::ResolverPara service::AwaitableResolver Subscription::resolve_typename(service::ResolverParams&& params) { - return service::ModifiedResult::convert(response::StringType{ R"gql(Subscription)gql" }, std::move(params)); + return service::ModifiedResult::convert(std::string{ R"gql(Subscription)gql" }, std::move(params)); } Appointment::Appointment(std::unique_ptr&& pimpl) @@ -864,7 +864,7 @@ service::AwaitableResolver Appointment::resolveSubject(service::ResolverParams&& auto result = _pimpl->getSubject(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } service::AwaitableResolver Appointment::resolveIsNow(service::ResolverParams&& params) @@ -874,7 +874,7 @@ service::AwaitableResolver Appointment::resolveIsNow(service::ResolverParams&& p auto result = _pimpl->getIsNow(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } service::AwaitableResolver Appointment::resolveForceError(service::ResolverParams&& params) @@ -884,12 +884,12 @@ service::AwaitableResolver Appointment::resolveForceError(service::ResolverParam auto result = _pimpl->getForceError(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } service::AwaitableResolver Appointment::resolve_typename(service::ResolverParams&& params) { - return service::ModifiedResult::convert(response::StringType{ R"gql(Appointment)gql" }, std::move(params)); + return service::ModifiedResult::convert(std::string{ R"gql(Appointment)gql" }, std::move(params)); } Task::Task(std::unique_ptr&& pimpl) @@ -934,7 +934,7 @@ service::AwaitableResolver Task::resolveTitle(service::ResolverParams&& params) auto result = _pimpl->getTitle(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } service::AwaitableResolver Task::resolveIsComplete(service::ResolverParams&& params) @@ -944,12 +944,12 @@ service::AwaitableResolver Task::resolveIsComplete(service::ResolverParams&& par auto result = _pimpl->getIsComplete(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } service::AwaitableResolver Task::resolve_typename(service::ResolverParams&& params) { - return service::ModifiedResult::convert(response::StringType{ R"gql(Task)gql" }, std::move(params)); + return service::ModifiedResult::convert(std::string{ R"gql(Task)gql" }, std::move(params)); } Folder::Folder(std::unique_ptr&& pimpl) @@ -994,7 +994,7 @@ service::AwaitableResolver Folder::resolveName(service::ResolverParams&& params) auto result = _pimpl->getName(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } service::AwaitableResolver Folder::resolveUnreadCount(service::ResolverParams&& params) @@ -1004,12 +1004,12 @@ service::AwaitableResolver Folder::resolveUnreadCount(service::ResolverParams&& auto result = _pimpl->getUnreadCount(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } service::AwaitableResolver Folder::resolve_typename(service::ResolverParams&& params) { - return service::ModifiedResult::convert(response::StringType{ R"gql(Folder)gql" }, std::move(params)); + return service::ModifiedResult::convert(std::string{ R"gql(Folder)gql" }, std::move(params)); } NestedType::NestedType(std::unique_ptr&& pimpl) @@ -1041,7 +1041,7 @@ service::AwaitableResolver NestedType::resolveDepth(service::ResolverParams&& pa auto result = _pimpl->getDepth(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } service::AwaitableResolver NestedType::resolveNested(service::ResolverParams&& params) @@ -1056,7 +1056,7 @@ service::AwaitableResolver NestedType::resolveNested(service::ResolverParams&& p service::AwaitableResolver NestedType::resolve_typename(service::ResolverParams&& params) { - return service::ModifiedResult::convert(response::StringType{ R"gql(NestedType)gql" }, std::move(params)); + return service::ModifiedResult::convert(std::string{ R"gql(NestedType)gql" }, std::move(params)); } Expensive::Expensive(std::unique_ptr&& pimpl) @@ -1087,12 +1087,12 @@ service::AwaitableResolver Expensive::resolveOrder(service::ResolverParams&& par auto result = _pimpl->getOrder(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } service::AwaitableResolver Expensive::resolve_typename(service::ResolverParams&& params) { - return service::ModifiedResult::convert(response::StringType{ R"gql(Expensive)gql" }, std::move(params)); + return service::ModifiedResult::convert(std::string{ R"gql(Expensive)gql" }, std::move(params)); } } // namespace object diff --git a/samples/unified_nointrospection/TodaySchema.h b/samples/unified_nointrospection/TodaySchema.h index 462fef19..c73499dd 100644 --- a/samples/unified_nointrospection/TodaySchema.h +++ b/samples/unified_nointrospection/TodaySchema.h @@ -33,8 +33,8 @@ struct CompleteTaskInput { response::IdType id; std::optional testTaskState; - std::optional isComplete; - std::optional clientMutationId; + std::optional isComplete; + std::optional clientMutationId; }; struct ThirdNestedInput @@ -103,37 +103,37 @@ concept NoParamsNode = requires (TImpl impl, response::IdType idArg) }; template -concept WithParamsAppointments = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) +concept WithParamsAppointments = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) { { service::FieldResult> { impl.getAppointments(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; }; template -concept NoParamsAppointments = requires (TImpl impl, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) +concept NoParamsAppointments = requires (TImpl impl, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) { { service::FieldResult> { impl.getAppointments(std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; }; template -concept WithParamsTasks = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) +concept WithParamsTasks = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) { { service::FieldResult> { impl.getTasks(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; }; template -concept NoParamsTasks = requires (TImpl impl, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) +concept NoParamsTasks = requires (TImpl impl, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) { { service::FieldResult> { impl.getTasks(std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; }; template -concept WithParamsUnreadCounts = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) +concept WithParamsUnreadCounts = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) { { service::FieldResult> { impl.getUnreadCounts(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; }; template -concept NoParamsUnreadCounts = requires (TImpl impl, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) +concept NoParamsUnreadCounts = requires (TImpl impl, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) { { service::FieldResult> { impl.getUnreadCounts(std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; }; @@ -189,13 +189,13 @@ concept NoParamsNested = requires (TImpl impl) template concept WithParamsUnimplemented = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult { impl.getUnimplemented(std::move(params)) } }; + { service::FieldResult { impl.getUnimplemented(std::move(params)) } }; }; template concept NoParamsUnimplemented = requires (TImpl impl) { - { service::FieldResult { impl.getUnimplemented() } }; + { service::FieldResult { impl.getUnimplemented() } }; }; template @@ -253,25 +253,25 @@ namespace PageInfoMethod { template concept WithParamsHasNextPage = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult { impl.getHasNextPage(std::move(params)) } }; + { service::FieldResult { impl.getHasNextPage(std::move(params)) } }; }; template concept NoParamsHasNextPage = requires (TImpl impl) { - { service::FieldResult { impl.getHasNextPage() } }; + { service::FieldResult { impl.getHasNextPage() } }; }; template concept WithParamsHasPreviousPage = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult { impl.getHasPreviousPage(std::move(params)) } }; + { service::FieldResult { impl.getHasPreviousPage(std::move(params)) } }; }; template concept NoParamsHasPreviousPage = requires (TImpl impl) { - { service::FieldResult { impl.getHasPreviousPage() } }; + { service::FieldResult { impl.getHasPreviousPage() } }; }; template @@ -545,13 +545,13 @@ concept NoParamsTask = requires (TImpl impl) template concept WithParamsClientMutationId = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult> { impl.getClientMutationId(std::move(params)) } }; + { service::FieldResult> { impl.getClientMutationId(std::move(params)) } }; }; template concept NoParamsClientMutationId = requires (TImpl impl) { - { service::FieldResult> { impl.getClientMutationId() } }; + { service::FieldResult> { impl.getClientMutationId() } }; }; template @@ -583,15 +583,15 @@ concept NoParamsCompleteTask = requires (TImpl impl, CompleteTaskInput inputArg) }; template -concept WithParamsSetFloat = requires (TImpl impl, service::FieldParams params, response::FloatType valueArg) +concept WithParamsSetFloat = requires (TImpl impl, service::FieldParams params, double valueArg) { - { service::FieldResult { impl.applySetFloat(std::move(params), std::move(valueArg)) } }; + { service::FieldResult { impl.applySetFloat(std::move(params), std::move(valueArg)) } }; }; template -concept NoParamsSetFloat = requires (TImpl impl, response::FloatType valueArg) +concept NoParamsSetFloat = requires (TImpl impl, double valueArg) { - { service::FieldResult { impl.applySetFloat(std::move(valueArg)) } }; + { service::FieldResult { impl.applySetFloat(std::move(valueArg)) } }; }; template @@ -677,37 +677,37 @@ concept NoParamsWhen = requires (TImpl impl) template concept WithParamsSubject = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult> { impl.getSubject(std::move(params)) } }; + { service::FieldResult> { impl.getSubject(std::move(params)) } }; }; template concept NoParamsSubject = requires (TImpl impl) { - { service::FieldResult> { impl.getSubject() } }; + { service::FieldResult> { impl.getSubject() } }; }; template concept WithParamsIsNow = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult { impl.getIsNow(std::move(params)) } }; + { service::FieldResult { impl.getIsNow(std::move(params)) } }; }; template concept NoParamsIsNow = requires (TImpl impl) { - { service::FieldResult { impl.getIsNow() } }; + { service::FieldResult { impl.getIsNow() } }; }; template concept WithParamsForceError = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult> { impl.getForceError(std::move(params)) } }; + { service::FieldResult> { impl.getForceError(std::move(params)) } }; }; template concept NoParamsForceError = requires (TImpl impl) { - { service::FieldResult> { impl.getForceError() } }; + { service::FieldResult> { impl.getForceError() } }; }; template @@ -741,25 +741,25 @@ concept NoParamsId = requires (TImpl impl) template concept WithParamsTitle = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult> { impl.getTitle(std::move(params)) } }; + { service::FieldResult> { impl.getTitle(std::move(params)) } }; }; template concept NoParamsTitle = requires (TImpl impl) { - { service::FieldResult> { impl.getTitle() } }; + { service::FieldResult> { impl.getTitle() } }; }; template concept WithParamsIsComplete = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult { impl.getIsComplete(std::move(params)) } }; + { service::FieldResult { impl.getIsComplete(std::move(params)) } }; }; template concept NoParamsIsComplete = requires (TImpl impl) { - { service::FieldResult { impl.getIsComplete() } }; + { service::FieldResult { impl.getIsComplete() } }; }; template @@ -793,25 +793,25 @@ concept NoParamsId = requires (TImpl impl) template concept WithParamsName = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult> { impl.getName(std::move(params)) } }; + { service::FieldResult> { impl.getName(std::move(params)) } }; }; template concept NoParamsName = requires (TImpl impl) { - { service::FieldResult> { impl.getName() } }; + { service::FieldResult> { impl.getName() } }; }; template concept WithParamsUnreadCount = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult { impl.getUnreadCount(std::move(params)) } }; + { service::FieldResult { impl.getUnreadCount(std::move(params)) } }; }; template concept NoParamsUnreadCount = requires (TImpl impl) { - { service::FieldResult { impl.getUnreadCount() } }; + { service::FieldResult { impl.getUnreadCount() } }; }; template @@ -833,13 +833,13 @@ namespace NestedTypeMethod { template concept WithParamsDepth = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult { impl.getDepth(std::move(params)) } }; + { service::FieldResult { impl.getDepth(std::move(params)) } }; }; template concept NoParamsDepth = requires (TImpl impl) { - { service::FieldResult { impl.getDepth() } }; + { service::FieldResult { impl.getDepth() } }; }; template @@ -873,13 +873,13 @@ namespace ExpensiveMethod { template concept WithParamsOrder = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult { impl.getOrder(std::move(params)) } }; + { service::FieldResult { impl.getOrder(std::move(params)) } }; }; template concept NoParamsOrder = requires (TImpl impl) { - { service::FieldResult { impl.getOrder() } }; + { service::FieldResult { impl.getOrder() } }; }; template @@ -924,14 +924,14 @@ class Query virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; virtual service::FieldResult> getNode(service::FieldParams&& params, response::IdType&& idArg) const = 0; - virtual service::FieldResult> getAppointments(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const = 0; - virtual service::FieldResult> getTasks(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const = 0; - virtual service::FieldResult> getUnreadCounts(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const = 0; + virtual service::FieldResult> getAppointments(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const = 0; + virtual service::FieldResult> getTasks(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const = 0; + virtual service::FieldResult> getUnreadCounts(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const = 0; virtual service::FieldResult>> getAppointmentsById(service::FieldParams&& params, std::vector&& idsArg) const = 0; virtual service::FieldResult>> getTasksById(service::FieldParams&& params, std::vector&& idsArg) const = 0; virtual service::FieldResult>> getUnreadCountsById(service::FieldParams&& params, std::vector&& idsArg) const = 0; virtual service::FieldResult> getNested(service::FieldParams&& params) const = 0; - virtual service::FieldResult getUnimplemented(service::FieldParams&& params) const = 0; + virtual service::FieldResult getUnimplemented(service::FieldParams&& params) const = 0; virtual service::FieldResult>> getExpensive(service::FieldParams&& params) const = 0; virtual service::FieldResult getTestTaskState(service::FieldParams&& params) const = 0; virtual service::FieldResult>> getAnyType(service::FieldParams&& params, std::vector&& idsArg) const = 0; @@ -962,7 +962,7 @@ class Query } } - service::FieldResult> getAppointments(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const final + service::FieldResult> getAppointments(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const final { if constexpr (methods::QueryMethod::WithParamsAppointments) { @@ -978,7 +978,7 @@ class Query } } - service::FieldResult> getTasks(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const final + service::FieldResult> getTasks(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const final { if constexpr (methods::QueryMethod::WithParamsTasks) { @@ -994,7 +994,7 @@ class Query } } - service::FieldResult> getUnreadCounts(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const final + service::FieldResult> getUnreadCounts(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const final { if constexpr (methods::QueryMethod::WithParamsUnreadCounts) { @@ -1074,7 +1074,7 @@ class Query } } - service::FieldResult getUnimplemented(service::FieldParams&& params) const final + service::FieldResult getUnimplemented(service::FieldParams&& params) const final { if constexpr (methods::QueryMethod::WithParamsUnimplemented) { @@ -1189,8 +1189,8 @@ class PageInfo virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual service::FieldResult getHasNextPage(service::FieldParams&& params) const = 0; - virtual service::FieldResult getHasPreviousPage(service::FieldParams&& params) const = 0; + virtual service::FieldResult getHasNextPage(service::FieldParams&& params) const = 0; + virtual service::FieldResult getHasPreviousPage(service::FieldParams&& params) const = 0; }; template @@ -1202,7 +1202,7 @@ class PageInfo { } - service::FieldResult getHasNextPage(service::FieldParams&& params) const final + service::FieldResult getHasNextPage(service::FieldParams&& params) const final { if constexpr (methods::PageInfoMethod::WithParamsHasNextPage) { @@ -1218,7 +1218,7 @@ class PageInfo } } - service::FieldResult getHasPreviousPage(service::FieldParams&& params) const final + service::FieldResult getHasPreviousPage(service::FieldParams&& params) const final { if constexpr (methods::PageInfoMethod::WithParamsHasPreviousPage) { @@ -1862,7 +1862,7 @@ class CompleteTaskPayload virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; virtual service::FieldResult> getTask(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getClientMutationId(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getClientMutationId(service::FieldParams&& params) const = 0; }; template @@ -1890,7 +1890,7 @@ class CompleteTaskPayload } } - service::FieldResult> getClientMutationId(service::FieldParams&& params) const final + service::FieldResult> getClientMutationId(service::FieldParams&& params) const final { if constexpr (methods::CompleteTaskPayloadMethod::WithParamsClientMutationId) { @@ -1958,7 +1958,7 @@ class Mutation virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; virtual service::FieldResult> applyCompleteTask(service::FieldParams&& params, CompleteTaskInput&& inputArg) const = 0; - virtual service::FieldResult applySetFloat(service::FieldParams&& params, response::FloatType&& valueArg) const = 0; + virtual service::FieldResult applySetFloat(service::FieldParams&& params, double&& valueArg) const = 0; }; template @@ -1986,7 +1986,7 @@ class Mutation } } - service::FieldResult applySetFloat(service::FieldParams&& params, response::FloatType&& valueArg) const final + service::FieldResult applySetFloat(service::FieldParams&& params, double&& valueArg) const final { if constexpr (methods::MutationMethod::WithParamsSetFloat) { @@ -2154,9 +2154,9 @@ class Appointment virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; virtual service::FieldResult> getWhen(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getSubject(service::FieldParams&& params) const = 0; - virtual service::FieldResult getIsNow(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getForceError(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getSubject(service::FieldParams&& params) const = 0; + virtual service::FieldResult getIsNow(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getForceError(service::FieldParams&& params) const = 0; }; template @@ -2200,7 +2200,7 @@ class Appointment } } - service::FieldResult> getSubject(service::FieldParams&& params) const final + service::FieldResult> getSubject(service::FieldParams&& params) const final { if constexpr (methods::AppointmentMethod::WithParamsSubject) { @@ -2216,7 +2216,7 @@ class Appointment } } - service::FieldResult getIsNow(service::FieldParams&& params) const final + service::FieldResult getIsNow(service::FieldParams&& params) const final { if constexpr (methods::AppointmentMethod::WithParamsIsNow) { @@ -2232,7 +2232,7 @@ class Appointment } } - service::FieldResult> getForceError(service::FieldParams&& params) const final + service::FieldResult> getForceError(service::FieldParams&& params) const final { if constexpr (methods::AppointmentMethod::WithParamsForceError) { @@ -2301,8 +2301,8 @@ class Task virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual service::FieldResult> getTitle(service::FieldParams&& params) const = 0; - virtual service::FieldResult getIsComplete(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getTitle(service::FieldParams&& params) const = 0; + virtual service::FieldResult getIsComplete(service::FieldParams&& params) const = 0; }; template @@ -2330,7 +2330,7 @@ class Task } } - service::FieldResult> getTitle(service::FieldParams&& params) const final + service::FieldResult> getTitle(service::FieldParams&& params) const final { if constexpr (methods::TaskMethod::WithParamsTitle) { @@ -2346,7 +2346,7 @@ class Task } } - service::FieldResult getIsComplete(service::FieldParams&& params) const final + service::FieldResult getIsComplete(service::FieldParams&& params) const final { if constexpr (methods::TaskMethod::WithParamsIsComplete) { @@ -2415,8 +2415,8 @@ class Folder virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual service::FieldResult> getName(service::FieldParams&& params) const = 0; - virtual service::FieldResult getUnreadCount(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getName(service::FieldParams&& params) const = 0; + virtual service::FieldResult getUnreadCount(service::FieldParams&& params) const = 0; }; template @@ -2444,7 +2444,7 @@ class Folder } } - service::FieldResult> getName(service::FieldParams&& params) const final + service::FieldResult> getName(service::FieldParams&& params) const final { if constexpr (methods::FolderMethod::WithParamsName) { @@ -2460,7 +2460,7 @@ class Folder } } - service::FieldResult getUnreadCount(service::FieldParams&& params) const final + service::FieldResult getUnreadCount(service::FieldParams&& params) const final { if constexpr (methods::FolderMethod::WithParamsUnreadCount) { @@ -2527,7 +2527,7 @@ class NestedType virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual service::FieldResult getDepth(service::FieldParams&& params) const = 0; + virtual service::FieldResult getDepth(service::FieldParams&& params) const = 0; virtual service::FieldResult> getNested(service::FieldParams&& params) const = 0; }; @@ -2540,7 +2540,7 @@ class NestedType { } - service::FieldResult getDepth(service::FieldParams&& params) const final + service::FieldResult getDepth(service::FieldParams&& params) const final { if constexpr (methods::NestedTypeMethod::WithParamsDepth) { @@ -2622,7 +2622,7 @@ class Expensive virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual service::FieldResult getOrder(service::FieldParams&& params) const = 0; + virtual service::FieldResult getOrder(service::FieldParams&& params) const = 0; }; template @@ -2634,7 +2634,7 @@ class Expensive { } - service::FieldResult getOrder(service::FieldParams&& params) const final + service::FieldResult getOrder(service::FieldParams&& params) const final { if constexpr (methods::ExpensiveMethod::WithParamsOrder) { diff --git a/samples/validation/ValidationSchema.cpp b/samples/validation/ValidationSchema.cpp index 68e464f8..9753cb91 100644 --- a/samples/validation/ValidationSchema.cpp +++ b/samples/validation/ValidationSchema.cpp @@ -35,7 +35,7 @@ validation::DogCommand ModifiedArgument::convert(const r throw service::schema_exception { { "not a valid DogCommand value" } }; } - const auto itr = std::find(s_namesDogCommand.cbegin(), s_namesDogCommand.cend(), value.get()); + const auto itr = std::find(s_namesDogCommand.cbegin(), s_namesDogCommand.cend(), value.get()); if (itr == s_namesDogCommand.cend()) { @@ -53,7 +53,7 @@ service::AwaitableResolver ModifiedResult::convert(servi { response::Value result(response::Type::EnumValue); - result.set(response::StringType { s_namesDogCommand[static_cast(value)] }); + result.set(std::string { s_namesDogCommand[static_cast(value)] }); return result; }); @@ -71,7 +71,7 @@ validation::CatCommand ModifiedArgument::convert(const r throw service::schema_exception { { "not a valid CatCommand value" } }; } - const auto itr = std::find(s_namesCatCommand.cbegin(), s_namesCatCommand.cend(), value.get()); + const auto itr = std::find(s_namesCatCommand.cbegin(), s_namesCatCommand.cend(), value.get()); if (itr == s_namesCatCommand.cend()) { @@ -89,7 +89,7 @@ service::AwaitableResolver ModifiedResult::convert(servi { response::Value result(response::Type::EnumValue); - result.set(response::StringType { s_namesCatCommand[static_cast(value)] }); + result.set(std::string { s_namesCatCommand[static_cast(value)] }); return result; }); @@ -98,8 +98,8 @@ service::AwaitableResolver ModifiedResult::convert(servi template <> validation::ComplexInput ModifiedArgument::convert(const response::Value& value) { - auto valueName = service::ModifiedArgument::require("name", value); - auto valueOwner = service::ModifiedArgument::require("owner", value); + auto valueName = service::ModifiedArgument::require("name", value); + auto valueOwner = service::ModifiedArgument::require("owner", value); return { std::move(valueName), @@ -205,18 +205,18 @@ service::AwaitableResolver Query::resolveFindDog(service::ResolverParams&& param service::AwaitableResolver Query::resolveBooleanList(service::ResolverParams&& params) { - auto argBooleanListArg = service::ModifiedArgument::require("booleanListArg", params.arguments); + auto argBooleanListArg = service::ModifiedArgument::require("booleanListArg", params.arguments); std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); auto result = _pimpl->getBooleanList(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argBooleanListArg)); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } service::AwaitableResolver Query::resolve_typename(service::ResolverParams&& params) { - return service::ModifiedResult::convert(response::StringType{ R"gql(Query)gql" }, std::move(params)); + return service::ModifiedResult::convert(std::string{ R"gql(Query)gql" }, std::move(params)); } service::AwaitableResolver Query::resolve_schema(service::ResolverParams&& params) @@ -226,7 +226,7 @@ service::AwaitableResolver Query::resolve_schema(service::ResolverParams&& param service::AwaitableResolver Query::resolve_type(service::ResolverParams&& params) { - auto argName = service::ModifiedArgument::require("name", params.arguments); + auto argName = service::ModifiedArgument::require("name", params.arguments); const auto& baseType = _schema->LookupType(argName); std::shared_ptr result { baseType ? std::make_shared(std::make_shared(baseType)) : nullptr }; @@ -269,7 +269,7 @@ service::AwaitableResolver Dog::resolveName(service::ResolverParams&& params) auto result = _pimpl->getName(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } service::AwaitableResolver Dog::resolveNickname(service::ResolverParams&& params) @@ -279,7 +279,7 @@ service::AwaitableResolver Dog::resolveNickname(service::ResolverParams&& params auto result = _pimpl->getNickname(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } service::AwaitableResolver Dog::resolveBarkVolume(service::ResolverParams&& params) @@ -289,7 +289,7 @@ service::AwaitableResolver Dog::resolveBarkVolume(service::ResolverParams&& para auto result = _pimpl->getBarkVolume(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } service::AwaitableResolver Dog::resolveDoesKnowCommand(service::ResolverParams&& params) @@ -300,18 +300,18 @@ service::AwaitableResolver Dog::resolveDoesKnowCommand(service::ResolverParams&& auto result = _pimpl->getDoesKnowCommand(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argDogCommand)); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } service::AwaitableResolver Dog::resolveIsHousetrained(service::ResolverParams&& params) { - auto argAtOtherHomes = service::ModifiedArgument::require("atOtherHomes", params.arguments); + auto argAtOtherHomes = service::ModifiedArgument::require("atOtherHomes", params.arguments); std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); auto result = _pimpl->getIsHousetrained(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argAtOtherHomes)); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } service::AwaitableResolver Dog::resolveOwner(service::ResolverParams&& params) @@ -326,7 +326,7 @@ service::AwaitableResolver Dog::resolveOwner(service::ResolverParams&& params) service::AwaitableResolver Dog::resolve_typename(service::ResolverParams&& params) { - return service::ModifiedResult::convert(response::StringType{ R"gql(Dog)gql" }, std::move(params)); + return service::ModifiedResult::convert(std::string{ R"gql(Dog)gql" }, std::move(params)); } Alien::Alien(std::unique_ptr&& pimpl) @@ -360,7 +360,7 @@ service::AwaitableResolver Alien::resolveName(service::ResolverParams&& params) auto result = _pimpl->getName(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } service::AwaitableResolver Alien::resolveHomePlanet(service::ResolverParams&& params) @@ -370,12 +370,12 @@ service::AwaitableResolver Alien::resolveHomePlanet(service::ResolverParams&& pa auto result = _pimpl->getHomePlanet(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } service::AwaitableResolver Alien::resolve_typename(service::ResolverParams&& params) { - return service::ModifiedResult::convert(response::StringType{ R"gql(Alien)gql" }, std::move(params)); + return service::ModifiedResult::convert(std::string{ R"gql(Alien)gql" }, std::move(params)); } Human::Human(std::unique_ptr&& pimpl) @@ -410,7 +410,7 @@ service::AwaitableResolver Human::resolveName(service::ResolverParams&& params) auto result = _pimpl->getName(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } service::AwaitableResolver Human::resolvePets(service::ResolverParams&& params) @@ -425,7 +425,7 @@ service::AwaitableResolver Human::resolvePets(service::ResolverParams&& params) service::AwaitableResolver Human::resolve_typename(service::ResolverParams&& params) { - return service::ModifiedResult::convert(response::StringType{ R"gql(Human)gql" }, std::move(params)); + return service::ModifiedResult::convert(std::string{ R"gql(Human)gql" }, std::move(params)); } Cat::Cat(std::unique_ptr&& pimpl) @@ -461,7 +461,7 @@ service::AwaitableResolver Cat::resolveName(service::ResolverParams&& params) auto result = _pimpl->getName(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } service::AwaitableResolver Cat::resolveNickname(service::ResolverParams&& params) @@ -471,7 +471,7 @@ service::AwaitableResolver Cat::resolveNickname(service::ResolverParams&& params auto result = _pimpl->getNickname(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } service::AwaitableResolver Cat::resolveDoesKnowCommand(service::ResolverParams&& params) @@ -482,7 +482,7 @@ service::AwaitableResolver Cat::resolveDoesKnowCommand(service::ResolverParams&& auto result = _pimpl->getDoesKnowCommand(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argCatCommand)); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } service::AwaitableResolver Cat::resolveMeowVolume(service::ResolverParams&& params) @@ -492,12 +492,12 @@ service::AwaitableResolver Cat::resolveMeowVolume(service::ResolverParams&& para auto result = _pimpl->getMeowVolume(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } service::AwaitableResolver Cat::resolve_typename(service::ResolverParams&& params) { - return service::ModifiedResult::convert(response::StringType{ R"gql(Cat)gql" }, std::move(params)); + return service::ModifiedResult::convert(std::string{ R"gql(Cat)gql" }, std::move(params)); } Mutation::Mutation(std::unique_ptr&& pimpl) @@ -533,7 +533,7 @@ service::AwaitableResolver Mutation::resolveMutateDog(service::ResolverParams&& service::AwaitableResolver Mutation::resolve_typename(service::ResolverParams&& params) { - return service::ModifiedResult::convert(response::StringType{ R"gql(Mutation)gql" }, std::move(params)); + return service::ModifiedResult::convert(std::string{ R"gql(Mutation)gql" }, std::move(params)); } MutateDogResult::MutateDogResult(std::unique_ptr&& pimpl) @@ -569,7 +569,7 @@ service::AwaitableResolver MutateDogResult::resolveId(service::ResolverParams&& service::AwaitableResolver MutateDogResult::resolve_typename(service::ResolverParams&& params) { - return service::ModifiedResult::convert(response::StringType{ R"gql(MutateDogResult)gql" }, std::move(params)); + return service::ModifiedResult::convert(std::string{ R"gql(MutateDogResult)gql" }, std::move(params)); } Subscription::Subscription(std::unique_ptr&& pimpl) @@ -611,12 +611,12 @@ service::AwaitableResolver Subscription::resolveDisallowedSecondRootField(servic auto result = _pimpl->getDisallowedSecondRootField(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } service::AwaitableResolver Subscription::resolve_typename(service::ResolverParams&& params) { - return service::ModifiedResult::convert(response::StringType{ R"gql(Subscription)gql" }, std::move(params)); + return service::ModifiedResult::convert(std::string{ R"gql(Subscription)gql" }, std::move(params)); } Message::Message(std::unique_ptr&& pimpl) @@ -648,7 +648,7 @@ service::AwaitableResolver Message::resolveBody(service::ResolverParams&& params auto result = _pimpl->getBody(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } service::AwaitableResolver Message::resolveSender(service::ResolverParams&& params) @@ -663,7 +663,7 @@ service::AwaitableResolver Message::resolveSender(service::ResolverParams&& para service::AwaitableResolver Message::resolve_typename(service::ResolverParams&& params) { - return service::ModifiedResult::convert(response::StringType{ R"gql(Message)gql" }, std::move(params)); + return service::ModifiedResult::convert(std::string{ R"gql(Message)gql" }, std::move(params)); } Arguments::Arguments(std::unique_ptr&& pimpl) @@ -696,80 +696,80 @@ void Arguments::endSelectionSet(const service::SelectionSetParams& params) const service::AwaitableResolver Arguments::resolveMultipleReqs(service::ResolverParams&& params) { - auto argX = service::ModifiedArgument::require("x", params.arguments); - auto argY = service::ModifiedArgument::require("y", params.arguments); + auto argX = service::ModifiedArgument::require("x", params.arguments); + auto argY = service::ModifiedArgument::require("y", params.arguments); std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); auto result = _pimpl->getMultipleReqs(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argX), std::move(argY)); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } service::AwaitableResolver Arguments::resolveBooleanArgField(service::ResolverParams&& params) { - auto argBooleanArg = service::ModifiedArgument::require("booleanArg", params.arguments); + auto argBooleanArg = service::ModifiedArgument::require("booleanArg", params.arguments); std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); auto result = _pimpl->getBooleanArgField(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argBooleanArg)); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } service::AwaitableResolver Arguments::resolveFloatArgField(service::ResolverParams&& params) { - auto argFloatArg = service::ModifiedArgument::require("floatArg", params.arguments); + auto argFloatArg = service::ModifiedArgument::require("floatArg", params.arguments); std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); auto result = _pimpl->getFloatArgField(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argFloatArg)); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } service::AwaitableResolver Arguments::resolveIntArgField(service::ResolverParams&& params) { - auto argIntArg = service::ModifiedArgument::require("intArg", params.arguments); + auto argIntArg = service::ModifiedArgument::require("intArg", params.arguments); std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); auto result = _pimpl->getIntArgField(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argIntArg)); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } service::AwaitableResolver Arguments::resolveNonNullBooleanArgField(service::ResolverParams&& params) { - auto argNonNullBooleanArg = service::ModifiedArgument::require("nonNullBooleanArg", params.arguments); + auto argNonNullBooleanArg = service::ModifiedArgument::require("nonNullBooleanArg", params.arguments); std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); auto result = _pimpl->getNonNullBooleanArgField(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argNonNullBooleanArg)); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } service::AwaitableResolver Arguments::resolveNonNullBooleanListField(service::ResolverParams&& params) { - auto argNonNullBooleanListArg = service::ModifiedArgument::require("nonNullBooleanListArg", params.arguments); + auto argNonNullBooleanListArg = service::ModifiedArgument::require("nonNullBooleanListArg", params.arguments); std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); auto result = _pimpl->getNonNullBooleanListField(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argNonNullBooleanListArg)); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } service::AwaitableResolver Arguments::resolveBooleanListArgField(service::ResolverParams&& params) { - auto argBooleanListArg = service::ModifiedArgument::require("booleanListArg", params.arguments); + auto argBooleanListArg = service::ModifiedArgument::require("booleanListArg", params.arguments); std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); auto result = _pimpl->getBooleanListArgField(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argBooleanListArg)); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } service::AwaitableResolver Arguments::resolveOptionalNonNullBooleanArgField(service::ResolverParams&& params) @@ -785,21 +785,21 @@ service::AwaitableResolver Arguments::resolveOptionalNonNullBooleanArgField(serv return values; }(); - auto pairOptionalBooleanArg = service::ModifiedArgument::find("optionalBooleanArg", params.arguments); + auto pairOptionalBooleanArg = service::ModifiedArgument::find("optionalBooleanArg", params.arguments); auto argOptionalBooleanArg = (pairOptionalBooleanArg.second ? std::move(pairOptionalBooleanArg.first) - : service::ModifiedArgument::require("optionalBooleanArg", defaultArguments)); + : service::ModifiedArgument::require("optionalBooleanArg", defaultArguments)); std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); auto result = _pimpl->getOptionalNonNullBooleanArgField(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argOptionalBooleanArg)); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } service::AwaitableResolver Arguments::resolve_typename(service::ResolverParams&& params) { - return service::ModifiedResult::convert(response::StringType{ R"gql(Arguments)gql" }, std::move(params)); + return service::ModifiedResult::convert(std::string{ R"gql(Arguments)gql" }, std::move(params)); } } // namespace object diff --git a/samples/validation/ValidationSchema.h b/samples/validation/ValidationSchema.h index d8b0876e..1aeae68c 100644 --- a/samples/validation/ValidationSchema.h +++ b/samples/validation/ValidationSchema.h @@ -35,8 +35,8 @@ enum class CatCommand struct ComplexInput { - std::optional name; - std::optional owner; + std::optional name; + std::optional owner; }; namespace object { @@ -59,12 +59,12 @@ struct Pet; struct Sentient { - virtual service::FieldResult getName(service::FieldParams&& params) const = 0; + virtual service::FieldResult getName(service::FieldParams&& params) const = 0; }; struct Pet { - virtual service::FieldResult getName(service::FieldParams&& params) const = 0; + virtual service::FieldResult getName(service::FieldParams&& params) const = 0; }; namespace object { @@ -144,15 +144,15 @@ concept NoParamsFindDog = requires (TImpl impl, std::optional comp }; template -concept WithParamsBooleanList = requires (TImpl impl, service::FieldParams params, std::optional> booleanListArgArg) +concept WithParamsBooleanList = requires (TImpl impl, service::FieldParams params, std::optional> booleanListArgArg) { - { service::FieldResult> { impl.getBooleanList(std::move(params), std::move(booleanListArgArg)) } }; + { service::FieldResult> { impl.getBooleanList(std::move(params), std::move(booleanListArgArg)) } }; }; template -concept NoParamsBooleanList = requires (TImpl impl, std::optional> booleanListArgArg) +concept NoParamsBooleanList = requires (TImpl impl, std::optional> booleanListArgArg) { - { service::FieldResult> { impl.getBooleanList(std::move(booleanListArgArg)) } }; + { service::FieldResult> { impl.getBooleanList(std::move(booleanListArgArg)) } }; }; template @@ -174,61 +174,61 @@ namespace DogMethod { template concept WithParamsName = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult { impl.getName(std::move(params)) } }; + { service::FieldResult { impl.getName(std::move(params)) } }; }; template concept NoParamsName = requires (TImpl impl) { - { service::FieldResult { impl.getName() } }; + { service::FieldResult { impl.getName() } }; }; template concept WithParamsNickname = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult> { impl.getNickname(std::move(params)) } }; + { service::FieldResult> { impl.getNickname(std::move(params)) } }; }; template concept NoParamsNickname = requires (TImpl impl) { - { service::FieldResult> { impl.getNickname() } }; + { service::FieldResult> { impl.getNickname() } }; }; template concept WithParamsBarkVolume = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult> { impl.getBarkVolume(std::move(params)) } }; + { service::FieldResult> { impl.getBarkVolume(std::move(params)) } }; }; template concept NoParamsBarkVolume = requires (TImpl impl) { - { service::FieldResult> { impl.getBarkVolume() } }; + { service::FieldResult> { impl.getBarkVolume() } }; }; template concept WithParamsDoesKnowCommand = requires (TImpl impl, service::FieldParams params, DogCommand dogCommandArg) { - { service::FieldResult { impl.getDoesKnowCommand(std::move(params), std::move(dogCommandArg)) } }; + { service::FieldResult { impl.getDoesKnowCommand(std::move(params), std::move(dogCommandArg)) } }; }; template concept NoParamsDoesKnowCommand = requires (TImpl impl, DogCommand dogCommandArg) { - { service::FieldResult { impl.getDoesKnowCommand(std::move(dogCommandArg)) } }; + { service::FieldResult { impl.getDoesKnowCommand(std::move(dogCommandArg)) } }; }; template -concept WithParamsIsHousetrained = requires (TImpl impl, service::FieldParams params, std::optional atOtherHomesArg) +concept WithParamsIsHousetrained = requires (TImpl impl, service::FieldParams params, std::optional atOtherHomesArg) { - { service::FieldResult { impl.getIsHousetrained(std::move(params), std::move(atOtherHomesArg)) } }; + { service::FieldResult { impl.getIsHousetrained(std::move(params), std::move(atOtherHomesArg)) } }; }; template -concept NoParamsIsHousetrained = requires (TImpl impl, std::optional atOtherHomesArg) +concept NoParamsIsHousetrained = requires (TImpl impl, std::optional atOtherHomesArg) { - { service::FieldResult { impl.getIsHousetrained(std::move(atOtherHomesArg)) } }; + { service::FieldResult { impl.getIsHousetrained(std::move(atOtherHomesArg)) } }; }; template @@ -262,25 +262,25 @@ namespace AlienMethod { template concept WithParamsName = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult { impl.getName(std::move(params)) } }; + { service::FieldResult { impl.getName(std::move(params)) } }; }; template concept NoParamsName = requires (TImpl impl) { - { service::FieldResult { impl.getName() } }; + { service::FieldResult { impl.getName() } }; }; template concept WithParamsHomePlanet = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult> { impl.getHomePlanet(std::move(params)) } }; + { service::FieldResult> { impl.getHomePlanet(std::move(params)) } }; }; template concept NoParamsHomePlanet = requires (TImpl impl) { - { service::FieldResult> { impl.getHomePlanet() } }; + { service::FieldResult> { impl.getHomePlanet() } }; }; template @@ -302,13 +302,13 @@ namespace HumanMethod { template concept WithParamsName = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult { impl.getName(std::move(params)) } }; + { service::FieldResult { impl.getName(std::move(params)) } }; }; template concept NoParamsName = requires (TImpl impl) { - { service::FieldResult { impl.getName() } }; + { service::FieldResult { impl.getName() } }; }; template @@ -342,49 +342,49 @@ namespace CatMethod { template concept WithParamsName = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult { impl.getName(std::move(params)) } }; + { service::FieldResult { impl.getName(std::move(params)) } }; }; template concept NoParamsName = requires (TImpl impl) { - { service::FieldResult { impl.getName() } }; + { service::FieldResult { impl.getName() } }; }; template concept WithParamsNickname = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult> { impl.getNickname(std::move(params)) } }; + { service::FieldResult> { impl.getNickname(std::move(params)) } }; }; template concept NoParamsNickname = requires (TImpl impl) { - { service::FieldResult> { impl.getNickname() } }; + { service::FieldResult> { impl.getNickname() } }; }; template concept WithParamsDoesKnowCommand = requires (TImpl impl, service::FieldParams params, CatCommand catCommandArg) { - { service::FieldResult { impl.getDoesKnowCommand(std::move(params), std::move(catCommandArg)) } }; + { service::FieldResult { impl.getDoesKnowCommand(std::move(params), std::move(catCommandArg)) } }; }; template concept NoParamsDoesKnowCommand = requires (TImpl impl, CatCommand catCommandArg) { - { service::FieldResult { impl.getDoesKnowCommand(std::move(catCommandArg)) } }; + { service::FieldResult { impl.getDoesKnowCommand(std::move(catCommandArg)) } }; }; template concept WithParamsMeowVolume = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult> { impl.getMeowVolume(std::move(params)) } }; + { service::FieldResult> { impl.getMeowVolume(std::move(params)) } }; }; template concept NoParamsMeowVolume = requires (TImpl impl) { - { service::FieldResult> { impl.getMeowVolume() } }; + { service::FieldResult> { impl.getMeowVolume() } }; }; template @@ -474,13 +474,13 @@ concept NoParamsNewMessage = requires (TImpl impl) template concept WithParamsDisallowedSecondRootField = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult { impl.getDisallowedSecondRootField(std::move(params)) } }; + { service::FieldResult { impl.getDisallowedSecondRootField(std::move(params)) } }; }; template concept NoParamsDisallowedSecondRootField = requires (TImpl impl) { - { service::FieldResult { impl.getDisallowedSecondRootField() } }; + { service::FieldResult { impl.getDisallowedSecondRootField() } }; }; template @@ -502,13 +502,13 @@ namespace MessageMethod { template concept WithParamsBody = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult> { impl.getBody(std::move(params)) } }; + { service::FieldResult> { impl.getBody(std::move(params)) } }; }; template concept NoParamsBody = requires (TImpl impl) { - { service::FieldResult> { impl.getBody() } }; + { service::FieldResult> { impl.getBody() } }; }; template @@ -540,99 +540,99 @@ concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetPa namespace ArgumentsMethod { template -concept WithParamsMultipleReqs = requires (TImpl impl, service::FieldParams params, response::IntType xArg, response::IntType yArg) +concept WithParamsMultipleReqs = requires (TImpl impl, service::FieldParams params, int xArg, int yArg) { - { service::FieldResult { impl.getMultipleReqs(std::move(params), std::move(xArg), std::move(yArg)) } }; + { service::FieldResult { impl.getMultipleReqs(std::move(params), std::move(xArg), std::move(yArg)) } }; }; template -concept NoParamsMultipleReqs = requires (TImpl impl, response::IntType xArg, response::IntType yArg) +concept NoParamsMultipleReqs = requires (TImpl impl, int xArg, int yArg) { - { service::FieldResult { impl.getMultipleReqs(std::move(xArg), std::move(yArg)) } }; + { service::FieldResult { impl.getMultipleReqs(std::move(xArg), std::move(yArg)) } }; }; template -concept WithParamsBooleanArgField = requires (TImpl impl, service::FieldParams params, std::optional booleanArgArg) +concept WithParamsBooleanArgField = requires (TImpl impl, service::FieldParams params, std::optional booleanArgArg) { - { service::FieldResult> { impl.getBooleanArgField(std::move(params), std::move(booleanArgArg)) } }; + { service::FieldResult> { impl.getBooleanArgField(std::move(params), std::move(booleanArgArg)) } }; }; template -concept NoParamsBooleanArgField = requires (TImpl impl, std::optional booleanArgArg) +concept NoParamsBooleanArgField = requires (TImpl impl, std::optional booleanArgArg) { - { service::FieldResult> { impl.getBooleanArgField(std::move(booleanArgArg)) } }; + { service::FieldResult> { impl.getBooleanArgField(std::move(booleanArgArg)) } }; }; template -concept WithParamsFloatArgField = requires (TImpl impl, service::FieldParams params, std::optional floatArgArg) +concept WithParamsFloatArgField = requires (TImpl impl, service::FieldParams params, std::optional floatArgArg) { - { service::FieldResult> { impl.getFloatArgField(std::move(params), std::move(floatArgArg)) } }; + { service::FieldResult> { impl.getFloatArgField(std::move(params), std::move(floatArgArg)) } }; }; template -concept NoParamsFloatArgField = requires (TImpl impl, std::optional floatArgArg) +concept NoParamsFloatArgField = requires (TImpl impl, std::optional floatArgArg) { - { service::FieldResult> { impl.getFloatArgField(std::move(floatArgArg)) } }; + { service::FieldResult> { impl.getFloatArgField(std::move(floatArgArg)) } }; }; template -concept WithParamsIntArgField = requires (TImpl impl, service::FieldParams params, std::optional intArgArg) +concept WithParamsIntArgField = requires (TImpl impl, service::FieldParams params, std::optional intArgArg) { - { service::FieldResult> { impl.getIntArgField(std::move(params), std::move(intArgArg)) } }; + { service::FieldResult> { impl.getIntArgField(std::move(params), std::move(intArgArg)) } }; }; template -concept NoParamsIntArgField = requires (TImpl impl, std::optional intArgArg) +concept NoParamsIntArgField = requires (TImpl impl, std::optional intArgArg) { - { service::FieldResult> { impl.getIntArgField(std::move(intArgArg)) } }; + { service::FieldResult> { impl.getIntArgField(std::move(intArgArg)) } }; }; template -concept WithParamsNonNullBooleanArgField = requires (TImpl impl, service::FieldParams params, response::BooleanType nonNullBooleanArgArg) +concept WithParamsNonNullBooleanArgField = requires (TImpl impl, service::FieldParams params, bool nonNullBooleanArgArg) { - { service::FieldResult { impl.getNonNullBooleanArgField(std::move(params), std::move(nonNullBooleanArgArg)) } }; + { service::FieldResult { impl.getNonNullBooleanArgField(std::move(params), std::move(nonNullBooleanArgArg)) } }; }; template -concept NoParamsNonNullBooleanArgField = requires (TImpl impl, response::BooleanType nonNullBooleanArgArg) +concept NoParamsNonNullBooleanArgField = requires (TImpl impl, bool nonNullBooleanArgArg) { - { service::FieldResult { impl.getNonNullBooleanArgField(std::move(nonNullBooleanArgArg)) } }; + { service::FieldResult { impl.getNonNullBooleanArgField(std::move(nonNullBooleanArgArg)) } }; }; template -concept WithParamsNonNullBooleanListField = requires (TImpl impl, service::FieldParams params, std::optional> nonNullBooleanListArgArg) +concept WithParamsNonNullBooleanListField = requires (TImpl impl, service::FieldParams params, std::optional> nonNullBooleanListArgArg) { - { service::FieldResult>> { impl.getNonNullBooleanListField(std::move(params), std::move(nonNullBooleanListArgArg)) } }; + { service::FieldResult>> { impl.getNonNullBooleanListField(std::move(params), std::move(nonNullBooleanListArgArg)) } }; }; template -concept NoParamsNonNullBooleanListField = requires (TImpl impl, std::optional> nonNullBooleanListArgArg) +concept NoParamsNonNullBooleanListField = requires (TImpl impl, std::optional> nonNullBooleanListArgArg) { - { service::FieldResult>> { impl.getNonNullBooleanListField(std::move(nonNullBooleanListArgArg)) } }; + { service::FieldResult>> { impl.getNonNullBooleanListField(std::move(nonNullBooleanListArgArg)) } }; }; template -concept WithParamsBooleanListArgField = requires (TImpl impl, service::FieldParams params, std::vector> booleanListArgArg) +concept WithParamsBooleanListArgField = requires (TImpl impl, service::FieldParams params, std::vector> booleanListArgArg) { - { service::FieldResult>>> { impl.getBooleanListArgField(std::move(params), std::move(booleanListArgArg)) } }; + { service::FieldResult>>> { impl.getBooleanListArgField(std::move(params), std::move(booleanListArgArg)) } }; }; template -concept NoParamsBooleanListArgField = requires (TImpl impl, std::vector> booleanListArgArg) +concept NoParamsBooleanListArgField = requires (TImpl impl, std::vector> booleanListArgArg) { - { service::FieldResult>>> { impl.getBooleanListArgField(std::move(booleanListArgArg)) } }; + { service::FieldResult>>> { impl.getBooleanListArgField(std::move(booleanListArgArg)) } }; }; template -concept WithParamsOptionalNonNullBooleanArgField = requires (TImpl impl, service::FieldParams params, response::BooleanType optionalBooleanArgArg) +concept WithParamsOptionalNonNullBooleanArgField = requires (TImpl impl, service::FieldParams params, bool optionalBooleanArgArg) { - { service::FieldResult { impl.getOptionalNonNullBooleanArgField(std::move(params), std::move(optionalBooleanArgArg)) } }; + { service::FieldResult { impl.getOptionalNonNullBooleanArgField(std::move(params), std::move(optionalBooleanArgArg)) } }; }; template -concept NoParamsOptionalNonNullBooleanArgField = requires (TImpl impl, response::BooleanType optionalBooleanArgArg) +concept NoParamsOptionalNonNullBooleanArgField = requires (TImpl impl, bool optionalBooleanArgArg) { - { service::FieldResult { impl.getOptionalNonNullBooleanArgField(std::move(optionalBooleanArgArg)) } }; + { service::FieldResult { impl.getOptionalNonNullBooleanArgField(std::move(optionalBooleanArgArg)) } }; }; template @@ -681,7 +681,7 @@ class Query virtual service::FieldResult> getCatOrDog(service::FieldParams&& params) const = 0; virtual service::FieldResult> getArguments(service::FieldParams&& params) const = 0; virtual service::FieldResult> getFindDog(service::FieldParams&& params, std::optional&& complexArg) const = 0; - virtual service::FieldResult> getBooleanList(service::FieldParams&& params, std::optional>&& booleanListArgArg) const = 0; + virtual service::FieldResult> getBooleanList(service::FieldParams&& params, std::optional>&& booleanListArgArg) const = 0; }; template @@ -789,7 +789,7 @@ class Query } } - service::FieldResult> getBooleanList(service::FieldParams&& params, std::optional>&& booleanListArgArg) const final + service::FieldResult> getBooleanList(service::FieldParams&& params, std::optional>&& booleanListArgArg) const final { if constexpr (methods::QueryMethod::WithParamsBooleanList) { @@ -861,10 +861,10 @@ class Dog virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual service::FieldResult> getNickname(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getBarkVolume(service::FieldParams&& params) const = 0; - virtual service::FieldResult getDoesKnowCommand(service::FieldParams&& params, DogCommand&& dogCommandArg) const = 0; - virtual service::FieldResult getIsHousetrained(service::FieldParams&& params, std::optional&& atOtherHomesArg) const = 0; + virtual service::FieldResult> getNickname(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getBarkVolume(service::FieldParams&& params) const = 0; + virtual service::FieldResult getDoesKnowCommand(service::FieldParams&& params, DogCommand&& dogCommandArg) const = 0; + virtual service::FieldResult getIsHousetrained(service::FieldParams&& params, std::optional&& atOtherHomesArg) const = 0; virtual service::FieldResult> getOwner(service::FieldParams&& params) const = 0; }; @@ -877,7 +877,7 @@ class Dog { } - service::FieldResult getName(service::FieldParams&& params) const final + service::FieldResult getName(service::FieldParams&& params) const final { if constexpr (methods::DogMethod::WithParamsName) { @@ -893,7 +893,7 @@ class Dog } } - service::FieldResult> getNickname(service::FieldParams&& params) const final + service::FieldResult> getNickname(service::FieldParams&& params) const final { if constexpr (methods::DogMethod::WithParamsNickname) { @@ -909,7 +909,7 @@ class Dog } } - service::FieldResult> getBarkVolume(service::FieldParams&& params) const final + service::FieldResult> getBarkVolume(service::FieldParams&& params) const final { if constexpr (methods::DogMethod::WithParamsBarkVolume) { @@ -925,7 +925,7 @@ class Dog } } - service::FieldResult getDoesKnowCommand(service::FieldParams&& params, DogCommand&& dogCommandArg) const final + service::FieldResult getDoesKnowCommand(service::FieldParams&& params, DogCommand&& dogCommandArg) const final { if constexpr (methods::DogMethod::WithParamsDoesKnowCommand) { @@ -941,7 +941,7 @@ class Dog } } - service::FieldResult getIsHousetrained(service::FieldParams&& params, std::optional&& atOtherHomesArg) const final + service::FieldResult getIsHousetrained(service::FieldParams&& params, std::optional&& atOtherHomesArg) const final { if constexpr (methods::DogMethod::WithParamsIsHousetrained) { @@ -1025,7 +1025,7 @@ class Alien virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual service::FieldResult> getHomePlanet(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getHomePlanet(service::FieldParams&& params) const = 0; }; template @@ -1037,7 +1037,7 @@ class Alien { } - service::FieldResult getName(service::FieldParams&& params) const final + service::FieldResult getName(service::FieldParams&& params) const final { if constexpr (methods::AlienMethod::WithParamsName) { @@ -1053,7 +1053,7 @@ class Alien } } - service::FieldResult> getHomePlanet(service::FieldParams&& params) const final + service::FieldResult> getHomePlanet(service::FieldParams&& params) const final { if constexpr (methods::AlienMethod::WithParamsHomePlanet) { @@ -1133,7 +1133,7 @@ class Human { } - service::FieldResult getName(service::FieldParams&& params) const final + service::FieldResult getName(service::FieldParams&& params) const final { if constexpr (methods::HumanMethod::WithParamsName) { @@ -1219,9 +1219,9 @@ class Cat virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual service::FieldResult> getNickname(service::FieldParams&& params) const = 0; - virtual service::FieldResult getDoesKnowCommand(service::FieldParams&& params, CatCommand&& catCommandArg) const = 0; - virtual service::FieldResult> getMeowVolume(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getNickname(service::FieldParams&& params) const = 0; + virtual service::FieldResult getDoesKnowCommand(service::FieldParams&& params, CatCommand&& catCommandArg) const = 0; + virtual service::FieldResult> getMeowVolume(service::FieldParams&& params) const = 0; }; template @@ -1233,7 +1233,7 @@ class Cat { } - service::FieldResult getName(service::FieldParams&& params) const final + service::FieldResult getName(service::FieldParams&& params) const final { if constexpr (methods::CatMethod::WithParamsName) { @@ -1249,7 +1249,7 @@ class Cat } } - service::FieldResult> getNickname(service::FieldParams&& params) const final + service::FieldResult> getNickname(service::FieldParams&& params) const final { if constexpr (methods::CatMethod::WithParamsNickname) { @@ -1265,7 +1265,7 @@ class Cat } } - service::FieldResult getDoesKnowCommand(service::FieldParams&& params, CatCommand&& catCommandArg) const final + service::FieldResult getDoesKnowCommand(service::FieldParams&& params, CatCommand&& catCommandArg) const final { if constexpr (methods::CatMethod::WithParamsDoesKnowCommand) { @@ -1281,7 +1281,7 @@ class Cat } } - service::FieldResult> getMeowVolume(service::FieldParams&& params) const final + service::FieldResult> getMeowVolume(service::FieldParams&& params) const final { if constexpr (methods::CatMethod::WithParamsMeowVolume) { @@ -1505,7 +1505,7 @@ class Subscription virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; virtual service::FieldResult> getNewMessage(service::FieldParams&& params) const = 0; - virtual service::FieldResult getDisallowedSecondRootField(service::FieldParams&& params) const = 0; + virtual service::FieldResult getDisallowedSecondRootField(service::FieldParams&& params) const = 0; }; template @@ -1533,7 +1533,7 @@ class Subscription } } - service::FieldResult getDisallowedSecondRootField(service::FieldParams&& params) const final + service::FieldResult getDisallowedSecondRootField(service::FieldParams&& params) const final { if constexpr (methods::SubscriptionMethod::WithParamsDisallowedSecondRootField) { @@ -1600,7 +1600,7 @@ class Message virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual service::FieldResult> getBody(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getBody(service::FieldParams&& params) const = 0; virtual service::FieldResult getSender(service::FieldParams&& params) const = 0; }; @@ -1613,7 +1613,7 @@ class Message { } - service::FieldResult> getBody(service::FieldParams&& params) const final + service::FieldResult> getBody(service::FieldParams&& params) const final { if constexpr (methods::MessageMethod::WithParamsBody) { @@ -1702,14 +1702,14 @@ class Arguments virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual service::FieldResult getMultipleReqs(service::FieldParams&& params, response::IntType&& xArg, response::IntType&& yArg) const = 0; - virtual service::FieldResult> getBooleanArgField(service::FieldParams&& params, std::optional&& booleanArgArg) const = 0; - virtual service::FieldResult> getFloatArgField(service::FieldParams&& params, std::optional&& floatArgArg) const = 0; - virtual service::FieldResult> getIntArgField(service::FieldParams&& params, std::optional&& intArgArg) const = 0; - virtual service::FieldResult getNonNullBooleanArgField(service::FieldParams&& params, response::BooleanType&& nonNullBooleanArgArg) const = 0; - virtual service::FieldResult>> getNonNullBooleanListField(service::FieldParams&& params, std::optional>&& nonNullBooleanListArgArg) const = 0; - virtual service::FieldResult>>> getBooleanListArgField(service::FieldParams&& params, std::vector>&& booleanListArgArg) const = 0; - virtual service::FieldResult getOptionalNonNullBooleanArgField(service::FieldParams&& params, response::BooleanType&& optionalBooleanArgArg) const = 0; + virtual service::FieldResult getMultipleReqs(service::FieldParams&& params, int&& xArg, int&& yArg) const = 0; + virtual service::FieldResult> getBooleanArgField(service::FieldParams&& params, std::optional&& booleanArgArg) const = 0; + virtual service::FieldResult> getFloatArgField(service::FieldParams&& params, std::optional&& floatArgArg) const = 0; + virtual service::FieldResult> getIntArgField(service::FieldParams&& params, std::optional&& intArgArg) const = 0; + virtual service::FieldResult getNonNullBooleanArgField(service::FieldParams&& params, bool&& nonNullBooleanArgArg) const = 0; + virtual service::FieldResult>> getNonNullBooleanListField(service::FieldParams&& params, std::optional>&& nonNullBooleanListArgArg) const = 0; + virtual service::FieldResult>>> getBooleanListArgField(service::FieldParams&& params, std::vector>&& booleanListArgArg) const = 0; + virtual service::FieldResult getOptionalNonNullBooleanArgField(service::FieldParams&& params, bool&& optionalBooleanArgArg) const = 0; }; template @@ -1721,7 +1721,7 @@ class Arguments { } - service::FieldResult getMultipleReqs(service::FieldParams&& params, response::IntType&& xArg, response::IntType&& yArg) const final + service::FieldResult getMultipleReqs(service::FieldParams&& params, int&& xArg, int&& yArg) const final { if constexpr (methods::ArgumentsMethod::WithParamsMultipleReqs) { @@ -1737,7 +1737,7 @@ class Arguments } } - service::FieldResult> getBooleanArgField(service::FieldParams&& params, std::optional&& booleanArgArg) const final + service::FieldResult> getBooleanArgField(service::FieldParams&& params, std::optional&& booleanArgArg) const final { if constexpr (methods::ArgumentsMethod::WithParamsBooleanArgField) { @@ -1753,7 +1753,7 @@ class Arguments } } - service::FieldResult> getFloatArgField(service::FieldParams&& params, std::optional&& floatArgArg) const final + service::FieldResult> getFloatArgField(service::FieldParams&& params, std::optional&& floatArgArg) const final { if constexpr (methods::ArgumentsMethod::WithParamsFloatArgField) { @@ -1769,7 +1769,7 @@ class Arguments } } - service::FieldResult> getIntArgField(service::FieldParams&& params, std::optional&& intArgArg) const final + service::FieldResult> getIntArgField(service::FieldParams&& params, std::optional&& intArgArg) const final { if constexpr (methods::ArgumentsMethod::WithParamsIntArgField) { @@ -1785,7 +1785,7 @@ class Arguments } } - service::FieldResult getNonNullBooleanArgField(service::FieldParams&& params, response::BooleanType&& nonNullBooleanArgArg) const final + service::FieldResult getNonNullBooleanArgField(service::FieldParams&& params, bool&& nonNullBooleanArgArg) const final { if constexpr (methods::ArgumentsMethod::WithParamsNonNullBooleanArgField) { @@ -1801,7 +1801,7 @@ class Arguments } } - service::FieldResult>> getNonNullBooleanListField(service::FieldParams&& params, std::optional>&& nonNullBooleanListArgArg) const final + service::FieldResult>> getNonNullBooleanListField(service::FieldParams&& params, std::optional>&& nonNullBooleanListArgArg) const final { if constexpr (methods::ArgumentsMethod::WithParamsNonNullBooleanListField) { @@ -1817,7 +1817,7 @@ class Arguments } } - service::FieldResult>>> getBooleanListArgField(service::FieldParams&& params, std::vector>&& booleanListArgArg) const final + service::FieldResult>>> getBooleanListArgField(service::FieldParams&& params, std::vector>&& booleanListArgArg) const final { if constexpr (methods::ArgumentsMethod::WithParamsBooleanListArgField) { @@ -1833,7 +1833,7 @@ class Arguments } } - service::FieldResult getOptionalNonNullBooleanArgField(service::FieldParams&& params, response::BooleanType&& optionalBooleanArgArg) const final + service::FieldResult getOptionalNonNullBooleanArgField(service::FieldParams&& params, bool&& optionalBooleanArgArg) const final { if constexpr (methods::ArgumentsMethod::WithParamsOptionalNonNullBooleanArgField) { diff --git a/src/ClientGenerator.cpp b/src/ClientGenerator.cpp index 55b29fa3..5c293ee3 100644 --- a/src/ClientGenerator.cpp +++ b/src/ClientGenerator.cpp @@ -223,7 +223,8 @@ static_assert(graphql::internal::MinorVersion == )cpp" { pendingSeparator.reset(); - headerFile << R"cpp(enum class )cpp" << _schemaLoader.getCppType(enumType->name()) << R"cpp( + headerFile << R"cpp(enum class )cpp" << _schemaLoader.getCppType(enumType->name()) + << R"cpp( { )cpp"; for (const auto& enumValue : enumType->enumValues()) @@ -451,8 +452,8 @@ bool Generator::outputSource() const noexcept #include #include -#include #include +#include #include using namespace std::literals; @@ -512,7 +513,7 @@ response::Value ModifiedVariable<)cpp" { response::Value result { response::Type::EnumValue }; - result.set(response::StringType { s_names)cpp" + result.set(std::string { s_names)cpp" << cppType << R"cpp([static_cast(value)] }); return result; @@ -577,7 +578,7 @@ response::Value ModifiedVariable()); + << R"cpp(.cend(), value.release()); if (itr == s_names)cpp" << cppType << R"cpp(.cend()) diff --git a/src/GeneratorLoader.cpp b/src/GeneratorLoader.cpp index 6e1edd6e..c57ed8fe 100644 --- a/src/GeneratorLoader.cpp +++ b/src/GeneratorLoader.cpp @@ -134,7 +134,7 @@ void DefaultValueVisitor::visitNullValue(const peg::ast_node& /*nullValue*/) void DefaultValueVisitor::visitEnumValue(const peg::ast_node& enumValue) { _value = response::Value(response::Type::EnumValue); - _value.set(enumValue.string()); + _value.set(enumValue.string()); } void DefaultValueVisitor::visitListValue(const peg::ast_node& listValue) diff --git a/src/GraphQLClient.cpp b/src/GraphQLClient.cpp index c7383991..b005c32b 100644 --- a/src/GraphQLClient.cpp +++ b/src/GraphQLClient.cpp @@ -21,7 +21,7 @@ ErrorLocation parseServiceErrorLocation(response::Value&& location) { if (member.second.type() == response::Type::Int) { - result.line = static_cast(member.second.get()); + result.line = static_cast(member.second.get()); } continue; @@ -31,7 +31,7 @@ ErrorLocation parseServiceErrorLocation(response::Value&& location) { if (member.second.type() == response::Type::Int) { - result.column = static_cast(member.second.get()); + result.column = static_cast(member.second.get()); } continue; @@ -44,16 +44,16 @@ ErrorLocation parseServiceErrorLocation(response::Value&& location) ErrorPathSegment parseServiceErrorPathSegment(response::Value&& segment) { - ErrorPathSegment result { response::IntType {} }; + ErrorPathSegment result { int {} }; switch (segment.type()) { case response::Type::Int: - result = segment.get(); + result = segment.get(); break; case response::Type::String: - result = segment.release(); + result = segment.release(); break; default: @@ -77,7 +77,7 @@ Error parseServiceError(response::Value&& error) { if (member.second.type() == response::Type::String) { - result.message = member.second.release(); + result.message = member.second.release(); } continue; @@ -93,10 +93,9 @@ Error parseServiceError(response::Value&& error) std::transform(locations.begin(), locations.end(), std::back_inserter(result.locations), - [](response::Value& location) - { - return parseServiceErrorLocation(std::move(location)); - }); + [](response::Value& location) { + return parseServiceErrorLocation(std::move(location)); + }); } continue; @@ -112,10 +111,9 @@ Error parseServiceError(response::Value&& error) std::transform(segments.begin(), segments.end(), std::back_inserter(result.path), - [](response::Value& segment) - { - return parseServiceErrorPathSegment(std::move(segment)); - }); + [](response::Value& segment) { + return parseServiceErrorPathSegment(std::move(segment)); + }); } continue; @@ -167,25 +165,25 @@ ServiceResponse parseServiceResponse(response::Value response) } template <> -response::Value ModifiedVariable::serialize(response::IntType&& value) +response::Value ModifiedVariable::serialize(int&& value) { return response::Value { value }; } template <> -response::Value ModifiedVariable::serialize(response::FloatType&& value) +response::Value ModifiedVariable::serialize(double&& value) { return response::Value { value }; } template <> -response::Value ModifiedVariable::serialize(response::StringType&& value) +response::Value ModifiedVariable::serialize(std::string&& value) { return response::Value { std::move(value) }; } template <> -response::Value ModifiedVariable::serialize(response::BooleanType&& value) +response::Value ModifiedVariable::serialize(bool&& value) { return response::Value { value }; } @@ -203,47 +201,47 @@ response::Value ModifiedVariable::serialize(response::IdType&& } template <> -response::IntType ModifiedResponse::parse(response::Value value) +int ModifiedResponse::parse(response::Value value) { if (value.type() != response::Type::Int) { throw std::logic_error { "not an integer" }; } - return value.get(); + return value.get(); } template <> -response::FloatType ModifiedResponse::parse(response::Value value) +double ModifiedResponse::parse(response::Value value) { if (value.type() != response::Type::Float && value.type() != response::Type::Int) { throw std::logic_error { "not a float" }; } - return value.get(); + return value.get(); } template <> -response::StringType ModifiedResponse::parse(response::Value value) +std::string ModifiedResponse::parse(response::Value value) { if (value.type() != response::Type::String) { throw std::logic_error { "not a string" }; } - return value.release(); + return value.release(); } template <> -response::BooleanType ModifiedResponse::parse(response::Value value) +bool ModifiedResponse::parse(response::Value value) { if (value.type() != response::Type::Boolean) { throw std::logic_error { "not a boolean" }; } - return value.get(); + return value.get(); } template <> diff --git a/src/GraphQLService.cpp b/src/GraphQLService.cpp index 22f51758..e40c98a2 100644 --- a/src/GraphQLService.cpp +++ b/src/GraphQLService.cpp @@ -30,9 +30,9 @@ void addErrorLocation(const schema_location& location, response::Value& error) errorLocation.reserve(2); errorLocation.emplace_back(std::string { strLine }, - response::Value(static_cast(location.line))); + response::Value(static_cast(location.line))); errorLocation.emplace_back(std::string { strColumn }, - response::Value(static_cast(location.column))); + response::Value(static_cast(location.column))); response::Value errorLocations(response::Type::List); @@ -61,8 +61,7 @@ void addErrorPath(const error_path& path, response::Value& error) } else if (std::holds_alternative(segment)) { - errorPath.emplace_back( - response::Value(static_cast(std::get(segment)))); + errorPath.emplace_back(response::Value(static_cast(std::get(segment)))); } } @@ -297,7 +296,7 @@ void ValueVisitor::visitNullValue(const peg::ast_node& /*nullValue*/) void ValueVisitor::visitEnumValue(const peg::ast_node& enumValue) { _value = response::Value(response::Type::EnumValue); - _value.set(enumValue.string()); + _value.set(enumValue.string()); } void ValueVisitor::visitListValue(const peg::ast_node& listValue) @@ -442,7 +441,7 @@ bool DirectiveVisitor::shouldSkip() const throw schema_exception { { error.str() } }; } - argumentTrue = argument.second.get(); + argumentTrue = argument.second.get(); argumentFalse = !argumentTrue; } @@ -519,47 +518,47 @@ schema_location ResolverParams::getLocation() const } template <> -response::IntType ModifiedArgument::convert(const response::Value& value) +int ModifiedArgument::convert(const response::Value& value) { if (value.type() != response::Type::Int) { throw schema_exception { { "not an integer" } }; } - return value.get(); + return value.get(); } template <> -response::FloatType ModifiedArgument::convert(const response::Value& value) +double ModifiedArgument::convert(const response::Value& value) { if (value.type() != response::Type::Float && value.type() != response::Type::Int) { throw schema_exception { { "not a float" } }; } - return value.get(); + return value.get(); } template <> -response::StringType ModifiedArgument::convert(const response::Value& value) +std::string ModifiedArgument::convert(const response::Value& value) { if (value.type() != response::Type::String) { throw schema_exception { { "not a string" } }; } - return value.get(); + return value.get(); } template <> -response::BooleanType ModifiedArgument::convert(const response::Value& value) +bool ModifiedArgument::convert(const response::Value& value) { if (value.type() != response::Type::Boolean) { throw schema_exception { { "not a boolean" } }; } - return value.get(); + return value.get(); } template <> @@ -627,55 +626,46 @@ void blockSubFields(const ResolverParams& params) } template <> -AwaitableResolver ModifiedResult::convert( - FieldResult result, ResolverParams params) +AwaitableResolver ModifiedResult::convert(FieldResult result, ResolverParams params) { blockSubFields(params); - return resolve(std::move(result), - std::move(params), - [](response::IntType&& value, const ResolverParams&) { - return response::Value(value); - }); + return resolve(std::move(result), std::move(params), [](int&& value, const ResolverParams&) { + return response::Value(value); + }); } template <> -AwaitableResolver ModifiedResult::convert( - FieldResult result, ResolverParams params) +AwaitableResolver ModifiedResult::convert(FieldResult result, ResolverParams params) { blockSubFields(params); - return resolve(std::move(result), - std::move(params), - [](response::FloatType&& value, const ResolverParams&) { - return response::Value(value); - }); + return resolve(std::move(result), std::move(params), [](double&& value, const ResolverParams&) { + return response::Value(value); + }); } template <> -AwaitableResolver ModifiedResult::convert( - FieldResult result, ResolverParams params) +AwaitableResolver ModifiedResult::convert( + FieldResult result, ResolverParams params) { blockSubFields(params); return resolve(std::move(result), std::move(params), - [](response::StringType&& value, const ResolverParams&) { + [](std::string&& value, const ResolverParams&) { return response::Value(std::move(value)); }); } template <> -AwaitableResolver ModifiedResult::convert( - FieldResult result, ResolverParams params) +AwaitableResolver ModifiedResult::convert(FieldResult result, ResolverParams params) { blockSubFields(params); - return resolve(std::move(result), - std::move(params), - [](response::BooleanType&& value, const ResolverParams&) { - return response::Value(value); - }); + return resolve(std::move(result), std::move(params), [](bool&& value, const ResolverParams&) { + return response::Value(value); + }); } template <> diff --git a/src/Introspection.cpp b/src/Introspection.cpp index dc797eb1..ae1f99d3 100644 --- a/src/Introspection.cpp +++ b/src/Introspection.cpp @@ -68,23 +68,22 @@ TypeKind Type::getKind() const return _type->kind(); } -std::optional Type::getName() const +std::optional Type::getName() const { const auto name = _type->name(); - return { name.empty() ? std::nullopt : std::make_optional(name) }; + return { name.empty() ? std::nullopt : std::make_optional(name) }; } -std::optional Type::getDescription() const +std::optional Type::getDescription() const { const auto description = _type->description(); - return { description.empty() ? std::nullopt - : std::make_optional(description) }; + return { description.empty() ? std::nullopt : std::make_optional(description) }; } std::optional>> Type::getFields( - std::optional&& includeDeprecatedArg) const + std::optional&& includeDeprecatedArg) const { switch (_type->kind()) { @@ -160,7 +159,7 @@ std::optional>> Type::getPossibleTypes } std::optional>> Type::getEnumValues( - std::optional&& includeDeprecatedArg) const + std::optional&& includeDeprecatedArg) const { switch (_type->kind()) { @@ -232,17 +231,16 @@ Field::Field(const std::shared_ptr& field) { } -response::StringType Field::getName() const +std::string Field::getName() const { - return response::StringType { _field->name() }; + return std::string { _field->name() }; } -std::optional Field::getDescription() const +std::optional Field::getDescription() const { const auto description = _field->description(); - return { description.empty() ? std::nullopt - : std::make_optional(description) }; + return { description.empty() ? std::nullopt : std::make_optional(description) }; } std::vector> Field::getArgs() const @@ -264,16 +262,16 @@ std::shared_ptr Field::getType() const return type ? std::make_shared(std::make_shared(type)) : nullptr; } -response::BooleanType Field::getIsDeprecated() const +bool Field::getIsDeprecated() const { return _field->deprecationReason().has_value(); } -std::optional Field::getDeprecationReason() const +std::optional Field::getDeprecationReason() const { const auto& deprecationReason = _field->deprecationReason(); - return { deprecationReason ? std::make_optional(*deprecationReason) + return { deprecationReason ? std::make_optional(*deprecationReason) : std::nullopt }; } @@ -282,17 +280,16 @@ InputValue::InputValue(const std::shared_ptr& inputVal { } -response::StringType InputValue::getName() const +std::string InputValue::getName() const { - return response::StringType { _inputValue->name() }; + return std::string { _inputValue->name() }; } -std::optional InputValue::getDescription() const +std::optional InputValue::getDescription() const { const auto description = _inputValue->description(); - return { description.empty() ? std::nullopt - : std::make_optional(description) }; + return { description.empty() ? std::nullopt : std::make_optional(description) }; } std::shared_ptr InputValue::getType() const @@ -302,12 +299,11 @@ std::shared_ptr InputValue::getType() const return type ? std::make_shared(std::make_shared(type)) : nullptr; } -std::optional InputValue::getDefaultValue() const +std::optional InputValue::getDefaultValue() const { const auto defaultValue = _inputValue->defaultValue(); - return { defaultValue.empty() ? std::nullopt - : std::make_optional(defaultValue) }; + return { defaultValue.empty() ? std::nullopt : std::make_optional(defaultValue) }; } EnumValue::EnumValue(const std::shared_ptr& enumValue) @@ -315,29 +311,28 @@ EnumValue::EnumValue(const std::shared_ptr& enumValue) { } -response::StringType EnumValue::getName() const +std::string EnumValue::getName() const { - return response::StringType { _enumValue->name() }; + return std::string { _enumValue->name() }; } -std::optional EnumValue::getDescription() const +std::optional EnumValue::getDescription() const { const auto description = _enumValue->description(); - return { description.empty() ? std::nullopt - : std::make_optional(description) }; + return { description.empty() ? std::nullopt : std::make_optional(description) }; } -response::BooleanType EnumValue::getIsDeprecated() const +bool EnumValue::getIsDeprecated() const { return _enumValue->deprecationReason().has_value(); } -std::optional EnumValue::getDeprecationReason() const +std::optional EnumValue::getDeprecationReason() const { const auto& deprecationReason = _enumValue->deprecationReason(); - return { deprecationReason ? std::make_optional(*deprecationReason) + return { deprecationReason ? std::make_optional(*deprecationReason) : std::nullopt }; } @@ -346,17 +341,16 @@ Directive::Directive(const std::shared_ptr& directive) { } -response::StringType Directive::getName() const +std::string Directive::getName() const { - return response::StringType { _directive->name() }; + return std::string { _directive->name() }; } -std::optional Directive::getDescription() const +std::optional Directive::getDescription() const { const auto description = _directive->description(); - return { description.empty() ? std::nullopt - : std::make_optional(description) }; + return { description.empty() ? std::nullopt : std::make_optional(description) }; } std::vector Directive::getLocations() const diff --git a/src/IntrospectionSchema.cpp b/src/IntrospectionSchema.cpp index a4e65b9d..cb8189ac 100644 --- a/src/IntrospectionSchema.cpp +++ b/src/IntrospectionSchema.cpp @@ -38,7 +38,7 @@ introspection::TypeKind ModifiedArgument::convert(const throw service::schema_exception { { "not a valid __TypeKind value" } }; } - const auto itr = std::find(s_namesTypeKind.cbegin(), s_namesTypeKind.cend(), value.get()); + const auto itr = std::find(s_namesTypeKind.cbegin(), s_namesTypeKind.cend(), value.get()); if (itr == s_namesTypeKind.cend()) { @@ -56,7 +56,7 @@ service::AwaitableResolver ModifiedResult::convert(serv { response::Value result(response::Type::EnumValue); - result.set(response::StringType { s_namesTypeKind[static_cast(value)] }); + result.set(std::string { s_namesTypeKind[static_cast(value)] }); return result; }); @@ -91,7 +91,7 @@ introspection::DirectiveLocation ModifiedArgument()); + const auto itr = std::find(s_namesDirectiveLocation.cbegin(), s_namesDirectiveLocation.cend(), value.get()); if (itr == s_namesDirectiveLocation.cend()) { @@ -109,7 +109,7 @@ service::AwaitableResolver ModifiedResult::con { response::Value result(response::Type::EnumValue); - result.set(response::StringType { s_namesDirectiveLocation[static_cast(value)] }); + result.set(std::string { s_namesDirectiveLocation[static_cast(value)] }); return result; }); @@ -193,7 +193,7 @@ service::AwaitableResolver Schema::resolveDirectives(service::ResolverParams&& p service::AwaitableResolver Schema::resolve_typename(service::ResolverParams&& params) { - return service::ModifiedResult::convert(response::StringType{ R"gql(__Schema)gql" }, std::move(params)); + return service::ModifiedResult::convert(std::string{ R"gql(__Schema)gql" }, std::move(params)); } Type::Type(std::shared_ptr pimpl) @@ -238,7 +238,7 @@ service::AwaitableResolver Type::resolveName(service::ResolverParams&& params) auto result = _pimpl->getName(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } service::AwaitableResolver Type::resolveDescription(service::ResolverParams&& params) @@ -248,7 +248,7 @@ service::AwaitableResolver Type::resolveDescription(service::ResolverParams&& pa auto result = _pimpl->getDescription(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } service::AwaitableResolver Type::resolveFields(service::ResolverParams&& params) @@ -264,10 +264,10 @@ service::AwaitableResolver Type::resolveFields(service::ResolverParams&& params) return values; }(); - auto pairIncludeDeprecated = service::ModifiedArgument::find("includeDeprecated", params.arguments); + auto pairIncludeDeprecated = service::ModifiedArgument::find("includeDeprecated", params.arguments); auto argIncludeDeprecated = (pairIncludeDeprecated.second ? std::move(pairIncludeDeprecated.first) - : service::ModifiedArgument::require("includeDeprecated", defaultArguments)); + : service::ModifiedArgument::require("includeDeprecated", defaultArguments)); std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); auto result = _pimpl->getFields(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argIncludeDeprecated)); @@ -309,10 +309,10 @@ service::AwaitableResolver Type::resolveEnumValues(service::ResolverParams&& par return values; }(); - auto pairIncludeDeprecated = service::ModifiedArgument::find("includeDeprecated", params.arguments); + auto pairIncludeDeprecated = service::ModifiedArgument::find("includeDeprecated", params.arguments); auto argIncludeDeprecated = (pairIncludeDeprecated.second ? std::move(pairIncludeDeprecated.first) - : service::ModifiedArgument::require("includeDeprecated", defaultArguments)); + : service::ModifiedArgument::require("includeDeprecated", defaultArguments)); std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); auto result = _pimpl->getEnumValues(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argIncludeDeprecated)); @@ -343,7 +343,7 @@ service::AwaitableResolver Type::resolveOfType(service::ResolverParams&& params) service::AwaitableResolver Type::resolve_typename(service::ResolverParams&& params) { - return service::ModifiedResult::convert(response::StringType{ R"gql(__Type)gql" }, std::move(params)); + return service::ModifiedResult::convert(std::string{ R"gql(__Type)gql" }, std::move(params)); } Field::Field(std::shared_ptr pimpl) @@ -375,7 +375,7 @@ service::AwaitableResolver Field::resolveName(service::ResolverParams&& params) auto result = _pimpl->getName(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } service::AwaitableResolver Field::resolveDescription(service::ResolverParams&& params) @@ -385,7 +385,7 @@ service::AwaitableResolver Field::resolveDescription(service::ResolverParams&& p auto result = _pimpl->getDescription(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } service::AwaitableResolver Field::resolveArgs(service::ResolverParams&& params) @@ -415,7 +415,7 @@ service::AwaitableResolver Field::resolveIsDeprecated(service::ResolverParams&& auto result = _pimpl->getIsDeprecated(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } service::AwaitableResolver Field::resolveDeprecationReason(service::ResolverParams&& params) @@ -425,12 +425,12 @@ service::AwaitableResolver Field::resolveDeprecationReason(service::ResolverPara auto result = _pimpl->getDeprecationReason(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } service::AwaitableResolver Field::resolve_typename(service::ResolverParams&& params) { - return service::ModifiedResult::convert(response::StringType{ R"gql(__Field)gql" }, std::move(params)); + return service::ModifiedResult::convert(std::string{ R"gql(__Field)gql" }, std::move(params)); } InputValue::InputValue(std::shared_ptr pimpl) @@ -460,7 +460,7 @@ service::AwaitableResolver InputValue::resolveName(service::ResolverParams&& par auto result = _pimpl->getName(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } service::AwaitableResolver InputValue::resolveDescription(service::ResolverParams&& params) @@ -470,7 +470,7 @@ service::AwaitableResolver InputValue::resolveDescription(service::ResolverParam auto result = _pimpl->getDescription(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } service::AwaitableResolver InputValue::resolveType(service::ResolverParams&& params) @@ -490,12 +490,12 @@ service::AwaitableResolver InputValue::resolveDefaultValue(service::ResolverPara auto result = _pimpl->getDefaultValue(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } service::AwaitableResolver InputValue::resolve_typename(service::ResolverParams&& params) { - return service::ModifiedResult::convert(response::StringType{ R"gql(__InputValue)gql" }, std::move(params)); + return service::ModifiedResult::convert(std::string{ R"gql(__InputValue)gql" }, std::move(params)); } EnumValue::EnumValue(std::shared_ptr pimpl) @@ -525,7 +525,7 @@ service::AwaitableResolver EnumValue::resolveName(service::ResolverParams&& para auto result = _pimpl->getName(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } service::AwaitableResolver EnumValue::resolveDescription(service::ResolverParams&& params) @@ -535,7 +535,7 @@ service::AwaitableResolver EnumValue::resolveDescription(service::ResolverParams auto result = _pimpl->getDescription(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } service::AwaitableResolver EnumValue::resolveIsDeprecated(service::ResolverParams&& params) @@ -545,7 +545,7 @@ service::AwaitableResolver EnumValue::resolveIsDeprecated(service::ResolverParam auto result = _pimpl->getIsDeprecated(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } service::AwaitableResolver EnumValue::resolveDeprecationReason(service::ResolverParams&& params) @@ -555,12 +555,12 @@ service::AwaitableResolver EnumValue::resolveDeprecationReason(service::Resolver auto result = _pimpl->getDeprecationReason(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } service::AwaitableResolver EnumValue::resolve_typename(service::ResolverParams&& params) { - return service::ModifiedResult::convert(response::StringType{ R"gql(__EnumValue)gql" }, std::move(params)); + return service::ModifiedResult::convert(std::string{ R"gql(__EnumValue)gql" }, std::move(params)); } Directive::Directive(std::shared_ptr pimpl) @@ -590,7 +590,7 @@ service::AwaitableResolver Directive::resolveName(service::ResolverParams&& para auto result = _pimpl->getName(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } service::AwaitableResolver Directive::resolveDescription(service::ResolverParams&& params) @@ -600,7 +600,7 @@ service::AwaitableResolver Directive::resolveDescription(service::ResolverParams auto result = _pimpl->getDescription(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } service::AwaitableResolver Directive::resolveLocations(service::ResolverParams&& params) @@ -625,7 +625,7 @@ service::AwaitableResolver Directive::resolveArgs(service::ResolverParams&& para service::AwaitableResolver Directive::resolve_typename(service::ResolverParams&& params) { - return service::ModifiedResult::convert(response::StringType{ R"gql(__Directive)gql" }, std::move(params)); + return service::ModifiedResult::convert(std::string{ R"gql(__Directive)gql" }, std::move(params)); } } // namespace object diff --git a/src/RequestLoader.cpp b/src/RequestLoader.cpp index 73c7b902..033f55d7 100644 --- a/src/RequestLoader.cpp +++ b/src/RequestLoader.cpp @@ -520,7 +520,7 @@ void RequestLoader::addTypesToSchema() [](std::string_view locationName) noexcept { response::Value locationValue(response::Type::EnumValue); - locationValue.set(response::StringType { locationName }); + locationValue.set(std::string { locationName }); return service::ModifiedArgument::convert( locationValue); diff --git a/src/SchemaGenerator.cpp b/src/SchemaGenerator.cpp index 5f073a1f..971cdff1 100644 --- a/src/SchemaGenerator.cpp +++ b/src/SchemaGenerator.cpp @@ -1044,7 +1044,7 @@ template <> const auto itr = std::find(s_names)cpp" << enumType.cppType << R"cpp(.cbegin(), s_names)cpp" << enumType.cppType - << R"cpp(.cend(), value.get()); + << R"cpp(.cend(), value.get()); if (itr == s_names)cpp" << enumType.cppType << R"cpp(.cend()) @@ -1071,7 +1071,7 @@ service::AwaitableResolver ModifiedResult<)cpp" { response::Value result(response::Type::EnumValue); - result.set(response::StringType { s_names)cpp" + result.set(std::string { s_names)cpp" << enumType.cppType << R"cpp([static_cast(value)] }); return result; @@ -1999,7 +1999,7 @@ service::AwaitableResolver )cpp" service::AwaitableResolver )cpp" << objectType.cppType << R"cpp(::resolve_typename(service::ResolverParams&& params) { - return service::ModifiedResult::convert(response::StringType{ R"gql()cpp" + return service::ModifiedResult::convert(std::string{ R"gql()cpp" << objectType.type << R"cpp()gql" }, std::move(params)); } )cpp"; @@ -2021,7 +2021,7 @@ service::AwaitableResolver )cpp" service::AwaitableResolver )cpp" << objectType.cppType << R"cpp(::resolve_type(service::ResolverParams&& params) { - auto argName = service::ModifiedArgument::require("name", params.arguments); + auto argName = service::ModifiedArgument::require("name", params.arguments); const auto& baseType = _schema->LookupType(argName); std::shared_ptr<)cpp" << SchemaLoader::getIntrospectionNamespace() @@ -2218,7 +2218,7 @@ std::string Generator::getArgumentDefaultValue( { argumentDefaultValue << padding << R"cpp( entry = response::Value(std::string(R"gql()cpp" - << defaultValue.get() << R"cpp()gql")); + << defaultValue.get() << R"cpp()gql")); )cpp"; break; } @@ -2233,8 +2233,7 @@ std::string Generator::getArgumentDefaultValue( case response::Type::Boolean: { argumentDefaultValue << padding << R"cpp( entry = response::Value()cpp" - << (defaultValue.get() ? R"cpp(true)cpp" - : R"cpp(false)cpp") + << (defaultValue.get() ? R"cpp(true)cpp" : R"cpp(false)cpp") << R"cpp(); )cpp"; break; @@ -2242,20 +2241,18 @@ std::string Generator::getArgumentDefaultValue( case response::Type::Int: { - argumentDefaultValue - << padding - << R"cpp( entry = response::Value(static_cast()cpp" - << defaultValue.get() << R"cpp()); + argumentDefaultValue << padding + << R"cpp( entry = response::Value(static_cast()cpp" + << defaultValue.get() << R"cpp()); )cpp"; break; } case response::Type::Float: { - argumentDefaultValue - << padding - << R"cpp( entry = response::Value(static_cast()cpp" - << defaultValue.get() << R"cpp()); + argumentDefaultValue << padding + << R"cpp( entry = response::Value(static_cast()cpp" + << defaultValue.get() << R"cpp()); )cpp"; break; } @@ -2264,8 +2261,8 @@ std::string Generator::getArgumentDefaultValue( { argumentDefaultValue << padding << R"cpp( entry = response::Value(response::Type::EnumValue); - entry.set(R"gql()cpp" - << defaultValue.get() << R"cpp()gql"); + entry.set(R"gql()cpp" + << defaultValue.get() << R"cpp()gql"); )cpp"; break; } diff --git a/src/SchemaLoader.cpp b/src/SchemaLoader.cpp index cd347d79..f82768b9 100644 --- a/src/SchemaLoader.cpp +++ b/src/SchemaLoader.cpp @@ -25,10 +25,10 @@ const BuiltinTypeMap SchemaLoader::s_builtinTypes = { }; const CppTypeMap SchemaLoader::s_builtinCppTypes = { - "response::IntType"sv, - "response::FloatType"sv, - "response::StringType"sv, - "response::BooleanType"sv, + "int"sv, + "double"sv, + "std::string"sv, + "bool"sv, "response::IdType"sv, }; diff --git a/src/Validation.cpp b/src/Validation.cpp index 293b4b9e..e51c8a0f 100644 --- a/src/Validation.cpp +++ b/src/Validation.cpp @@ -64,12 +64,12 @@ ValidateArgumentValue::ValidateArgumentValue(ValidateArgumentVariable&& value) { } -ValidateArgumentValue::ValidateArgumentValue(response::IntType value) +ValidateArgumentValue::ValidateArgumentValue(int value) : data(value) { } -ValidateArgumentValue::ValidateArgumentValue(response::FloatType value) +ValidateArgumentValue::ValidateArgumentValue(double value) : data(value) { } @@ -79,7 +79,7 @@ ValidateArgumentValue::ValidateArgumentValue(std::string_view value) { } -ValidateArgumentValue::ValidateArgumentValue(response::BooleanType value) +ValidateArgumentValue::ValidateArgumentValue(bool value) : data(value) { } @@ -162,7 +162,7 @@ void ValidateArgumentValueVisitor::visitVariable(const peg::ast_node& variable) void ValidateArgumentValueVisitor::visitIntValue(const peg::ast_node& intValue) { - response::IntType value { std::atoi(intValue.string().c_str()) }; + int value { std::atoi(intValue.string().c_str()) }; auto position = intValue.begin(); _argumentValue.value = std::make_unique(value); @@ -171,7 +171,7 @@ void ValidateArgumentValueVisitor::visitIntValue(const peg::ast_node& intValue) void ValidateArgumentValueVisitor::visitFloatValue(const peg::ast_node& floatValue) { - response::FloatType value { std::atof(floatValue.string().c_str()) }; + double value { std::atof(floatValue.string().c_str()) }; auto position = floatValue.begin(); _argumentValue.value = std::make_unique(value); @@ -189,7 +189,7 @@ void ValidateArgumentValueVisitor::visitStringValue(const peg::ast_node& stringV void ValidateArgumentValueVisitor::visitBooleanValue(const peg::ast_node& booleanValue) { - response::BooleanType value { booleanValue.is_type() }; + bool value { booleanValue.is_type() }; auto position = booleanValue.begin(); _argumentValue.value = std::make_unique(value); @@ -1160,7 +1160,7 @@ bool ValidateExecutableVisitor::validateInputValue( if (name == R"gql(Int)gql"sv) { - if (!std::holds_alternative(argument.value->data)) + if (!std::holds_alternative(argument.value->data)) { _errors.push_back({ "Expected Int value", argument.position }); return false; @@ -1168,8 +1168,8 @@ bool ValidateExecutableVisitor::validateInputValue( } else if (name == R"gql(Float)gql"sv) { - if (!std::holds_alternative(argument.value->data) - && !std::holds_alternative(argument.value->data)) + if (!std::holds_alternative(argument.value->data) + && !std::holds_alternative(argument.value->data)) { _errors.push_back({ "Expected Float value", argument.position }); return false; @@ -1205,7 +1205,7 @@ bool ValidateExecutableVisitor::validateInputValue( } else if (name == R"gql(Boolean)gql"sv) { - if (!std::holds_alternative(argument.value->data)) + if (!std::holds_alternative(argument.value->data)) { _errors.push_back({ "Expected Boolean value", argument.position }); return false; diff --git a/test/ArgumentTests.cpp b/test/ArgumentTests.cpp index 9f73f5c1..5227d868 100644 --- a/test/ArgumentTests.cpp +++ b/test/ArgumentTests.cpp @@ -147,7 +147,7 @@ TEST(ArgumentsCase, TaskStateEnum) { response::Value response(response::Type::Map); response::Value status(response::Type::EnumValue); - status.set("Started"); + status.set("Started"); response.emplace_back("status", std::move(status)); today::TaskState actual = static_cast(-1); @@ -229,7 +229,7 @@ TEST(ArgumentsCase, ScalarArgumentMap) values = actual.release(); ASSERT_EQ(1, values.size()) << "should have a single key/value"; ASSERT_EQ("foo", values.front().first) << "should match the key"; - ASSERT_EQ("bar", values.front().second.get()) << "should match the value"; + ASSERT_EQ("bar", values.front().second.get()) << "should match the value"; } TEST(ArgumentsCase, ScalarArgumentList) @@ -251,8 +251,8 @@ TEST(ArgumentsCase, ScalarArgumentList) ASSERT_EQ(response::Type::List, actual.type()) << "should parse the array"; values = actual.release(); ASSERT_EQ(2, values.size()) << "should have 2 values"; - ASSERT_EQ("foo", values.front().get()) << "should match the value"; - ASSERT_EQ("bar", values.back().get()) << "should match the value"; + ASSERT_EQ("foo", values.front().get()) << "should match the value"; + ASSERT_EQ("bar", values.back().get()) << "should match the value"; } TEST(ArgumentsCase, ScalarArgumentNull) @@ -289,7 +289,7 @@ TEST(ArgumentsCase, ScalarArgumentString) } ASSERT_EQ(response::Type::String, actual.type()) << "should parse the object"; - ASSERT_EQ("foobar", actual.get()) << "should match the value"; + ASSERT_EQ("foobar", actual.get()) << "should match the value"; } TEST(ArgumentsCase, FindArgumentNoTemplateArguments) @@ -309,7 +309,7 @@ TEST(ArgumentsCase, FindArgumentNoTemplateArguments) ASSERT_TRUE(actual.second) << "should find the argument"; ASSERT_EQ(response::Type::String, actual.first.type()) << "should parse the object"; - ASSERT_EQ("foobar", actual.first.get()) << "should match the value"; + ASSERT_EQ("foobar", actual.first.get()) << "should match the value"; } TEST(ArgumentsCase, FindArgumentEmptyTemplateArgs) @@ -329,5 +329,5 @@ TEST(ArgumentsCase, FindArgumentEmptyTemplateArgs) ASSERT_TRUE(actual.second) << "should find the argument"; ASSERT_EQ(response::Type::String, actual.first.type()) << "should parse the object"; - ASSERT_EQ("foobar", actual.first.get()) << "should match the value"; + ASSERT_EQ("foobar", actual.first.get()) << "should match the value"; } diff --git a/test/ClientTests.cpp b/test/ClientTests.cpp index 35951bfd..acef05f0 100644 --- a/test/ClientTests.cpp +++ b/test/ClientTests.cpp @@ -141,8 +141,7 @@ TEST_F(ClientCase, QueryEverything) ASSERT_TRUE(appointmentNode->subject.has_value()) << "subject should be set"; EXPECT_EQ("Lunch?", *(appointmentNode->subject)) << "subject should match"; ASSERT_TRUE(appointmentNode->when.has_value()) << "when should be set"; - EXPECT_EQ("tomorrow", appointmentNode->when->get()) - << "when should match"; + EXPECT_EQ("tomorrow", appointmentNode->when->get()) << "when should match"; EXPECT_FALSE(appointmentNode->isNow) << "isNow should match"; EXPECT_EQ("Appointment", appointmentNode->_typename) << "__typename should match"; @@ -181,7 +180,7 @@ TEST_F(ClientCase, QueryEverything) ASSERT_TRUE(anyType.subject.has_value()) << "subject should be set"; EXPECT_EQ("Lunch?", *(anyType.subject)) << "subject should match"; ASSERT_TRUE(anyType.when.has_value()) << "when should be set"; - EXPECT_EQ("tomorrow", anyType.when->get()) << "when should match"; + EXPECT_EQ("tomorrow", anyType.when->get()) << "when should match"; EXPECT_FALSE(anyType.isNow) << "isNow should match"; } catch (const std::logic_error& ex) @@ -263,8 +262,7 @@ TEST_F(ClientCase, SubscribeNextAppointmentChangeDefault) ASSERT_TRUE(appointmentNode->subject.has_value()) << "subject should be set"; EXPECT_EQ("Lunch?", *(appointmentNode->subject)) << "subject should match"; ASSERT_TRUE(appointmentNode->when.has_value()) << "when should be set"; - EXPECT_EQ("tomorrow", appointmentNode->when->get()) - << "when should match"; + EXPECT_EQ("tomorrow", appointmentNode->when->get()) << "when should match"; EXPECT_TRUE(appointmentNode->isNow) << "isNow should match"; } catch (const std::logic_error& ex) diff --git a/test/ResponseTests.cpp b/test/ResponseTests.cpp index a035d97a..0a878a58 100644 --- a/test/ResponseTests.cpp +++ b/test/ResponseTests.cpp @@ -13,5 +13,5 @@ TEST(ResponseCase, ValueConstructorFromStringLiteral) auto actual = response::Value(expected); ASSERT_TRUE(response::Type::String == actual.type()); - ASSERT_EQ(expected, actual.release()); + ASSERT_EQ(expected, actual.release()); } diff --git a/test/TodayTests.cpp b/test/TodayTests.cpp index 571d000b..c4a1bbf1 100644 --- a/test/TodayTests.cpp +++ b/test/TodayTests.cpp @@ -1302,7 +1302,7 @@ TEST_F(TodayServiceCase, SubscribeNodeChangeFuzzyComparator) response::MapType::const_reference fuzzy) noexcept -> bool { EXPECT_FALSE(filterCalled); EXPECT_EQ("id", fuzzy.first) << "should only get called once for the id argument"; - EXPECT_EQ("ZmFr", fuzzy.second.get()); + EXPECT_EQ("ZmFr", fuzzy.second.get()); filterCalled = true; return true; }; @@ -1375,7 +1375,7 @@ TEST_F(TodayServiceCase, SubscribeNodeChangeFuzzyMismatch) response::MapType::const_reference fuzzy) noexcept -> bool { EXPECT_FALSE(filterCalled); EXPECT_EQ("id", fuzzy.first) << "should only get called once for the id argument"; - EXPECT_EQ("ZmFrZVRhc2tJZA==", fuzzy.second.get()); + EXPECT_EQ("ZmFrZVRhc2tJZA==", fuzzy.second.get()); filterCalled = true; return false; }; From 78af84edda144e402252e34f2bfbb67da56b2b8b Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Wed, 1 Dec 2021 21:21:51 -0800 Subject: [PATCH 043/119] Reverse schemagen default to not generate stubs --- include/SchemaGenerator.h | 2 +- samples/CMakeLists.txt | 24 ++++++++++++------------ src/SchemaGenerator.cpp | 18 +++++++++--------- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/include/SchemaGenerator.h b/include/SchemaGenerator.h index e7a4bd48..c737e632 100644 --- a/include/SchemaGenerator.h +++ b/include/SchemaGenerator.h @@ -21,7 +21,7 @@ struct GeneratorOptions const std::optional paths; const bool verbose = false; const bool separateFiles = false; - const bool noStubs = false; + const bool stubs = false; const bool noIntrospection = false; }; diff --git a/samples/CMakeLists.txt b/samples/CMakeLists.txt index 4c27dddb..8c645e60 100644 --- a/samples/CMakeLists.txt +++ b/samples/CMakeLists.txt @@ -11,14 +11,14 @@ if(GRAPHQL_UPDATE_SAMPLES) OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/unified/TodaySchema.cpp ${CMAKE_CURRENT_BINARY_DIR}/unified/TodaySchema.h - COMMAND schemagen --schema="${CMAKE_CURRENT_SOURCE_DIR}/schema.today.graphql" --prefix="Today" --namespace="today" + COMMAND schemagen --schema="${CMAKE_CURRENT_SOURCE_DIR}/schema.today.graphql" --prefix="Today" --namespace="today" --stubs COMMAND ${CMAKE_COMMAND} -E copy_if_different TodaySchema.cpp TodaySchema.h ${CMAKE_CURRENT_SOURCE_DIR}/unified DEPENDS schemagen graphqlpeg schema.today.graphql WORKING_DIRECTORY unified - COMMENT "Generating mock TodaySchema files") + COMMENT "Generating mock TodaySchema files (--stubs)") # unifiedschema_nointrospection file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/unified_nointrospection) @@ -27,14 +27,14 @@ if(GRAPHQL_UPDATE_SAMPLES) OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/unified_nointrospection/TodaySchema.cpp ${CMAKE_CURRENT_BINARY_DIR}/unified_nointrospection/TodaySchema.h - COMMAND schemagen --schema="${CMAKE_CURRENT_SOURCE_DIR}/schema.today.graphql" --prefix="Today" --namespace="today" --no-introspection + COMMAND schemagen --schema="${CMAKE_CURRENT_SOURCE_DIR}/schema.today.graphql" --prefix="Today" --namespace="today" --stubs --no-introspection COMMAND ${CMAKE_COMMAND} -E copy_if_different TodaySchema.cpp TodaySchema.h ${CMAKE_CURRENT_SOURCE_DIR}/unified_nointrospection DEPENDS schemagen graphqlpeg schema.today.graphql WORKING_DIRECTORY unified_nointrospection - COMMENT "Generating mock TodaySchema files without Introspection (--no-introspection)") + COMMENT "Generating mock TodaySchema files without Introspection (--stubs --no-introspection)") # validationschema file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/validation) @@ -43,47 +43,47 @@ if(GRAPHQL_UPDATE_SAMPLES) OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/validation/ValidationSchema.cpp ${CMAKE_CURRENT_BINARY_DIR}/validation/ValidationSchema.h - COMMAND schemagen --schema="${CMAKE_CURRENT_SOURCE_DIR}/schema.validation.graphql" --prefix="Validation" --namespace="validation" + COMMAND schemagen --schema="${CMAKE_CURRENT_SOURCE_DIR}/schema.validation.graphql" --prefix="Validation" --namespace="validation" --stubs COMMAND ${CMAKE_COMMAND} -E copy_if_different ValidationSchema.cpp ValidationSchema.h ${CMAKE_CURRENT_SOURCE_DIR}/validation DEPENDS schemagen graphqlpeg schema.validation.graphql WORKING_DIRECTORY validation - COMMENT "Generating ValidationSchema files") + COMMENT "Generating ValidationSchema files (--stubs)") # separateschema file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/separate) add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/separate/today_schema_files - COMMAND schemagen --schema="${CMAKE_CURRENT_SOURCE_DIR}/schema.today.graphql" --prefix="Today" --namespace="today" --separate-files > today_schema_files + COMMAND schemagen --schema="${CMAKE_CURRENT_SOURCE_DIR}/schema.today.graphql" --prefix="Today" --namespace="today" --separate-files --stubs > today_schema_files COMMAND ${CMAKE_COMMAND} -E copy_if_different today_schema_files ${CMAKE_CURRENT_SOURCE_DIR}/separate DEPENDS schemagen graphqlpeg schema.today.graphql WORKING_DIRECTORY separate - COMMENT "Generating mock TodaySchema (--separate-files)") + COMMENT "Generating mock TodaySchema (--stubs --separate-files)") # separateschema_nointrospection file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/separate_nointrospection) add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/separate_nointrospection/today_schema_files - COMMAND schemagen --schema="${CMAKE_CURRENT_SOURCE_DIR}/schema.today.graphql" --prefix="Today" --namespace="today" --no-introspection --separate-files > today_schema_files + COMMAND schemagen --schema="${CMAKE_CURRENT_SOURCE_DIR}/schema.today.graphql" --prefix="Today" --namespace="today" --no-introspection --separate-files --stubs > today_schema_files COMMAND ${CMAKE_COMMAND} -E copy_if_different today_schema_files ${CMAKE_CURRENT_SOURCE_DIR}/separate_nointrospection DEPENDS schemagen graphqlpeg schema.today.graphql WORKING_DIRECTORY separate_nointrospection - COMMENT "Generating mock TodaySchema without Introspection (--no-introspection --separate-files)") + COMMENT "Generating mock TodaySchema without Introspection (--stubs --separate-files --no-introspection)") # learn file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/learn) add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/learn/learn_schema_files - COMMAND schemagen --schema="${CMAKE_CURRENT_SOURCE_DIR}/schema.learn.graphql" --prefix="StarWars" --namespace="learn" --no-stubs --separate-files > learn_schema_files + COMMAND schemagen --schema="${CMAKE_CURRENT_SOURCE_DIR}/schema.learn.graphql" --prefix="StarWars" --namespace="learn" --separate-files > learn_schema_files COMMAND ${CMAKE_COMMAND} -E copy_if_different learn_schema_files ${CMAKE_CURRENT_SOURCE_DIR}/learn DEPENDS schemagen graphqlpeg schema.learn.graphql WORKING_DIRECTORY learn - COMMENT "Generating mock StarWarsSchema (--no-stubs --separate-files)") + COMMENT "Generating mock StarWarsSchema (--separate-files)") add_custom_command( OUTPUT updated_samples diff --git a/src/SchemaGenerator.cpp b/src/SchemaGenerator.cpp index 971cdff1..b373983a 100644 --- a/src/SchemaGenerator.cpp +++ b/src/SchemaGenerator.cpp @@ -806,7 +806,7 @@ void Generator::outputObjectDeclaration( } else)cpp"; - if (_options.noStubs) + if (!_options.stubs) { headerFile << R"cpp( { @@ -835,7 +835,7 @@ void Generator::outputObjectDeclaration( headerFile << R"cpp() }; })cpp"; - if (!_options.noStubs) + if (_options.stubs) { headerFile << R"cpp( else @@ -1505,8 +1505,7 @@ Operations::Operations()cpp"; { bool firstValue = true; - sourceFile << R"cpp( type)cpp" << unionType.cppType - << R"cpp(->AddPossibleTypes({ + sourceFile << R"cpp( type)cpp" << unionType.cppType << R"cpp(->AddPossibleTypes({ )cpp"; for (const auto& unionOption : unionType.options) @@ -2655,7 +2654,7 @@ int main(int argc, char** argv) bool showVersion = false; bool buildIntrospection = false; bool buildCustom = false; - bool noStubs = false; + bool stubs = false; bool verbose = false; bool separateFiles = false; bool noIntrospection = false; @@ -2680,9 +2679,10 @@ int main(int argc, char** argv) po::value(&sourceDir), "Target path for the Schema.cpp source file")("header-dir", po::value(&headerDir), - "Target path for the Schema.h header file")("no-stubs", - po::bool_switch(&noStubs), - "Generate abstract classes without stub implementations")("separate-files", + "Target path for the Schema.h header file")("stubs", + po::bool_switch(&stubs), + "Unimplemented fields throw runtime exceptions instead of compiler errors")( + "separate-files", po::bool_switch(&separateFiles), "Generate separate files for each of the types")("no-introspection", po::bool_switch(&noIntrospection), @@ -2765,7 +2765,7 @@ int main(int argc, char** argv) std::move(sourceDir) }, verbose, separateFiles, - noStubs, + stubs, noIntrospection, }) .Build(); From 230f368233617929712386a3159d329b693fb09a Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Wed, 1 Dec 2021 22:06:34 -0800 Subject: [PATCH 044/119] Emit separate files for each type by default --- include/SchemaGenerator.h | 2 +- samples/CMakeLists.txt | 24 ++++++++++++------------ src/SchemaGenerator.cpp | 39 ++++++++++++++++++++++----------------- 3 files changed, 35 insertions(+), 30 deletions(-) diff --git a/include/SchemaGenerator.h b/include/SchemaGenerator.h index c737e632..10b4afd2 100644 --- a/include/SchemaGenerator.h +++ b/include/SchemaGenerator.h @@ -20,8 +20,8 @@ struct GeneratorOptions { const std::optional paths; const bool verbose = false; - const bool separateFiles = false; const bool stubs = false; + const bool mergeFiles = false; const bool noIntrospection = false; }; diff --git a/samples/CMakeLists.txt b/samples/CMakeLists.txt index 8c645e60..dc1bc540 100644 --- a/samples/CMakeLists.txt +++ b/samples/CMakeLists.txt @@ -11,14 +11,14 @@ if(GRAPHQL_UPDATE_SAMPLES) OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/unified/TodaySchema.cpp ${CMAKE_CURRENT_BINARY_DIR}/unified/TodaySchema.h - COMMAND schemagen --schema="${CMAKE_CURRENT_SOURCE_DIR}/schema.today.graphql" --prefix="Today" --namespace="today" --stubs + COMMAND schemagen --schema="${CMAKE_CURRENT_SOURCE_DIR}/schema.today.graphql" --prefix="Today" --namespace="today" --stubs --merge-files COMMAND ${CMAKE_COMMAND} -E copy_if_different TodaySchema.cpp TodaySchema.h ${CMAKE_CURRENT_SOURCE_DIR}/unified DEPENDS schemagen graphqlpeg schema.today.graphql WORKING_DIRECTORY unified - COMMENT "Generating mock TodaySchema files (--stubs)") + COMMENT "Generating mock TodaySchema files (--stubs --merge-files)") # unifiedschema_nointrospection file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/unified_nointrospection) @@ -27,14 +27,14 @@ if(GRAPHQL_UPDATE_SAMPLES) OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/unified_nointrospection/TodaySchema.cpp ${CMAKE_CURRENT_BINARY_DIR}/unified_nointrospection/TodaySchema.h - COMMAND schemagen --schema="${CMAKE_CURRENT_SOURCE_DIR}/schema.today.graphql" --prefix="Today" --namespace="today" --stubs --no-introspection + COMMAND schemagen --schema="${CMAKE_CURRENT_SOURCE_DIR}/schema.today.graphql" --prefix="Today" --namespace="today" --stubs --merge-files --no-introspection COMMAND ${CMAKE_COMMAND} -E copy_if_different TodaySchema.cpp TodaySchema.h ${CMAKE_CURRENT_SOURCE_DIR}/unified_nointrospection DEPENDS schemagen graphqlpeg schema.today.graphql WORKING_DIRECTORY unified_nointrospection - COMMENT "Generating mock TodaySchema files without Introspection (--stubs --no-introspection)") + COMMENT "Generating mock TodaySchema files without Introspection (--stubs --merge-files --no-introspection)") # validationschema file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/validation) @@ -43,47 +43,47 @@ if(GRAPHQL_UPDATE_SAMPLES) OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/validation/ValidationSchema.cpp ${CMAKE_CURRENT_BINARY_DIR}/validation/ValidationSchema.h - COMMAND schemagen --schema="${CMAKE_CURRENT_SOURCE_DIR}/schema.validation.graphql" --prefix="Validation" --namespace="validation" --stubs + COMMAND schemagen --schema="${CMAKE_CURRENT_SOURCE_DIR}/schema.validation.graphql" --prefix="Validation" --namespace="validation" --stubs --merge-files COMMAND ${CMAKE_COMMAND} -E copy_if_different ValidationSchema.cpp ValidationSchema.h ${CMAKE_CURRENT_SOURCE_DIR}/validation DEPENDS schemagen graphqlpeg schema.validation.graphql WORKING_DIRECTORY validation - COMMENT "Generating ValidationSchema files (--stubs)") + COMMENT "Generating ValidationSchema files (--stubs --merge-files)") # separateschema file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/separate) add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/separate/today_schema_files - COMMAND schemagen --schema="${CMAKE_CURRENT_SOURCE_DIR}/schema.today.graphql" --prefix="Today" --namespace="today" --separate-files --stubs > today_schema_files + COMMAND schemagen --schema="${CMAKE_CURRENT_SOURCE_DIR}/schema.today.graphql" --prefix="Today" --namespace="today" --stubs > today_schema_files COMMAND ${CMAKE_COMMAND} -E copy_if_different today_schema_files ${CMAKE_CURRENT_SOURCE_DIR}/separate DEPENDS schemagen graphqlpeg schema.today.graphql WORKING_DIRECTORY separate - COMMENT "Generating mock TodaySchema (--stubs --separate-files)") + COMMENT "Generating mock TodaySchema (--stubs)") # separateschema_nointrospection file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/separate_nointrospection) add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/separate_nointrospection/today_schema_files - COMMAND schemagen --schema="${CMAKE_CURRENT_SOURCE_DIR}/schema.today.graphql" --prefix="Today" --namespace="today" --no-introspection --separate-files --stubs > today_schema_files + COMMAND schemagen --schema="${CMAKE_CURRENT_SOURCE_DIR}/schema.today.graphql" --prefix="Today" --namespace="today" --no-introspection --stubs > today_schema_files COMMAND ${CMAKE_COMMAND} -E copy_if_different today_schema_files ${CMAKE_CURRENT_SOURCE_DIR}/separate_nointrospection DEPENDS schemagen graphqlpeg schema.today.graphql WORKING_DIRECTORY separate_nointrospection - COMMENT "Generating mock TodaySchema without Introspection (--stubs --separate-files --no-introspection)") + COMMENT "Generating mock TodaySchema without Introspection (--stubs --no-introspection)") # learn file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/learn) add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/learn/learn_schema_files - COMMAND schemagen --schema="${CMAKE_CURRENT_SOURCE_DIR}/schema.learn.graphql" --prefix="StarWars" --namespace="learn" --separate-files > learn_schema_files + COMMAND schemagen --schema="${CMAKE_CURRENT_SOURCE_DIR}/schema.learn.graphql" --prefix="StarWars" --namespace="learn" > learn_schema_files COMMAND ${CMAKE_COMMAND} -E copy_if_different learn_schema_files ${CMAKE_CURRENT_SOURCE_DIR}/learn DEPENDS schemagen graphqlpeg schema.learn.graphql WORKING_DIRECTORY learn - COMMENT "Generating mock StarWarsSchema (--separate-files)") + COMMENT "Generating mock StarWarsSchema") add_custom_command( OUTPUT updated_samples diff --git a/src/SchemaGenerator.cpp b/src/SchemaGenerator.cpp index b373983a..0c8e35cc 100644 --- a/src/SchemaGenerator.cpp +++ b/src/SchemaGenerator.cpp @@ -91,7 +91,7 @@ std::string Generator::getHeaderPath() const noexcept std::string Generator::getObjectHeaderPath() const noexcept { - if (_options.separateFiles) + if (!_options.mergeFiles) { fs::path fullPath { _headerDir }; @@ -124,7 +124,7 @@ std::vector Generator::Build() const noexcept builtFiles.push_back(_sourcePath); } - if (_options.separateFiles) + if (!_options.mergeFiles) { auto separateFiles = outputSeparateFiles(); @@ -306,7 +306,7 @@ static_assert(graphql::internal::MinorVersion == )cpp" } } - if (!_loader.getObjectTypes().empty() && !_options.separateFiles) + if (!_loader.getObjectTypes().empty() && _options.mergeFiles) { if (_loader.isIntrospection()) { @@ -465,7 +465,7 @@ static_assert(graphql::internal::MinorVersion == )cpp" )cpp"; } - if (!_loader.getObjectTypes().empty() && _options.separateFiles) + if (!_loader.getObjectTypes().empty() && !_options.mergeFiles) { for (const auto& objectType : _loader.getObjectTypes()) { @@ -1181,7 +1181,7 @@ service::AwaitableResolver ModifiedResult<)cpp" } } - if (!_loader.getObjectTypes().empty() && !_options.separateFiles) + if (!_loader.getObjectTypes().empty() && _options.mergeFiles) { NamespaceScope objectNamespace { sourceFile, "object" }; @@ -1624,7 +1624,7 @@ Operations::Operations()cpp"; for (const auto& objectType : _loader.getObjectTypes()) { - if (_options.separateFiles) + if (!_options.mergeFiles) { sourceFile << R"cpp( Add)cpp" << objectType.cppType << R"cpp(Details(type)cpp" << objectType.cppType << R"cpp(, schema); @@ -2057,7 +2057,7 @@ void Generator::outputObjectIntrospection( firstInterface = false; - if (_options.separateFiles) + if (!_options.mergeFiles) { sourceFile << R"cpp( std::static_pointer_cast(schema->LookupType(R"gql()cpp" @@ -2654,9 +2654,9 @@ int main(int argc, char** argv) bool showVersion = false; bool buildIntrospection = false; bool buildCustom = false; - bool stubs = false; bool verbose = false; - bool separateFiles = false; + bool stubs = false; + bool mergeFiles = false; bool noIntrospection = false; std::string schemaFileName; std::string filenamePrefix; @@ -2681,10 +2681,9 @@ int main(int argc, char** argv) po::value(&headerDir), "Target path for the Schema.h header file")("stubs", po::bool_switch(&stubs), - "Unimplemented fields throw runtime exceptions instead of compiler errors")( - "separate-files", - po::bool_switch(&separateFiles), - "Generate separate files for each of the types")("no-introspection", + "Unimplemented fields throw runtime exceptions instead of compiler errors")("merge-files", + po::bool_switch(&mergeFiles), + "Generate a single header and source file for the entire schema")("no-introspection", po::bool_switch(&noIntrospection), "Do not generate support for Introspection"); positional.add("schema", 1).add("prefix", 1).add("namespace", 1); @@ -2744,9 +2743,15 @@ int main(int argc, char** argv) { if (buildIntrospection) { - const auto files = - graphql::generator::schema::Generator(std::nullopt, { std::nullopt, verbose }) - .Build(); + const auto files = graphql::generator::schema::Generator(std::nullopt, + { + std::nullopt, + verbose, + false, // stubs + true, // mergeFiles + false, // noIntrospection + }) + .Build(); for (const auto& file : files) { @@ -2764,8 +2769,8 @@ int main(int argc, char** argv) graphql::generator::schema::GeneratorPaths { std::move(headerDir), std::move(sourceDir) }, verbose, - separateFiles, stubs, + mergeFiles, noIntrospection, }) .Build(); From b16f48207aaed661ddbd5bad3ac96b1379706ec4 Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Thu, 2 Dec 2021 17:46:47 -0800 Subject: [PATCH 045/119] Encapsulate code gen in reusable cmake functions --- cmake/CMakeLists.txt | 2 + cmake/cppgraphqlgen-config.cmake | 12 +- cmake/cppgraphqlgen-functions.cmake | 57 +++ cmake/cppgraphqlgen-update-schema-files.cmake | 57 +++ samples/CMakeLists.txt | 438 +++--------------- samples/learn/CMakeLists.txt | 42 ++ samples/{star_wars => learn}/DroidData.cpp | 0 samples/{star_wars => learn}/DroidData.h | 0 samples/{star_wars => learn}/HeroData.h | 0 samples/{star_wars => learn}/HumanData.cpp | 0 samples/{star_wars => learn}/HumanData.h | 0 samples/{star_wars => learn}/MutationData.cpp | 0 samples/{star_wars => learn}/MutationData.h | 0 samples/{star_wars => learn}/QueryData.cpp | 0 samples/{star_wars => learn}/QueryData.h | 0 samples/{star_wars => learn}/ReviewData.cpp | 0 samples/{star_wars => learn}/ReviewData.h | 0 samples/{star_wars => learn}/StarWarsData.cpp | 0 samples/{star_wars => learn}/StarWarsData.h | 0 samples/{star_wars => learn}/sample.cpp | 0 samples/learn/schema/CMakeLists.txt | 12 + samples/learn/{ => schema}/DroidObject.cpp | 0 samples/learn/{ => schema}/DroidObject.h | 0 samples/learn/{ => schema}/HumanObject.cpp | 0 samples/learn/{ => schema}/HumanObject.h | 0 samples/learn/{ => schema}/MutationObject.cpp | 0 samples/learn/{ => schema}/MutationObject.h | 0 samples/learn/{ => schema}/QueryObject.cpp | 0 samples/learn/{ => schema}/QueryObject.h | 0 samples/learn/{ => schema}/ReviewObject.cpp | 0 samples/learn/{ => schema}/ReviewObject.h | 0 samples/learn/{ => schema}/StarWarsObjects.h | 0 samples/learn/{ => schema}/StarWarsSchema.cpp | 0 samples/learn/{ => schema}/StarWarsSchema.h | 0 samples/learn/{ => schema}/learn_schema_files | 0 .../{ => learn/schema}/schema.learn.graphql | 0 samples/today/CMakeLists.txt | 82 ++++ samples/{ => today}/schema.today.graphql | 0 .../separate/AppointmentConnectionObject.cpp | 0 .../separate/AppointmentConnectionObject.h | 0 .../separate/AppointmentEdgeObject.cpp | 0 .../separate/AppointmentEdgeObject.h | 0 .../separate/AppointmentObject.cpp | 0 .../{ => today}/separate/AppointmentObject.h | 0 samples/today/separate/CMakeLists.txt | 12 + .../separate/CompleteTaskPayloadObject.cpp | 0 .../separate/CompleteTaskPayloadObject.h | 0 .../{ => today}/separate/ExpensiveObject.cpp | 0 .../{ => today}/separate/ExpensiveObject.h | 0 .../separate/FolderConnectionObject.cpp | 0 .../separate/FolderConnectionObject.h | 0 .../{ => today}/separate/FolderEdgeObject.cpp | 0 .../{ => today}/separate/FolderEdgeObject.h | 0 samples/{ => today}/separate/FolderObject.cpp | 0 samples/{ => today}/separate/FolderObject.h | 0 .../{ => today}/separate/MutationObject.cpp | 0 samples/{ => today}/separate/MutationObject.h | 0 .../{ => today}/separate/NestedTypeObject.cpp | 0 .../{ => today}/separate/NestedTypeObject.h | 0 .../{ => today}/separate/PageInfoObject.cpp | 0 samples/{ => today}/separate/PageInfoObject.h | 0 samples/{ => today}/separate/QueryObject.cpp | 0 samples/{ => today}/separate/QueryObject.h | 0 .../separate/SubscriptionObject.cpp | 0 .../{ => today}/separate/SubscriptionObject.h | 0 .../separate/TaskConnectionObject.cpp | 0 .../separate/TaskConnectionObject.h | 0 .../{ => today}/separate/TaskEdgeObject.cpp | 0 samples/{ => today}/separate/TaskEdgeObject.h | 0 samples/{ => today}/separate/TaskObject.cpp | 0 samples/{ => today}/separate/TaskObject.h | 0 samples/{ => today}/separate/TodayObjects.h | 0 samples/{ => today}/separate/TodaySchema.cpp | 0 samples/{ => today}/separate/TodaySchema.h | 0 .../separate/separate_schema_files} | 0 .../AppointmentConnectionObject.cpp | 0 .../AppointmentConnectionObject.h | 0 .../AppointmentEdgeObject.cpp | 0 .../AppointmentEdgeObject.h | 0 .../AppointmentObject.cpp | 0 .../AppointmentObject.h | 0 .../separate_nointrospection/CMakeLists.txt | 12 + .../CompleteTaskPayloadObject.cpp | 0 .../CompleteTaskPayloadObject.h | 0 .../ExpensiveObject.cpp | 0 .../ExpensiveObject.h | 0 .../FolderConnectionObject.cpp | 0 .../FolderConnectionObject.h | 0 .../FolderEdgeObject.cpp | 0 .../FolderEdgeObject.h | 0 .../separate_nointrospection/FolderObject.cpp | 0 .../separate_nointrospection/FolderObject.h | 0 .../MutationObject.cpp | 0 .../separate_nointrospection/MutationObject.h | 0 .../NestedTypeObject.cpp | 0 .../NestedTypeObject.h | 0 .../PageInfoObject.cpp | 0 .../separate_nointrospection/PageInfoObject.h | 0 .../separate_nointrospection/QueryObject.cpp | 0 .../separate_nointrospection/QueryObject.h | 0 .../SubscriptionObject.cpp | 0 .../SubscriptionObject.h | 0 .../TaskConnectionObject.cpp | 0 .../TaskConnectionObject.h | 0 .../TaskEdgeObject.cpp | 0 .../separate_nointrospection/TaskEdgeObject.h | 0 .../separate_nointrospection/TaskObject.cpp | 0 .../separate_nointrospection/TaskObject.h | 0 .../separate_nointrospection/TodayObjects.h | 0 .../separate_nointrospection/TodaySchema.cpp | 0 .../separate_nointrospection/TodaySchema.h | 0 .../separate_nointrospection_schema_files} | 0 samples/today/unified/CMakeLists.txt | 12 + samples/{ => today}/unified/TodaySchema.cpp | 0 samples/{ => today}/unified/TodaySchema.h | 0 samples/today/unified/unified_schema_files | 1 + .../unified_nointrospection/CMakeLists.txt | 12 + .../unified_nointrospection/TodaySchema.cpp | 0 .../unified_nointrospection/TodaySchema.h | 0 .../unified_nointrospection_schema_files | 1 + samples/validation/CMakeLists.txt | 13 + samples/validation/schema/CMakeLists.txt | 12 + .../{ => schema}/ValidationSchema.cpp | 0 .../{ => schema}/ValidationSchema.h | 0 .../schema}/schema.validation.graphql | 0 .../validation/schema/validation_schema_files | 1 + test/CMakeLists.txt | 15 +- 127 files changed, 404 insertions(+), 389 deletions(-) create mode 100644 cmake/cppgraphqlgen-functions.cmake create mode 100644 cmake/cppgraphqlgen-update-schema-files.cmake create mode 100644 samples/learn/CMakeLists.txt rename samples/{star_wars => learn}/DroidData.cpp (100%) rename samples/{star_wars => learn}/DroidData.h (100%) rename samples/{star_wars => learn}/HeroData.h (100%) rename samples/{star_wars => learn}/HumanData.cpp (100%) rename samples/{star_wars => learn}/HumanData.h (100%) rename samples/{star_wars => learn}/MutationData.cpp (100%) rename samples/{star_wars => learn}/MutationData.h (100%) rename samples/{star_wars => learn}/QueryData.cpp (100%) rename samples/{star_wars => learn}/QueryData.h (100%) rename samples/{star_wars => learn}/ReviewData.cpp (100%) rename samples/{star_wars => learn}/ReviewData.h (100%) rename samples/{star_wars => learn}/StarWarsData.cpp (100%) rename samples/{star_wars => learn}/StarWarsData.h (100%) rename samples/{star_wars => learn}/sample.cpp (100%) create mode 100644 samples/learn/schema/CMakeLists.txt rename samples/learn/{ => schema}/DroidObject.cpp (100%) rename samples/learn/{ => schema}/DroidObject.h (100%) rename samples/learn/{ => schema}/HumanObject.cpp (100%) rename samples/learn/{ => schema}/HumanObject.h (100%) rename samples/learn/{ => schema}/MutationObject.cpp (100%) rename samples/learn/{ => schema}/MutationObject.h (100%) rename samples/learn/{ => schema}/QueryObject.cpp (100%) rename samples/learn/{ => schema}/QueryObject.h (100%) rename samples/learn/{ => schema}/ReviewObject.cpp (100%) rename samples/learn/{ => schema}/ReviewObject.h (100%) rename samples/learn/{ => schema}/StarWarsObjects.h (100%) rename samples/learn/{ => schema}/StarWarsSchema.cpp (100%) rename samples/learn/{ => schema}/StarWarsSchema.h (100%) rename samples/learn/{ => schema}/learn_schema_files (100%) rename samples/{ => learn/schema}/schema.learn.graphql (100%) create mode 100644 samples/today/CMakeLists.txt rename samples/{ => today}/schema.today.graphql (100%) rename samples/{ => today}/separate/AppointmentConnectionObject.cpp (100%) rename samples/{ => today}/separate/AppointmentConnectionObject.h (100%) rename samples/{ => today}/separate/AppointmentEdgeObject.cpp (100%) rename samples/{ => today}/separate/AppointmentEdgeObject.h (100%) rename samples/{ => today}/separate/AppointmentObject.cpp (100%) rename samples/{ => today}/separate/AppointmentObject.h (100%) create mode 100644 samples/today/separate/CMakeLists.txt rename samples/{ => today}/separate/CompleteTaskPayloadObject.cpp (100%) rename samples/{ => today}/separate/CompleteTaskPayloadObject.h (100%) rename samples/{ => today}/separate/ExpensiveObject.cpp (100%) rename samples/{ => today}/separate/ExpensiveObject.h (100%) rename samples/{ => today}/separate/FolderConnectionObject.cpp (100%) rename samples/{ => today}/separate/FolderConnectionObject.h (100%) rename samples/{ => today}/separate/FolderEdgeObject.cpp (100%) rename samples/{ => today}/separate/FolderEdgeObject.h (100%) rename samples/{ => today}/separate/FolderObject.cpp (100%) rename samples/{ => today}/separate/FolderObject.h (100%) rename samples/{ => today}/separate/MutationObject.cpp (100%) rename samples/{ => today}/separate/MutationObject.h (100%) rename samples/{ => today}/separate/NestedTypeObject.cpp (100%) rename samples/{ => today}/separate/NestedTypeObject.h (100%) rename samples/{ => today}/separate/PageInfoObject.cpp (100%) rename samples/{ => today}/separate/PageInfoObject.h (100%) rename samples/{ => today}/separate/QueryObject.cpp (100%) rename samples/{ => today}/separate/QueryObject.h (100%) rename samples/{ => today}/separate/SubscriptionObject.cpp (100%) rename samples/{ => today}/separate/SubscriptionObject.h (100%) rename samples/{ => today}/separate/TaskConnectionObject.cpp (100%) rename samples/{ => today}/separate/TaskConnectionObject.h (100%) rename samples/{ => today}/separate/TaskEdgeObject.cpp (100%) rename samples/{ => today}/separate/TaskEdgeObject.h (100%) rename samples/{ => today}/separate/TaskObject.cpp (100%) rename samples/{ => today}/separate/TaskObject.h (100%) rename samples/{ => today}/separate/TodayObjects.h (100%) rename samples/{ => today}/separate/TodaySchema.cpp (100%) rename samples/{ => today}/separate/TodaySchema.h (100%) rename samples/{separate/today_schema_files => today/separate/separate_schema_files} (100%) rename samples/{ => today}/separate_nointrospection/AppointmentConnectionObject.cpp (100%) rename samples/{ => today}/separate_nointrospection/AppointmentConnectionObject.h (100%) rename samples/{ => today}/separate_nointrospection/AppointmentEdgeObject.cpp (100%) rename samples/{ => today}/separate_nointrospection/AppointmentEdgeObject.h (100%) rename samples/{ => today}/separate_nointrospection/AppointmentObject.cpp (100%) rename samples/{ => today}/separate_nointrospection/AppointmentObject.h (100%) create mode 100644 samples/today/separate_nointrospection/CMakeLists.txt rename samples/{ => today}/separate_nointrospection/CompleteTaskPayloadObject.cpp (100%) rename samples/{ => today}/separate_nointrospection/CompleteTaskPayloadObject.h (100%) rename samples/{ => today}/separate_nointrospection/ExpensiveObject.cpp (100%) rename samples/{ => today}/separate_nointrospection/ExpensiveObject.h (100%) rename samples/{ => today}/separate_nointrospection/FolderConnectionObject.cpp (100%) rename samples/{ => today}/separate_nointrospection/FolderConnectionObject.h (100%) rename samples/{ => today}/separate_nointrospection/FolderEdgeObject.cpp (100%) rename samples/{ => today}/separate_nointrospection/FolderEdgeObject.h (100%) rename samples/{ => today}/separate_nointrospection/FolderObject.cpp (100%) rename samples/{ => today}/separate_nointrospection/FolderObject.h (100%) rename samples/{ => today}/separate_nointrospection/MutationObject.cpp (100%) rename samples/{ => today}/separate_nointrospection/MutationObject.h (100%) rename samples/{ => today}/separate_nointrospection/NestedTypeObject.cpp (100%) rename samples/{ => today}/separate_nointrospection/NestedTypeObject.h (100%) rename samples/{ => today}/separate_nointrospection/PageInfoObject.cpp (100%) rename samples/{ => today}/separate_nointrospection/PageInfoObject.h (100%) rename samples/{ => today}/separate_nointrospection/QueryObject.cpp (100%) rename samples/{ => today}/separate_nointrospection/QueryObject.h (100%) rename samples/{ => today}/separate_nointrospection/SubscriptionObject.cpp (100%) rename samples/{ => today}/separate_nointrospection/SubscriptionObject.h (100%) rename samples/{ => today}/separate_nointrospection/TaskConnectionObject.cpp (100%) rename samples/{ => today}/separate_nointrospection/TaskConnectionObject.h (100%) rename samples/{ => today}/separate_nointrospection/TaskEdgeObject.cpp (100%) rename samples/{ => today}/separate_nointrospection/TaskEdgeObject.h (100%) rename samples/{ => today}/separate_nointrospection/TaskObject.cpp (100%) rename samples/{ => today}/separate_nointrospection/TaskObject.h (100%) rename samples/{ => today}/separate_nointrospection/TodayObjects.h (100%) rename samples/{ => today}/separate_nointrospection/TodaySchema.cpp (100%) rename samples/{ => today}/separate_nointrospection/TodaySchema.h (100%) rename samples/{separate_nointrospection/today_schema_files => today/separate_nointrospection/separate_nointrospection_schema_files} (100%) create mode 100644 samples/today/unified/CMakeLists.txt rename samples/{ => today}/unified/TodaySchema.cpp (100%) rename samples/{ => today}/unified/TodaySchema.h (100%) create mode 100644 samples/today/unified/unified_schema_files create mode 100644 samples/today/unified_nointrospection/CMakeLists.txt rename samples/{ => today}/unified_nointrospection/TodaySchema.cpp (100%) rename samples/{ => today}/unified_nointrospection/TodaySchema.h (100%) create mode 100644 samples/today/unified_nointrospection/unified_nointrospection_schema_files create mode 100644 samples/validation/CMakeLists.txt create mode 100644 samples/validation/schema/CMakeLists.txt rename samples/validation/{ => schema}/ValidationSchema.cpp (100%) rename samples/validation/{ => schema}/ValidationSchema.h (100%) rename samples/{ => validation/schema}/schema.validation.graphql (100%) create mode 100644 samples/validation/schema/validation_schema_files diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index bc212859..683e85a1 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -10,4 +10,6 @@ write_basic_package_version_file(${PROJECT_NAME}-config-version.cmake COMPATIBIL install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}-config.cmake ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake + ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}-functions.cmake + ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}-update-schema-files.cmake DESTINATION ${GRAPHQL_INSTALL_CMAKE_DIR}/${PROJECT_NAME}) diff --git a/cmake/cppgraphqlgen-config.cmake b/cmake/cppgraphqlgen-config.cmake index 2adc2fb5..98975194 100644 --- a/cmake/cppgraphqlgen-config.cmake +++ b/cmake/cppgraphqlgen-config.cmake @@ -5,7 +5,7 @@ cppgraphqlgen ------------- -The following import targets are created +The following import targets are created: :: @@ -15,8 +15,18 @@ The following import targets are created cppgraphqlgen::graphqlintrospection cppgraphqlgen::graphqljson cppgraphqlgen::schemagen + cppgraphqlgen::clientgen + +The following functions are defined to help with code generation and build targets: + +:: + + update_graphql_schema_files + add_graphql_schema_target + add_graphql_schema_no_introspection_target #]=======================================================================] include(CMakeFindDependencyMacro) find_package(Threads REQUIRED) include("${CMAKE_CURRENT_LIST_DIR}/cppgraphqlgen-targets.cmake") +include("${CMAKE_CURRENT_LIST_DIR}/cppgraphqlgen-functions.cmake") diff --git a/cmake/cppgraphqlgen-functions.cmake b/cmake/cppgraphqlgen-functions.cmake new file mode 100644 index 00000000..3abd3319 --- /dev/null +++ b/cmake/cppgraphqlgen-functions.cmake @@ -0,0 +1,57 @@ +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. + +get_filename_component(GRAPHQL_UPDATE_SCHEMA_FILES_SCRIPT + "${CMAKE_CURRENT_LIST_DIR}/cppgraphqlgen-update-schema-files.cmake" + ABSOLUTE) + +function(update_graphql_schema_files SCHEMA_TARGET SCHEMA_GRAPHQL SCHEMA_PREFIX SCHEMA_NAMESPACE) + set_property(DIRECTORY APPEND + PROPERTY CMAKE_CONFIGURE_DEPENDS ${SCHEMA_TARGET}_schema_files) + + # Collect optional arguments + set(ADDITIONAL_SCHEMAGEN_ARGS "") + if(ARGC GREATER 4) + math(EXPR LAST_ARG "${ARGC} - 1") + foreach(ARGN RANGE 4 ${LAST_ARG}) + set(NEXT_ARG "${ARGV${ARGN}}") + list(APPEND ADDITIONAL_SCHEMAGEN_ARGS "${NEXT_ARG}") + endforeach() + endif() + + add_custom_command( + OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/${SCHEMA_TARGET}_schema_files + COMMAND + ${CMAKE_COMMAND} "-DSCHEMA_SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR}" + "-DSCHEMA_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR}" + "-DSCHEMAGEN_PROGRAM=$" + "-DSCHEMA_TARGET=${SCHEMA_TARGET}" "-DSCHEMA_GRAPHQL=${SCHEMA_GRAPHQL}" + "-DSCHEMA_PREFIX=${SCHEMA_PREFIX}" "-DSCHEMA_NAMESPACE=${SCHEMA_NAMESPACE}" + "-DADDITIONAL_SCHEMAGEN_ARGS=${ADDITIONAL_SCHEMAGEN_ARGS}" + -P ${GRAPHQL_UPDATE_SCHEMA_FILES_SCRIPT} + DEPENDS ${SCHEMA_GRAPHQL} ${GRAPHQL_UPDATE_SCHEMA_FILES_SCRIPT} + COMMENT "Generating ${SCHEMA_TARGET} GraphQL schema" + VERBATIM) +endfunction() + +function(add_graphql_schema_target SCHEMA_TARGET) + add_custom_target(${SCHEMA_TARGET}_update_schema ALL + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${SCHEMA_TARGET}_schema_files) + + file(STRINGS ${SCHEMA_TARGET}_schema_files SCHEMA_FILES) + add_library(${SCHEMA_TARGET}_schema STATIC ${SCHEMA_FILES}) + add_dependencies(${SCHEMA_TARGET}_schema ${SCHEMA_TARGET}_update_schema) + target_include_directories(${SCHEMA_TARGET}_schema PUBLIC $) + target_link_libraries(${SCHEMA_TARGET}_schema PUBLIC cppgraphqlgen::graphqlintrospection) +endfunction() + +function(add_graphql_schema_no_introspection_target SCHEMA_NO_INTROSPECTION_TARGET) + add_custom_target(${SCHEMA_NO_INTROSPECTION_TARGET}_update_schema ALL + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${SCHEMA_NO_INTROSPECTION_TARGET}_schema_files) + + file(STRINGS ${SCHEMA_NO_INTROSPECTION_TARGET}_schema_files SCHEMA_FILES) + add_library(${SCHEMA_NO_INTROSPECTION_TARGET}_schema STATIC ${SCHEMA_FILES}) + add_dependencies(${SCHEMA_NO_INTROSPECTION_TARGET}_schema ${SCHEMA_NO_INTROSPECTION_TARGET}_update_schema) + target_include_directories(${SCHEMA_NO_INTROSPECTION_TARGET}_schema PUBLIC $) + target_link_libraries(${SCHEMA_NO_INTROSPECTION_TARGET}_schema PUBLIC cppgraphqlgen::graphqlservice) +endfunction() diff --git a/cmake/cppgraphqlgen-update-schema-files.cmake b/cmake/cppgraphqlgen-update-schema-files.cmake new file mode 100644 index 00000000..aada3bf3 --- /dev/null +++ b/cmake/cppgraphqlgen-update-schema-files.cmake @@ -0,0 +1,57 @@ +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. + +# Normalize the filesystem paths +get_filename_component(SCHEMA_SOURCE_DIR ${SCHEMA_SOURCE_DIR} ABSOLUTE) +get_filename_component(SCHEMA_BINARY_DIR ${SCHEMA_BINARY_DIR} ABSOLUTE) +get_filename_component(SCHEMAGEN_PROGRAM ${SCHEMAGEN_PROGRAM} ABSOLUTE) +get_filename_component(SCHEMA_GRAPHQL "${SCHEMA_SOURCE_DIR}/${SCHEMA_GRAPHQL}" ABSOLUTE) + +file(MAKE_DIRECTORY ${SCHEMA_BINARY_DIR}) + +# Cleanup all of the stale files in the binary directory +file(GLOB PREVIOUS_FILES ${SCHEMA_BINARY_DIR}/*.h ${SCHEMA_BINARY_DIR}/*.cpp + ${SCHEMA_BINARY_DIR}/${SCHEMA_TARGET}_schema_files) +foreach(PREVIOUS_FILE ${PREVIOUS_FILES}) + file(REMOVE ${PREVIOUS_FILE}) +endforeach() + +set(SCHEMAGEN_ARGS "--schema=${SCHEMA_GRAPHQL}" "--prefix=${SCHEMA_PREFIX}" "--namespace=${SCHEMA_NAMESPACE}") +foreach(SCHEMAGEN_ARG ${ADDITIONAL_SCHEMAGEN_ARGS}) + list(APPEND SCHEMAGEN_ARGS ${SCHEMAGEN_ARG}) +endforeach() + +# Regenerate the sources in the binary directory +execute_process( + COMMAND ${SCHEMAGEN_PROGRAM} ${SCHEMAGEN_ARGS} + OUTPUT_FILE ${SCHEMA_TARGET}_schema_files + WORKING_DIRECTORY ${SCHEMA_BINARY_DIR}) + +# Get the up-to-date list of files in the binary directory +set(FILE_NAMES "") +file(GLOB NEW_FILES ${SCHEMA_BINARY_DIR}/*.h ${SCHEMA_BINARY_DIR}/*.cpp) +foreach(NEW_FILE ${NEW_FILES}) + get_filename_component(NEW_FILE ${NEW_FILE} NAME) + list(APPEND FILE_NAMES "${NEW_FILE}") +endforeach() + +# Don't update the files in the source directory if no files were generated in the binary directory. +if(NOT FILE_NAMES) + message(FATAL_ERROR "Schema generation failed!") +endif() + +# Remove stale files in the source directory +cmake_policy(SET CMP0057 NEW) +file(GLOB OLD_FILES ${SCHEMA_SOURCE_DIR}/*.h ${SCHEMA_SOURCE_DIR}/*.cpp) +foreach(OLD_FILE ${OLD_FILES}) + get_filename_component(OLD_FILE ${OLD_FILE} NAME) + if(NOT OLD_FILE IN_LIST FILE_NAMES) + file(REMOVE "${SCHEMA_SOURCE_DIR}/${OLD_FILE}") + endif() +endforeach() + +# Copy new and modified files from the binary directory to the source directory +execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different + ${SCHEMA_BINARY_DIR}/${SCHEMA_TARGET}_schema_files + ${NEW_FILES} + ${SCHEMA_SOURCE_DIR}) diff --git a/samples/CMakeLists.txt b/samples/CMakeLists.txt index dc1bc540..1e5f7dab 100644 --- a/samples/CMakeLists.txt +++ b/samples/CMakeLists.txt @@ -3,400 +3,80 @@ cmake_minimum_required(VERSION 3.8.2) -if(GRAPHQL_UPDATE_SAMPLES) - # unifiedschema - file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/unified) +if(GRAPHQL_UPDATE_SAMPLES AND GRAPHQL_BUILD_CLIENTGEN) + file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/client) + # query.today.graphql add_custom_command( OUTPUT - ${CMAKE_CURRENT_BINARY_DIR}/unified/TodaySchema.cpp - ${CMAKE_CURRENT_BINARY_DIR}/unified/TodaySchema.h - COMMAND schemagen --schema="${CMAKE_CURRENT_SOURCE_DIR}/schema.today.graphql" --prefix="Today" --namespace="today" --stubs --merge-files + ${CMAKE_CURRENT_BINARY_DIR}/client/QueryClient.cpp + ${CMAKE_CURRENT_BINARY_DIR}/client/QueryClient.h + COMMAND clientgen --schema="${CMAKE_CURRENT_SOURCE_DIR}/today/schema.today.graphql" --request="${CMAKE_CURRENT_SOURCE_DIR}/query.today.graphql" --prefix="Query" --namespace="query" COMMAND ${CMAKE_COMMAND} -E copy_if_different - TodaySchema.cpp - TodaySchema.h - ${CMAKE_CURRENT_SOURCE_DIR}/unified - DEPENDS schemagen graphqlpeg schema.today.graphql - WORKING_DIRECTORY unified - COMMENT "Generating mock TodaySchema files (--stubs --merge-files)") - - # unifiedschema_nointrospection - file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/unified_nointrospection) - + QueryClient.cpp + QueryClient.h + ${CMAKE_CURRENT_SOURCE_DIR}/client + DEPENDS clientgen today/schema.today.graphql query.today.graphql + WORKING_DIRECTORY client + COMMENT "Generating QueryClient samples") + + # mutate.today.graphql add_custom_command( OUTPUT - ${CMAKE_CURRENT_BINARY_DIR}/unified_nointrospection/TodaySchema.cpp - ${CMAKE_CURRENT_BINARY_DIR}/unified_nointrospection/TodaySchema.h - COMMAND schemagen --schema="${CMAKE_CURRENT_SOURCE_DIR}/schema.today.graphql" --prefix="Today" --namespace="today" --stubs --merge-files --no-introspection + ${CMAKE_CURRENT_BINARY_DIR}/client/MutateClient.cpp + ${CMAKE_CURRENT_BINARY_DIR}/client/MutateClient.h + COMMAND clientgen --schema="${CMAKE_CURRENT_SOURCE_DIR}/today/schema.today.graphql" --request="${CMAKE_CURRENT_SOURCE_DIR}/mutate.today.graphql" --prefix="Mutate" --namespace="mutate" COMMAND ${CMAKE_COMMAND} -E copy_if_different - TodaySchema.cpp - TodaySchema.h - ${CMAKE_CURRENT_SOURCE_DIR}/unified_nointrospection - DEPENDS schemagen graphqlpeg schema.today.graphql - WORKING_DIRECTORY unified_nointrospection - COMMENT "Generating mock TodaySchema files without Introspection (--stubs --merge-files --no-introspection)") - - # validationschema - file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/validation) - + MutateClient.cpp + MutateClient.h + ${CMAKE_CURRENT_SOURCE_DIR}/client + DEPENDS clientgen today/schema.today.graphql mutate.today.graphql + WORKING_DIRECTORY client + COMMENT "Generating MutateClient samples") + + # subscribe.today.graphql add_custom_command( OUTPUT - ${CMAKE_CURRENT_BINARY_DIR}/validation/ValidationSchema.cpp - ${CMAKE_CURRENT_BINARY_DIR}/validation/ValidationSchema.h - COMMAND schemagen --schema="${CMAKE_CURRENT_SOURCE_DIR}/schema.validation.graphql" --prefix="Validation" --namespace="validation" --stubs --merge-files + ${CMAKE_CURRENT_BINARY_DIR}/client/SubscribeClient.cpp + ${CMAKE_CURRENT_BINARY_DIR}/client/SubscribeClient.h + COMMAND clientgen --schema="${CMAKE_CURRENT_SOURCE_DIR}/today/schema.today.graphql" --request="${CMAKE_CURRENT_SOURCE_DIR}/subscribe.today.graphql" --prefix="Subscribe" --namespace="subscribe" COMMAND ${CMAKE_COMMAND} -E copy_if_different - ValidationSchema.cpp - ValidationSchema.h - ${CMAKE_CURRENT_SOURCE_DIR}/validation - DEPENDS schemagen graphqlpeg schema.validation.graphql - WORKING_DIRECTORY validation - COMMENT "Generating ValidationSchema files (--stubs --merge-files)") - - # separateschema - file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/separate) - - add_custom_command( - OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/separate/today_schema_files - COMMAND schemagen --schema="${CMAKE_CURRENT_SOURCE_DIR}/schema.today.graphql" --prefix="Today" --namespace="today" --stubs > today_schema_files - COMMAND ${CMAKE_COMMAND} -E copy_if_different today_schema_files ${CMAKE_CURRENT_SOURCE_DIR}/separate - DEPENDS schemagen graphqlpeg schema.today.graphql - WORKING_DIRECTORY separate - COMMENT "Generating mock TodaySchema (--stubs)") - - # separateschema_nointrospection - file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/separate_nointrospection) - + SubscribeClient.cpp + SubscribeClient.h + ${CMAKE_CURRENT_SOURCE_DIR}/client + DEPENDS clientgen today/schema.today.graphql subscribe.today.graphql + WORKING_DIRECTORY client + COMMENT "Generating SubscribeClient samples") + + # client.benchmark.today.graphql add_custom_command( - OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/separate_nointrospection/today_schema_files - COMMAND schemagen --schema="${CMAKE_CURRENT_SOURCE_DIR}/schema.today.graphql" --prefix="Today" --namespace="today" --no-introspection --stubs > today_schema_files - COMMAND ${CMAKE_COMMAND} -E copy_if_different today_schema_files ${CMAKE_CURRENT_SOURCE_DIR}/separate_nointrospection - DEPENDS schemagen graphqlpeg schema.today.graphql - WORKING_DIRECTORY separate_nointrospection - COMMENT "Generating mock TodaySchema without Introspection (--stubs --no-introspection)") - - # learn - file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/learn) - - add_custom_command( - OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/learn/learn_schema_files - COMMAND schemagen --schema="${CMAKE_CURRENT_SOURCE_DIR}/schema.learn.graphql" --prefix="StarWars" --namespace="learn" > learn_schema_files - COMMAND ${CMAKE_COMMAND} -E copy_if_different learn_schema_files ${CMAKE_CURRENT_SOURCE_DIR}/learn - DEPENDS schemagen graphqlpeg schema.learn.graphql - WORKING_DIRECTORY learn - COMMENT "Generating mock StarWarsSchema") - - add_custom_command( - OUTPUT updated_samples - COMMAND ${CMAKE_COMMAND} - "-DSCHEMA_SOURCE_LIST=today_schema_files" - "-DSCHEMA_SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR}/separate" - "-DSCHEMA_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR}/separate" - -P "${CMAKE_CURRENT_SOURCE_DIR}/update_samples.cmake" - COMMAND ${CMAKE_COMMAND} - "-DSCHEMA_SOURCE_LIST=today_schema_files" - "-DSCHEMA_SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR}/separate_nointrospection" - "-DSCHEMA_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR}/separate_nointrospection" - -P "${CMAKE_CURRENT_SOURCE_DIR}/update_samples.cmake" - COMMAND ${CMAKE_COMMAND} - "-DSCHEMA_SOURCE_LIST=learn_schema_files" - "-DSCHEMA_SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR}/learn" - "-DSCHEMA_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR}/learn" - -P "${CMAKE_CURRENT_SOURCE_DIR}/update_samples.cmake" - COMMAND ${CMAKE_COMMAND} -E touch updated_samples - DEPENDS - ${CMAKE_CURRENT_BINARY_DIR}/separate/today_schema_files - ${CMAKE_CURRENT_BINARY_DIR}/separate_nointrospection/today_schema_files - ${CMAKE_CURRENT_BINARY_DIR}/learn/learn_schema_files - COMMENT "Updating sample files") - - add_custom_target(update_samples ALL - DEPENDS - ${CMAKE_CURRENT_BINARY_DIR}/unified/TodaySchema.cpp - ${CMAKE_CURRENT_BINARY_DIR}/unified/TodaySchema.h - ${CMAKE_CURRENT_BINARY_DIR}/unified_nointrospection/TodaySchema.cpp - ${CMAKE_CURRENT_BINARY_DIR}/unified_nointrospection/TodaySchema.h - ${CMAKE_CURRENT_BINARY_DIR}/validation/ValidationSchema.cpp - ${CMAKE_CURRENT_BINARY_DIR}/validation/ValidationSchema.h - updated_samples) - - if(GRAPHQL_BUILD_CLIENTGEN) - file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/client) - - # query.today.graphql - add_custom_command( - OUTPUT - ${CMAKE_CURRENT_BINARY_DIR}/client/QueryClient.cpp - ${CMAKE_CURRENT_BINARY_DIR}/client/QueryClient.h - COMMAND clientgen --schema="${CMAKE_CURRENT_SOURCE_DIR}/schema.today.graphql" --request="${CMAKE_CURRENT_SOURCE_DIR}/query.today.graphql" --prefix="Query" --namespace="query" - COMMAND ${CMAKE_COMMAND} -E copy_if_different - QueryClient.cpp - QueryClient.h - ${CMAKE_CURRENT_SOURCE_DIR}/client - DEPENDS clientgen schema.today.graphql query.today.graphql - WORKING_DIRECTORY client - COMMENT "Generating QueryClient samples") - - # mutate.today.graphql - add_custom_command( - OUTPUT - ${CMAKE_CURRENT_BINARY_DIR}/client/MutateClient.cpp - ${CMAKE_CURRENT_BINARY_DIR}/client/MutateClient.h - COMMAND clientgen --schema="${CMAKE_CURRENT_SOURCE_DIR}/schema.today.graphql" --request="${CMAKE_CURRENT_SOURCE_DIR}/mutate.today.graphql" --prefix="Mutate" --namespace="mutate" - COMMAND ${CMAKE_COMMAND} -E copy_if_different - MutateClient.cpp - MutateClient.h - ${CMAKE_CURRENT_SOURCE_DIR}/client - DEPENDS clientgen schema.today.graphql mutate.today.graphql - WORKING_DIRECTORY client - COMMENT "Generating MutateClient samples") - - # subscribe.today.graphql - add_custom_command( - OUTPUT - ${CMAKE_CURRENT_BINARY_DIR}/client/SubscribeClient.cpp - ${CMAKE_CURRENT_BINARY_DIR}/client/SubscribeClient.h - COMMAND clientgen --schema="${CMAKE_CURRENT_SOURCE_DIR}/schema.today.graphql" --request="${CMAKE_CURRENT_SOURCE_DIR}/subscribe.today.graphql" --prefix="Subscribe" --namespace="subscribe" - COMMAND ${CMAKE_COMMAND} -E copy_if_different - SubscribeClient.cpp - SubscribeClient.h - ${CMAKE_CURRENT_SOURCE_DIR}/client - DEPENDS clientgen schema.today.graphql subscribe.today.graphql - WORKING_DIRECTORY client - COMMENT "Generating SubscribeClient samples") - - # client.benchmark.today.graphql - add_custom_command( - OUTPUT - ${CMAKE_CURRENT_BINARY_DIR}/client/BenchmarkClient.cpp - ${CMAKE_CURRENT_BINARY_DIR}/client/BenchmarkClient.h - COMMAND clientgen --schema="${CMAKE_CURRENT_SOURCE_DIR}/schema.today.graphql" --request="${CMAKE_CURRENT_SOURCE_DIR}/client.benchmark.today.graphql" --prefix="Benchmark" --namespace="benchmark" - COMMAND ${CMAKE_COMMAND} -E copy_if_different - BenchmarkClient.cpp - BenchmarkClient.h - ${CMAKE_CURRENT_SOURCE_DIR}/client - DEPENDS clientgen schema.today.graphql client.benchmark.today.graphql - WORKING_DIRECTORY client - COMMENT "Generating BenchmarkClient samples") - - add_custom_target(update_client_samples ALL - DEPENDS - ${CMAKE_CURRENT_BINARY_DIR}/client/QueryClient.cpp - ${CMAKE_CURRENT_BINARY_DIR}/client/QueryClient.h - ${CMAKE_CURRENT_BINARY_DIR}/client/MutateClient.cpp - ${CMAKE_CURRENT_BINARY_DIR}/client/MutateClient.h - ${CMAKE_CURRENT_BINARY_DIR}/client/SubscribeClient.cpp - ${CMAKE_CURRENT_BINARY_DIR}/client/SubscribeClient.h - ${CMAKE_CURRENT_BINARY_DIR}/client/BenchmarkClient.cpp - ${CMAKE_CURRENT_BINARY_DIR}/client/BenchmarkClient.h) - endif() -endif() - -# separateschema -set(SEPARATE_SCHEMA_PATHS "") -file(STRINGS ${CMAKE_CURRENT_SOURCE_DIR}/separate/today_schema_files SEPARATE_SCHEMA_FILES) -foreach(CPP_FILE IN LISTS SEPARATE_SCHEMA_FILES) - list(APPEND SEPARATE_SCHEMA_PATHS "${CMAKE_CURRENT_SOURCE_DIR}/separate/${CPP_FILE}") -endforeach(CPP_FILE) - -add_library(separateschema STATIC ${SEPARATE_SCHEMA_PATHS}) -target_link_libraries(separateschema PUBLIC graphqlintrospection) -target_compile_definitions(separateschema PUBLIC IMPL_SEPARATE_TODAY) -target_include_directories(separateschema PUBLIC - ${CMAKE_CURRENT_SOURCE_DIR}/../include - ${CMAKE_CURRENT_SOURCE_DIR}/../PEGTL/include - ${CMAKE_CURRENT_SOURCE_DIR}/separate) - -if(GRAPHQL_UPDATE_SAMPLES) - # wait for the sample update to complete - add_dependencies(separateschema update_samples) -endif() - -# separateschema_nointrospection -set(SEPARATE_NOINTROSPECTION_SCHEMA_PATHS "") -file(STRINGS ${CMAKE_CURRENT_SOURCE_DIR}/separate_nointrospection/today_schema_files SEPARATE_NOINTROSPECTION_SCHEMA_FILES) -foreach(CPP_FILE IN LISTS SEPARATE_NOINTROSPECTION_SCHEMA_FILES) - list(APPEND SEPARATE_NOINTROSPECTION_SCHEMA_PATHS "${CMAKE_CURRENT_SOURCE_DIR}/separate_nointrospection/${CPP_FILE}") -endforeach(CPP_FILE) - -add_library(separateschema_nointrospection STATIC ${SEPARATE_NOINTROSPECTION_SCHEMA_PATHS}) -target_link_libraries(separateschema_nointrospection PUBLIC graphqlservice) -target_compile_definitions(separateschema_nointrospection PUBLIC IMPL_SEPARATE_TODAY) -target_include_directories(separateschema_nointrospection PUBLIC - ${CMAKE_CURRENT_SOURCE_DIR}/../include - ${CMAKE_CURRENT_SOURCE_DIR}/../PEGTL/include - ${CMAKE_CURRENT_SOURCE_DIR}/separate_nointrospection) - -if(GRAPHQL_UPDATE_SAMPLES) - # wait for the sample update to complete - add_dependencies(separateschema_nointrospection update_samples) -endif() - -# learnschema -set(LEARN_SCHEMA_PATHS "") -file(STRINGS ${CMAKE_CURRENT_SOURCE_DIR}/learn/learn_schema_files LEARN_SCHEMA_FILES) -foreach(CPP_FILE IN LISTS LEARN_SCHEMA_FILES) - list(APPEND LEARN_SCHEMA_PATHS "${CMAKE_CURRENT_SOURCE_DIR}/learn/${CPP_FILE}") -endforeach(CPP_FILE) - -add_library(learnschema STATIC ${LEARN_SCHEMA_PATHS}) -target_link_libraries(learnschema PUBLIC graphqlintrospection) -target_include_directories(learnschema PUBLIC - ${CMAKE_CURRENT_SOURCE_DIR}/../include - ${CMAKE_CURRENT_SOURCE_DIR}/../PEGTL/include - ${CMAKE_CURRENT_SOURCE_DIR}/learn) - -if(GRAPHQL_UPDATE_SAMPLES) - # wait for the sample update to complete - add_dependencies(learnschema update_samples) -endif() - -# separategraphql -add_library(separategraphql STATIC today/TodayMock.cpp) -target_link_libraries(separategraphql PUBLIC separateschema) -target_include_directories(separategraphql PUBLIC today) - -# separategraphql_nointrospection -add_library(separategraphql_nointrospection STATIC today/TodayMock.cpp) -target_link_libraries(separategraphql_nointrospection PUBLIC separateschema_nointrospection) -target_include_directories(separategraphql_nointrospection PUBLIC today) - -# star_wars -add_library(star_wars STATIC - star_wars/DroidData.cpp - star_wars/HumanData.cpp - star_wars/QueryData.cpp - star_wars/ReviewData.cpp - star_wars/MutationData.cpp - star_wars/StarWarsData.cpp) -target_link_libraries(star_wars PUBLIC learnschema) -target_include_directories(star_wars PUBLIC star_wars) - -# sample -add_executable(sample today/sample.cpp) -target_link_libraries(sample PRIVATE - separategraphql - graphqljson) -target_include_directories(sample PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR}/../include - ${CMAKE_CURRENT_SOURCE_DIR}/../PEGTL/include) - -# sample_nointrospection -add_executable(sample_nointrospection today/sample.cpp) -target_link_libraries(sample_nointrospection PRIVATE - separategraphql_nointrospection - graphqljson) -target_include_directories(sample_nointrospection PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR}/../include - ${CMAKE_CURRENT_SOURCE_DIR}/../PEGTL/include) - -# learn_star_wars -add_executable(learn_star_wars star_wars/sample.cpp) -target_link_libraries(learn_star_wars PRIVATE - star_wars - graphqljson) -target_include_directories(learn_star_wars PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR}/../include - ${CMAKE_CURRENT_SOURCE_DIR}/../PEGTL/include) - -if(WIN32 AND BUILD_SHARED_LIBS) - add_custom_command(OUTPUT copied_sample_dlls + OUTPUT + ${CMAKE_CURRENT_BINARY_DIR}/client/BenchmarkClient.cpp + ${CMAKE_CURRENT_BINARY_DIR}/client/BenchmarkClient.h + COMMAND clientgen --schema="${CMAKE_CURRENT_SOURCE_DIR}/today/schema.today.graphql" --request="${CMAKE_CURRENT_SOURCE_DIR}/client.benchmark.today.graphql" --prefix="Benchmark" --namespace="benchmark" COMMAND ${CMAKE_COMMAND} -E copy_if_different - $ - $ - $ - $ - $ - $ - ${CMAKE_CURRENT_BINARY_DIR} - COMMAND ${CMAKE_COMMAND} -E touch copied_sample_dlls + BenchmarkClient.cpp + BenchmarkClient.h + ${CMAKE_CURRENT_SOURCE_DIR}/client + DEPENDS clientgen today/schema.today.graphql client.benchmark.today.graphql + WORKING_DIRECTORY client + COMMENT "Generating BenchmarkClient samples") + + add_custom_target(update_client_samples ALL DEPENDS - graphqlservice - graphqlintrospection - graphqljson - graphqlpeg - graphqlresponse - graphqlclient) - - add_custom_target(copy_sample_dlls DEPENDS copied_sample_dlls) - - add_dependencies(sample copy_sample_dlls) - add_dependencies(sample_nointrospection copy_sample_dlls) + ${CMAKE_CURRENT_BINARY_DIR}/client/QueryClient.cpp + ${CMAKE_CURRENT_BINARY_DIR}/client/QueryClient.h + ${CMAKE_CURRENT_BINARY_DIR}/client/MutateClient.cpp + ${CMAKE_CURRENT_BINARY_DIR}/client/MutateClient.h + ${CMAKE_CURRENT_BINARY_DIR}/client/SubscribeClient.cpp + ${CMAKE_CURRENT_BINARY_DIR}/client/SubscribeClient.h + ${CMAKE_CURRENT_BINARY_DIR}/client/BenchmarkClient.cpp + ${CMAKE_CURRENT_BINARY_DIR}/client/BenchmarkClient.h) endif() -# benchmark -add_executable(benchmark today/benchmark.cpp) -target_link_libraries(benchmark PRIVATE - separategraphql - graphqljson) -target_include_directories(benchmark PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR}/../include - ${CMAKE_CURRENT_SOURCE_DIR}/../PEGTL/include) - -# benchmark_nointrospection -add_executable(benchmark_nointrospection today/benchmark.cpp) -target_link_libraries(benchmark_nointrospection PRIVATE - separategraphql_nointrospection - graphqljson) -target_include_directories(benchmark_nointrospection PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR}/../include - ${CMAKE_CURRENT_SOURCE_DIR}/../PEGTL/include) - -if(WIN32 AND BUILD_SHARED_LIBS) - add_dependencies(benchmark copy_sample_dlls) - add_dependencies(benchmark_nointrospection copy_sample_dlls) -endif() - -if(GRAPHQL_BUILD_TESTS) - # tests - add_library(unifiedschema STATIC ${CMAKE_CURRENT_SOURCE_DIR}/unified/TodaySchema.cpp) - target_link_libraries(unifiedschema PUBLIC graphqlintrospection) - target_include_directories(unifiedschema PUBLIC - ${CMAKE_CURRENT_SOURCE_DIR}/../include - ${CMAKE_CURRENT_SOURCE_DIR}/../PEGTL/include - ${CMAKE_CURRENT_SOURCE_DIR}/unified) - - if(GRAPHQL_UPDATE_SAMPLES) - # wait for the sample update to complete - add_dependencies(unifiedschema update_samples) - endif() - - add_library(unifiedgraphql STATIC today/TodayMock.cpp) - target_link_libraries(unifiedgraphql PUBLIC unifiedschema) - target_include_directories(unifiedgraphql PUBLIC today) - add_bigobj_flag(unifiedgraphql) - - add_library(unifiedschema_nointrospection STATIC ${CMAKE_CURRENT_SOURCE_DIR}/unified_nointrospection/TodaySchema.cpp) - target_link_libraries(unifiedschema_nointrospection PUBLIC graphqlservice) - target_include_directories(unifiedschema_nointrospection PUBLIC - ${CMAKE_CURRENT_SOURCE_DIR}/../include - ${CMAKE_CURRENT_SOURCE_DIR}/../PEGTL/include - ${CMAKE_CURRENT_SOURCE_DIR}/unified_nointrospection) - - if(GRAPHQL_UPDATE_SAMPLES) - # wait for the sample update to complete - add_dependencies(unifiedschema_nointrospection update_samples) - endif() - - add_library(unifiedgraphql_nointrospection STATIC today/TodayMock.cpp) - target_link_libraries(unifiedgraphql_nointrospection PUBLIC unifiedschema_nointrospection) - target_include_directories(unifiedgraphql_nointrospection PUBLIC today) - add_bigobj_flag(unifiedgraphql_nointrospection) - - add_library(validationgraphql STATIC - ${CMAKE_CURRENT_SOURCE_DIR}/validation/ValidationMock.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/validation/ValidationSchema.cpp) - target_link_libraries(validationgraphql PUBLIC graphqlintrospection) - target_include_directories(validationgraphql PUBLIC - ${CMAKE_CURRENT_SOURCE_DIR}/../include - ${CMAKE_CURRENT_SOURCE_DIR}/../PEGTL/include - ${CMAKE_CURRENT_SOURCE_DIR}/validation) - add_bigobj_flag(validationgraphql) - - if(GRAPHQL_UPDATE_SAMPLES) - # wait for the sample update to complete - add_dependencies(validationgraphql update_samples) - endif() -endif() +add_subdirectory(learn) +add_subdirectory(today) +add_subdirectory(validation) # todayclient add_library(todayclient STATIC diff --git a/samples/learn/CMakeLists.txt b/samples/learn/CMakeLists.txt new file mode 100644 index 00000000..427b0a16 --- /dev/null +++ b/samples/learn/CMakeLists.txt @@ -0,0 +1,42 @@ +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. + +cmake_minimum_required(VERSION 3.8.2) + +add_subdirectory(schema) +add_library(star_wars STATIC + DroidData.cpp + HumanData.cpp + QueryData.cpp + ReviewData.cpp + MutationData.cpp + StarWarsData.cpp) +target_link_libraries(star_wars PUBLIC learn_schema) +target_include_directories(star_wars PUBLIC star_wars) + +add_executable(learn_star_wars sample.cpp) +target_link_libraries(learn_star_wars PRIVATE + star_wars + graphqljson) + +if(WIN32 AND BUILD_SHARED_LIBS) + add_custom_command(OUTPUT copied_learn_dlls + COMMAND ${CMAKE_COMMAND} -E copy_if_different + $ + $ + $ + $ + $ + ${CMAKE_CURRENT_BINARY_DIR} + COMMAND ${CMAKE_COMMAND} -E touch copied_sample_dlls + DEPENDS + graphqlservice + graphqlintrospection + graphqljson + graphqlpeg + graphqlresponse) + + add_custom_target(copy_sample_dlls DEPENDS copied_sample_dlls) + + add_dependencies(learn_star_wars copy_sample_dlls) +endif() diff --git a/samples/star_wars/DroidData.cpp b/samples/learn/DroidData.cpp similarity index 100% rename from samples/star_wars/DroidData.cpp rename to samples/learn/DroidData.cpp diff --git a/samples/star_wars/DroidData.h b/samples/learn/DroidData.h similarity index 100% rename from samples/star_wars/DroidData.h rename to samples/learn/DroidData.h diff --git a/samples/star_wars/HeroData.h b/samples/learn/HeroData.h similarity index 100% rename from samples/star_wars/HeroData.h rename to samples/learn/HeroData.h diff --git a/samples/star_wars/HumanData.cpp b/samples/learn/HumanData.cpp similarity index 100% rename from samples/star_wars/HumanData.cpp rename to samples/learn/HumanData.cpp diff --git a/samples/star_wars/HumanData.h b/samples/learn/HumanData.h similarity index 100% rename from samples/star_wars/HumanData.h rename to samples/learn/HumanData.h diff --git a/samples/star_wars/MutationData.cpp b/samples/learn/MutationData.cpp similarity index 100% rename from samples/star_wars/MutationData.cpp rename to samples/learn/MutationData.cpp diff --git a/samples/star_wars/MutationData.h b/samples/learn/MutationData.h similarity index 100% rename from samples/star_wars/MutationData.h rename to samples/learn/MutationData.h diff --git a/samples/star_wars/QueryData.cpp b/samples/learn/QueryData.cpp similarity index 100% rename from samples/star_wars/QueryData.cpp rename to samples/learn/QueryData.cpp diff --git a/samples/star_wars/QueryData.h b/samples/learn/QueryData.h similarity index 100% rename from samples/star_wars/QueryData.h rename to samples/learn/QueryData.h diff --git a/samples/star_wars/ReviewData.cpp b/samples/learn/ReviewData.cpp similarity index 100% rename from samples/star_wars/ReviewData.cpp rename to samples/learn/ReviewData.cpp diff --git a/samples/star_wars/ReviewData.h b/samples/learn/ReviewData.h similarity index 100% rename from samples/star_wars/ReviewData.h rename to samples/learn/ReviewData.h diff --git a/samples/star_wars/StarWarsData.cpp b/samples/learn/StarWarsData.cpp similarity index 100% rename from samples/star_wars/StarWarsData.cpp rename to samples/learn/StarWarsData.cpp diff --git a/samples/star_wars/StarWarsData.h b/samples/learn/StarWarsData.h similarity index 100% rename from samples/star_wars/StarWarsData.h rename to samples/learn/StarWarsData.h diff --git a/samples/star_wars/sample.cpp b/samples/learn/sample.cpp similarity index 100% rename from samples/star_wars/sample.cpp rename to samples/learn/sample.cpp diff --git a/samples/learn/schema/CMakeLists.txt b/samples/learn/schema/CMakeLists.txt new file mode 100644 index 00000000..db13a481 --- /dev/null +++ b/samples/learn/schema/CMakeLists.txt @@ -0,0 +1,12 @@ +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. + +cmake_minimum_required(VERSION 3.8.2) + +include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/cppgraphqlgen-functions.cmake) + +if(GRAPHQL_UPDATE_SAMPLES) + update_graphql_schema_files(learn schema.learn.graphql StarWars learn) +endif() + +add_graphql_schema_target(learn) diff --git a/samples/learn/DroidObject.cpp b/samples/learn/schema/DroidObject.cpp similarity index 100% rename from samples/learn/DroidObject.cpp rename to samples/learn/schema/DroidObject.cpp diff --git a/samples/learn/DroidObject.h b/samples/learn/schema/DroidObject.h similarity index 100% rename from samples/learn/DroidObject.h rename to samples/learn/schema/DroidObject.h diff --git a/samples/learn/HumanObject.cpp b/samples/learn/schema/HumanObject.cpp similarity index 100% rename from samples/learn/HumanObject.cpp rename to samples/learn/schema/HumanObject.cpp diff --git a/samples/learn/HumanObject.h b/samples/learn/schema/HumanObject.h similarity index 100% rename from samples/learn/HumanObject.h rename to samples/learn/schema/HumanObject.h diff --git a/samples/learn/MutationObject.cpp b/samples/learn/schema/MutationObject.cpp similarity index 100% rename from samples/learn/MutationObject.cpp rename to samples/learn/schema/MutationObject.cpp diff --git a/samples/learn/MutationObject.h b/samples/learn/schema/MutationObject.h similarity index 100% rename from samples/learn/MutationObject.h rename to samples/learn/schema/MutationObject.h diff --git a/samples/learn/QueryObject.cpp b/samples/learn/schema/QueryObject.cpp similarity index 100% rename from samples/learn/QueryObject.cpp rename to samples/learn/schema/QueryObject.cpp diff --git a/samples/learn/QueryObject.h b/samples/learn/schema/QueryObject.h similarity index 100% rename from samples/learn/QueryObject.h rename to samples/learn/schema/QueryObject.h diff --git a/samples/learn/ReviewObject.cpp b/samples/learn/schema/ReviewObject.cpp similarity index 100% rename from samples/learn/ReviewObject.cpp rename to samples/learn/schema/ReviewObject.cpp diff --git a/samples/learn/ReviewObject.h b/samples/learn/schema/ReviewObject.h similarity index 100% rename from samples/learn/ReviewObject.h rename to samples/learn/schema/ReviewObject.h diff --git a/samples/learn/StarWarsObjects.h b/samples/learn/schema/StarWarsObjects.h similarity index 100% rename from samples/learn/StarWarsObjects.h rename to samples/learn/schema/StarWarsObjects.h diff --git a/samples/learn/StarWarsSchema.cpp b/samples/learn/schema/StarWarsSchema.cpp similarity index 100% rename from samples/learn/StarWarsSchema.cpp rename to samples/learn/schema/StarWarsSchema.cpp diff --git a/samples/learn/StarWarsSchema.h b/samples/learn/schema/StarWarsSchema.h similarity index 100% rename from samples/learn/StarWarsSchema.h rename to samples/learn/schema/StarWarsSchema.h diff --git a/samples/learn/learn_schema_files b/samples/learn/schema/learn_schema_files similarity index 100% rename from samples/learn/learn_schema_files rename to samples/learn/schema/learn_schema_files diff --git a/samples/schema.learn.graphql b/samples/learn/schema/schema.learn.graphql similarity index 100% rename from samples/schema.learn.graphql rename to samples/learn/schema/schema.learn.graphql diff --git a/samples/today/CMakeLists.txt b/samples/today/CMakeLists.txt new file mode 100644 index 00000000..157619e9 --- /dev/null +++ b/samples/today/CMakeLists.txt @@ -0,0 +1,82 @@ +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. + +cmake_minimum_required(VERSION 3.8.2) + +# separategraphql +add_subdirectory(separate) +add_library(separategraphql STATIC TodayMock.cpp) +target_link_libraries(separategraphql PUBLIC separate_schema) +target_include_directories(separategraphql PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) +target_compile_definitions(separategraphql PUBLIC IMPL_SEPARATE_TODAY) + +# separategraphql_nointrospection +add_subdirectory(separate_nointrospection) +add_library(separategraphql_nointrospection STATIC TodayMock.cpp) +target_link_libraries(separategraphql_nointrospection PUBLIC separate_nointrospection_schema) +target_include_directories(separategraphql_nointrospection PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) +target_compile_definitions(separategraphql_nointrospection PUBLIC IMPL_SEPARATE_TODAY) + +# sample +add_executable(sample sample.cpp) +target_link_libraries(sample PRIVATE + separategraphql + graphqljson) + +# sample_nointrospection +add_executable(sample_nointrospection sample.cpp) +target_link_libraries(sample_nointrospection PRIVATE + separategraphql_nointrospection + graphqljson) + +# benchmark +add_executable(benchmark benchmark.cpp) +target_link_libraries(benchmark PRIVATE + separategraphql + graphqljson) + +# benchmark_nointrospection +add_executable(benchmark_nointrospection benchmark.cpp) +target_link_libraries(benchmark_nointrospection PRIVATE + separategraphql_nointrospection + graphqljson) + +if(WIN32 AND BUILD_SHARED_LIBS) + add_custom_command(OUTPUT copied_sample_dlls + COMMAND ${CMAKE_COMMAND} -E copy_if_different + $ + $ + $ + $ + $ + ${CMAKE_CURRENT_BINARY_DIR} + COMMAND ${CMAKE_COMMAND} -E touch copied_sample_dlls + DEPENDS + graphqlservice + graphqlintrospection + graphqljson + graphqlpeg + graphqlresponse) + + add_custom_target(copy_sample_dlls DEPENDS copied_sample_dlls) + + add_dependencies(sample copy_sample_dlls) + add_dependencies(sample_nointrospection copy_sample_dlls) + add_dependencies(benchmark copy_sample_dlls) + add_dependencies(benchmark_nointrospection copy_sample_dlls) +endif() + +if(GRAPHQL_BUILD_TESTS) + # tests + add_subdirectory(unified) + add_library(unifiedgraphql STATIC TodayMock.cpp) + target_link_libraries(unifiedgraphql PUBLIC unified_schema) + target_include_directories(unifiedgraphql PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) + add_bigobj_flag(unifiedgraphql) + + add_subdirectory(unified_nointrospection) + add_library(unifiedgraphql_nointrospection STATIC TodayMock.cpp) + target_link_libraries(unifiedgraphql_nointrospection PUBLIC unified_nointrospection_schema) + target_include_directories(unifiedgraphql_nointrospection PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) + add_bigobj_flag(unifiedgraphql_nointrospection) +endif() diff --git a/samples/schema.today.graphql b/samples/today/schema.today.graphql similarity index 100% rename from samples/schema.today.graphql rename to samples/today/schema.today.graphql diff --git a/samples/separate/AppointmentConnectionObject.cpp b/samples/today/separate/AppointmentConnectionObject.cpp similarity index 100% rename from samples/separate/AppointmentConnectionObject.cpp rename to samples/today/separate/AppointmentConnectionObject.cpp diff --git a/samples/separate/AppointmentConnectionObject.h b/samples/today/separate/AppointmentConnectionObject.h similarity index 100% rename from samples/separate/AppointmentConnectionObject.h rename to samples/today/separate/AppointmentConnectionObject.h diff --git a/samples/separate/AppointmentEdgeObject.cpp b/samples/today/separate/AppointmentEdgeObject.cpp similarity index 100% rename from samples/separate/AppointmentEdgeObject.cpp rename to samples/today/separate/AppointmentEdgeObject.cpp diff --git a/samples/separate/AppointmentEdgeObject.h b/samples/today/separate/AppointmentEdgeObject.h similarity index 100% rename from samples/separate/AppointmentEdgeObject.h rename to samples/today/separate/AppointmentEdgeObject.h diff --git a/samples/separate/AppointmentObject.cpp b/samples/today/separate/AppointmentObject.cpp similarity index 100% rename from samples/separate/AppointmentObject.cpp rename to samples/today/separate/AppointmentObject.cpp diff --git a/samples/separate/AppointmentObject.h b/samples/today/separate/AppointmentObject.h similarity index 100% rename from samples/separate/AppointmentObject.h rename to samples/today/separate/AppointmentObject.h diff --git a/samples/today/separate/CMakeLists.txt b/samples/today/separate/CMakeLists.txt new file mode 100644 index 00000000..024c5d70 --- /dev/null +++ b/samples/today/separate/CMakeLists.txt @@ -0,0 +1,12 @@ +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. + +cmake_minimum_required(VERSION 3.8.2) + +include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/cppgraphqlgen-functions.cmake) + +if(GRAPHQL_UPDATE_SAMPLES) + update_graphql_schema_files(separate ../schema.today.graphql Today today --stubs) +endif() + +add_graphql_schema_target(separate) diff --git a/samples/separate/CompleteTaskPayloadObject.cpp b/samples/today/separate/CompleteTaskPayloadObject.cpp similarity index 100% rename from samples/separate/CompleteTaskPayloadObject.cpp rename to samples/today/separate/CompleteTaskPayloadObject.cpp diff --git a/samples/separate/CompleteTaskPayloadObject.h b/samples/today/separate/CompleteTaskPayloadObject.h similarity index 100% rename from samples/separate/CompleteTaskPayloadObject.h rename to samples/today/separate/CompleteTaskPayloadObject.h diff --git a/samples/separate/ExpensiveObject.cpp b/samples/today/separate/ExpensiveObject.cpp similarity index 100% rename from samples/separate/ExpensiveObject.cpp rename to samples/today/separate/ExpensiveObject.cpp diff --git a/samples/separate/ExpensiveObject.h b/samples/today/separate/ExpensiveObject.h similarity index 100% rename from samples/separate/ExpensiveObject.h rename to samples/today/separate/ExpensiveObject.h diff --git a/samples/separate/FolderConnectionObject.cpp b/samples/today/separate/FolderConnectionObject.cpp similarity index 100% rename from samples/separate/FolderConnectionObject.cpp rename to samples/today/separate/FolderConnectionObject.cpp diff --git a/samples/separate/FolderConnectionObject.h b/samples/today/separate/FolderConnectionObject.h similarity index 100% rename from samples/separate/FolderConnectionObject.h rename to samples/today/separate/FolderConnectionObject.h diff --git a/samples/separate/FolderEdgeObject.cpp b/samples/today/separate/FolderEdgeObject.cpp similarity index 100% rename from samples/separate/FolderEdgeObject.cpp rename to samples/today/separate/FolderEdgeObject.cpp diff --git a/samples/separate/FolderEdgeObject.h b/samples/today/separate/FolderEdgeObject.h similarity index 100% rename from samples/separate/FolderEdgeObject.h rename to samples/today/separate/FolderEdgeObject.h diff --git a/samples/separate/FolderObject.cpp b/samples/today/separate/FolderObject.cpp similarity index 100% rename from samples/separate/FolderObject.cpp rename to samples/today/separate/FolderObject.cpp diff --git a/samples/separate/FolderObject.h b/samples/today/separate/FolderObject.h similarity index 100% rename from samples/separate/FolderObject.h rename to samples/today/separate/FolderObject.h diff --git a/samples/separate/MutationObject.cpp b/samples/today/separate/MutationObject.cpp similarity index 100% rename from samples/separate/MutationObject.cpp rename to samples/today/separate/MutationObject.cpp diff --git a/samples/separate/MutationObject.h b/samples/today/separate/MutationObject.h similarity index 100% rename from samples/separate/MutationObject.h rename to samples/today/separate/MutationObject.h diff --git a/samples/separate/NestedTypeObject.cpp b/samples/today/separate/NestedTypeObject.cpp similarity index 100% rename from samples/separate/NestedTypeObject.cpp rename to samples/today/separate/NestedTypeObject.cpp diff --git a/samples/separate/NestedTypeObject.h b/samples/today/separate/NestedTypeObject.h similarity index 100% rename from samples/separate/NestedTypeObject.h rename to samples/today/separate/NestedTypeObject.h diff --git a/samples/separate/PageInfoObject.cpp b/samples/today/separate/PageInfoObject.cpp similarity index 100% rename from samples/separate/PageInfoObject.cpp rename to samples/today/separate/PageInfoObject.cpp diff --git a/samples/separate/PageInfoObject.h b/samples/today/separate/PageInfoObject.h similarity index 100% rename from samples/separate/PageInfoObject.h rename to samples/today/separate/PageInfoObject.h diff --git a/samples/separate/QueryObject.cpp b/samples/today/separate/QueryObject.cpp similarity index 100% rename from samples/separate/QueryObject.cpp rename to samples/today/separate/QueryObject.cpp diff --git a/samples/separate/QueryObject.h b/samples/today/separate/QueryObject.h similarity index 100% rename from samples/separate/QueryObject.h rename to samples/today/separate/QueryObject.h diff --git a/samples/separate/SubscriptionObject.cpp b/samples/today/separate/SubscriptionObject.cpp similarity index 100% rename from samples/separate/SubscriptionObject.cpp rename to samples/today/separate/SubscriptionObject.cpp diff --git a/samples/separate/SubscriptionObject.h b/samples/today/separate/SubscriptionObject.h similarity index 100% rename from samples/separate/SubscriptionObject.h rename to samples/today/separate/SubscriptionObject.h diff --git a/samples/separate/TaskConnectionObject.cpp b/samples/today/separate/TaskConnectionObject.cpp similarity index 100% rename from samples/separate/TaskConnectionObject.cpp rename to samples/today/separate/TaskConnectionObject.cpp diff --git a/samples/separate/TaskConnectionObject.h b/samples/today/separate/TaskConnectionObject.h similarity index 100% rename from samples/separate/TaskConnectionObject.h rename to samples/today/separate/TaskConnectionObject.h diff --git a/samples/separate/TaskEdgeObject.cpp b/samples/today/separate/TaskEdgeObject.cpp similarity index 100% rename from samples/separate/TaskEdgeObject.cpp rename to samples/today/separate/TaskEdgeObject.cpp diff --git a/samples/separate/TaskEdgeObject.h b/samples/today/separate/TaskEdgeObject.h similarity index 100% rename from samples/separate/TaskEdgeObject.h rename to samples/today/separate/TaskEdgeObject.h diff --git a/samples/separate/TaskObject.cpp b/samples/today/separate/TaskObject.cpp similarity index 100% rename from samples/separate/TaskObject.cpp rename to samples/today/separate/TaskObject.cpp diff --git a/samples/separate/TaskObject.h b/samples/today/separate/TaskObject.h similarity index 100% rename from samples/separate/TaskObject.h rename to samples/today/separate/TaskObject.h diff --git a/samples/separate/TodayObjects.h b/samples/today/separate/TodayObjects.h similarity index 100% rename from samples/separate/TodayObjects.h rename to samples/today/separate/TodayObjects.h diff --git a/samples/separate/TodaySchema.cpp b/samples/today/separate/TodaySchema.cpp similarity index 100% rename from samples/separate/TodaySchema.cpp rename to samples/today/separate/TodaySchema.cpp diff --git a/samples/separate/TodaySchema.h b/samples/today/separate/TodaySchema.h similarity index 100% rename from samples/separate/TodaySchema.h rename to samples/today/separate/TodaySchema.h diff --git a/samples/separate/today_schema_files b/samples/today/separate/separate_schema_files similarity index 100% rename from samples/separate/today_schema_files rename to samples/today/separate/separate_schema_files diff --git a/samples/separate_nointrospection/AppointmentConnectionObject.cpp b/samples/today/separate_nointrospection/AppointmentConnectionObject.cpp similarity index 100% rename from samples/separate_nointrospection/AppointmentConnectionObject.cpp rename to samples/today/separate_nointrospection/AppointmentConnectionObject.cpp diff --git a/samples/separate_nointrospection/AppointmentConnectionObject.h b/samples/today/separate_nointrospection/AppointmentConnectionObject.h similarity index 100% rename from samples/separate_nointrospection/AppointmentConnectionObject.h rename to samples/today/separate_nointrospection/AppointmentConnectionObject.h diff --git a/samples/separate_nointrospection/AppointmentEdgeObject.cpp b/samples/today/separate_nointrospection/AppointmentEdgeObject.cpp similarity index 100% rename from samples/separate_nointrospection/AppointmentEdgeObject.cpp rename to samples/today/separate_nointrospection/AppointmentEdgeObject.cpp diff --git a/samples/separate_nointrospection/AppointmentEdgeObject.h b/samples/today/separate_nointrospection/AppointmentEdgeObject.h similarity index 100% rename from samples/separate_nointrospection/AppointmentEdgeObject.h rename to samples/today/separate_nointrospection/AppointmentEdgeObject.h diff --git a/samples/separate_nointrospection/AppointmentObject.cpp b/samples/today/separate_nointrospection/AppointmentObject.cpp similarity index 100% rename from samples/separate_nointrospection/AppointmentObject.cpp rename to samples/today/separate_nointrospection/AppointmentObject.cpp diff --git a/samples/separate_nointrospection/AppointmentObject.h b/samples/today/separate_nointrospection/AppointmentObject.h similarity index 100% rename from samples/separate_nointrospection/AppointmentObject.h rename to samples/today/separate_nointrospection/AppointmentObject.h diff --git a/samples/today/separate_nointrospection/CMakeLists.txt b/samples/today/separate_nointrospection/CMakeLists.txt new file mode 100644 index 00000000..95e7a03a --- /dev/null +++ b/samples/today/separate_nointrospection/CMakeLists.txt @@ -0,0 +1,12 @@ +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. + +cmake_minimum_required(VERSION 3.8.2) + +include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/cppgraphqlgen-functions.cmake) + +if(GRAPHQL_UPDATE_SAMPLES) + update_graphql_schema_files(separate_nointrospection ../schema.today.graphql Today today --stubs --no-introspection) +endif() + +add_graphql_schema_no_introspection_target(separate_nointrospection) diff --git a/samples/separate_nointrospection/CompleteTaskPayloadObject.cpp b/samples/today/separate_nointrospection/CompleteTaskPayloadObject.cpp similarity index 100% rename from samples/separate_nointrospection/CompleteTaskPayloadObject.cpp rename to samples/today/separate_nointrospection/CompleteTaskPayloadObject.cpp diff --git a/samples/separate_nointrospection/CompleteTaskPayloadObject.h b/samples/today/separate_nointrospection/CompleteTaskPayloadObject.h similarity index 100% rename from samples/separate_nointrospection/CompleteTaskPayloadObject.h rename to samples/today/separate_nointrospection/CompleteTaskPayloadObject.h diff --git a/samples/separate_nointrospection/ExpensiveObject.cpp b/samples/today/separate_nointrospection/ExpensiveObject.cpp similarity index 100% rename from samples/separate_nointrospection/ExpensiveObject.cpp rename to samples/today/separate_nointrospection/ExpensiveObject.cpp diff --git a/samples/separate_nointrospection/ExpensiveObject.h b/samples/today/separate_nointrospection/ExpensiveObject.h similarity index 100% rename from samples/separate_nointrospection/ExpensiveObject.h rename to samples/today/separate_nointrospection/ExpensiveObject.h diff --git a/samples/separate_nointrospection/FolderConnectionObject.cpp b/samples/today/separate_nointrospection/FolderConnectionObject.cpp similarity index 100% rename from samples/separate_nointrospection/FolderConnectionObject.cpp rename to samples/today/separate_nointrospection/FolderConnectionObject.cpp diff --git a/samples/separate_nointrospection/FolderConnectionObject.h b/samples/today/separate_nointrospection/FolderConnectionObject.h similarity index 100% rename from samples/separate_nointrospection/FolderConnectionObject.h rename to samples/today/separate_nointrospection/FolderConnectionObject.h diff --git a/samples/separate_nointrospection/FolderEdgeObject.cpp b/samples/today/separate_nointrospection/FolderEdgeObject.cpp similarity index 100% rename from samples/separate_nointrospection/FolderEdgeObject.cpp rename to samples/today/separate_nointrospection/FolderEdgeObject.cpp diff --git a/samples/separate_nointrospection/FolderEdgeObject.h b/samples/today/separate_nointrospection/FolderEdgeObject.h similarity index 100% rename from samples/separate_nointrospection/FolderEdgeObject.h rename to samples/today/separate_nointrospection/FolderEdgeObject.h diff --git a/samples/separate_nointrospection/FolderObject.cpp b/samples/today/separate_nointrospection/FolderObject.cpp similarity index 100% rename from samples/separate_nointrospection/FolderObject.cpp rename to samples/today/separate_nointrospection/FolderObject.cpp diff --git a/samples/separate_nointrospection/FolderObject.h b/samples/today/separate_nointrospection/FolderObject.h similarity index 100% rename from samples/separate_nointrospection/FolderObject.h rename to samples/today/separate_nointrospection/FolderObject.h diff --git a/samples/separate_nointrospection/MutationObject.cpp b/samples/today/separate_nointrospection/MutationObject.cpp similarity index 100% rename from samples/separate_nointrospection/MutationObject.cpp rename to samples/today/separate_nointrospection/MutationObject.cpp diff --git a/samples/separate_nointrospection/MutationObject.h b/samples/today/separate_nointrospection/MutationObject.h similarity index 100% rename from samples/separate_nointrospection/MutationObject.h rename to samples/today/separate_nointrospection/MutationObject.h diff --git a/samples/separate_nointrospection/NestedTypeObject.cpp b/samples/today/separate_nointrospection/NestedTypeObject.cpp similarity index 100% rename from samples/separate_nointrospection/NestedTypeObject.cpp rename to samples/today/separate_nointrospection/NestedTypeObject.cpp diff --git a/samples/separate_nointrospection/NestedTypeObject.h b/samples/today/separate_nointrospection/NestedTypeObject.h similarity index 100% rename from samples/separate_nointrospection/NestedTypeObject.h rename to samples/today/separate_nointrospection/NestedTypeObject.h diff --git a/samples/separate_nointrospection/PageInfoObject.cpp b/samples/today/separate_nointrospection/PageInfoObject.cpp similarity index 100% rename from samples/separate_nointrospection/PageInfoObject.cpp rename to samples/today/separate_nointrospection/PageInfoObject.cpp diff --git a/samples/separate_nointrospection/PageInfoObject.h b/samples/today/separate_nointrospection/PageInfoObject.h similarity index 100% rename from samples/separate_nointrospection/PageInfoObject.h rename to samples/today/separate_nointrospection/PageInfoObject.h diff --git a/samples/separate_nointrospection/QueryObject.cpp b/samples/today/separate_nointrospection/QueryObject.cpp similarity index 100% rename from samples/separate_nointrospection/QueryObject.cpp rename to samples/today/separate_nointrospection/QueryObject.cpp diff --git a/samples/separate_nointrospection/QueryObject.h b/samples/today/separate_nointrospection/QueryObject.h similarity index 100% rename from samples/separate_nointrospection/QueryObject.h rename to samples/today/separate_nointrospection/QueryObject.h diff --git a/samples/separate_nointrospection/SubscriptionObject.cpp b/samples/today/separate_nointrospection/SubscriptionObject.cpp similarity index 100% rename from samples/separate_nointrospection/SubscriptionObject.cpp rename to samples/today/separate_nointrospection/SubscriptionObject.cpp diff --git a/samples/separate_nointrospection/SubscriptionObject.h b/samples/today/separate_nointrospection/SubscriptionObject.h similarity index 100% rename from samples/separate_nointrospection/SubscriptionObject.h rename to samples/today/separate_nointrospection/SubscriptionObject.h diff --git a/samples/separate_nointrospection/TaskConnectionObject.cpp b/samples/today/separate_nointrospection/TaskConnectionObject.cpp similarity index 100% rename from samples/separate_nointrospection/TaskConnectionObject.cpp rename to samples/today/separate_nointrospection/TaskConnectionObject.cpp diff --git a/samples/separate_nointrospection/TaskConnectionObject.h b/samples/today/separate_nointrospection/TaskConnectionObject.h similarity index 100% rename from samples/separate_nointrospection/TaskConnectionObject.h rename to samples/today/separate_nointrospection/TaskConnectionObject.h diff --git a/samples/separate_nointrospection/TaskEdgeObject.cpp b/samples/today/separate_nointrospection/TaskEdgeObject.cpp similarity index 100% rename from samples/separate_nointrospection/TaskEdgeObject.cpp rename to samples/today/separate_nointrospection/TaskEdgeObject.cpp diff --git a/samples/separate_nointrospection/TaskEdgeObject.h b/samples/today/separate_nointrospection/TaskEdgeObject.h similarity index 100% rename from samples/separate_nointrospection/TaskEdgeObject.h rename to samples/today/separate_nointrospection/TaskEdgeObject.h diff --git a/samples/separate_nointrospection/TaskObject.cpp b/samples/today/separate_nointrospection/TaskObject.cpp similarity index 100% rename from samples/separate_nointrospection/TaskObject.cpp rename to samples/today/separate_nointrospection/TaskObject.cpp diff --git a/samples/separate_nointrospection/TaskObject.h b/samples/today/separate_nointrospection/TaskObject.h similarity index 100% rename from samples/separate_nointrospection/TaskObject.h rename to samples/today/separate_nointrospection/TaskObject.h diff --git a/samples/separate_nointrospection/TodayObjects.h b/samples/today/separate_nointrospection/TodayObjects.h similarity index 100% rename from samples/separate_nointrospection/TodayObjects.h rename to samples/today/separate_nointrospection/TodayObjects.h diff --git a/samples/separate_nointrospection/TodaySchema.cpp b/samples/today/separate_nointrospection/TodaySchema.cpp similarity index 100% rename from samples/separate_nointrospection/TodaySchema.cpp rename to samples/today/separate_nointrospection/TodaySchema.cpp diff --git a/samples/separate_nointrospection/TodaySchema.h b/samples/today/separate_nointrospection/TodaySchema.h similarity index 100% rename from samples/separate_nointrospection/TodaySchema.h rename to samples/today/separate_nointrospection/TodaySchema.h diff --git a/samples/separate_nointrospection/today_schema_files b/samples/today/separate_nointrospection/separate_nointrospection_schema_files similarity index 100% rename from samples/separate_nointrospection/today_schema_files rename to samples/today/separate_nointrospection/separate_nointrospection_schema_files diff --git a/samples/today/unified/CMakeLists.txt b/samples/today/unified/CMakeLists.txt new file mode 100644 index 00000000..4490d0f4 --- /dev/null +++ b/samples/today/unified/CMakeLists.txt @@ -0,0 +1,12 @@ +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. + +cmake_minimum_required(VERSION 3.8.2) + +include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/cppgraphqlgen-functions.cmake) + +if(GRAPHQL_UPDATE_SAMPLES) + update_graphql_schema_files(unified ../schema.today.graphql Today today --stubs --merge-files) +endif() + +add_graphql_schema_target(unified) diff --git a/samples/unified/TodaySchema.cpp b/samples/today/unified/TodaySchema.cpp similarity index 100% rename from samples/unified/TodaySchema.cpp rename to samples/today/unified/TodaySchema.cpp diff --git a/samples/unified/TodaySchema.h b/samples/today/unified/TodaySchema.h similarity index 100% rename from samples/unified/TodaySchema.h rename to samples/today/unified/TodaySchema.h diff --git a/samples/today/unified/unified_schema_files b/samples/today/unified/unified_schema_files new file mode 100644 index 00000000..1647a93d --- /dev/null +++ b/samples/today/unified/unified_schema_files @@ -0,0 +1 @@ +TodaySchema.cpp diff --git a/samples/today/unified_nointrospection/CMakeLists.txt b/samples/today/unified_nointrospection/CMakeLists.txt new file mode 100644 index 00000000..ab0ed1d5 --- /dev/null +++ b/samples/today/unified_nointrospection/CMakeLists.txt @@ -0,0 +1,12 @@ +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. + +cmake_minimum_required(VERSION 3.8.2) + +include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/cppgraphqlgen-functions.cmake) + +if(GRAPHQL_UPDATE_SAMPLES) + update_graphql_schema_files(unified_nointrospection ../schema.today.graphql Today today --stubs --merge-files --no-introspection) +endif() + +add_graphql_schema_no_introspection_target(unified_nointrospection) diff --git a/samples/unified_nointrospection/TodaySchema.cpp b/samples/today/unified_nointrospection/TodaySchema.cpp similarity index 100% rename from samples/unified_nointrospection/TodaySchema.cpp rename to samples/today/unified_nointrospection/TodaySchema.cpp diff --git a/samples/unified_nointrospection/TodaySchema.h b/samples/today/unified_nointrospection/TodaySchema.h similarity index 100% rename from samples/unified_nointrospection/TodaySchema.h rename to samples/today/unified_nointrospection/TodaySchema.h diff --git a/samples/today/unified_nointrospection/unified_nointrospection_schema_files b/samples/today/unified_nointrospection/unified_nointrospection_schema_files new file mode 100644 index 00000000..1647a93d --- /dev/null +++ b/samples/today/unified_nointrospection/unified_nointrospection_schema_files @@ -0,0 +1 @@ +TodaySchema.cpp diff --git a/samples/validation/CMakeLists.txt b/samples/validation/CMakeLists.txt new file mode 100644 index 00000000..f63d5944 --- /dev/null +++ b/samples/validation/CMakeLists.txt @@ -0,0 +1,13 @@ +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. + +cmake_minimum_required(VERSION 3.8.2) + +if(GRAPHQL_BUILD_TESTS) + add_subdirectory(schema) + add_library(validationgraphql STATIC + ValidationMock.cpp) + target_link_libraries(validationgraphql PUBLIC validation_schema) + target_include_directories(validationgraphql PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) + add_bigobj_flag(validationgraphql) +endif() diff --git a/samples/validation/schema/CMakeLists.txt b/samples/validation/schema/CMakeLists.txt new file mode 100644 index 00000000..fc5164b5 --- /dev/null +++ b/samples/validation/schema/CMakeLists.txt @@ -0,0 +1,12 @@ +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. + +cmake_minimum_required(VERSION 3.8.2) + +include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/cppgraphqlgen-functions.cmake) + +if(GRAPHQL_UPDATE_SAMPLES) + update_graphql_schema_files(validation schema.validation.graphql Validation validation --stubs --merge-files) +endif() + +add_graphql_schema_target(validation) diff --git a/samples/validation/ValidationSchema.cpp b/samples/validation/schema/ValidationSchema.cpp similarity index 100% rename from samples/validation/ValidationSchema.cpp rename to samples/validation/schema/ValidationSchema.cpp diff --git a/samples/validation/ValidationSchema.h b/samples/validation/schema/ValidationSchema.h similarity index 100% rename from samples/validation/ValidationSchema.h rename to samples/validation/schema/ValidationSchema.h diff --git a/samples/schema.validation.graphql b/samples/validation/schema/schema.validation.graphql similarity index 100% rename from samples/schema.validation.graphql rename to samples/validation/schema/schema.validation.graphql diff --git a/samples/validation/schema/validation_schema_files b/samples/validation/schema/validation_schema_files new file mode 100644 index 00000000..0e298f8f --- /dev/null +++ b/samples/validation/schema/validation_schema_files @@ -0,0 +1 @@ +ValidationSchema.cpp diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index cba206bf..fdafd450 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -55,9 +55,8 @@ target_link_libraries(pegtl_combined_tests PRIVATE taocpp::pegtl GTest::GTest GTest::Main) -target_include_directories(pegtl_combined_tests PUBLIC - ${CMAKE_CURRENT_SOURCE_DIR}/../include - ${CMAKE_CURRENT_SOURCE_DIR}/../PEGTL/include) +target_include_directories(pegtl_combined_tests PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR}/../include) gtest_add_tests(TARGET pegtl_combined_tests) add_executable(pegtl_executable_tests PegtlExecutableTests.cpp) @@ -65,9 +64,8 @@ target_link_libraries(pegtl_executable_tests PRIVATE taocpp::pegtl GTest::GTest GTest::Main) -target_include_directories(pegtl_executable_tests PUBLIC - ${CMAKE_CURRENT_SOURCE_DIR}/../include - ${CMAKE_CURRENT_SOURCE_DIR}/../PEGTL/include) +target_include_directories(pegtl_executable_tests PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR}/../include) gtest_add_tests(TARGET pegtl_executable_tests) add_executable(pegtl_schema_tests PegtlSchemaTests.cpp) @@ -75,9 +73,8 @@ target_link_libraries(pegtl_schema_tests PRIVATE taocpp::pegtl GTest::GTest GTest::Main) -target_include_directories(pegtl_schema_tests PUBLIC - ${CMAKE_CURRENT_SOURCE_DIR}/../include - ${CMAKE_CURRENT_SOURCE_DIR}/../PEGTL/include) +target_include_directories(pegtl_schema_tests PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR}/../include) gtest_add_tests(TARGET pegtl_schema_tests) add_executable(response_tests ResponseTests.cpp) From 49d4cedf1b2710caa3446757ca154ad5b332deeb Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Thu, 2 Dec 2021 18:46:27 -0800 Subject: [PATCH 046/119] Extract clientgen cmake functions as well --- cmake/cppgraphqlgen-config.cmake | 2 + cmake/cppgraphqlgen-functions.cmake | 44 ++++++++ cmake/cppgraphqlgen-update-client-files.cmake | 58 ++++++++++ samples/CMakeLists.txt | 105 +----------------- samples/client/CMakeLists.txt | 41 +++++++ .../{ => benchmark}/BenchmarkClient.cpp | 0 .../client/{ => benchmark}/BenchmarkClient.h | 0 samples/client/benchmark/CMakeLists.txt | 12 ++ .../client/benchmark/benchmark_client_files | 1 + .../benchmark}/client.benchmark.today.graphql | 0 samples/client/mutate/CMakeLists.txt | 12 ++ samples/client/{ => mutate}/MutateClient.cpp | 0 samples/client/{ => mutate}/MutateClient.h | 0 .../{ => client/mutate}/mutate.today.graphql | 0 samples/client/mutate/mutate_client_files | 1 + samples/client/query/CMakeLists.txt | 12 ++ samples/client/{ => query}/QueryClient.cpp | 0 samples/client/{ => query}/QueryClient.h | 0 .../{ => client/query}/query.today.graphql | 0 samples/client/query/query_client_files | 1 + samples/client/subscribe/CMakeLists.txt | 12 ++ .../{ => subscribe}/SubscribeClient.cpp | 0 .../client/{ => subscribe}/SubscribeClient.h | 0 .../subscribe}/subscribe.today.graphql | 0 .../client/subscribe/subscribe_client_files | 1 + samples/update_samples.cmake | 29 ----- test/CMakeLists.txt | 4 +- 27 files changed, 201 insertions(+), 134 deletions(-) create mode 100644 cmake/cppgraphqlgen-update-client-files.cmake create mode 100644 samples/client/CMakeLists.txt rename samples/client/{ => benchmark}/BenchmarkClient.cpp (100%) rename samples/client/{ => benchmark}/BenchmarkClient.h (100%) create mode 100644 samples/client/benchmark/CMakeLists.txt create mode 100644 samples/client/benchmark/benchmark_client_files rename samples/{ => client/benchmark}/client.benchmark.today.graphql (100%) create mode 100644 samples/client/mutate/CMakeLists.txt rename samples/client/{ => mutate}/MutateClient.cpp (100%) rename samples/client/{ => mutate}/MutateClient.h (100%) rename samples/{ => client/mutate}/mutate.today.graphql (100%) create mode 100644 samples/client/mutate/mutate_client_files create mode 100644 samples/client/query/CMakeLists.txt rename samples/client/{ => query}/QueryClient.cpp (100%) rename samples/client/{ => query}/QueryClient.h (100%) rename samples/{ => client/query}/query.today.graphql (100%) create mode 100644 samples/client/query/query_client_files create mode 100644 samples/client/subscribe/CMakeLists.txt rename samples/client/{ => subscribe}/SubscribeClient.cpp (100%) rename samples/client/{ => subscribe}/SubscribeClient.h (100%) rename samples/{ => client/subscribe}/subscribe.today.graphql (100%) create mode 100644 samples/client/subscribe/subscribe_client_files delete mode 100644 samples/update_samples.cmake diff --git a/cmake/cppgraphqlgen-config.cmake b/cmake/cppgraphqlgen-config.cmake index 98975194..df9b03b6 100644 --- a/cmake/cppgraphqlgen-config.cmake +++ b/cmake/cppgraphqlgen-config.cmake @@ -24,6 +24,8 @@ The following functions are defined to help with code generation and build targe update_graphql_schema_files add_graphql_schema_target add_graphql_schema_no_introspection_target + update_graphql_client_files + add_graphql_client_target #]=======================================================================] include(CMakeFindDependencyMacro) diff --git a/cmake/cppgraphqlgen-functions.cmake b/cmake/cppgraphqlgen-functions.cmake index 3abd3319..a6e19f25 100644 --- a/cmake/cppgraphqlgen-functions.cmake +++ b/cmake/cppgraphqlgen-functions.cmake @@ -5,6 +5,10 @@ get_filename_component(GRAPHQL_UPDATE_SCHEMA_FILES_SCRIPT "${CMAKE_CURRENT_LIST_DIR}/cppgraphqlgen-update-schema-files.cmake" ABSOLUTE) +get_filename_component(GRAPHQL_UPDATE_CLIENT_FILES_SCRIPT + "${CMAKE_CURRENT_LIST_DIR}/cppgraphqlgen-update-client-files.cmake" + ABSOLUTE) + function(update_graphql_schema_files SCHEMA_TARGET SCHEMA_GRAPHQL SCHEMA_PREFIX SCHEMA_NAMESPACE) set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${SCHEMA_TARGET}_schema_files) @@ -55,3 +59,43 @@ function(add_graphql_schema_no_introspection_target SCHEMA_NO_INTROSPECTION_TARG target_include_directories(${SCHEMA_NO_INTROSPECTION_TARGET}_schema PUBLIC $) target_link_libraries(${SCHEMA_NO_INTROSPECTION_TARGET}_schema PUBLIC cppgraphqlgen::graphqlservice) endfunction() + +function(update_graphql_client_files CLIENT_TARGET SCHEMA_GRAPHQL REQUEST_GRAPHQL CLIENT_PREFIX CLIENT_NAMESPACE) + set_property(DIRECTORY APPEND + PROPERTY CMAKE_CONFIGURE_DEPENDS ${CLIENT_TARGET}_client_files) + + # Collect optional arguments + set(ADDITIONAL_CLIENTGEN_ARGS "") + if(ARGC GREATER 5) + math(EXPR LAST_ARG "${ARGC} - 1") + foreach(ARGN RANGE 5 ${LAST_ARG}) + set(NEXT_ARG "${ARGV${ARGN}}") + list(APPEND ADDITIONAL_CLIENTGEN_ARGS "${NEXT_ARG}") + endforeach() + endif() + + add_custom_command( + OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/${CLIENT_TARGET}_client_files + COMMAND + ${CMAKE_COMMAND} "-DCLIENT_SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR}" + "-DCLIENT_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR}" + "-DCLIENTGEN_PROGRAM=$" "-DCLIENT_TARGET=${CLIENT_TARGET}" + "-DSCHEMA_GRAPHQL=${SCHEMA_GRAPHQL}" "-DREQUEST_GRAPHQL=${REQUEST_GRAPHQL}" + "-DCLIENT_PREFIX=${CLIENT_PREFIX}" "-DCLIENT_NAMESPACE=${CLIENT_NAMESPACE}" + "-DADDITIONAL_CLIENTGEN_ARGS=${ADDITIONAL_CLIENTGEN_ARGS}" + -P ${GRAPHQL_UPDATE_CLIENT_FILES_SCRIPT} + DEPENDS ${SCHEMA_GRAPHQL} ${REQUEST_GRAPHQL} ${GRAPHQL_UPDATE_CLIENT_FILES_SCRIPT} + COMMENT "Generating ${CLIENT_TARGET} client" + VERBATIM) +endfunction() + +function(add_graphql_client_target CLIENT_TARGET) + add_custom_target(${CLIENT_TARGET}_update_client ALL + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${CLIENT_TARGET}_client_files) + + file(STRINGS ${CLIENT_TARGET}_client_files CLIENT_FILES) + add_library(${CLIENT_TARGET}_client STATIC ${CLIENT_FILES}) + add_dependencies(${CLIENT_TARGET}_client ${CLIENT_TARGET}_update_client) + target_include_directories(${CLIENT_TARGET}_client PUBLIC $) + target_link_libraries(${CLIENT_TARGET}_client PUBLIC cppgraphqlgen::graphqlclient) +endfunction() diff --git a/cmake/cppgraphqlgen-update-client-files.cmake b/cmake/cppgraphqlgen-update-client-files.cmake new file mode 100644 index 00000000..0c53f144 --- /dev/null +++ b/cmake/cppgraphqlgen-update-client-files.cmake @@ -0,0 +1,58 @@ +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. + +# Normalize the filesystem paths +get_filename_component(CLIENT_SOURCE_DIR ${CLIENT_SOURCE_DIR} ABSOLUTE) +get_filename_component(CLIENT_BINARY_DIR ${CLIENT_BINARY_DIR} ABSOLUTE) +get_filename_component(CLIENTGEN_PROGRAM ${CLIENTGEN_PROGRAM} ABSOLUTE) +get_filename_component(SCHEMA_GRAPHQL "${CLIENT_SOURCE_DIR}/${SCHEMA_GRAPHQL}" ABSOLUTE) +get_filename_component(REQUEST_GRAPHQL "${CLIENT_SOURCE_DIR}/${REQUEST_GRAPHQL}" ABSOLUTE) + +file(MAKE_DIRECTORY ${CLIENT_BINARY_DIR}) + +# Cleanup all of the stale files in the binary directory +file(GLOB PREVIOUS_FILES ${CLIENT_BINARY_DIR}/*.h ${CLIENT_BINARY_DIR}/*.cpp + ${CLIENT_BINARY_DIR}/${CLIENT_TARGET}_client_files) +foreach(PREVIOUS_FILE ${PREVIOUS_FILES}) + file(REMOVE ${PREVIOUS_FILE}) +endforeach() + +set(CLIENTGEN_ARGS "--schema=${SCHEMA_GRAPHQL}" "--request=${REQUEST_GRAPHQL}" "--prefix=${CLIENT_PREFIX}" "--namespace=${CLIENT_NAMESPACE}") +foreach(CLIENTGEN_ARG ${ADDITIONAL_CLIENTGEN_ARGS}) + list(APPEND CLIENTGEN_ARGS ${CLIENTGEN_ARG}) +endforeach() + +# Regenerate the sources in the binary directory +execute_process( + COMMAND ${CLIENTGEN_PROGRAM} ${CLIENTGEN_ARGS} + OUTPUT_FILE ${CLIENT_TARGET}_client_files + WORKING_DIRECTORY ${CLIENT_BINARY_DIR}) + +# Get the up-to-date list of files in the binary directory +set(FILE_NAMES "") +file(GLOB NEW_FILES ${CLIENT_BINARY_DIR}/*.h ${CLIENT_BINARY_DIR}/*.cpp) +foreach(NEW_FILE ${NEW_FILES}) + get_filename_component(NEW_FILE ${NEW_FILE} NAME) + list(APPEND FILE_NAMES "${NEW_FILE}") +endforeach() + +# Don't update the files in the source directory if no files were generated in the binary directory. +if(NOT FILE_NAMES) + message(FATAL_ERROR "Schema generation failed!") +endif() + +# Remove stale files in the source directory +cmake_policy(SET CMP0057 NEW) +file(GLOB OLD_FILES ${CLIENT_SOURCE_DIR}/*.h ${CLIENT_SOURCE_DIR}/*.cpp) +foreach(OLD_FILE ${OLD_FILES}) + get_filename_component(OLD_FILE ${OLD_FILE} NAME) + if(NOT OLD_FILE IN_LIST FILE_NAMES) + file(REMOVE "${CLIENT_SOURCE_DIR}/${OLD_FILE}") + endif() +endforeach() + +# Copy new and modified files from the binary directory to the source directory +execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different + ${CLIENT_BINARY_DIR}/${CLIENT_TARGET}_client_files + ${NEW_FILES} + ${CLIENT_SOURCE_DIR}) diff --git a/samples/CMakeLists.txt b/samples/CMakeLists.txt index 1e5f7dab..0bd2ba2c 100644 --- a/samples/CMakeLists.txt +++ b/samples/CMakeLists.txt @@ -3,110 +3,7 @@ cmake_minimum_required(VERSION 3.8.2) -if(GRAPHQL_UPDATE_SAMPLES AND GRAPHQL_BUILD_CLIENTGEN) - file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/client) - - # query.today.graphql - add_custom_command( - OUTPUT - ${CMAKE_CURRENT_BINARY_DIR}/client/QueryClient.cpp - ${CMAKE_CURRENT_BINARY_DIR}/client/QueryClient.h - COMMAND clientgen --schema="${CMAKE_CURRENT_SOURCE_DIR}/today/schema.today.graphql" --request="${CMAKE_CURRENT_SOURCE_DIR}/query.today.graphql" --prefix="Query" --namespace="query" - COMMAND ${CMAKE_COMMAND} -E copy_if_different - QueryClient.cpp - QueryClient.h - ${CMAKE_CURRENT_SOURCE_DIR}/client - DEPENDS clientgen today/schema.today.graphql query.today.graphql - WORKING_DIRECTORY client - COMMENT "Generating QueryClient samples") - - # mutate.today.graphql - add_custom_command( - OUTPUT - ${CMAKE_CURRENT_BINARY_DIR}/client/MutateClient.cpp - ${CMAKE_CURRENT_BINARY_DIR}/client/MutateClient.h - COMMAND clientgen --schema="${CMAKE_CURRENT_SOURCE_DIR}/today/schema.today.graphql" --request="${CMAKE_CURRENT_SOURCE_DIR}/mutate.today.graphql" --prefix="Mutate" --namespace="mutate" - COMMAND ${CMAKE_COMMAND} -E copy_if_different - MutateClient.cpp - MutateClient.h - ${CMAKE_CURRENT_SOURCE_DIR}/client - DEPENDS clientgen today/schema.today.graphql mutate.today.graphql - WORKING_DIRECTORY client - COMMENT "Generating MutateClient samples") - - # subscribe.today.graphql - add_custom_command( - OUTPUT - ${CMAKE_CURRENT_BINARY_DIR}/client/SubscribeClient.cpp - ${CMAKE_CURRENT_BINARY_DIR}/client/SubscribeClient.h - COMMAND clientgen --schema="${CMAKE_CURRENT_SOURCE_DIR}/today/schema.today.graphql" --request="${CMAKE_CURRENT_SOURCE_DIR}/subscribe.today.graphql" --prefix="Subscribe" --namespace="subscribe" - COMMAND ${CMAKE_COMMAND} -E copy_if_different - SubscribeClient.cpp - SubscribeClient.h - ${CMAKE_CURRENT_SOURCE_DIR}/client - DEPENDS clientgen today/schema.today.graphql subscribe.today.graphql - WORKING_DIRECTORY client - COMMENT "Generating SubscribeClient samples") - - # client.benchmark.today.graphql - add_custom_command( - OUTPUT - ${CMAKE_CURRENT_BINARY_DIR}/client/BenchmarkClient.cpp - ${CMAKE_CURRENT_BINARY_DIR}/client/BenchmarkClient.h - COMMAND clientgen --schema="${CMAKE_CURRENT_SOURCE_DIR}/today/schema.today.graphql" --request="${CMAKE_CURRENT_SOURCE_DIR}/client.benchmark.today.graphql" --prefix="Benchmark" --namespace="benchmark" - COMMAND ${CMAKE_COMMAND} -E copy_if_different - BenchmarkClient.cpp - BenchmarkClient.h - ${CMAKE_CURRENT_SOURCE_DIR}/client - DEPENDS clientgen today/schema.today.graphql client.benchmark.today.graphql - WORKING_DIRECTORY client - COMMENT "Generating BenchmarkClient samples") - - add_custom_target(update_client_samples ALL - DEPENDS - ${CMAKE_CURRENT_BINARY_DIR}/client/QueryClient.cpp - ${CMAKE_CURRENT_BINARY_DIR}/client/QueryClient.h - ${CMAKE_CURRENT_BINARY_DIR}/client/MutateClient.cpp - ${CMAKE_CURRENT_BINARY_DIR}/client/MutateClient.h - ${CMAKE_CURRENT_BINARY_DIR}/client/SubscribeClient.cpp - ${CMAKE_CURRENT_BINARY_DIR}/client/SubscribeClient.h - ${CMAKE_CURRENT_BINARY_DIR}/client/BenchmarkClient.cpp - ${CMAKE_CURRENT_BINARY_DIR}/client/BenchmarkClient.h) -endif() - +add_subdirectory(client) add_subdirectory(learn) add_subdirectory(today) add_subdirectory(validation) - -# todayclient -add_library(todayclient STATIC - ${CMAKE_CURRENT_SOURCE_DIR}/client/QueryClient.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/client/MutateClient.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/client/SubscribeClient.cpp) -target_link_libraries(todayclient PUBLIC graphqlclient) -target_include_directories(todayclient PUBLIC - ${CMAKE_CURRENT_SOURCE_DIR}/../include - ${CMAKE_CURRENT_SOURCE_DIR}/../PEGTL/include - ${CMAKE_CURRENT_SOURCE_DIR}/client) - -if(GRAPHQL_UPDATE_SAMPLES AND GRAPHQL_BUILD_CLIENTGEN) - # wait for the sample update to complete - add_dependencies(todayclient update_client_samples) -endif() - -# client_benchmark -add_executable(client_benchmark - ${CMAKE_CURRENT_SOURCE_DIR}/client/BenchmarkClient.cpp - client/benchmark.cpp) -target_link_libraries(client_benchmark PRIVATE - separategraphql - todayclient - graphqlclient) -target_include_directories(client_benchmark PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR}/../include - ${CMAKE_CURRENT_SOURCE_DIR}/../PEGTL/include - ${CMAKE_CURRENT_SOURCE_DIR}/client) - -if(WIN32 AND BUILD_SHARED_LIBS) - add_dependencies(client_benchmark copy_sample_dlls) -endif() diff --git a/samples/client/CMakeLists.txt b/samples/client/CMakeLists.txt new file mode 100644 index 00000000..ad88ebbc --- /dev/null +++ b/samples/client/CMakeLists.txt @@ -0,0 +1,41 @@ +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. + +cmake_minimum_required(VERSION 3.8.2) + +add_subdirectory(query) +add_subdirectory(mutate) +add_subdirectory(subscribe) + +add_subdirectory(benchmark) + +# client_benchmark +add_executable(client_benchmark benchmark.cpp) +target_link_libraries(client_benchmark PRIVATE + separategraphql + benchmark_client) + +if(WIN32 AND BUILD_SHARED_LIBS) + add_custom_command(OUTPUT copied_sample_dlls + COMMAND ${CMAKE_COMMAND} -E copy_if_different + $ + $ + $ + $ + $ + $ + ${CMAKE_CURRENT_BINARY_DIR} + COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/copied_sample_dlls + DEPENDS + graphqlservice + graphqlintrospection + graphqljson + graphqlpeg + graphqlresponse + graphqlclient + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/../src) + + add_custom_target(copy_sample_dlls DEPENDS copied_sample_dlls) + + add_dependencies(client_benchmark copy_sample_dlls) +endif() diff --git a/samples/client/BenchmarkClient.cpp b/samples/client/benchmark/BenchmarkClient.cpp similarity index 100% rename from samples/client/BenchmarkClient.cpp rename to samples/client/benchmark/BenchmarkClient.cpp diff --git a/samples/client/BenchmarkClient.h b/samples/client/benchmark/BenchmarkClient.h similarity index 100% rename from samples/client/BenchmarkClient.h rename to samples/client/benchmark/BenchmarkClient.h diff --git a/samples/client/benchmark/CMakeLists.txt b/samples/client/benchmark/CMakeLists.txt new file mode 100644 index 00000000..4b390290 --- /dev/null +++ b/samples/client/benchmark/CMakeLists.txt @@ -0,0 +1,12 @@ +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. + +cmake_minimum_required(VERSION 3.8.2) + +include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/cppgraphqlgen-functions.cmake) + +if(GRAPHQL_UPDATE_SAMPLES AND GRAPHQL_BUILD_CLIENTGEN) + update_graphql_client_files(benchmark ../../today/schema.today.graphql client.benchmark.today.graphql Benchmark benchmark) +endif() + +add_graphql_client_target(benchmark) diff --git a/samples/client/benchmark/benchmark_client_files b/samples/client/benchmark/benchmark_client_files new file mode 100644 index 00000000..2d3350f3 --- /dev/null +++ b/samples/client/benchmark/benchmark_client_files @@ -0,0 +1 @@ +BenchmarkClient.cpp diff --git a/samples/client.benchmark.today.graphql b/samples/client/benchmark/client.benchmark.today.graphql similarity index 100% rename from samples/client.benchmark.today.graphql rename to samples/client/benchmark/client.benchmark.today.graphql diff --git a/samples/client/mutate/CMakeLists.txt b/samples/client/mutate/CMakeLists.txt new file mode 100644 index 00000000..b66967ae --- /dev/null +++ b/samples/client/mutate/CMakeLists.txt @@ -0,0 +1,12 @@ +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. + +cmake_minimum_required(VERSION 3.8.2) + +include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/cppgraphqlgen-functions.cmake) + +if(GRAPHQL_UPDATE_SAMPLES AND GRAPHQL_BUILD_CLIENTGEN) + update_graphql_client_files(mutate ../../today/schema.today.graphql mutate.today.graphql Mutate mutate) +endif() + +add_graphql_client_target(mutate) diff --git a/samples/client/MutateClient.cpp b/samples/client/mutate/MutateClient.cpp similarity index 100% rename from samples/client/MutateClient.cpp rename to samples/client/mutate/MutateClient.cpp diff --git a/samples/client/MutateClient.h b/samples/client/mutate/MutateClient.h similarity index 100% rename from samples/client/MutateClient.h rename to samples/client/mutate/MutateClient.h diff --git a/samples/mutate.today.graphql b/samples/client/mutate/mutate.today.graphql similarity index 100% rename from samples/mutate.today.graphql rename to samples/client/mutate/mutate.today.graphql diff --git a/samples/client/mutate/mutate_client_files b/samples/client/mutate/mutate_client_files new file mode 100644 index 00000000..b6aead9c --- /dev/null +++ b/samples/client/mutate/mutate_client_files @@ -0,0 +1 @@ +MutateClient.cpp diff --git a/samples/client/query/CMakeLists.txt b/samples/client/query/CMakeLists.txt new file mode 100644 index 00000000..8a23e755 --- /dev/null +++ b/samples/client/query/CMakeLists.txt @@ -0,0 +1,12 @@ +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. + +cmake_minimum_required(VERSION 3.8.2) + +include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/cppgraphqlgen-functions.cmake) + +if(GRAPHQL_UPDATE_SAMPLES AND GRAPHQL_BUILD_CLIENTGEN) + update_graphql_client_files(query ../../today/schema.today.graphql query.today.graphql Query query) +endif() + +add_graphql_client_target(query) diff --git a/samples/client/QueryClient.cpp b/samples/client/query/QueryClient.cpp similarity index 100% rename from samples/client/QueryClient.cpp rename to samples/client/query/QueryClient.cpp diff --git a/samples/client/QueryClient.h b/samples/client/query/QueryClient.h similarity index 100% rename from samples/client/QueryClient.h rename to samples/client/query/QueryClient.h diff --git a/samples/query.today.graphql b/samples/client/query/query.today.graphql similarity index 100% rename from samples/query.today.graphql rename to samples/client/query/query.today.graphql diff --git a/samples/client/query/query_client_files b/samples/client/query/query_client_files new file mode 100644 index 00000000..849c8c17 --- /dev/null +++ b/samples/client/query/query_client_files @@ -0,0 +1 @@ +QueryClient.cpp diff --git a/samples/client/subscribe/CMakeLists.txt b/samples/client/subscribe/CMakeLists.txt new file mode 100644 index 00000000..9e3dd74f --- /dev/null +++ b/samples/client/subscribe/CMakeLists.txt @@ -0,0 +1,12 @@ +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. + +cmake_minimum_required(VERSION 3.8.2) + +include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/cppgraphqlgen-functions.cmake) + +if(GRAPHQL_UPDATE_SAMPLES AND GRAPHQL_BUILD_CLIENTGEN) + update_graphql_client_files(subscribe ../../today/schema.today.graphql subscribe.today.graphql Subscribe subscribe) +endif() + +add_graphql_client_target(subscribe) diff --git a/samples/client/SubscribeClient.cpp b/samples/client/subscribe/SubscribeClient.cpp similarity index 100% rename from samples/client/SubscribeClient.cpp rename to samples/client/subscribe/SubscribeClient.cpp diff --git a/samples/client/SubscribeClient.h b/samples/client/subscribe/SubscribeClient.h similarity index 100% rename from samples/client/SubscribeClient.h rename to samples/client/subscribe/SubscribeClient.h diff --git a/samples/subscribe.today.graphql b/samples/client/subscribe/subscribe.today.graphql similarity index 100% rename from samples/subscribe.today.graphql rename to samples/client/subscribe/subscribe.today.graphql diff --git a/samples/client/subscribe/subscribe_client_files b/samples/client/subscribe/subscribe_client_files new file mode 100644 index 00000000..39049156 --- /dev/null +++ b/samples/client/subscribe/subscribe_client_files @@ -0,0 +1 @@ +SubscribeClient.cpp diff --git a/samples/update_samples.cmake b/samples/update_samples.cmake deleted file mode 100644 index 1d3d2757..00000000 --- a/samples/update_samples.cmake +++ /dev/null @@ -1,29 +0,0 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. - -cmake_minimum_required(VERSION 3.8.2) - -# Get the up-to-date list of files in the binary directory -set(FILE_NAMES "") -file(GLOB NEW_FILES ${SCHEMA_BINARY_DIR}/*.h ${SCHEMA_BINARY_DIR}/*.cpp) -foreach(NEW_FILE ${NEW_FILES}) - get_filename_component(NEW_FILE ${NEW_FILE} NAME) - list(APPEND FILE_NAMES "${NEW_FILE}") -endforeach() - -# Don't update the files in the source directory if no files were generated in the binary directory. -if(NOT FILE_NAMES) - message(FATAL_ERROR "Schema generation failed!") -endif() - -# Remove stale files in the source directory -file(GLOB OLD_FILES ${SCHEMA_SOURCE_DIR}/*.h ${SCHEMA_SOURCE_DIR}/*.cpp) -foreach(OLD_FILE ${OLD_FILES}) - get_filename_component(OLD_FILE ${OLD_FILE} NAME) - if(NOT OLD_FILE IN_LIST FILE_NAMES) - file(REMOVE "${SCHEMA_SOURCE_DIR}/${OLD_FILE}") - endif() -endforeach() - -# Copy new and modified files from the binary directory to the source directory -execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different ${SCHEMA_BINARY_DIR}/${SCHEMA_SOURCE_LIST} ${NEW_FILES} ${SCHEMA_SOURCE_DIR}) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index fdafd450..9b073054 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -26,7 +26,9 @@ gtest_add_tests(TARGET today_tests) add_executable(client_tests ClientTests.cpp) target_link_libraries(client_tests PRIVATE unifiedgraphql - todayclient + query_client + mutate_client + subscribe_client GTest::GTest GTest::Main) add_bigobj_flag(client_tests) From 37756a1fca2dae52601815c7c101e6607c61fe73 Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Thu, 2 Dec 2021 18:50:38 -0800 Subject: [PATCH 047/119] Disambiguate copy_sample_dlls target names --- samples/client/CMakeLists.txt | 4 ++-- samples/learn/CMakeLists.txt | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/samples/client/CMakeLists.txt b/samples/client/CMakeLists.txt index ad88ebbc..cf963dae 100644 --- a/samples/client/CMakeLists.txt +++ b/samples/client/CMakeLists.txt @@ -35,7 +35,7 @@ if(WIN32 AND BUILD_SHARED_LIBS) graphqlclient WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/../src) - add_custom_target(copy_sample_dlls DEPENDS copied_sample_dlls) + add_custom_target(copy_client_sample_dlls DEPENDS copied_sample_dlls) - add_dependencies(client_benchmark copy_sample_dlls) + add_dependencies(client_benchmark copy_client_sample_dlls) endif() diff --git a/samples/learn/CMakeLists.txt b/samples/learn/CMakeLists.txt index 427b0a16..5f019e64 100644 --- a/samples/learn/CMakeLists.txt +++ b/samples/learn/CMakeLists.txt @@ -36,7 +36,7 @@ if(WIN32 AND BUILD_SHARED_LIBS) graphqlpeg graphqlresponse) - add_custom_target(copy_sample_dlls DEPENDS copied_sample_dlls) + add_custom_target(copy_learn_sample_dlls DEPENDS copied_sample_dlls) - add_dependencies(learn_star_wars copy_sample_dlls) + add_dependencies(learn_star_wars copy_learn_sample_dlls) endif() From b7c7849f416fe1f6a685eb672b6e017e34f42634 Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Thu, 2 Dec 2021 19:03:30 -0800 Subject: [PATCH 048/119] Remove out-of-date WORKING_DIRECTORY --- samples/client/CMakeLists.txt | 3 +-- test/CMakeLists.txt | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/samples/client/CMakeLists.txt b/samples/client/CMakeLists.txt index cf963dae..d44b9966 100644 --- a/samples/client/CMakeLists.txt +++ b/samples/client/CMakeLists.txt @@ -32,8 +32,7 @@ if(WIN32 AND BUILD_SHARED_LIBS) graphqljson graphqlpeg graphqlresponse - graphqlclient - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/../src) + graphqlclient) add_custom_target(copy_client_sample_dlls DEPENDS copied_sample_dlls) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 9b073054..d114aa25 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -105,8 +105,7 @@ if(WIN32 AND BUILD_SHARED_LIBS) graphqljson graphqlpeg graphqlresponse - graphqlclient - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/../src) + graphqlclient) add_custom_target(copy_test_dlls DEPENDS copied_test_dlls) From da66d772d169e45e2ac9c076b2d20b44bb26d508 Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Thu, 2 Dec 2021 21:30:54 -0800 Subject: [PATCH 049/119] Install update-client-files script --- cmake/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 683e85a1..c3de4ca5 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -12,4 +12,5 @@ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}-functions.cmake ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}-update-schema-files.cmake + ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}-update-client-files.cmake DESTINATION ${GRAPHQL_INSTALL_CMAKE_DIR}/${PROJECT_NAME}) From 5b88b3e170d383c622823bb30bc1bc06926daddc Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Thu, 2 Dec 2021 23:31:03 -0800 Subject: [PATCH 050/119] Add support for custom type-erased await_async --- include/graphqlservice/GraphQLService.h | 129 ++++++++++++++++++------ samples/today/TodayMock.cpp | 4 +- src/GraphQLService.cpp | 60 ++++------- 3 files changed, 118 insertions(+), 75 deletions(-) diff --git a/include/graphqlservice/GraphQLService.h b/include/graphqlservice/GraphQLService.h index 5f6013c1..6e5bb608 100644 --- a/include/graphqlservice/GraphQLService.h +++ b/include/graphqlservice/GraphQLService.h @@ -148,6 +148,87 @@ enum class ResolverContext NotifyUnsubscribe, }; +// Resume coroutine execution on a worker thread. +struct await_worker_thread : coro::suspend_always +{ + void await_suspend(coro::coroutine_handle<> h) const + { + std::thread( + [](coro::coroutine_handle<>&& h) noexcept { + h.resume(); + }, + std::move(h)) + .detach(); + } +}; + +// Type-erased awaitable, if you want finer grain control. +class await_async : public coro::suspend_always +{ +private: + struct Concept + { + virtual ~Concept() = default; + + virtual bool await_ready() const = 0; + virtual void await_suspend(coro::coroutine_handle<> h) const = 0; + }; + + template + struct Model : Concept + { + Model(std::shared_ptr&& pimpl) + : _pimpl { std::move(pimpl) } + { + } + + bool await_ready() const final + { + return _pimpl->await_ready(); + } + + void await_suspend(coro::coroutine_handle<> h) const final + { + _pimpl->await_suspend(std::move(h)); + } + + private: + std::shared_ptr _pimpl; + }; + + const std::shared_ptr _pimpl; + +public: + template + await_async(std::shared_ptr pimpl) + : _pimpl { std::make_shared>(std::move(pimpl)) } + { + } + + await_async(std::launch launch) + : _pimpl { ((launch & std::launch::async) == std::launch::async) + ? std::static_pointer_cast(std::make_shared>( + std::make_shared())) + : std::static_pointer_cast(std::make_shared>( + std::make_shared())) } + { + } + + bool await_ready() const + { + return _pimpl->await_ready(); + } + + void await_suspend(coro::coroutine_handle<> h) const + { + _pimpl->await_suspend(std::move(h)); + } + + constexpr void await_resume() const noexcept + { + } +}; + // Pass a common bundle of parameters to all of the generated Object::getField accessors in a // SelectionSet struct SelectionSetParams @@ -171,7 +252,7 @@ struct SelectionSetParams std::optional errorPath; // Async launch policy for sub-field resolvers. - const std::launch launch = std::launch::deferred; + const await_async launch { std::launch::deferred }; }; // Pass a common bundle of parameters to all of the generated Object::getField accessors. @@ -557,24 +638,6 @@ class Object : public std::enable_shared_from_this ResolverMap _resolvers; }; -// Resume coroutine execution on a worker thread. This is used internally to implement the APIs -// which can take std::launch::async as a parameter. -class await_async -{ -public: - GRAPHQLSERVICE_EXPORT explicit await_async(std::launch launch) noexcept; - - GRAPHQLSERVICE_EXPORT bool await_ready() const noexcept; - GRAPHQLSERVICE_EXPORT void await_suspend(coro::coroutine_handle<> h) const; - - constexpr void await_resume() const noexcept - { - } - -private: - const std::launch _launch; -}; - // Convert the result of a resolver function with chained type modifiers that add nullable or // list wrappers. This is the inverse of ModifiedArgument for output types instead of input types. template @@ -622,7 +685,7 @@ struct ModifiedResult static_assert(std::is_same_v, typename ResultTraits::type>, "this is the derived object type"); - co_await await_async { params.launch }; + co_await params.launch; auto awaitedResult = co_await ModifiedResult::convert( std::static_pointer_cast(co_await result), @@ -650,7 +713,7 @@ struct ModifiedResult convert( typename ResultTraits::future_type result, ResolverParams params) { - co_await await_async { params.launch }; + co_await params.launch; auto awaitedResult = co_await std::move(result); @@ -677,7 +740,7 @@ struct ModifiedResult typename ResultTraits::type>, "this is the optional version"); - co_await await_async { params.launch }; + co_await params.launch; auto awaitedResult = co_await std::move(result); @@ -700,7 +763,7 @@ struct ModifiedResult std::vector children; const auto parentPath = params.errorPath; - co_await await_async { params.launch }; + co_await params.launch; auto awaitedResult = co_await std::move(result); @@ -743,7 +806,7 @@ struct ModifiedResult { try { - co_await await_async { params.launch }; + co_await params.launch; auto value = co_await std::move(child); @@ -796,7 +859,7 @@ struct ModifiedResult try { - co_await await_async { params.launch }; + co_await params.launch; document.data = pendingResolver(co_await result, params); } catch (schema_exception& scx) @@ -943,17 +1006,17 @@ class Request : public std::enable_shared_from_this GRAPHQLSERVICE_EXPORT response::AwaitableValue resolve(std::shared_ptr state, peg::ast& query, std::string_view operationName, response::Value variables) const; - GRAPHQLSERVICE_EXPORT response::AwaitableValue resolve(std::launch launch, + GRAPHQLSERVICE_EXPORT response::AwaitableValue resolve(await_async launch, std::shared_ptr state, peg::ast& query, std::string_view operationName, response::Value variables) const; GRAPHQLSERVICE_EXPORT SubscriptionKey subscribe( SubscriptionParams&& params, SubscriptionCallback&& callback); GRAPHQLSERVICE_EXPORT AwaitableSubscribe subscribe( - std::launch launch, SubscriptionParams&& params, SubscriptionCallback&& callback); + await_async launch, SubscriptionParams&& params, SubscriptionCallback&& callback); GRAPHQLSERVICE_EXPORT void unsubscribe(SubscriptionKey key); - GRAPHQLSERVICE_EXPORT AwaitableUnsubscribe unsubscribe(std::launch launch, SubscriptionKey key); + GRAPHQLSERVICE_EXPORT AwaitableUnsubscribe unsubscribe(await_async launch, SubscriptionKey key); GRAPHQLSERVICE_EXPORT void deliver( const SubscriptionName& name, const std::shared_ptr& subscriptionObject) const; @@ -970,17 +1033,17 @@ class Request : public std::enable_shared_from_this const SubscriptionFilterCallback& applyDirectives, std::shared_ptr subscriptionObject) const; - GRAPHQLSERVICE_EXPORT AwaitableDeliver deliver(std::launch launch, const SubscriptionName& name, + GRAPHQLSERVICE_EXPORT AwaitableDeliver deliver(await_async launch, const SubscriptionName& name, std::shared_ptr subscriptionObject) const; - GRAPHQLSERVICE_EXPORT AwaitableDeliver deliver(std::launch launch, const SubscriptionName& name, + GRAPHQLSERVICE_EXPORT AwaitableDeliver deliver(await_async launch, const SubscriptionName& name, const SubscriptionArguments& arguments, std::shared_ptr subscriptionObject) const; - GRAPHQLSERVICE_EXPORT AwaitableDeliver deliver(std::launch launch, const SubscriptionName& name, + GRAPHQLSERVICE_EXPORT AwaitableDeliver deliver(await_async launch, const SubscriptionName& name, const SubscriptionArguments& arguments, const SubscriptionArguments& directives, std::shared_ptr subscriptionObject) const; - GRAPHQLSERVICE_EXPORT AwaitableDeliver deliver(std::launch launch, const SubscriptionName& name, + GRAPHQLSERVICE_EXPORT AwaitableDeliver deliver(await_async launch, const SubscriptionName& name, const SubscriptionFilterCallback& applyArguments, std::shared_ptr subscriptionObject) const; - GRAPHQLSERVICE_EXPORT AwaitableDeliver deliver(std::launch launch, const SubscriptionName& name, + GRAPHQLSERVICE_EXPORT AwaitableDeliver deliver(await_async launch, const SubscriptionName& name, const SubscriptionFilterCallback& applyArguments, const SubscriptionFilterCallback& applyDirectives, std::shared_ptr subscriptionObject) const; diff --git a/samples/today/TodayMock.cpp b/samples/today/TodayMock.cpp index e329e396..62262189 100644 --- a/samples/today/TodayMock.cpp +++ b/samples/today/TodayMock.cpp @@ -547,7 +547,7 @@ Expensive::~Expensive() std::future Expensive::getOrder(const service::FieldParams& params) const noexcept { return std::async( - params.launch, + params.launch.await_ready() ? std::launch::deferred : std::launch::async, [](bool blockAsync, int instanceOrder) noexcept { if (blockAsync) { @@ -568,7 +568,7 @@ std::future Expensive::getOrder(const service::FieldParams& params) const n return instanceOrder; }, - params.launch == std::launch::async, + !params.launch.await_ready(), static_cast(order)); } diff --git a/src/GraphQLService.cpp b/src/GraphQLService.cpp index e40c98a2..dfa3d956 100644 --- a/src/GraphQLService.cpp +++ b/src/GraphQLService.cpp @@ -589,26 +589,6 @@ response::IdType ModifiedArgument::convert(const response::Val return result; } -await_async::await_async(std::launch launch) noexcept - : _launch { launch } -{ -} - -bool await_async::await_ready() const noexcept -{ - return (_launch & std::launch::async) != std::launch::async; -} - -void await_async::await_suspend(coro::coroutine_handle<> h) const -{ - std::thread( - [](coro::coroutine_handle<>&& h) noexcept { - h.resume(); - }, - std::move(h)) - .detach(); -} - void blockSubFields(const ResolverParams& params) { // http://spec.graphql.org/June2018/#sec-Leaf-Field-Selections @@ -716,7 +696,7 @@ AwaitableResolver ModifiedResult::convert( { requireSubFields(params); - co_await await_async { params.launch }; + co_await params.launch; auto awaitedResult = co_await std::move(result); @@ -766,7 +746,7 @@ class SelectionVisitor const std::shared_ptr& _state; const response::Value& _operationDirectives; const std::optional> _path; - const std::launch _launch; + const await_async _launch; const FragmentMap& _fragments; const response::Value& _variables; const TypeNames& _typeNames; @@ -1142,7 +1122,7 @@ AwaitableResolver Object::resolve(const SelectionSetParams& selectionSetParams, try { - co_await await_async { launch }; + co_await launch; auto value = co_await std::move(child.second); @@ -1246,7 +1226,7 @@ void FragmentDefinitionVisitor::visit(const peg::ast_node& fragmentDefinition) class OperationDefinitionVisitor { public: - OperationDefinitionVisitor(ResolverContext resolverContext, std::launch launch, + OperationDefinitionVisitor(ResolverContext resolverContext, await_async launch, std::shared_ptr state, const TypeMap& operations, response::Value&& variables, FragmentMap&& fragments); @@ -1256,7 +1236,7 @@ class OperationDefinitionVisitor private: const ResolverContext _resolverContext; - const std::launch _launch; + const await_async _launch; std::shared_ptr _params; const TypeMap& _operations; std::optional _result; @@ -1277,7 +1257,7 @@ SubscriptionData::SubscriptionData(std::shared_ptr data, Subscrip } OperationDefinitionVisitor::OperationDefinitionVisitor(ResolverContext resolverContext, - std::launch launch, std::shared_ptr state, const TypeMap& operations, + await_async launch, std::shared_ptr state, const TypeMap& operations, response::Value&& variables, FragmentMap&& fragments) : _resolverContext(resolverContext) , _launch(launch) @@ -1296,7 +1276,7 @@ AwaitableResolver OperationDefinitionVisitor::getValue() auto result = std::move(*_result); - co_await await_async { _launch }; + co_await _launch; co_return co_await result; } @@ -1670,7 +1650,7 @@ response::AwaitableValue Request::resolve(std::shared_ptr state, p std::move(variables)); } -response::AwaitableValue Request::resolve(std::launch launch, std::shared_ptr state, +response::AwaitableValue Request::resolve(await_async launch, std::shared_ptr state, peg::ast& query, std::string_view operationName, response::Value variables) const { try @@ -1719,7 +1699,7 @@ response::AwaitableValue Request::resolve(std::launch launch, std::shared_ptrsubscribe(std::move(params), std::move(callback)); @@ -1850,7 +1830,7 @@ AwaitableSubscribe Request::subscribe( try { - co_await await_async { launch }; + co_await launch; co_await operation->resolve(selectionSetParams, registration->selection, registration->data->fragments, @@ -1897,7 +1877,7 @@ void Request::unsubscribe(SubscriptionKey key) } } -AwaitableUnsubscribe Request::unsubscribe(std::launch launch, SubscriptionKey key) +AwaitableUnsubscribe Request::unsubscribe(await_async launch, SubscriptionKey key) { const auto spThis = shared_from_this(); const auto itrOperation = spThis->_operations.find(strSubscription); @@ -1918,7 +1898,7 @@ AwaitableUnsubscribe Request::unsubscribe(std::launch launch, SubscriptionKey ke launch, }; - co_await await_async { launch }; + co_await launch; co_await operation->resolve(selectionSetParams, registration->selection, registration->data->fragments, @@ -1969,7 +1949,7 @@ void Request::deliver(const SubscriptionName& name, .get(); } -AwaitableDeliver Request::deliver(std::launch launch, const SubscriptionName& name, +AwaitableDeliver Request::deliver(await_async launch, const SubscriptionName& name, std::shared_ptr subscriptionObject) const { return deliver(launch, @@ -1979,7 +1959,7 @@ AwaitableDeliver Request::deliver(std::launch launch, const SubscriptionName& na std::move(subscriptionObject)); } -AwaitableDeliver Request::deliver(std::launch launch, const SubscriptionName& name, +AwaitableDeliver Request::deliver(await_async launch, const SubscriptionName& name, const SubscriptionArguments& arguments, std::shared_ptr subscriptionObject) const { return deliver(launch, @@ -1989,7 +1969,7 @@ AwaitableDeliver Request::deliver(std::launch launch, const SubscriptionName& na std::move(subscriptionObject)); } -AwaitableDeliver Request::deliver(std::launch launch, const SubscriptionName& name, +AwaitableDeliver Request::deliver(await_async launch, const SubscriptionName& name, const SubscriptionArguments& arguments, const SubscriptionArguments& directives, std::shared_ptr subscriptionObject) const { @@ -2010,7 +1990,7 @@ AwaitableDeliver Request::deliver(std::launch launch, const SubscriptionName& na return deliver(launch, name, argumentsMatch, directivesMatch, std::move(subscriptionObject)); } -AwaitableDeliver Request::deliver(std::launch launch, const SubscriptionName& name, +AwaitableDeliver Request::deliver(await_async launch, const SubscriptionName& name, const SubscriptionFilterCallback& applyArguments, std::shared_ptr subscriptionObject) const { @@ -2024,7 +2004,7 @@ AwaitableDeliver Request::deliver(std::launch launch, const SubscriptionName& na std::move(subscriptionObject)); } -AwaitableDeliver Request::deliver(std::launch launch, const SubscriptionName& name, +AwaitableDeliver Request::deliver(await_async launch, const SubscriptionName& name, const SubscriptionFilterCallback& applyArguments, const SubscriptionFilterCallback& applyDirectives, std::shared_ptr subscriptionObject) const @@ -2121,7 +2101,7 @@ AwaitableDeliver Request::deliver(std::launch launch, const SubscriptionName& na try { - co_await await_async { launch }; + co_await launch; auto result = co_await optionalOrDefaultSubscription->resolve(selectionSetParams, registration->selection, From 1448d7092318687842b1a0c987b4e90d9fe834c7 Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Fri, 3 Dec 2021 08:34:21 -0800 Subject: [PATCH 051/119] Validation schema does not require Introspection support --- samples/validation/schema/CMakeLists.txt | 4 +- .../validation/schema/ValidationSchema.cpp | 53 +++++++------------ samples/validation/schema/ValidationSchema.h | 4 -- 3 files changed, 20 insertions(+), 41 deletions(-) diff --git a/samples/validation/schema/CMakeLists.txt b/samples/validation/schema/CMakeLists.txt index fc5164b5..329ccba7 100644 --- a/samples/validation/schema/CMakeLists.txt +++ b/samples/validation/schema/CMakeLists.txt @@ -6,7 +6,7 @@ cmake_minimum_required(VERSION 3.8.2) include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/cppgraphqlgen-functions.cmake) if(GRAPHQL_UPDATE_SAMPLES) - update_graphql_schema_files(validation schema.validation.graphql Validation validation --stubs --merge-files) + update_graphql_schema_files(validation schema.validation.graphql Validation validation --stubs --merge-files --no-introspection) endif() -add_graphql_schema_target(validation) +add_graphql_schema_no_introspection_target(validation) diff --git a/samples/validation/schema/ValidationSchema.cpp b/samples/validation/schema/ValidationSchema.cpp index 9753cb91..4cabc028 100644 --- a/samples/validation/schema/ValidationSchema.cpp +++ b/samples/validation/schema/ValidationSchema.cpp @@ -119,15 +119,12 @@ Query::Query(std::unique_ptr&& pimpl) { R"gql(dog)gql"sv, [this](service::ResolverParams&& params) { return resolveDog(std::move(params)); } }, { R"gql(pet)gql"sv, [this](service::ResolverParams&& params) { return resolvePet(std::move(params)); } }, { R"gql(human)gql"sv, [this](service::ResolverParams&& params) { return resolveHuman(std::move(params)); } }, - { R"gql(__type)gql"sv, [this](service::ResolverParams&& params) { return resolve_type(std::move(params)); } }, { R"gql(findDog)gql"sv, [this](service::ResolverParams&& params) { return resolveFindDog(std::move(params)); } }, - { R"gql(__schema)gql"sv, [this](service::ResolverParams&& params) { return resolve_schema(std::move(params)); } }, { R"gql(catOrDog)gql"sv, [this](service::ResolverParams&& params) { return resolveCatOrDog(std::move(params)); } }, { R"gql(arguments)gql"sv, [this](service::ResolverParams&& params) { return resolveArguments(std::move(params)); } }, { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, { R"gql(booleanList)gql"sv, [this](service::ResolverParams&& params) { return resolveBooleanList(std::move(params)); } } }) - , _schema(GetSchema()) , _pimpl(std::move(pimpl)) { } @@ -219,20 +216,6 @@ service::AwaitableResolver Query::resolve_typename(service::ResolverParams&& par return service::ModifiedResult::convert(std::string{ R"gql(Query)gql" }, std::move(params)); } -service::AwaitableResolver Query::resolve_schema(service::ResolverParams&& params) -{ - return service::ModifiedResult::convert(std::static_pointer_cast(std::make_shared(std::make_shared(_schema))), std::move(params)); -} - -service::AwaitableResolver Query::resolve_type(service::ResolverParams&& params) -{ - auto argName = service::ModifiedArgument::require("name", params.arguments); - const auto& baseType = _schema->LookupType(argName); - std::shared_ptr result { baseType ? std::make_shared(std::make_shared(baseType)) : nullptr }; - - return service::ModifiedResult::convert(result, std::move(params)); -} - Dog::Dog(std::unique_ptr&& pimpl) : service::Object({ "Pet", @@ -822,7 +805,7 @@ void AddTypesToSchema(const std::shared_ptr& schema) schema->AddType(R"gql(DogCommand)gql"sv, typeDogCommand); auto typeCatCommand = schema::EnumType::Make(R"gql(CatCommand)gql"sv, R"md()md"sv); schema->AddType(R"gql(CatCommand)gql"sv, typeCatCommand); - auto typeComplexInput = schema::InputObjectType::Make(R"gql(ComplexInput)gql"sv, R"md([Example 155](http://spec.graphql.org/June2018/#example-f3185))md"sv); + auto typeComplexInput = schema::InputObjectType::Make(R"gql(ComplexInput)gql"sv, R"md()md"sv); schema->AddType(R"gql(ComplexInput)gql"sv, typeComplexInput); auto typeCatOrDog = schema::UnionType::Make(R"gql(CatOrDog)gql"sv, R"md()md"sv); schema->AddType(R"gql(CatOrDog)gql"sv, typeCatOrDog); @@ -834,7 +817,7 @@ void AddTypesToSchema(const std::shared_ptr& schema) schema->AddType(R"gql(Sentient)gql"sv, typeSentient); auto typePet = schema::InterfaceType::Make(R"gql(Pet)gql"sv, R"md()md"sv); schema->AddType(R"gql(Pet)gql"sv, typePet); - auto typeQuery = schema::ObjectType::Make(R"gql(Query)gql"sv, R"md(GraphQL validation [sample](http://spec.graphql.org/June2018/#example-26a9d))md"); + auto typeQuery = schema::ObjectType::Make(R"gql(Query)gql"sv, R"md()md"); schema->AddType(R"gql(Query)gql"sv, typeQuery); auto typeDog = schema::ObjectType::Make(R"gql(Dog)gql"sv, R"md()md"); schema->AddType(R"gql(Dog)gql"sv, typeDog); @@ -844,15 +827,15 @@ void AddTypesToSchema(const std::shared_ptr& schema) schema->AddType(R"gql(Human)gql"sv, typeHuman); auto typeCat = schema::ObjectType::Make(R"gql(Cat)gql"sv, R"md()md"); schema->AddType(R"gql(Cat)gql"sv, typeCat); - auto typeMutation = schema::ObjectType::Make(R"gql(Mutation)gql"sv, R"md(Support for [Counter Example 94](http://spec.graphql.org/June2018/#example-77c2e))md"); + auto typeMutation = schema::ObjectType::Make(R"gql(Mutation)gql"sv, R"md()md"); schema->AddType(R"gql(Mutation)gql"sv, typeMutation); - auto typeMutateDogResult = schema::ObjectType::Make(R"gql(MutateDogResult)gql"sv, R"md(Support for [Counter Example 94](http://spec.graphql.org/June2018/#example-77c2e))md"); + auto typeMutateDogResult = schema::ObjectType::Make(R"gql(MutateDogResult)gql"sv, R"md()md"); schema->AddType(R"gql(MutateDogResult)gql"sv, typeMutateDogResult); - auto typeSubscription = schema::ObjectType::Make(R"gql(Subscription)gql"sv, R"md(Support for [Example 97](http://spec.graphql.org/June2018/#example-5bbc3) - [Counter Example 101](http://spec.graphql.org/June2018/#example-2353b))md"); + auto typeSubscription = schema::ObjectType::Make(R"gql(Subscription)gql"sv, R"md()md"); schema->AddType(R"gql(Subscription)gql"sv, typeSubscription); - auto typeMessage = schema::ObjectType::Make(R"gql(Message)gql"sv, R"md(Support for [Example 97](http://spec.graphql.org/June2018/#example-5bbc3) - [Counter Example 101](http://spec.graphql.org/June2018/#example-2353b))md"); + auto typeMessage = schema::ObjectType::Make(R"gql(Message)gql"sv, R"md()md"); schema->AddType(R"gql(Message)gql"sv, typeMessage); - auto typeArguments = schema::ObjectType::Make(R"gql(Arguments)gql"sv, R"md(Support for [Example 120](http://spec.graphql.org/June2018/#example-1891c))md"); + auto typeArguments = schema::ObjectType::Make(R"gql(Arguments)gql"sv, R"md()md"); schema->AddType(R"gql(Arguments)gql"sv, typeArguments); typeDogCommand->AddEnumValues({ @@ -891,14 +874,14 @@ void AddTypesToSchema(const std::shared_ptr& schema) typeQuery->AddFields({ schema::Field::Make(R"gql(dog)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType("Dog")), - schema::Field::Make(R"gql(human)gql"sv, R"md(Support for [Counter Example 116](http://spec.graphql.org/June2018/#example-77c2e))md"sv, std::nullopt, schema->LookupType("Human")), - schema::Field::Make(R"gql(pet)gql"sv, R"md(Support for [Counter Example 116](http://spec.graphql.org/June2018/#example-77c2e))md"sv, std::nullopt, schema->LookupType("Pet")), - schema::Field::Make(R"gql(catOrDog)gql"sv, R"md(Support for [Counter Example 116](http://spec.graphql.org/June2018/#example-77c2e))md"sv, std::nullopt, schema->LookupType("CatOrDog")), - schema::Field::Make(R"gql(arguments)gql"sv, R"md(Support for [Example 120](http://spec.graphql.org/June2018/#example-1891c))md"sv, std::nullopt, schema->LookupType("Arguments")), - schema::Field::Make(R"gql(findDog)gql"sv, R"md([Example 155](http://spec.graphql.org/June2018/#example-f3185))md"sv, std::nullopt, schema->LookupType("Dog"), { + schema::Field::Make(R"gql(human)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType("Human")), + schema::Field::Make(R"gql(pet)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType("Pet")), + schema::Field::Make(R"gql(catOrDog)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType("CatOrDog")), + schema::Field::Make(R"gql(arguments)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType("Arguments")), + schema::Field::Make(R"gql(findDog)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType("Dog"), { schema::InputValue::Make(R"gql(complex)gql"sv, R"md()md"sv, schema->LookupType("ComplexInput"), R"gql()gql"sv) }), - schema::Field::Make(R"gql(booleanList)gql"sv, R"md([Example 155](http://spec.graphql.org/June2018/#example-f3185))md"sv, std::nullopt, schema->LookupType("Boolean"), { + schema::Field::Make(R"gql(booleanList)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType("Boolean"), { schema::InputValue::Make(R"gql(booleanListArg)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("Boolean"))), R"gql()gql"sv) }) }); @@ -929,7 +912,7 @@ void AddTypesToSchema(const std::shared_ptr& schema) }); typeHuman->AddFields({ schema::Field::Make(R"gql(name)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("String"))), - schema::Field::Make(R"gql(pets)gql"sv, R"md(Support for [Counter Example 136](http://spec.graphql.org/June2018/#example-6bbad))md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("Pet"))))) + schema::Field::Make(R"gql(pets)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("Pet"))))) }); typeCat->AddInterfaces({ typePet @@ -949,15 +932,15 @@ void AddTypesToSchema(const std::shared_ptr& schema) schema::Field::Make(R"gql(id)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("ID"))) }); typeSubscription->AddFields({ - schema::Field::Make(R"gql(newMessage)gql"sv, R"md(Support for [Example 97](http://spec.graphql.org/June2018/#example-5bbc3) - [Counter Example 101](http://spec.graphql.org/June2018/#example-2353b))md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("Message"))), - schema::Field::Make(R"gql(disallowedSecondRootField)gql"sv, R"md(Support for [Counter Example 99](http://spec.graphql.org/June2018/#example-3997d) - [Counter Example 100](http://spec.graphql.org/June2018/#example-18466))md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("Boolean"))) + schema::Field::Make(R"gql(newMessage)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("Message"))), + schema::Field::Make(R"gql(disallowedSecondRootField)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("Boolean"))) }); typeMessage->AddFields({ schema::Field::Make(R"gql(body)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType("String")), schema::Field::Make(R"gql(sender)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("ID"))) }); typeArguments->AddFields({ - schema::Field::Make(R"gql(multipleReqs)gql"sv, R"md(Support for [Example 121](http://spec.graphql.org/June2018/#example-18fab))md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("Int")), { + schema::Field::Make(R"gql(multipleReqs)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("Int")), { schema::InputValue::Make(R"gql(x)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("Int")), R"gql()gql"sv), schema::InputValue::Make(R"gql(y)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("Int")), R"gql()gql"sv) }), @@ -996,7 +979,7 @@ std::shared_ptr GetSchema() if (!schema) { - schema = std::make_shared(false); + schema = std::make_shared(true); introspection::AddTypesToSchema(schema); AddTypesToSchema(schema); s_wpSchema = schema; diff --git a/samples/validation/schema/ValidationSchema.h b/samples/validation/schema/ValidationSchema.h index 1aeae68c..2992c596 100644 --- a/samples/validation/schema/ValidationSchema.h +++ b/samples/validation/schema/ValidationSchema.h @@ -663,10 +663,6 @@ class Query service::AwaitableResolver resolveBooleanList(service::ResolverParams&& params); service::AwaitableResolver resolve_typename(service::ResolverParams&& params); - service::AwaitableResolver resolve_schema(service::ResolverParams&& params); - service::AwaitableResolver resolve_type(service::ResolverParams&& params); - - std::shared_ptr _schema; struct Concept { From c614893f589ae23b2de7ba9ebbb8fdfb20069b5d Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Fri, 3 Dec 2021 08:39:43 -0800 Subject: [PATCH 052/119] Add comments indicating not to copy include statements --- samples/client/benchmark/CMakeLists.txt | 1 + samples/client/mutate/CMakeLists.txt | 1 + samples/client/query/CMakeLists.txt | 1 + samples/client/subscribe/CMakeLists.txt | 1 + samples/learn/schema/CMakeLists.txt | 1 + samples/today/separate/CMakeLists.txt | 1 + samples/today/separate_nointrospection/CMakeLists.txt | 1 + samples/today/unified/CMakeLists.txt | 1 + samples/today/unified_nointrospection/CMakeLists.txt | 1 + samples/validation/schema/CMakeLists.txt | 1 + 10 files changed, 10 insertions(+) diff --git a/samples/client/benchmark/CMakeLists.txt b/samples/client/benchmark/CMakeLists.txt index 4b390290..cc0dbb0b 100644 --- a/samples/client/benchmark/CMakeLists.txt +++ b/samples/client/benchmark/CMakeLists.txt @@ -3,6 +3,7 @@ cmake_minimum_required(VERSION 3.8.2) +# Normally this would be handled by find_package(cppgraphqlgen CONFIG). include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/cppgraphqlgen-functions.cmake) if(GRAPHQL_UPDATE_SAMPLES AND GRAPHQL_BUILD_CLIENTGEN) diff --git a/samples/client/mutate/CMakeLists.txt b/samples/client/mutate/CMakeLists.txt index b66967ae..cf143bd1 100644 --- a/samples/client/mutate/CMakeLists.txt +++ b/samples/client/mutate/CMakeLists.txt @@ -3,6 +3,7 @@ cmake_minimum_required(VERSION 3.8.2) +# Normally this would be handled by find_package(cppgraphqlgen CONFIG). include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/cppgraphqlgen-functions.cmake) if(GRAPHQL_UPDATE_SAMPLES AND GRAPHQL_BUILD_CLIENTGEN) diff --git a/samples/client/query/CMakeLists.txt b/samples/client/query/CMakeLists.txt index 8a23e755..f4d68c18 100644 --- a/samples/client/query/CMakeLists.txt +++ b/samples/client/query/CMakeLists.txt @@ -3,6 +3,7 @@ cmake_minimum_required(VERSION 3.8.2) +# Normally this would be handled by find_package(cppgraphqlgen CONFIG). include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/cppgraphqlgen-functions.cmake) if(GRAPHQL_UPDATE_SAMPLES AND GRAPHQL_BUILD_CLIENTGEN) diff --git a/samples/client/subscribe/CMakeLists.txt b/samples/client/subscribe/CMakeLists.txt index 9e3dd74f..15712ae6 100644 --- a/samples/client/subscribe/CMakeLists.txt +++ b/samples/client/subscribe/CMakeLists.txt @@ -3,6 +3,7 @@ cmake_minimum_required(VERSION 3.8.2) +# Normally this would be handled by find_package(cppgraphqlgen CONFIG). include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/cppgraphqlgen-functions.cmake) if(GRAPHQL_UPDATE_SAMPLES AND GRAPHQL_BUILD_CLIENTGEN) diff --git a/samples/learn/schema/CMakeLists.txt b/samples/learn/schema/CMakeLists.txt index db13a481..272eed9f 100644 --- a/samples/learn/schema/CMakeLists.txt +++ b/samples/learn/schema/CMakeLists.txt @@ -3,6 +3,7 @@ cmake_minimum_required(VERSION 3.8.2) +# Normally this would be handled by find_package(cppgraphqlgen CONFIG). include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/cppgraphqlgen-functions.cmake) if(GRAPHQL_UPDATE_SAMPLES) diff --git a/samples/today/separate/CMakeLists.txt b/samples/today/separate/CMakeLists.txt index 024c5d70..105b6f58 100644 --- a/samples/today/separate/CMakeLists.txt +++ b/samples/today/separate/CMakeLists.txt @@ -3,6 +3,7 @@ cmake_minimum_required(VERSION 3.8.2) +# Normally this would be handled by find_package(cppgraphqlgen CONFIG). include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/cppgraphqlgen-functions.cmake) if(GRAPHQL_UPDATE_SAMPLES) diff --git a/samples/today/separate_nointrospection/CMakeLists.txt b/samples/today/separate_nointrospection/CMakeLists.txt index 95e7a03a..58043d37 100644 --- a/samples/today/separate_nointrospection/CMakeLists.txt +++ b/samples/today/separate_nointrospection/CMakeLists.txt @@ -3,6 +3,7 @@ cmake_minimum_required(VERSION 3.8.2) +# Normally this would be handled by find_package(cppgraphqlgen CONFIG). include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/cppgraphqlgen-functions.cmake) if(GRAPHQL_UPDATE_SAMPLES) diff --git a/samples/today/unified/CMakeLists.txt b/samples/today/unified/CMakeLists.txt index 4490d0f4..320ecc0f 100644 --- a/samples/today/unified/CMakeLists.txt +++ b/samples/today/unified/CMakeLists.txt @@ -3,6 +3,7 @@ cmake_minimum_required(VERSION 3.8.2) +# Normally this would be handled by find_package(cppgraphqlgen CONFIG). include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/cppgraphqlgen-functions.cmake) if(GRAPHQL_UPDATE_SAMPLES) diff --git a/samples/today/unified_nointrospection/CMakeLists.txt b/samples/today/unified_nointrospection/CMakeLists.txt index ab0ed1d5..ee854ba4 100644 --- a/samples/today/unified_nointrospection/CMakeLists.txt +++ b/samples/today/unified_nointrospection/CMakeLists.txt @@ -3,6 +3,7 @@ cmake_minimum_required(VERSION 3.8.2) +# Normally this would be handled by find_package(cppgraphqlgen CONFIG). include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/cppgraphqlgen-functions.cmake) if(GRAPHQL_UPDATE_SAMPLES) diff --git a/samples/validation/schema/CMakeLists.txt b/samples/validation/schema/CMakeLists.txt index 329ccba7..ab0e7d36 100644 --- a/samples/validation/schema/CMakeLists.txt +++ b/samples/validation/schema/CMakeLists.txt @@ -3,6 +3,7 @@ cmake_minimum_required(VERSION 3.8.2) +# Normally this would be handled by find_package(cppgraphqlgen CONFIG). include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/cppgraphqlgen-functions.cmake) if(GRAPHQL_UPDATE_SAMPLES) From 733e1008eec211cecefdeab0c274f3728c80ccce Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Fri, 3 Dec 2021 09:01:53 -0800 Subject: [PATCH 053/119] CMake modernization/cleanup --- CMakeLists.txt | 11 ++++------- cmake/CMakeLists.txt | 2 +- cmake/cppgraphqlgen-update-client-files.cmake | 4 +++- cmake/cppgraphqlgen-update-schema-files.cmake | 4 +++- samples/CMakeLists.txt | 2 +- samples/client/CMakeLists.txt | 2 +- samples/client/benchmark/CMakeLists.txt | 2 +- samples/client/mutate/CMakeLists.txt | 2 +- samples/client/query/CMakeLists.txt | 2 +- samples/client/subscribe/CMakeLists.txt | 2 +- samples/learn/CMakeLists.txt | 2 +- samples/learn/schema/CMakeLists.txt | 2 +- samples/today/CMakeLists.txt | 2 +- samples/today/separate/CMakeLists.txt | 2 +- .../today/separate_nointrospection/CMakeLists.txt | 2 +- samples/today/unified/CMakeLists.txt | 2 +- .../today/unified_nointrospection/CMakeLists.txt | 2 +- samples/validation/CMakeLists.txt | 2 +- samples/validation/schema/CMakeLists.txt | 2 +- src/CMakeLists.txt | 14 +++++++------- test/CMakeLists.txt | 2 +- 21 files changed, 34 insertions(+), 33 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f5202523..83c6e626 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,13 +1,10 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. -cmake_minimum_required(VERSION 3.8.2) +cmake_minimum_required(VERSION 3.15) -if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.15") - # Enable CMAKE_MSVC_RUNTIME_LIBRARY on Windows. - set(MSVC_MATCH_VCPKG_TRIPLET ON) - cmake_policy(SET CMP0091 NEW) -endif() +# Enable CMAKE_MSVC_RUNTIME_LIBRARY on Windows: https://cmake.org/cmake/help/latest/policy/CMP0091.html +cmake_policy(SET CMP0091 NEW) # Default to the last updated version from version.txt. file(TO_CMAKE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/version.txt" VERSION_FILE) @@ -43,7 +40,7 @@ option(BUILD_SHARED_LIBS "Build shared libraries instead of static libs" OFF) if(VCPKG_TARGET_TRIPLET) message(STATUS "Using ${VCPKG_TARGET_TRIPLET} triplet with vcpkg") - if(MSVC AND MSVC_MATCH_VCPKG_TRIPLET) + if(MSVC) # Match the MSVC runtime if we're using VCPKG with static libraries. if(VCPKG_TARGET_TRIPLET MATCHES [[^.+-static$]]) set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index c3de4ca5..18e37011 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. -cmake_minimum_required(VERSION 3.8.2) +cmake_minimum_required(VERSION 3.15) # Enable version checks in find_package include(CMakePackageConfigHelpers) diff --git a/cmake/cppgraphqlgen-update-client-files.cmake b/cmake/cppgraphqlgen-update-client-files.cmake index 0c53f144..fe6fa0cc 100644 --- a/cmake/cppgraphqlgen-update-client-files.cmake +++ b/cmake/cppgraphqlgen-update-client-files.cmake @@ -41,8 +41,10 @@ if(NOT FILE_NAMES) message(FATAL_ERROR "Schema generation failed!") endif() -# Remove stale files in the source directory + # Support if() IN_LIST operator: https://cmake.org/cmake/help/latest/policy/CMP0057.html cmake_policy(SET CMP0057 NEW) + +# Remove stale files in the source directory file(GLOB OLD_FILES ${CLIENT_SOURCE_DIR}/*.h ${CLIENT_SOURCE_DIR}/*.cpp) foreach(OLD_FILE ${OLD_FILES}) get_filename_component(OLD_FILE ${OLD_FILE} NAME) diff --git a/cmake/cppgraphqlgen-update-schema-files.cmake b/cmake/cppgraphqlgen-update-schema-files.cmake index aada3bf3..495987f6 100644 --- a/cmake/cppgraphqlgen-update-schema-files.cmake +++ b/cmake/cppgraphqlgen-update-schema-files.cmake @@ -40,8 +40,10 @@ if(NOT FILE_NAMES) message(FATAL_ERROR "Schema generation failed!") endif() -# Remove stale files in the source directory + # Support if() IN_LIST operator: https://cmake.org/cmake/help/latest/policy/CMP0057.html cmake_policy(SET CMP0057 NEW) + +# Remove stale files in the source directory file(GLOB OLD_FILES ${SCHEMA_SOURCE_DIR}/*.h ${SCHEMA_SOURCE_DIR}/*.cpp) foreach(OLD_FILE ${OLD_FILES}) get_filename_component(OLD_FILE ${OLD_FILE} NAME) diff --git a/samples/CMakeLists.txt b/samples/CMakeLists.txt index 0bd2ba2c..45c1691b 100644 --- a/samples/CMakeLists.txt +++ b/samples/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. -cmake_minimum_required(VERSION 3.8.2) +cmake_minimum_required(VERSION 3.15) add_subdirectory(client) add_subdirectory(learn) diff --git a/samples/client/CMakeLists.txt b/samples/client/CMakeLists.txt index d44b9966..bcee7f94 100644 --- a/samples/client/CMakeLists.txt +++ b/samples/client/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. -cmake_minimum_required(VERSION 3.8.2) +cmake_minimum_required(VERSION 3.15) add_subdirectory(query) add_subdirectory(mutate) diff --git a/samples/client/benchmark/CMakeLists.txt b/samples/client/benchmark/CMakeLists.txt index cc0dbb0b..ea0ab74c 100644 --- a/samples/client/benchmark/CMakeLists.txt +++ b/samples/client/benchmark/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. -cmake_minimum_required(VERSION 3.8.2) +cmake_minimum_required(VERSION 3.15) # Normally this would be handled by find_package(cppgraphqlgen CONFIG). include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/cppgraphqlgen-functions.cmake) diff --git a/samples/client/mutate/CMakeLists.txt b/samples/client/mutate/CMakeLists.txt index cf143bd1..61b3ab67 100644 --- a/samples/client/mutate/CMakeLists.txt +++ b/samples/client/mutate/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. -cmake_minimum_required(VERSION 3.8.2) +cmake_minimum_required(VERSION 3.15) # Normally this would be handled by find_package(cppgraphqlgen CONFIG). include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/cppgraphqlgen-functions.cmake) diff --git a/samples/client/query/CMakeLists.txt b/samples/client/query/CMakeLists.txt index f4d68c18..dd483b6c 100644 --- a/samples/client/query/CMakeLists.txt +++ b/samples/client/query/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. -cmake_minimum_required(VERSION 3.8.2) +cmake_minimum_required(VERSION 3.15) # Normally this would be handled by find_package(cppgraphqlgen CONFIG). include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/cppgraphqlgen-functions.cmake) diff --git a/samples/client/subscribe/CMakeLists.txt b/samples/client/subscribe/CMakeLists.txt index 15712ae6..fb3ea5eb 100644 --- a/samples/client/subscribe/CMakeLists.txt +++ b/samples/client/subscribe/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. -cmake_minimum_required(VERSION 3.8.2) +cmake_minimum_required(VERSION 3.15) # Normally this would be handled by find_package(cppgraphqlgen CONFIG). include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/cppgraphqlgen-functions.cmake) diff --git a/samples/learn/CMakeLists.txt b/samples/learn/CMakeLists.txt index 5f019e64..3f406be1 100644 --- a/samples/learn/CMakeLists.txt +++ b/samples/learn/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. -cmake_minimum_required(VERSION 3.8.2) +cmake_minimum_required(VERSION 3.15) add_subdirectory(schema) add_library(star_wars STATIC diff --git a/samples/learn/schema/CMakeLists.txt b/samples/learn/schema/CMakeLists.txt index 272eed9f..2cab0cc0 100644 --- a/samples/learn/schema/CMakeLists.txt +++ b/samples/learn/schema/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. -cmake_minimum_required(VERSION 3.8.2) +cmake_minimum_required(VERSION 3.15) # Normally this would be handled by find_package(cppgraphqlgen CONFIG). include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/cppgraphqlgen-functions.cmake) diff --git a/samples/today/CMakeLists.txt b/samples/today/CMakeLists.txt index 157619e9..5cff1394 100644 --- a/samples/today/CMakeLists.txt +++ b/samples/today/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. -cmake_minimum_required(VERSION 3.8.2) +cmake_minimum_required(VERSION 3.15) # separategraphql add_subdirectory(separate) diff --git a/samples/today/separate/CMakeLists.txt b/samples/today/separate/CMakeLists.txt index 105b6f58..37bb752e 100644 --- a/samples/today/separate/CMakeLists.txt +++ b/samples/today/separate/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. -cmake_minimum_required(VERSION 3.8.2) +cmake_minimum_required(VERSION 3.15) # Normally this would be handled by find_package(cppgraphqlgen CONFIG). include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/cppgraphqlgen-functions.cmake) diff --git a/samples/today/separate_nointrospection/CMakeLists.txt b/samples/today/separate_nointrospection/CMakeLists.txt index 58043d37..124fc7ed 100644 --- a/samples/today/separate_nointrospection/CMakeLists.txt +++ b/samples/today/separate_nointrospection/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. -cmake_minimum_required(VERSION 3.8.2) +cmake_minimum_required(VERSION 3.15) # Normally this would be handled by find_package(cppgraphqlgen CONFIG). include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/cppgraphqlgen-functions.cmake) diff --git a/samples/today/unified/CMakeLists.txt b/samples/today/unified/CMakeLists.txt index 320ecc0f..b221706d 100644 --- a/samples/today/unified/CMakeLists.txt +++ b/samples/today/unified/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. -cmake_minimum_required(VERSION 3.8.2) +cmake_minimum_required(VERSION 3.15) # Normally this would be handled by find_package(cppgraphqlgen CONFIG). include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/cppgraphqlgen-functions.cmake) diff --git a/samples/today/unified_nointrospection/CMakeLists.txt b/samples/today/unified_nointrospection/CMakeLists.txt index ee854ba4..405f5ecd 100644 --- a/samples/today/unified_nointrospection/CMakeLists.txt +++ b/samples/today/unified_nointrospection/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. -cmake_minimum_required(VERSION 3.8.2) +cmake_minimum_required(VERSION 3.15) # Normally this would be handled by find_package(cppgraphqlgen CONFIG). include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/cppgraphqlgen-functions.cmake) diff --git a/samples/validation/CMakeLists.txt b/samples/validation/CMakeLists.txt index f63d5944..8db4b408 100644 --- a/samples/validation/CMakeLists.txt +++ b/samples/validation/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. -cmake_minimum_required(VERSION 3.8.2) +cmake_minimum_required(VERSION 3.15) if(GRAPHQL_BUILD_TESTS) add_subdirectory(schema) diff --git a/samples/validation/schema/CMakeLists.txt b/samples/validation/schema/CMakeLists.txt index ab0e7d36..1aad121c 100644 --- a/samples/validation/schema/CMakeLists.txt +++ b/samples/validation/schema/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. -cmake_minimum_required(VERSION 3.8.2) +cmake_minimum_required(VERSION 3.15) # Normally this would be handled by find_package(cppgraphqlgen CONFIG). include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/cppgraphqlgen-functions.cmake) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 00830ba9..921a1c50 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. -cmake_minimum_required(VERSION 3.8.2) +cmake_minimum_required(VERSION 3.15) if(GRAPHQL_UPDATE_VERSION) # internal/Version.h @@ -74,7 +74,7 @@ function(check_coroutine_impl COROUTINE_HEADER COROUTINE_NAMESPACE OPTIONAL_FLAG CXX_STANDARD 20) if(NOT TEST_RESULT) - # Retry with each of the optional libraries. + # Retry with each of the optional flags. foreach(OPTIONAL_FLAG IN LISTS OPTIONAL_FLAGS) try_compile(TEST_RESULT ${CMAKE_CURRENT_BINARY_DIR} @@ -347,9 +347,9 @@ add_library(graphqlservice Validation.cpp) add_library(cppgraphqlgen::graphqlservice ALIAS graphqlservice) target_link_libraries(graphqlservice PUBLIC - graphqlpeg - graphqlresponse - Threads::Threads) + graphqlpeg + graphqlresponse + Threads::Threads) if(GRAPHQL_UPDATE_SAMPLES) # Even though this target doesn't build IntrospectionSchema.cpp, it still @@ -396,8 +396,8 @@ endif() add_library(graphqlclient GraphQLClient.cpp) add_library(cppgraphqlgen::graphqlclient ALIAS graphqlclient) target_link_libraries(graphqlclient PUBLIC - graphqlpeg - graphqlresponse) + graphqlpeg + graphqlresponse) if(GRAPHQL_UPDATE_VERSION) update_version_rc(graphqlclient) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index d114aa25..8d0df3f2 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,7 +1,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. -cmake_minimum_required(VERSION 3.8.2) +cmake_minimum_required(VERSION 3.15) find_package(GTest MODULE REQUIRED) From cb56e15ee4187433c06ad0727091a9042c478f41 Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Mon, 6 Dec 2021 14:34:06 -0800 Subject: [PATCH 054/119] Fix mismatch in sentinel file names and cleanup targets --- samples/learn/CMakeLists.txt | 2 +- samples/today/CMakeLists.txt | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/samples/learn/CMakeLists.txt b/samples/learn/CMakeLists.txt index 3f406be1..1821b10b 100644 --- a/samples/learn/CMakeLists.txt +++ b/samples/learn/CMakeLists.txt @@ -20,7 +20,7 @@ target_link_libraries(learn_star_wars PRIVATE graphqljson) if(WIN32 AND BUILD_SHARED_LIBS) - add_custom_command(OUTPUT copied_learn_dlls + add_custom_command(OUTPUT copied_sample_dlls COMMAND ${CMAKE_COMMAND} -E copy_if_different $ $ diff --git a/samples/today/CMakeLists.txt b/samples/today/CMakeLists.txt index 5cff1394..56415c3f 100644 --- a/samples/today/CMakeLists.txt +++ b/samples/today/CMakeLists.txt @@ -58,12 +58,12 @@ if(WIN32 AND BUILD_SHARED_LIBS) graphqlpeg graphqlresponse) - add_custom_target(copy_sample_dlls DEPENDS copied_sample_dlls) + add_custom_target(copy_today_sample_dlls DEPENDS copied_sample_dlls) - add_dependencies(sample copy_sample_dlls) - add_dependencies(sample_nointrospection copy_sample_dlls) - add_dependencies(benchmark copy_sample_dlls) - add_dependencies(benchmark_nointrospection copy_sample_dlls) + add_dependencies(sample copy_today_sample_dlls) + add_dependencies(sample_nointrospection copy_today_sample_dlls) + add_dependencies(benchmark copy_today_sample_dlls) + add_dependencies(benchmark_nointrospection copy_today_sample_dlls) endif() if(GRAPHQL_BUILD_TESTS) From 0da63787f71341591aabee51ea29b1ffa46f1104 Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Tue, 7 Dec 2021 14:39:04 -0800 Subject: [PATCH 055/119] Move the concrete Introspection object declarations up --- .../introspection/IntrospectionSchema.h | 6 +--- src/SchemaGenerator.cpp | 28 ++++++------------- 2 files changed, 10 insertions(+), 24 deletions(-) diff --git a/include/graphqlservice/introspection/IntrospectionSchema.h b/include/graphqlservice/introspection/IntrospectionSchema.h index 55e732ca..5ddb9368 100644 --- a/include/graphqlservice/introspection/IntrospectionSchema.h +++ b/include/graphqlservice/introspection/IntrospectionSchema.h @@ -67,8 +67,6 @@ enum class DirectiveLocation INPUT_FIELD_DEFINITION }; -namespace object { - class Schema; class Type; class Field; @@ -76,7 +74,7 @@ class InputValue; class EnumValue; class Directive; -} // namespace object +namespace object { class Schema; class Type; @@ -85,8 +83,6 @@ class InputValue; class EnumValue; class Directive; -namespace object { - class Schema : public service::Object { diff --git a/src/SchemaGenerator.cpp b/src/SchemaGenerator.cpp index 0c8e35cc..70aff75c 100644 --- a/src/SchemaGenerator.cpp +++ b/src/SchemaGenerator.cpp @@ -254,6 +254,14 @@ static_assert(graphql::internal::MinorVersion == )cpp" { if (_loader.isIntrospection()) { + // Forward declare all of the concrete types for the Introspection schema + for (const auto& objectType : _loader.getObjectTypes()) + { + headerFile << R"cpp(class )cpp" << objectType.cppType << R"cpp(; +)cpp"; + } + + headerFile << std::endl; } objectNamespace.enter(); @@ -308,25 +316,7 @@ static_assert(graphql::internal::MinorVersion == )cpp" if (!_loader.getObjectTypes().empty() && _options.mergeFiles) { - if (_loader.isIntrospection()) - { - if (objectNamespace.exit()) - { - headerFile << std::endl; - } - - // Forward declare all of the concrete types for the Introspection schema - for (const auto& objectType : _loader.getObjectTypes()) - { - headerFile << R"cpp(class )cpp" << objectType.cppType << R"cpp(; -)cpp"; - } - - headerFile << std::endl; - objectNamespace.enter(); - headerFile << std::endl; - } - else + if (!_loader.isIntrospection()) { objectNamespace.enter(); From 2a5870287f72dc43d5c3821cea7e15ad8a5ac928 Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Tue, 7 Dec 2021 15:12:30 -0800 Subject: [PATCH 056/119] Codegen targets should depend on the generators --- cmake/cppgraphqlgen-functions.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/cppgraphqlgen-functions.cmake b/cmake/cppgraphqlgen-functions.cmake index a6e19f25..46a0aef6 100644 --- a/cmake/cppgraphqlgen-functions.cmake +++ b/cmake/cppgraphqlgen-functions.cmake @@ -33,7 +33,7 @@ function(update_graphql_schema_files SCHEMA_TARGET SCHEMA_GRAPHQL SCHEMA_PREFIX "-DSCHEMA_PREFIX=${SCHEMA_PREFIX}" "-DSCHEMA_NAMESPACE=${SCHEMA_NAMESPACE}" "-DADDITIONAL_SCHEMAGEN_ARGS=${ADDITIONAL_SCHEMAGEN_ARGS}" -P ${GRAPHQL_UPDATE_SCHEMA_FILES_SCRIPT} - DEPENDS ${SCHEMA_GRAPHQL} ${GRAPHQL_UPDATE_SCHEMA_FILES_SCRIPT} + DEPENDS ${SCHEMA_GRAPHQL} ${GRAPHQL_UPDATE_SCHEMA_FILES_SCRIPT} cppgraphqlgen::schemagen COMMENT "Generating ${SCHEMA_TARGET} GraphQL schema" VERBATIM) endfunction() @@ -84,7 +84,7 @@ function(update_graphql_client_files CLIENT_TARGET SCHEMA_GRAPHQL REQUEST_GRAPHQ "-DCLIENT_PREFIX=${CLIENT_PREFIX}" "-DCLIENT_NAMESPACE=${CLIENT_NAMESPACE}" "-DADDITIONAL_CLIENTGEN_ARGS=${ADDITIONAL_CLIENTGEN_ARGS}" -P ${GRAPHQL_UPDATE_CLIENT_FILES_SCRIPT} - DEPENDS ${SCHEMA_GRAPHQL} ${REQUEST_GRAPHQL} ${GRAPHQL_UPDATE_CLIENT_FILES_SCRIPT} + DEPENDS ${SCHEMA_GRAPHQL} ${REQUEST_GRAPHQL} ${GRAPHQL_UPDATE_CLIENT_FILES_SCRIPT} cppgraphqlgen::clientgen COMMENT "Generating ${CLIENT_TARGET} client" VERBATIM) endfunction() From 7807c539f58a0776c194f5c0dbc81dd50395982f Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Wed, 8 Dec 2021 12:05:25 -0800 Subject: [PATCH 057/119] Implement type-erased interface object types --- include/SchemaGenerator.h | 12 +- include/graphqlservice/GraphQLService.h | 4 +- .../introspection/IntrospectionSchema.h | 108 +- samples/learn/DroidData.cpp | 10 +- samples/learn/DroidData.h | 2 +- samples/learn/HumanData.cpp | 10 +- samples/learn/HumanData.h | 2 +- samples/learn/QueryData.cpp | 10 +- samples/learn/QueryData.h | 2 +- samples/learn/schema/CharacterObject.cpp | 49 + samples/learn/schema/CharacterObject.h | 81 ++ samples/learn/schema/DroidObject.cpp | 38 +- samples/learn/schema/DroidObject.h | 100 +- samples/learn/schema/HumanObject.cpp | 38 +- samples/learn/schema/HumanObject.h | 100 +- samples/learn/schema/MutationObject.cpp | 28 +- samples/learn/schema/MutationObject.h | 31 +- samples/learn/schema/QueryObject.cpp | 40 +- samples/learn/schema/QueryObject.h | 63 +- samples/learn/schema/ReviewObject.cpp | 30 +- samples/learn/schema/ReviewObject.h | 41 +- samples/learn/schema/StarWarsObjects.h | 1 + samples/learn/schema/StarWarsSchema.cpp | 7 +- samples/learn/schema/StarWarsSchema.h | 22 +- samples/learn/schema/learn_schema_files | 1 + samples/today/TodayMock.cpp | 10 +- samples/today/TodayMock.h | 13 +- .../separate/AppointmentConnectionObject.cpp | 30 +- .../separate/AppointmentConnectionObject.h | 41 +- .../today/separate/AppointmentEdgeObject.cpp | 30 +- .../today/separate/AppointmentEdgeObject.h | 41 +- samples/today/separate/AppointmentObject.cpp | 36 +- samples/today/separate/AppointmentObject.h | 91 +- .../separate/CompleteTaskPayloadObject.cpp | 30 +- .../separate/CompleteTaskPayloadObject.h | 41 +- samples/today/separate/ExpensiveObject.cpp | 28 +- samples/today/separate/ExpensiveObject.h | 31 +- .../today/separate/FolderConnectionObject.cpp | 30 +- .../today/separate/FolderConnectionObject.h | 41 +- samples/today/separate/FolderEdgeObject.cpp | 30 +- samples/today/separate/FolderEdgeObject.h | 41 +- samples/today/separate/FolderObject.cpp | 32 +- samples/today/separate/FolderObject.h | 71 +- samples/today/separate/MutationObject.cpp | 30 +- samples/today/separate/MutationObject.h | 41 +- samples/today/separate/NestedTypeObject.cpp | 30 +- samples/today/separate/NestedTypeObject.h | 41 +- samples/today/separate/NodeObject.cpp | 46 + samples/today/separate/NodeObject.h | 81 ++ samples/today/separate/PageInfoObject.cpp | 30 +- samples/today/separate/PageInfoObject.h | 41 +- samples/today/separate/QueryObject.cpp | 58 +- samples/today/separate/QueryObject.h | 155 +-- samples/today/separate/SubscriptionObject.cpp | 32 +- samples/today/separate/SubscriptionObject.h | 49 +- .../today/separate/TaskConnectionObject.cpp | 30 +- samples/today/separate/TaskConnectionObject.h | 41 +- samples/today/separate/TaskEdgeObject.cpp | 30 +- samples/today/separate/TaskEdgeObject.h | 41 +- samples/today/separate/TaskObject.cpp | 32 +- samples/today/separate/TaskObject.h | 71 +- samples/today/separate/TodayObjects.h | 1 + samples/today/separate/TodaySchema.cpp | 4 +- samples/today/separate/TodaySchema.h | 41 +- samples/today/separate/separate_schema_files | 1 + .../AppointmentConnectionObject.cpp | 30 +- .../AppointmentConnectionObject.h | 41 +- .../AppointmentEdgeObject.cpp | 30 +- .../AppointmentEdgeObject.h | 41 +- .../AppointmentObject.cpp | 36 +- .../AppointmentObject.h | 91 +- .../CompleteTaskPayloadObject.cpp | 30 +- .../CompleteTaskPayloadObject.h | 41 +- .../ExpensiveObject.cpp | 28 +- .../ExpensiveObject.h | 31 +- .../FolderConnectionObject.cpp | 30 +- .../FolderConnectionObject.h | 41 +- .../FolderEdgeObject.cpp | 30 +- .../FolderEdgeObject.h | 41 +- .../separate_nointrospection/FolderObject.cpp | 32 +- .../separate_nointrospection/FolderObject.h | 71 +- .../MutationObject.cpp | 30 +- .../separate_nointrospection/MutationObject.h | 41 +- .../NestedTypeObject.cpp | 30 +- .../NestedTypeObject.h | 41 +- .../separate_nointrospection/NodeObject.cpp | 46 + .../separate_nointrospection/NodeObject.h | 81 ++ .../PageInfoObject.cpp | 30 +- .../separate_nointrospection/PageInfoObject.h | 41 +- .../separate_nointrospection/QueryObject.cpp | 52 +- .../separate_nointrospection/QueryObject.h | 151 +-- .../SubscriptionObject.cpp | 32 +- .../SubscriptionObject.h | 49 +- .../TaskConnectionObject.cpp | 30 +- .../TaskConnectionObject.h | 41 +- .../TaskEdgeObject.cpp | 30 +- .../separate_nointrospection/TaskEdgeObject.h | 41 +- .../separate_nointrospection/TaskObject.cpp | 32 +- .../separate_nointrospection/TaskObject.h | 71 +- .../separate_nointrospection/TodayObjects.h | 1 + .../separate_nointrospection/TodaySchema.cpp | 4 +- .../separate_nointrospection/TodaySchema.h | 41 +- .../separate_nointrospection_schema_files | 1 + samples/today/unified/TodaySchema.cpp | 502 ++++++--- samples/today/unified/TodaySchema.h | 932 +++++++++-------- .../unified_nointrospection/TodaySchema.cpp | 496 ++++++--- .../unified_nointrospection/TodaySchema.h | 928 ++++++++++------- .../validation/schema/ValidationSchema.cpp | 346 +++++-- samples/validation/schema/ValidationSchema.h | 769 ++++++++------ src/GraphQLService.cpp | 2 +- src/IntrospectionSchema.cpp | 274 +++-- src/SchemaGenerator.cpp | 950 +++++++++++------- src/SchemaLoader.cpp | 7 +- test/TodayTests.cpp | 34 +- 114 files changed, 5766 insertions(+), 3457 deletions(-) create mode 100644 samples/learn/schema/CharacterObject.cpp create mode 100644 samples/learn/schema/CharacterObject.h create mode 100644 samples/today/separate/NodeObject.cpp create mode 100644 samples/today/separate/NodeObject.h create mode 100644 samples/today/separate_nointrospection/NodeObject.cpp create mode 100644 samples/today/separate_nointrospection/NodeObject.h diff --git a/include/SchemaGenerator.h b/include/SchemaGenerator.h index 10b4afd2..07dab141 100644 --- a/include/SchemaGenerator.h +++ b/include/SchemaGenerator.h @@ -42,8 +42,10 @@ class Generator std::string getSourcePath() const noexcept; bool outputHeader() const noexcept; - void outputObjectStubs( - std::ostream& headerFile, const ObjectType& objectType) const; + void outputInterfaceDeclaration( + std::ostream& headerFile, const InterfaceType& interfaceType) const; + void outputObjectImplements(std::ostream& headerFile, const ObjectType& objectType) const; + void outputObjectStubs(std::ostream& headerFile, const ObjectType& objectType) const; void outputObjectDeclaration( std::ostream& headerFile, const ObjectType& objectType, bool isQueryType) const; std::string getFieldDeclaration(const InputField& inputField) const noexcept; @@ -51,9 +53,15 @@ class Generator std::string getResolverDeclaration(const OutputField& outputField) const noexcept; bool outputSource() const noexcept; + void outputInterfaceImplementation( + std::ostream& sourceFile, const InterfaceType& interfaceType) const; + void outputInterfaceIntrospection( + std::ostream& sourceFile, const InterfaceType& interfaceType) const; void outputObjectImplementation( std::ostream& sourceFile, const ObjectType& objectType, bool isQueryType) const; void outputObjectIntrospection(std::ostream& sourceFile, const ObjectType& objectType) const; + void outputIntrospectionFields( + std::ostream& sourceFile, std::string_view cppType, const OutputFieldList& fields) const; std::string getArgumentDefaultValue( size_t level, const response::Value& defaultValue) const noexcept; std::string getArgumentDeclaration(const InputField& argument, const char* prefixToken, diff --git a/include/graphqlservice/GraphQLService.h b/include/graphqlservice/GraphQLService.h index 6e5bb608..79d71012 100644 --- a/include/graphqlservice/GraphQLService.h +++ b/include/graphqlservice/GraphQLService.h @@ -612,7 +612,7 @@ using TypeNames = internal::string_view_set; class Object : public std::enable_shared_from_this { public: - GRAPHQLSERVICE_EXPORT explicit Object(TypeNames&& typeNames, ResolverMap&& resolvers); + GRAPHQLSERVICE_EXPORT explicit Object(TypeNames&& typeNames, ResolverMap&& resolvers) noexcept; GRAPHQLSERVICE_EXPORT virtual ~Object() = default; GRAPHQLSERVICE_EXPORT AwaitableResolver resolve(const SelectionSetParams& selectionSetParams, @@ -631,7 +631,7 @@ class Object : public std::enable_shared_from_this GRAPHQLSERVICE_EXPORT virtual void beginSelectionSet(const SelectionSetParams& params) const; GRAPHQLSERVICE_EXPORT virtual void endSelectionSet(const SelectionSetParams& params) const; - std::mutex _resolverMutex {}; + mutable std::mutex _resolverMutex {}; private: TypeNames _typeNames; diff --git a/include/graphqlservice/introspection/IntrospectionSchema.h b/include/graphqlservice/introspection/IntrospectionSchema.h index 5ddb9368..420b4c2d 100644 --- a/include/graphqlservice/introspection/IntrospectionSchema.h +++ b/include/graphqlservice/introspection/IntrospectionSchema.h @@ -87,13 +87,13 @@ class Schema : public service::Object { private: - service::AwaitableResolver resolveTypes(service::ResolverParams&& params); - service::AwaitableResolver resolveQueryType(service::ResolverParams&& params); - service::AwaitableResolver resolveMutationType(service::ResolverParams&& params); - service::AwaitableResolver resolveSubscriptionType(service::ResolverParams&& params); - service::AwaitableResolver resolveDirectives(service::ResolverParams&& params); + service::AwaitableResolver resolveTypes(service::ResolverParams&& params) const; + service::AwaitableResolver resolveQueryType(service::ResolverParams&& params) const; + service::AwaitableResolver resolveMutationType(service::ResolverParams&& params) const; + service::AwaitableResolver resolveSubscriptionType(service::ResolverParams&& params) const; + service::AwaitableResolver resolveDirectives(service::ResolverParams&& params) const; - service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; struct Concept { @@ -146,8 +146,11 @@ class Schema const std::unique_ptr _pimpl; + service::TypeNames getTypeNames() const noexcept; + service::ResolverMap getResolvers() const noexcept; + public: - GRAPHQLINTROSPECTION_EXPORT Schema(std::shared_ptr pimpl); + GRAPHQLINTROSPECTION_EXPORT Schema(std::shared_ptr pimpl) noexcept; GRAPHQLINTROSPECTION_EXPORT ~Schema(); }; @@ -155,17 +158,17 @@ class Type : public service::Object { private: - service::AwaitableResolver resolveKind(service::ResolverParams&& params); - service::AwaitableResolver resolveName(service::ResolverParams&& params); - service::AwaitableResolver resolveDescription(service::ResolverParams&& params); - service::AwaitableResolver resolveFields(service::ResolverParams&& params); - service::AwaitableResolver resolveInterfaces(service::ResolverParams&& params); - service::AwaitableResolver resolvePossibleTypes(service::ResolverParams&& params); - service::AwaitableResolver resolveEnumValues(service::ResolverParams&& params); - service::AwaitableResolver resolveInputFields(service::ResolverParams&& params); - service::AwaitableResolver resolveOfType(service::ResolverParams&& params); - - service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolveKind(service::ResolverParams&& params) const; + service::AwaitableResolver resolveName(service::ResolverParams&& params) const; + service::AwaitableResolver resolveDescription(service::ResolverParams&& params) const; + service::AwaitableResolver resolveFields(service::ResolverParams&& params) const; + service::AwaitableResolver resolveInterfaces(service::ResolverParams&& params) const; + service::AwaitableResolver resolvePossibleTypes(service::ResolverParams&& params) const; + service::AwaitableResolver resolveEnumValues(service::ResolverParams&& params) const; + service::AwaitableResolver resolveInputFields(service::ResolverParams&& params) const; + service::AwaitableResolver resolveOfType(service::ResolverParams&& params) const; + + service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; struct Concept { @@ -242,8 +245,11 @@ class Type const std::unique_ptr _pimpl; + service::TypeNames getTypeNames() const noexcept; + service::ResolverMap getResolvers() const noexcept; + public: - GRAPHQLINTROSPECTION_EXPORT Type(std::shared_ptr pimpl); + GRAPHQLINTROSPECTION_EXPORT Type(std::shared_ptr pimpl) noexcept; GRAPHQLINTROSPECTION_EXPORT ~Type(); }; @@ -251,14 +257,14 @@ class Field : public service::Object { private: - service::AwaitableResolver resolveName(service::ResolverParams&& params); - service::AwaitableResolver resolveDescription(service::ResolverParams&& params); - service::AwaitableResolver resolveArgs(service::ResolverParams&& params); - service::AwaitableResolver resolveType(service::ResolverParams&& params); - service::AwaitableResolver resolveIsDeprecated(service::ResolverParams&& params); - service::AwaitableResolver resolveDeprecationReason(service::ResolverParams&& params); + service::AwaitableResolver resolveName(service::ResolverParams&& params) const; + service::AwaitableResolver resolveDescription(service::ResolverParams&& params) const; + service::AwaitableResolver resolveArgs(service::ResolverParams&& params) const; + service::AwaitableResolver resolveType(service::ResolverParams&& params) const; + service::AwaitableResolver resolveIsDeprecated(service::ResolverParams&& params) const; + service::AwaitableResolver resolveDeprecationReason(service::ResolverParams&& params) const; - service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; struct Concept { @@ -317,8 +323,11 @@ class Field const std::unique_ptr _pimpl; + service::TypeNames getTypeNames() const noexcept; + service::ResolverMap getResolvers() const noexcept; + public: - GRAPHQLINTROSPECTION_EXPORT Field(std::shared_ptr pimpl); + GRAPHQLINTROSPECTION_EXPORT Field(std::shared_ptr pimpl) noexcept; GRAPHQLINTROSPECTION_EXPORT ~Field(); }; @@ -326,12 +335,12 @@ class InputValue : public service::Object { private: - service::AwaitableResolver resolveName(service::ResolverParams&& params); - service::AwaitableResolver resolveDescription(service::ResolverParams&& params); - service::AwaitableResolver resolveType(service::ResolverParams&& params); - service::AwaitableResolver resolveDefaultValue(service::ResolverParams&& params); + service::AwaitableResolver resolveName(service::ResolverParams&& params) const; + service::AwaitableResolver resolveDescription(service::ResolverParams&& params) const; + service::AwaitableResolver resolveType(service::ResolverParams&& params) const; + service::AwaitableResolver resolveDefaultValue(service::ResolverParams&& params) const; - service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; struct Concept { @@ -378,8 +387,11 @@ class InputValue const std::unique_ptr _pimpl; + service::TypeNames getTypeNames() const noexcept; + service::ResolverMap getResolvers() const noexcept; + public: - GRAPHQLINTROSPECTION_EXPORT InputValue(std::shared_ptr pimpl); + GRAPHQLINTROSPECTION_EXPORT InputValue(std::shared_ptr pimpl) noexcept; GRAPHQLINTROSPECTION_EXPORT ~InputValue(); }; @@ -387,12 +399,12 @@ class EnumValue : public service::Object { private: - service::AwaitableResolver resolveName(service::ResolverParams&& params); - service::AwaitableResolver resolveDescription(service::ResolverParams&& params); - service::AwaitableResolver resolveIsDeprecated(service::ResolverParams&& params); - service::AwaitableResolver resolveDeprecationReason(service::ResolverParams&& params); + service::AwaitableResolver resolveName(service::ResolverParams&& params) const; + service::AwaitableResolver resolveDescription(service::ResolverParams&& params) const; + service::AwaitableResolver resolveIsDeprecated(service::ResolverParams&& params) const; + service::AwaitableResolver resolveDeprecationReason(service::ResolverParams&& params) const; - service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; struct Concept { @@ -439,8 +451,11 @@ class EnumValue const std::unique_ptr _pimpl; + service::TypeNames getTypeNames() const noexcept; + service::ResolverMap getResolvers() const noexcept; + public: - GRAPHQLINTROSPECTION_EXPORT EnumValue(std::shared_ptr pimpl); + GRAPHQLINTROSPECTION_EXPORT EnumValue(std::shared_ptr pimpl) noexcept; GRAPHQLINTROSPECTION_EXPORT ~EnumValue(); }; @@ -448,12 +463,12 @@ class Directive : public service::Object { private: - service::AwaitableResolver resolveName(service::ResolverParams&& params); - service::AwaitableResolver resolveDescription(service::ResolverParams&& params); - service::AwaitableResolver resolveLocations(service::ResolverParams&& params); - service::AwaitableResolver resolveArgs(service::ResolverParams&& params); + service::AwaitableResolver resolveName(service::ResolverParams&& params) const; + service::AwaitableResolver resolveDescription(service::ResolverParams&& params) const; + service::AwaitableResolver resolveLocations(service::ResolverParams&& params) const; + service::AwaitableResolver resolveArgs(service::ResolverParams&& params) const; - service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; struct Concept { @@ -500,8 +515,11 @@ class Directive const std::unique_ptr _pimpl; + service::TypeNames getTypeNames() const noexcept; + service::ResolverMap getResolvers() const noexcept; + public: - GRAPHQLINTROSPECTION_EXPORT Directive(std::shared_ptr pimpl); + GRAPHQLINTROSPECTION_EXPORT Directive(std::shared_ptr pimpl) noexcept; GRAPHQLINTROSPECTION_EXPORT ~Directive(); }; diff --git a/samples/learn/DroidData.cpp b/samples/learn/DroidData.cpp index 7a115420..f1654aec 100644 --- a/samples/learn/DroidData.cpp +++ b/samples/learn/DroidData.cpp @@ -1,6 +1,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. +#include "CharacterObject.h" + #include "DroidData.h" #include "HumanData.h" @@ -45,9 +47,9 @@ const std::optional& Droid::getName() const noexcept return name_; } -std::optional>> Droid::getFriends() const noexcept +std::optional>> Droid::getFriends() const noexcept { - std::vector> result(friends_.size()); + std::vector> result(friends_.size()); std::transform(friends_.begin(), friends_.end(), @@ -59,12 +61,12 @@ std::optional>> Droid::getFriends() if constexpr (std::is_same_v, hero_t>) { - return std::static_pointer_cast( + return std::make_shared( std::make_shared(hero.lock())); } else if constexpr (std::is_same_v, hero_t>) { - return std::static_pointer_cast( + return std::make_shared( std::make_shared(hero.lock())); } }, diff --git a/samples/learn/DroidData.h b/samples/learn/DroidData.h index 0cc4df11..6d59bdad 100644 --- a/samples/learn/DroidData.h +++ b/samples/learn/DroidData.h @@ -24,7 +24,7 @@ class Droid const std::string& getId() const noexcept; const std::optional& getName() const noexcept; - std::optional>> getFriends() const noexcept; + std::optional>> getFriends() const noexcept; std::optional>> getAppearsIn() const noexcept; const std::optional& getPrimaryFunction() const noexcept; diff --git a/samples/learn/HumanData.cpp b/samples/learn/HumanData.cpp index c8623937..7ba4f0f1 100644 --- a/samples/learn/HumanData.cpp +++ b/samples/learn/HumanData.cpp @@ -1,6 +1,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. +#include "CharacterObject.h" + #include "HumanData.h" #include "DroidData.h" @@ -44,9 +46,9 @@ const std::optional& Human::getName() const noexcept return name_; } -std::optional>> Human::getFriends() const noexcept +std::optional>> Human::getFriends() const noexcept { - std::vector> result(friends_.size()); + std::vector> result(friends_.size()); std::transform(friends_.begin(), friends_.end(), @@ -58,12 +60,12 @@ std::optional>> Human::getFriends() if constexpr (std::is_same_v, hero_t>) { - return std::static_pointer_cast( + return std::make_shared( std::make_shared(hero.lock())); } else if constexpr (std::is_same_v, hero_t>) { - return std::static_pointer_cast( + return std::make_shared( std::make_shared(hero.lock())); } }, diff --git a/samples/learn/HumanData.h b/samples/learn/HumanData.h index 53f9b7c6..e29bd3b3 100644 --- a/samples/learn/HumanData.h +++ b/samples/learn/HumanData.h @@ -22,7 +22,7 @@ class Human const std::string& getId() const noexcept; const std::optional& getName() const noexcept; - std::optional>> getFriends() const noexcept; + std::optional>> getFriends() const noexcept; std::optional>> getAppearsIn() const noexcept; const std::optional& getHomePlanet() const noexcept; diff --git a/samples/learn/QueryData.cpp b/samples/learn/QueryData.cpp index 8d9f9747..8b25efa6 100644 --- a/samples/learn/QueryData.cpp +++ b/samples/learn/QueryData.cpp @@ -1,6 +1,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. +#include "CharacterObject.h" + #include "QueryData.h" namespace graphql::learn { @@ -14,9 +16,9 @@ Query::Query(std::map&& heroes, { } -std::shared_ptr Query::getHero(std::optional episodeArg) const noexcept +std::shared_ptr Query::getHero(std::optional episodeArg) const noexcept { - std::shared_ptr result; + std::shared_ptr result; const auto episode = episodeArg ? *episodeArg : Episode::NEW_HOPE; if (const auto itr = heroes_.find(episode); itr != heroes_.end()) @@ -27,12 +29,12 @@ std::shared_ptr Query::getHero(std::optional episodeAr if constexpr (std::is_same_v, hero_t>) { - return std::static_pointer_cast( + return std::make_shared( std::make_shared(hero)); } else if constexpr (std::is_same_v, hero_t>) { - return std::static_pointer_cast( + return std::make_shared( std::make_shared(hero)); } }, diff --git a/samples/learn/QueryData.h b/samples/learn/QueryData.h index 9efb7c31..0552e65f 100644 --- a/samples/learn/QueryData.h +++ b/samples/learn/QueryData.h @@ -20,7 +20,7 @@ class Query std::map>&& humans, std::map>&& droids) noexcept; - std::shared_ptr getHero(std::optional episodeArg) const noexcept; + std::shared_ptr getHero(std::optional episodeArg) const noexcept; std::shared_ptr getHuman(const std::string& idArg) const noexcept; std::shared_ptr getDroid(const std::string& idArg) const noexcept; diff --git a/samples/learn/schema/CharacterObject.cpp b/samples/learn/schema/CharacterObject.cpp new file mode 100644 index 00000000..2c41c0e4 --- /dev/null +++ b/samples/learn/schema/CharacterObject.cpp @@ -0,0 +1,49 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// WARNING! Do not edit this file manually, your changes will be overwritten. + +#include "StarWarsObjects.h" + +#include "graphqlservice/introspection/Introspection.h" + +#include +#include +#include +#include +#include + +using namespace std::literals; + +namespace graphql::learn { +namespace object { + +Character::Character(std::unique_ptr&& pimpl) noexcept + : service::Object { pimpl->getTypeNames(), pimpl->getResolvers() } + , _pimpl { std::move(pimpl) } +{ +} + +void Character::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void Character::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} + +} // namespace object + +void AddCharacterDetails(const std::shared_ptr& typeCharacter, const std::shared_ptr& schema) +{ + typeCharacter->AddFields({ + schema::Field::Make(R"gql(id)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("String"))), + schema::Field::Make(R"gql(name)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType("String")), + schema::Field::Make(R"gql(friends)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::LIST, schema->LookupType("Character"))), + schema::Field::Make(R"gql(appearsIn)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::LIST, schema->LookupType("Episode"))) + }); +} + +} // namespace graphql::learn diff --git a/samples/learn/schema/CharacterObject.h b/samples/learn/schema/CharacterObject.h new file mode 100644 index 00000000..d69e63b7 --- /dev/null +++ b/samples/learn/schema/CharacterObject.h @@ -0,0 +1,81 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// WARNING! Do not edit this file manually, your changes will be overwritten. + +#pragma once + +#ifndef CHARACTEROBJECT_H +#define CHARACTEROBJECT_H + +#include "StarWarsSchema.h" + +namespace graphql::learn::object { + +class Character + : public service::Object +{ +private: + struct Concept + { + virtual ~Concept() = default; + + virtual service::TypeNames getTypeNames() const noexcept = 0; + virtual service::ResolverMap getResolvers() const noexcept = 0; + + virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::TypeNames getTypeNames() const noexcept final + { + return _pimpl->getTypeNames(); + } + + service::ResolverMap getResolvers() const noexcept final + { + return _pimpl->getResolvers(); + } + + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + _pimpl->beginSelectionSet(params); + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + _pimpl->endSelectionSet(params); + } + + private: + const std::shared_ptr _pimpl; + }; + + Character(std::unique_ptr&& pimpl) noexcept; + + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; + + const std::unique_ptr _pimpl; + +public: + template + Character(std::shared_ptr pimpl) noexcept + : Character { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } + { + static_assert(T::template implements(), "Character is not implemented"); + } +}; + +} // namespace graphql::learn::object + +#endif // CHARACTEROBJECT_H diff --git a/samples/learn/schema/DroidObject.cpp b/samples/learn/schema/DroidObject.cpp index c3a8aa02..e2bdc889 100644 --- a/samples/learn/schema/DroidObject.cpp +++ b/samples/learn/schema/DroidObject.cpp @@ -18,20 +18,30 @@ using namespace std::literals; namespace graphql::learn { namespace object { -Droid::Droid(std::unique_ptr&& pimpl) - : service::Object({ +Droid::Droid(std::unique_ptr&& pimpl) noexcept + : service::Object{ getTypeNames(), getResolvers() } + , _pimpl { std::move(pimpl) } +{ +} + +service::TypeNames Droid::getTypeNames() const noexcept +{ + return { "Character", "Droid" - }, { + }; +} + +service::ResolverMap Droid::getResolvers() const noexcept +{ + return { { R"gql(id)gql"sv, [this](service::ResolverParams&& params) { return resolveId(std::move(params)); } }, { R"gql(name)gql"sv, [this](service::ResolverParams&& params) { return resolveName(std::move(params)); } }, { R"gql(friends)gql"sv, [this](service::ResolverParams&& params) { return resolveFriends(std::move(params)); } }, { R"gql(appearsIn)gql"sv, [this](service::ResolverParams&& params) { return resolveAppearsIn(std::move(params)); } }, { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, { R"gql(primaryFunction)gql"sv, [this](service::ResolverParams&& params) { return resolvePrimaryFunction(std::move(params)); } } - }) - , _pimpl(std::move(pimpl)) -{ + }; } void Droid::beginSelectionSet(const service::SelectionSetParams& params) const @@ -44,7 +54,7 @@ void Droid::endSelectionSet(const service::SelectionSetParams& params) const _pimpl->endSelectionSet(params); } -service::AwaitableResolver Droid::resolveId(service::ResolverParams&& params) +service::AwaitableResolver Droid::resolveId(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -54,7 +64,7 @@ service::AwaitableResolver Droid::resolveId(service::ResolverParams&& params) return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Droid::resolveName(service::ResolverParams&& params) +service::AwaitableResolver Droid::resolveName(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -64,17 +74,17 @@ service::AwaitableResolver Droid::resolveName(service::ResolverParams&& params) return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Droid::resolveFriends(service::ResolverParams&& params) +service::AwaitableResolver Droid::resolveFriends(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); auto result = _pimpl->getFriends(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Droid::resolveAppearsIn(service::ResolverParams&& params) +service::AwaitableResolver Droid::resolveAppearsIn(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -84,7 +94,7 @@ service::AwaitableResolver Droid::resolveAppearsIn(service::ResolverParams&& par return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Droid::resolvePrimaryFunction(service::ResolverParams&& params) +service::AwaitableResolver Droid::resolvePrimaryFunction(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -94,14 +104,14 @@ service::AwaitableResolver Droid::resolvePrimaryFunction(service::ResolverParams return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Droid::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver Droid::resolve_typename(service::ResolverParams&& params) const { return service::ModifiedResult::convert(std::string{ R"gql(Droid)gql" }, std::move(params)); } } // namespace object -void AddDroidDetails(std::shared_ptr typeDroid, const std::shared_ptr& schema) +void AddDroidDetails(const std::shared_ptr& typeDroid, const std::shared_ptr& schema) { typeDroid->AddInterfaces({ std::static_pointer_cast(schema->LookupType(R"gql(Character)gql"sv)) diff --git a/samples/learn/schema/DroidObject.h b/samples/learn/schema/DroidObject.h index 4a68ccd3..af339dbe 100644 --- a/samples/learn/schema/DroidObject.h +++ b/samples/learn/schema/DroidObject.h @@ -10,103 +10,115 @@ #include "StarWarsSchema.h" +#include "CharacterObject.h" + namespace graphql::learn::object { -namespace methods::DroidMethod { +namespace implements { + +template +concept DroidIs = std::is_same_v; + +} // namespace implements + +namespace methods::DroidHas { template -concept WithParamsId = requires (TImpl impl, service::FieldParams params) +concept getIdWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getId(std::move(params)) } }; }; template -concept NoParamsId = requires (TImpl impl) +concept getId = requires (TImpl impl) { { service::FieldResult { impl.getId() } }; }; template -concept WithParamsName = requires (TImpl impl, service::FieldParams params) +concept getNameWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getName(std::move(params)) } }; }; template -concept NoParamsName = requires (TImpl impl) +concept getName = requires (TImpl impl) { { service::FieldResult> { impl.getName() } }; }; template -concept WithParamsFriends = requires (TImpl impl, service::FieldParams params) +concept getFriendsWithParams = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult>>> { impl.getFriends(std::move(params)) } }; + { service::FieldResult>>> { impl.getFriends(std::move(params)) } }; }; template -concept NoParamsFriends = requires (TImpl impl) +concept getFriends = requires (TImpl impl) { - { service::FieldResult>>> { impl.getFriends() } }; + { service::FieldResult>>> { impl.getFriends() } }; }; template -concept WithParamsAppearsIn = requires (TImpl impl, service::FieldParams params) +concept getAppearsInWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult>>> { impl.getAppearsIn(std::move(params)) } }; }; template -concept NoParamsAppearsIn = requires (TImpl impl) +concept getAppearsIn = requires (TImpl impl) { { service::FieldResult>>> { impl.getAppearsIn() } }; }; template -concept WithParamsPrimaryFunction = requires (TImpl impl, service::FieldParams params) +concept getPrimaryFunctionWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getPrimaryFunction(std::move(params)) } }; }; template -concept NoParamsPrimaryFunction = requires (TImpl impl) +concept getPrimaryFunction = requires (TImpl impl) { { service::FieldResult> { impl.getPrimaryFunction() } }; }; template -concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.beginSelectionSet(params) }; }; template -concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.endSelectionSet(params) }; }; -} // namespace methods::DroidMethod +} // namespace methods::DroidHas class Droid : public service::Object { private: - service::AwaitableResolver resolveId(service::ResolverParams&& params); - service::AwaitableResolver resolveName(service::ResolverParams&& params); - service::AwaitableResolver resolveFriends(service::ResolverParams&& params); - service::AwaitableResolver resolveAppearsIn(service::ResolverParams&& params); - service::AwaitableResolver resolvePrimaryFunction(service::ResolverParams&& params); + service::AwaitableResolver resolveId(service::ResolverParams&& params) const; + service::AwaitableResolver resolveName(service::ResolverParams&& params) const; + service::AwaitableResolver resolveFriends(service::ResolverParams&& params) const; + service::AwaitableResolver resolveAppearsIn(service::ResolverParams&& params) const; + service::AwaitableResolver resolvePrimaryFunction(service::ResolverParams&& params) const; - service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; struct Concept - : Character { virtual ~Concept() = default; virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual service::FieldResult getId(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getName(service::FieldParams&& params) const = 0; + virtual service::FieldResult>>> getFriends(service::FieldParams&& params) const = 0; + virtual service::FieldResult>>> getAppearsIn(service::FieldParams&& params) const = 0; virtual service::FieldResult> getPrimaryFunction(service::FieldParams&& params) const = 0; }; @@ -121,72 +133,72 @@ class Droid service::FieldResult getId(service::FieldParams&& params) const final { - if constexpr (methods::DroidMethod::WithParamsId) + if constexpr (methods::DroidHas::getIdWithParams) { return { _pimpl->getId(std::move(params)) }; } else { - static_assert(methods::DroidMethod::NoParamsId, R"msg(Droid::getId is not implemented)msg"); + static_assert(methods::DroidHas::getId, R"msg(Droid::getId is not implemented)msg"); return { _pimpl->getId() }; } } service::FieldResult> getName(service::FieldParams&& params) const final { - if constexpr (methods::DroidMethod::WithParamsName) + if constexpr (methods::DroidHas::getNameWithParams) { return { _pimpl->getName(std::move(params)) }; } else { - static_assert(methods::DroidMethod::NoParamsName, R"msg(Droid::getName is not implemented)msg"); + static_assert(methods::DroidHas::getName, R"msg(Droid::getName is not implemented)msg"); return { _pimpl->getName() }; } } - service::FieldResult>>> getFriends(service::FieldParams&& params) const final + service::FieldResult>>> getFriends(service::FieldParams&& params) const final { - if constexpr (methods::DroidMethod::WithParamsFriends) + if constexpr (methods::DroidHas::getFriendsWithParams) { return { _pimpl->getFriends(std::move(params)) }; } else { - static_assert(methods::DroidMethod::NoParamsFriends, R"msg(Droid::getFriends is not implemented)msg"); + static_assert(methods::DroidHas::getFriends, R"msg(Droid::getFriends is not implemented)msg"); return { _pimpl->getFriends() }; } } service::FieldResult>>> getAppearsIn(service::FieldParams&& params) const final { - if constexpr (methods::DroidMethod::WithParamsAppearsIn) + if constexpr (methods::DroidHas::getAppearsInWithParams) { return { _pimpl->getAppearsIn(std::move(params)) }; } else { - static_assert(methods::DroidMethod::NoParamsAppearsIn, R"msg(Droid::getAppearsIn is not implemented)msg"); + static_assert(methods::DroidHas::getAppearsIn, R"msg(Droid::getAppearsIn is not implemented)msg"); return { _pimpl->getAppearsIn() }; } } service::FieldResult> getPrimaryFunction(service::FieldParams&& params) const final { - if constexpr (methods::DroidMethod::WithParamsPrimaryFunction) + if constexpr (methods::DroidHas::getPrimaryFunctionWithParams) { return { _pimpl->getPrimaryFunction(std::move(params)) }; } else { - static_assert(methods::DroidMethod::NoParamsPrimaryFunction, R"msg(Droid::getPrimaryFunction is not implemented)msg"); + static_assert(methods::DroidHas::getPrimaryFunction, R"msg(Droid::getPrimaryFunction is not implemented)msg"); return { _pimpl->getPrimaryFunction() }; } } void beginSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::DroidMethod::HasBeginSelectionSet) + if constexpr (methods::DroidHas::beginSelectionSet) { _pimpl->beginSelectionSet(params); } @@ -194,7 +206,7 @@ class Droid void endSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::DroidMethod::HasEndSelectionSet) + if constexpr (methods::DroidHas::endSelectionSet) { _pimpl->endSelectionSet(params); } @@ -204,7 +216,19 @@ class Droid const std::shared_ptr _pimpl; }; - Droid(std::unique_ptr&& pimpl); + Droid(std::unique_ptr&& pimpl) noexcept; + + // Interface objects need access to these methods + friend Character; + + template + static constexpr bool implements() noexcept + { + return implements::DroidIs; + } + + service::TypeNames getTypeNames() const noexcept; + service::ResolverMap getResolvers() const noexcept; void beginSelectionSet(const service::SelectionSetParams& params) const final; void endSelectionSet(const service::SelectionSetParams& params) const final; @@ -213,7 +237,7 @@ class Droid public: template - Droid(std::shared_ptr pimpl) + Droid(std::shared_ptr pimpl) noexcept : Droid { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } diff --git a/samples/learn/schema/HumanObject.cpp b/samples/learn/schema/HumanObject.cpp index 9c293201..eef34f4b 100644 --- a/samples/learn/schema/HumanObject.cpp +++ b/samples/learn/schema/HumanObject.cpp @@ -18,20 +18,30 @@ using namespace std::literals; namespace graphql::learn { namespace object { -Human::Human(std::unique_ptr&& pimpl) - : service::Object({ +Human::Human(std::unique_ptr&& pimpl) noexcept + : service::Object{ getTypeNames(), getResolvers() } + , _pimpl { std::move(pimpl) } +{ +} + +service::TypeNames Human::getTypeNames() const noexcept +{ + return { "Character", "Human" - }, { + }; +} + +service::ResolverMap Human::getResolvers() const noexcept +{ + return { { R"gql(id)gql"sv, [this](service::ResolverParams&& params) { return resolveId(std::move(params)); } }, { R"gql(name)gql"sv, [this](service::ResolverParams&& params) { return resolveName(std::move(params)); } }, { R"gql(friends)gql"sv, [this](service::ResolverParams&& params) { return resolveFriends(std::move(params)); } }, { R"gql(appearsIn)gql"sv, [this](service::ResolverParams&& params) { return resolveAppearsIn(std::move(params)); } }, { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, { R"gql(homePlanet)gql"sv, [this](service::ResolverParams&& params) { return resolveHomePlanet(std::move(params)); } } - }) - , _pimpl(std::move(pimpl)) -{ + }; } void Human::beginSelectionSet(const service::SelectionSetParams& params) const @@ -44,7 +54,7 @@ void Human::endSelectionSet(const service::SelectionSetParams& params) const _pimpl->endSelectionSet(params); } -service::AwaitableResolver Human::resolveId(service::ResolverParams&& params) +service::AwaitableResolver Human::resolveId(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -54,7 +64,7 @@ service::AwaitableResolver Human::resolveId(service::ResolverParams&& params) return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Human::resolveName(service::ResolverParams&& params) +service::AwaitableResolver Human::resolveName(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -64,17 +74,17 @@ service::AwaitableResolver Human::resolveName(service::ResolverParams&& params) return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Human::resolveFriends(service::ResolverParams&& params) +service::AwaitableResolver Human::resolveFriends(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); auto result = _pimpl->getFriends(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Human::resolveAppearsIn(service::ResolverParams&& params) +service::AwaitableResolver Human::resolveAppearsIn(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -84,7 +94,7 @@ service::AwaitableResolver Human::resolveAppearsIn(service::ResolverParams&& par return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Human::resolveHomePlanet(service::ResolverParams&& params) +service::AwaitableResolver Human::resolveHomePlanet(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -94,14 +104,14 @@ service::AwaitableResolver Human::resolveHomePlanet(service::ResolverParams&& pa return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Human::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver Human::resolve_typename(service::ResolverParams&& params) const { return service::ModifiedResult::convert(std::string{ R"gql(Human)gql" }, std::move(params)); } } // namespace object -void AddHumanDetails(std::shared_ptr typeHuman, const std::shared_ptr& schema) +void AddHumanDetails(const std::shared_ptr& typeHuman, const std::shared_ptr& schema) { typeHuman->AddInterfaces({ std::static_pointer_cast(schema->LookupType(R"gql(Character)gql"sv)) diff --git a/samples/learn/schema/HumanObject.h b/samples/learn/schema/HumanObject.h index aab00461..4f62db54 100644 --- a/samples/learn/schema/HumanObject.h +++ b/samples/learn/schema/HumanObject.h @@ -10,103 +10,115 @@ #include "StarWarsSchema.h" +#include "CharacterObject.h" + namespace graphql::learn::object { -namespace methods::HumanMethod { +namespace implements { + +template +concept HumanIs = std::is_same_v; + +} // namespace implements + +namespace methods::HumanHas { template -concept WithParamsId = requires (TImpl impl, service::FieldParams params) +concept getIdWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getId(std::move(params)) } }; }; template -concept NoParamsId = requires (TImpl impl) +concept getId = requires (TImpl impl) { { service::FieldResult { impl.getId() } }; }; template -concept WithParamsName = requires (TImpl impl, service::FieldParams params) +concept getNameWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getName(std::move(params)) } }; }; template -concept NoParamsName = requires (TImpl impl) +concept getName = requires (TImpl impl) { { service::FieldResult> { impl.getName() } }; }; template -concept WithParamsFriends = requires (TImpl impl, service::FieldParams params) +concept getFriendsWithParams = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult>>> { impl.getFriends(std::move(params)) } }; + { service::FieldResult>>> { impl.getFriends(std::move(params)) } }; }; template -concept NoParamsFriends = requires (TImpl impl) +concept getFriends = requires (TImpl impl) { - { service::FieldResult>>> { impl.getFriends() } }; + { service::FieldResult>>> { impl.getFriends() } }; }; template -concept WithParamsAppearsIn = requires (TImpl impl, service::FieldParams params) +concept getAppearsInWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult>>> { impl.getAppearsIn(std::move(params)) } }; }; template -concept NoParamsAppearsIn = requires (TImpl impl) +concept getAppearsIn = requires (TImpl impl) { { service::FieldResult>>> { impl.getAppearsIn() } }; }; template -concept WithParamsHomePlanet = requires (TImpl impl, service::FieldParams params) +concept getHomePlanetWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getHomePlanet(std::move(params)) } }; }; template -concept NoParamsHomePlanet = requires (TImpl impl) +concept getHomePlanet = requires (TImpl impl) { { service::FieldResult> { impl.getHomePlanet() } }; }; template -concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.beginSelectionSet(params) }; }; template -concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.endSelectionSet(params) }; }; -} // namespace methods::HumanMethod +} // namespace methods::HumanHas class Human : public service::Object { private: - service::AwaitableResolver resolveId(service::ResolverParams&& params); - service::AwaitableResolver resolveName(service::ResolverParams&& params); - service::AwaitableResolver resolveFriends(service::ResolverParams&& params); - service::AwaitableResolver resolveAppearsIn(service::ResolverParams&& params); - service::AwaitableResolver resolveHomePlanet(service::ResolverParams&& params); + service::AwaitableResolver resolveId(service::ResolverParams&& params) const; + service::AwaitableResolver resolveName(service::ResolverParams&& params) const; + service::AwaitableResolver resolveFriends(service::ResolverParams&& params) const; + service::AwaitableResolver resolveAppearsIn(service::ResolverParams&& params) const; + service::AwaitableResolver resolveHomePlanet(service::ResolverParams&& params) const; - service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; struct Concept - : Character { virtual ~Concept() = default; virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual service::FieldResult getId(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getName(service::FieldParams&& params) const = 0; + virtual service::FieldResult>>> getFriends(service::FieldParams&& params) const = 0; + virtual service::FieldResult>>> getAppearsIn(service::FieldParams&& params) const = 0; virtual service::FieldResult> getHomePlanet(service::FieldParams&& params) const = 0; }; @@ -121,72 +133,72 @@ class Human service::FieldResult getId(service::FieldParams&& params) const final { - if constexpr (methods::HumanMethod::WithParamsId) + if constexpr (methods::HumanHas::getIdWithParams) { return { _pimpl->getId(std::move(params)) }; } else { - static_assert(methods::HumanMethod::NoParamsId, R"msg(Human::getId is not implemented)msg"); + static_assert(methods::HumanHas::getId, R"msg(Human::getId is not implemented)msg"); return { _pimpl->getId() }; } } service::FieldResult> getName(service::FieldParams&& params) const final { - if constexpr (methods::HumanMethod::WithParamsName) + if constexpr (methods::HumanHas::getNameWithParams) { return { _pimpl->getName(std::move(params)) }; } else { - static_assert(methods::HumanMethod::NoParamsName, R"msg(Human::getName is not implemented)msg"); + static_assert(methods::HumanHas::getName, R"msg(Human::getName is not implemented)msg"); return { _pimpl->getName() }; } } - service::FieldResult>>> getFriends(service::FieldParams&& params) const final + service::FieldResult>>> getFriends(service::FieldParams&& params) const final { - if constexpr (methods::HumanMethod::WithParamsFriends) + if constexpr (methods::HumanHas::getFriendsWithParams) { return { _pimpl->getFriends(std::move(params)) }; } else { - static_assert(methods::HumanMethod::NoParamsFriends, R"msg(Human::getFriends is not implemented)msg"); + static_assert(methods::HumanHas::getFriends, R"msg(Human::getFriends is not implemented)msg"); return { _pimpl->getFriends() }; } } service::FieldResult>>> getAppearsIn(service::FieldParams&& params) const final { - if constexpr (methods::HumanMethod::WithParamsAppearsIn) + if constexpr (methods::HumanHas::getAppearsInWithParams) { return { _pimpl->getAppearsIn(std::move(params)) }; } else { - static_assert(methods::HumanMethod::NoParamsAppearsIn, R"msg(Human::getAppearsIn is not implemented)msg"); + static_assert(methods::HumanHas::getAppearsIn, R"msg(Human::getAppearsIn is not implemented)msg"); return { _pimpl->getAppearsIn() }; } } service::FieldResult> getHomePlanet(service::FieldParams&& params) const final { - if constexpr (methods::HumanMethod::WithParamsHomePlanet) + if constexpr (methods::HumanHas::getHomePlanetWithParams) { return { _pimpl->getHomePlanet(std::move(params)) }; } else { - static_assert(methods::HumanMethod::NoParamsHomePlanet, R"msg(Human::getHomePlanet is not implemented)msg"); + static_assert(methods::HumanHas::getHomePlanet, R"msg(Human::getHomePlanet is not implemented)msg"); return { _pimpl->getHomePlanet() }; } } void beginSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::HumanMethod::HasBeginSelectionSet) + if constexpr (methods::HumanHas::beginSelectionSet) { _pimpl->beginSelectionSet(params); } @@ -194,7 +206,7 @@ class Human void endSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::HumanMethod::HasEndSelectionSet) + if constexpr (methods::HumanHas::endSelectionSet) { _pimpl->endSelectionSet(params); } @@ -204,7 +216,19 @@ class Human const std::shared_ptr _pimpl; }; - Human(std::unique_ptr&& pimpl); + Human(std::unique_ptr&& pimpl) noexcept; + + // Interface objects need access to these methods + friend Character; + + template + static constexpr bool implements() noexcept + { + return implements::HumanIs; + } + + service::TypeNames getTypeNames() const noexcept; + service::ResolverMap getResolvers() const noexcept; void beginSelectionSet(const service::SelectionSetParams& params) const final; void endSelectionSet(const service::SelectionSetParams& params) const final; @@ -213,7 +237,7 @@ class Human public: template - Human(std::shared_ptr pimpl) + Human(std::shared_ptr pimpl) noexcept : Human { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } diff --git a/samples/learn/schema/MutationObject.cpp b/samples/learn/schema/MutationObject.cpp index 608b3293..cf071707 100644 --- a/samples/learn/schema/MutationObject.cpp +++ b/samples/learn/schema/MutationObject.cpp @@ -18,15 +18,25 @@ using namespace std::literals; namespace graphql::learn { namespace object { -Mutation::Mutation(std::unique_ptr&& pimpl) - : service::Object({ +Mutation::Mutation(std::unique_ptr&& pimpl) noexcept + : service::Object{ getTypeNames(), getResolvers() } + , _pimpl { std::move(pimpl) } +{ +} + +service::TypeNames Mutation::getTypeNames() const noexcept +{ + return { "Mutation" - }, { + }; +} + +service::ResolverMap Mutation::getResolvers() const noexcept +{ + return { { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, { R"gql(createReview)gql"sv, [this](service::ResolverParams&& params) { return resolveCreateReview(std::move(params)); } } - }) - , _pimpl(std::move(pimpl)) -{ + }; } void Mutation::beginSelectionSet(const service::SelectionSetParams& params) const @@ -39,7 +49,7 @@ void Mutation::endSelectionSet(const service::SelectionSetParams& params) const _pimpl->endSelectionSet(params); } -service::AwaitableResolver Mutation::resolveCreateReview(service::ResolverParams&& params) +service::AwaitableResolver Mutation::resolveCreateReview(service::ResolverParams&& params) const { auto argEp = service::ModifiedArgument::require("ep", params.arguments); auto argReview = service::ModifiedArgument::require("review", params.arguments); @@ -51,14 +61,14 @@ service::AwaitableResolver Mutation::resolveCreateReview(service::ResolverParams return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Mutation::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver Mutation::resolve_typename(service::ResolverParams&& params) const { return service::ModifiedResult::convert(std::string{ R"gql(Mutation)gql" }, std::move(params)); } } // namespace object -void AddMutationDetails(std::shared_ptr typeMutation, const std::shared_ptr& schema) +void AddMutationDetails(const std::shared_ptr& typeMutation, const std::shared_ptr& schema) { typeMutation->AddFields({ schema::Field::Make(R"gql(createReview)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("Review")), { diff --git a/samples/learn/schema/MutationObject.h b/samples/learn/schema/MutationObject.h index 12313ca4..a6cf98d7 100644 --- a/samples/learn/schema/MutationObject.h +++ b/samples/learn/schema/MutationObject.h @@ -11,41 +11,41 @@ #include "StarWarsSchema.h" namespace graphql::learn::object { -namespace methods::MutationMethod { +namespace methods::MutationHas { template -concept WithParamsCreateReview = requires (TImpl impl, service::FieldParams params, Episode epArg, ReviewInput reviewArg) +concept applyCreateReviewWithParams = requires (TImpl impl, service::FieldParams params, Episode epArg, ReviewInput reviewArg) { { service::FieldResult> { impl.applyCreateReview(std::move(params), std::move(epArg), std::move(reviewArg)) } }; }; template -concept NoParamsCreateReview = requires (TImpl impl, Episode epArg, ReviewInput reviewArg) +concept applyCreateReview = requires (TImpl impl, Episode epArg, ReviewInput reviewArg) { { service::FieldResult> { impl.applyCreateReview(std::move(epArg), std::move(reviewArg)) } }; }; template -concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.beginSelectionSet(params) }; }; template -concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.endSelectionSet(params) }; }; -} // namespace methods::MutationMethod +} // namespace methods::MutationHas class Mutation : public service::Object { private: - service::AwaitableResolver resolveCreateReview(service::ResolverParams&& params); + service::AwaitableResolver resolveCreateReview(service::ResolverParams&& params) const; - service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; struct Concept { @@ -68,20 +68,20 @@ class Mutation service::FieldResult> applyCreateReview(service::FieldParams&& params, Episode&& epArg, ReviewInput&& reviewArg) const final { - if constexpr (methods::MutationMethod::WithParamsCreateReview) + if constexpr (methods::MutationHas::applyCreateReviewWithParams) { return { _pimpl->applyCreateReview(std::move(params), std::move(epArg), std::move(reviewArg)) }; } else { - static_assert(methods::MutationMethod::NoParamsCreateReview, R"msg(Mutation::applyCreateReview is not implemented)msg"); + static_assert(methods::MutationHas::applyCreateReview, R"msg(Mutation::applyCreateReview is not implemented)msg"); return { _pimpl->applyCreateReview(std::move(epArg), std::move(reviewArg)) }; } } void beginSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::MutationMethod::HasBeginSelectionSet) + if constexpr (methods::MutationHas::beginSelectionSet) { _pimpl->beginSelectionSet(params); } @@ -89,7 +89,7 @@ class Mutation void endSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::MutationMethod::HasEndSelectionSet) + if constexpr (methods::MutationHas::endSelectionSet) { _pimpl->endSelectionSet(params); } @@ -99,7 +99,10 @@ class Mutation const std::shared_ptr _pimpl; }; - Mutation(std::unique_ptr&& pimpl); + Mutation(std::unique_ptr&& pimpl) noexcept; + + service::TypeNames getTypeNames() const noexcept; + service::ResolverMap getResolvers() const noexcept; void beginSelectionSet(const service::SelectionSetParams& params) const final; void endSelectionSet(const service::SelectionSetParams& params) const final; @@ -108,7 +111,7 @@ class Mutation public: template - Mutation(std::shared_ptr pimpl) + Mutation(std::shared_ptr pimpl) noexcept : Mutation { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } diff --git a/samples/learn/schema/QueryObject.cpp b/samples/learn/schema/QueryObject.cpp index b31490e0..3bbab1aa 100644 --- a/samples/learn/schema/QueryObject.cpp +++ b/samples/learn/schema/QueryObject.cpp @@ -18,20 +18,30 @@ using namespace std::literals; namespace graphql::learn { namespace object { -Query::Query(std::unique_ptr&& pimpl) - : service::Object({ +Query::Query(std::unique_ptr&& pimpl) noexcept + : service::Object{ getTypeNames(), getResolvers() } + , _schema { GetSchema() } + , _pimpl { std::move(pimpl) } +{ +} + +service::TypeNames Query::getTypeNames() const noexcept +{ + return { "Query" - }, { + }; +} + +service::ResolverMap Query::getResolvers() const noexcept +{ + return { { R"gql(hero)gql"sv, [this](service::ResolverParams&& params) { return resolveHero(std::move(params)); } }, { R"gql(droid)gql"sv, [this](service::ResolverParams&& params) { return resolveDroid(std::move(params)); } }, { R"gql(human)gql"sv, [this](service::ResolverParams&& params) { return resolveHuman(std::move(params)); } }, { R"gql(__type)gql"sv, [this](service::ResolverParams&& params) { return resolve_type(std::move(params)); } }, { R"gql(__schema)gql"sv, [this](service::ResolverParams&& params) { return resolve_schema(std::move(params)); } }, { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } } - }) - , _schema(GetSchema()) - , _pimpl(std::move(pimpl)) -{ + }; } void Query::beginSelectionSet(const service::SelectionSetParams& params) const @@ -44,7 +54,7 @@ void Query::endSelectionSet(const service::SelectionSetParams& params) const _pimpl->endSelectionSet(params); } -service::AwaitableResolver Query::resolveHero(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveHero(service::ResolverParams&& params) const { auto argEpisode = service::ModifiedArgument::require("episode", params.arguments); std::unique_lock resolverLock(_resolverMutex); @@ -52,10 +62,10 @@ service::AwaitableResolver Query::resolveHero(service::ResolverParams&& params) auto result = _pimpl->getHero(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argEpisode)); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Query::resolveHuman(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveHuman(service::ResolverParams&& params) const { auto argId = service::ModifiedArgument::require("id", params.arguments); std::unique_lock resolverLock(_resolverMutex); @@ -66,7 +76,7 @@ service::AwaitableResolver Query::resolveHuman(service::ResolverParams&& params) return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Query::resolveDroid(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveDroid(service::ResolverParams&& params) const { auto argId = service::ModifiedArgument::require("id", params.arguments); std::unique_lock resolverLock(_resolverMutex); @@ -77,17 +87,17 @@ service::AwaitableResolver Query::resolveDroid(service::ResolverParams&& params) return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Query::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver Query::resolve_typename(service::ResolverParams&& params) const { return service::ModifiedResult::convert(std::string{ R"gql(Query)gql" }, std::move(params)); } -service::AwaitableResolver Query::resolve_schema(service::ResolverParams&& params) +service::AwaitableResolver Query::resolve_schema(service::ResolverParams&& params) const { return service::ModifiedResult::convert(std::static_pointer_cast(std::make_shared(std::make_shared(_schema))), std::move(params)); } -service::AwaitableResolver Query::resolve_type(service::ResolverParams&& params) +service::AwaitableResolver Query::resolve_type(service::ResolverParams&& params) const { auto argName = service::ModifiedArgument::require("name", params.arguments); const auto& baseType = _schema->LookupType(argName); @@ -98,7 +108,7 @@ service::AwaitableResolver Query::resolve_type(service::ResolverParams&& params) } // namespace object -void AddQueryDetails(std::shared_ptr typeQuery, const std::shared_ptr& schema) +void AddQueryDetails(const std::shared_ptr& typeQuery, const std::shared_ptr& schema) { typeQuery->AddFields({ schema::Field::Make(R"gql(hero)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType("Character"), { diff --git a/samples/learn/schema/QueryObject.h b/samples/learn/schema/QueryObject.h index 059bbefa..b3fa5bab 100644 --- a/samples/learn/schema/QueryObject.h +++ b/samples/learn/schema/QueryObject.h @@ -11,69 +11,69 @@ #include "StarWarsSchema.h" namespace graphql::learn::object { -namespace methods::QueryMethod { +namespace methods::QueryHas { template -concept WithParamsHero = requires (TImpl impl, service::FieldParams params, std::optional episodeArg) +concept getHeroWithParams = requires (TImpl impl, service::FieldParams params, std::optional episodeArg) { - { service::FieldResult> { impl.getHero(std::move(params), std::move(episodeArg)) } }; + { service::FieldResult> { impl.getHero(std::move(params), std::move(episodeArg)) } }; }; template -concept NoParamsHero = requires (TImpl impl, std::optional episodeArg) +concept getHero = requires (TImpl impl, std::optional episodeArg) { - { service::FieldResult> { impl.getHero(std::move(episodeArg)) } }; + { service::FieldResult> { impl.getHero(std::move(episodeArg)) } }; }; template -concept WithParamsHuman = requires (TImpl impl, service::FieldParams params, std::string idArg) +concept getHumanWithParams = requires (TImpl impl, service::FieldParams params, std::string idArg) { { service::FieldResult> { impl.getHuman(std::move(params), std::move(idArg)) } }; }; template -concept NoParamsHuman = requires (TImpl impl, std::string idArg) +concept getHuman = requires (TImpl impl, std::string idArg) { { service::FieldResult> { impl.getHuman(std::move(idArg)) } }; }; template -concept WithParamsDroid = requires (TImpl impl, service::FieldParams params, std::string idArg) +concept getDroidWithParams = requires (TImpl impl, service::FieldParams params, std::string idArg) { { service::FieldResult> { impl.getDroid(std::move(params), std::move(idArg)) } }; }; template -concept NoParamsDroid = requires (TImpl impl, std::string idArg) +concept getDroid = requires (TImpl impl, std::string idArg) { { service::FieldResult> { impl.getDroid(std::move(idArg)) } }; }; template -concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.beginSelectionSet(params) }; }; template -concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.endSelectionSet(params) }; }; -} // namespace methods::QueryMethod +} // namespace methods::QueryHas class Query : public service::Object { private: - service::AwaitableResolver resolveHero(service::ResolverParams&& params); - service::AwaitableResolver resolveHuman(service::ResolverParams&& params); - service::AwaitableResolver resolveDroid(service::ResolverParams&& params); + service::AwaitableResolver resolveHero(service::ResolverParams&& params) const; + service::AwaitableResolver resolveHuman(service::ResolverParams&& params) const; + service::AwaitableResolver resolveDroid(service::ResolverParams&& params) const; - service::AwaitableResolver resolve_typename(service::ResolverParams&& params); - service::AwaitableResolver resolve_schema(service::ResolverParams&& params); - service::AwaitableResolver resolve_type(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; + service::AwaitableResolver resolve_schema(service::ResolverParams&& params) const; + service::AwaitableResolver resolve_type(service::ResolverParams&& params) const; std::shared_ptr _schema; @@ -84,7 +84,7 @@ class Query virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual service::FieldResult> getHero(service::FieldParams&& params, std::optional&& episodeArg) const = 0; + virtual service::FieldResult> getHero(service::FieldParams&& params, std::optional&& episodeArg) const = 0; virtual service::FieldResult> getHuman(service::FieldParams&& params, std::string&& idArg) const = 0; virtual service::FieldResult> getDroid(service::FieldParams&& params, std::string&& idArg) const = 0; }; @@ -98,48 +98,48 @@ class Query { } - service::FieldResult> getHero(service::FieldParams&& params, std::optional&& episodeArg) const final + service::FieldResult> getHero(service::FieldParams&& params, std::optional&& episodeArg) const final { - if constexpr (methods::QueryMethod::WithParamsHero) + if constexpr (methods::QueryHas::getHeroWithParams) { return { _pimpl->getHero(std::move(params), std::move(episodeArg)) }; } else { - static_assert(methods::QueryMethod::NoParamsHero, R"msg(Query::getHero is not implemented)msg"); + static_assert(methods::QueryHas::getHero, R"msg(Query::getHero is not implemented)msg"); return { _pimpl->getHero(std::move(episodeArg)) }; } } service::FieldResult> getHuman(service::FieldParams&& params, std::string&& idArg) const final { - if constexpr (methods::QueryMethod::WithParamsHuman) + if constexpr (methods::QueryHas::getHumanWithParams) { return { _pimpl->getHuman(std::move(params), std::move(idArg)) }; } else { - static_assert(methods::QueryMethod::NoParamsHuman, R"msg(Query::getHuman is not implemented)msg"); + static_assert(methods::QueryHas::getHuman, R"msg(Query::getHuman is not implemented)msg"); return { _pimpl->getHuman(std::move(idArg)) }; } } service::FieldResult> getDroid(service::FieldParams&& params, std::string&& idArg) const final { - if constexpr (methods::QueryMethod::WithParamsDroid) + if constexpr (methods::QueryHas::getDroidWithParams) { return { _pimpl->getDroid(std::move(params), std::move(idArg)) }; } else { - static_assert(methods::QueryMethod::NoParamsDroid, R"msg(Query::getDroid is not implemented)msg"); + static_assert(methods::QueryHas::getDroid, R"msg(Query::getDroid is not implemented)msg"); return { _pimpl->getDroid(std::move(idArg)) }; } } void beginSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::QueryMethod::HasBeginSelectionSet) + if constexpr (methods::QueryHas::beginSelectionSet) { _pimpl->beginSelectionSet(params); } @@ -147,7 +147,7 @@ class Query void endSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::QueryMethod::HasEndSelectionSet) + if constexpr (methods::QueryHas::endSelectionSet) { _pimpl->endSelectionSet(params); } @@ -157,7 +157,10 @@ class Query const std::shared_ptr _pimpl; }; - Query(std::unique_ptr&& pimpl); + Query(std::unique_ptr&& pimpl) noexcept; + + service::TypeNames getTypeNames() const noexcept; + service::ResolverMap getResolvers() const noexcept; void beginSelectionSet(const service::SelectionSetParams& params) const final; void endSelectionSet(const service::SelectionSetParams& params) const final; @@ -166,7 +169,7 @@ class Query public: template - Query(std::shared_ptr pimpl) + Query(std::shared_ptr pimpl) noexcept : Query { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } diff --git a/samples/learn/schema/ReviewObject.cpp b/samples/learn/schema/ReviewObject.cpp index ac9daf40..fd773a95 100644 --- a/samples/learn/schema/ReviewObject.cpp +++ b/samples/learn/schema/ReviewObject.cpp @@ -18,16 +18,26 @@ using namespace std::literals; namespace graphql::learn { namespace object { -Review::Review(std::unique_ptr&& pimpl) - : service::Object({ +Review::Review(std::unique_ptr&& pimpl) noexcept + : service::Object{ getTypeNames(), getResolvers() } + , _pimpl { std::move(pimpl) } +{ +} + +service::TypeNames Review::getTypeNames() const noexcept +{ + return { "Review" - }, { + }; +} + +service::ResolverMap Review::getResolvers() const noexcept +{ + return { { R"gql(stars)gql"sv, [this](service::ResolverParams&& params) { return resolveStars(std::move(params)); } }, { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, { R"gql(commentary)gql"sv, [this](service::ResolverParams&& params) { return resolveCommentary(std::move(params)); } } - }) - , _pimpl(std::move(pimpl)) -{ + }; } void Review::beginSelectionSet(const service::SelectionSetParams& params) const @@ -40,7 +50,7 @@ void Review::endSelectionSet(const service::SelectionSetParams& params) const _pimpl->endSelectionSet(params); } -service::AwaitableResolver Review::resolveStars(service::ResolverParams&& params) +service::AwaitableResolver Review::resolveStars(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -50,7 +60,7 @@ service::AwaitableResolver Review::resolveStars(service::ResolverParams&& params return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Review::resolveCommentary(service::ResolverParams&& params) +service::AwaitableResolver Review::resolveCommentary(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -60,14 +70,14 @@ service::AwaitableResolver Review::resolveCommentary(service::ResolverParams&& p return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Review::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver Review::resolve_typename(service::ResolverParams&& params) const { return service::ModifiedResult::convert(std::string{ R"gql(Review)gql" }, std::move(params)); } } // namespace object -void AddReviewDetails(std::shared_ptr typeReview, const std::shared_ptr& schema) +void AddReviewDetails(const std::shared_ptr& typeReview, const std::shared_ptr& schema) { typeReview->AddFields({ schema::Field::Make(R"gql(stars)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("Int"))), diff --git a/samples/learn/schema/ReviewObject.h b/samples/learn/schema/ReviewObject.h index aac678ca..efa4128e 100644 --- a/samples/learn/schema/ReviewObject.h +++ b/samples/learn/schema/ReviewObject.h @@ -11,54 +11,54 @@ #include "StarWarsSchema.h" namespace graphql::learn::object { -namespace methods::ReviewMethod { +namespace methods::ReviewHas { template -concept WithParamsStars = requires (TImpl impl, service::FieldParams params) +concept getStarsWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getStars(std::move(params)) } }; }; template -concept NoParamsStars = requires (TImpl impl) +concept getStars = requires (TImpl impl) { { service::FieldResult { impl.getStars() } }; }; template -concept WithParamsCommentary = requires (TImpl impl, service::FieldParams params) +concept getCommentaryWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getCommentary(std::move(params)) } }; }; template -concept NoParamsCommentary = requires (TImpl impl) +concept getCommentary = requires (TImpl impl) { { service::FieldResult> { impl.getCommentary() } }; }; template -concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.beginSelectionSet(params) }; }; template -concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.endSelectionSet(params) }; }; -} // namespace methods::ReviewMethod +} // namespace methods::ReviewHas class Review : public service::Object { private: - service::AwaitableResolver resolveStars(service::ResolverParams&& params); - service::AwaitableResolver resolveCommentary(service::ResolverParams&& params); + service::AwaitableResolver resolveStars(service::ResolverParams&& params) const; + service::AwaitableResolver resolveCommentary(service::ResolverParams&& params) const; - service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; struct Concept { @@ -82,33 +82,33 @@ class Review service::FieldResult getStars(service::FieldParams&& params) const final { - if constexpr (methods::ReviewMethod::WithParamsStars) + if constexpr (methods::ReviewHas::getStarsWithParams) { return { _pimpl->getStars(std::move(params)) }; } else { - static_assert(methods::ReviewMethod::NoParamsStars, R"msg(Review::getStars is not implemented)msg"); + static_assert(methods::ReviewHas::getStars, R"msg(Review::getStars is not implemented)msg"); return { _pimpl->getStars() }; } } service::FieldResult> getCommentary(service::FieldParams&& params) const final { - if constexpr (methods::ReviewMethod::WithParamsCommentary) + if constexpr (methods::ReviewHas::getCommentaryWithParams) { return { _pimpl->getCommentary(std::move(params)) }; } else { - static_assert(methods::ReviewMethod::NoParamsCommentary, R"msg(Review::getCommentary is not implemented)msg"); + static_assert(methods::ReviewHas::getCommentary, R"msg(Review::getCommentary is not implemented)msg"); return { _pimpl->getCommentary() }; } } void beginSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::ReviewMethod::HasBeginSelectionSet) + if constexpr (methods::ReviewHas::beginSelectionSet) { _pimpl->beginSelectionSet(params); } @@ -116,7 +116,7 @@ class Review void endSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::ReviewMethod::HasEndSelectionSet) + if constexpr (methods::ReviewHas::endSelectionSet) { _pimpl->endSelectionSet(params); } @@ -126,7 +126,10 @@ class Review const std::shared_ptr _pimpl; }; - Review(std::unique_ptr&& pimpl); + Review(std::unique_ptr&& pimpl) noexcept; + + service::TypeNames getTypeNames() const noexcept; + service::ResolverMap getResolvers() const noexcept; void beginSelectionSet(const service::SelectionSetParams& params) const final; void endSelectionSet(const service::SelectionSetParams& params) const final; @@ -135,7 +138,7 @@ class Review public: template - Review(std::shared_ptr pimpl) + Review(std::shared_ptr pimpl) noexcept : Review { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } diff --git a/samples/learn/schema/StarWarsObjects.h b/samples/learn/schema/StarWarsObjects.h index 80b7d28f..b3c06e0c 100644 --- a/samples/learn/schema/StarWarsObjects.h +++ b/samples/learn/schema/StarWarsObjects.h @@ -10,6 +10,7 @@ #include "StarWarsSchema.h" +#include "CharacterObject.h" #include "HumanObject.h" #include "DroidObject.h" #include "QueryObject.h" diff --git a/samples/learn/schema/StarWarsSchema.cpp b/samples/learn/schema/StarWarsSchema.cpp index 26ce5b3c..a61a98c4 100644 --- a/samples/learn/schema/StarWarsSchema.cpp +++ b/samples/learn/schema/StarWarsSchema.cpp @@ -115,12 +115,7 @@ void AddTypesToSchema(const std::shared_ptr& schema) schema::InputValue::Make(R"gql(commentary)gql"sv, R"md()md"sv, schema->LookupType("String"), R"gql()gql"sv) }); - typeCharacter->AddFields({ - schema::Field::Make(R"gql(id)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("String"))), - schema::Field::Make(R"gql(name)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType("String")), - schema::Field::Make(R"gql(friends)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::LIST, schema->LookupType("Character"))), - schema::Field::Make(R"gql(appearsIn)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::LIST, schema->LookupType("Episode"))) - }); + AddCharacterDetails(typeCharacter, schema); AddHumanDetails(typeHuman, schema); AddDroidDetails(typeDroid, schema); diff --git a/samples/learn/schema/StarWarsSchema.h b/samples/learn/schema/StarWarsSchema.h index 38dc21c2..652d290f 100644 --- a/samples/learn/schema/StarWarsSchema.h +++ b/samples/learn/schema/StarWarsSchema.h @@ -36,6 +36,8 @@ struct ReviewInput namespace object { +class Character; + class Human; class Droid; class Query; @@ -44,14 +46,6 @@ class Mutation; } // namespace object -struct Character -{ - virtual service::FieldResult getId(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getName(service::FieldParams&& params) const = 0; - virtual service::FieldResult>>> getFriends(service::FieldParams&& params) const = 0; - virtual service::FieldResult>>> getAppearsIn(service::FieldParams&& params) const = 0; -}; - class Operations : public service::Request { @@ -69,11 +63,13 @@ class Operations std::shared_ptr _mutation; }; -void AddHumanDetails(std::shared_ptr typeHuman, const std::shared_ptr& schema); -void AddDroidDetails(std::shared_ptr typeDroid, const std::shared_ptr& schema); -void AddQueryDetails(std::shared_ptr typeQuery, const std::shared_ptr& schema); -void AddReviewDetails(std::shared_ptr typeReview, const std::shared_ptr& schema); -void AddMutationDetails(std::shared_ptr typeMutation, const std::shared_ptr& schema); +void AddCharacterDetails(const std::shared_ptr& typeCharacter, const std::shared_ptr& schema); + +void AddHumanDetails(const std::shared_ptr& typeHuman, const std::shared_ptr& schema); +void AddDroidDetails(const std::shared_ptr& typeDroid, const std::shared_ptr& schema); +void AddQueryDetails(const std::shared_ptr& typeQuery, const std::shared_ptr& schema); +void AddReviewDetails(const std::shared_ptr& typeReview, const std::shared_ptr& schema); +void AddMutationDetails(const std::shared_ptr& typeMutation, const std::shared_ptr& schema); std::shared_ptr GetSchema(); diff --git a/samples/learn/schema/learn_schema_files b/samples/learn/schema/learn_schema_files index 9bbec79d..4f897e53 100644 --- a/samples/learn/schema/learn_schema_files +++ b/samples/learn/schema/learn_schema_files @@ -1,4 +1,5 @@ StarWarsSchema.cpp +CharacterObject.cpp HumanObject.cpp DroidObject.cpp QueryObject.cpp diff --git a/samples/today/TodayMock.cpp b/samples/today/TodayMock.cpp index 62262189..34d3f7d2 100644 --- a/samples/today/TodayMock.cpp +++ b/samples/today/TodayMock.cpp @@ -166,7 +166,7 @@ auto operator co_await(std::chrono::duration<_Rep, _Period> delay) return awaiter { delay }; } -service::FieldResult> Query::getNode( +service::FieldResult> Query::getNode( service::FieldParams params, response::IdType id) { // query { node(id: "ZmFrZVRhc2tJZA==") { ...on Task { title } } } @@ -177,21 +177,23 @@ service::FieldResult> Query::getNode( if (appointment) { - co_return std::make_shared(std::move(appointment)); + co_return std::make_shared( + std::make_shared(std::move(appointment))); } auto task = findTask(params, id); if (task) { - co_return std::make_shared(std::move(task)); + co_return std::make_shared(std::make_shared(std::move(task))); } auto folder = findUnreadCount(params, id); if (folder) { - co_return std::make_shared(std::move(folder)); + co_return std::make_shared( + std::make_shared(std::move(folder))); } co_return nullptr; diff --git a/samples/today/TodayMock.h b/samples/today/TodayMock.h index dcea0f50..b8af2cd2 100644 --- a/samples/today/TodayMock.h +++ b/samples/today/TodayMock.h @@ -50,7 +50,7 @@ class Query : public std::enable_shared_from_this explicit Query(appointmentsLoader&& getAppointments, tasksLoader&& getTasks, unreadCountsLoader&& getUnreadCounts); - service::FieldResult> getNode( + service::FieldResult> getNode( service::FieldParams params, response::IdType id); std::future> getAppointments( const service::FieldParams& params, std::optional first, @@ -456,7 +456,7 @@ class Subscription throw std::runtime_error("Unexpected call to getNextAppointmentChange"); } - std::shared_ptr getNodeChange(const response::IdType&) const + std::shared_ptr getNodeChange(const response::IdType&) const { throw std::runtime_error("Unexpected call to getNodeChange"); } @@ -521,7 +521,7 @@ class NextAppointmentChange return std::make_shared(_changeNextAppointment(params.state)); } - std::shared_ptr getNodeChange(const response::IdType&) const + std::shared_ptr getNodeChange(const response::IdType&) const { throw std::runtime_error("Unexpected call to getNodeChange"); } @@ -537,7 +537,7 @@ class NextAppointmentChange class NodeChange { public: - using nodeChange = std::function( + using nodeChange = std::function( const std::shared_ptr&, response::IdType&&)>; explicit NodeChange(nodeChange&& changeNode) @@ -550,11 +550,10 @@ class NodeChange throw std::runtime_error("Unexpected call to getNextAppointmentChange"); } - std::shared_ptr getNodeChange( + std::shared_ptr getNodeChange( const service::FieldParams& params, response::IdType&& idArg) const { - return std::static_pointer_cast( - _changeNode(params.state, std::move(idArg))); + return _changeNode(params.state, std::move(idArg)); } private: diff --git a/samples/today/separate/AppointmentConnectionObject.cpp b/samples/today/separate/AppointmentConnectionObject.cpp index 4a97fb36..446723de 100644 --- a/samples/today/separate/AppointmentConnectionObject.cpp +++ b/samples/today/separate/AppointmentConnectionObject.cpp @@ -18,16 +18,26 @@ using namespace std::literals; namespace graphql::today { namespace object { -AppointmentConnection::AppointmentConnection(std::unique_ptr&& pimpl) - : service::Object({ +AppointmentConnection::AppointmentConnection(std::unique_ptr&& pimpl) noexcept + : service::Object{ getTypeNames(), getResolvers() } + , _pimpl { std::move(pimpl) } +{ +} + +service::TypeNames AppointmentConnection::getTypeNames() const noexcept +{ + return { "AppointmentConnection" - }, { + }; +} + +service::ResolverMap AppointmentConnection::getResolvers() const noexcept +{ + return { { R"gql(edges)gql"sv, [this](service::ResolverParams&& params) { return resolveEdges(std::move(params)); } }, { R"gql(pageInfo)gql"sv, [this](service::ResolverParams&& params) { return resolvePageInfo(std::move(params)); } }, { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } } - }) - , _pimpl(std::move(pimpl)) -{ + }; } void AppointmentConnection::beginSelectionSet(const service::SelectionSetParams& params) const @@ -40,7 +50,7 @@ void AppointmentConnection::endSelectionSet(const service::SelectionSetParams& p _pimpl->endSelectionSet(params); } -service::AwaitableResolver AppointmentConnection::resolvePageInfo(service::ResolverParams&& params) +service::AwaitableResolver AppointmentConnection::resolvePageInfo(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -50,7 +60,7 @@ service::AwaitableResolver AppointmentConnection::resolvePageInfo(service::Resol return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver AppointmentConnection::resolveEdges(service::ResolverParams&& params) +service::AwaitableResolver AppointmentConnection::resolveEdges(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -60,14 +70,14 @@ service::AwaitableResolver AppointmentConnection::resolveEdges(service::Resolver return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver AppointmentConnection::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver AppointmentConnection::resolve_typename(service::ResolverParams&& params) const { return service::ModifiedResult::convert(std::string{ R"gql(AppointmentConnection)gql" }, std::move(params)); } } // namespace object -void AddAppointmentConnectionDetails(std::shared_ptr typeAppointmentConnection, const std::shared_ptr& schema) +void AddAppointmentConnectionDetails(const std::shared_ptr& typeAppointmentConnection, const std::shared_ptr& schema) { typeAppointmentConnection->AddFields({ schema::Field::Make(R"gql(pageInfo)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("PageInfo"))), diff --git a/samples/today/separate/AppointmentConnectionObject.h b/samples/today/separate/AppointmentConnectionObject.h index 20146fdf..b7d5baee 100644 --- a/samples/today/separate/AppointmentConnectionObject.h +++ b/samples/today/separate/AppointmentConnectionObject.h @@ -11,54 +11,54 @@ #include "TodaySchema.h" namespace graphql::today::object { -namespace methods::AppointmentConnectionMethod { +namespace methods::AppointmentConnectionHas { template -concept WithParamsPageInfo = requires (TImpl impl, service::FieldParams params) +concept getPageInfoWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getPageInfo(std::move(params)) } }; }; template -concept NoParamsPageInfo = requires (TImpl impl) +concept getPageInfo = requires (TImpl impl) { { service::FieldResult> { impl.getPageInfo() } }; }; template -concept WithParamsEdges = requires (TImpl impl, service::FieldParams params) +concept getEdgesWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult>>> { impl.getEdges(std::move(params)) } }; }; template -concept NoParamsEdges = requires (TImpl impl) +concept getEdges = requires (TImpl impl) { { service::FieldResult>>> { impl.getEdges() } }; }; template -concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.beginSelectionSet(params) }; }; template -concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.endSelectionSet(params) }; }; -} // namespace methods::AppointmentConnectionMethod +} // namespace methods::AppointmentConnectionHas class AppointmentConnection : public service::Object { private: - service::AwaitableResolver resolvePageInfo(service::ResolverParams&& params); - service::AwaitableResolver resolveEdges(service::ResolverParams&& params); + service::AwaitableResolver resolvePageInfo(service::ResolverParams&& params) const; + service::AwaitableResolver resolveEdges(service::ResolverParams&& params) const; - service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; struct Concept { @@ -82,11 +82,11 @@ class AppointmentConnection service::FieldResult> getPageInfo(service::FieldParams&& params) const final { - if constexpr (methods::AppointmentConnectionMethod::WithParamsPageInfo) + if constexpr (methods::AppointmentConnectionHas::getPageInfoWithParams) { return { _pimpl->getPageInfo(std::move(params)) }; } - else if constexpr (methods::AppointmentConnectionMethod::NoParamsPageInfo) + else if constexpr (methods::AppointmentConnectionHas::getPageInfo) { return { _pimpl->getPageInfo() }; } @@ -98,11 +98,11 @@ class AppointmentConnection service::FieldResult>>> getEdges(service::FieldParams&& params) const final { - if constexpr (methods::AppointmentConnectionMethod::WithParamsEdges) + if constexpr (methods::AppointmentConnectionHas::getEdgesWithParams) { return { _pimpl->getEdges(std::move(params)) }; } - else if constexpr (methods::AppointmentConnectionMethod::NoParamsEdges) + else if constexpr (methods::AppointmentConnectionHas::getEdges) { return { _pimpl->getEdges() }; } @@ -114,7 +114,7 @@ class AppointmentConnection void beginSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::AppointmentConnectionMethod::HasBeginSelectionSet) + if constexpr (methods::AppointmentConnectionHas::beginSelectionSet) { _pimpl->beginSelectionSet(params); } @@ -122,7 +122,7 @@ class AppointmentConnection void endSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::AppointmentConnectionMethod::HasEndSelectionSet) + if constexpr (methods::AppointmentConnectionHas::endSelectionSet) { _pimpl->endSelectionSet(params); } @@ -132,7 +132,10 @@ class AppointmentConnection const std::shared_ptr _pimpl; }; - AppointmentConnection(std::unique_ptr&& pimpl); + AppointmentConnection(std::unique_ptr&& pimpl) noexcept; + + service::TypeNames getTypeNames() const noexcept; + service::ResolverMap getResolvers() const noexcept; void beginSelectionSet(const service::SelectionSetParams& params) const final; void endSelectionSet(const service::SelectionSetParams& params) const final; @@ -141,7 +144,7 @@ class AppointmentConnection public: template - AppointmentConnection(std::shared_ptr pimpl) + AppointmentConnection(std::shared_ptr pimpl) noexcept : AppointmentConnection { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } diff --git a/samples/today/separate/AppointmentEdgeObject.cpp b/samples/today/separate/AppointmentEdgeObject.cpp index 05a5d795..84742a4a 100644 --- a/samples/today/separate/AppointmentEdgeObject.cpp +++ b/samples/today/separate/AppointmentEdgeObject.cpp @@ -18,16 +18,26 @@ using namespace std::literals; namespace graphql::today { namespace object { -AppointmentEdge::AppointmentEdge(std::unique_ptr&& pimpl) - : service::Object({ +AppointmentEdge::AppointmentEdge(std::unique_ptr&& pimpl) noexcept + : service::Object{ getTypeNames(), getResolvers() } + , _pimpl { std::move(pimpl) } +{ +} + +service::TypeNames AppointmentEdge::getTypeNames() const noexcept +{ + return { "AppointmentEdge" - }, { + }; +} + +service::ResolverMap AppointmentEdge::getResolvers() const noexcept +{ + return { { R"gql(node)gql"sv, [this](service::ResolverParams&& params) { return resolveNode(std::move(params)); } }, { R"gql(cursor)gql"sv, [this](service::ResolverParams&& params) { return resolveCursor(std::move(params)); } }, { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } } - }) - , _pimpl(std::move(pimpl)) -{ + }; } void AppointmentEdge::beginSelectionSet(const service::SelectionSetParams& params) const @@ -40,7 +50,7 @@ void AppointmentEdge::endSelectionSet(const service::SelectionSetParams& params) _pimpl->endSelectionSet(params); } -service::AwaitableResolver AppointmentEdge::resolveNode(service::ResolverParams&& params) +service::AwaitableResolver AppointmentEdge::resolveNode(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -50,7 +60,7 @@ service::AwaitableResolver AppointmentEdge::resolveNode(service::ResolverParams& return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver AppointmentEdge::resolveCursor(service::ResolverParams&& params) +service::AwaitableResolver AppointmentEdge::resolveCursor(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -60,14 +70,14 @@ service::AwaitableResolver AppointmentEdge::resolveCursor(service::ResolverParam return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver AppointmentEdge::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver AppointmentEdge::resolve_typename(service::ResolverParams&& params) const { return service::ModifiedResult::convert(std::string{ R"gql(AppointmentEdge)gql" }, std::move(params)); } } // namespace object -void AddAppointmentEdgeDetails(std::shared_ptr typeAppointmentEdge, const std::shared_ptr& schema) +void AddAppointmentEdgeDetails(const std::shared_ptr& typeAppointmentEdge, const std::shared_ptr& schema) { typeAppointmentEdge->AddFields({ schema::Field::Make(R"gql(node)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType("Appointment")), diff --git a/samples/today/separate/AppointmentEdgeObject.h b/samples/today/separate/AppointmentEdgeObject.h index 893a704d..7477476b 100644 --- a/samples/today/separate/AppointmentEdgeObject.h +++ b/samples/today/separate/AppointmentEdgeObject.h @@ -11,54 +11,54 @@ #include "TodaySchema.h" namespace graphql::today::object { -namespace methods::AppointmentEdgeMethod { +namespace methods::AppointmentEdgeHas { template -concept WithParamsNode = requires (TImpl impl, service::FieldParams params) +concept getNodeWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getNode(std::move(params)) } }; }; template -concept NoParamsNode = requires (TImpl impl) +concept getNode = requires (TImpl impl) { { service::FieldResult> { impl.getNode() } }; }; template -concept WithParamsCursor = requires (TImpl impl, service::FieldParams params) +concept getCursorWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getCursor(std::move(params)) } }; }; template -concept NoParamsCursor = requires (TImpl impl) +concept getCursor = requires (TImpl impl) { { service::FieldResult { impl.getCursor() } }; }; template -concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.beginSelectionSet(params) }; }; template -concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.endSelectionSet(params) }; }; -} // namespace methods::AppointmentEdgeMethod +} // namespace methods::AppointmentEdgeHas class AppointmentEdge : public service::Object { private: - service::AwaitableResolver resolveNode(service::ResolverParams&& params); - service::AwaitableResolver resolveCursor(service::ResolverParams&& params); + service::AwaitableResolver resolveNode(service::ResolverParams&& params) const; + service::AwaitableResolver resolveCursor(service::ResolverParams&& params) const; - service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; struct Concept { @@ -82,11 +82,11 @@ class AppointmentEdge service::FieldResult> getNode(service::FieldParams&& params) const final { - if constexpr (methods::AppointmentEdgeMethod::WithParamsNode) + if constexpr (methods::AppointmentEdgeHas::getNodeWithParams) { return { _pimpl->getNode(std::move(params)) }; } - else if constexpr (methods::AppointmentEdgeMethod::NoParamsNode) + else if constexpr (methods::AppointmentEdgeHas::getNode) { return { _pimpl->getNode() }; } @@ -98,11 +98,11 @@ class AppointmentEdge service::FieldResult getCursor(service::FieldParams&& params) const final { - if constexpr (methods::AppointmentEdgeMethod::WithParamsCursor) + if constexpr (methods::AppointmentEdgeHas::getCursorWithParams) { return { _pimpl->getCursor(std::move(params)) }; } - else if constexpr (methods::AppointmentEdgeMethod::NoParamsCursor) + else if constexpr (methods::AppointmentEdgeHas::getCursor) { return { _pimpl->getCursor() }; } @@ -114,7 +114,7 @@ class AppointmentEdge void beginSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::AppointmentEdgeMethod::HasBeginSelectionSet) + if constexpr (methods::AppointmentEdgeHas::beginSelectionSet) { _pimpl->beginSelectionSet(params); } @@ -122,7 +122,7 @@ class AppointmentEdge void endSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::AppointmentEdgeMethod::HasEndSelectionSet) + if constexpr (methods::AppointmentEdgeHas::endSelectionSet) { _pimpl->endSelectionSet(params); } @@ -132,7 +132,10 @@ class AppointmentEdge const std::shared_ptr _pimpl; }; - AppointmentEdge(std::unique_ptr&& pimpl); + AppointmentEdge(std::unique_ptr&& pimpl) noexcept; + + service::TypeNames getTypeNames() const noexcept; + service::ResolverMap getResolvers() const noexcept; void beginSelectionSet(const service::SelectionSetParams& params) const final; void endSelectionSet(const service::SelectionSetParams& params) const final; @@ -141,7 +144,7 @@ class AppointmentEdge public: template - AppointmentEdge(std::shared_ptr pimpl) + AppointmentEdge(std::shared_ptr pimpl) noexcept : AppointmentEdge { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } diff --git a/samples/today/separate/AppointmentObject.cpp b/samples/today/separate/AppointmentObject.cpp index 338ab608..3bc3745d 100644 --- a/samples/today/separate/AppointmentObject.cpp +++ b/samples/today/separate/AppointmentObject.cpp @@ -18,21 +18,31 @@ using namespace std::literals; namespace graphql::today { namespace object { -Appointment::Appointment(std::unique_ptr&& pimpl) - : service::Object({ +Appointment::Appointment(std::unique_ptr&& pimpl) noexcept + : service::Object{ getTypeNames(), getResolvers() } + , _pimpl { std::move(pimpl) } +{ +} + +service::TypeNames Appointment::getTypeNames() const noexcept +{ + return { "Node", "UnionType", "Appointment" - }, { + }; +} + +service::ResolverMap Appointment::getResolvers() const noexcept +{ + return { { R"gql(id)gql"sv, [this](service::ResolverParams&& params) { return resolveId(std::move(params)); } }, { R"gql(when)gql"sv, [this](service::ResolverParams&& params) { return resolveWhen(std::move(params)); } }, { R"gql(isNow)gql"sv, [this](service::ResolverParams&& params) { return resolveIsNow(std::move(params)); } }, { R"gql(subject)gql"sv, [this](service::ResolverParams&& params) { return resolveSubject(std::move(params)); } }, { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, { R"gql(forceError)gql"sv, [this](service::ResolverParams&& params) { return resolveForceError(std::move(params)); } } - }) - , _pimpl(std::move(pimpl)) -{ + }; } void Appointment::beginSelectionSet(const service::SelectionSetParams& params) const @@ -45,7 +55,7 @@ void Appointment::endSelectionSet(const service::SelectionSetParams& params) con _pimpl->endSelectionSet(params); } -service::AwaitableResolver Appointment::resolveId(service::ResolverParams&& params) +service::AwaitableResolver Appointment::resolveId(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -55,7 +65,7 @@ service::AwaitableResolver Appointment::resolveId(service::ResolverParams&& para return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Appointment::resolveWhen(service::ResolverParams&& params) +service::AwaitableResolver Appointment::resolveWhen(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -65,7 +75,7 @@ service::AwaitableResolver Appointment::resolveWhen(service::ResolverParams&& pa return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Appointment::resolveSubject(service::ResolverParams&& params) +service::AwaitableResolver Appointment::resolveSubject(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -75,7 +85,7 @@ service::AwaitableResolver Appointment::resolveSubject(service::ResolverParams&& return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Appointment::resolveIsNow(service::ResolverParams&& params) +service::AwaitableResolver Appointment::resolveIsNow(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -85,7 +95,7 @@ service::AwaitableResolver Appointment::resolveIsNow(service::ResolverParams&& p return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Appointment::resolveForceError(service::ResolverParams&& params) +service::AwaitableResolver Appointment::resolveForceError(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -95,14 +105,14 @@ service::AwaitableResolver Appointment::resolveForceError(service::ResolverParam return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Appointment::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver Appointment::resolve_typename(service::ResolverParams&& params) const { return service::ModifiedResult::convert(std::string{ R"gql(Appointment)gql" }, std::move(params)); } } // namespace object -void AddAppointmentDetails(std::shared_ptr typeAppointment, const std::shared_ptr& schema) +void AddAppointmentDetails(const std::shared_ptr& typeAppointment, const std::shared_ptr& schema) { typeAppointment->AddInterfaces({ std::static_pointer_cast(schema->LookupType(R"gql(Node)gql"sv)) diff --git a/samples/today/separate/AppointmentObject.h b/samples/today/separate/AppointmentObject.h index fd49dd1d..b394859d 100644 --- a/samples/today/separate/AppointmentObject.h +++ b/samples/today/separate/AppointmentObject.h @@ -10,103 +10,112 @@ #include "TodaySchema.h" +#include "NodeObject.h" + namespace graphql::today::object { -namespace methods::AppointmentMethod { +namespace implements { + +template +concept AppointmentIs = std::is_same_v; + +} // namespace implements + +namespace methods::AppointmentHas { template -concept WithParamsId = requires (TImpl impl, service::FieldParams params) +concept getIdWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getId(std::move(params)) } }; }; template -concept NoParamsId = requires (TImpl impl) +concept getId = requires (TImpl impl) { { service::FieldResult { impl.getId() } }; }; template -concept WithParamsWhen = requires (TImpl impl, service::FieldParams params) +concept getWhenWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getWhen(std::move(params)) } }; }; template -concept NoParamsWhen = requires (TImpl impl) +concept getWhen = requires (TImpl impl) { { service::FieldResult> { impl.getWhen() } }; }; template -concept WithParamsSubject = requires (TImpl impl, service::FieldParams params) +concept getSubjectWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getSubject(std::move(params)) } }; }; template -concept NoParamsSubject = requires (TImpl impl) +concept getSubject = requires (TImpl impl) { { service::FieldResult> { impl.getSubject() } }; }; template -concept WithParamsIsNow = requires (TImpl impl, service::FieldParams params) +concept getIsNowWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getIsNow(std::move(params)) } }; }; template -concept NoParamsIsNow = requires (TImpl impl) +concept getIsNow = requires (TImpl impl) { { service::FieldResult { impl.getIsNow() } }; }; template -concept WithParamsForceError = requires (TImpl impl, service::FieldParams params) +concept getForceErrorWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getForceError(std::move(params)) } }; }; template -concept NoParamsForceError = requires (TImpl impl) +concept getForceError = requires (TImpl impl) { { service::FieldResult> { impl.getForceError() } }; }; template -concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.beginSelectionSet(params) }; }; template -concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.endSelectionSet(params) }; }; -} // namespace methods::AppointmentMethod +} // namespace methods::AppointmentHas class Appointment : public service::Object { private: - service::AwaitableResolver resolveId(service::ResolverParams&& params); - service::AwaitableResolver resolveWhen(service::ResolverParams&& params); - service::AwaitableResolver resolveSubject(service::ResolverParams&& params); - service::AwaitableResolver resolveIsNow(service::ResolverParams&& params); - service::AwaitableResolver resolveForceError(service::ResolverParams&& params); + service::AwaitableResolver resolveId(service::ResolverParams&& params) const; + service::AwaitableResolver resolveWhen(service::ResolverParams&& params) const; + service::AwaitableResolver resolveSubject(service::ResolverParams&& params) const; + service::AwaitableResolver resolveIsNow(service::ResolverParams&& params) const; + service::AwaitableResolver resolveForceError(service::ResolverParams&& params) const; - service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; struct Concept - : Node { virtual ~Concept() = default; virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual service::FieldResult getId(service::FieldParams&& params) const = 0; virtual service::FieldResult> getWhen(service::FieldParams&& params) const = 0; virtual service::FieldResult> getSubject(service::FieldParams&& params) const = 0; virtual service::FieldResult getIsNow(service::FieldParams&& params) const = 0; @@ -124,11 +133,11 @@ class Appointment service::FieldResult getId(service::FieldParams&& params) const final { - if constexpr (methods::AppointmentMethod::WithParamsId) + if constexpr (methods::AppointmentHas::getIdWithParams) { return { _pimpl->getId(std::move(params)) }; } - else if constexpr (methods::AppointmentMethod::NoParamsId) + else if constexpr (methods::AppointmentHas::getId) { return { _pimpl->getId() }; } @@ -140,11 +149,11 @@ class Appointment service::FieldResult> getWhen(service::FieldParams&& params) const final { - if constexpr (methods::AppointmentMethod::WithParamsWhen) + if constexpr (methods::AppointmentHas::getWhenWithParams) { return { _pimpl->getWhen(std::move(params)) }; } - else if constexpr (methods::AppointmentMethod::NoParamsWhen) + else if constexpr (methods::AppointmentHas::getWhen) { return { _pimpl->getWhen() }; } @@ -156,11 +165,11 @@ class Appointment service::FieldResult> getSubject(service::FieldParams&& params) const final { - if constexpr (methods::AppointmentMethod::WithParamsSubject) + if constexpr (methods::AppointmentHas::getSubjectWithParams) { return { _pimpl->getSubject(std::move(params)) }; } - else if constexpr (methods::AppointmentMethod::NoParamsSubject) + else if constexpr (methods::AppointmentHas::getSubject) { return { _pimpl->getSubject() }; } @@ -172,11 +181,11 @@ class Appointment service::FieldResult getIsNow(service::FieldParams&& params) const final { - if constexpr (methods::AppointmentMethod::WithParamsIsNow) + if constexpr (methods::AppointmentHas::getIsNowWithParams) { return { _pimpl->getIsNow(std::move(params)) }; } - else if constexpr (methods::AppointmentMethod::NoParamsIsNow) + else if constexpr (methods::AppointmentHas::getIsNow) { return { _pimpl->getIsNow() }; } @@ -188,11 +197,11 @@ class Appointment service::FieldResult> getForceError(service::FieldParams&& params) const final { - if constexpr (methods::AppointmentMethod::WithParamsForceError) + if constexpr (methods::AppointmentHas::getForceErrorWithParams) { return { _pimpl->getForceError(std::move(params)) }; } - else if constexpr (methods::AppointmentMethod::NoParamsForceError) + else if constexpr (methods::AppointmentHas::getForceError) { return { _pimpl->getForceError() }; } @@ -204,7 +213,7 @@ class Appointment void beginSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::AppointmentMethod::HasBeginSelectionSet) + if constexpr (methods::AppointmentHas::beginSelectionSet) { _pimpl->beginSelectionSet(params); } @@ -212,7 +221,7 @@ class Appointment void endSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::AppointmentMethod::HasEndSelectionSet) + if constexpr (methods::AppointmentHas::endSelectionSet) { _pimpl->endSelectionSet(params); } @@ -222,7 +231,19 @@ class Appointment const std::shared_ptr _pimpl; }; - Appointment(std::unique_ptr&& pimpl); + Appointment(std::unique_ptr&& pimpl) noexcept; + + // Interface objects need access to these methods + friend Node; + + template + static constexpr bool implements() noexcept + { + return implements::AppointmentIs; + } + + service::TypeNames getTypeNames() const noexcept; + service::ResolverMap getResolvers() const noexcept; void beginSelectionSet(const service::SelectionSetParams& params) const final; void endSelectionSet(const service::SelectionSetParams& params) const final; @@ -231,7 +252,7 @@ class Appointment public: template - Appointment(std::shared_ptr pimpl) + Appointment(std::shared_ptr pimpl) noexcept : Appointment { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } diff --git a/samples/today/separate/CompleteTaskPayloadObject.cpp b/samples/today/separate/CompleteTaskPayloadObject.cpp index 0c8036f8..aca47fd0 100644 --- a/samples/today/separate/CompleteTaskPayloadObject.cpp +++ b/samples/today/separate/CompleteTaskPayloadObject.cpp @@ -18,16 +18,26 @@ using namespace std::literals; namespace graphql::today { namespace object { -CompleteTaskPayload::CompleteTaskPayload(std::unique_ptr&& pimpl) - : service::Object({ +CompleteTaskPayload::CompleteTaskPayload(std::unique_ptr&& pimpl) noexcept + : service::Object{ getTypeNames(), getResolvers() } + , _pimpl { std::move(pimpl) } +{ +} + +service::TypeNames CompleteTaskPayload::getTypeNames() const noexcept +{ + return { "CompleteTaskPayload" - }, { + }; +} + +service::ResolverMap CompleteTaskPayload::getResolvers() const noexcept +{ + return { { R"gql(task)gql"sv, [this](service::ResolverParams&& params) { return resolveTask(std::move(params)); } }, { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, { R"gql(clientMutationId)gql"sv, [this](service::ResolverParams&& params) { return resolveClientMutationId(std::move(params)); } } - }) - , _pimpl(std::move(pimpl)) -{ + }; } void CompleteTaskPayload::beginSelectionSet(const service::SelectionSetParams& params) const @@ -40,7 +50,7 @@ void CompleteTaskPayload::endSelectionSet(const service::SelectionSetParams& par _pimpl->endSelectionSet(params); } -service::AwaitableResolver CompleteTaskPayload::resolveTask(service::ResolverParams&& params) +service::AwaitableResolver CompleteTaskPayload::resolveTask(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -50,7 +60,7 @@ service::AwaitableResolver CompleteTaskPayload::resolveTask(service::ResolverPar return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver CompleteTaskPayload::resolveClientMutationId(service::ResolverParams&& params) +service::AwaitableResolver CompleteTaskPayload::resolveClientMutationId(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -60,14 +70,14 @@ service::AwaitableResolver CompleteTaskPayload::resolveClientMutationId(service: return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver CompleteTaskPayload::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver CompleteTaskPayload::resolve_typename(service::ResolverParams&& params) const { return service::ModifiedResult::convert(std::string{ R"gql(CompleteTaskPayload)gql" }, std::move(params)); } } // namespace object -void AddCompleteTaskPayloadDetails(std::shared_ptr typeCompleteTaskPayload, const std::shared_ptr& schema) +void AddCompleteTaskPayloadDetails(const std::shared_ptr& typeCompleteTaskPayload, const std::shared_ptr& schema) { typeCompleteTaskPayload->AddFields({ schema::Field::Make(R"gql(task)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType("Task")), diff --git a/samples/today/separate/CompleteTaskPayloadObject.h b/samples/today/separate/CompleteTaskPayloadObject.h index 3411230d..806cf182 100644 --- a/samples/today/separate/CompleteTaskPayloadObject.h +++ b/samples/today/separate/CompleteTaskPayloadObject.h @@ -11,54 +11,54 @@ #include "TodaySchema.h" namespace graphql::today::object { -namespace methods::CompleteTaskPayloadMethod { +namespace methods::CompleteTaskPayloadHas { template -concept WithParamsTask = requires (TImpl impl, service::FieldParams params) +concept getTaskWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getTask(std::move(params)) } }; }; template -concept NoParamsTask = requires (TImpl impl) +concept getTask = requires (TImpl impl) { { service::FieldResult> { impl.getTask() } }; }; template -concept WithParamsClientMutationId = requires (TImpl impl, service::FieldParams params) +concept getClientMutationIdWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getClientMutationId(std::move(params)) } }; }; template -concept NoParamsClientMutationId = requires (TImpl impl) +concept getClientMutationId = requires (TImpl impl) { { service::FieldResult> { impl.getClientMutationId() } }; }; template -concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.beginSelectionSet(params) }; }; template -concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.endSelectionSet(params) }; }; -} // namespace methods::CompleteTaskPayloadMethod +} // namespace methods::CompleteTaskPayloadHas class CompleteTaskPayload : public service::Object { private: - service::AwaitableResolver resolveTask(service::ResolverParams&& params); - service::AwaitableResolver resolveClientMutationId(service::ResolverParams&& params); + service::AwaitableResolver resolveTask(service::ResolverParams&& params) const; + service::AwaitableResolver resolveClientMutationId(service::ResolverParams&& params) const; - service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; struct Concept { @@ -82,11 +82,11 @@ class CompleteTaskPayload service::FieldResult> getTask(service::FieldParams&& params) const final { - if constexpr (methods::CompleteTaskPayloadMethod::WithParamsTask) + if constexpr (methods::CompleteTaskPayloadHas::getTaskWithParams) { return { _pimpl->getTask(std::move(params)) }; } - else if constexpr (methods::CompleteTaskPayloadMethod::NoParamsTask) + else if constexpr (methods::CompleteTaskPayloadHas::getTask) { return { _pimpl->getTask() }; } @@ -98,11 +98,11 @@ class CompleteTaskPayload service::FieldResult> getClientMutationId(service::FieldParams&& params) const final { - if constexpr (methods::CompleteTaskPayloadMethod::WithParamsClientMutationId) + if constexpr (methods::CompleteTaskPayloadHas::getClientMutationIdWithParams) { return { _pimpl->getClientMutationId(std::move(params)) }; } - else if constexpr (methods::CompleteTaskPayloadMethod::NoParamsClientMutationId) + else if constexpr (methods::CompleteTaskPayloadHas::getClientMutationId) { return { _pimpl->getClientMutationId() }; } @@ -114,7 +114,7 @@ class CompleteTaskPayload void beginSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::CompleteTaskPayloadMethod::HasBeginSelectionSet) + if constexpr (methods::CompleteTaskPayloadHas::beginSelectionSet) { _pimpl->beginSelectionSet(params); } @@ -122,7 +122,7 @@ class CompleteTaskPayload void endSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::CompleteTaskPayloadMethod::HasEndSelectionSet) + if constexpr (methods::CompleteTaskPayloadHas::endSelectionSet) { _pimpl->endSelectionSet(params); } @@ -132,7 +132,10 @@ class CompleteTaskPayload const std::shared_ptr _pimpl; }; - CompleteTaskPayload(std::unique_ptr&& pimpl); + CompleteTaskPayload(std::unique_ptr&& pimpl) noexcept; + + service::TypeNames getTypeNames() const noexcept; + service::ResolverMap getResolvers() const noexcept; void beginSelectionSet(const service::SelectionSetParams& params) const final; void endSelectionSet(const service::SelectionSetParams& params) const final; @@ -141,7 +144,7 @@ class CompleteTaskPayload public: template - CompleteTaskPayload(std::shared_ptr pimpl) + CompleteTaskPayload(std::shared_ptr pimpl) noexcept : CompleteTaskPayload { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } diff --git a/samples/today/separate/ExpensiveObject.cpp b/samples/today/separate/ExpensiveObject.cpp index 4e036d1f..ab1b1008 100644 --- a/samples/today/separate/ExpensiveObject.cpp +++ b/samples/today/separate/ExpensiveObject.cpp @@ -18,15 +18,25 @@ using namespace std::literals; namespace graphql::today { namespace object { -Expensive::Expensive(std::unique_ptr&& pimpl) - : service::Object({ +Expensive::Expensive(std::unique_ptr&& pimpl) noexcept + : service::Object{ getTypeNames(), getResolvers() } + , _pimpl { std::move(pimpl) } +{ +} + +service::TypeNames Expensive::getTypeNames() const noexcept +{ + return { "Expensive" - }, { + }; +} + +service::ResolverMap Expensive::getResolvers() const noexcept +{ + return { { R"gql(order)gql"sv, [this](service::ResolverParams&& params) { return resolveOrder(std::move(params)); } }, { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } } - }) - , _pimpl(std::move(pimpl)) -{ + }; } void Expensive::beginSelectionSet(const service::SelectionSetParams& params) const @@ -39,7 +49,7 @@ void Expensive::endSelectionSet(const service::SelectionSetParams& params) const _pimpl->endSelectionSet(params); } -service::AwaitableResolver Expensive::resolveOrder(service::ResolverParams&& params) +service::AwaitableResolver Expensive::resolveOrder(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -49,14 +59,14 @@ service::AwaitableResolver Expensive::resolveOrder(service::ResolverParams&& par return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Expensive::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver Expensive::resolve_typename(service::ResolverParams&& params) const { return service::ModifiedResult::convert(std::string{ R"gql(Expensive)gql" }, std::move(params)); } } // namespace object -void AddExpensiveDetails(std::shared_ptr typeExpensive, const std::shared_ptr& schema) +void AddExpensiveDetails(const std::shared_ptr& typeExpensive, const std::shared_ptr& schema) { typeExpensive->AddFields({ schema::Field::Make(R"gql(order)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("Int"))) diff --git a/samples/today/separate/ExpensiveObject.h b/samples/today/separate/ExpensiveObject.h index 7fd5d538..920d34d5 100644 --- a/samples/today/separate/ExpensiveObject.h +++ b/samples/today/separate/ExpensiveObject.h @@ -11,41 +11,41 @@ #include "TodaySchema.h" namespace graphql::today::object { -namespace methods::ExpensiveMethod { +namespace methods::ExpensiveHas { template -concept WithParamsOrder = requires (TImpl impl, service::FieldParams params) +concept getOrderWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getOrder(std::move(params)) } }; }; template -concept NoParamsOrder = requires (TImpl impl) +concept getOrder = requires (TImpl impl) { { service::FieldResult { impl.getOrder() } }; }; template -concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.beginSelectionSet(params) }; }; template -concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.endSelectionSet(params) }; }; -} // namespace methods::ExpensiveMethod +} // namespace methods::ExpensiveHas class Expensive : public service::Object { private: - service::AwaitableResolver resolveOrder(service::ResolverParams&& params); + service::AwaitableResolver resolveOrder(service::ResolverParams&& params) const; - service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; struct Concept { @@ -68,11 +68,11 @@ class Expensive service::FieldResult getOrder(service::FieldParams&& params) const final { - if constexpr (methods::ExpensiveMethod::WithParamsOrder) + if constexpr (methods::ExpensiveHas::getOrderWithParams) { return { _pimpl->getOrder(std::move(params)) }; } - else if constexpr (methods::ExpensiveMethod::NoParamsOrder) + else if constexpr (methods::ExpensiveHas::getOrder) { return { _pimpl->getOrder() }; } @@ -84,7 +84,7 @@ class Expensive void beginSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::ExpensiveMethod::HasBeginSelectionSet) + if constexpr (methods::ExpensiveHas::beginSelectionSet) { _pimpl->beginSelectionSet(params); } @@ -92,7 +92,7 @@ class Expensive void endSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::ExpensiveMethod::HasEndSelectionSet) + if constexpr (methods::ExpensiveHas::endSelectionSet) { _pimpl->endSelectionSet(params); } @@ -102,7 +102,10 @@ class Expensive const std::shared_ptr _pimpl; }; - Expensive(std::unique_ptr&& pimpl); + Expensive(std::unique_ptr&& pimpl) noexcept; + + service::TypeNames getTypeNames() const noexcept; + service::ResolverMap getResolvers() const noexcept; void beginSelectionSet(const service::SelectionSetParams& params) const final; void endSelectionSet(const service::SelectionSetParams& params) const final; @@ -111,7 +114,7 @@ class Expensive public: template - Expensive(std::shared_ptr pimpl) + Expensive(std::shared_ptr pimpl) noexcept : Expensive { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } diff --git a/samples/today/separate/FolderConnectionObject.cpp b/samples/today/separate/FolderConnectionObject.cpp index b47dd28d..1408c541 100644 --- a/samples/today/separate/FolderConnectionObject.cpp +++ b/samples/today/separate/FolderConnectionObject.cpp @@ -18,16 +18,26 @@ using namespace std::literals; namespace graphql::today { namespace object { -FolderConnection::FolderConnection(std::unique_ptr&& pimpl) - : service::Object({ +FolderConnection::FolderConnection(std::unique_ptr&& pimpl) noexcept + : service::Object{ getTypeNames(), getResolvers() } + , _pimpl { std::move(pimpl) } +{ +} + +service::TypeNames FolderConnection::getTypeNames() const noexcept +{ + return { "FolderConnection" - }, { + }; +} + +service::ResolverMap FolderConnection::getResolvers() const noexcept +{ + return { { R"gql(edges)gql"sv, [this](service::ResolverParams&& params) { return resolveEdges(std::move(params)); } }, { R"gql(pageInfo)gql"sv, [this](service::ResolverParams&& params) { return resolvePageInfo(std::move(params)); } }, { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } } - }) - , _pimpl(std::move(pimpl)) -{ + }; } void FolderConnection::beginSelectionSet(const service::SelectionSetParams& params) const @@ -40,7 +50,7 @@ void FolderConnection::endSelectionSet(const service::SelectionSetParams& params _pimpl->endSelectionSet(params); } -service::AwaitableResolver FolderConnection::resolvePageInfo(service::ResolverParams&& params) +service::AwaitableResolver FolderConnection::resolvePageInfo(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -50,7 +60,7 @@ service::AwaitableResolver FolderConnection::resolvePageInfo(service::ResolverPa return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver FolderConnection::resolveEdges(service::ResolverParams&& params) +service::AwaitableResolver FolderConnection::resolveEdges(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -60,14 +70,14 @@ service::AwaitableResolver FolderConnection::resolveEdges(service::ResolverParam return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver FolderConnection::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver FolderConnection::resolve_typename(service::ResolverParams&& params) const { return service::ModifiedResult::convert(std::string{ R"gql(FolderConnection)gql" }, std::move(params)); } } // namespace object -void AddFolderConnectionDetails(std::shared_ptr typeFolderConnection, const std::shared_ptr& schema) +void AddFolderConnectionDetails(const std::shared_ptr& typeFolderConnection, const std::shared_ptr& schema) { typeFolderConnection->AddFields({ schema::Field::Make(R"gql(pageInfo)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("PageInfo"))), diff --git a/samples/today/separate/FolderConnectionObject.h b/samples/today/separate/FolderConnectionObject.h index f1dc10b1..d2de2dea 100644 --- a/samples/today/separate/FolderConnectionObject.h +++ b/samples/today/separate/FolderConnectionObject.h @@ -11,54 +11,54 @@ #include "TodaySchema.h" namespace graphql::today::object { -namespace methods::FolderConnectionMethod { +namespace methods::FolderConnectionHas { template -concept WithParamsPageInfo = requires (TImpl impl, service::FieldParams params) +concept getPageInfoWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getPageInfo(std::move(params)) } }; }; template -concept NoParamsPageInfo = requires (TImpl impl) +concept getPageInfo = requires (TImpl impl) { { service::FieldResult> { impl.getPageInfo() } }; }; template -concept WithParamsEdges = requires (TImpl impl, service::FieldParams params) +concept getEdgesWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult>>> { impl.getEdges(std::move(params)) } }; }; template -concept NoParamsEdges = requires (TImpl impl) +concept getEdges = requires (TImpl impl) { { service::FieldResult>>> { impl.getEdges() } }; }; template -concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.beginSelectionSet(params) }; }; template -concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.endSelectionSet(params) }; }; -} // namespace methods::FolderConnectionMethod +} // namespace methods::FolderConnectionHas class FolderConnection : public service::Object { private: - service::AwaitableResolver resolvePageInfo(service::ResolverParams&& params); - service::AwaitableResolver resolveEdges(service::ResolverParams&& params); + service::AwaitableResolver resolvePageInfo(service::ResolverParams&& params) const; + service::AwaitableResolver resolveEdges(service::ResolverParams&& params) const; - service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; struct Concept { @@ -82,11 +82,11 @@ class FolderConnection service::FieldResult> getPageInfo(service::FieldParams&& params) const final { - if constexpr (methods::FolderConnectionMethod::WithParamsPageInfo) + if constexpr (methods::FolderConnectionHas::getPageInfoWithParams) { return { _pimpl->getPageInfo(std::move(params)) }; } - else if constexpr (methods::FolderConnectionMethod::NoParamsPageInfo) + else if constexpr (methods::FolderConnectionHas::getPageInfo) { return { _pimpl->getPageInfo() }; } @@ -98,11 +98,11 @@ class FolderConnection service::FieldResult>>> getEdges(service::FieldParams&& params) const final { - if constexpr (methods::FolderConnectionMethod::WithParamsEdges) + if constexpr (methods::FolderConnectionHas::getEdgesWithParams) { return { _pimpl->getEdges(std::move(params)) }; } - else if constexpr (methods::FolderConnectionMethod::NoParamsEdges) + else if constexpr (methods::FolderConnectionHas::getEdges) { return { _pimpl->getEdges() }; } @@ -114,7 +114,7 @@ class FolderConnection void beginSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::FolderConnectionMethod::HasBeginSelectionSet) + if constexpr (methods::FolderConnectionHas::beginSelectionSet) { _pimpl->beginSelectionSet(params); } @@ -122,7 +122,7 @@ class FolderConnection void endSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::FolderConnectionMethod::HasEndSelectionSet) + if constexpr (methods::FolderConnectionHas::endSelectionSet) { _pimpl->endSelectionSet(params); } @@ -132,7 +132,10 @@ class FolderConnection const std::shared_ptr _pimpl; }; - FolderConnection(std::unique_ptr&& pimpl); + FolderConnection(std::unique_ptr&& pimpl) noexcept; + + service::TypeNames getTypeNames() const noexcept; + service::ResolverMap getResolvers() const noexcept; void beginSelectionSet(const service::SelectionSetParams& params) const final; void endSelectionSet(const service::SelectionSetParams& params) const final; @@ -141,7 +144,7 @@ class FolderConnection public: template - FolderConnection(std::shared_ptr pimpl) + FolderConnection(std::shared_ptr pimpl) noexcept : FolderConnection { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } diff --git a/samples/today/separate/FolderEdgeObject.cpp b/samples/today/separate/FolderEdgeObject.cpp index 95ed2c21..6022c600 100644 --- a/samples/today/separate/FolderEdgeObject.cpp +++ b/samples/today/separate/FolderEdgeObject.cpp @@ -18,16 +18,26 @@ using namespace std::literals; namespace graphql::today { namespace object { -FolderEdge::FolderEdge(std::unique_ptr&& pimpl) - : service::Object({ +FolderEdge::FolderEdge(std::unique_ptr&& pimpl) noexcept + : service::Object{ getTypeNames(), getResolvers() } + , _pimpl { std::move(pimpl) } +{ +} + +service::TypeNames FolderEdge::getTypeNames() const noexcept +{ + return { "FolderEdge" - }, { + }; +} + +service::ResolverMap FolderEdge::getResolvers() const noexcept +{ + return { { R"gql(node)gql"sv, [this](service::ResolverParams&& params) { return resolveNode(std::move(params)); } }, { R"gql(cursor)gql"sv, [this](service::ResolverParams&& params) { return resolveCursor(std::move(params)); } }, { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } } - }) - , _pimpl(std::move(pimpl)) -{ + }; } void FolderEdge::beginSelectionSet(const service::SelectionSetParams& params) const @@ -40,7 +50,7 @@ void FolderEdge::endSelectionSet(const service::SelectionSetParams& params) cons _pimpl->endSelectionSet(params); } -service::AwaitableResolver FolderEdge::resolveNode(service::ResolverParams&& params) +service::AwaitableResolver FolderEdge::resolveNode(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -50,7 +60,7 @@ service::AwaitableResolver FolderEdge::resolveNode(service::ResolverParams&& par return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver FolderEdge::resolveCursor(service::ResolverParams&& params) +service::AwaitableResolver FolderEdge::resolveCursor(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -60,14 +70,14 @@ service::AwaitableResolver FolderEdge::resolveCursor(service::ResolverParams&& p return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver FolderEdge::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver FolderEdge::resolve_typename(service::ResolverParams&& params) const { return service::ModifiedResult::convert(std::string{ R"gql(FolderEdge)gql" }, std::move(params)); } } // namespace object -void AddFolderEdgeDetails(std::shared_ptr typeFolderEdge, const std::shared_ptr& schema) +void AddFolderEdgeDetails(const std::shared_ptr& typeFolderEdge, const std::shared_ptr& schema) { typeFolderEdge->AddFields({ schema::Field::Make(R"gql(node)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType("Folder")), diff --git a/samples/today/separate/FolderEdgeObject.h b/samples/today/separate/FolderEdgeObject.h index 6fbd7499..993f0c3c 100644 --- a/samples/today/separate/FolderEdgeObject.h +++ b/samples/today/separate/FolderEdgeObject.h @@ -11,54 +11,54 @@ #include "TodaySchema.h" namespace graphql::today::object { -namespace methods::FolderEdgeMethod { +namespace methods::FolderEdgeHas { template -concept WithParamsNode = requires (TImpl impl, service::FieldParams params) +concept getNodeWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getNode(std::move(params)) } }; }; template -concept NoParamsNode = requires (TImpl impl) +concept getNode = requires (TImpl impl) { { service::FieldResult> { impl.getNode() } }; }; template -concept WithParamsCursor = requires (TImpl impl, service::FieldParams params) +concept getCursorWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getCursor(std::move(params)) } }; }; template -concept NoParamsCursor = requires (TImpl impl) +concept getCursor = requires (TImpl impl) { { service::FieldResult { impl.getCursor() } }; }; template -concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.beginSelectionSet(params) }; }; template -concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.endSelectionSet(params) }; }; -} // namespace methods::FolderEdgeMethod +} // namespace methods::FolderEdgeHas class FolderEdge : public service::Object { private: - service::AwaitableResolver resolveNode(service::ResolverParams&& params); - service::AwaitableResolver resolveCursor(service::ResolverParams&& params); + service::AwaitableResolver resolveNode(service::ResolverParams&& params) const; + service::AwaitableResolver resolveCursor(service::ResolverParams&& params) const; - service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; struct Concept { @@ -82,11 +82,11 @@ class FolderEdge service::FieldResult> getNode(service::FieldParams&& params) const final { - if constexpr (methods::FolderEdgeMethod::WithParamsNode) + if constexpr (methods::FolderEdgeHas::getNodeWithParams) { return { _pimpl->getNode(std::move(params)) }; } - else if constexpr (methods::FolderEdgeMethod::NoParamsNode) + else if constexpr (methods::FolderEdgeHas::getNode) { return { _pimpl->getNode() }; } @@ -98,11 +98,11 @@ class FolderEdge service::FieldResult getCursor(service::FieldParams&& params) const final { - if constexpr (methods::FolderEdgeMethod::WithParamsCursor) + if constexpr (methods::FolderEdgeHas::getCursorWithParams) { return { _pimpl->getCursor(std::move(params)) }; } - else if constexpr (methods::FolderEdgeMethod::NoParamsCursor) + else if constexpr (methods::FolderEdgeHas::getCursor) { return { _pimpl->getCursor() }; } @@ -114,7 +114,7 @@ class FolderEdge void beginSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::FolderEdgeMethod::HasBeginSelectionSet) + if constexpr (methods::FolderEdgeHas::beginSelectionSet) { _pimpl->beginSelectionSet(params); } @@ -122,7 +122,7 @@ class FolderEdge void endSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::FolderEdgeMethod::HasEndSelectionSet) + if constexpr (methods::FolderEdgeHas::endSelectionSet) { _pimpl->endSelectionSet(params); } @@ -132,7 +132,10 @@ class FolderEdge const std::shared_ptr _pimpl; }; - FolderEdge(std::unique_ptr&& pimpl); + FolderEdge(std::unique_ptr&& pimpl) noexcept; + + service::TypeNames getTypeNames() const noexcept; + service::ResolverMap getResolvers() const noexcept; void beginSelectionSet(const service::SelectionSetParams& params) const final; void endSelectionSet(const service::SelectionSetParams& params) const final; @@ -141,7 +144,7 @@ class FolderEdge public: template - FolderEdge(std::shared_ptr pimpl) + FolderEdge(std::shared_ptr pimpl) noexcept : FolderEdge { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } diff --git a/samples/today/separate/FolderObject.cpp b/samples/today/separate/FolderObject.cpp index dfe25974..8c7406a2 100644 --- a/samples/today/separate/FolderObject.cpp +++ b/samples/today/separate/FolderObject.cpp @@ -18,19 +18,29 @@ using namespace std::literals; namespace graphql::today { namespace object { -Folder::Folder(std::unique_ptr&& pimpl) - : service::Object({ +Folder::Folder(std::unique_ptr&& pimpl) noexcept + : service::Object{ getTypeNames(), getResolvers() } + , _pimpl { std::move(pimpl) } +{ +} + +service::TypeNames Folder::getTypeNames() const noexcept +{ + return { "Node", "UnionType", "Folder" - }, { + }; +} + +service::ResolverMap Folder::getResolvers() const noexcept +{ + return { { R"gql(id)gql"sv, [this](service::ResolverParams&& params) { return resolveId(std::move(params)); } }, { R"gql(name)gql"sv, [this](service::ResolverParams&& params) { return resolveName(std::move(params)); } }, { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, { R"gql(unreadCount)gql"sv, [this](service::ResolverParams&& params) { return resolveUnreadCount(std::move(params)); } } - }) - , _pimpl(std::move(pimpl)) -{ + }; } void Folder::beginSelectionSet(const service::SelectionSetParams& params) const @@ -43,7 +53,7 @@ void Folder::endSelectionSet(const service::SelectionSetParams& params) const _pimpl->endSelectionSet(params); } -service::AwaitableResolver Folder::resolveId(service::ResolverParams&& params) +service::AwaitableResolver Folder::resolveId(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -53,7 +63,7 @@ service::AwaitableResolver Folder::resolveId(service::ResolverParams&& params) return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Folder::resolveName(service::ResolverParams&& params) +service::AwaitableResolver Folder::resolveName(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -63,7 +73,7 @@ service::AwaitableResolver Folder::resolveName(service::ResolverParams&& params) return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Folder::resolveUnreadCount(service::ResolverParams&& params) +service::AwaitableResolver Folder::resolveUnreadCount(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -73,14 +83,14 @@ service::AwaitableResolver Folder::resolveUnreadCount(service::ResolverParams&& return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Folder::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver Folder::resolve_typename(service::ResolverParams&& params) const { return service::ModifiedResult::convert(std::string{ R"gql(Folder)gql" }, std::move(params)); } } // namespace object -void AddFolderDetails(std::shared_ptr typeFolder, const std::shared_ptr& schema) +void AddFolderDetails(const std::shared_ptr& typeFolder, const std::shared_ptr& schema) { typeFolder->AddInterfaces({ std::static_pointer_cast(schema->LookupType(R"gql(Node)gql"sv)) diff --git a/samples/today/separate/FolderObject.h b/samples/today/separate/FolderObject.h index 940f1190..38fe33d4 100644 --- a/samples/today/separate/FolderObject.h +++ b/samples/today/separate/FolderObject.h @@ -10,77 +10,86 @@ #include "TodaySchema.h" +#include "NodeObject.h" + namespace graphql::today::object { -namespace methods::FolderMethod { +namespace implements { + +template +concept FolderIs = std::is_same_v; + +} // namespace implements + +namespace methods::FolderHas { template -concept WithParamsId = requires (TImpl impl, service::FieldParams params) +concept getIdWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getId(std::move(params)) } }; }; template -concept NoParamsId = requires (TImpl impl) +concept getId = requires (TImpl impl) { { service::FieldResult { impl.getId() } }; }; template -concept WithParamsName = requires (TImpl impl, service::FieldParams params) +concept getNameWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getName(std::move(params)) } }; }; template -concept NoParamsName = requires (TImpl impl) +concept getName = requires (TImpl impl) { { service::FieldResult> { impl.getName() } }; }; template -concept WithParamsUnreadCount = requires (TImpl impl, service::FieldParams params) +concept getUnreadCountWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getUnreadCount(std::move(params)) } }; }; template -concept NoParamsUnreadCount = requires (TImpl impl) +concept getUnreadCount = requires (TImpl impl) { { service::FieldResult { impl.getUnreadCount() } }; }; template -concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.beginSelectionSet(params) }; }; template -concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.endSelectionSet(params) }; }; -} // namespace methods::FolderMethod +} // namespace methods::FolderHas class Folder : public service::Object { private: - service::AwaitableResolver resolveId(service::ResolverParams&& params); - service::AwaitableResolver resolveName(service::ResolverParams&& params); - service::AwaitableResolver resolveUnreadCount(service::ResolverParams&& params); + service::AwaitableResolver resolveId(service::ResolverParams&& params) const; + service::AwaitableResolver resolveName(service::ResolverParams&& params) const; + service::AwaitableResolver resolveUnreadCount(service::ResolverParams&& params) const; - service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; struct Concept - : Node { virtual ~Concept() = default; virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual service::FieldResult getId(service::FieldParams&& params) const = 0; virtual service::FieldResult> getName(service::FieldParams&& params) const = 0; virtual service::FieldResult getUnreadCount(service::FieldParams&& params) const = 0; }; @@ -96,11 +105,11 @@ class Folder service::FieldResult getId(service::FieldParams&& params) const final { - if constexpr (methods::FolderMethod::WithParamsId) + if constexpr (methods::FolderHas::getIdWithParams) { return { _pimpl->getId(std::move(params)) }; } - else if constexpr (methods::FolderMethod::NoParamsId) + else if constexpr (methods::FolderHas::getId) { return { _pimpl->getId() }; } @@ -112,11 +121,11 @@ class Folder service::FieldResult> getName(service::FieldParams&& params) const final { - if constexpr (methods::FolderMethod::WithParamsName) + if constexpr (methods::FolderHas::getNameWithParams) { return { _pimpl->getName(std::move(params)) }; } - else if constexpr (methods::FolderMethod::NoParamsName) + else if constexpr (methods::FolderHas::getName) { return { _pimpl->getName() }; } @@ -128,11 +137,11 @@ class Folder service::FieldResult getUnreadCount(service::FieldParams&& params) const final { - if constexpr (methods::FolderMethod::WithParamsUnreadCount) + if constexpr (methods::FolderHas::getUnreadCountWithParams) { return { _pimpl->getUnreadCount(std::move(params)) }; } - else if constexpr (methods::FolderMethod::NoParamsUnreadCount) + else if constexpr (methods::FolderHas::getUnreadCount) { return { _pimpl->getUnreadCount() }; } @@ -144,7 +153,7 @@ class Folder void beginSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::FolderMethod::HasBeginSelectionSet) + if constexpr (methods::FolderHas::beginSelectionSet) { _pimpl->beginSelectionSet(params); } @@ -152,7 +161,7 @@ class Folder void endSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::FolderMethod::HasEndSelectionSet) + if constexpr (methods::FolderHas::endSelectionSet) { _pimpl->endSelectionSet(params); } @@ -162,7 +171,19 @@ class Folder const std::shared_ptr _pimpl; }; - Folder(std::unique_ptr&& pimpl); + Folder(std::unique_ptr&& pimpl) noexcept; + + // Interface objects need access to these methods + friend Node; + + template + static constexpr bool implements() noexcept + { + return implements::FolderIs; + } + + service::TypeNames getTypeNames() const noexcept; + service::ResolverMap getResolvers() const noexcept; void beginSelectionSet(const service::SelectionSetParams& params) const final; void endSelectionSet(const service::SelectionSetParams& params) const final; @@ -171,7 +192,7 @@ class Folder public: template - Folder(std::shared_ptr pimpl) + Folder(std::shared_ptr pimpl) noexcept : Folder { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } diff --git a/samples/today/separate/MutationObject.cpp b/samples/today/separate/MutationObject.cpp index 5d80c817..a0ed9b90 100644 --- a/samples/today/separate/MutationObject.cpp +++ b/samples/today/separate/MutationObject.cpp @@ -18,16 +18,26 @@ using namespace std::literals; namespace graphql::today { namespace object { -Mutation::Mutation(std::unique_ptr&& pimpl) - : service::Object({ +Mutation::Mutation(std::unique_ptr&& pimpl) noexcept + : service::Object{ getTypeNames(), getResolvers() } + , _pimpl { std::move(pimpl) } +{ +} + +service::TypeNames Mutation::getTypeNames() const noexcept +{ + return { "Mutation" - }, { + }; +} + +service::ResolverMap Mutation::getResolvers() const noexcept +{ + return { { R"gql(setFloat)gql"sv, [this](service::ResolverParams&& params) { return resolveSetFloat(std::move(params)); } }, { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, { R"gql(completeTask)gql"sv, [this](service::ResolverParams&& params) { return resolveCompleteTask(std::move(params)); } } - }) - , _pimpl(std::move(pimpl)) -{ + }; } void Mutation::beginSelectionSet(const service::SelectionSetParams& params) const @@ -40,7 +50,7 @@ void Mutation::endSelectionSet(const service::SelectionSetParams& params) const _pimpl->endSelectionSet(params); } -service::AwaitableResolver Mutation::resolveCompleteTask(service::ResolverParams&& params) +service::AwaitableResolver Mutation::resolveCompleteTask(service::ResolverParams&& params) const { auto argInput = service::ModifiedArgument::require("input", params.arguments); std::unique_lock resolverLock(_resolverMutex); @@ -51,7 +61,7 @@ service::AwaitableResolver Mutation::resolveCompleteTask(service::ResolverParams return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Mutation::resolveSetFloat(service::ResolverParams&& params) +service::AwaitableResolver Mutation::resolveSetFloat(service::ResolverParams&& params) const { auto argValue = service::ModifiedArgument::require("value", params.arguments); std::unique_lock resolverLock(_resolverMutex); @@ -62,14 +72,14 @@ service::AwaitableResolver Mutation::resolveSetFloat(service::ResolverParams&& p return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Mutation::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver Mutation::resolve_typename(service::ResolverParams&& params) const { return service::ModifiedResult::convert(std::string{ R"gql(Mutation)gql" }, std::move(params)); } } // namespace object -void AddMutationDetails(std::shared_ptr typeMutation, const std::shared_ptr& schema) +void AddMutationDetails(const std::shared_ptr& typeMutation, const std::shared_ptr& schema) { typeMutation->AddFields({ schema::Field::Make(R"gql(completeTask)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("CompleteTaskPayload")), { diff --git a/samples/today/separate/MutationObject.h b/samples/today/separate/MutationObject.h index c78f0ac3..f9ecb4b8 100644 --- a/samples/today/separate/MutationObject.h +++ b/samples/today/separate/MutationObject.h @@ -11,54 +11,54 @@ #include "TodaySchema.h" namespace graphql::today::object { -namespace methods::MutationMethod { +namespace methods::MutationHas { template -concept WithParamsCompleteTask = requires (TImpl impl, service::FieldParams params, CompleteTaskInput inputArg) +concept applyCompleteTaskWithParams = requires (TImpl impl, service::FieldParams params, CompleteTaskInput inputArg) { { service::FieldResult> { impl.applyCompleteTask(std::move(params), std::move(inputArg)) } }; }; template -concept NoParamsCompleteTask = requires (TImpl impl, CompleteTaskInput inputArg) +concept applyCompleteTask = requires (TImpl impl, CompleteTaskInput inputArg) { { service::FieldResult> { impl.applyCompleteTask(std::move(inputArg)) } }; }; template -concept WithParamsSetFloat = requires (TImpl impl, service::FieldParams params, double valueArg) +concept applySetFloatWithParams = requires (TImpl impl, service::FieldParams params, double valueArg) { { service::FieldResult { impl.applySetFloat(std::move(params), std::move(valueArg)) } }; }; template -concept NoParamsSetFloat = requires (TImpl impl, double valueArg) +concept applySetFloat = requires (TImpl impl, double valueArg) { { service::FieldResult { impl.applySetFloat(std::move(valueArg)) } }; }; template -concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.beginSelectionSet(params) }; }; template -concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.endSelectionSet(params) }; }; -} // namespace methods::MutationMethod +} // namespace methods::MutationHas class Mutation : public service::Object { private: - service::AwaitableResolver resolveCompleteTask(service::ResolverParams&& params); - service::AwaitableResolver resolveSetFloat(service::ResolverParams&& params); + service::AwaitableResolver resolveCompleteTask(service::ResolverParams&& params) const; + service::AwaitableResolver resolveSetFloat(service::ResolverParams&& params) const; - service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; struct Concept { @@ -82,11 +82,11 @@ class Mutation service::FieldResult> applyCompleteTask(service::FieldParams&& params, CompleteTaskInput&& inputArg) const final { - if constexpr (methods::MutationMethod::WithParamsCompleteTask) + if constexpr (methods::MutationHas::applyCompleteTaskWithParams) { return { _pimpl->applyCompleteTask(std::move(params), std::move(inputArg)) }; } - else if constexpr (methods::MutationMethod::NoParamsCompleteTask) + else if constexpr (methods::MutationHas::applyCompleteTask) { return { _pimpl->applyCompleteTask(std::move(inputArg)) }; } @@ -98,11 +98,11 @@ class Mutation service::FieldResult applySetFloat(service::FieldParams&& params, double&& valueArg) const final { - if constexpr (methods::MutationMethod::WithParamsSetFloat) + if constexpr (methods::MutationHas::applySetFloatWithParams) { return { _pimpl->applySetFloat(std::move(params), std::move(valueArg)) }; } - else if constexpr (methods::MutationMethod::NoParamsSetFloat) + else if constexpr (methods::MutationHas::applySetFloat) { return { _pimpl->applySetFloat(std::move(valueArg)) }; } @@ -114,7 +114,7 @@ class Mutation void beginSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::MutationMethod::HasBeginSelectionSet) + if constexpr (methods::MutationHas::beginSelectionSet) { _pimpl->beginSelectionSet(params); } @@ -122,7 +122,7 @@ class Mutation void endSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::MutationMethod::HasEndSelectionSet) + if constexpr (methods::MutationHas::endSelectionSet) { _pimpl->endSelectionSet(params); } @@ -132,7 +132,10 @@ class Mutation const std::shared_ptr _pimpl; }; - Mutation(std::unique_ptr&& pimpl); + Mutation(std::unique_ptr&& pimpl) noexcept; + + service::TypeNames getTypeNames() const noexcept; + service::ResolverMap getResolvers() const noexcept; void beginSelectionSet(const service::SelectionSetParams& params) const final; void endSelectionSet(const service::SelectionSetParams& params) const final; @@ -141,7 +144,7 @@ class Mutation public: template - Mutation(std::shared_ptr pimpl) + Mutation(std::shared_ptr pimpl) noexcept : Mutation { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } diff --git a/samples/today/separate/NestedTypeObject.cpp b/samples/today/separate/NestedTypeObject.cpp index 797d562a..c93e820a 100644 --- a/samples/today/separate/NestedTypeObject.cpp +++ b/samples/today/separate/NestedTypeObject.cpp @@ -18,16 +18,26 @@ using namespace std::literals; namespace graphql::today { namespace object { -NestedType::NestedType(std::unique_ptr&& pimpl) - : service::Object({ +NestedType::NestedType(std::unique_ptr&& pimpl) noexcept + : service::Object{ getTypeNames(), getResolvers() } + , _pimpl { std::move(pimpl) } +{ +} + +service::TypeNames NestedType::getTypeNames() const noexcept +{ + return { "NestedType" - }, { + }; +} + +service::ResolverMap NestedType::getResolvers() const noexcept +{ + return { { R"gql(depth)gql"sv, [this](service::ResolverParams&& params) { return resolveDepth(std::move(params)); } }, { R"gql(nested)gql"sv, [this](service::ResolverParams&& params) { return resolveNested(std::move(params)); } }, { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } } - }) - , _pimpl(std::move(pimpl)) -{ + }; } void NestedType::beginSelectionSet(const service::SelectionSetParams& params) const @@ -40,7 +50,7 @@ void NestedType::endSelectionSet(const service::SelectionSetParams& params) cons _pimpl->endSelectionSet(params); } -service::AwaitableResolver NestedType::resolveDepth(service::ResolverParams&& params) +service::AwaitableResolver NestedType::resolveDepth(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -50,7 +60,7 @@ service::AwaitableResolver NestedType::resolveDepth(service::ResolverParams&& pa return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver NestedType::resolveNested(service::ResolverParams&& params) +service::AwaitableResolver NestedType::resolveNested(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -60,14 +70,14 @@ service::AwaitableResolver NestedType::resolveNested(service::ResolverParams&& p return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver NestedType::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver NestedType::resolve_typename(service::ResolverParams&& params) const { return service::ModifiedResult::convert(std::string{ R"gql(NestedType)gql" }, std::move(params)); } } // namespace object -void AddNestedTypeDetails(std::shared_ptr typeNestedType, const std::shared_ptr& schema) +void AddNestedTypeDetails(const std::shared_ptr& typeNestedType, const std::shared_ptr& schema) { typeNestedType->AddFields({ schema::Field::Make(R"gql(depth)gql"sv, R"md(Depth of the nested element)md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("Int"))), diff --git a/samples/today/separate/NestedTypeObject.h b/samples/today/separate/NestedTypeObject.h index 3ef0292a..6215cf06 100644 --- a/samples/today/separate/NestedTypeObject.h +++ b/samples/today/separate/NestedTypeObject.h @@ -11,54 +11,54 @@ #include "TodaySchema.h" namespace graphql::today::object { -namespace methods::NestedTypeMethod { +namespace methods::NestedTypeHas { template -concept WithParamsDepth = requires (TImpl impl, service::FieldParams params) +concept getDepthWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getDepth(std::move(params)) } }; }; template -concept NoParamsDepth = requires (TImpl impl) +concept getDepth = requires (TImpl impl) { { service::FieldResult { impl.getDepth() } }; }; template -concept WithParamsNested = requires (TImpl impl, service::FieldParams params) +concept getNestedWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getNested(std::move(params)) } }; }; template -concept NoParamsNested = requires (TImpl impl) +concept getNested = requires (TImpl impl) { { service::FieldResult> { impl.getNested() } }; }; template -concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.beginSelectionSet(params) }; }; template -concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.endSelectionSet(params) }; }; -} // namespace methods::NestedTypeMethod +} // namespace methods::NestedTypeHas class NestedType : public service::Object { private: - service::AwaitableResolver resolveDepth(service::ResolverParams&& params); - service::AwaitableResolver resolveNested(service::ResolverParams&& params); + service::AwaitableResolver resolveDepth(service::ResolverParams&& params) const; + service::AwaitableResolver resolveNested(service::ResolverParams&& params) const; - service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; struct Concept { @@ -82,11 +82,11 @@ class NestedType service::FieldResult getDepth(service::FieldParams&& params) const final { - if constexpr (methods::NestedTypeMethod::WithParamsDepth) + if constexpr (methods::NestedTypeHas::getDepthWithParams) { return { _pimpl->getDepth(std::move(params)) }; } - else if constexpr (methods::NestedTypeMethod::NoParamsDepth) + else if constexpr (methods::NestedTypeHas::getDepth) { return { _pimpl->getDepth() }; } @@ -98,11 +98,11 @@ class NestedType service::FieldResult> getNested(service::FieldParams&& params) const final { - if constexpr (methods::NestedTypeMethod::WithParamsNested) + if constexpr (methods::NestedTypeHas::getNestedWithParams) { return { _pimpl->getNested(std::move(params)) }; } - else if constexpr (methods::NestedTypeMethod::NoParamsNested) + else if constexpr (methods::NestedTypeHas::getNested) { return { _pimpl->getNested() }; } @@ -114,7 +114,7 @@ class NestedType void beginSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::NestedTypeMethod::HasBeginSelectionSet) + if constexpr (methods::NestedTypeHas::beginSelectionSet) { _pimpl->beginSelectionSet(params); } @@ -122,7 +122,7 @@ class NestedType void endSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::NestedTypeMethod::HasEndSelectionSet) + if constexpr (methods::NestedTypeHas::endSelectionSet) { _pimpl->endSelectionSet(params); } @@ -132,7 +132,10 @@ class NestedType const std::shared_ptr _pimpl; }; - NestedType(std::unique_ptr&& pimpl); + NestedType(std::unique_ptr&& pimpl) noexcept; + + service::TypeNames getTypeNames() const noexcept; + service::ResolverMap getResolvers() const noexcept; void beginSelectionSet(const service::SelectionSetParams& params) const final; void endSelectionSet(const service::SelectionSetParams& params) const final; @@ -141,7 +144,7 @@ class NestedType public: template - NestedType(std::shared_ptr pimpl) + NestedType(std::shared_ptr pimpl) noexcept : NestedType { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } diff --git a/samples/today/separate/NodeObject.cpp b/samples/today/separate/NodeObject.cpp new file mode 100644 index 00000000..7196db2b --- /dev/null +++ b/samples/today/separate/NodeObject.cpp @@ -0,0 +1,46 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// WARNING! Do not edit this file manually, your changes will be overwritten. + +#include "TodayObjects.h" + +#include "graphqlservice/introspection/Introspection.h" + +#include +#include +#include +#include +#include + +using namespace std::literals; + +namespace graphql::today { +namespace object { + +Node::Node(std::unique_ptr&& pimpl) noexcept + : service::Object { pimpl->getTypeNames(), pimpl->getResolvers() } + , _pimpl { std::move(pimpl) } +{ +} + +void Node::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void Node::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} + +} // namespace object + +void AddNodeDetails(const std::shared_ptr& typeNode, const std::shared_ptr& schema) +{ + typeNode->AddFields({ + schema::Field::Make(R"gql(id)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("ID"))) + }); +} + +} // namespace graphql::today diff --git a/samples/today/separate/NodeObject.h b/samples/today/separate/NodeObject.h new file mode 100644 index 00000000..af1a537b --- /dev/null +++ b/samples/today/separate/NodeObject.h @@ -0,0 +1,81 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// WARNING! Do not edit this file manually, your changes will be overwritten. + +#pragma once + +#ifndef NODEOBJECT_H +#define NODEOBJECT_H + +#include "TodaySchema.h" + +namespace graphql::today::object { + +class Node + : public service::Object +{ +private: + struct Concept + { + virtual ~Concept() = default; + + virtual service::TypeNames getTypeNames() const noexcept = 0; + virtual service::ResolverMap getResolvers() const noexcept = 0; + + virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::TypeNames getTypeNames() const noexcept final + { + return _pimpl->getTypeNames(); + } + + service::ResolverMap getResolvers() const noexcept final + { + return _pimpl->getResolvers(); + } + + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + _pimpl->beginSelectionSet(params); + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + _pimpl->endSelectionSet(params); + } + + private: + const std::shared_ptr _pimpl; + }; + + Node(std::unique_ptr&& pimpl) noexcept; + + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; + + const std::unique_ptr _pimpl; + +public: + template + Node(std::shared_ptr pimpl) noexcept + : Node { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } + { + static_assert(T::template implements(), "Node is not implemented"); + } +}; + +} // namespace graphql::today::object + +#endif // NODEOBJECT_H diff --git a/samples/today/separate/PageInfoObject.cpp b/samples/today/separate/PageInfoObject.cpp index e9677c85..87112979 100644 --- a/samples/today/separate/PageInfoObject.cpp +++ b/samples/today/separate/PageInfoObject.cpp @@ -18,16 +18,26 @@ using namespace std::literals; namespace graphql::today { namespace object { -PageInfo::PageInfo(std::unique_ptr&& pimpl) - : service::Object({ +PageInfo::PageInfo(std::unique_ptr&& pimpl) noexcept + : service::Object{ getTypeNames(), getResolvers() } + , _pimpl { std::move(pimpl) } +{ +} + +service::TypeNames PageInfo::getTypeNames() const noexcept +{ + return { "PageInfo" - }, { + }; +} + +service::ResolverMap PageInfo::getResolvers() const noexcept +{ + return { { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, { R"gql(hasNextPage)gql"sv, [this](service::ResolverParams&& params) { return resolveHasNextPage(std::move(params)); } }, { R"gql(hasPreviousPage)gql"sv, [this](service::ResolverParams&& params) { return resolveHasPreviousPage(std::move(params)); } } - }) - , _pimpl(std::move(pimpl)) -{ + }; } void PageInfo::beginSelectionSet(const service::SelectionSetParams& params) const @@ -40,7 +50,7 @@ void PageInfo::endSelectionSet(const service::SelectionSetParams& params) const _pimpl->endSelectionSet(params); } -service::AwaitableResolver PageInfo::resolveHasNextPage(service::ResolverParams&& params) +service::AwaitableResolver PageInfo::resolveHasNextPage(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -50,7 +60,7 @@ service::AwaitableResolver PageInfo::resolveHasNextPage(service::ResolverParams& return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver PageInfo::resolveHasPreviousPage(service::ResolverParams&& params) +service::AwaitableResolver PageInfo::resolveHasPreviousPage(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -60,14 +70,14 @@ service::AwaitableResolver PageInfo::resolveHasPreviousPage(service::ResolverPar return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver PageInfo::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver PageInfo::resolve_typename(service::ResolverParams&& params) const { return service::ModifiedResult::convert(std::string{ R"gql(PageInfo)gql" }, std::move(params)); } } // namespace object -void AddPageInfoDetails(std::shared_ptr typePageInfo, const std::shared_ptr& schema) +void AddPageInfoDetails(const std::shared_ptr& typePageInfo, const std::shared_ptr& schema) { typePageInfo->AddFields({ schema::Field::Make(R"gql(hasNextPage)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("Boolean"))), diff --git a/samples/today/separate/PageInfoObject.h b/samples/today/separate/PageInfoObject.h index ca851ed1..d5c1cf4f 100644 --- a/samples/today/separate/PageInfoObject.h +++ b/samples/today/separate/PageInfoObject.h @@ -11,54 +11,54 @@ #include "TodaySchema.h" namespace graphql::today::object { -namespace methods::PageInfoMethod { +namespace methods::PageInfoHas { template -concept WithParamsHasNextPage = requires (TImpl impl, service::FieldParams params) +concept getHasNextPageWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getHasNextPage(std::move(params)) } }; }; template -concept NoParamsHasNextPage = requires (TImpl impl) +concept getHasNextPage = requires (TImpl impl) { { service::FieldResult { impl.getHasNextPage() } }; }; template -concept WithParamsHasPreviousPage = requires (TImpl impl, service::FieldParams params) +concept getHasPreviousPageWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getHasPreviousPage(std::move(params)) } }; }; template -concept NoParamsHasPreviousPage = requires (TImpl impl) +concept getHasPreviousPage = requires (TImpl impl) { { service::FieldResult { impl.getHasPreviousPage() } }; }; template -concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.beginSelectionSet(params) }; }; template -concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.endSelectionSet(params) }; }; -} // namespace methods::PageInfoMethod +} // namespace methods::PageInfoHas class PageInfo : public service::Object { private: - service::AwaitableResolver resolveHasNextPage(service::ResolverParams&& params); - service::AwaitableResolver resolveHasPreviousPage(service::ResolverParams&& params); + service::AwaitableResolver resolveHasNextPage(service::ResolverParams&& params) const; + service::AwaitableResolver resolveHasPreviousPage(service::ResolverParams&& params) const; - service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; struct Concept { @@ -82,11 +82,11 @@ class PageInfo service::FieldResult getHasNextPage(service::FieldParams&& params) const final { - if constexpr (methods::PageInfoMethod::WithParamsHasNextPage) + if constexpr (methods::PageInfoHas::getHasNextPageWithParams) { return { _pimpl->getHasNextPage(std::move(params)) }; } - else if constexpr (methods::PageInfoMethod::NoParamsHasNextPage) + else if constexpr (methods::PageInfoHas::getHasNextPage) { return { _pimpl->getHasNextPage() }; } @@ -98,11 +98,11 @@ class PageInfo service::FieldResult getHasPreviousPage(service::FieldParams&& params) const final { - if constexpr (methods::PageInfoMethod::WithParamsHasPreviousPage) + if constexpr (methods::PageInfoHas::getHasPreviousPageWithParams) { return { _pimpl->getHasPreviousPage(std::move(params)) }; } - else if constexpr (methods::PageInfoMethod::NoParamsHasPreviousPage) + else if constexpr (methods::PageInfoHas::getHasPreviousPage) { return { _pimpl->getHasPreviousPage() }; } @@ -114,7 +114,7 @@ class PageInfo void beginSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::PageInfoMethod::HasBeginSelectionSet) + if constexpr (methods::PageInfoHas::beginSelectionSet) { _pimpl->beginSelectionSet(params); } @@ -122,7 +122,7 @@ class PageInfo void endSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::PageInfoMethod::HasEndSelectionSet) + if constexpr (methods::PageInfoHas::endSelectionSet) { _pimpl->endSelectionSet(params); } @@ -132,7 +132,10 @@ class PageInfo const std::shared_ptr _pimpl; }; - PageInfo(std::unique_ptr&& pimpl); + PageInfo(std::unique_ptr&& pimpl) noexcept; + + service::TypeNames getTypeNames() const noexcept; + service::ResolverMap getResolvers() const noexcept; void beginSelectionSet(const service::SelectionSetParams& params) const final; void endSelectionSet(const service::SelectionSetParams& params) const final; @@ -141,7 +144,7 @@ class PageInfo public: template - PageInfo(std::shared_ptr pimpl) + PageInfo(std::shared_ptr pimpl) noexcept : PageInfo { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } diff --git a/samples/today/separate/QueryObject.cpp b/samples/today/separate/QueryObject.cpp index 3ce1de65..7890b96f 100644 --- a/samples/today/separate/QueryObject.cpp +++ b/samples/today/separate/QueryObject.cpp @@ -18,10 +18,23 @@ using namespace std::literals; namespace graphql::today { namespace object { -Query::Query(std::unique_ptr&& pimpl) - : service::Object({ +Query::Query(std::unique_ptr&& pimpl) noexcept + : service::Object{ getTypeNames(), getResolvers() } + , _schema { GetSchema() } + , _pimpl { std::move(pimpl) } +{ +} + +service::TypeNames Query::getTypeNames() const noexcept +{ + return { "Query" - }, { + }; +} + +service::ResolverMap Query::getResolvers() const noexcept +{ + return { { R"gql(node)gql"sv, [this](service::ResolverParams&& params) { return resolveNode(std::move(params)); } }, { R"gql(tasks)gql"sv, [this](service::ResolverParams&& params) { return resolveTasks(std::move(params)); } }, { R"gql(__type)gql"sv, [this](service::ResolverParams&& params) { return resolve_type(std::move(params)); } }, @@ -37,10 +50,7 @@ Query::Query(std::unique_ptr&& pimpl) { R"gql(unimplemented)gql"sv, [this](service::ResolverParams&& params) { return resolveUnimplemented(std::move(params)); } }, { R"gql(appointmentsById)gql"sv, [this](service::ResolverParams&& params) { return resolveAppointmentsById(std::move(params)); } }, { R"gql(unreadCountsById)gql"sv, [this](service::ResolverParams&& params) { return resolveUnreadCountsById(std::move(params)); } } - }) - , _schema(GetSchema()) - , _pimpl(std::move(pimpl)) -{ + }; } void Query::beginSelectionSet(const service::SelectionSetParams& params) const @@ -53,7 +63,7 @@ void Query::endSelectionSet(const service::SelectionSetParams& params) const _pimpl->endSelectionSet(params); } -service::AwaitableResolver Query::resolveNode(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveNode(service::ResolverParams&& params) const { auto argId = service::ModifiedArgument::require("id", params.arguments); std::unique_lock resolverLock(_resolverMutex); @@ -61,10 +71,10 @@ service::AwaitableResolver Query::resolveNode(service::ResolverParams&& params) auto result = _pimpl->getNode(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argId)); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Query::resolveAppointments(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveAppointments(service::ResolverParams&& params) const { auto argFirst = service::ModifiedArgument::require("first", params.arguments); auto argAfter = service::ModifiedArgument::require("after", params.arguments); @@ -78,7 +88,7 @@ service::AwaitableResolver Query::resolveAppointments(service::ResolverParams&& return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Query::resolveTasks(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveTasks(service::ResolverParams&& params) const { auto argFirst = service::ModifiedArgument::require("first", params.arguments); auto argAfter = service::ModifiedArgument::require("after", params.arguments); @@ -92,7 +102,7 @@ service::AwaitableResolver Query::resolveTasks(service::ResolverParams&& params) return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Query::resolveUnreadCounts(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveUnreadCounts(service::ResolverParams&& params) const { auto argFirst = service::ModifiedArgument::require("first", params.arguments); auto argAfter = service::ModifiedArgument::require("after", params.arguments); @@ -106,7 +116,7 @@ service::AwaitableResolver Query::resolveUnreadCounts(service::ResolverParams&& return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Query::resolveAppointmentsById(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveAppointmentsById(service::ResolverParams&& params) const { const auto defaultArguments = []() { @@ -139,7 +149,7 @@ service::AwaitableResolver Query::resolveAppointmentsById(service::ResolverParam return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Query::resolveTasksById(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveTasksById(service::ResolverParams&& params) const { auto argIds = service::ModifiedArgument::require("ids", params.arguments); std::unique_lock resolverLock(_resolverMutex); @@ -150,7 +160,7 @@ service::AwaitableResolver Query::resolveTasksById(service::ResolverParams&& par return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Query::resolveUnreadCountsById(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveUnreadCountsById(service::ResolverParams&& params) const { auto argIds = service::ModifiedArgument::require("ids", params.arguments); std::unique_lock resolverLock(_resolverMutex); @@ -161,7 +171,7 @@ service::AwaitableResolver Query::resolveUnreadCountsById(service::ResolverParam return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Query::resolveNested(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveNested(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -171,7 +181,7 @@ service::AwaitableResolver Query::resolveNested(service::ResolverParams&& params return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Query::resolveUnimplemented(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveUnimplemented(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -181,7 +191,7 @@ service::AwaitableResolver Query::resolveUnimplemented(service::ResolverParams&& return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Query::resolveExpensive(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveExpensive(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -191,7 +201,7 @@ service::AwaitableResolver Query::resolveExpensive(service::ResolverParams&& par return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Query::resolveTestTaskState(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveTestTaskState(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -201,7 +211,7 @@ service::AwaitableResolver Query::resolveTestTaskState(service::ResolverParams&& return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Query::resolveAnyType(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveAnyType(service::ResolverParams&& params) const { auto argIds = service::ModifiedArgument::require("ids", params.arguments); std::unique_lock resolverLock(_resolverMutex); @@ -212,17 +222,17 @@ service::AwaitableResolver Query::resolveAnyType(service::ResolverParams&& param return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Query::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver Query::resolve_typename(service::ResolverParams&& params) const { return service::ModifiedResult::convert(std::string{ R"gql(Query)gql" }, std::move(params)); } -service::AwaitableResolver Query::resolve_schema(service::ResolverParams&& params) +service::AwaitableResolver Query::resolve_schema(service::ResolverParams&& params) const { return service::ModifiedResult::convert(std::static_pointer_cast(std::make_shared(std::make_shared(_schema))), std::move(params)); } -service::AwaitableResolver Query::resolve_type(service::ResolverParams&& params) +service::AwaitableResolver Query::resolve_type(service::ResolverParams&& params) const { auto argName = service::ModifiedArgument::require("name", params.arguments); const auto& baseType = _schema->LookupType(argName); @@ -233,7 +243,7 @@ service::AwaitableResolver Query::resolve_type(service::ResolverParams&& params) } // namespace object -void AddQueryDetails(std::shared_ptr typeQuery, const std::shared_ptr& schema) +void AddQueryDetails(const std::shared_ptr& typeQuery, const std::shared_ptr& schema) { typeQuery->AddFields({ schema::Field::Make(R"gql(node)gql"sv, R"md([Object Identification](https://facebook.github.io/relay/docs/en/graphql-server-specification.html#object-identification))md"sv, std::nullopt, schema->LookupType("Node"), { diff --git a/samples/today/separate/QueryObject.h b/samples/today/separate/QueryObject.h index 878ad986..043d869c 100644 --- a/samples/today/separate/QueryObject.h +++ b/samples/today/separate/QueryObject.h @@ -11,186 +11,186 @@ #include "TodaySchema.h" namespace graphql::today::object { -namespace methods::QueryMethod { +namespace methods::QueryHas { template -concept WithParamsNode = requires (TImpl impl, service::FieldParams params, response::IdType idArg) +concept getNodeWithParams = requires (TImpl impl, service::FieldParams params, response::IdType idArg) { - { service::FieldResult> { impl.getNode(std::move(params), std::move(idArg)) } }; + { service::FieldResult> { impl.getNode(std::move(params), std::move(idArg)) } }; }; template -concept NoParamsNode = requires (TImpl impl, response::IdType idArg) +concept getNode = requires (TImpl impl, response::IdType idArg) { - { service::FieldResult> { impl.getNode(std::move(idArg)) } }; + { service::FieldResult> { impl.getNode(std::move(idArg)) } }; }; template -concept WithParamsAppointments = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) +concept getAppointmentsWithParams = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) { { service::FieldResult> { impl.getAppointments(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; }; template -concept NoParamsAppointments = requires (TImpl impl, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) +concept getAppointments = requires (TImpl impl, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) { { service::FieldResult> { impl.getAppointments(std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; }; template -concept WithParamsTasks = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) +concept getTasksWithParams = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) { { service::FieldResult> { impl.getTasks(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; }; template -concept NoParamsTasks = requires (TImpl impl, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) +concept getTasks = requires (TImpl impl, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) { { service::FieldResult> { impl.getTasks(std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; }; template -concept WithParamsUnreadCounts = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) +concept getUnreadCountsWithParams = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) { { service::FieldResult> { impl.getUnreadCounts(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; }; template -concept NoParamsUnreadCounts = requires (TImpl impl, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) +concept getUnreadCounts = requires (TImpl impl, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) { { service::FieldResult> { impl.getUnreadCounts(std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; }; template -concept WithParamsAppointmentsById = requires (TImpl impl, service::FieldParams params, std::vector idsArg) +concept getAppointmentsByIdWithParams = requires (TImpl impl, service::FieldParams params, std::vector idsArg) { { service::FieldResult>> { impl.getAppointmentsById(std::move(params), std::move(idsArg)) } }; }; template -concept NoParamsAppointmentsById = requires (TImpl impl, std::vector idsArg) +concept getAppointmentsById = requires (TImpl impl, std::vector idsArg) { { service::FieldResult>> { impl.getAppointmentsById(std::move(idsArg)) } }; }; template -concept WithParamsTasksById = requires (TImpl impl, service::FieldParams params, std::vector idsArg) +concept getTasksByIdWithParams = requires (TImpl impl, service::FieldParams params, std::vector idsArg) { { service::FieldResult>> { impl.getTasksById(std::move(params), std::move(idsArg)) } }; }; template -concept NoParamsTasksById = requires (TImpl impl, std::vector idsArg) +concept getTasksById = requires (TImpl impl, std::vector idsArg) { { service::FieldResult>> { impl.getTasksById(std::move(idsArg)) } }; }; template -concept WithParamsUnreadCountsById = requires (TImpl impl, service::FieldParams params, std::vector idsArg) +concept getUnreadCountsByIdWithParams = requires (TImpl impl, service::FieldParams params, std::vector idsArg) { { service::FieldResult>> { impl.getUnreadCountsById(std::move(params), std::move(idsArg)) } }; }; template -concept NoParamsUnreadCountsById = requires (TImpl impl, std::vector idsArg) +concept getUnreadCountsById = requires (TImpl impl, std::vector idsArg) { { service::FieldResult>> { impl.getUnreadCountsById(std::move(idsArg)) } }; }; template -concept WithParamsNested = requires (TImpl impl, service::FieldParams params) +concept getNestedWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getNested(std::move(params)) } }; }; template -concept NoParamsNested = requires (TImpl impl) +concept getNested = requires (TImpl impl) { { service::FieldResult> { impl.getNested() } }; }; template -concept WithParamsUnimplemented = requires (TImpl impl, service::FieldParams params) +concept getUnimplementedWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getUnimplemented(std::move(params)) } }; }; template -concept NoParamsUnimplemented = requires (TImpl impl) +concept getUnimplemented = requires (TImpl impl) { { service::FieldResult { impl.getUnimplemented() } }; }; template -concept WithParamsExpensive = requires (TImpl impl, service::FieldParams params) +concept getExpensiveWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult>> { impl.getExpensive(std::move(params)) } }; }; template -concept NoParamsExpensive = requires (TImpl impl) +concept getExpensive = requires (TImpl impl) { { service::FieldResult>> { impl.getExpensive() } }; }; template -concept WithParamsTestTaskState = requires (TImpl impl, service::FieldParams params) +concept getTestTaskStateWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getTestTaskState(std::move(params)) } }; }; template -concept NoParamsTestTaskState = requires (TImpl impl) +concept getTestTaskState = requires (TImpl impl) { { service::FieldResult { impl.getTestTaskState() } }; }; template -concept WithParamsAnyType = requires (TImpl impl, service::FieldParams params, std::vector idsArg) +concept getAnyTypeWithParams = requires (TImpl impl, service::FieldParams params, std::vector idsArg) { { service::FieldResult>> { impl.getAnyType(std::move(params), std::move(idsArg)) } }; }; template -concept NoParamsAnyType = requires (TImpl impl, std::vector idsArg) +concept getAnyType = requires (TImpl impl, std::vector idsArg) { { service::FieldResult>> { impl.getAnyType(std::move(idsArg)) } }; }; template -concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.beginSelectionSet(params) }; }; template -concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.endSelectionSet(params) }; }; -} // namespace methods::QueryMethod +} // namespace methods::QueryHas class Query : public service::Object { private: - service::AwaitableResolver resolveNode(service::ResolverParams&& params); - service::AwaitableResolver resolveAppointments(service::ResolverParams&& params); - service::AwaitableResolver resolveTasks(service::ResolverParams&& params); - service::AwaitableResolver resolveUnreadCounts(service::ResolverParams&& params); - service::AwaitableResolver resolveAppointmentsById(service::ResolverParams&& params); - service::AwaitableResolver resolveTasksById(service::ResolverParams&& params); - service::AwaitableResolver resolveUnreadCountsById(service::ResolverParams&& params); - service::AwaitableResolver resolveNested(service::ResolverParams&& params); - service::AwaitableResolver resolveUnimplemented(service::ResolverParams&& params); - service::AwaitableResolver resolveExpensive(service::ResolverParams&& params); - service::AwaitableResolver resolveTestTaskState(service::ResolverParams&& params); - service::AwaitableResolver resolveAnyType(service::ResolverParams&& params); - - service::AwaitableResolver resolve_typename(service::ResolverParams&& params); - service::AwaitableResolver resolve_schema(service::ResolverParams&& params); - service::AwaitableResolver resolve_type(service::ResolverParams&& params); + service::AwaitableResolver resolveNode(service::ResolverParams&& params) const; + service::AwaitableResolver resolveAppointments(service::ResolverParams&& params) const; + service::AwaitableResolver resolveTasks(service::ResolverParams&& params) const; + service::AwaitableResolver resolveUnreadCounts(service::ResolverParams&& params) const; + service::AwaitableResolver resolveAppointmentsById(service::ResolverParams&& params) const; + service::AwaitableResolver resolveTasksById(service::ResolverParams&& params) const; + service::AwaitableResolver resolveUnreadCountsById(service::ResolverParams&& params) const; + service::AwaitableResolver resolveNested(service::ResolverParams&& params) const; + service::AwaitableResolver resolveUnimplemented(service::ResolverParams&& params) const; + service::AwaitableResolver resolveExpensive(service::ResolverParams&& params) const; + service::AwaitableResolver resolveTestTaskState(service::ResolverParams&& params) const; + service::AwaitableResolver resolveAnyType(service::ResolverParams&& params) const; + + service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; + service::AwaitableResolver resolve_schema(service::ResolverParams&& params) const; + service::AwaitableResolver resolve_type(service::ResolverParams&& params) const; std::shared_ptr _schema; @@ -201,7 +201,7 @@ class Query virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual service::FieldResult> getNode(service::FieldParams&& params, response::IdType&& idArg) const = 0; + virtual service::FieldResult> getNode(service::FieldParams&& params, response::IdType&& idArg) const = 0; virtual service::FieldResult> getAppointments(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const = 0; virtual service::FieldResult> getTasks(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const = 0; virtual service::FieldResult> getUnreadCounts(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const = 0; @@ -224,13 +224,13 @@ class Query { } - service::FieldResult> getNode(service::FieldParams&& params, response::IdType&& idArg) const final + service::FieldResult> getNode(service::FieldParams&& params, response::IdType&& idArg) const final { - if constexpr (methods::QueryMethod::WithParamsNode) + if constexpr (methods::QueryHas::getNodeWithParams) { return { _pimpl->getNode(std::move(params), std::move(idArg)) }; } - else if constexpr (methods::QueryMethod::NoParamsNode) + else if constexpr (methods::QueryHas::getNode) { return { _pimpl->getNode(std::move(idArg)) }; } @@ -242,11 +242,11 @@ class Query service::FieldResult> getAppointments(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const final { - if constexpr (methods::QueryMethod::WithParamsAppointments) + if constexpr (methods::QueryHas::getAppointmentsWithParams) { return { _pimpl->getAppointments(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) }; } - else if constexpr (methods::QueryMethod::NoParamsAppointments) + else if constexpr (methods::QueryHas::getAppointments) { return { _pimpl->getAppointments(std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) }; } @@ -258,11 +258,11 @@ class Query service::FieldResult> getTasks(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const final { - if constexpr (methods::QueryMethod::WithParamsTasks) + if constexpr (methods::QueryHas::getTasksWithParams) { return { _pimpl->getTasks(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) }; } - else if constexpr (methods::QueryMethod::NoParamsTasks) + else if constexpr (methods::QueryHas::getTasks) { return { _pimpl->getTasks(std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) }; } @@ -274,11 +274,11 @@ class Query service::FieldResult> getUnreadCounts(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const final { - if constexpr (methods::QueryMethod::WithParamsUnreadCounts) + if constexpr (methods::QueryHas::getUnreadCountsWithParams) { return { _pimpl->getUnreadCounts(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) }; } - else if constexpr (methods::QueryMethod::NoParamsUnreadCounts) + else if constexpr (methods::QueryHas::getUnreadCounts) { return { _pimpl->getUnreadCounts(std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) }; } @@ -290,11 +290,11 @@ class Query service::FieldResult>> getAppointmentsById(service::FieldParams&& params, std::vector&& idsArg) const final { - if constexpr (methods::QueryMethod::WithParamsAppointmentsById) + if constexpr (methods::QueryHas::getAppointmentsByIdWithParams) { return { _pimpl->getAppointmentsById(std::move(params), std::move(idsArg)) }; } - else if constexpr (methods::QueryMethod::NoParamsAppointmentsById) + else if constexpr (methods::QueryHas::getAppointmentsById) { return { _pimpl->getAppointmentsById(std::move(idsArg)) }; } @@ -306,11 +306,11 @@ class Query service::FieldResult>> getTasksById(service::FieldParams&& params, std::vector&& idsArg) const final { - if constexpr (methods::QueryMethod::WithParamsTasksById) + if constexpr (methods::QueryHas::getTasksByIdWithParams) { return { _pimpl->getTasksById(std::move(params), std::move(idsArg)) }; } - else if constexpr (methods::QueryMethod::NoParamsTasksById) + else if constexpr (methods::QueryHas::getTasksById) { return { _pimpl->getTasksById(std::move(idsArg)) }; } @@ -322,11 +322,11 @@ class Query service::FieldResult>> getUnreadCountsById(service::FieldParams&& params, std::vector&& idsArg) const final { - if constexpr (methods::QueryMethod::WithParamsUnreadCountsById) + if constexpr (methods::QueryHas::getUnreadCountsByIdWithParams) { return { _pimpl->getUnreadCountsById(std::move(params), std::move(idsArg)) }; } - else if constexpr (methods::QueryMethod::NoParamsUnreadCountsById) + else if constexpr (methods::QueryHas::getUnreadCountsById) { return { _pimpl->getUnreadCountsById(std::move(idsArg)) }; } @@ -338,11 +338,11 @@ class Query service::FieldResult> getNested(service::FieldParams&& params) const final { - if constexpr (methods::QueryMethod::WithParamsNested) + if constexpr (methods::QueryHas::getNestedWithParams) { return { _pimpl->getNested(std::move(params)) }; } - else if constexpr (methods::QueryMethod::NoParamsNested) + else if constexpr (methods::QueryHas::getNested) { return { _pimpl->getNested() }; } @@ -354,11 +354,11 @@ class Query service::FieldResult getUnimplemented(service::FieldParams&& params) const final { - if constexpr (methods::QueryMethod::WithParamsUnimplemented) + if constexpr (methods::QueryHas::getUnimplementedWithParams) { return { _pimpl->getUnimplemented(std::move(params)) }; } - else if constexpr (methods::QueryMethod::NoParamsUnimplemented) + else if constexpr (methods::QueryHas::getUnimplemented) { return { _pimpl->getUnimplemented() }; } @@ -370,11 +370,11 @@ class Query service::FieldResult>> getExpensive(service::FieldParams&& params) const final { - if constexpr (methods::QueryMethod::WithParamsExpensive) + if constexpr (methods::QueryHas::getExpensiveWithParams) { return { _pimpl->getExpensive(std::move(params)) }; } - else if constexpr (methods::QueryMethod::NoParamsExpensive) + else if constexpr (methods::QueryHas::getExpensive) { return { _pimpl->getExpensive() }; } @@ -386,11 +386,11 @@ class Query service::FieldResult getTestTaskState(service::FieldParams&& params) const final { - if constexpr (methods::QueryMethod::WithParamsTestTaskState) + if constexpr (methods::QueryHas::getTestTaskStateWithParams) { return { _pimpl->getTestTaskState(std::move(params)) }; } - else if constexpr (methods::QueryMethod::NoParamsTestTaskState) + else if constexpr (methods::QueryHas::getTestTaskState) { return { _pimpl->getTestTaskState() }; } @@ -402,11 +402,11 @@ class Query service::FieldResult>> getAnyType(service::FieldParams&& params, std::vector&& idsArg) const final { - if constexpr (methods::QueryMethod::WithParamsAnyType) + if constexpr (methods::QueryHas::getAnyTypeWithParams) { return { _pimpl->getAnyType(std::move(params), std::move(idsArg)) }; } - else if constexpr (methods::QueryMethod::NoParamsAnyType) + else if constexpr (methods::QueryHas::getAnyType) { return { _pimpl->getAnyType(std::move(idsArg)) }; } @@ -418,7 +418,7 @@ class Query void beginSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::QueryMethod::HasBeginSelectionSet) + if constexpr (methods::QueryHas::beginSelectionSet) { _pimpl->beginSelectionSet(params); } @@ -426,7 +426,7 @@ class Query void endSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::QueryMethod::HasEndSelectionSet) + if constexpr (methods::QueryHas::endSelectionSet) { _pimpl->endSelectionSet(params); } @@ -436,7 +436,10 @@ class Query const std::shared_ptr _pimpl; }; - Query(std::unique_ptr&& pimpl); + Query(std::unique_ptr&& pimpl) noexcept; + + service::TypeNames getTypeNames() const noexcept; + service::ResolverMap getResolvers() const noexcept; void beginSelectionSet(const service::SelectionSetParams& params) const final; void endSelectionSet(const service::SelectionSetParams& params) const final; @@ -445,7 +448,7 @@ class Query public: template - Query(std::shared_ptr pimpl) + Query(std::shared_ptr pimpl) noexcept : Query { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } diff --git a/samples/today/separate/SubscriptionObject.cpp b/samples/today/separate/SubscriptionObject.cpp index d5e4d4cd..8c7b5321 100644 --- a/samples/today/separate/SubscriptionObject.cpp +++ b/samples/today/separate/SubscriptionObject.cpp @@ -18,16 +18,26 @@ using namespace std::literals; namespace graphql::today { namespace object { -Subscription::Subscription(std::unique_ptr&& pimpl) - : service::Object({ +Subscription::Subscription(std::unique_ptr&& pimpl) noexcept + : service::Object{ getTypeNames(), getResolvers() } + , _pimpl { std::move(pimpl) } +{ +} + +service::TypeNames Subscription::getTypeNames() const noexcept +{ + return { "Subscription" - }, { + }; +} + +service::ResolverMap Subscription::getResolvers() const noexcept +{ + return { { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, { R"gql(nodeChange)gql"sv, [this](service::ResolverParams&& params) { return resolveNodeChange(std::move(params)); } }, { R"gql(nextAppointmentChange)gql"sv, [this](service::ResolverParams&& params) { return resolveNextAppointmentChange(std::move(params)); } } - }) - , _pimpl(std::move(pimpl)) -{ + }; } void Subscription::beginSelectionSet(const service::SelectionSetParams& params) const @@ -40,7 +50,7 @@ void Subscription::endSelectionSet(const service::SelectionSetParams& params) co _pimpl->endSelectionSet(params); } -service::AwaitableResolver Subscription::resolveNextAppointmentChange(service::ResolverParams&& params) +service::AwaitableResolver Subscription::resolveNextAppointmentChange(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -50,7 +60,7 @@ service::AwaitableResolver Subscription::resolveNextAppointmentChange(service::R return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Subscription::resolveNodeChange(service::ResolverParams&& params) +service::AwaitableResolver Subscription::resolveNodeChange(service::ResolverParams&& params) const { auto argId = service::ModifiedArgument::require("id", params.arguments); std::unique_lock resolverLock(_resolverMutex); @@ -58,17 +68,17 @@ service::AwaitableResolver Subscription::resolveNodeChange(service::ResolverPara auto result = _pimpl->getNodeChange(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argId)); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Subscription::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver Subscription::resolve_typename(service::ResolverParams&& params) const { return service::ModifiedResult::convert(std::string{ R"gql(Subscription)gql" }, std::move(params)); } } // namespace object -void AddSubscriptionDetails(std::shared_ptr typeSubscription, const std::shared_ptr& schema) +void AddSubscriptionDetails(const std::shared_ptr& typeSubscription, const std::shared_ptr& schema) { typeSubscription->AddFields({ schema::Field::Make(R"gql(nextAppointmentChange)gql"sv, R"md()md"sv, std::make_optional(R"md(Need to deprecate a [field](http://spec.graphql.org/June2018/#sec-Deprecation))md"sv), schema->LookupType("Appointment")), diff --git a/samples/today/separate/SubscriptionObject.h b/samples/today/separate/SubscriptionObject.h index 21db5c1b..86e5e8c8 100644 --- a/samples/today/separate/SubscriptionObject.h +++ b/samples/today/separate/SubscriptionObject.h @@ -11,54 +11,54 @@ #include "TodaySchema.h" namespace graphql::today::object { -namespace methods::SubscriptionMethod { +namespace methods::SubscriptionHas { template -concept WithParamsNextAppointmentChange = requires (TImpl impl, service::FieldParams params) +concept getNextAppointmentChangeWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getNextAppointmentChange(std::move(params)) } }; }; template -concept NoParamsNextAppointmentChange = requires (TImpl impl) +concept getNextAppointmentChange = requires (TImpl impl) { { service::FieldResult> { impl.getNextAppointmentChange() } }; }; template -concept WithParamsNodeChange = requires (TImpl impl, service::FieldParams params, response::IdType idArg) +concept getNodeChangeWithParams = requires (TImpl impl, service::FieldParams params, response::IdType idArg) { - { service::FieldResult> { impl.getNodeChange(std::move(params), std::move(idArg)) } }; + { service::FieldResult> { impl.getNodeChange(std::move(params), std::move(idArg)) } }; }; template -concept NoParamsNodeChange = requires (TImpl impl, response::IdType idArg) +concept getNodeChange = requires (TImpl impl, response::IdType idArg) { - { service::FieldResult> { impl.getNodeChange(std::move(idArg)) } }; + { service::FieldResult> { impl.getNodeChange(std::move(idArg)) } }; }; template -concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.beginSelectionSet(params) }; }; template -concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.endSelectionSet(params) }; }; -} // namespace methods::SubscriptionMethod +} // namespace methods::SubscriptionHas class Subscription : public service::Object { private: - service::AwaitableResolver resolveNextAppointmentChange(service::ResolverParams&& params); - service::AwaitableResolver resolveNodeChange(service::ResolverParams&& params); + service::AwaitableResolver resolveNextAppointmentChange(service::ResolverParams&& params) const; + service::AwaitableResolver resolveNodeChange(service::ResolverParams&& params) const; - service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; struct Concept { @@ -68,7 +68,7 @@ class Subscription virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; virtual service::FieldResult> getNextAppointmentChange(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getNodeChange(service::FieldParams&& params, response::IdType&& idArg) const = 0; + virtual service::FieldResult> getNodeChange(service::FieldParams&& params, response::IdType&& idArg) const = 0; }; template @@ -82,11 +82,11 @@ class Subscription service::FieldResult> getNextAppointmentChange(service::FieldParams&& params) const final { - if constexpr (methods::SubscriptionMethod::WithParamsNextAppointmentChange) + if constexpr (methods::SubscriptionHas::getNextAppointmentChangeWithParams) { return { _pimpl->getNextAppointmentChange(std::move(params)) }; } - else if constexpr (methods::SubscriptionMethod::NoParamsNextAppointmentChange) + else if constexpr (methods::SubscriptionHas::getNextAppointmentChange) { return { _pimpl->getNextAppointmentChange() }; } @@ -96,13 +96,13 @@ class Subscription } } - service::FieldResult> getNodeChange(service::FieldParams&& params, response::IdType&& idArg) const final + service::FieldResult> getNodeChange(service::FieldParams&& params, response::IdType&& idArg) const final { - if constexpr (methods::SubscriptionMethod::WithParamsNodeChange) + if constexpr (methods::SubscriptionHas::getNodeChangeWithParams) { return { _pimpl->getNodeChange(std::move(params), std::move(idArg)) }; } - else if constexpr (methods::SubscriptionMethod::NoParamsNodeChange) + else if constexpr (methods::SubscriptionHas::getNodeChange) { return { _pimpl->getNodeChange(std::move(idArg)) }; } @@ -114,7 +114,7 @@ class Subscription void beginSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::SubscriptionMethod::HasBeginSelectionSet) + if constexpr (methods::SubscriptionHas::beginSelectionSet) { _pimpl->beginSelectionSet(params); } @@ -122,7 +122,7 @@ class Subscription void endSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::SubscriptionMethod::HasEndSelectionSet) + if constexpr (methods::SubscriptionHas::endSelectionSet) { _pimpl->endSelectionSet(params); } @@ -132,7 +132,10 @@ class Subscription const std::shared_ptr _pimpl; }; - Subscription(std::unique_ptr&& pimpl); + Subscription(std::unique_ptr&& pimpl) noexcept; + + service::TypeNames getTypeNames() const noexcept; + service::ResolverMap getResolvers() const noexcept; void beginSelectionSet(const service::SelectionSetParams& params) const final; void endSelectionSet(const service::SelectionSetParams& params) const final; @@ -141,7 +144,7 @@ class Subscription public: template - Subscription(std::shared_ptr pimpl) + Subscription(std::shared_ptr pimpl) noexcept : Subscription { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } diff --git a/samples/today/separate/TaskConnectionObject.cpp b/samples/today/separate/TaskConnectionObject.cpp index ac3fc259..b1e9da1f 100644 --- a/samples/today/separate/TaskConnectionObject.cpp +++ b/samples/today/separate/TaskConnectionObject.cpp @@ -18,16 +18,26 @@ using namespace std::literals; namespace graphql::today { namespace object { -TaskConnection::TaskConnection(std::unique_ptr&& pimpl) - : service::Object({ +TaskConnection::TaskConnection(std::unique_ptr&& pimpl) noexcept + : service::Object{ getTypeNames(), getResolvers() } + , _pimpl { std::move(pimpl) } +{ +} + +service::TypeNames TaskConnection::getTypeNames() const noexcept +{ + return { "TaskConnection" - }, { + }; +} + +service::ResolverMap TaskConnection::getResolvers() const noexcept +{ + return { { R"gql(edges)gql"sv, [this](service::ResolverParams&& params) { return resolveEdges(std::move(params)); } }, { R"gql(pageInfo)gql"sv, [this](service::ResolverParams&& params) { return resolvePageInfo(std::move(params)); } }, { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } } - }) - , _pimpl(std::move(pimpl)) -{ + }; } void TaskConnection::beginSelectionSet(const service::SelectionSetParams& params) const @@ -40,7 +50,7 @@ void TaskConnection::endSelectionSet(const service::SelectionSetParams& params) _pimpl->endSelectionSet(params); } -service::AwaitableResolver TaskConnection::resolvePageInfo(service::ResolverParams&& params) +service::AwaitableResolver TaskConnection::resolvePageInfo(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -50,7 +60,7 @@ service::AwaitableResolver TaskConnection::resolvePageInfo(service::ResolverPara return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver TaskConnection::resolveEdges(service::ResolverParams&& params) +service::AwaitableResolver TaskConnection::resolveEdges(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -60,14 +70,14 @@ service::AwaitableResolver TaskConnection::resolveEdges(service::ResolverParams& return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver TaskConnection::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver TaskConnection::resolve_typename(service::ResolverParams&& params) const { return service::ModifiedResult::convert(std::string{ R"gql(TaskConnection)gql" }, std::move(params)); } } // namespace object -void AddTaskConnectionDetails(std::shared_ptr typeTaskConnection, const std::shared_ptr& schema) +void AddTaskConnectionDetails(const std::shared_ptr& typeTaskConnection, const std::shared_ptr& schema) { typeTaskConnection->AddFields({ schema::Field::Make(R"gql(pageInfo)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("PageInfo"))), diff --git a/samples/today/separate/TaskConnectionObject.h b/samples/today/separate/TaskConnectionObject.h index 362183f2..a7015334 100644 --- a/samples/today/separate/TaskConnectionObject.h +++ b/samples/today/separate/TaskConnectionObject.h @@ -11,54 +11,54 @@ #include "TodaySchema.h" namespace graphql::today::object { -namespace methods::TaskConnectionMethod { +namespace methods::TaskConnectionHas { template -concept WithParamsPageInfo = requires (TImpl impl, service::FieldParams params) +concept getPageInfoWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getPageInfo(std::move(params)) } }; }; template -concept NoParamsPageInfo = requires (TImpl impl) +concept getPageInfo = requires (TImpl impl) { { service::FieldResult> { impl.getPageInfo() } }; }; template -concept WithParamsEdges = requires (TImpl impl, service::FieldParams params) +concept getEdgesWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult>>> { impl.getEdges(std::move(params)) } }; }; template -concept NoParamsEdges = requires (TImpl impl) +concept getEdges = requires (TImpl impl) { { service::FieldResult>>> { impl.getEdges() } }; }; template -concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.beginSelectionSet(params) }; }; template -concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.endSelectionSet(params) }; }; -} // namespace methods::TaskConnectionMethod +} // namespace methods::TaskConnectionHas class TaskConnection : public service::Object { private: - service::AwaitableResolver resolvePageInfo(service::ResolverParams&& params); - service::AwaitableResolver resolveEdges(service::ResolverParams&& params); + service::AwaitableResolver resolvePageInfo(service::ResolverParams&& params) const; + service::AwaitableResolver resolveEdges(service::ResolverParams&& params) const; - service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; struct Concept { @@ -82,11 +82,11 @@ class TaskConnection service::FieldResult> getPageInfo(service::FieldParams&& params) const final { - if constexpr (methods::TaskConnectionMethod::WithParamsPageInfo) + if constexpr (methods::TaskConnectionHas::getPageInfoWithParams) { return { _pimpl->getPageInfo(std::move(params)) }; } - else if constexpr (methods::TaskConnectionMethod::NoParamsPageInfo) + else if constexpr (methods::TaskConnectionHas::getPageInfo) { return { _pimpl->getPageInfo() }; } @@ -98,11 +98,11 @@ class TaskConnection service::FieldResult>>> getEdges(service::FieldParams&& params) const final { - if constexpr (methods::TaskConnectionMethod::WithParamsEdges) + if constexpr (methods::TaskConnectionHas::getEdgesWithParams) { return { _pimpl->getEdges(std::move(params)) }; } - else if constexpr (methods::TaskConnectionMethod::NoParamsEdges) + else if constexpr (methods::TaskConnectionHas::getEdges) { return { _pimpl->getEdges() }; } @@ -114,7 +114,7 @@ class TaskConnection void beginSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::TaskConnectionMethod::HasBeginSelectionSet) + if constexpr (methods::TaskConnectionHas::beginSelectionSet) { _pimpl->beginSelectionSet(params); } @@ -122,7 +122,7 @@ class TaskConnection void endSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::TaskConnectionMethod::HasEndSelectionSet) + if constexpr (methods::TaskConnectionHas::endSelectionSet) { _pimpl->endSelectionSet(params); } @@ -132,7 +132,10 @@ class TaskConnection const std::shared_ptr _pimpl; }; - TaskConnection(std::unique_ptr&& pimpl); + TaskConnection(std::unique_ptr&& pimpl) noexcept; + + service::TypeNames getTypeNames() const noexcept; + service::ResolverMap getResolvers() const noexcept; void beginSelectionSet(const service::SelectionSetParams& params) const final; void endSelectionSet(const service::SelectionSetParams& params) const final; @@ -141,7 +144,7 @@ class TaskConnection public: template - TaskConnection(std::shared_ptr pimpl) + TaskConnection(std::shared_ptr pimpl) noexcept : TaskConnection { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } diff --git a/samples/today/separate/TaskEdgeObject.cpp b/samples/today/separate/TaskEdgeObject.cpp index 6a96ec40..ff7758d4 100644 --- a/samples/today/separate/TaskEdgeObject.cpp +++ b/samples/today/separate/TaskEdgeObject.cpp @@ -18,16 +18,26 @@ using namespace std::literals; namespace graphql::today { namespace object { -TaskEdge::TaskEdge(std::unique_ptr&& pimpl) - : service::Object({ +TaskEdge::TaskEdge(std::unique_ptr&& pimpl) noexcept + : service::Object{ getTypeNames(), getResolvers() } + , _pimpl { std::move(pimpl) } +{ +} + +service::TypeNames TaskEdge::getTypeNames() const noexcept +{ + return { "TaskEdge" - }, { + }; +} + +service::ResolverMap TaskEdge::getResolvers() const noexcept +{ + return { { R"gql(node)gql"sv, [this](service::ResolverParams&& params) { return resolveNode(std::move(params)); } }, { R"gql(cursor)gql"sv, [this](service::ResolverParams&& params) { return resolveCursor(std::move(params)); } }, { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } } - }) - , _pimpl(std::move(pimpl)) -{ + }; } void TaskEdge::beginSelectionSet(const service::SelectionSetParams& params) const @@ -40,7 +50,7 @@ void TaskEdge::endSelectionSet(const service::SelectionSetParams& params) const _pimpl->endSelectionSet(params); } -service::AwaitableResolver TaskEdge::resolveNode(service::ResolverParams&& params) +service::AwaitableResolver TaskEdge::resolveNode(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -50,7 +60,7 @@ service::AwaitableResolver TaskEdge::resolveNode(service::ResolverParams&& param return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver TaskEdge::resolveCursor(service::ResolverParams&& params) +service::AwaitableResolver TaskEdge::resolveCursor(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -60,14 +70,14 @@ service::AwaitableResolver TaskEdge::resolveCursor(service::ResolverParams&& par return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver TaskEdge::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver TaskEdge::resolve_typename(service::ResolverParams&& params) const { return service::ModifiedResult::convert(std::string{ R"gql(TaskEdge)gql" }, std::move(params)); } } // namespace object -void AddTaskEdgeDetails(std::shared_ptr typeTaskEdge, const std::shared_ptr& schema) +void AddTaskEdgeDetails(const std::shared_ptr& typeTaskEdge, const std::shared_ptr& schema) { typeTaskEdge->AddFields({ schema::Field::Make(R"gql(node)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType("Task")), diff --git a/samples/today/separate/TaskEdgeObject.h b/samples/today/separate/TaskEdgeObject.h index 45d77ab9..1dbd5980 100644 --- a/samples/today/separate/TaskEdgeObject.h +++ b/samples/today/separate/TaskEdgeObject.h @@ -11,54 +11,54 @@ #include "TodaySchema.h" namespace graphql::today::object { -namespace methods::TaskEdgeMethod { +namespace methods::TaskEdgeHas { template -concept WithParamsNode = requires (TImpl impl, service::FieldParams params) +concept getNodeWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getNode(std::move(params)) } }; }; template -concept NoParamsNode = requires (TImpl impl) +concept getNode = requires (TImpl impl) { { service::FieldResult> { impl.getNode() } }; }; template -concept WithParamsCursor = requires (TImpl impl, service::FieldParams params) +concept getCursorWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getCursor(std::move(params)) } }; }; template -concept NoParamsCursor = requires (TImpl impl) +concept getCursor = requires (TImpl impl) { { service::FieldResult { impl.getCursor() } }; }; template -concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.beginSelectionSet(params) }; }; template -concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.endSelectionSet(params) }; }; -} // namespace methods::TaskEdgeMethod +} // namespace methods::TaskEdgeHas class TaskEdge : public service::Object { private: - service::AwaitableResolver resolveNode(service::ResolverParams&& params); - service::AwaitableResolver resolveCursor(service::ResolverParams&& params); + service::AwaitableResolver resolveNode(service::ResolverParams&& params) const; + service::AwaitableResolver resolveCursor(service::ResolverParams&& params) const; - service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; struct Concept { @@ -82,11 +82,11 @@ class TaskEdge service::FieldResult> getNode(service::FieldParams&& params) const final { - if constexpr (methods::TaskEdgeMethod::WithParamsNode) + if constexpr (methods::TaskEdgeHas::getNodeWithParams) { return { _pimpl->getNode(std::move(params)) }; } - else if constexpr (methods::TaskEdgeMethod::NoParamsNode) + else if constexpr (methods::TaskEdgeHas::getNode) { return { _pimpl->getNode() }; } @@ -98,11 +98,11 @@ class TaskEdge service::FieldResult getCursor(service::FieldParams&& params) const final { - if constexpr (methods::TaskEdgeMethod::WithParamsCursor) + if constexpr (methods::TaskEdgeHas::getCursorWithParams) { return { _pimpl->getCursor(std::move(params)) }; } - else if constexpr (methods::TaskEdgeMethod::NoParamsCursor) + else if constexpr (methods::TaskEdgeHas::getCursor) { return { _pimpl->getCursor() }; } @@ -114,7 +114,7 @@ class TaskEdge void beginSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::TaskEdgeMethod::HasBeginSelectionSet) + if constexpr (methods::TaskEdgeHas::beginSelectionSet) { _pimpl->beginSelectionSet(params); } @@ -122,7 +122,7 @@ class TaskEdge void endSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::TaskEdgeMethod::HasEndSelectionSet) + if constexpr (methods::TaskEdgeHas::endSelectionSet) { _pimpl->endSelectionSet(params); } @@ -132,7 +132,10 @@ class TaskEdge const std::shared_ptr _pimpl; }; - TaskEdge(std::unique_ptr&& pimpl); + TaskEdge(std::unique_ptr&& pimpl) noexcept; + + service::TypeNames getTypeNames() const noexcept; + service::ResolverMap getResolvers() const noexcept; void beginSelectionSet(const service::SelectionSetParams& params) const final; void endSelectionSet(const service::SelectionSetParams& params) const final; @@ -141,7 +144,7 @@ class TaskEdge public: template - TaskEdge(std::shared_ptr pimpl) + TaskEdge(std::shared_ptr pimpl) noexcept : TaskEdge { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } diff --git a/samples/today/separate/TaskObject.cpp b/samples/today/separate/TaskObject.cpp index 39272e88..bdc7596c 100644 --- a/samples/today/separate/TaskObject.cpp +++ b/samples/today/separate/TaskObject.cpp @@ -18,19 +18,29 @@ using namespace std::literals; namespace graphql::today { namespace object { -Task::Task(std::unique_ptr&& pimpl) - : service::Object({ +Task::Task(std::unique_ptr&& pimpl) noexcept + : service::Object{ getTypeNames(), getResolvers() } + , _pimpl { std::move(pimpl) } +{ +} + +service::TypeNames Task::getTypeNames() const noexcept +{ + return { "Node", "UnionType", "Task" - }, { + }; +} + +service::ResolverMap Task::getResolvers() const noexcept +{ + return { { R"gql(id)gql"sv, [this](service::ResolverParams&& params) { return resolveId(std::move(params)); } }, { R"gql(title)gql"sv, [this](service::ResolverParams&& params) { return resolveTitle(std::move(params)); } }, { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, { R"gql(isComplete)gql"sv, [this](service::ResolverParams&& params) { return resolveIsComplete(std::move(params)); } } - }) - , _pimpl(std::move(pimpl)) -{ + }; } void Task::beginSelectionSet(const service::SelectionSetParams& params) const @@ -43,7 +53,7 @@ void Task::endSelectionSet(const service::SelectionSetParams& params) const _pimpl->endSelectionSet(params); } -service::AwaitableResolver Task::resolveId(service::ResolverParams&& params) +service::AwaitableResolver Task::resolveId(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -53,7 +63,7 @@ service::AwaitableResolver Task::resolveId(service::ResolverParams&& params) return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Task::resolveTitle(service::ResolverParams&& params) +service::AwaitableResolver Task::resolveTitle(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -63,7 +73,7 @@ service::AwaitableResolver Task::resolveTitle(service::ResolverParams&& params) return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Task::resolveIsComplete(service::ResolverParams&& params) +service::AwaitableResolver Task::resolveIsComplete(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -73,14 +83,14 @@ service::AwaitableResolver Task::resolveIsComplete(service::ResolverParams&& par return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Task::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver Task::resolve_typename(service::ResolverParams&& params) const { return service::ModifiedResult::convert(std::string{ R"gql(Task)gql" }, std::move(params)); } } // namespace object -void AddTaskDetails(std::shared_ptr typeTask, const std::shared_ptr& schema) +void AddTaskDetails(const std::shared_ptr& typeTask, const std::shared_ptr& schema) { typeTask->AddInterfaces({ std::static_pointer_cast(schema->LookupType(R"gql(Node)gql"sv)) diff --git a/samples/today/separate/TaskObject.h b/samples/today/separate/TaskObject.h index cbf1457c..5cadd3de 100644 --- a/samples/today/separate/TaskObject.h +++ b/samples/today/separate/TaskObject.h @@ -10,77 +10,86 @@ #include "TodaySchema.h" +#include "NodeObject.h" + namespace graphql::today::object { -namespace methods::TaskMethod { +namespace implements { + +template +concept TaskIs = std::is_same_v; + +} // namespace implements + +namespace methods::TaskHas { template -concept WithParamsId = requires (TImpl impl, service::FieldParams params) +concept getIdWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getId(std::move(params)) } }; }; template -concept NoParamsId = requires (TImpl impl) +concept getId = requires (TImpl impl) { { service::FieldResult { impl.getId() } }; }; template -concept WithParamsTitle = requires (TImpl impl, service::FieldParams params) +concept getTitleWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getTitle(std::move(params)) } }; }; template -concept NoParamsTitle = requires (TImpl impl) +concept getTitle = requires (TImpl impl) { { service::FieldResult> { impl.getTitle() } }; }; template -concept WithParamsIsComplete = requires (TImpl impl, service::FieldParams params) +concept getIsCompleteWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getIsComplete(std::move(params)) } }; }; template -concept NoParamsIsComplete = requires (TImpl impl) +concept getIsComplete = requires (TImpl impl) { { service::FieldResult { impl.getIsComplete() } }; }; template -concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.beginSelectionSet(params) }; }; template -concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.endSelectionSet(params) }; }; -} // namespace methods::TaskMethod +} // namespace methods::TaskHas class Task : public service::Object { private: - service::AwaitableResolver resolveId(service::ResolverParams&& params); - service::AwaitableResolver resolveTitle(service::ResolverParams&& params); - service::AwaitableResolver resolveIsComplete(service::ResolverParams&& params); + service::AwaitableResolver resolveId(service::ResolverParams&& params) const; + service::AwaitableResolver resolveTitle(service::ResolverParams&& params) const; + service::AwaitableResolver resolveIsComplete(service::ResolverParams&& params) const; - service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; struct Concept - : Node { virtual ~Concept() = default; virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual service::FieldResult getId(service::FieldParams&& params) const = 0; virtual service::FieldResult> getTitle(service::FieldParams&& params) const = 0; virtual service::FieldResult getIsComplete(service::FieldParams&& params) const = 0; }; @@ -96,11 +105,11 @@ class Task service::FieldResult getId(service::FieldParams&& params) const final { - if constexpr (methods::TaskMethod::WithParamsId) + if constexpr (methods::TaskHas::getIdWithParams) { return { _pimpl->getId(std::move(params)) }; } - else if constexpr (methods::TaskMethod::NoParamsId) + else if constexpr (methods::TaskHas::getId) { return { _pimpl->getId() }; } @@ -112,11 +121,11 @@ class Task service::FieldResult> getTitle(service::FieldParams&& params) const final { - if constexpr (methods::TaskMethod::WithParamsTitle) + if constexpr (methods::TaskHas::getTitleWithParams) { return { _pimpl->getTitle(std::move(params)) }; } - else if constexpr (methods::TaskMethod::NoParamsTitle) + else if constexpr (methods::TaskHas::getTitle) { return { _pimpl->getTitle() }; } @@ -128,11 +137,11 @@ class Task service::FieldResult getIsComplete(service::FieldParams&& params) const final { - if constexpr (methods::TaskMethod::WithParamsIsComplete) + if constexpr (methods::TaskHas::getIsCompleteWithParams) { return { _pimpl->getIsComplete(std::move(params)) }; } - else if constexpr (methods::TaskMethod::NoParamsIsComplete) + else if constexpr (methods::TaskHas::getIsComplete) { return { _pimpl->getIsComplete() }; } @@ -144,7 +153,7 @@ class Task void beginSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::TaskMethod::HasBeginSelectionSet) + if constexpr (methods::TaskHas::beginSelectionSet) { _pimpl->beginSelectionSet(params); } @@ -152,7 +161,7 @@ class Task void endSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::TaskMethod::HasEndSelectionSet) + if constexpr (methods::TaskHas::endSelectionSet) { _pimpl->endSelectionSet(params); } @@ -162,7 +171,19 @@ class Task const std::shared_ptr _pimpl; }; - Task(std::unique_ptr&& pimpl); + Task(std::unique_ptr&& pimpl) noexcept; + + // Interface objects need access to these methods + friend Node; + + template + static constexpr bool implements() noexcept + { + return implements::TaskIs; + } + + service::TypeNames getTypeNames() const noexcept; + service::ResolverMap getResolvers() const noexcept; void beginSelectionSet(const service::SelectionSetParams& params) const final; void endSelectionSet(const service::SelectionSetParams& params) const final; @@ -171,7 +192,7 @@ class Task public: template - Task(std::shared_ptr pimpl) + Task(std::shared_ptr pimpl) noexcept : Task { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } diff --git a/samples/today/separate/TodayObjects.h b/samples/today/separate/TodayObjects.h index 80502f8c..b9dda2ce 100644 --- a/samples/today/separate/TodayObjects.h +++ b/samples/today/separate/TodayObjects.h @@ -10,6 +10,7 @@ #include "TodaySchema.h" +#include "NodeObject.h" #include "QueryObject.h" #include "PageInfoObject.h" #include "AppointmentEdgeObject.h" diff --git a/samples/today/separate/TodaySchema.cpp b/samples/today/separate/TodaySchema.cpp index 7eb8375b..e11d4626 100644 --- a/samples/today/separate/TodaySchema.cpp +++ b/samples/today/separate/TodaySchema.cpp @@ -240,9 +240,7 @@ void AddTypesToSchema(const std::shared_ptr& schema) schema->LookupType(R"gql(Folder)gql"sv) }); - typeNode->AddFields({ - schema::Field::Make(R"gql(id)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("ID"))) - }); + AddNodeDetails(typeNode, schema); AddQueryDetails(typeQuery, schema); AddPageInfoDetails(typePageInfo, schema); diff --git a/samples/today/separate/TodaySchema.h b/samples/today/separate/TodaySchema.h index f7afa110..c3042f81 100644 --- a/samples/today/separate/TodaySchema.h +++ b/samples/today/separate/TodaySchema.h @@ -62,6 +62,8 @@ struct FirstNestedInput namespace object { +class Node; + class Query; class PageInfo; class AppointmentEdge; @@ -81,11 +83,6 @@ class Expensive; } // namespace object -struct Node -{ - virtual service::FieldResult getId(service::FieldParams&& params) const = 0; -}; - class Operations : public service::Request { @@ -104,22 +101,24 @@ class Operations std::shared_ptr _subscription; }; -void AddQueryDetails(std::shared_ptr typeQuery, const std::shared_ptr& schema); -void AddPageInfoDetails(std::shared_ptr typePageInfo, const std::shared_ptr& schema); -void AddAppointmentEdgeDetails(std::shared_ptr typeAppointmentEdge, const std::shared_ptr& schema); -void AddAppointmentConnectionDetails(std::shared_ptr typeAppointmentConnection, const std::shared_ptr& schema); -void AddTaskEdgeDetails(std::shared_ptr typeTaskEdge, const std::shared_ptr& schema); -void AddTaskConnectionDetails(std::shared_ptr typeTaskConnection, const std::shared_ptr& schema); -void AddFolderEdgeDetails(std::shared_ptr typeFolderEdge, const std::shared_ptr& schema); -void AddFolderConnectionDetails(std::shared_ptr typeFolderConnection, const std::shared_ptr& schema); -void AddCompleteTaskPayloadDetails(std::shared_ptr typeCompleteTaskPayload, const std::shared_ptr& schema); -void AddMutationDetails(std::shared_ptr typeMutation, const std::shared_ptr& schema); -void AddSubscriptionDetails(std::shared_ptr typeSubscription, const std::shared_ptr& schema); -void AddAppointmentDetails(std::shared_ptr typeAppointment, const std::shared_ptr& schema); -void AddTaskDetails(std::shared_ptr typeTask, const std::shared_ptr& schema); -void AddFolderDetails(std::shared_ptr typeFolder, const std::shared_ptr& schema); -void AddNestedTypeDetails(std::shared_ptr typeNestedType, const std::shared_ptr& schema); -void AddExpensiveDetails(std::shared_ptr typeExpensive, const std::shared_ptr& schema); +void AddNodeDetails(const std::shared_ptr& typeNode, const std::shared_ptr& schema); + +void AddQueryDetails(const std::shared_ptr& typeQuery, const std::shared_ptr& schema); +void AddPageInfoDetails(const std::shared_ptr& typePageInfo, const std::shared_ptr& schema); +void AddAppointmentEdgeDetails(const std::shared_ptr& typeAppointmentEdge, const std::shared_ptr& schema); +void AddAppointmentConnectionDetails(const std::shared_ptr& typeAppointmentConnection, const std::shared_ptr& schema); +void AddTaskEdgeDetails(const std::shared_ptr& typeTaskEdge, const std::shared_ptr& schema); +void AddTaskConnectionDetails(const std::shared_ptr& typeTaskConnection, const std::shared_ptr& schema); +void AddFolderEdgeDetails(const std::shared_ptr& typeFolderEdge, const std::shared_ptr& schema); +void AddFolderConnectionDetails(const std::shared_ptr& typeFolderConnection, const std::shared_ptr& schema); +void AddCompleteTaskPayloadDetails(const std::shared_ptr& typeCompleteTaskPayload, const std::shared_ptr& schema); +void AddMutationDetails(const std::shared_ptr& typeMutation, const std::shared_ptr& schema); +void AddSubscriptionDetails(const std::shared_ptr& typeSubscription, const std::shared_ptr& schema); +void AddAppointmentDetails(const std::shared_ptr& typeAppointment, const std::shared_ptr& schema); +void AddTaskDetails(const std::shared_ptr& typeTask, const std::shared_ptr& schema); +void AddFolderDetails(const std::shared_ptr& typeFolder, const std::shared_ptr& schema); +void AddNestedTypeDetails(const std::shared_ptr& typeNestedType, const std::shared_ptr& schema); +void AddExpensiveDetails(const std::shared_ptr& typeExpensive, const std::shared_ptr& schema); std::shared_ptr GetSchema(); diff --git a/samples/today/separate/separate_schema_files b/samples/today/separate/separate_schema_files index f1fb1229..bb9ce34b 100644 --- a/samples/today/separate/separate_schema_files +++ b/samples/today/separate/separate_schema_files @@ -1,4 +1,5 @@ TodaySchema.cpp +NodeObject.cpp QueryObject.cpp PageInfoObject.cpp AppointmentEdgeObject.cpp diff --git a/samples/today/separate_nointrospection/AppointmentConnectionObject.cpp b/samples/today/separate_nointrospection/AppointmentConnectionObject.cpp index 4a97fb36..446723de 100644 --- a/samples/today/separate_nointrospection/AppointmentConnectionObject.cpp +++ b/samples/today/separate_nointrospection/AppointmentConnectionObject.cpp @@ -18,16 +18,26 @@ using namespace std::literals; namespace graphql::today { namespace object { -AppointmentConnection::AppointmentConnection(std::unique_ptr&& pimpl) - : service::Object({ +AppointmentConnection::AppointmentConnection(std::unique_ptr&& pimpl) noexcept + : service::Object{ getTypeNames(), getResolvers() } + , _pimpl { std::move(pimpl) } +{ +} + +service::TypeNames AppointmentConnection::getTypeNames() const noexcept +{ + return { "AppointmentConnection" - }, { + }; +} + +service::ResolverMap AppointmentConnection::getResolvers() const noexcept +{ + return { { R"gql(edges)gql"sv, [this](service::ResolverParams&& params) { return resolveEdges(std::move(params)); } }, { R"gql(pageInfo)gql"sv, [this](service::ResolverParams&& params) { return resolvePageInfo(std::move(params)); } }, { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } } - }) - , _pimpl(std::move(pimpl)) -{ + }; } void AppointmentConnection::beginSelectionSet(const service::SelectionSetParams& params) const @@ -40,7 +50,7 @@ void AppointmentConnection::endSelectionSet(const service::SelectionSetParams& p _pimpl->endSelectionSet(params); } -service::AwaitableResolver AppointmentConnection::resolvePageInfo(service::ResolverParams&& params) +service::AwaitableResolver AppointmentConnection::resolvePageInfo(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -50,7 +60,7 @@ service::AwaitableResolver AppointmentConnection::resolvePageInfo(service::Resol return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver AppointmentConnection::resolveEdges(service::ResolverParams&& params) +service::AwaitableResolver AppointmentConnection::resolveEdges(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -60,14 +70,14 @@ service::AwaitableResolver AppointmentConnection::resolveEdges(service::Resolver return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver AppointmentConnection::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver AppointmentConnection::resolve_typename(service::ResolverParams&& params) const { return service::ModifiedResult::convert(std::string{ R"gql(AppointmentConnection)gql" }, std::move(params)); } } // namespace object -void AddAppointmentConnectionDetails(std::shared_ptr typeAppointmentConnection, const std::shared_ptr& schema) +void AddAppointmentConnectionDetails(const std::shared_ptr& typeAppointmentConnection, const std::shared_ptr& schema) { typeAppointmentConnection->AddFields({ schema::Field::Make(R"gql(pageInfo)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("PageInfo"))), diff --git a/samples/today/separate_nointrospection/AppointmentConnectionObject.h b/samples/today/separate_nointrospection/AppointmentConnectionObject.h index 20146fdf..b7d5baee 100644 --- a/samples/today/separate_nointrospection/AppointmentConnectionObject.h +++ b/samples/today/separate_nointrospection/AppointmentConnectionObject.h @@ -11,54 +11,54 @@ #include "TodaySchema.h" namespace graphql::today::object { -namespace methods::AppointmentConnectionMethod { +namespace methods::AppointmentConnectionHas { template -concept WithParamsPageInfo = requires (TImpl impl, service::FieldParams params) +concept getPageInfoWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getPageInfo(std::move(params)) } }; }; template -concept NoParamsPageInfo = requires (TImpl impl) +concept getPageInfo = requires (TImpl impl) { { service::FieldResult> { impl.getPageInfo() } }; }; template -concept WithParamsEdges = requires (TImpl impl, service::FieldParams params) +concept getEdgesWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult>>> { impl.getEdges(std::move(params)) } }; }; template -concept NoParamsEdges = requires (TImpl impl) +concept getEdges = requires (TImpl impl) { { service::FieldResult>>> { impl.getEdges() } }; }; template -concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.beginSelectionSet(params) }; }; template -concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.endSelectionSet(params) }; }; -} // namespace methods::AppointmentConnectionMethod +} // namespace methods::AppointmentConnectionHas class AppointmentConnection : public service::Object { private: - service::AwaitableResolver resolvePageInfo(service::ResolverParams&& params); - service::AwaitableResolver resolveEdges(service::ResolverParams&& params); + service::AwaitableResolver resolvePageInfo(service::ResolverParams&& params) const; + service::AwaitableResolver resolveEdges(service::ResolverParams&& params) const; - service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; struct Concept { @@ -82,11 +82,11 @@ class AppointmentConnection service::FieldResult> getPageInfo(service::FieldParams&& params) const final { - if constexpr (methods::AppointmentConnectionMethod::WithParamsPageInfo) + if constexpr (methods::AppointmentConnectionHas::getPageInfoWithParams) { return { _pimpl->getPageInfo(std::move(params)) }; } - else if constexpr (methods::AppointmentConnectionMethod::NoParamsPageInfo) + else if constexpr (methods::AppointmentConnectionHas::getPageInfo) { return { _pimpl->getPageInfo() }; } @@ -98,11 +98,11 @@ class AppointmentConnection service::FieldResult>>> getEdges(service::FieldParams&& params) const final { - if constexpr (methods::AppointmentConnectionMethod::WithParamsEdges) + if constexpr (methods::AppointmentConnectionHas::getEdgesWithParams) { return { _pimpl->getEdges(std::move(params)) }; } - else if constexpr (methods::AppointmentConnectionMethod::NoParamsEdges) + else if constexpr (methods::AppointmentConnectionHas::getEdges) { return { _pimpl->getEdges() }; } @@ -114,7 +114,7 @@ class AppointmentConnection void beginSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::AppointmentConnectionMethod::HasBeginSelectionSet) + if constexpr (methods::AppointmentConnectionHas::beginSelectionSet) { _pimpl->beginSelectionSet(params); } @@ -122,7 +122,7 @@ class AppointmentConnection void endSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::AppointmentConnectionMethod::HasEndSelectionSet) + if constexpr (methods::AppointmentConnectionHas::endSelectionSet) { _pimpl->endSelectionSet(params); } @@ -132,7 +132,10 @@ class AppointmentConnection const std::shared_ptr _pimpl; }; - AppointmentConnection(std::unique_ptr&& pimpl); + AppointmentConnection(std::unique_ptr&& pimpl) noexcept; + + service::TypeNames getTypeNames() const noexcept; + service::ResolverMap getResolvers() const noexcept; void beginSelectionSet(const service::SelectionSetParams& params) const final; void endSelectionSet(const service::SelectionSetParams& params) const final; @@ -141,7 +144,7 @@ class AppointmentConnection public: template - AppointmentConnection(std::shared_ptr pimpl) + AppointmentConnection(std::shared_ptr pimpl) noexcept : AppointmentConnection { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } diff --git a/samples/today/separate_nointrospection/AppointmentEdgeObject.cpp b/samples/today/separate_nointrospection/AppointmentEdgeObject.cpp index 05a5d795..84742a4a 100644 --- a/samples/today/separate_nointrospection/AppointmentEdgeObject.cpp +++ b/samples/today/separate_nointrospection/AppointmentEdgeObject.cpp @@ -18,16 +18,26 @@ using namespace std::literals; namespace graphql::today { namespace object { -AppointmentEdge::AppointmentEdge(std::unique_ptr&& pimpl) - : service::Object({ +AppointmentEdge::AppointmentEdge(std::unique_ptr&& pimpl) noexcept + : service::Object{ getTypeNames(), getResolvers() } + , _pimpl { std::move(pimpl) } +{ +} + +service::TypeNames AppointmentEdge::getTypeNames() const noexcept +{ + return { "AppointmentEdge" - }, { + }; +} + +service::ResolverMap AppointmentEdge::getResolvers() const noexcept +{ + return { { R"gql(node)gql"sv, [this](service::ResolverParams&& params) { return resolveNode(std::move(params)); } }, { R"gql(cursor)gql"sv, [this](service::ResolverParams&& params) { return resolveCursor(std::move(params)); } }, { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } } - }) - , _pimpl(std::move(pimpl)) -{ + }; } void AppointmentEdge::beginSelectionSet(const service::SelectionSetParams& params) const @@ -40,7 +50,7 @@ void AppointmentEdge::endSelectionSet(const service::SelectionSetParams& params) _pimpl->endSelectionSet(params); } -service::AwaitableResolver AppointmentEdge::resolveNode(service::ResolverParams&& params) +service::AwaitableResolver AppointmentEdge::resolveNode(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -50,7 +60,7 @@ service::AwaitableResolver AppointmentEdge::resolveNode(service::ResolverParams& return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver AppointmentEdge::resolveCursor(service::ResolverParams&& params) +service::AwaitableResolver AppointmentEdge::resolveCursor(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -60,14 +70,14 @@ service::AwaitableResolver AppointmentEdge::resolveCursor(service::ResolverParam return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver AppointmentEdge::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver AppointmentEdge::resolve_typename(service::ResolverParams&& params) const { return service::ModifiedResult::convert(std::string{ R"gql(AppointmentEdge)gql" }, std::move(params)); } } // namespace object -void AddAppointmentEdgeDetails(std::shared_ptr typeAppointmentEdge, const std::shared_ptr& schema) +void AddAppointmentEdgeDetails(const std::shared_ptr& typeAppointmentEdge, const std::shared_ptr& schema) { typeAppointmentEdge->AddFields({ schema::Field::Make(R"gql(node)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType("Appointment")), diff --git a/samples/today/separate_nointrospection/AppointmentEdgeObject.h b/samples/today/separate_nointrospection/AppointmentEdgeObject.h index 893a704d..7477476b 100644 --- a/samples/today/separate_nointrospection/AppointmentEdgeObject.h +++ b/samples/today/separate_nointrospection/AppointmentEdgeObject.h @@ -11,54 +11,54 @@ #include "TodaySchema.h" namespace graphql::today::object { -namespace methods::AppointmentEdgeMethod { +namespace methods::AppointmentEdgeHas { template -concept WithParamsNode = requires (TImpl impl, service::FieldParams params) +concept getNodeWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getNode(std::move(params)) } }; }; template -concept NoParamsNode = requires (TImpl impl) +concept getNode = requires (TImpl impl) { { service::FieldResult> { impl.getNode() } }; }; template -concept WithParamsCursor = requires (TImpl impl, service::FieldParams params) +concept getCursorWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getCursor(std::move(params)) } }; }; template -concept NoParamsCursor = requires (TImpl impl) +concept getCursor = requires (TImpl impl) { { service::FieldResult { impl.getCursor() } }; }; template -concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.beginSelectionSet(params) }; }; template -concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.endSelectionSet(params) }; }; -} // namespace methods::AppointmentEdgeMethod +} // namespace methods::AppointmentEdgeHas class AppointmentEdge : public service::Object { private: - service::AwaitableResolver resolveNode(service::ResolverParams&& params); - service::AwaitableResolver resolveCursor(service::ResolverParams&& params); + service::AwaitableResolver resolveNode(service::ResolverParams&& params) const; + service::AwaitableResolver resolveCursor(service::ResolverParams&& params) const; - service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; struct Concept { @@ -82,11 +82,11 @@ class AppointmentEdge service::FieldResult> getNode(service::FieldParams&& params) const final { - if constexpr (methods::AppointmentEdgeMethod::WithParamsNode) + if constexpr (methods::AppointmentEdgeHas::getNodeWithParams) { return { _pimpl->getNode(std::move(params)) }; } - else if constexpr (methods::AppointmentEdgeMethod::NoParamsNode) + else if constexpr (methods::AppointmentEdgeHas::getNode) { return { _pimpl->getNode() }; } @@ -98,11 +98,11 @@ class AppointmentEdge service::FieldResult getCursor(service::FieldParams&& params) const final { - if constexpr (methods::AppointmentEdgeMethod::WithParamsCursor) + if constexpr (methods::AppointmentEdgeHas::getCursorWithParams) { return { _pimpl->getCursor(std::move(params)) }; } - else if constexpr (methods::AppointmentEdgeMethod::NoParamsCursor) + else if constexpr (methods::AppointmentEdgeHas::getCursor) { return { _pimpl->getCursor() }; } @@ -114,7 +114,7 @@ class AppointmentEdge void beginSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::AppointmentEdgeMethod::HasBeginSelectionSet) + if constexpr (methods::AppointmentEdgeHas::beginSelectionSet) { _pimpl->beginSelectionSet(params); } @@ -122,7 +122,7 @@ class AppointmentEdge void endSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::AppointmentEdgeMethod::HasEndSelectionSet) + if constexpr (methods::AppointmentEdgeHas::endSelectionSet) { _pimpl->endSelectionSet(params); } @@ -132,7 +132,10 @@ class AppointmentEdge const std::shared_ptr _pimpl; }; - AppointmentEdge(std::unique_ptr&& pimpl); + AppointmentEdge(std::unique_ptr&& pimpl) noexcept; + + service::TypeNames getTypeNames() const noexcept; + service::ResolverMap getResolvers() const noexcept; void beginSelectionSet(const service::SelectionSetParams& params) const final; void endSelectionSet(const service::SelectionSetParams& params) const final; @@ -141,7 +144,7 @@ class AppointmentEdge public: template - AppointmentEdge(std::shared_ptr pimpl) + AppointmentEdge(std::shared_ptr pimpl) noexcept : AppointmentEdge { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } diff --git a/samples/today/separate_nointrospection/AppointmentObject.cpp b/samples/today/separate_nointrospection/AppointmentObject.cpp index 338ab608..3bc3745d 100644 --- a/samples/today/separate_nointrospection/AppointmentObject.cpp +++ b/samples/today/separate_nointrospection/AppointmentObject.cpp @@ -18,21 +18,31 @@ using namespace std::literals; namespace graphql::today { namespace object { -Appointment::Appointment(std::unique_ptr&& pimpl) - : service::Object({ +Appointment::Appointment(std::unique_ptr&& pimpl) noexcept + : service::Object{ getTypeNames(), getResolvers() } + , _pimpl { std::move(pimpl) } +{ +} + +service::TypeNames Appointment::getTypeNames() const noexcept +{ + return { "Node", "UnionType", "Appointment" - }, { + }; +} + +service::ResolverMap Appointment::getResolvers() const noexcept +{ + return { { R"gql(id)gql"sv, [this](service::ResolverParams&& params) { return resolveId(std::move(params)); } }, { R"gql(when)gql"sv, [this](service::ResolverParams&& params) { return resolveWhen(std::move(params)); } }, { R"gql(isNow)gql"sv, [this](service::ResolverParams&& params) { return resolveIsNow(std::move(params)); } }, { R"gql(subject)gql"sv, [this](service::ResolverParams&& params) { return resolveSubject(std::move(params)); } }, { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, { R"gql(forceError)gql"sv, [this](service::ResolverParams&& params) { return resolveForceError(std::move(params)); } } - }) - , _pimpl(std::move(pimpl)) -{ + }; } void Appointment::beginSelectionSet(const service::SelectionSetParams& params) const @@ -45,7 +55,7 @@ void Appointment::endSelectionSet(const service::SelectionSetParams& params) con _pimpl->endSelectionSet(params); } -service::AwaitableResolver Appointment::resolveId(service::ResolverParams&& params) +service::AwaitableResolver Appointment::resolveId(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -55,7 +65,7 @@ service::AwaitableResolver Appointment::resolveId(service::ResolverParams&& para return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Appointment::resolveWhen(service::ResolverParams&& params) +service::AwaitableResolver Appointment::resolveWhen(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -65,7 +75,7 @@ service::AwaitableResolver Appointment::resolveWhen(service::ResolverParams&& pa return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Appointment::resolveSubject(service::ResolverParams&& params) +service::AwaitableResolver Appointment::resolveSubject(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -75,7 +85,7 @@ service::AwaitableResolver Appointment::resolveSubject(service::ResolverParams&& return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Appointment::resolveIsNow(service::ResolverParams&& params) +service::AwaitableResolver Appointment::resolveIsNow(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -85,7 +95,7 @@ service::AwaitableResolver Appointment::resolveIsNow(service::ResolverParams&& p return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Appointment::resolveForceError(service::ResolverParams&& params) +service::AwaitableResolver Appointment::resolveForceError(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -95,14 +105,14 @@ service::AwaitableResolver Appointment::resolveForceError(service::ResolverParam return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Appointment::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver Appointment::resolve_typename(service::ResolverParams&& params) const { return service::ModifiedResult::convert(std::string{ R"gql(Appointment)gql" }, std::move(params)); } } // namespace object -void AddAppointmentDetails(std::shared_ptr typeAppointment, const std::shared_ptr& schema) +void AddAppointmentDetails(const std::shared_ptr& typeAppointment, const std::shared_ptr& schema) { typeAppointment->AddInterfaces({ std::static_pointer_cast(schema->LookupType(R"gql(Node)gql"sv)) diff --git a/samples/today/separate_nointrospection/AppointmentObject.h b/samples/today/separate_nointrospection/AppointmentObject.h index fd49dd1d..b394859d 100644 --- a/samples/today/separate_nointrospection/AppointmentObject.h +++ b/samples/today/separate_nointrospection/AppointmentObject.h @@ -10,103 +10,112 @@ #include "TodaySchema.h" +#include "NodeObject.h" + namespace graphql::today::object { -namespace methods::AppointmentMethod { +namespace implements { + +template +concept AppointmentIs = std::is_same_v; + +} // namespace implements + +namespace methods::AppointmentHas { template -concept WithParamsId = requires (TImpl impl, service::FieldParams params) +concept getIdWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getId(std::move(params)) } }; }; template -concept NoParamsId = requires (TImpl impl) +concept getId = requires (TImpl impl) { { service::FieldResult { impl.getId() } }; }; template -concept WithParamsWhen = requires (TImpl impl, service::FieldParams params) +concept getWhenWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getWhen(std::move(params)) } }; }; template -concept NoParamsWhen = requires (TImpl impl) +concept getWhen = requires (TImpl impl) { { service::FieldResult> { impl.getWhen() } }; }; template -concept WithParamsSubject = requires (TImpl impl, service::FieldParams params) +concept getSubjectWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getSubject(std::move(params)) } }; }; template -concept NoParamsSubject = requires (TImpl impl) +concept getSubject = requires (TImpl impl) { { service::FieldResult> { impl.getSubject() } }; }; template -concept WithParamsIsNow = requires (TImpl impl, service::FieldParams params) +concept getIsNowWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getIsNow(std::move(params)) } }; }; template -concept NoParamsIsNow = requires (TImpl impl) +concept getIsNow = requires (TImpl impl) { { service::FieldResult { impl.getIsNow() } }; }; template -concept WithParamsForceError = requires (TImpl impl, service::FieldParams params) +concept getForceErrorWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getForceError(std::move(params)) } }; }; template -concept NoParamsForceError = requires (TImpl impl) +concept getForceError = requires (TImpl impl) { { service::FieldResult> { impl.getForceError() } }; }; template -concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.beginSelectionSet(params) }; }; template -concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.endSelectionSet(params) }; }; -} // namespace methods::AppointmentMethod +} // namespace methods::AppointmentHas class Appointment : public service::Object { private: - service::AwaitableResolver resolveId(service::ResolverParams&& params); - service::AwaitableResolver resolveWhen(service::ResolverParams&& params); - service::AwaitableResolver resolveSubject(service::ResolverParams&& params); - service::AwaitableResolver resolveIsNow(service::ResolverParams&& params); - service::AwaitableResolver resolveForceError(service::ResolverParams&& params); + service::AwaitableResolver resolveId(service::ResolverParams&& params) const; + service::AwaitableResolver resolveWhen(service::ResolverParams&& params) const; + service::AwaitableResolver resolveSubject(service::ResolverParams&& params) const; + service::AwaitableResolver resolveIsNow(service::ResolverParams&& params) const; + service::AwaitableResolver resolveForceError(service::ResolverParams&& params) const; - service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; struct Concept - : Node { virtual ~Concept() = default; virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual service::FieldResult getId(service::FieldParams&& params) const = 0; virtual service::FieldResult> getWhen(service::FieldParams&& params) const = 0; virtual service::FieldResult> getSubject(service::FieldParams&& params) const = 0; virtual service::FieldResult getIsNow(service::FieldParams&& params) const = 0; @@ -124,11 +133,11 @@ class Appointment service::FieldResult getId(service::FieldParams&& params) const final { - if constexpr (methods::AppointmentMethod::WithParamsId) + if constexpr (methods::AppointmentHas::getIdWithParams) { return { _pimpl->getId(std::move(params)) }; } - else if constexpr (methods::AppointmentMethod::NoParamsId) + else if constexpr (methods::AppointmentHas::getId) { return { _pimpl->getId() }; } @@ -140,11 +149,11 @@ class Appointment service::FieldResult> getWhen(service::FieldParams&& params) const final { - if constexpr (methods::AppointmentMethod::WithParamsWhen) + if constexpr (methods::AppointmentHas::getWhenWithParams) { return { _pimpl->getWhen(std::move(params)) }; } - else if constexpr (methods::AppointmentMethod::NoParamsWhen) + else if constexpr (methods::AppointmentHas::getWhen) { return { _pimpl->getWhen() }; } @@ -156,11 +165,11 @@ class Appointment service::FieldResult> getSubject(service::FieldParams&& params) const final { - if constexpr (methods::AppointmentMethod::WithParamsSubject) + if constexpr (methods::AppointmentHas::getSubjectWithParams) { return { _pimpl->getSubject(std::move(params)) }; } - else if constexpr (methods::AppointmentMethod::NoParamsSubject) + else if constexpr (methods::AppointmentHas::getSubject) { return { _pimpl->getSubject() }; } @@ -172,11 +181,11 @@ class Appointment service::FieldResult getIsNow(service::FieldParams&& params) const final { - if constexpr (methods::AppointmentMethod::WithParamsIsNow) + if constexpr (methods::AppointmentHas::getIsNowWithParams) { return { _pimpl->getIsNow(std::move(params)) }; } - else if constexpr (methods::AppointmentMethod::NoParamsIsNow) + else if constexpr (methods::AppointmentHas::getIsNow) { return { _pimpl->getIsNow() }; } @@ -188,11 +197,11 @@ class Appointment service::FieldResult> getForceError(service::FieldParams&& params) const final { - if constexpr (methods::AppointmentMethod::WithParamsForceError) + if constexpr (methods::AppointmentHas::getForceErrorWithParams) { return { _pimpl->getForceError(std::move(params)) }; } - else if constexpr (methods::AppointmentMethod::NoParamsForceError) + else if constexpr (methods::AppointmentHas::getForceError) { return { _pimpl->getForceError() }; } @@ -204,7 +213,7 @@ class Appointment void beginSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::AppointmentMethod::HasBeginSelectionSet) + if constexpr (methods::AppointmentHas::beginSelectionSet) { _pimpl->beginSelectionSet(params); } @@ -212,7 +221,7 @@ class Appointment void endSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::AppointmentMethod::HasEndSelectionSet) + if constexpr (methods::AppointmentHas::endSelectionSet) { _pimpl->endSelectionSet(params); } @@ -222,7 +231,19 @@ class Appointment const std::shared_ptr _pimpl; }; - Appointment(std::unique_ptr&& pimpl); + Appointment(std::unique_ptr&& pimpl) noexcept; + + // Interface objects need access to these methods + friend Node; + + template + static constexpr bool implements() noexcept + { + return implements::AppointmentIs; + } + + service::TypeNames getTypeNames() const noexcept; + service::ResolverMap getResolvers() const noexcept; void beginSelectionSet(const service::SelectionSetParams& params) const final; void endSelectionSet(const service::SelectionSetParams& params) const final; @@ -231,7 +252,7 @@ class Appointment public: template - Appointment(std::shared_ptr pimpl) + Appointment(std::shared_ptr pimpl) noexcept : Appointment { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } diff --git a/samples/today/separate_nointrospection/CompleteTaskPayloadObject.cpp b/samples/today/separate_nointrospection/CompleteTaskPayloadObject.cpp index 0c8036f8..aca47fd0 100644 --- a/samples/today/separate_nointrospection/CompleteTaskPayloadObject.cpp +++ b/samples/today/separate_nointrospection/CompleteTaskPayloadObject.cpp @@ -18,16 +18,26 @@ using namespace std::literals; namespace graphql::today { namespace object { -CompleteTaskPayload::CompleteTaskPayload(std::unique_ptr&& pimpl) - : service::Object({ +CompleteTaskPayload::CompleteTaskPayload(std::unique_ptr&& pimpl) noexcept + : service::Object{ getTypeNames(), getResolvers() } + , _pimpl { std::move(pimpl) } +{ +} + +service::TypeNames CompleteTaskPayload::getTypeNames() const noexcept +{ + return { "CompleteTaskPayload" - }, { + }; +} + +service::ResolverMap CompleteTaskPayload::getResolvers() const noexcept +{ + return { { R"gql(task)gql"sv, [this](service::ResolverParams&& params) { return resolveTask(std::move(params)); } }, { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, { R"gql(clientMutationId)gql"sv, [this](service::ResolverParams&& params) { return resolveClientMutationId(std::move(params)); } } - }) - , _pimpl(std::move(pimpl)) -{ + }; } void CompleteTaskPayload::beginSelectionSet(const service::SelectionSetParams& params) const @@ -40,7 +50,7 @@ void CompleteTaskPayload::endSelectionSet(const service::SelectionSetParams& par _pimpl->endSelectionSet(params); } -service::AwaitableResolver CompleteTaskPayload::resolveTask(service::ResolverParams&& params) +service::AwaitableResolver CompleteTaskPayload::resolveTask(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -50,7 +60,7 @@ service::AwaitableResolver CompleteTaskPayload::resolveTask(service::ResolverPar return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver CompleteTaskPayload::resolveClientMutationId(service::ResolverParams&& params) +service::AwaitableResolver CompleteTaskPayload::resolveClientMutationId(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -60,14 +70,14 @@ service::AwaitableResolver CompleteTaskPayload::resolveClientMutationId(service: return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver CompleteTaskPayload::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver CompleteTaskPayload::resolve_typename(service::ResolverParams&& params) const { return service::ModifiedResult::convert(std::string{ R"gql(CompleteTaskPayload)gql" }, std::move(params)); } } // namespace object -void AddCompleteTaskPayloadDetails(std::shared_ptr typeCompleteTaskPayload, const std::shared_ptr& schema) +void AddCompleteTaskPayloadDetails(const std::shared_ptr& typeCompleteTaskPayload, const std::shared_ptr& schema) { typeCompleteTaskPayload->AddFields({ schema::Field::Make(R"gql(task)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType("Task")), diff --git a/samples/today/separate_nointrospection/CompleteTaskPayloadObject.h b/samples/today/separate_nointrospection/CompleteTaskPayloadObject.h index 3411230d..806cf182 100644 --- a/samples/today/separate_nointrospection/CompleteTaskPayloadObject.h +++ b/samples/today/separate_nointrospection/CompleteTaskPayloadObject.h @@ -11,54 +11,54 @@ #include "TodaySchema.h" namespace graphql::today::object { -namespace methods::CompleteTaskPayloadMethod { +namespace methods::CompleteTaskPayloadHas { template -concept WithParamsTask = requires (TImpl impl, service::FieldParams params) +concept getTaskWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getTask(std::move(params)) } }; }; template -concept NoParamsTask = requires (TImpl impl) +concept getTask = requires (TImpl impl) { { service::FieldResult> { impl.getTask() } }; }; template -concept WithParamsClientMutationId = requires (TImpl impl, service::FieldParams params) +concept getClientMutationIdWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getClientMutationId(std::move(params)) } }; }; template -concept NoParamsClientMutationId = requires (TImpl impl) +concept getClientMutationId = requires (TImpl impl) { { service::FieldResult> { impl.getClientMutationId() } }; }; template -concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.beginSelectionSet(params) }; }; template -concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.endSelectionSet(params) }; }; -} // namespace methods::CompleteTaskPayloadMethod +} // namespace methods::CompleteTaskPayloadHas class CompleteTaskPayload : public service::Object { private: - service::AwaitableResolver resolveTask(service::ResolverParams&& params); - service::AwaitableResolver resolveClientMutationId(service::ResolverParams&& params); + service::AwaitableResolver resolveTask(service::ResolverParams&& params) const; + service::AwaitableResolver resolveClientMutationId(service::ResolverParams&& params) const; - service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; struct Concept { @@ -82,11 +82,11 @@ class CompleteTaskPayload service::FieldResult> getTask(service::FieldParams&& params) const final { - if constexpr (methods::CompleteTaskPayloadMethod::WithParamsTask) + if constexpr (methods::CompleteTaskPayloadHas::getTaskWithParams) { return { _pimpl->getTask(std::move(params)) }; } - else if constexpr (methods::CompleteTaskPayloadMethod::NoParamsTask) + else if constexpr (methods::CompleteTaskPayloadHas::getTask) { return { _pimpl->getTask() }; } @@ -98,11 +98,11 @@ class CompleteTaskPayload service::FieldResult> getClientMutationId(service::FieldParams&& params) const final { - if constexpr (methods::CompleteTaskPayloadMethod::WithParamsClientMutationId) + if constexpr (methods::CompleteTaskPayloadHas::getClientMutationIdWithParams) { return { _pimpl->getClientMutationId(std::move(params)) }; } - else if constexpr (methods::CompleteTaskPayloadMethod::NoParamsClientMutationId) + else if constexpr (methods::CompleteTaskPayloadHas::getClientMutationId) { return { _pimpl->getClientMutationId() }; } @@ -114,7 +114,7 @@ class CompleteTaskPayload void beginSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::CompleteTaskPayloadMethod::HasBeginSelectionSet) + if constexpr (methods::CompleteTaskPayloadHas::beginSelectionSet) { _pimpl->beginSelectionSet(params); } @@ -122,7 +122,7 @@ class CompleteTaskPayload void endSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::CompleteTaskPayloadMethod::HasEndSelectionSet) + if constexpr (methods::CompleteTaskPayloadHas::endSelectionSet) { _pimpl->endSelectionSet(params); } @@ -132,7 +132,10 @@ class CompleteTaskPayload const std::shared_ptr _pimpl; }; - CompleteTaskPayload(std::unique_ptr&& pimpl); + CompleteTaskPayload(std::unique_ptr&& pimpl) noexcept; + + service::TypeNames getTypeNames() const noexcept; + service::ResolverMap getResolvers() const noexcept; void beginSelectionSet(const service::SelectionSetParams& params) const final; void endSelectionSet(const service::SelectionSetParams& params) const final; @@ -141,7 +144,7 @@ class CompleteTaskPayload public: template - CompleteTaskPayload(std::shared_ptr pimpl) + CompleteTaskPayload(std::shared_ptr pimpl) noexcept : CompleteTaskPayload { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } diff --git a/samples/today/separate_nointrospection/ExpensiveObject.cpp b/samples/today/separate_nointrospection/ExpensiveObject.cpp index 4e036d1f..ab1b1008 100644 --- a/samples/today/separate_nointrospection/ExpensiveObject.cpp +++ b/samples/today/separate_nointrospection/ExpensiveObject.cpp @@ -18,15 +18,25 @@ using namespace std::literals; namespace graphql::today { namespace object { -Expensive::Expensive(std::unique_ptr&& pimpl) - : service::Object({ +Expensive::Expensive(std::unique_ptr&& pimpl) noexcept + : service::Object{ getTypeNames(), getResolvers() } + , _pimpl { std::move(pimpl) } +{ +} + +service::TypeNames Expensive::getTypeNames() const noexcept +{ + return { "Expensive" - }, { + }; +} + +service::ResolverMap Expensive::getResolvers() const noexcept +{ + return { { R"gql(order)gql"sv, [this](service::ResolverParams&& params) { return resolveOrder(std::move(params)); } }, { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } } - }) - , _pimpl(std::move(pimpl)) -{ + }; } void Expensive::beginSelectionSet(const service::SelectionSetParams& params) const @@ -39,7 +49,7 @@ void Expensive::endSelectionSet(const service::SelectionSetParams& params) const _pimpl->endSelectionSet(params); } -service::AwaitableResolver Expensive::resolveOrder(service::ResolverParams&& params) +service::AwaitableResolver Expensive::resolveOrder(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -49,14 +59,14 @@ service::AwaitableResolver Expensive::resolveOrder(service::ResolverParams&& par return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Expensive::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver Expensive::resolve_typename(service::ResolverParams&& params) const { return service::ModifiedResult::convert(std::string{ R"gql(Expensive)gql" }, std::move(params)); } } // namespace object -void AddExpensiveDetails(std::shared_ptr typeExpensive, const std::shared_ptr& schema) +void AddExpensiveDetails(const std::shared_ptr& typeExpensive, const std::shared_ptr& schema) { typeExpensive->AddFields({ schema::Field::Make(R"gql(order)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("Int"))) diff --git a/samples/today/separate_nointrospection/ExpensiveObject.h b/samples/today/separate_nointrospection/ExpensiveObject.h index 7fd5d538..920d34d5 100644 --- a/samples/today/separate_nointrospection/ExpensiveObject.h +++ b/samples/today/separate_nointrospection/ExpensiveObject.h @@ -11,41 +11,41 @@ #include "TodaySchema.h" namespace graphql::today::object { -namespace methods::ExpensiveMethod { +namespace methods::ExpensiveHas { template -concept WithParamsOrder = requires (TImpl impl, service::FieldParams params) +concept getOrderWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getOrder(std::move(params)) } }; }; template -concept NoParamsOrder = requires (TImpl impl) +concept getOrder = requires (TImpl impl) { { service::FieldResult { impl.getOrder() } }; }; template -concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.beginSelectionSet(params) }; }; template -concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.endSelectionSet(params) }; }; -} // namespace methods::ExpensiveMethod +} // namespace methods::ExpensiveHas class Expensive : public service::Object { private: - service::AwaitableResolver resolveOrder(service::ResolverParams&& params); + service::AwaitableResolver resolveOrder(service::ResolverParams&& params) const; - service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; struct Concept { @@ -68,11 +68,11 @@ class Expensive service::FieldResult getOrder(service::FieldParams&& params) const final { - if constexpr (methods::ExpensiveMethod::WithParamsOrder) + if constexpr (methods::ExpensiveHas::getOrderWithParams) { return { _pimpl->getOrder(std::move(params)) }; } - else if constexpr (methods::ExpensiveMethod::NoParamsOrder) + else if constexpr (methods::ExpensiveHas::getOrder) { return { _pimpl->getOrder() }; } @@ -84,7 +84,7 @@ class Expensive void beginSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::ExpensiveMethod::HasBeginSelectionSet) + if constexpr (methods::ExpensiveHas::beginSelectionSet) { _pimpl->beginSelectionSet(params); } @@ -92,7 +92,7 @@ class Expensive void endSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::ExpensiveMethod::HasEndSelectionSet) + if constexpr (methods::ExpensiveHas::endSelectionSet) { _pimpl->endSelectionSet(params); } @@ -102,7 +102,10 @@ class Expensive const std::shared_ptr _pimpl; }; - Expensive(std::unique_ptr&& pimpl); + Expensive(std::unique_ptr&& pimpl) noexcept; + + service::TypeNames getTypeNames() const noexcept; + service::ResolverMap getResolvers() const noexcept; void beginSelectionSet(const service::SelectionSetParams& params) const final; void endSelectionSet(const service::SelectionSetParams& params) const final; @@ -111,7 +114,7 @@ class Expensive public: template - Expensive(std::shared_ptr pimpl) + Expensive(std::shared_ptr pimpl) noexcept : Expensive { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } diff --git a/samples/today/separate_nointrospection/FolderConnectionObject.cpp b/samples/today/separate_nointrospection/FolderConnectionObject.cpp index b47dd28d..1408c541 100644 --- a/samples/today/separate_nointrospection/FolderConnectionObject.cpp +++ b/samples/today/separate_nointrospection/FolderConnectionObject.cpp @@ -18,16 +18,26 @@ using namespace std::literals; namespace graphql::today { namespace object { -FolderConnection::FolderConnection(std::unique_ptr&& pimpl) - : service::Object({ +FolderConnection::FolderConnection(std::unique_ptr&& pimpl) noexcept + : service::Object{ getTypeNames(), getResolvers() } + , _pimpl { std::move(pimpl) } +{ +} + +service::TypeNames FolderConnection::getTypeNames() const noexcept +{ + return { "FolderConnection" - }, { + }; +} + +service::ResolverMap FolderConnection::getResolvers() const noexcept +{ + return { { R"gql(edges)gql"sv, [this](service::ResolverParams&& params) { return resolveEdges(std::move(params)); } }, { R"gql(pageInfo)gql"sv, [this](service::ResolverParams&& params) { return resolvePageInfo(std::move(params)); } }, { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } } - }) - , _pimpl(std::move(pimpl)) -{ + }; } void FolderConnection::beginSelectionSet(const service::SelectionSetParams& params) const @@ -40,7 +50,7 @@ void FolderConnection::endSelectionSet(const service::SelectionSetParams& params _pimpl->endSelectionSet(params); } -service::AwaitableResolver FolderConnection::resolvePageInfo(service::ResolverParams&& params) +service::AwaitableResolver FolderConnection::resolvePageInfo(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -50,7 +60,7 @@ service::AwaitableResolver FolderConnection::resolvePageInfo(service::ResolverPa return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver FolderConnection::resolveEdges(service::ResolverParams&& params) +service::AwaitableResolver FolderConnection::resolveEdges(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -60,14 +70,14 @@ service::AwaitableResolver FolderConnection::resolveEdges(service::ResolverParam return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver FolderConnection::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver FolderConnection::resolve_typename(service::ResolverParams&& params) const { return service::ModifiedResult::convert(std::string{ R"gql(FolderConnection)gql" }, std::move(params)); } } // namespace object -void AddFolderConnectionDetails(std::shared_ptr typeFolderConnection, const std::shared_ptr& schema) +void AddFolderConnectionDetails(const std::shared_ptr& typeFolderConnection, const std::shared_ptr& schema) { typeFolderConnection->AddFields({ schema::Field::Make(R"gql(pageInfo)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("PageInfo"))), diff --git a/samples/today/separate_nointrospection/FolderConnectionObject.h b/samples/today/separate_nointrospection/FolderConnectionObject.h index f1dc10b1..d2de2dea 100644 --- a/samples/today/separate_nointrospection/FolderConnectionObject.h +++ b/samples/today/separate_nointrospection/FolderConnectionObject.h @@ -11,54 +11,54 @@ #include "TodaySchema.h" namespace graphql::today::object { -namespace methods::FolderConnectionMethod { +namespace methods::FolderConnectionHas { template -concept WithParamsPageInfo = requires (TImpl impl, service::FieldParams params) +concept getPageInfoWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getPageInfo(std::move(params)) } }; }; template -concept NoParamsPageInfo = requires (TImpl impl) +concept getPageInfo = requires (TImpl impl) { { service::FieldResult> { impl.getPageInfo() } }; }; template -concept WithParamsEdges = requires (TImpl impl, service::FieldParams params) +concept getEdgesWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult>>> { impl.getEdges(std::move(params)) } }; }; template -concept NoParamsEdges = requires (TImpl impl) +concept getEdges = requires (TImpl impl) { { service::FieldResult>>> { impl.getEdges() } }; }; template -concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.beginSelectionSet(params) }; }; template -concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.endSelectionSet(params) }; }; -} // namespace methods::FolderConnectionMethod +} // namespace methods::FolderConnectionHas class FolderConnection : public service::Object { private: - service::AwaitableResolver resolvePageInfo(service::ResolverParams&& params); - service::AwaitableResolver resolveEdges(service::ResolverParams&& params); + service::AwaitableResolver resolvePageInfo(service::ResolverParams&& params) const; + service::AwaitableResolver resolveEdges(service::ResolverParams&& params) const; - service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; struct Concept { @@ -82,11 +82,11 @@ class FolderConnection service::FieldResult> getPageInfo(service::FieldParams&& params) const final { - if constexpr (methods::FolderConnectionMethod::WithParamsPageInfo) + if constexpr (methods::FolderConnectionHas::getPageInfoWithParams) { return { _pimpl->getPageInfo(std::move(params)) }; } - else if constexpr (methods::FolderConnectionMethod::NoParamsPageInfo) + else if constexpr (methods::FolderConnectionHas::getPageInfo) { return { _pimpl->getPageInfo() }; } @@ -98,11 +98,11 @@ class FolderConnection service::FieldResult>>> getEdges(service::FieldParams&& params) const final { - if constexpr (methods::FolderConnectionMethod::WithParamsEdges) + if constexpr (methods::FolderConnectionHas::getEdgesWithParams) { return { _pimpl->getEdges(std::move(params)) }; } - else if constexpr (methods::FolderConnectionMethod::NoParamsEdges) + else if constexpr (methods::FolderConnectionHas::getEdges) { return { _pimpl->getEdges() }; } @@ -114,7 +114,7 @@ class FolderConnection void beginSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::FolderConnectionMethod::HasBeginSelectionSet) + if constexpr (methods::FolderConnectionHas::beginSelectionSet) { _pimpl->beginSelectionSet(params); } @@ -122,7 +122,7 @@ class FolderConnection void endSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::FolderConnectionMethod::HasEndSelectionSet) + if constexpr (methods::FolderConnectionHas::endSelectionSet) { _pimpl->endSelectionSet(params); } @@ -132,7 +132,10 @@ class FolderConnection const std::shared_ptr _pimpl; }; - FolderConnection(std::unique_ptr&& pimpl); + FolderConnection(std::unique_ptr&& pimpl) noexcept; + + service::TypeNames getTypeNames() const noexcept; + service::ResolverMap getResolvers() const noexcept; void beginSelectionSet(const service::SelectionSetParams& params) const final; void endSelectionSet(const service::SelectionSetParams& params) const final; @@ -141,7 +144,7 @@ class FolderConnection public: template - FolderConnection(std::shared_ptr pimpl) + FolderConnection(std::shared_ptr pimpl) noexcept : FolderConnection { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } diff --git a/samples/today/separate_nointrospection/FolderEdgeObject.cpp b/samples/today/separate_nointrospection/FolderEdgeObject.cpp index 95ed2c21..6022c600 100644 --- a/samples/today/separate_nointrospection/FolderEdgeObject.cpp +++ b/samples/today/separate_nointrospection/FolderEdgeObject.cpp @@ -18,16 +18,26 @@ using namespace std::literals; namespace graphql::today { namespace object { -FolderEdge::FolderEdge(std::unique_ptr&& pimpl) - : service::Object({ +FolderEdge::FolderEdge(std::unique_ptr&& pimpl) noexcept + : service::Object{ getTypeNames(), getResolvers() } + , _pimpl { std::move(pimpl) } +{ +} + +service::TypeNames FolderEdge::getTypeNames() const noexcept +{ + return { "FolderEdge" - }, { + }; +} + +service::ResolverMap FolderEdge::getResolvers() const noexcept +{ + return { { R"gql(node)gql"sv, [this](service::ResolverParams&& params) { return resolveNode(std::move(params)); } }, { R"gql(cursor)gql"sv, [this](service::ResolverParams&& params) { return resolveCursor(std::move(params)); } }, { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } } - }) - , _pimpl(std::move(pimpl)) -{ + }; } void FolderEdge::beginSelectionSet(const service::SelectionSetParams& params) const @@ -40,7 +50,7 @@ void FolderEdge::endSelectionSet(const service::SelectionSetParams& params) cons _pimpl->endSelectionSet(params); } -service::AwaitableResolver FolderEdge::resolveNode(service::ResolverParams&& params) +service::AwaitableResolver FolderEdge::resolveNode(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -50,7 +60,7 @@ service::AwaitableResolver FolderEdge::resolveNode(service::ResolverParams&& par return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver FolderEdge::resolveCursor(service::ResolverParams&& params) +service::AwaitableResolver FolderEdge::resolveCursor(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -60,14 +70,14 @@ service::AwaitableResolver FolderEdge::resolveCursor(service::ResolverParams&& p return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver FolderEdge::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver FolderEdge::resolve_typename(service::ResolverParams&& params) const { return service::ModifiedResult::convert(std::string{ R"gql(FolderEdge)gql" }, std::move(params)); } } // namespace object -void AddFolderEdgeDetails(std::shared_ptr typeFolderEdge, const std::shared_ptr& schema) +void AddFolderEdgeDetails(const std::shared_ptr& typeFolderEdge, const std::shared_ptr& schema) { typeFolderEdge->AddFields({ schema::Field::Make(R"gql(node)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType("Folder")), diff --git a/samples/today/separate_nointrospection/FolderEdgeObject.h b/samples/today/separate_nointrospection/FolderEdgeObject.h index 6fbd7499..993f0c3c 100644 --- a/samples/today/separate_nointrospection/FolderEdgeObject.h +++ b/samples/today/separate_nointrospection/FolderEdgeObject.h @@ -11,54 +11,54 @@ #include "TodaySchema.h" namespace graphql::today::object { -namespace methods::FolderEdgeMethod { +namespace methods::FolderEdgeHas { template -concept WithParamsNode = requires (TImpl impl, service::FieldParams params) +concept getNodeWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getNode(std::move(params)) } }; }; template -concept NoParamsNode = requires (TImpl impl) +concept getNode = requires (TImpl impl) { { service::FieldResult> { impl.getNode() } }; }; template -concept WithParamsCursor = requires (TImpl impl, service::FieldParams params) +concept getCursorWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getCursor(std::move(params)) } }; }; template -concept NoParamsCursor = requires (TImpl impl) +concept getCursor = requires (TImpl impl) { { service::FieldResult { impl.getCursor() } }; }; template -concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.beginSelectionSet(params) }; }; template -concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.endSelectionSet(params) }; }; -} // namespace methods::FolderEdgeMethod +} // namespace methods::FolderEdgeHas class FolderEdge : public service::Object { private: - service::AwaitableResolver resolveNode(service::ResolverParams&& params); - service::AwaitableResolver resolveCursor(service::ResolverParams&& params); + service::AwaitableResolver resolveNode(service::ResolverParams&& params) const; + service::AwaitableResolver resolveCursor(service::ResolverParams&& params) const; - service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; struct Concept { @@ -82,11 +82,11 @@ class FolderEdge service::FieldResult> getNode(service::FieldParams&& params) const final { - if constexpr (methods::FolderEdgeMethod::WithParamsNode) + if constexpr (methods::FolderEdgeHas::getNodeWithParams) { return { _pimpl->getNode(std::move(params)) }; } - else if constexpr (methods::FolderEdgeMethod::NoParamsNode) + else if constexpr (methods::FolderEdgeHas::getNode) { return { _pimpl->getNode() }; } @@ -98,11 +98,11 @@ class FolderEdge service::FieldResult getCursor(service::FieldParams&& params) const final { - if constexpr (methods::FolderEdgeMethod::WithParamsCursor) + if constexpr (methods::FolderEdgeHas::getCursorWithParams) { return { _pimpl->getCursor(std::move(params)) }; } - else if constexpr (methods::FolderEdgeMethod::NoParamsCursor) + else if constexpr (methods::FolderEdgeHas::getCursor) { return { _pimpl->getCursor() }; } @@ -114,7 +114,7 @@ class FolderEdge void beginSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::FolderEdgeMethod::HasBeginSelectionSet) + if constexpr (methods::FolderEdgeHas::beginSelectionSet) { _pimpl->beginSelectionSet(params); } @@ -122,7 +122,7 @@ class FolderEdge void endSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::FolderEdgeMethod::HasEndSelectionSet) + if constexpr (methods::FolderEdgeHas::endSelectionSet) { _pimpl->endSelectionSet(params); } @@ -132,7 +132,10 @@ class FolderEdge const std::shared_ptr _pimpl; }; - FolderEdge(std::unique_ptr&& pimpl); + FolderEdge(std::unique_ptr&& pimpl) noexcept; + + service::TypeNames getTypeNames() const noexcept; + service::ResolverMap getResolvers() const noexcept; void beginSelectionSet(const service::SelectionSetParams& params) const final; void endSelectionSet(const service::SelectionSetParams& params) const final; @@ -141,7 +144,7 @@ class FolderEdge public: template - FolderEdge(std::shared_ptr pimpl) + FolderEdge(std::shared_ptr pimpl) noexcept : FolderEdge { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } diff --git a/samples/today/separate_nointrospection/FolderObject.cpp b/samples/today/separate_nointrospection/FolderObject.cpp index dfe25974..8c7406a2 100644 --- a/samples/today/separate_nointrospection/FolderObject.cpp +++ b/samples/today/separate_nointrospection/FolderObject.cpp @@ -18,19 +18,29 @@ using namespace std::literals; namespace graphql::today { namespace object { -Folder::Folder(std::unique_ptr&& pimpl) - : service::Object({ +Folder::Folder(std::unique_ptr&& pimpl) noexcept + : service::Object{ getTypeNames(), getResolvers() } + , _pimpl { std::move(pimpl) } +{ +} + +service::TypeNames Folder::getTypeNames() const noexcept +{ + return { "Node", "UnionType", "Folder" - }, { + }; +} + +service::ResolverMap Folder::getResolvers() const noexcept +{ + return { { R"gql(id)gql"sv, [this](service::ResolverParams&& params) { return resolveId(std::move(params)); } }, { R"gql(name)gql"sv, [this](service::ResolverParams&& params) { return resolveName(std::move(params)); } }, { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, { R"gql(unreadCount)gql"sv, [this](service::ResolverParams&& params) { return resolveUnreadCount(std::move(params)); } } - }) - , _pimpl(std::move(pimpl)) -{ + }; } void Folder::beginSelectionSet(const service::SelectionSetParams& params) const @@ -43,7 +53,7 @@ void Folder::endSelectionSet(const service::SelectionSetParams& params) const _pimpl->endSelectionSet(params); } -service::AwaitableResolver Folder::resolveId(service::ResolverParams&& params) +service::AwaitableResolver Folder::resolveId(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -53,7 +63,7 @@ service::AwaitableResolver Folder::resolveId(service::ResolverParams&& params) return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Folder::resolveName(service::ResolverParams&& params) +service::AwaitableResolver Folder::resolveName(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -63,7 +73,7 @@ service::AwaitableResolver Folder::resolveName(service::ResolverParams&& params) return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Folder::resolveUnreadCount(service::ResolverParams&& params) +service::AwaitableResolver Folder::resolveUnreadCount(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -73,14 +83,14 @@ service::AwaitableResolver Folder::resolveUnreadCount(service::ResolverParams&& return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Folder::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver Folder::resolve_typename(service::ResolverParams&& params) const { return service::ModifiedResult::convert(std::string{ R"gql(Folder)gql" }, std::move(params)); } } // namespace object -void AddFolderDetails(std::shared_ptr typeFolder, const std::shared_ptr& schema) +void AddFolderDetails(const std::shared_ptr& typeFolder, const std::shared_ptr& schema) { typeFolder->AddInterfaces({ std::static_pointer_cast(schema->LookupType(R"gql(Node)gql"sv)) diff --git a/samples/today/separate_nointrospection/FolderObject.h b/samples/today/separate_nointrospection/FolderObject.h index 940f1190..38fe33d4 100644 --- a/samples/today/separate_nointrospection/FolderObject.h +++ b/samples/today/separate_nointrospection/FolderObject.h @@ -10,77 +10,86 @@ #include "TodaySchema.h" +#include "NodeObject.h" + namespace graphql::today::object { -namespace methods::FolderMethod { +namespace implements { + +template +concept FolderIs = std::is_same_v; + +} // namespace implements + +namespace methods::FolderHas { template -concept WithParamsId = requires (TImpl impl, service::FieldParams params) +concept getIdWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getId(std::move(params)) } }; }; template -concept NoParamsId = requires (TImpl impl) +concept getId = requires (TImpl impl) { { service::FieldResult { impl.getId() } }; }; template -concept WithParamsName = requires (TImpl impl, service::FieldParams params) +concept getNameWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getName(std::move(params)) } }; }; template -concept NoParamsName = requires (TImpl impl) +concept getName = requires (TImpl impl) { { service::FieldResult> { impl.getName() } }; }; template -concept WithParamsUnreadCount = requires (TImpl impl, service::FieldParams params) +concept getUnreadCountWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getUnreadCount(std::move(params)) } }; }; template -concept NoParamsUnreadCount = requires (TImpl impl) +concept getUnreadCount = requires (TImpl impl) { { service::FieldResult { impl.getUnreadCount() } }; }; template -concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.beginSelectionSet(params) }; }; template -concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.endSelectionSet(params) }; }; -} // namespace methods::FolderMethod +} // namespace methods::FolderHas class Folder : public service::Object { private: - service::AwaitableResolver resolveId(service::ResolverParams&& params); - service::AwaitableResolver resolveName(service::ResolverParams&& params); - service::AwaitableResolver resolveUnreadCount(service::ResolverParams&& params); + service::AwaitableResolver resolveId(service::ResolverParams&& params) const; + service::AwaitableResolver resolveName(service::ResolverParams&& params) const; + service::AwaitableResolver resolveUnreadCount(service::ResolverParams&& params) const; - service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; struct Concept - : Node { virtual ~Concept() = default; virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual service::FieldResult getId(service::FieldParams&& params) const = 0; virtual service::FieldResult> getName(service::FieldParams&& params) const = 0; virtual service::FieldResult getUnreadCount(service::FieldParams&& params) const = 0; }; @@ -96,11 +105,11 @@ class Folder service::FieldResult getId(service::FieldParams&& params) const final { - if constexpr (methods::FolderMethod::WithParamsId) + if constexpr (methods::FolderHas::getIdWithParams) { return { _pimpl->getId(std::move(params)) }; } - else if constexpr (methods::FolderMethod::NoParamsId) + else if constexpr (methods::FolderHas::getId) { return { _pimpl->getId() }; } @@ -112,11 +121,11 @@ class Folder service::FieldResult> getName(service::FieldParams&& params) const final { - if constexpr (methods::FolderMethod::WithParamsName) + if constexpr (methods::FolderHas::getNameWithParams) { return { _pimpl->getName(std::move(params)) }; } - else if constexpr (methods::FolderMethod::NoParamsName) + else if constexpr (methods::FolderHas::getName) { return { _pimpl->getName() }; } @@ -128,11 +137,11 @@ class Folder service::FieldResult getUnreadCount(service::FieldParams&& params) const final { - if constexpr (methods::FolderMethod::WithParamsUnreadCount) + if constexpr (methods::FolderHas::getUnreadCountWithParams) { return { _pimpl->getUnreadCount(std::move(params)) }; } - else if constexpr (methods::FolderMethod::NoParamsUnreadCount) + else if constexpr (methods::FolderHas::getUnreadCount) { return { _pimpl->getUnreadCount() }; } @@ -144,7 +153,7 @@ class Folder void beginSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::FolderMethod::HasBeginSelectionSet) + if constexpr (methods::FolderHas::beginSelectionSet) { _pimpl->beginSelectionSet(params); } @@ -152,7 +161,7 @@ class Folder void endSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::FolderMethod::HasEndSelectionSet) + if constexpr (methods::FolderHas::endSelectionSet) { _pimpl->endSelectionSet(params); } @@ -162,7 +171,19 @@ class Folder const std::shared_ptr _pimpl; }; - Folder(std::unique_ptr&& pimpl); + Folder(std::unique_ptr&& pimpl) noexcept; + + // Interface objects need access to these methods + friend Node; + + template + static constexpr bool implements() noexcept + { + return implements::FolderIs; + } + + service::TypeNames getTypeNames() const noexcept; + service::ResolverMap getResolvers() const noexcept; void beginSelectionSet(const service::SelectionSetParams& params) const final; void endSelectionSet(const service::SelectionSetParams& params) const final; @@ -171,7 +192,7 @@ class Folder public: template - Folder(std::shared_ptr pimpl) + Folder(std::shared_ptr pimpl) noexcept : Folder { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } diff --git a/samples/today/separate_nointrospection/MutationObject.cpp b/samples/today/separate_nointrospection/MutationObject.cpp index 5d80c817..a0ed9b90 100644 --- a/samples/today/separate_nointrospection/MutationObject.cpp +++ b/samples/today/separate_nointrospection/MutationObject.cpp @@ -18,16 +18,26 @@ using namespace std::literals; namespace graphql::today { namespace object { -Mutation::Mutation(std::unique_ptr&& pimpl) - : service::Object({ +Mutation::Mutation(std::unique_ptr&& pimpl) noexcept + : service::Object{ getTypeNames(), getResolvers() } + , _pimpl { std::move(pimpl) } +{ +} + +service::TypeNames Mutation::getTypeNames() const noexcept +{ + return { "Mutation" - }, { + }; +} + +service::ResolverMap Mutation::getResolvers() const noexcept +{ + return { { R"gql(setFloat)gql"sv, [this](service::ResolverParams&& params) { return resolveSetFloat(std::move(params)); } }, { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, { R"gql(completeTask)gql"sv, [this](service::ResolverParams&& params) { return resolveCompleteTask(std::move(params)); } } - }) - , _pimpl(std::move(pimpl)) -{ + }; } void Mutation::beginSelectionSet(const service::SelectionSetParams& params) const @@ -40,7 +50,7 @@ void Mutation::endSelectionSet(const service::SelectionSetParams& params) const _pimpl->endSelectionSet(params); } -service::AwaitableResolver Mutation::resolveCompleteTask(service::ResolverParams&& params) +service::AwaitableResolver Mutation::resolveCompleteTask(service::ResolverParams&& params) const { auto argInput = service::ModifiedArgument::require("input", params.arguments); std::unique_lock resolverLock(_resolverMutex); @@ -51,7 +61,7 @@ service::AwaitableResolver Mutation::resolveCompleteTask(service::ResolverParams return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Mutation::resolveSetFloat(service::ResolverParams&& params) +service::AwaitableResolver Mutation::resolveSetFloat(service::ResolverParams&& params) const { auto argValue = service::ModifiedArgument::require("value", params.arguments); std::unique_lock resolverLock(_resolverMutex); @@ -62,14 +72,14 @@ service::AwaitableResolver Mutation::resolveSetFloat(service::ResolverParams&& p return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Mutation::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver Mutation::resolve_typename(service::ResolverParams&& params) const { return service::ModifiedResult::convert(std::string{ R"gql(Mutation)gql" }, std::move(params)); } } // namespace object -void AddMutationDetails(std::shared_ptr typeMutation, const std::shared_ptr& schema) +void AddMutationDetails(const std::shared_ptr& typeMutation, const std::shared_ptr& schema) { typeMutation->AddFields({ schema::Field::Make(R"gql(completeTask)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("CompleteTaskPayload")), { diff --git a/samples/today/separate_nointrospection/MutationObject.h b/samples/today/separate_nointrospection/MutationObject.h index c78f0ac3..f9ecb4b8 100644 --- a/samples/today/separate_nointrospection/MutationObject.h +++ b/samples/today/separate_nointrospection/MutationObject.h @@ -11,54 +11,54 @@ #include "TodaySchema.h" namespace graphql::today::object { -namespace methods::MutationMethod { +namespace methods::MutationHas { template -concept WithParamsCompleteTask = requires (TImpl impl, service::FieldParams params, CompleteTaskInput inputArg) +concept applyCompleteTaskWithParams = requires (TImpl impl, service::FieldParams params, CompleteTaskInput inputArg) { { service::FieldResult> { impl.applyCompleteTask(std::move(params), std::move(inputArg)) } }; }; template -concept NoParamsCompleteTask = requires (TImpl impl, CompleteTaskInput inputArg) +concept applyCompleteTask = requires (TImpl impl, CompleteTaskInput inputArg) { { service::FieldResult> { impl.applyCompleteTask(std::move(inputArg)) } }; }; template -concept WithParamsSetFloat = requires (TImpl impl, service::FieldParams params, double valueArg) +concept applySetFloatWithParams = requires (TImpl impl, service::FieldParams params, double valueArg) { { service::FieldResult { impl.applySetFloat(std::move(params), std::move(valueArg)) } }; }; template -concept NoParamsSetFloat = requires (TImpl impl, double valueArg) +concept applySetFloat = requires (TImpl impl, double valueArg) { { service::FieldResult { impl.applySetFloat(std::move(valueArg)) } }; }; template -concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.beginSelectionSet(params) }; }; template -concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.endSelectionSet(params) }; }; -} // namespace methods::MutationMethod +} // namespace methods::MutationHas class Mutation : public service::Object { private: - service::AwaitableResolver resolveCompleteTask(service::ResolverParams&& params); - service::AwaitableResolver resolveSetFloat(service::ResolverParams&& params); + service::AwaitableResolver resolveCompleteTask(service::ResolverParams&& params) const; + service::AwaitableResolver resolveSetFloat(service::ResolverParams&& params) const; - service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; struct Concept { @@ -82,11 +82,11 @@ class Mutation service::FieldResult> applyCompleteTask(service::FieldParams&& params, CompleteTaskInput&& inputArg) const final { - if constexpr (methods::MutationMethod::WithParamsCompleteTask) + if constexpr (methods::MutationHas::applyCompleteTaskWithParams) { return { _pimpl->applyCompleteTask(std::move(params), std::move(inputArg)) }; } - else if constexpr (methods::MutationMethod::NoParamsCompleteTask) + else if constexpr (methods::MutationHas::applyCompleteTask) { return { _pimpl->applyCompleteTask(std::move(inputArg)) }; } @@ -98,11 +98,11 @@ class Mutation service::FieldResult applySetFloat(service::FieldParams&& params, double&& valueArg) const final { - if constexpr (methods::MutationMethod::WithParamsSetFloat) + if constexpr (methods::MutationHas::applySetFloatWithParams) { return { _pimpl->applySetFloat(std::move(params), std::move(valueArg)) }; } - else if constexpr (methods::MutationMethod::NoParamsSetFloat) + else if constexpr (methods::MutationHas::applySetFloat) { return { _pimpl->applySetFloat(std::move(valueArg)) }; } @@ -114,7 +114,7 @@ class Mutation void beginSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::MutationMethod::HasBeginSelectionSet) + if constexpr (methods::MutationHas::beginSelectionSet) { _pimpl->beginSelectionSet(params); } @@ -122,7 +122,7 @@ class Mutation void endSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::MutationMethod::HasEndSelectionSet) + if constexpr (methods::MutationHas::endSelectionSet) { _pimpl->endSelectionSet(params); } @@ -132,7 +132,10 @@ class Mutation const std::shared_ptr _pimpl; }; - Mutation(std::unique_ptr&& pimpl); + Mutation(std::unique_ptr&& pimpl) noexcept; + + service::TypeNames getTypeNames() const noexcept; + service::ResolverMap getResolvers() const noexcept; void beginSelectionSet(const service::SelectionSetParams& params) const final; void endSelectionSet(const service::SelectionSetParams& params) const final; @@ -141,7 +144,7 @@ class Mutation public: template - Mutation(std::shared_ptr pimpl) + Mutation(std::shared_ptr pimpl) noexcept : Mutation { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } diff --git a/samples/today/separate_nointrospection/NestedTypeObject.cpp b/samples/today/separate_nointrospection/NestedTypeObject.cpp index acb8adb4..4d8c7a94 100644 --- a/samples/today/separate_nointrospection/NestedTypeObject.cpp +++ b/samples/today/separate_nointrospection/NestedTypeObject.cpp @@ -18,16 +18,26 @@ using namespace std::literals; namespace graphql::today { namespace object { -NestedType::NestedType(std::unique_ptr&& pimpl) - : service::Object({ +NestedType::NestedType(std::unique_ptr&& pimpl) noexcept + : service::Object{ getTypeNames(), getResolvers() } + , _pimpl { std::move(pimpl) } +{ +} + +service::TypeNames NestedType::getTypeNames() const noexcept +{ + return { "NestedType" - }, { + }; +} + +service::ResolverMap NestedType::getResolvers() const noexcept +{ + return { { R"gql(depth)gql"sv, [this](service::ResolverParams&& params) { return resolveDepth(std::move(params)); } }, { R"gql(nested)gql"sv, [this](service::ResolverParams&& params) { return resolveNested(std::move(params)); } }, { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } } - }) - , _pimpl(std::move(pimpl)) -{ + }; } void NestedType::beginSelectionSet(const service::SelectionSetParams& params) const @@ -40,7 +50,7 @@ void NestedType::endSelectionSet(const service::SelectionSetParams& params) cons _pimpl->endSelectionSet(params); } -service::AwaitableResolver NestedType::resolveDepth(service::ResolverParams&& params) +service::AwaitableResolver NestedType::resolveDepth(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -50,7 +60,7 @@ service::AwaitableResolver NestedType::resolveDepth(service::ResolverParams&& pa return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver NestedType::resolveNested(service::ResolverParams&& params) +service::AwaitableResolver NestedType::resolveNested(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -60,14 +70,14 @@ service::AwaitableResolver NestedType::resolveNested(service::ResolverParams&& p return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver NestedType::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver NestedType::resolve_typename(service::ResolverParams&& params) const { return service::ModifiedResult::convert(std::string{ R"gql(NestedType)gql" }, std::move(params)); } } // namespace object -void AddNestedTypeDetails(std::shared_ptr typeNestedType, const std::shared_ptr& schema) +void AddNestedTypeDetails(const std::shared_ptr& typeNestedType, const std::shared_ptr& schema) { typeNestedType->AddFields({ schema::Field::Make(R"gql(depth)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("Int"))), diff --git a/samples/today/separate_nointrospection/NestedTypeObject.h b/samples/today/separate_nointrospection/NestedTypeObject.h index 3ef0292a..6215cf06 100644 --- a/samples/today/separate_nointrospection/NestedTypeObject.h +++ b/samples/today/separate_nointrospection/NestedTypeObject.h @@ -11,54 +11,54 @@ #include "TodaySchema.h" namespace graphql::today::object { -namespace methods::NestedTypeMethod { +namespace methods::NestedTypeHas { template -concept WithParamsDepth = requires (TImpl impl, service::FieldParams params) +concept getDepthWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getDepth(std::move(params)) } }; }; template -concept NoParamsDepth = requires (TImpl impl) +concept getDepth = requires (TImpl impl) { { service::FieldResult { impl.getDepth() } }; }; template -concept WithParamsNested = requires (TImpl impl, service::FieldParams params) +concept getNestedWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getNested(std::move(params)) } }; }; template -concept NoParamsNested = requires (TImpl impl) +concept getNested = requires (TImpl impl) { { service::FieldResult> { impl.getNested() } }; }; template -concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.beginSelectionSet(params) }; }; template -concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.endSelectionSet(params) }; }; -} // namespace methods::NestedTypeMethod +} // namespace methods::NestedTypeHas class NestedType : public service::Object { private: - service::AwaitableResolver resolveDepth(service::ResolverParams&& params); - service::AwaitableResolver resolveNested(service::ResolverParams&& params); + service::AwaitableResolver resolveDepth(service::ResolverParams&& params) const; + service::AwaitableResolver resolveNested(service::ResolverParams&& params) const; - service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; struct Concept { @@ -82,11 +82,11 @@ class NestedType service::FieldResult getDepth(service::FieldParams&& params) const final { - if constexpr (methods::NestedTypeMethod::WithParamsDepth) + if constexpr (methods::NestedTypeHas::getDepthWithParams) { return { _pimpl->getDepth(std::move(params)) }; } - else if constexpr (methods::NestedTypeMethod::NoParamsDepth) + else if constexpr (methods::NestedTypeHas::getDepth) { return { _pimpl->getDepth() }; } @@ -98,11 +98,11 @@ class NestedType service::FieldResult> getNested(service::FieldParams&& params) const final { - if constexpr (methods::NestedTypeMethod::WithParamsNested) + if constexpr (methods::NestedTypeHas::getNestedWithParams) { return { _pimpl->getNested(std::move(params)) }; } - else if constexpr (methods::NestedTypeMethod::NoParamsNested) + else if constexpr (methods::NestedTypeHas::getNested) { return { _pimpl->getNested() }; } @@ -114,7 +114,7 @@ class NestedType void beginSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::NestedTypeMethod::HasBeginSelectionSet) + if constexpr (methods::NestedTypeHas::beginSelectionSet) { _pimpl->beginSelectionSet(params); } @@ -122,7 +122,7 @@ class NestedType void endSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::NestedTypeMethod::HasEndSelectionSet) + if constexpr (methods::NestedTypeHas::endSelectionSet) { _pimpl->endSelectionSet(params); } @@ -132,7 +132,10 @@ class NestedType const std::shared_ptr _pimpl; }; - NestedType(std::unique_ptr&& pimpl); + NestedType(std::unique_ptr&& pimpl) noexcept; + + service::TypeNames getTypeNames() const noexcept; + service::ResolverMap getResolvers() const noexcept; void beginSelectionSet(const service::SelectionSetParams& params) const final; void endSelectionSet(const service::SelectionSetParams& params) const final; @@ -141,7 +144,7 @@ class NestedType public: template - NestedType(std::shared_ptr pimpl) + NestedType(std::shared_ptr pimpl) noexcept : NestedType { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } diff --git a/samples/today/separate_nointrospection/NodeObject.cpp b/samples/today/separate_nointrospection/NodeObject.cpp new file mode 100644 index 00000000..7196db2b --- /dev/null +++ b/samples/today/separate_nointrospection/NodeObject.cpp @@ -0,0 +1,46 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// WARNING! Do not edit this file manually, your changes will be overwritten. + +#include "TodayObjects.h" + +#include "graphqlservice/introspection/Introspection.h" + +#include +#include +#include +#include +#include + +using namespace std::literals; + +namespace graphql::today { +namespace object { + +Node::Node(std::unique_ptr&& pimpl) noexcept + : service::Object { pimpl->getTypeNames(), pimpl->getResolvers() } + , _pimpl { std::move(pimpl) } +{ +} + +void Node::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void Node::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} + +} // namespace object + +void AddNodeDetails(const std::shared_ptr& typeNode, const std::shared_ptr& schema) +{ + typeNode->AddFields({ + schema::Field::Make(R"gql(id)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("ID"))) + }); +} + +} // namespace graphql::today diff --git a/samples/today/separate_nointrospection/NodeObject.h b/samples/today/separate_nointrospection/NodeObject.h new file mode 100644 index 00000000..af1a537b --- /dev/null +++ b/samples/today/separate_nointrospection/NodeObject.h @@ -0,0 +1,81 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// WARNING! Do not edit this file manually, your changes will be overwritten. + +#pragma once + +#ifndef NODEOBJECT_H +#define NODEOBJECT_H + +#include "TodaySchema.h" + +namespace graphql::today::object { + +class Node + : public service::Object +{ +private: + struct Concept + { + virtual ~Concept() = default; + + virtual service::TypeNames getTypeNames() const noexcept = 0; + virtual service::ResolverMap getResolvers() const noexcept = 0; + + virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::TypeNames getTypeNames() const noexcept final + { + return _pimpl->getTypeNames(); + } + + service::ResolverMap getResolvers() const noexcept final + { + return _pimpl->getResolvers(); + } + + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + _pimpl->beginSelectionSet(params); + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + _pimpl->endSelectionSet(params); + } + + private: + const std::shared_ptr _pimpl; + }; + + Node(std::unique_ptr&& pimpl) noexcept; + + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; + + const std::unique_ptr _pimpl; + +public: + template + Node(std::shared_ptr pimpl) noexcept + : Node { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } + { + static_assert(T::template implements(), "Node is not implemented"); + } +}; + +} // namespace graphql::today::object + +#endif // NODEOBJECT_H diff --git a/samples/today/separate_nointrospection/PageInfoObject.cpp b/samples/today/separate_nointrospection/PageInfoObject.cpp index e9677c85..87112979 100644 --- a/samples/today/separate_nointrospection/PageInfoObject.cpp +++ b/samples/today/separate_nointrospection/PageInfoObject.cpp @@ -18,16 +18,26 @@ using namespace std::literals; namespace graphql::today { namespace object { -PageInfo::PageInfo(std::unique_ptr&& pimpl) - : service::Object({ +PageInfo::PageInfo(std::unique_ptr&& pimpl) noexcept + : service::Object{ getTypeNames(), getResolvers() } + , _pimpl { std::move(pimpl) } +{ +} + +service::TypeNames PageInfo::getTypeNames() const noexcept +{ + return { "PageInfo" - }, { + }; +} + +service::ResolverMap PageInfo::getResolvers() const noexcept +{ + return { { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, { R"gql(hasNextPage)gql"sv, [this](service::ResolverParams&& params) { return resolveHasNextPage(std::move(params)); } }, { R"gql(hasPreviousPage)gql"sv, [this](service::ResolverParams&& params) { return resolveHasPreviousPage(std::move(params)); } } - }) - , _pimpl(std::move(pimpl)) -{ + }; } void PageInfo::beginSelectionSet(const service::SelectionSetParams& params) const @@ -40,7 +50,7 @@ void PageInfo::endSelectionSet(const service::SelectionSetParams& params) const _pimpl->endSelectionSet(params); } -service::AwaitableResolver PageInfo::resolveHasNextPage(service::ResolverParams&& params) +service::AwaitableResolver PageInfo::resolveHasNextPage(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -50,7 +60,7 @@ service::AwaitableResolver PageInfo::resolveHasNextPage(service::ResolverParams& return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver PageInfo::resolveHasPreviousPage(service::ResolverParams&& params) +service::AwaitableResolver PageInfo::resolveHasPreviousPage(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -60,14 +70,14 @@ service::AwaitableResolver PageInfo::resolveHasPreviousPage(service::ResolverPar return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver PageInfo::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver PageInfo::resolve_typename(service::ResolverParams&& params) const { return service::ModifiedResult::convert(std::string{ R"gql(PageInfo)gql" }, std::move(params)); } } // namespace object -void AddPageInfoDetails(std::shared_ptr typePageInfo, const std::shared_ptr& schema) +void AddPageInfoDetails(const std::shared_ptr& typePageInfo, const std::shared_ptr& schema) { typePageInfo->AddFields({ schema::Field::Make(R"gql(hasNextPage)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("Boolean"))), diff --git a/samples/today/separate_nointrospection/PageInfoObject.h b/samples/today/separate_nointrospection/PageInfoObject.h index ca851ed1..d5c1cf4f 100644 --- a/samples/today/separate_nointrospection/PageInfoObject.h +++ b/samples/today/separate_nointrospection/PageInfoObject.h @@ -11,54 +11,54 @@ #include "TodaySchema.h" namespace graphql::today::object { -namespace methods::PageInfoMethod { +namespace methods::PageInfoHas { template -concept WithParamsHasNextPage = requires (TImpl impl, service::FieldParams params) +concept getHasNextPageWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getHasNextPage(std::move(params)) } }; }; template -concept NoParamsHasNextPage = requires (TImpl impl) +concept getHasNextPage = requires (TImpl impl) { { service::FieldResult { impl.getHasNextPage() } }; }; template -concept WithParamsHasPreviousPage = requires (TImpl impl, service::FieldParams params) +concept getHasPreviousPageWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getHasPreviousPage(std::move(params)) } }; }; template -concept NoParamsHasPreviousPage = requires (TImpl impl) +concept getHasPreviousPage = requires (TImpl impl) { { service::FieldResult { impl.getHasPreviousPage() } }; }; template -concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.beginSelectionSet(params) }; }; template -concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.endSelectionSet(params) }; }; -} // namespace methods::PageInfoMethod +} // namespace methods::PageInfoHas class PageInfo : public service::Object { private: - service::AwaitableResolver resolveHasNextPage(service::ResolverParams&& params); - service::AwaitableResolver resolveHasPreviousPage(service::ResolverParams&& params); + service::AwaitableResolver resolveHasNextPage(service::ResolverParams&& params) const; + service::AwaitableResolver resolveHasPreviousPage(service::ResolverParams&& params) const; - service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; struct Concept { @@ -82,11 +82,11 @@ class PageInfo service::FieldResult getHasNextPage(service::FieldParams&& params) const final { - if constexpr (methods::PageInfoMethod::WithParamsHasNextPage) + if constexpr (methods::PageInfoHas::getHasNextPageWithParams) { return { _pimpl->getHasNextPage(std::move(params)) }; } - else if constexpr (methods::PageInfoMethod::NoParamsHasNextPage) + else if constexpr (methods::PageInfoHas::getHasNextPage) { return { _pimpl->getHasNextPage() }; } @@ -98,11 +98,11 @@ class PageInfo service::FieldResult getHasPreviousPage(service::FieldParams&& params) const final { - if constexpr (methods::PageInfoMethod::WithParamsHasPreviousPage) + if constexpr (methods::PageInfoHas::getHasPreviousPageWithParams) { return { _pimpl->getHasPreviousPage(std::move(params)) }; } - else if constexpr (methods::PageInfoMethod::NoParamsHasPreviousPage) + else if constexpr (methods::PageInfoHas::getHasPreviousPage) { return { _pimpl->getHasPreviousPage() }; } @@ -114,7 +114,7 @@ class PageInfo void beginSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::PageInfoMethod::HasBeginSelectionSet) + if constexpr (methods::PageInfoHas::beginSelectionSet) { _pimpl->beginSelectionSet(params); } @@ -122,7 +122,7 @@ class PageInfo void endSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::PageInfoMethod::HasEndSelectionSet) + if constexpr (methods::PageInfoHas::endSelectionSet) { _pimpl->endSelectionSet(params); } @@ -132,7 +132,10 @@ class PageInfo const std::shared_ptr _pimpl; }; - PageInfo(std::unique_ptr&& pimpl); + PageInfo(std::unique_ptr&& pimpl) noexcept; + + service::TypeNames getTypeNames() const noexcept; + service::ResolverMap getResolvers() const noexcept; void beginSelectionSet(const service::SelectionSetParams& params) const final; void endSelectionSet(const service::SelectionSetParams& params) const final; @@ -141,7 +144,7 @@ class PageInfo public: template - PageInfo(std::shared_ptr pimpl) + PageInfo(std::shared_ptr pimpl) noexcept : PageInfo { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } diff --git a/samples/today/separate_nointrospection/QueryObject.cpp b/samples/today/separate_nointrospection/QueryObject.cpp index a7c2a563..cc7d9fcc 100644 --- a/samples/today/separate_nointrospection/QueryObject.cpp +++ b/samples/today/separate_nointrospection/QueryObject.cpp @@ -18,10 +18,22 @@ using namespace std::literals; namespace graphql::today { namespace object { -Query::Query(std::unique_ptr&& pimpl) - : service::Object({ +Query::Query(std::unique_ptr&& pimpl) noexcept + : service::Object{ getTypeNames(), getResolvers() } + , _pimpl { std::move(pimpl) } +{ +} + +service::TypeNames Query::getTypeNames() const noexcept +{ + return { "Query" - }, { + }; +} + +service::ResolverMap Query::getResolvers() const noexcept +{ + return { { R"gql(node)gql"sv, [this](service::ResolverParams&& params) { return resolveNode(std::move(params)); } }, { R"gql(tasks)gql"sv, [this](service::ResolverParams&& params) { return resolveTasks(std::move(params)); } }, { R"gql(nested)gql"sv, [this](service::ResolverParams&& params) { return resolveNested(std::move(params)); } }, @@ -35,9 +47,7 @@ Query::Query(std::unique_ptr&& pimpl) { R"gql(unimplemented)gql"sv, [this](service::ResolverParams&& params) { return resolveUnimplemented(std::move(params)); } }, { R"gql(appointmentsById)gql"sv, [this](service::ResolverParams&& params) { return resolveAppointmentsById(std::move(params)); } }, { R"gql(unreadCountsById)gql"sv, [this](service::ResolverParams&& params) { return resolveUnreadCountsById(std::move(params)); } } - }) - , _pimpl(std::move(pimpl)) -{ + }; } void Query::beginSelectionSet(const service::SelectionSetParams& params) const @@ -50,7 +60,7 @@ void Query::endSelectionSet(const service::SelectionSetParams& params) const _pimpl->endSelectionSet(params); } -service::AwaitableResolver Query::resolveNode(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveNode(service::ResolverParams&& params) const { auto argId = service::ModifiedArgument::require("id", params.arguments); std::unique_lock resolverLock(_resolverMutex); @@ -58,10 +68,10 @@ service::AwaitableResolver Query::resolveNode(service::ResolverParams&& params) auto result = _pimpl->getNode(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argId)); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Query::resolveAppointments(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveAppointments(service::ResolverParams&& params) const { auto argFirst = service::ModifiedArgument::require("first", params.arguments); auto argAfter = service::ModifiedArgument::require("after", params.arguments); @@ -75,7 +85,7 @@ service::AwaitableResolver Query::resolveAppointments(service::ResolverParams&& return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Query::resolveTasks(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveTasks(service::ResolverParams&& params) const { auto argFirst = service::ModifiedArgument::require("first", params.arguments); auto argAfter = service::ModifiedArgument::require("after", params.arguments); @@ -89,7 +99,7 @@ service::AwaitableResolver Query::resolveTasks(service::ResolverParams&& params) return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Query::resolveUnreadCounts(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveUnreadCounts(service::ResolverParams&& params) const { auto argFirst = service::ModifiedArgument::require("first", params.arguments); auto argAfter = service::ModifiedArgument::require("after", params.arguments); @@ -103,7 +113,7 @@ service::AwaitableResolver Query::resolveUnreadCounts(service::ResolverParams&& return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Query::resolveAppointmentsById(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveAppointmentsById(service::ResolverParams&& params) const { const auto defaultArguments = []() { @@ -136,7 +146,7 @@ service::AwaitableResolver Query::resolveAppointmentsById(service::ResolverParam return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Query::resolveTasksById(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveTasksById(service::ResolverParams&& params) const { auto argIds = service::ModifiedArgument::require("ids", params.arguments); std::unique_lock resolverLock(_resolverMutex); @@ -147,7 +157,7 @@ service::AwaitableResolver Query::resolveTasksById(service::ResolverParams&& par return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Query::resolveUnreadCountsById(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveUnreadCountsById(service::ResolverParams&& params) const { auto argIds = service::ModifiedArgument::require("ids", params.arguments); std::unique_lock resolverLock(_resolverMutex); @@ -158,7 +168,7 @@ service::AwaitableResolver Query::resolveUnreadCountsById(service::ResolverParam return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Query::resolveNested(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveNested(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -168,7 +178,7 @@ service::AwaitableResolver Query::resolveNested(service::ResolverParams&& params return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Query::resolveUnimplemented(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveUnimplemented(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -178,7 +188,7 @@ service::AwaitableResolver Query::resolveUnimplemented(service::ResolverParams&& return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Query::resolveExpensive(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveExpensive(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -188,7 +198,7 @@ service::AwaitableResolver Query::resolveExpensive(service::ResolverParams&& par return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Query::resolveTestTaskState(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveTestTaskState(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -198,7 +208,7 @@ service::AwaitableResolver Query::resolveTestTaskState(service::ResolverParams&& return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Query::resolveAnyType(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveAnyType(service::ResolverParams&& params) const { auto argIds = service::ModifiedArgument::require("ids", params.arguments); std::unique_lock resolverLock(_resolverMutex); @@ -209,14 +219,14 @@ service::AwaitableResolver Query::resolveAnyType(service::ResolverParams&& param return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Query::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver Query::resolve_typename(service::ResolverParams&& params) const { return service::ModifiedResult::convert(std::string{ R"gql(Query)gql" }, std::move(params)); } } // namespace object -void AddQueryDetails(std::shared_ptr typeQuery, const std::shared_ptr& schema) +void AddQueryDetails(const std::shared_ptr& typeQuery, const std::shared_ptr& schema) { typeQuery->AddFields({ schema::Field::Make(R"gql(node)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType("Node"), { diff --git a/samples/today/separate_nointrospection/QueryObject.h b/samples/today/separate_nointrospection/QueryObject.h index 8f75ddbb..fbd11bc4 100644 --- a/samples/today/separate_nointrospection/QueryObject.h +++ b/samples/today/separate_nointrospection/QueryObject.h @@ -11,184 +11,184 @@ #include "TodaySchema.h" namespace graphql::today::object { -namespace methods::QueryMethod { +namespace methods::QueryHas { template -concept WithParamsNode = requires (TImpl impl, service::FieldParams params, response::IdType idArg) +concept getNodeWithParams = requires (TImpl impl, service::FieldParams params, response::IdType idArg) { - { service::FieldResult> { impl.getNode(std::move(params), std::move(idArg)) } }; + { service::FieldResult> { impl.getNode(std::move(params), std::move(idArg)) } }; }; template -concept NoParamsNode = requires (TImpl impl, response::IdType idArg) +concept getNode = requires (TImpl impl, response::IdType idArg) { - { service::FieldResult> { impl.getNode(std::move(idArg)) } }; + { service::FieldResult> { impl.getNode(std::move(idArg)) } }; }; template -concept WithParamsAppointments = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) +concept getAppointmentsWithParams = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) { { service::FieldResult> { impl.getAppointments(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; }; template -concept NoParamsAppointments = requires (TImpl impl, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) +concept getAppointments = requires (TImpl impl, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) { { service::FieldResult> { impl.getAppointments(std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; }; template -concept WithParamsTasks = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) +concept getTasksWithParams = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) { { service::FieldResult> { impl.getTasks(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; }; template -concept NoParamsTasks = requires (TImpl impl, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) +concept getTasks = requires (TImpl impl, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) { { service::FieldResult> { impl.getTasks(std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; }; template -concept WithParamsUnreadCounts = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) +concept getUnreadCountsWithParams = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) { { service::FieldResult> { impl.getUnreadCounts(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; }; template -concept NoParamsUnreadCounts = requires (TImpl impl, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) +concept getUnreadCounts = requires (TImpl impl, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) { { service::FieldResult> { impl.getUnreadCounts(std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; }; template -concept WithParamsAppointmentsById = requires (TImpl impl, service::FieldParams params, std::vector idsArg) +concept getAppointmentsByIdWithParams = requires (TImpl impl, service::FieldParams params, std::vector idsArg) { { service::FieldResult>> { impl.getAppointmentsById(std::move(params), std::move(idsArg)) } }; }; template -concept NoParamsAppointmentsById = requires (TImpl impl, std::vector idsArg) +concept getAppointmentsById = requires (TImpl impl, std::vector idsArg) { { service::FieldResult>> { impl.getAppointmentsById(std::move(idsArg)) } }; }; template -concept WithParamsTasksById = requires (TImpl impl, service::FieldParams params, std::vector idsArg) +concept getTasksByIdWithParams = requires (TImpl impl, service::FieldParams params, std::vector idsArg) { { service::FieldResult>> { impl.getTasksById(std::move(params), std::move(idsArg)) } }; }; template -concept NoParamsTasksById = requires (TImpl impl, std::vector idsArg) +concept getTasksById = requires (TImpl impl, std::vector idsArg) { { service::FieldResult>> { impl.getTasksById(std::move(idsArg)) } }; }; template -concept WithParamsUnreadCountsById = requires (TImpl impl, service::FieldParams params, std::vector idsArg) +concept getUnreadCountsByIdWithParams = requires (TImpl impl, service::FieldParams params, std::vector idsArg) { { service::FieldResult>> { impl.getUnreadCountsById(std::move(params), std::move(idsArg)) } }; }; template -concept NoParamsUnreadCountsById = requires (TImpl impl, std::vector idsArg) +concept getUnreadCountsById = requires (TImpl impl, std::vector idsArg) { { service::FieldResult>> { impl.getUnreadCountsById(std::move(idsArg)) } }; }; template -concept WithParamsNested = requires (TImpl impl, service::FieldParams params) +concept getNestedWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getNested(std::move(params)) } }; }; template -concept NoParamsNested = requires (TImpl impl) +concept getNested = requires (TImpl impl) { { service::FieldResult> { impl.getNested() } }; }; template -concept WithParamsUnimplemented = requires (TImpl impl, service::FieldParams params) +concept getUnimplementedWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getUnimplemented(std::move(params)) } }; }; template -concept NoParamsUnimplemented = requires (TImpl impl) +concept getUnimplemented = requires (TImpl impl) { { service::FieldResult { impl.getUnimplemented() } }; }; template -concept WithParamsExpensive = requires (TImpl impl, service::FieldParams params) +concept getExpensiveWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult>> { impl.getExpensive(std::move(params)) } }; }; template -concept NoParamsExpensive = requires (TImpl impl) +concept getExpensive = requires (TImpl impl) { { service::FieldResult>> { impl.getExpensive() } }; }; template -concept WithParamsTestTaskState = requires (TImpl impl, service::FieldParams params) +concept getTestTaskStateWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getTestTaskState(std::move(params)) } }; }; template -concept NoParamsTestTaskState = requires (TImpl impl) +concept getTestTaskState = requires (TImpl impl) { { service::FieldResult { impl.getTestTaskState() } }; }; template -concept WithParamsAnyType = requires (TImpl impl, service::FieldParams params, std::vector idsArg) +concept getAnyTypeWithParams = requires (TImpl impl, service::FieldParams params, std::vector idsArg) { { service::FieldResult>> { impl.getAnyType(std::move(params), std::move(idsArg)) } }; }; template -concept NoParamsAnyType = requires (TImpl impl, std::vector idsArg) +concept getAnyType = requires (TImpl impl, std::vector idsArg) { { service::FieldResult>> { impl.getAnyType(std::move(idsArg)) } }; }; template -concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.beginSelectionSet(params) }; }; template -concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.endSelectionSet(params) }; }; -} // namespace methods::QueryMethod +} // namespace methods::QueryHas class Query : public service::Object { private: - service::AwaitableResolver resolveNode(service::ResolverParams&& params); - service::AwaitableResolver resolveAppointments(service::ResolverParams&& params); - service::AwaitableResolver resolveTasks(service::ResolverParams&& params); - service::AwaitableResolver resolveUnreadCounts(service::ResolverParams&& params); - service::AwaitableResolver resolveAppointmentsById(service::ResolverParams&& params); - service::AwaitableResolver resolveTasksById(service::ResolverParams&& params); - service::AwaitableResolver resolveUnreadCountsById(service::ResolverParams&& params); - service::AwaitableResolver resolveNested(service::ResolverParams&& params); - service::AwaitableResolver resolveUnimplemented(service::ResolverParams&& params); - service::AwaitableResolver resolveExpensive(service::ResolverParams&& params); - service::AwaitableResolver resolveTestTaskState(service::ResolverParams&& params); - service::AwaitableResolver resolveAnyType(service::ResolverParams&& params); - - service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolveNode(service::ResolverParams&& params) const; + service::AwaitableResolver resolveAppointments(service::ResolverParams&& params) const; + service::AwaitableResolver resolveTasks(service::ResolverParams&& params) const; + service::AwaitableResolver resolveUnreadCounts(service::ResolverParams&& params) const; + service::AwaitableResolver resolveAppointmentsById(service::ResolverParams&& params) const; + service::AwaitableResolver resolveTasksById(service::ResolverParams&& params) const; + service::AwaitableResolver resolveUnreadCountsById(service::ResolverParams&& params) const; + service::AwaitableResolver resolveNested(service::ResolverParams&& params) const; + service::AwaitableResolver resolveUnimplemented(service::ResolverParams&& params) const; + service::AwaitableResolver resolveExpensive(service::ResolverParams&& params) const; + service::AwaitableResolver resolveTestTaskState(service::ResolverParams&& params) const; + service::AwaitableResolver resolveAnyType(service::ResolverParams&& params) const; + + service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; struct Concept { @@ -197,7 +197,7 @@ class Query virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual service::FieldResult> getNode(service::FieldParams&& params, response::IdType&& idArg) const = 0; + virtual service::FieldResult> getNode(service::FieldParams&& params, response::IdType&& idArg) const = 0; virtual service::FieldResult> getAppointments(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const = 0; virtual service::FieldResult> getTasks(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const = 0; virtual service::FieldResult> getUnreadCounts(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const = 0; @@ -220,13 +220,13 @@ class Query { } - service::FieldResult> getNode(service::FieldParams&& params, response::IdType&& idArg) const final + service::FieldResult> getNode(service::FieldParams&& params, response::IdType&& idArg) const final { - if constexpr (methods::QueryMethod::WithParamsNode) + if constexpr (methods::QueryHas::getNodeWithParams) { return { _pimpl->getNode(std::move(params), std::move(idArg)) }; } - else if constexpr (methods::QueryMethod::NoParamsNode) + else if constexpr (methods::QueryHas::getNode) { return { _pimpl->getNode(std::move(idArg)) }; } @@ -238,11 +238,11 @@ class Query service::FieldResult> getAppointments(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const final { - if constexpr (methods::QueryMethod::WithParamsAppointments) + if constexpr (methods::QueryHas::getAppointmentsWithParams) { return { _pimpl->getAppointments(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) }; } - else if constexpr (methods::QueryMethod::NoParamsAppointments) + else if constexpr (methods::QueryHas::getAppointments) { return { _pimpl->getAppointments(std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) }; } @@ -254,11 +254,11 @@ class Query service::FieldResult> getTasks(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const final { - if constexpr (methods::QueryMethod::WithParamsTasks) + if constexpr (methods::QueryHas::getTasksWithParams) { return { _pimpl->getTasks(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) }; } - else if constexpr (methods::QueryMethod::NoParamsTasks) + else if constexpr (methods::QueryHas::getTasks) { return { _pimpl->getTasks(std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) }; } @@ -270,11 +270,11 @@ class Query service::FieldResult> getUnreadCounts(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const final { - if constexpr (methods::QueryMethod::WithParamsUnreadCounts) + if constexpr (methods::QueryHas::getUnreadCountsWithParams) { return { _pimpl->getUnreadCounts(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) }; } - else if constexpr (methods::QueryMethod::NoParamsUnreadCounts) + else if constexpr (methods::QueryHas::getUnreadCounts) { return { _pimpl->getUnreadCounts(std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) }; } @@ -286,11 +286,11 @@ class Query service::FieldResult>> getAppointmentsById(service::FieldParams&& params, std::vector&& idsArg) const final { - if constexpr (methods::QueryMethod::WithParamsAppointmentsById) + if constexpr (methods::QueryHas::getAppointmentsByIdWithParams) { return { _pimpl->getAppointmentsById(std::move(params), std::move(idsArg)) }; } - else if constexpr (methods::QueryMethod::NoParamsAppointmentsById) + else if constexpr (methods::QueryHas::getAppointmentsById) { return { _pimpl->getAppointmentsById(std::move(idsArg)) }; } @@ -302,11 +302,11 @@ class Query service::FieldResult>> getTasksById(service::FieldParams&& params, std::vector&& idsArg) const final { - if constexpr (methods::QueryMethod::WithParamsTasksById) + if constexpr (methods::QueryHas::getTasksByIdWithParams) { return { _pimpl->getTasksById(std::move(params), std::move(idsArg)) }; } - else if constexpr (methods::QueryMethod::NoParamsTasksById) + else if constexpr (methods::QueryHas::getTasksById) { return { _pimpl->getTasksById(std::move(idsArg)) }; } @@ -318,11 +318,11 @@ class Query service::FieldResult>> getUnreadCountsById(service::FieldParams&& params, std::vector&& idsArg) const final { - if constexpr (methods::QueryMethod::WithParamsUnreadCountsById) + if constexpr (methods::QueryHas::getUnreadCountsByIdWithParams) { return { _pimpl->getUnreadCountsById(std::move(params), std::move(idsArg)) }; } - else if constexpr (methods::QueryMethod::NoParamsUnreadCountsById) + else if constexpr (methods::QueryHas::getUnreadCountsById) { return { _pimpl->getUnreadCountsById(std::move(idsArg)) }; } @@ -334,11 +334,11 @@ class Query service::FieldResult> getNested(service::FieldParams&& params) const final { - if constexpr (methods::QueryMethod::WithParamsNested) + if constexpr (methods::QueryHas::getNestedWithParams) { return { _pimpl->getNested(std::move(params)) }; } - else if constexpr (methods::QueryMethod::NoParamsNested) + else if constexpr (methods::QueryHas::getNested) { return { _pimpl->getNested() }; } @@ -350,11 +350,11 @@ class Query service::FieldResult getUnimplemented(service::FieldParams&& params) const final { - if constexpr (methods::QueryMethod::WithParamsUnimplemented) + if constexpr (methods::QueryHas::getUnimplementedWithParams) { return { _pimpl->getUnimplemented(std::move(params)) }; } - else if constexpr (methods::QueryMethod::NoParamsUnimplemented) + else if constexpr (methods::QueryHas::getUnimplemented) { return { _pimpl->getUnimplemented() }; } @@ -366,11 +366,11 @@ class Query service::FieldResult>> getExpensive(service::FieldParams&& params) const final { - if constexpr (methods::QueryMethod::WithParamsExpensive) + if constexpr (methods::QueryHas::getExpensiveWithParams) { return { _pimpl->getExpensive(std::move(params)) }; } - else if constexpr (methods::QueryMethod::NoParamsExpensive) + else if constexpr (methods::QueryHas::getExpensive) { return { _pimpl->getExpensive() }; } @@ -382,11 +382,11 @@ class Query service::FieldResult getTestTaskState(service::FieldParams&& params) const final { - if constexpr (methods::QueryMethod::WithParamsTestTaskState) + if constexpr (methods::QueryHas::getTestTaskStateWithParams) { return { _pimpl->getTestTaskState(std::move(params)) }; } - else if constexpr (methods::QueryMethod::NoParamsTestTaskState) + else if constexpr (methods::QueryHas::getTestTaskState) { return { _pimpl->getTestTaskState() }; } @@ -398,11 +398,11 @@ class Query service::FieldResult>> getAnyType(service::FieldParams&& params, std::vector&& idsArg) const final { - if constexpr (methods::QueryMethod::WithParamsAnyType) + if constexpr (methods::QueryHas::getAnyTypeWithParams) { return { _pimpl->getAnyType(std::move(params), std::move(idsArg)) }; } - else if constexpr (methods::QueryMethod::NoParamsAnyType) + else if constexpr (methods::QueryHas::getAnyType) { return { _pimpl->getAnyType(std::move(idsArg)) }; } @@ -414,7 +414,7 @@ class Query void beginSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::QueryMethod::HasBeginSelectionSet) + if constexpr (methods::QueryHas::beginSelectionSet) { _pimpl->beginSelectionSet(params); } @@ -422,7 +422,7 @@ class Query void endSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::QueryMethod::HasEndSelectionSet) + if constexpr (methods::QueryHas::endSelectionSet) { _pimpl->endSelectionSet(params); } @@ -432,7 +432,10 @@ class Query const std::shared_ptr _pimpl; }; - Query(std::unique_ptr&& pimpl); + Query(std::unique_ptr&& pimpl) noexcept; + + service::TypeNames getTypeNames() const noexcept; + service::ResolverMap getResolvers() const noexcept; void beginSelectionSet(const service::SelectionSetParams& params) const final; void endSelectionSet(const service::SelectionSetParams& params) const final; @@ -441,7 +444,7 @@ class Query public: template - Query(std::shared_ptr pimpl) + Query(std::shared_ptr pimpl) noexcept : Query { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } diff --git a/samples/today/separate_nointrospection/SubscriptionObject.cpp b/samples/today/separate_nointrospection/SubscriptionObject.cpp index d5e4d4cd..8c7b5321 100644 --- a/samples/today/separate_nointrospection/SubscriptionObject.cpp +++ b/samples/today/separate_nointrospection/SubscriptionObject.cpp @@ -18,16 +18,26 @@ using namespace std::literals; namespace graphql::today { namespace object { -Subscription::Subscription(std::unique_ptr&& pimpl) - : service::Object({ +Subscription::Subscription(std::unique_ptr&& pimpl) noexcept + : service::Object{ getTypeNames(), getResolvers() } + , _pimpl { std::move(pimpl) } +{ +} + +service::TypeNames Subscription::getTypeNames() const noexcept +{ + return { "Subscription" - }, { + }; +} + +service::ResolverMap Subscription::getResolvers() const noexcept +{ + return { { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, { R"gql(nodeChange)gql"sv, [this](service::ResolverParams&& params) { return resolveNodeChange(std::move(params)); } }, { R"gql(nextAppointmentChange)gql"sv, [this](service::ResolverParams&& params) { return resolveNextAppointmentChange(std::move(params)); } } - }) - , _pimpl(std::move(pimpl)) -{ + }; } void Subscription::beginSelectionSet(const service::SelectionSetParams& params) const @@ -40,7 +50,7 @@ void Subscription::endSelectionSet(const service::SelectionSetParams& params) co _pimpl->endSelectionSet(params); } -service::AwaitableResolver Subscription::resolveNextAppointmentChange(service::ResolverParams&& params) +service::AwaitableResolver Subscription::resolveNextAppointmentChange(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -50,7 +60,7 @@ service::AwaitableResolver Subscription::resolveNextAppointmentChange(service::R return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Subscription::resolveNodeChange(service::ResolverParams&& params) +service::AwaitableResolver Subscription::resolveNodeChange(service::ResolverParams&& params) const { auto argId = service::ModifiedArgument::require("id", params.arguments); std::unique_lock resolverLock(_resolverMutex); @@ -58,17 +68,17 @@ service::AwaitableResolver Subscription::resolveNodeChange(service::ResolverPara auto result = _pimpl->getNodeChange(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argId)); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Subscription::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver Subscription::resolve_typename(service::ResolverParams&& params) const { return service::ModifiedResult::convert(std::string{ R"gql(Subscription)gql" }, std::move(params)); } } // namespace object -void AddSubscriptionDetails(std::shared_ptr typeSubscription, const std::shared_ptr& schema) +void AddSubscriptionDetails(const std::shared_ptr& typeSubscription, const std::shared_ptr& schema) { typeSubscription->AddFields({ schema::Field::Make(R"gql(nextAppointmentChange)gql"sv, R"md()md"sv, std::make_optional(R"md(Need to deprecate a [field](http://spec.graphql.org/June2018/#sec-Deprecation))md"sv), schema->LookupType("Appointment")), diff --git a/samples/today/separate_nointrospection/SubscriptionObject.h b/samples/today/separate_nointrospection/SubscriptionObject.h index 21db5c1b..86e5e8c8 100644 --- a/samples/today/separate_nointrospection/SubscriptionObject.h +++ b/samples/today/separate_nointrospection/SubscriptionObject.h @@ -11,54 +11,54 @@ #include "TodaySchema.h" namespace graphql::today::object { -namespace methods::SubscriptionMethod { +namespace methods::SubscriptionHas { template -concept WithParamsNextAppointmentChange = requires (TImpl impl, service::FieldParams params) +concept getNextAppointmentChangeWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getNextAppointmentChange(std::move(params)) } }; }; template -concept NoParamsNextAppointmentChange = requires (TImpl impl) +concept getNextAppointmentChange = requires (TImpl impl) { { service::FieldResult> { impl.getNextAppointmentChange() } }; }; template -concept WithParamsNodeChange = requires (TImpl impl, service::FieldParams params, response::IdType idArg) +concept getNodeChangeWithParams = requires (TImpl impl, service::FieldParams params, response::IdType idArg) { - { service::FieldResult> { impl.getNodeChange(std::move(params), std::move(idArg)) } }; + { service::FieldResult> { impl.getNodeChange(std::move(params), std::move(idArg)) } }; }; template -concept NoParamsNodeChange = requires (TImpl impl, response::IdType idArg) +concept getNodeChange = requires (TImpl impl, response::IdType idArg) { - { service::FieldResult> { impl.getNodeChange(std::move(idArg)) } }; + { service::FieldResult> { impl.getNodeChange(std::move(idArg)) } }; }; template -concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.beginSelectionSet(params) }; }; template -concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.endSelectionSet(params) }; }; -} // namespace methods::SubscriptionMethod +} // namespace methods::SubscriptionHas class Subscription : public service::Object { private: - service::AwaitableResolver resolveNextAppointmentChange(service::ResolverParams&& params); - service::AwaitableResolver resolveNodeChange(service::ResolverParams&& params); + service::AwaitableResolver resolveNextAppointmentChange(service::ResolverParams&& params) const; + service::AwaitableResolver resolveNodeChange(service::ResolverParams&& params) const; - service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; struct Concept { @@ -68,7 +68,7 @@ class Subscription virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; virtual service::FieldResult> getNextAppointmentChange(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getNodeChange(service::FieldParams&& params, response::IdType&& idArg) const = 0; + virtual service::FieldResult> getNodeChange(service::FieldParams&& params, response::IdType&& idArg) const = 0; }; template @@ -82,11 +82,11 @@ class Subscription service::FieldResult> getNextAppointmentChange(service::FieldParams&& params) const final { - if constexpr (methods::SubscriptionMethod::WithParamsNextAppointmentChange) + if constexpr (methods::SubscriptionHas::getNextAppointmentChangeWithParams) { return { _pimpl->getNextAppointmentChange(std::move(params)) }; } - else if constexpr (methods::SubscriptionMethod::NoParamsNextAppointmentChange) + else if constexpr (methods::SubscriptionHas::getNextAppointmentChange) { return { _pimpl->getNextAppointmentChange() }; } @@ -96,13 +96,13 @@ class Subscription } } - service::FieldResult> getNodeChange(service::FieldParams&& params, response::IdType&& idArg) const final + service::FieldResult> getNodeChange(service::FieldParams&& params, response::IdType&& idArg) const final { - if constexpr (methods::SubscriptionMethod::WithParamsNodeChange) + if constexpr (methods::SubscriptionHas::getNodeChangeWithParams) { return { _pimpl->getNodeChange(std::move(params), std::move(idArg)) }; } - else if constexpr (methods::SubscriptionMethod::NoParamsNodeChange) + else if constexpr (methods::SubscriptionHas::getNodeChange) { return { _pimpl->getNodeChange(std::move(idArg)) }; } @@ -114,7 +114,7 @@ class Subscription void beginSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::SubscriptionMethod::HasBeginSelectionSet) + if constexpr (methods::SubscriptionHas::beginSelectionSet) { _pimpl->beginSelectionSet(params); } @@ -122,7 +122,7 @@ class Subscription void endSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::SubscriptionMethod::HasEndSelectionSet) + if constexpr (methods::SubscriptionHas::endSelectionSet) { _pimpl->endSelectionSet(params); } @@ -132,7 +132,10 @@ class Subscription const std::shared_ptr _pimpl; }; - Subscription(std::unique_ptr&& pimpl); + Subscription(std::unique_ptr&& pimpl) noexcept; + + service::TypeNames getTypeNames() const noexcept; + service::ResolverMap getResolvers() const noexcept; void beginSelectionSet(const service::SelectionSetParams& params) const final; void endSelectionSet(const service::SelectionSetParams& params) const final; @@ -141,7 +144,7 @@ class Subscription public: template - Subscription(std::shared_ptr pimpl) + Subscription(std::shared_ptr pimpl) noexcept : Subscription { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } diff --git a/samples/today/separate_nointrospection/TaskConnectionObject.cpp b/samples/today/separate_nointrospection/TaskConnectionObject.cpp index ac3fc259..b1e9da1f 100644 --- a/samples/today/separate_nointrospection/TaskConnectionObject.cpp +++ b/samples/today/separate_nointrospection/TaskConnectionObject.cpp @@ -18,16 +18,26 @@ using namespace std::literals; namespace graphql::today { namespace object { -TaskConnection::TaskConnection(std::unique_ptr&& pimpl) - : service::Object({ +TaskConnection::TaskConnection(std::unique_ptr&& pimpl) noexcept + : service::Object{ getTypeNames(), getResolvers() } + , _pimpl { std::move(pimpl) } +{ +} + +service::TypeNames TaskConnection::getTypeNames() const noexcept +{ + return { "TaskConnection" - }, { + }; +} + +service::ResolverMap TaskConnection::getResolvers() const noexcept +{ + return { { R"gql(edges)gql"sv, [this](service::ResolverParams&& params) { return resolveEdges(std::move(params)); } }, { R"gql(pageInfo)gql"sv, [this](service::ResolverParams&& params) { return resolvePageInfo(std::move(params)); } }, { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } } - }) - , _pimpl(std::move(pimpl)) -{ + }; } void TaskConnection::beginSelectionSet(const service::SelectionSetParams& params) const @@ -40,7 +50,7 @@ void TaskConnection::endSelectionSet(const service::SelectionSetParams& params) _pimpl->endSelectionSet(params); } -service::AwaitableResolver TaskConnection::resolvePageInfo(service::ResolverParams&& params) +service::AwaitableResolver TaskConnection::resolvePageInfo(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -50,7 +60,7 @@ service::AwaitableResolver TaskConnection::resolvePageInfo(service::ResolverPara return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver TaskConnection::resolveEdges(service::ResolverParams&& params) +service::AwaitableResolver TaskConnection::resolveEdges(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -60,14 +70,14 @@ service::AwaitableResolver TaskConnection::resolveEdges(service::ResolverParams& return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver TaskConnection::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver TaskConnection::resolve_typename(service::ResolverParams&& params) const { return service::ModifiedResult::convert(std::string{ R"gql(TaskConnection)gql" }, std::move(params)); } } // namespace object -void AddTaskConnectionDetails(std::shared_ptr typeTaskConnection, const std::shared_ptr& schema) +void AddTaskConnectionDetails(const std::shared_ptr& typeTaskConnection, const std::shared_ptr& schema) { typeTaskConnection->AddFields({ schema::Field::Make(R"gql(pageInfo)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("PageInfo"))), diff --git a/samples/today/separate_nointrospection/TaskConnectionObject.h b/samples/today/separate_nointrospection/TaskConnectionObject.h index 362183f2..a7015334 100644 --- a/samples/today/separate_nointrospection/TaskConnectionObject.h +++ b/samples/today/separate_nointrospection/TaskConnectionObject.h @@ -11,54 +11,54 @@ #include "TodaySchema.h" namespace graphql::today::object { -namespace methods::TaskConnectionMethod { +namespace methods::TaskConnectionHas { template -concept WithParamsPageInfo = requires (TImpl impl, service::FieldParams params) +concept getPageInfoWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getPageInfo(std::move(params)) } }; }; template -concept NoParamsPageInfo = requires (TImpl impl) +concept getPageInfo = requires (TImpl impl) { { service::FieldResult> { impl.getPageInfo() } }; }; template -concept WithParamsEdges = requires (TImpl impl, service::FieldParams params) +concept getEdgesWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult>>> { impl.getEdges(std::move(params)) } }; }; template -concept NoParamsEdges = requires (TImpl impl) +concept getEdges = requires (TImpl impl) { { service::FieldResult>>> { impl.getEdges() } }; }; template -concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.beginSelectionSet(params) }; }; template -concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.endSelectionSet(params) }; }; -} // namespace methods::TaskConnectionMethod +} // namespace methods::TaskConnectionHas class TaskConnection : public service::Object { private: - service::AwaitableResolver resolvePageInfo(service::ResolverParams&& params); - service::AwaitableResolver resolveEdges(service::ResolverParams&& params); + service::AwaitableResolver resolvePageInfo(service::ResolverParams&& params) const; + service::AwaitableResolver resolveEdges(service::ResolverParams&& params) const; - service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; struct Concept { @@ -82,11 +82,11 @@ class TaskConnection service::FieldResult> getPageInfo(service::FieldParams&& params) const final { - if constexpr (methods::TaskConnectionMethod::WithParamsPageInfo) + if constexpr (methods::TaskConnectionHas::getPageInfoWithParams) { return { _pimpl->getPageInfo(std::move(params)) }; } - else if constexpr (methods::TaskConnectionMethod::NoParamsPageInfo) + else if constexpr (methods::TaskConnectionHas::getPageInfo) { return { _pimpl->getPageInfo() }; } @@ -98,11 +98,11 @@ class TaskConnection service::FieldResult>>> getEdges(service::FieldParams&& params) const final { - if constexpr (methods::TaskConnectionMethod::WithParamsEdges) + if constexpr (methods::TaskConnectionHas::getEdgesWithParams) { return { _pimpl->getEdges(std::move(params)) }; } - else if constexpr (methods::TaskConnectionMethod::NoParamsEdges) + else if constexpr (methods::TaskConnectionHas::getEdges) { return { _pimpl->getEdges() }; } @@ -114,7 +114,7 @@ class TaskConnection void beginSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::TaskConnectionMethod::HasBeginSelectionSet) + if constexpr (methods::TaskConnectionHas::beginSelectionSet) { _pimpl->beginSelectionSet(params); } @@ -122,7 +122,7 @@ class TaskConnection void endSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::TaskConnectionMethod::HasEndSelectionSet) + if constexpr (methods::TaskConnectionHas::endSelectionSet) { _pimpl->endSelectionSet(params); } @@ -132,7 +132,10 @@ class TaskConnection const std::shared_ptr _pimpl; }; - TaskConnection(std::unique_ptr&& pimpl); + TaskConnection(std::unique_ptr&& pimpl) noexcept; + + service::TypeNames getTypeNames() const noexcept; + service::ResolverMap getResolvers() const noexcept; void beginSelectionSet(const service::SelectionSetParams& params) const final; void endSelectionSet(const service::SelectionSetParams& params) const final; @@ -141,7 +144,7 @@ class TaskConnection public: template - TaskConnection(std::shared_ptr pimpl) + TaskConnection(std::shared_ptr pimpl) noexcept : TaskConnection { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } diff --git a/samples/today/separate_nointrospection/TaskEdgeObject.cpp b/samples/today/separate_nointrospection/TaskEdgeObject.cpp index 6a96ec40..ff7758d4 100644 --- a/samples/today/separate_nointrospection/TaskEdgeObject.cpp +++ b/samples/today/separate_nointrospection/TaskEdgeObject.cpp @@ -18,16 +18,26 @@ using namespace std::literals; namespace graphql::today { namespace object { -TaskEdge::TaskEdge(std::unique_ptr&& pimpl) - : service::Object({ +TaskEdge::TaskEdge(std::unique_ptr&& pimpl) noexcept + : service::Object{ getTypeNames(), getResolvers() } + , _pimpl { std::move(pimpl) } +{ +} + +service::TypeNames TaskEdge::getTypeNames() const noexcept +{ + return { "TaskEdge" - }, { + }; +} + +service::ResolverMap TaskEdge::getResolvers() const noexcept +{ + return { { R"gql(node)gql"sv, [this](service::ResolverParams&& params) { return resolveNode(std::move(params)); } }, { R"gql(cursor)gql"sv, [this](service::ResolverParams&& params) { return resolveCursor(std::move(params)); } }, { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } } - }) - , _pimpl(std::move(pimpl)) -{ + }; } void TaskEdge::beginSelectionSet(const service::SelectionSetParams& params) const @@ -40,7 +50,7 @@ void TaskEdge::endSelectionSet(const service::SelectionSetParams& params) const _pimpl->endSelectionSet(params); } -service::AwaitableResolver TaskEdge::resolveNode(service::ResolverParams&& params) +service::AwaitableResolver TaskEdge::resolveNode(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -50,7 +60,7 @@ service::AwaitableResolver TaskEdge::resolveNode(service::ResolverParams&& param return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver TaskEdge::resolveCursor(service::ResolverParams&& params) +service::AwaitableResolver TaskEdge::resolveCursor(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -60,14 +70,14 @@ service::AwaitableResolver TaskEdge::resolveCursor(service::ResolverParams&& par return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver TaskEdge::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver TaskEdge::resolve_typename(service::ResolverParams&& params) const { return service::ModifiedResult::convert(std::string{ R"gql(TaskEdge)gql" }, std::move(params)); } } // namespace object -void AddTaskEdgeDetails(std::shared_ptr typeTaskEdge, const std::shared_ptr& schema) +void AddTaskEdgeDetails(const std::shared_ptr& typeTaskEdge, const std::shared_ptr& schema) { typeTaskEdge->AddFields({ schema::Field::Make(R"gql(node)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType("Task")), diff --git a/samples/today/separate_nointrospection/TaskEdgeObject.h b/samples/today/separate_nointrospection/TaskEdgeObject.h index 45d77ab9..1dbd5980 100644 --- a/samples/today/separate_nointrospection/TaskEdgeObject.h +++ b/samples/today/separate_nointrospection/TaskEdgeObject.h @@ -11,54 +11,54 @@ #include "TodaySchema.h" namespace graphql::today::object { -namespace methods::TaskEdgeMethod { +namespace methods::TaskEdgeHas { template -concept WithParamsNode = requires (TImpl impl, service::FieldParams params) +concept getNodeWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getNode(std::move(params)) } }; }; template -concept NoParamsNode = requires (TImpl impl) +concept getNode = requires (TImpl impl) { { service::FieldResult> { impl.getNode() } }; }; template -concept WithParamsCursor = requires (TImpl impl, service::FieldParams params) +concept getCursorWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getCursor(std::move(params)) } }; }; template -concept NoParamsCursor = requires (TImpl impl) +concept getCursor = requires (TImpl impl) { { service::FieldResult { impl.getCursor() } }; }; template -concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.beginSelectionSet(params) }; }; template -concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.endSelectionSet(params) }; }; -} // namespace methods::TaskEdgeMethod +} // namespace methods::TaskEdgeHas class TaskEdge : public service::Object { private: - service::AwaitableResolver resolveNode(service::ResolverParams&& params); - service::AwaitableResolver resolveCursor(service::ResolverParams&& params); + service::AwaitableResolver resolveNode(service::ResolverParams&& params) const; + service::AwaitableResolver resolveCursor(service::ResolverParams&& params) const; - service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; struct Concept { @@ -82,11 +82,11 @@ class TaskEdge service::FieldResult> getNode(service::FieldParams&& params) const final { - if constexpr (methods::TaskEdgeMethod::WithParamsNode) + if constexpr (methods::TaskEdgeHas::getNodeWithParams) { return { _pimpl->getNode(std::move(params)) }; } - else if constexpr (methods::TaskEdgeMethod::NoParamsNode) + else if constexpr (methods::TaskEdgeHas::getNode) { return { _pimpl->getNode() }; } @@ -98,11 +98,11 @@ class TaskEdge service::FieldResult getCursor(service::FieldParams&& params) const final { - if constexpr (methods::TaskEdgeMethod::WithParamsCursor) + if constexpr (methods::TaskEdgeHas::getCursorWithParams) { return { _pimpl->getCursor(std::move(params)) }; } - else if constexpr (methods::TaskEdgeMethod::NoParamsCursor) + else if constexpr (methods::TaskEdgeHas::getCursor) { return { _pimpl->getCursor() }; } @@ -114,7 +114,7 @@ class TaskEdge void beginSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::TaskEdgeMethod::HasBeginSelectionSet) + if constexpr (methods::TaskEdgeHas::beginSelectionSet) { _pimpl->beginSelectionSet(params); } @@ -122,7 +122,7 @@ class TaskEdge void endSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::TaskEdgeMethod::HasEndSelectionSet) + if constexpr (methods::TaskEdgeHas::endSelectionSet) { _pimpl->endSelectionSet(params); } @@ -132,7 +132,10 @@ class TaskEdge const std::shared_ptr _pimpl; }; - TaskEdge(std::unique_ptr&& pimpl); + TaskEdge(std::unique_ptr&& pimpl) noexcept; + + service::TypeNames getTypeNames() const noexcept; + service::ResolverMap getResolvers() const noexcept; void beginSelectionSet(const service::SelectionSetParams& params) const final; void endSelectionSet(const service::SelectionSetParams& params) const final; @@ -141,7 +144,7 @@ class TaskEdge public: template - TaskEdge(std::shared_ptr pimpl) + TaskEdge(std::shared_ptr pimpl) noexcept : TaskEdge { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } diff --git a/samples/today/separate_nointrospection/TaskObject.cpp b/samples/today/separate_nointrospection/TaskObject.cpp index 39272e88..bdc7596c 100644 --- a/samples/today/separate_nointrospection/TaskObject.cpp +++ b/samples/today/separate_nointrospection/TaskObject.cpp @@ -18,19 +18,29 @@ using namespace std::literals; namespace graphql::today { namespace object { -Task::Task(std::unique_ptr&& pimpl) - : service::Object({ +Task::Task(std::unique_ptr&& pimpl) noexcept + : service::Object{ getTypeNames(), getResolvers() } + , _pimpl { std::move(pimpl) } +{ +} + +service::TypeNames Task::getTypeNames() const noexcept +{ + return { "Node", "UnionType", "Task" - }, { + }; +} + +service::ResolverMap Task::getResolvers() const noexcept +{ + return { { R"gql(id)gql"sv, [this](service::ResolverParams&& params) { return resolveId(std::move(params)); } }, { R"gql(title)gql"sv, [this](service::ResolverParams&& params) { return resolveTitle(std::move(params)); } }, { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, { R"gql(isComplete)gql"sv, [this](service::ResolverParams&& params) { return resolveIsComplete(std::move(params)); } } - }) - , _pimpl(std::move(pimpl)) -{ + }; } void Task::beginSelectionSet(const service::SelectionSetParams& params) const @@ -43,7 +53,7 @@ void Task::endSelectionSet(const service::SelectionSetParams& params) const _pimpl->endSelectionSet(params); } -service::AwaitableResolver Task::resolveId(service::ResolverParams&& params) +service::AwaitableResolver Task::resolveId(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -53,7 +63,7 @@ service::AwaitableResolver Task::resolveId(service::ResolverParams&& params) return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Task::resolveTitle(service::ResolverParams&& params) +service::AwaitableResolver Task::resolveTitle(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -63,7 +73,7 @@ service::AwaitableResolver Task::resolveTitle(service::ResolverParams&& params) return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Task::resolveIsComplete(service::ResolverParams&& params) +service::AwaitableResolver Task::resolveIsComplete(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -73,14 +83,14 @@ service::AwaitableResolver Task::resolveIsComplete(service::ResolverParams&& par return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Task::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver Task::resolve_typename(service::ResolverParams&& params) const { return service::ModifiedResult::convert(std::string{ R"gql(Task)gql" }, std::move(params)); } } // namespace object -void AddTaskDetails(std::shared_ptr typeTask, const std::shared_ptr& schema) +void AddTaskDetails(const std::shared_ptr& typeTask, const std::shared_ptr& schema) { typeTask->AddInterfaces({ std::static_pointer_cast(schema->LookupType(R"gql(Node)gql"sv)) diff --git a/samples/today/separate_nointrospection/TaskObject.h b/samples/today/separate_nointrospection/TaskObject.h index cbf1457c..5cadd3de 100644 --- a/samples/today/separate_nointrospection/TaskObject.h +++ b/samples/today/separate_nointrospection/TaskObject.h @@ -10,77 +10,86 @@ #include "TodaySchema.h" +#include "NodeObject.h" + namespace graphql::today::object { -namespace methods::TaskMethod { +namespace implements { + +template +concept TaskIs = std::is_same_v; + +} // namespace implements + +namespace methods::TaskHas { template -concept WithParamsId = requires (TImpl impl, service::FieldParams params) +concept getIdWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getId(std::move(params)) } }; }; template -concept NoParamsId = requires (TImpl impl) +concept getId = requires (TImpl impl) { { service::FieldResult { impl.getId() } }; }; template -concept WithParamsTitle = requires (TImpl impl, service::FieldParams params) +concept getTitleWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getTitle(std::move(params)) } }; }; template -concept NoParamsTitle = requires (TImpl impl) +concept getTitle = requires (TImpl impl) { { service::FieldResult> { impl.getTitle() } }; }; template -concept WithParamsIsComplete = requires (TImpl impl, service::FieldParams params) +concept getIsCompleteWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getIsComplete(std::move(params)) } }; }; template -concept NoParamsIsComplete = requires (TImpl impl) +concept getIsComplete = requires (TImpl impl) { { service::FieldResult { impl.getIsComplete() } }; }; template -concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.beginSelectionSet(params) }; }; template -concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.endSelectionSet(params) }; }; -} // namespace methods::TaskMethod +} // namespace methods::TaskHas class Task : public service::Object { private: - service::AwaitableResolver resolveId(service::ResolverParams&& params); - service::AwaitableResolver resolveTitle(service::ResolverParams&& params); - service::AwaitableResolver resolveIsComplete(service::ResolverParams&& params); + service::AwaitableResolver resolveId(service::ResolverParams&& params) const; + service::AwaitableResolver resolveTitle(service::ResolverParams&& params) const; + service::AwaitableResolver resolveIsComplete(service::ResolverParams&& params) const; - service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; struct Concept - : Node { virtual ~Concept() = default; virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual service::FieldResult getId(service::FieldParams&& params) const = 0; virtual service::FieldResult> getTitle(service::FieldParams&& params) const = 0; virtual service::FieldResult getIsComplete(service::FieldParams&& params) const = 0; }; @@ -96,11 +105,11 @@ class Task service::FieldResult getId(service::FieldParams&& params) const final { - if constexpr (methods::TaskMethod::WithParamsId) + if constexpr (methods::TaskHas::getIdWithParams) { return { _pimpl->getId(std::move(params)) }; } - else if constexpr (methods::TaskMethod::NoParamsId) + else if constexpr (methods::TaskHas::getId) { return { _pimpl->getId() }; } @@ -112,11 +121,11 @@ class Task service::FieldResult> getTitle(service::FieldParams&& params) const final { - if constexpr (methods::TaskMethod::WithParamsTitle) + if constexpr (methods::TaskHas::getTitleWithParams) { return { _pimpl->getTitle(std::move(params)) }; } - else if constexpr (methods::TaskMethod::NoParamsTitle) + else if constexpr (methods::TaskHas::getTitle) { return { _pimpl->getTitle() }; } @@ -128,11 +137,11 @@ class Task service::FieldResult getIsComplete(service::FieldParams&& params) const final { - if constexpr (methods::TaskMethod::WithParamsIsComplete) + if constexpr (methods::TaskHas::getIsCompleteWithParams) { return { _pimpl->getIsComplete(std::move(params)) }; } - else if constexpr (methods::TaskMethod::NoParamsIsComplete) + else if constexpr (methods::TaskHas::getIsComplete) { return { _pimpl->getIsComplete() }; } @@ -144,7 +153,7 @@ class Task void beginSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::TaskMethod::HasBeginSelectionSet) + if constexpr (methods::TaskHas::beginSelectionSet) { _pimpl->beginSelectionSet(params); } @@ -152,7 +161,7 @@ class Task void endSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::TaskMethod::HasEndSelectionSet) + if constexpr (methods::TaskHas::endSelectionSet) { _pimpl->endSelectionSet(params); } @@ -162,7 +171,19 @@ class Task const std::shared_ptr _pimpl; }; - Task(std::unique_ptr&& pimpl); + Task(std::unique_ptr&& pimpl) noexcept; + + // Interface objects need access to these methods + friend Node; + + template + static constexpr bool implements() noexcept + { + return implements::TaskIs; + } + + service::TypeNames getTypeNames() const noexcept; + service::ResolverMap getResolvers() const noexcept; void beginSelectionSet(const service::SelectionSetParams& params) const final; void endSelectionSet(const service::SelectionSetParams& params) const final; @@ -171,7 +192,7 @@ class Task public: template - Task(std::shared_ptr pimpl) + Task(std::shared_ptr pimpl) noexcept : Task { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } diff --git a/samples/today/separate_nointrospection/TodayObjects.h b/samples/today/separate_nointrospection/TodayObjects.h index 80502f8c..b9dda2ce 100644 --- a/samples/today/separate_nointrospection/TodayObjects.h +++ b/samples/today/separate_nointrospection/TodayObjects.h @@ -10,6 +10,7 @@ #include "TodaySchema.h" +#include "NodeObject.h" #include "QueryObject.h" #include "PageInfoObject.h" #include "AppointmentEdgeObject.h" diff --git a/samples/today/separate_nointrospection/TodaySchema.cpp b/samples/today/separate_nointrospection/TodaySchema.cpp index a3ba328b..88fc302b 100644 --- a/samples/today/separate_nointrospection/TodaySchema.cpp +++ b/samples/today/separate_nointrospection/TodaySchema.cpp @@ -240,9 +240,7 @@ void AddTypesToSchema(const std::shared_ptr& schema) schema->LookupType(R"gql(Folder)gql"sv) }); - typeNode->AddFields({ - schema::Field::Make(R"gql(id)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("ID"))) - }); + AddNodeDetails(typeNode, schema); AddQueryDetails(typeQuery, schema); AddPageInfoDetails(typePageInfo, schema); diff --git a/samples/today/separate_nointrospection/TodaySchema.h b/samples/today/separate_nointrospection/TodaySchema.h index f7afa110..c3042f81 100644 --- a/samples/today/separate_nointrospection/TodaySchema.h +++ b/samples/today/separate_nointrospection/TodaySchema.h @@ -62,6 +62,8 @@ struct FirstNestedInput namespace object { +class Node; + class Query; class PageInfo; class AppointmentEdge; @@ -81,11 +83,6 @@ class Expensive; } // namespace object -struct Node -{ - virtual service::FieldResult getId(service::FieldParams&& params) const = 0; -}; - class Operations : public service::Request { @@ -104,22 +101,24 @@ class Operations std::shared_ptr _subscription; }; -void AddQueryDetails(std::shared_ptr typeQuery, const std::shared_ptr& schema); -void AddPageInfoDetails(std::shared_ptr typePageInfo, const std::shared_ptr& schema); -void AddAppointmentEdgeDetails(std::shared_ptr typeAppointmentEdge, const std::shared_ptr& schema); -void AddAppointmentConnectionDetails(std::shared_ptr typeAppointmentConnection, const std::shared_ptr& schema); -void AddTaskEdgeDetails(std::shared_ptr typeTaskEdge, const std::shared_ptr& schema); -void AddTaskConnectionDetails(std::shared_ptr typeTaskConnection, const std::shared_ptr& schema); -void AddFolderEdgeDetails(std::shared_ptr typeFolderEdge, const std::shared_ptr& schema); -void AddFolderConnectionDetails(std::shared_ptr typeFolderConnection, const std::shared_ptr& schema); -void AddCompleteTaskPayloadDetails(std::shared_ptr typeCompleteTaskPayload, const std::shared_ptr& schema); -void AddMutationDetails(std::shared_ptr typeMutation, const std::shared_ptr& schema); -void AddSubscriptionDetails(std::shared_ptr typeSubscription, const std::shared_ptr& schema); -void AddAppointmentDetails(std::shared_ptr typeAppointment, const std::shared_ptr& schema); -void AddTaskDetails(std::shared_ptr typeTask, const std::shared_ptr& schema); -void AddFolderDetails(std::shared_ptr typeFolder, const std::shared_ptr& schema); -void AddNestedTypeDetails(std::shared_ptr typeNestedType, const std::shared_ptr& schema); -void AddExpensiveDetails(std::shared_ptr typeExpensive, const std::shared_ptr& schema); +void AddNodeDetails(const std::shared_ptr& typeNode, const std::shared_ptr& schema); + +void AddQueryDetails(const std::shared_ptr& typeQuery, const std::shared_ptr& schema); +void AddPageInfoDetails(const std::shared_ptr& typePageInfo, const std::shared_ptr& schema); +void AddAppointmentEdgeDetails(const std::shared_ptr& typeAppointmentEdge, const std::shared_ptr& schema); +void AddAppointmentConnectionDetails(const std::shared_ptr& typeAppointmentConnection, const std::shared_ptr& schema); +void AddTaskEdgeDetails(const std::shared_ptr& typeTaskEdge, const std::shared_ptr& schema); +void AddTaskConnectionDetails(const std::shared_ptr& typeTaskConnection, const std::shared_ptr& schema); +void AddFolderEdgeDetails(const std::shared_ptr& typeFolderEdge, const std::shared_ptr& schema); +void AddFolderConnectionDetails(const std::shared_ptr& typeFolderConnection, const std::shared_ptr& schema); +void AddCompleteTaskPayloadDetails(const std::shared_ptr& typeCompleteTaskPayload, const std::shared_ptr& schema); +void AddMutationDetails(const std::shared_ptr& typeMutation, const std::shared_ptr& schema); +void AddSubscriptionDetails(const std::shared_ptr& typeSubscription, const std::shared_ptr& schema); +void AddAppointmentDetails(const std::shared_ptr& typeAppointment, const std::shared_ptr& schema); +void AddTaskDetails(const std::shared_ptr& typeTask, const std::shared_ptr& schema); +void AddFolderDetails(const std::shared_ptr& typeFolder, const std::shared_ptr& schema); +void AddNestedTypeDetails(const std::shared_ptr& typeNestedType, const std::shared_ptr& schema); +void AddExpensiveDetails(const std::shared_ptr& typeExpensive, const std::shared_ptr& schema); std::shared_ptr GetSchema(); diff --git a/samples/today/separate_nointrospection/separate_nointrospection_schema_files b/samples/today/separate_nointrospection/separate_nointrospection_schema_files index f1fb1229..bb9ce34b 100644 --- a/samples/today/separate_nointrospection/separate_nointrospection_schema_files +++ b/samples/today/separate_nointrospection/separate_nointrospection_schema_files @@ -1,4 +1,5 @@ TodaySchema.cpp +NodeObject.cpp QueryObject.cpp PageInfoObject.cpp AppointmentEdgeObject.cpp diff --git a/samples/today/unified/TodaySchema.cpp b/samples/today/unified/TodaySchema.cpp index d399d22f..3688b3a8 100644 --- a/samples/today/unified/TodaySchema.cpp +++ b/samples/today/unified/TodaySchema.cpp @@ -141,10 +141,39 @@ today::FirstNestedInput ModifiedArgument::convert(const namespace today { namespace object { -Query::Query(std::unique_ptr&& pimpl) - : service::Object({ +Node::Node(std::unique_ptr&& pimpl) noexcept + : service::Object { pimpl->getTypeNames(), pimpl->getResolvers() } + , _pimpl { std::move(pimpl) } +{ +} + +void Node::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void Node::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} + +Query::Query(std::unique_ptr&& pimpl) noexcept + : service::Object{ getTypeNames(), getResolvers() } + , _schema { GetSchema() } + , _pimpl { std::move(pimpl) } +{ +} + +service::TypeNames Query::getTypeNames() const noexcept +{ + return { "Query" - }, { + }; +} + +service::ResolverMap Query::getResolvers() const noexcept +{ + return { { R"gql(node)gql"sv, [this](service::ResolverParams&& params) { return resolveNode(std::move(params)); } }, { R"gql(tasks)gql"sv, [this](service::ResolverParams&& params) { return resolveTasks(std::move(params)); } }, { R"gql(__type)gql"sv, [this](service::ResolverParams&& params) { return resolve_type(std::move(params)); } }, @@ -160,10 +189,7 @@ Query::Query(std::unique_ptr&& pimpl) { R"gql(unimplemented)gql"sv, [this](service::ResolverParams&& params) { return resolveUnimplemented(std::move(params)); } }, { R"gql(appointmentsById)gql"sv, [this](service::ResolverParams&& params) { return resolveAppointmentsById(std::move(params)); } }, { R"gql(unreadCountsById)gql"sv, [this](service::ResolverParams&& params) { return resolveUnreadCountsById(std::move(params)); } } - }) - , _schema(GetSchema()) - , _pimpl(std::move(pimpl)) -{ + }; } void Query::beginSelectionSet(const service::SelectionSetParams& params) const @@ -176,7 +202,7 @@ void Query::endSelectionSet(const service::SelectionSetParams& params) const _pimpl->endSelectionSet(params); } -service::AwaitableResolver Query::resolveNode(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveNode(service::ResolverParams&& params) const { auto argId = service::ModifiedArgument::require("id", params.arguments); std::unique_lock resolverLock(_resolverMutex); @@ -184,10 +210,10 @@ service::AwaitableResolver Query::resolveNode(service::ResolverParams&& params) auto result = _pimpl->getNode(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argId)); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Query::resolveAppointments(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveAppointments(service::ResolverParams&& params) const { auto argFirst = service::ModifiedArgument::require("first", params.arguments); auto argAfter = service::ModifiedArgument::require("after", params.arguments); @@ -201,7 +227,7 @@ service::AwaitableResolver Query::resolveAppointments(service::ResolverParams&& return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Query::resolveTasks(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveTasks(service::ResolverParams&& params) const { auto argFirst = service::ModifiedArgument::require("first", params.arguments); auto argAfter = service::ModifiedArgument::require("after", params.arguments); @@ -215,7 +241,7 @@ service::AwaitableResolver Query::resolveTasks(service::ResolverParams&& params) return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Query::resolveUnreadCounts(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveUnreadCounts(service::ResolverParams&& params) const { auto argFirst = service::ModifiedArgument::require("first", params.arguments); auto argAfter = service::ModifiedArgument::require("after", params.arguments); @@ -229,7 +255,7 @@ service::AwaitableResolver Query::resolveUnreadCounts(service::ResolverParams&& return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Query::resolveAppointmentsById(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveAppointmentsById(service::ResolverParams&& params) const { const auto defaultArguments = []() { @@ -262,7 +288,7 @@ service::AwaitableResolver Query::resolveAppointmentsById(service::ResolverParam return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Query::resolveTasksById(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveTasksById(service::ResolverParams&& params) const { auto argIds = service::ModifiedArgument::require("ids", params.arguments); std::unique_lock resolverLock(_resolverMutex); @@ -273,7 +299,7 @@ service::AwaitableResolver Query::resolveTasksById(service::ResolverParams&& par return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Query::resolveUnreadCountsById(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveUnreadCountsById(service::ResolverParams&& params) const { auto argIds = service::ModifiedArgument::require("ids", params.arguments); std::unique_lock resolverLock(_resolverMutex); @@ -284,7 +310,7 @@ service::AwaitableResolver Query::resolveUnreadCountsById(service::ResolverParam return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Query::resolveNested(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveNested(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -294,7 +320,7 @@ service::AwaitableResolver Query::resolveNested(service::ResolverParams&& params return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Query::resolveUnimplemented(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveUnimplemented(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -304,7 +330,7 @@ service::AwaitableResolver Query::resolveUnimplemented(service::ResolverParams&& return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Query::resolveExpensive(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveExpensive(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -314,7 +340,7 @@ service::AwaitableResolver Query::resolveExpensive(service::ResolverParams&& par return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Query::resolveTestTaskState(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveTestTaskState(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -324,7 +350,7 @@ service::AwaitableResolver Query::resolveTestTaskState(service::ResolverParams&& return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Query::resolveAnyType(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveAnyType(service::ResolverParams&& params) const { auto argIds = service::ModifiedArgument::require("ids", params.arguments); std::unique_lock resolverLock(_resolverMutex); @@ -335,17 +361,17 @@ service::AwaitableResolver Query::resolveAnyType(service::ResolverParams&& param return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Query::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver Query::resolve_typename(service::ResolverParams&& params) const { return service::ModifiedResult::convert(std::string{ R"gql(Query)gql" }, std::move(params)); } -service::AwaitableResolver Query::resolve_schema(service::ResolverParams&& params) +service::AwaitableResolver Query::resolve_schema(service::ResolverParams&& params) const { return service::ModifiedResult::convert(std::static_pointer_cast(std::make_shared(std::make_shared(_schema))), std::move(params)); } -service::AwaitableResolver Query::resolve_type(service::ResolverParams&& params) +service::AwaitableResolver Query::resolve_type(service::ResolverParams&& params) const { auto argName = service::ModifiedArgument::require("name", params.arguments); const auto& baseType = _schema->LookupType(argName); @@ -354,16 +380,26 @@ service::AwaitableResolver Query::resolve_type(service::ResolverParams&& params) return service::ModifiedResult::convert(result, std::move(params)); } -PageInfo::PageInfo(std::unique_ptr&& pimpl) - : service::Object({ +PageInfo::PageInfo(std::unique_ptr&& pimpl) noexcept + : service::Object{ getTypeNames(), getResolvers() } + , _pimpl { std::move(pimpl) } +{ +} + +service::TypeNames PageInfo::getTypeNames() const noexcept +{ + return { "PageInfo" - }, { + }; +} + +service::ResolverMap PageInfo::getResolvers() const noexcept +{ + return { { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, { R"gql(hasNextPage)gql"sv, [this](service::ResolverParams&& params) { return resolveHasNextPage(std::move(params)); } }, { R"gql(hasPreviousPage)gql"sv, [this](service::ResolverParams&& params) { return resolveHasPreviousPage(std::move(params)); } } - }) - , _pimpl(std::move(pimpl)) -{ + }; } void PageInfo::beginSelectionSet(const service::SelectionSetParams& params) const @@ -376,7 +412,7 @@ void PageInfo::endSelectionSet(const service::SelectionSetParams& params) const _pimpl->endSelectionSet(params); } -service::AwaitableResolver PageInfo::resolveHasNextPage(service::ResolverParams&& params) +service::AwaitableResolver PageInfo::resolveHasNextPage(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -386,7 +422,7 @@ service::AwaitableResolver PageInfo::resolveHasNextPage(service::ResolverParams& return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver PageInfo::resolveHasPreviousPage(service::ResolverParams&& params) +service::AwaitableResolver PageInfo::resolveHasPreviousPage(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -396,21 +432,31 @@ service::AwaitableResolver PageInfo::resolveHasPreviousPage(service::ResolverPar return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver PageInfo::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver PageInfo::resolve_typename(service::ResolverParams&& params) const { return service::ModifiedResult::convert(std::string{ R"gql(PageInfo)gql" }, std::move(params)); } -AppointmentEdge::AppointmentEdge(std::unique_ptr&& pimpl) - : service::Object({ +AppointmentEdge::AppointmentEdge(std::unique_ptr&& pimpl) noexcept + : service::Object{ getTypeNames(), getResolvers() } + , _pimpl { std::move(pimpl) } +{ +} + +service::TypeNames AppointmentEdge::getTypeNames() const noexcept +{ + return { "AppointmentEdge" - }, { + }; +} + +service::ResolverMap AppointmentEdge::getResolvers() const noexcept +{ + return { { R"gql(node)gql"sv, [this](service::ResolverParams&& params) { return resolveNode(std::move(params)); } }, { R"gql(cursor)gql"sv, [this](service::ResolverParams&& params) { return resolveCursor(std::move(params)); } }, { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } } - }) - , _pimpl(std::move(pimpl)) -{ + }; } void AppointmentEdge::beginSelectionSet(const service::SelectionSetParams& params) const @@ -423,7 +469,7 @@ void AppointmentEdge::endSelectionSet(const service::SelectionSetParams& params) _pimpl->endSelectionSet(params); } -service::AwaitableResolver AppointmentEdge::resolveNode(service::ResolverParams&& params) +service::AwaitableResolver AppointmentEdge::resolveNode(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -433,7 +479,7 @@ service::AwaitableResolver AppointmentEdge::resolveNode(service::ResolverParams& return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver AppointmentEdge::resolveCursor(service::ResolverParams&& params) +service::AwaitableResolver AppointmentEdge::resolveCursor(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -443,21 +489,31 @@ service::AwaitableResolver AppointmentEdge::resolveCursor(service::ResolverParam return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver AppointmentEdge::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver AppointmentEdge::resolve_typename(service::ResolverParams&& params) const { return service::ModifiedResult::convert(std::string{ R"gql(AppointmentEdge)gql" }, std::move(params)); } -AppointmentConnection::AppointmentConnection(std::unique_ptr&& pimpl) - : service::Object({ +AppointmentConnection::AppointmentConnection(std::unique_ptr&& pimpl) noexcept + : service::Object{ getTypeNames(), getResolvers() } + , _pimpl { std::move(pimpl) } +{ +} + +service::TypeNames AppointmentConnection::getTypeNames() const noexcept +{ + return { "AppointmentConnection" - }, { + }; +} + +service::ResolverMap AppointmentConnection::getResolvers() const noexcept +{ + return { { R"gql(edges)gql"sv, [this](service::ResolverParams&& params) { return resolveEdges(std::move(params)); } }, { R"gql(pageInfo)gql"sv, [this](service::ResolverParams&& params) { return resolvePageInfo(std::move(params)); } }, { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } } - }) - , _pimpl(std::move(pimpl)) -{ + }; } void AppointmentConnection::beginSelectionSet(const service::SelectionSetParams& params) const @@ -470,7 +526,7 @@ void AppointmentConnection::endSelectionSet(const service::SelectionSetParams& p _pimpl->endSelectionSet(params); } -service::AwaitableResolver AppointmentConnection::resolvePageInfo(service::ResolverParams&& params) +service::AwaitableResolver AppointmentConnection::resolvePageInfo(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -480,7 +536,7 @@ service::AwaitableResolver AppointmentConnection::resolvePageInfo(service::Resol return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver AppointmentConnection::resolveEdges(service::ResolverParams&& params) +service::AwaitableResolver AppointmentConnection::resolveEdges(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -490,21 +546,31 @@ service::AwaitableResolver AppointmentConnection::resolveEdges(service::Resolver return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver AppointmentConnection::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver AppointmentConnection::resolve_typename(service::ResolverParams&& params) const { return service::ModifiedResult::convert(std::string{ R"gql(AppointmentConnection)gql" }, std::move(params)); } -TaskEdge::TaskEdge(std::unique_ptr&& pimpl) - : service::Object({ +TaskEdge::TaskEdge(std::unique_ptr&& pimpl) noexcept + : service::Object{ getTypeNames(), getResolvers() } + , _pimpl { std::move(pimpl) } +{ +} + +service::TypeNames TaskEdge::getTypeNames() const noexcept +{ + return { "TaskEdge" - }, { + }; +} + +service::ResolverMap TaskEdge::getResolvers() const noexcept +{ + return { { R"gql(node)gql"sv, [this](service::ResolverParams&& params) { return resolveNode(std::move(params)); } }, { R"gql(cursor)gql"sv, [this](service::ResolverParams&& params) { return resolveCursor(std::move(params)); } }, { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } } - }) - , _pimpl(std::move(pimpl)) -{ + }; } void TaskEdge::beginSelectionSet(const service::SelectionSetParams& params) const @@ -517,7 +583,7 @@ void TaskEdge::endSelectionSet(const service::SelectionSetParams& params) const _pimpl->endSelectionSet(params); } -service::AwaitableResolver TaskEdge::resolveNode(service::ResolverParams&& params) +service::AwaitableResolver TaskEdge::resolveNode(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -527,7 +593,7 @@ service::AwaitableResolver TaskEdge::resolveNode(service::ResolverParams&& param return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver TaskEdge::resolveCursor(service::ResolverParams&& params) +service::AwaitableResolver TaskEdge::resolveCursor(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -537,21 +603,31 @@ service::AwaitableResolver TaskEdge::resolveCursor(service::ResolverParams&& par return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver TaskEdge::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver TaskEdge::resolve_typename(service::ResolverParams&& params) const { return service::ModifiedResult::convert(std::string{ R"gql(TaskEdge)gql" }, std::move(params)); } -TaskConnection::TaskConnection(std::unique_ptr&& pimpl) - : service::Object({ +TaskConnection::TaskConnection(std::unique_ptr&& pimpl) noexcept + : service::Object{ getTypeNames(), getResolvers() } + , _pimpl { std::move(pimpl) } +{ +} + +service::TypeNames TaskConnection::getTypeNames() const noexcept +{ + return { "TaskConnection" - }, { + }; +} + +service::ResolverMap TaskConnection::getResolvers() const noexcept +{ + return { { R"gql(edges)gql"sv, [this](service::ResolverParams&& params) { return resolveEdges(std::move(params)); } }, { R"gql(pageInfo)gql"sv, [this](service::ResolverParams&& params) { return resolvePageInfo(std::move(params)); } }, { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } } - }) - , _pimpl(std::move(pimpl)) -{ + }; } void TaskConnection::beginSelectionSet(const service::SelectionSetParams& params) const @@ -564,7 +640,7 @@ void TaskConnection::endSelectionSet(const service::SelectionSetParams& params) _pimpl->endSelectionSet(params); } -service::AwaitableResolver TaskConnection::resolvePageInfo(service::ResolverParams&& params) +service::AwaitableResolver TaskConnection::resolvePageInfo(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -574,7 +650,7 @@ service::AwaitableResolver TaskConnection::resolvePageInfo(service::ResolverPara return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver TaskConnection::resolveEdges(service::ResolverParams&& params) +service::AwaitableResolver TaskConnection::resolveEdges(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -584,21 +660,31 @@ service::AwaitableResolver TaskConnection::resolveEdges(service::ResolverParams& return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver TaskConnection::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver TaskConnection::resolve_typename(service::ResolverParams&& params) const { return service::ModifiedResult::convert(std::string{ R"gql(TaskConnection)gql" }, std::move(params)); } -FolderEdge::FolderEdge(std::unique_ptr&& pimpl) - : service::Object({ +FolderEdge::FolderEdge(std::unique_ptr&& pimpl) noexcept + : service::Object{ getTypeNames(), getResolvers() } + , _pimpl { std::move(pimpl) } +{ +} + +service::TypeNames FolderEdge::getTypeNames() const noexcept +{ + return { "FolderEdge" - }, { + }; +} + +service::ResolverMap FolderEdge::getResolvers() const noexcept +{ + return { { R"gql(node)gql"sv, [this](service::ResolverParams&& params) { return resolveNode(std::move(params)); } }, { R"gql(cursor)gql"sv, [this](service::ResolverParams&& params) { return resolveCursor(std::move(params)); } }, { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } } - }) - , _pimpl(std::move(pimpl)) -{ + }; } void FolderEdge::beginSelectionSet(const service::SelectionSetParams& params) const @@ -611,7 +697,7 @@ void FolderEdge::endSelectionSet(const service::SelectionSetParams& params) cons _pimpl->endSelectionSet(params); } -service::AwaitableResolver FolderEdge::resolveNode(service::ResolverParams&& params) +service::AwaitableResolver FolderEdge::resolveNode(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -621,7 +707,7 @@ service::AwaitableResolver FolderEdge::resolveNode(service::ResolverParams&& par return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver FolderEdge::resolveCursor(service::ResolverParams&& params) +service::AwaitableResolver FolderEdge::resolveCursor(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -631,21 +717,31 @@ service::AwaitableResolver FolderEdge::resolveCursor(service::ResolverParams&& p return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver FolderEdge::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver FolderEdge::resolve_typename(service::ResolverParams&& params) const { return service::ModifiedResult::convert(std::string{ R"gql(FolderEdge)gql" }, std::move(params)); } -FolderConnection::FolderConnection(std::unique_ptr&& pimpl) - : service::Object({ +FolderConnection::FolderConnection(std::unique_ptr&& pimpl) noexcept + : service::Object{ getTypeNames(), getResolvers() } + , _pimpl { std::move(pimpl) } +{ +} + +service::TypeNames FolderConnection::getTypeNames() const noexcept +{ + return { "FolderConnection" - }, { + }; +} + +service::ResolverMap FolderConnection::getResolvers() const noexcept +{ + return { { R"gql(edges)gql"sv, [this](service::ResolverParams&& params) { return resolveEdges(std::move(params)); } }, { R"gql(pageInfo)gql"sv, [this](service::ResolverParams&& params) { return resolvePageInfo(std::move(params)); } }, { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } } - }) - , _pimpl(std::move(pimpl)) -{ + }; } void FolderConnection::beginSelectionSet(const service::SelectionSetParams& params) const @@ -658,7 +754,7 @@ void FolderConnection::endSelectionSet(const service::SelectionSetParams& params _pimpl->endSelectionSet(params); } -service::AwaitableResolver FolderConnection::resolvePageInfo(service::ResolverParams&& params) +service::AwaitableResolver FolderConnection::resolvePageInfo(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -668,7 +764,7 @@ service::AwaitableResolver FolderConnection::resolvePageInfo(service::ResolverPa return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver FolderConnection::resolveEdges(service::ResolverParams&& params) +service::AwaitableResolver FolderConnection::resolveEdges(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -678,21 +774,31 @@ service::AwaitableResolver FolderConnection::resolveEdges(service::ResolverParam return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver FolderConnection::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver FolderConnection::resolve_typename(service::ResolverParams&& params) const { return service::ModifiedResult::convert(std::string{ R"gql(FolderConnection)gql" }, std::move(params)); } -CompleteTaskPayload::CompleteTaskPayload(std::unique_ptr&& pimpl) - : service::Object({ +CompleteTaskPayload::CompleteTaskPayload(std::unique_ptr&& pimpl) noexcept + : service::Object{ getTypeNames(), getResolvers() } + , _pimpl { std::move(pimpl) } +{ +} + +service::TypeNames CompleteTaskPayload::getTypeNames() const noexcept +{ + return { "CompleteTaskPayload" - }, { + }; +} + +service::ResolverMap CompleteTaskPayload::getResolvers() const noexcept +{ + return { { R"gql(task)gql"sv, [this](service::ResolverParams&& params) { return resolveTask(std::move(params)); } }, { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, { R"gql(clientMutationId)gql"sv, [this](service::ResolverParams&& params) { return resolveClientMutationId(std::move(params)); } } - }) - , _pimpl(std::move(pimpl)) -{ + }; } void CompleteTaskPayload::beginSelectionSet(const service::SelectionSetParams& params) const @@ -705,7 +811,7 @@ void CompleteTaskPayload::endSelectionSet(const service::SelectionSetParams& par _pimpl->endSelectionSet(params); } -service::AwaitableResolver CompleteTaskPayload::resolveTask(service::ResolverParams&& params) +service::AwaitableResolver CompleteTaskPayload::resolveTask(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -715,7 +821,7 @@ service::AwaitableResolver CompleteTaskPayload::resolveTask(service::ResolverPar return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver CompleteTaskPayload::resolveClientMutationId(service::ResolverParams&& params) +service::AwaitableResolver CompleteTaskPayload::resolveClientMutationId(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -725,21 +831,31 @@ service::AwaitableResolver CompleteTaskPayload::resolveClientMutationId(service: return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver CompleteTaskPayload::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver CompleteTaskPayload::resolve_typename(service::ResolverParams&& params) const { return service::ModifiedResult::convert(std::string{ R"gql(CompleteTaskPayload)gql" }, std::move(params)); } -Mutation::Mutation(std::unique_ptr&& pimpl) - : service::Object({ +Mutation::Mutation(std::unique_ptr&& pimpl) noexcept + : service::Object{ getTypeNames(), getResolvers() } + , _pimpl { std::move(pimpl) } +{ +} + +service::TypeNames Mutation::getTypeNames() const noexcept +{ + return { "Mutation" - }, { + }; +} + +service::ResolverMap Mutation::getResolvers() const noexcept +{ + return { { R"gql(setFloat)gql"sv, [this](service::ResolverParams&& params) { return resolveSetFloat(std::move(params)); } }, { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, { R"gql(completeTask)gql"sv, [this](service::ResolverParams&& params) { return resolveCompleteTask(std::move(params)); } } - }) - , _pimpl(std::move(pimpl)) -{ + }; } void Mutation::beginSelectionSet(const service::SelectionSetParams& params) const @@ -752,7 +868,7 @@ void Mutation::endSelectionSet(const service::SelectionSetParams& params) const _pimpl->endSelectionSet(params); } -service::AwaitableResolver Mutation::resolveCompleteTask(service::ResolverParams&& params) +service::AwaitableResolver Mutation::resolveCompleteTask(service::ResolverParams&& params) const { auto argInput = service::ModifiedArgument::require("input", params.arguments); std::unique_lock resolverLock(_resolverMutex); @@ -763,7 +879,7 @@ service::AwaitableResolver Mutation::resolveCompleteTask(service::ResolverParams return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Mutation::resolveSetFloat(service::ResolverParams&& params) +service::AwaitableResolver Mutation::resolveSetFloat(service::ResolverParams&& params) const { auto argValue = service::ModifiedArgument::require("value", params.arguments); std::unique_lock resolverLock(_resolverMutex); @@ -774,21 +890,31 @@ service::AwaitableResolver Mutation::resolveSetFloat(service::ResolverParams&& p return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Mutation::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver Mutation::resolve_typename(service::ResolverParams&& params) const { return service::ModifiedResult::convert(std::string{ R"gql(Mutation)gql" }, std::move(params)); } -Subscription::Subscription(std::unique_ptr&& pimpl) - : service::Object({ +Subscription::Subscription(std::unique_ptr&& pimpl) noexcept + : service::Object{ getTypeNames(), getResolvers() } + , _pimpl { std::move(pimpl) } +{ +} + +service::TypeNames Subscription::getTypeNames() const noexcept +{ + return { "Subscription" - }, { + }; +} + +service::ResolverMap Subscription::getResolvers() const noexcept +{ + return { { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, { R"gql(nodeChange)gql"sv, [this](service::ResolverParams&& params) { return resolveNodeChange(std::move(params)); } }, { R"gql(nextAppointmentChange)gql"sv, [this](service::ResolverParams&& params) { return resolveNextAppointmentChange(std::move(params)); } } - }) - , _pimpl(std::move(pimpl)) -{ + }; } void Subscription::beginSelectionSet(const service::SelectionSetParams& params) const @@ -801,7 +927,7 @@ void Subscription::endSelectionSet(const service::SelectionSetParams& params) co _pimpl->endSelectionSet(params); } -service::AwaitableResolver Subscription::resolveNextAppointmentChange(service::ResolverParams&& params) +service::AwaitableResolver Subscription::resolveNextAppointmentChange(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -811,7 +937,7 @@ service::AwaitableResolver Subscription::resolveNextAppointmentChange(service::R return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Subscription::resolveNodeChange(service::ResolverParams&& params) +service::AwaitableResolver Subscription::resolveNodeChange(service::ResolverParams&& params) const { auto argId = service::ModifiedArgument::require("id", params.arguments); std::unique_lock resolverLock(_resolverMutex); @@ -819,29 +945,39 @@ service::AwaitableResolver Subscription::resolveNodeChange(service::ResolverPara auto result = _pimpl->getNodeChange(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argId)); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Subscription::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver Subscription::resolve_typename(service::ResolverParams&& params) const { return service::ModifiedResult::convert(std::string{ R"gql(Subscription)gql" }, std::move(params)); } -Appointment::Appointment(std::unique_ptr&& pimpl) - : service::Object({ +Appointment::Appointment(std::unique_ptr&& pimpl) noexcept + : service::Object{ getTypeNames(), getResolvers() } + , _pimpl { std::move(pimpl) } +{ +} + +service::TypeNames Appointment::getTypeNames() const noexcept +{ + return { "Node", "UnionType", "Appointment" - }, { + }; +} + +service::ResolverMap Appointment::getResolvers() const noexcept +{ + return { { R"gql(id)gql"sv, [this](service::ResolverParams&& params) { return resolveId(std::move(params)); } }, { R"gql(when)gql"sv, [this](service::ResolverParams&& params) { return resolveWhen(std::move(params)); } }, { R"gql(isNow)gql"sv, [this](service::ResolverParams&& params) { return resolveIsNow(std::move(params)); } }, { R"gql(subject)gql"sv, [this](service::ResolverParams&& params) { return resolveSubject(std::move(params)); } }, { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, { R"gql(forceError)gql"sv, [this](service::ResolverParams&& params) { return resolveForceError(std::move(params)); } } - }) - , _pimpl(std::move(pimpl)) -{ + }; } void Appointment::beginSelectionSet(const service::SelectionSetParams& params) const @@ -854,7 +990,7 @@ void Appointment::endSelectionSet(const service::SelectionSetParams& params) con _pimpl->endSelectionSet(params); } -service::AwaitableResolver Appointment::resolveId(service::ResolverParams&& params) +service::AwaitableResolver Appointment::resolveId(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -864,7 +1000,7 @@ service::AwaitableResolver Appointment::resolveId(service::ResolverParams&& para return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Appointment::resolveWhen(service::ResolverParams&& params) +service::AwaitableResolver Appointment::resolveWhen(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -874,7 +1010,7 @@ service::AwaitableResolver Appointment::resolveWhen(service::ResolverParams&& pa return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Appointment::resolveSubject(service::ResolverParams&& params) +service::AwaitableResolver Appointment::resolveSubject(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -884,7 +1020,7 @@ service::AwaitableResolver Appointment::resolveSubject(service::ResolverParams&& return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Appointment::resolveIsNow(service::ResolverParams&& params) +service::AwaitableResolver Appointment::resolveIsNow(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -894,7 +1030,7 @@ service::AwaitableResolver Appointment::resolveIsNow(service::ResolverParams&& p return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Appointment::resolveForceError(service::ResolverParams&& params) +service::AwaitableResolver Appointment::resolveForceError(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -904,24 +1040,34 @@ service::AwaitableResolver Appointment::resolveForceError(service::ResolverParam return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Appointment::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver Appointment::resolve_typename(service::ResolverParams&& params) const { return service::ModifiedResult::convert(std::string{ R"gql(Appointment)gql" }, std::move(params)); } -Task::Task(std::unique_ptr&& pimpl) - : service::Object({ +Task::Task(std::unique_ptr&& pimpl) noexcept + : service::Object{ getTypeNames(), getResolvers() } + , _pimpl { std::move(pimpl) } +{ +} + +service::TypeNames Task::getTypeNames() const noexcept +{ + return { "Node", "UnionType", "Task" - }, { + }; +} + +service::ResolverMap Task::getResolvers() const noexcept +{ + return { { R"gql(id)gql"sv, [this](service::ResolverParams&& params) { return resolveId(std::move(params)); } }, { R"gql(title)gql"sv, [this](service::ResolverParams&& params) { return resolveTitle(std::move(params)); } }, { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, { R"gql(isComplete)gql"sv, [this](service::ResolverParams&& params) { return resolveIsComplete(std::move(params)); } } - }) - , _pimpl(std::move(pimpl)) -{ + }; } void Task::beginSelectionSet(const service::SelectionSetParams& params) const @@ -934,7 +1080,7 @@ void Task::endSelectionSet(const service::SelectionSetParams& params) const _pimpl->endSelectionSet(params); } -service::AwaitableResolver Task::resolveId(service::ResolverParams&& params) +service::AwaitableResolver Task::resolveId(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -944,7 +1090,7 @@ service::AwaitableResolver Task::resolveId(service::ResolverParams&& params) return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Task::resolveTitle(service::ResolverParams&& params) +service::AwaitableResolver Task::resolveTitle(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -954,7 +1100,7 @@ service::AwaitableResolver Task::resolveTitle(service::ResolverParams&& params) return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Task::resolveIsComplete(service::ResolverParams&& params) +service::AwaitableResolver Task::resolveIsComplete(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -964,24 +1110,34 @@ service::AwaitableResolver Task::resolveIsComplete(service::ResolverParams&& par return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Task::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver Task::resolve_typename(service::ResolverParams&& params) const { return service::ModifiedResult::convert(std::string{ R"gql(Task)gql" }, std::move(params)); } -Folder::Folder(std::unique_ptr&& pimpl) - : service::Object({ +Folder::Folder(std::unique_ptr&& pimpl) noexcept + : service::Object{ getTypeNames(), getResolvers() } + , _pimpl { std::move(pimpl) } +{ +} + +service::TypeNames Folder::getTypeNames() const noexcept +{ + return { "Node", "UnionType", "Folder" - }, { + }; +} + +service::ResolverMap Folder::getResolvers() const noexcept +{ + return { { R"gql(id)gql"sv, [this](service::ResolverParams&& params) { return resolveId(std::move(params)); } }, { R"gql(name)gql"sv, [this](service::ResolverParams&& params) { return resolveName(std::move(params)); } }, { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, { R"gql(unreadCount)gql"sv, [this](service::ResolverParams&& params) { return resolveUnreadCount(std::move(params)); } } - }) - , _pimpl(std::move(pimpl)) -{ + }; } void Folder::beginSelectionSet(const service::SelectionSetParams& params) const @@ -994,7 +1150,7 @@ void Folder::endSelectionSet(const service::SelectionSetParams& params) const _pimpl->endSelectionSet(params); } -service::AwaitableResolver Folder::resolveId(service::ResolverParams&& params) +service::AwaitableResolver Folder::resolveId(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -1004,7 +1160,7 @@ service::AwaitableResolver Folder::resolveId(service::ResolverParams&& params) return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Folder::resolveName(service::ResolverParams&& params) +service::AwaitableResolver Folder::resolveName(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -1014,7 +1170,7 @@ service::AwaitableResolver Folder::resolveName(service::ResolverParams&& params) return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Folder::resolveUnreadCount(service::ResolverParams&& params) +service::AwaitableResolver Folder::resolveUnreadCount(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -1024,21 +1180,31 @@ service::AwaitableResolver Folder::resolveUnreadCount(service::ResolverParams&& return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Folder::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver Folder::resolve_typename(service::ResolverParams&& params) const { return service::ModifiedResult::convert(std::string{ R"gql(Folder)gql" }, std::move(params)); } -NestedType::NestedType(std::unique_ptr&& pimpl) - : service::Object({ +NestedType::NestedType(std::unique_ptr&& pimpl) noexcept + : service::Object{ getTypeNames(), getResolvers() } + , _pimpl { std::move(pimpl) } +{ +} + +service::TypeNames NestedType::getTypeNames() const noexcept +{ + return { "NestedType" - }, { + }; +} + +service::ResolverMap NestedType::getResolvers() const noexcept +{ + return { { R"gql(depth)gql"sv, [this](service::ResolverParams&& params) { return resolveDepth(std::move(params)); } }, { R"gql(nested)gql"sv, [this](service::ResolverParams&& params) { return resolveNested(std::move(params)); } }, { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } } - }) - , _pimpl(std::move(pimpl)) -{ + }; } void NestedType::beginSelectionSet(const service::SelectionSetParams& params) const @@ -1051,7 +1217,7 @@ void NestedType::endSelectionSet(const service::SelectionSetParams& params) cons _pimpl->endSelectionSet(params); } -service::AwaitableResolver NestedType::resolveDepth(service::ResolverParams&& params) +service::AwaitableResolver NestedType::resolveDepth(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -1061,7 +1227,7 @@ service::AwaitableResolver NestedType::resolveDepth(service::ResolverParams&& pa return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver NestedType::resolveNested(service::ResolverParams&& params) +service::AwaitableResolver NestedType::resolveNested(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -1071,20 +1237,30 @@ service::AwaitableResolver NestedType::resolveNested(service::ResolverParams&& p return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver NestedType::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver NestedType::resolve_typename(service::ResolverParams&& params) const { return service::ModifiedResult::convert(std::string{ R"gql(NestedType)gql" }, std::move(params)); } -Expensive::Expensive(std::unique_ptr&& pimpl) - : service::Object({ +Expensive::Expensive(std::unique_ptr&& pimpl) noexcept + : service::Object{ getTypeNames(), getResolvers() } + , _pimpl { std::move(pimpl) } +{ +} + +service::TypeNames Expensive::getTypeNames() const noexcept +{ + return { "Expensive" - }, { + }; +} + +service::ResolverMap Expensive::getResolvers() const noexcept +{ + return { { R"gql(order)gql"sv, [this](service::ResolverParams&& params) { return resolveOrder(std::move(params)); } }, { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } } - }) - , _pimpl(std::move(pimpl)) -{ + }; } void Expensive::beginSelectionSet(const service::SelectionSetParams& params) const @@ -1097,7 +1273,7 @@ void Expensive::endSelectionSet(const service::SelectionSetParams& params) const _pimpl->endSelectionSet(params); } -service::AwaitableResolver Expensive::resolveOrder(service::ResolverParams&& params) +service::AwaitableResolver Expensive::resolveOrder(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -1107,7 +1283,7 @@ service::AwaitableResolver Expensive::resolveOrder(service::ResolverParams&& par return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Expensive::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver Expensive::resolve_typename(service::ResolverParams&& params) const { return service::ModifiedResult::convert(std::string{ R"gql(Expensive)gql" }, std::move(params)); } diff --git a/samples/today/unified/TodaySchema.h b/samples/today/unified/TodaySchema.h index 4dfaa0ef..736cfac9 100644 --- a/samples/today/unified/TodaySchema.h +++ b/samples/today/unified/TodaySchema.h @@ -62,6 +62,8 @@ struct FirstNestedInput namespace object { +class Node; + class Query; class PageInfo; class AppointmentEdge; @@ -79,844 +81,913 @@ class Folder; class NestedType; class Expensive; -} // namespace object - -struct Node +class Node + : public service::Object { - virtual service::FieldResult getId(service::FieldParams&& params) const = 0; +private: + struct Concept + { + virtual ~Concept() = default; + + virtual service::TypeNames getTypeNames() const noexcept = 0; + virtual service::ResolverMap getResolvers() const noexcept = 0; + + virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::TypeNames getTypeNames() const noexcept final + { + return _pimpl->getTypeNames(); + } + + service::ResolverMap getResolvers() const noexcept final + { + return _pimpl->getResolvers(); + } + + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + _pimpl->beginSelectionSet(params); + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + _pimpl->endSelectionSet(params); + } + + private: + const std::shared_ptr _pimpl; + }; + + Node(std::unique_ptr&& pimpl) noexcept; + + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; + + const std::unique_ptr _pimpl; + +public: + template + Node(std::shared_ptr pimpl) noexcept + : Node { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } + { + static_assert(T::template implements(), "Node is not implemented"); + } }; -namespace object { +namespace implements { + +template +concept AppointmentIs = std::is_same_v; + +template +concept TaskIs = std::is_same_v; + +template +concept FolderIs = std::is_same_v; + +} // namespace implements + namespace methods { -namespace QueryMethod { +namespace QueryHas { template -concept WithParamsNode = requires (TImpl impl, service::FieldParams params, response::IdType idArg) +concept getNodeWithParams = requires (TImpl impl, service::FieldParams params, response::IdType idArg) { - { service::FieldResult> { impl.getNode(std::move(params), std::move(idArg)) } }; + { service::FieldResult> { impl.getNode(std::move(params), std::move(idArg)) } }; }; template -concept NoParamsNode = requires (TImpl impl, response::IdType idArg) +concept getNode = requires (TImpl impl, response::IdType idArg) { - { service::FieldResult> { impl.getNode(std::move(idArg)) } }; + { service::FieldResult> { impl.getNode(std::move(idArg)) } }; }; template -concept WithParamsAppointments = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) +concept getAppointmentsWithParams = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) { { service::FieldResult> { impl.getAppointments(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; }; template -concept NoParamsAppointments = requires (TImpl impl, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) +concept getAppointments = requires (TImpl impl, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) { { service::FieldResult> { impl.getAppointments(std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; }; template -concept WithParamsTasks = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) +concept getTasksWithParams = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) { { service::FieldResult> { impl.getTasks(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; }; template -concept NoParamsTasks = requires (TImpl impl, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) +concept getTasks = requires (TImpl impl, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) { { service::FieldResult> { impl.getTasks(std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; }; template -concept WithParamsUnreadCounts = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) +concept getUnreadCountsWithParams = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) { { service::FieldResult> { impl.getUnreadCounts(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; }; template -concept NoParamsUnreadCounts = requires (TImpl impl, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) +concept getUnreadCounts = requires (TImpl impl, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) { { service::FieldResult> { impl.getUnreadCounts(std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; }; template -concept WithParamsAppointmentsById = requires (TImpl impl, service::FieldParams params, std::vector idsArg) +concept getAppointmentsByIdWithParams = requires (TImpl impl, service::FieldParams params, std::vector idsArg) { { service::FieldResult>> { impl.getAppointmentsById(std::move(params), std::move(idsArg)) } }; }; template -concept NoParamsAppointmentsById = requires (TImpl impl, std::vector idsArg) +concept getAppointmentsById = requires (TImpl impl, std::vector idsArg) { { service::FieldResult>> { impl.getAppointmentsById(std::move(idsArg)) } }; }; template -concept WithParamsTasksById = requires (TImpl impl, service::FieldParams params, std::vector idsArg) +concept getTasksByIdWithParams = requires (TImpl impl, service::FieldParams params, std::vector idsArg) { { service::FieldResult>> { impl.getTasksById(std::move(params), std::move(idsArg)) } }; }; template -concept NoParamsTasksById = requires (TImpl impl, std::vector idsArg) +concept getTasksById = requires (TImpl impl, std::vector idsArg) { { service::FieldResult>> { impl.getTasksById(std::move(idsArg)) } }; }; template -concept WithParamsUnreadCountsById = requires (TImpl impl, service::FieldParams params, std::vector idsArg) +concept getUnreadCountsByIdWithParams = requires (TImpl impl, service::FieldParams params, std::vector idsArg) { { service::FieldResult>> { impl.getUnreadCountsById(std::move(params), std::move(idsArg)) } }; }; template -concept NoParamsUnreadCountsById = requires (TImpl impl, std::vector idsArg) +concept getUnreadCountsById = requires (TImpl impl, std::vector idsArg) { { service::FieldResult>> { impl.getUnreadCountsById(std::move(idsArg)) } }; }; template -concept WithParamsNested = requires (TImpl impl, service::FieldParams params) +concept getNestedWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getNested(std::move(params)) } }; }; template -concept NoParamsNested = requires (TImpl impl) +concept getNested = requires (TImpl impl) { { service::FieldResult> { impl.getNested() } }; }; template -concept WithParamsUnimplemented = requires (TImpl impl, service::FieldParams params) +concept getUnimplementedWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getUnimplemented(std::move(params)) } }; }; template -concept NoParamsUnimplemented = requires (TImpl impl) +concept getUnimplemented = requires (TImpl impl) { { service::FieldResult { impl.getUnimplemented() } }; }; template -concept WithParamsExpensive = requires (TImpl impl, service::FieldParams params) +concept getExpensiveWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult>> { impl.getExpensive(std::move(params)) } }; }; template -concept NoParamsExpensive = requires (TImpl impl) +concept getExpensive = requires (TImpl impl) { { service::FieldResult>> { impl.getExpensive() } }; }; template -concept WithParamsTestTaskState = requires (TImpl impl, service::FieldParams params) +concept getTestTaskStateWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getTestTaskState(std::move(params)) } }; }; template -concept NoParamsTestTaskState = requires (TImpl impl) +concept getTestTaskState = requires (TImpl impl) { { service::FieldResult { impl.getTestTaskState() } }; }; template -concept WithParamsAnyType = requires (TImpl impl, service::FieldParams params, std::vector idsArg) +concept getAnyTypeWithParams = requires (TImpl impl, service::FieldParams params, std::vector idsArg) { { service::FieldResult>> { impl.getAnyType(std::move(params), std::move(idsArg)) } }; }; template -concept NoParamsAnyType = requires (TImpl impl, std::vector idsArg) +concept getAnyType = requires (TImpl impl, std::vector idsArg) { { service::FieldResult>> { impl.getAnyType(std::move(idsArg)) } }; }; template -concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.beginSelectionSet(params) }; }; template -concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.endSelectionSet(params) }; }; -} // namespace QueryMethod +} // namespace QueryHas -namespace PageInfoMethod { +namespace PageInfoHas { template -concept WithParamsHasNextPage = requires (TImpl impl, service::FieldParams params) +concept getHasNextPageWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getHasNextPage(std::move(params)) } }; }; template -concept NoParamsHasNextPage = requires (TImpl impl) +concept getHasNextPage = requires (TImpl impl) { { service::FieldResult { impl.getHasNextPage() } }; }; template -concept WithParamsHasPreviousPage = requires (TImpl impl, service::FieldParams params) +concept getHasPreviousPageWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getHasPreviousPage(std::move(params)) } }; }; template -concept NoParamsHasPreviousPage = requires (TImpl impl) +concept getHasPreviousPage = requires (TImpl impl) { { service::FieldResult { impl.getHasPreviousPage() } }; }; template -concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.beginSelectionSet(params) }; }; template -concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.endSelectionSet(params) }; }; -} // namespace PageInfoMethod +} // namespace PageInfoHas -namespace AppointmentEdgeMethod { +namespace AppointmentEdgeHas { template -concept WithParamsNode = requires (TImpl impl, service::FieldParams params) +concept getNodeWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getNode(std::move(params)) } }; }; template -concept NoParamsNode = requires (TImpl impl) +concept getNode = requires (TImpl impl) { { service::FieldResult> { impl.getNode() } }; }; template -concept WithParamsCursor = requires (TImpl impl, service::FieldParams params) +concept getCursorWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getCursor(std::move(params)) } }; }; template -concept NoParamsCursor = requires (TImpl impl) +concept getCursor = requires (TImpl impl) { { service::FieldResult { impl.getCursor() } }; }; template -concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.beginSelectionSet(params) }; }; template -concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.endSelectionSet(params) }; }; -} // namespace AppointmentEdgeMethod +} // namespace AppointmentEdgeHas -namespace AppointmentConnectionMethod { +namespace AppointmentConnectionHas { template -concept WithParamsPageInfo = requires (TImpl impl, service::FieldParams params) +concept getPageInfoWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getPageInfo(std::move(params)) } }; }; template -concept NoParamsPageInfo = requires (TImpl impl) +concept getPageInfo = requires (TImpl impl) { { service::FieldResult> { impl.getPageInfo() } }; }; template -concept WithParamsEdges = requires (TImpl impl, service::FieldParams params) +concept getEdgesWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult>>> { impl.getEdges(std::move(params)) } }; }; template -concept NoParamsEdges = requires (TImpl impl) +concept getEdges = requires (TImpl impl) { { service::FieldResult>>> { impl.getEdges() } }; }; template -concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.beginSelectionSet(params) }; }; template -concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.endSelectionSet(params) }; }; -} // namespace AppointmentConnectionMethod +} // namespace AppointmentConnectionHas -namespace TaskEdgeMethod { +namespace TaskEdgeHas { template -concept WithParamsNode = requires (TImpl impl, service::FieldParams params) +concept getNodeWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getNode(std::move(params)) } }; }; template -concept NoParamsNode = requires (TImpl impl) +concept getNode = requires (TImpl impl) { { service::FieldResult> { impl.getNode() } }; }; template -concept WithParamsCursor = requires (TImpl impl, service::FieldParams params) +concept getCursorWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getCursor(std::move(params)) } }; }; template -concept NoParamsCursor = requires (TImpl impl) +concept getCursor = requires (TImpl impl) { { service::FieldResult { impl.getCursor() } }; }; template -concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.beginSelectionSet(params) }; }; template -concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.endSelectionSet(params) }; }; -} // namespace TaskEdgeMethod +} // namespace TaskEdgeHas -namespace TaskConnectionMethod { +namespace TaskConnectionHas { template -concept WithParamsPageInfo = requires (TImpl impl, service::FieldParams params) +concept getPageInfoWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getPageInfo(std::move(params)) } }; }; template -concept NoParamsPageInfo = requires (TImpl impl) +concept getPageInfo = requires (TImpl impl) { { service::FieldResult> { impl.getPageInfo() } }; }; template -concept WithParamsEdges = requires (TImpl impl, service::FieldParams params) +concept getEdgesWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult>>> { impl.getEdges(std::move(params)) } }; }; template -concept NoParamsEdges = requires (TImpl impl) +concept getEdges = requires (TImpl impl) { { service::FieldResult>>> { impl.getEdges() } }; }; template -concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.beginSelectionSet(params) }; }; template -concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.endSelectionSet(params) }; }; -} // namespace TaskConnectionMethod +} // namespace TaskConnectionHas -namespace FolderEdgeMethod { +namespace FolderEdgeHas { template -concept WithParamsNode = requires (TImpl impl, service::FieldParams params) +concept getNodeWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getNode(std::move(params)) } }; }; template -concept NoParamsNode = requires (TImpl impl) +concept getNode = requires (TImpl impl) { { service::FieldResult> { impl.getNode() } }; }; template -concept WithParamsCursor = requires (TImpl impl, service::FieldParams params) +concept getCursorWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getCursor(std::move(params)) } }; }; template -concept NoParamsCursor = requires (TImpl impl) +concept getCursor = requires (TImpl impl) { { service::FieldResult { impl.getCursor() } }; }; template -concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.beginSelectionSet(params) }; }; template -concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.endSelectionSet(params) }; }; -} // namespace FolderEdgeMethod +} // namespace FolderEdgeHas -namespace FolderConnectionMethod { +namespace FolderConnectionHas { template -concept WithParamsPageInfo = requires (TImpl impl, service::FieldParams params) +concept getPageInfoWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getPageInfo(std::move(params)) } }; }; template -concept NoParamsPageInfo = requires (TImpl impl) +concept getPageInfo = requires (TImpl impl) { { service::FieldResult> { impl.getPageInfo() } }; }; template -concept WithParamsEdges = requires (TImpl impl, service::FieldParams params) +concept getEdgesWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult>>> { impl.getEdges(std::move(params)) } }; }; template -concept NoParamsEdges = requires (TImpl impl) +concept getEdges = requires (TImpl impl) { { service::FieldResult>>> { impl.getEdges() } }; }; template -concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.beginSelectionSet(params) }; }; template -concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.endSelectionSet(params) }; }; -} // namespace FolderConnectionMethod +} // namespace FolderConnectionHas -namespace CompleteTaskPayloadMethod { +namespace CompleteTaskPayloadHas { template -concept WithParamsTask = requires (TImpl impl, service::FieldParams params) +concept getTaskWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getTask(std::move(params)) } }; }; template -concept NoParamsTask = requires (TImpl impl) +concept getTask = requires (TImpl impl) { { service::FieldResult> { impl.getTask() } }; }; template -concept WithParamsClientMutationId = requires (TImpl impl, service::FieldParams params) +concept getClientMutationIdWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getClientMutationId(std::move(params)) } }; }; template -concept NoParamsClientMutationId = requires (TImpl impl) +concept getClientMutationId = requires (TImpl impl) { { service::FieldResult> { impl.getClientMutationId() } }; }; template -concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.beginSelectionSet(params) }; }; template -concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.endSelectionSet(params) }; }; -} // namespace CompleteTaskPayloadMethod +} // namespace CompleteTaskPayloadHas -namespace MutationMethod { +namespace MutationHas { template -concept WithParamsCompleteTask = requires (TImpl impl, service::FieldParams params, CompleteTaskInput inputArg) +concept applyCompleteTaskWithParams = requires (TImpl impl, service::FieldParams params, CompleteTaskInput inputArg) { { service::FieldResult> { impl.applyCompleteTask(std::move(params), std::move(inputArg)) } }; }; template -concept NoParamsCompleteTask = requires (TImpl impl, CompleteTaskInput inputArg) +concept applyCompleteTask = requires (TImpl impl, CompleteTaskInput inputArg) { { service::FieldResult> { impl.applyCompleteTask(std::move(inputArg)) } }; }; template -concept WithParamsSetFloat = requires (TImpl impl, service::FieldParams params, double valueArg) +concept applySetFloatWithParams = requires (TImpl impl, service::FieldParams params, double valueArg) { { service::FieldResult { impl.applySetFloat(std::move(params), std::move(valueArg)) } }; }; template -concept NoParamsSetFloat = requires (TImpl impl, double valueArg) +concept applySetFloat = requires (TImpl impl, double valueArg) { { service::FieldResult { impl.applySetFloat(std::move(valueArg)) } }; }; template -concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.beginSelectionSet(params) }; }; template -concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.endSelectionSet(params) }; }; -} // namespace MutationMethod +} // namespace MutationHas -namespace SubscriptionMethod { +namespace SubscriptionHas { template -concept WithParamsNextAppointmentChange = requires (TImpl impl, service::FieldParams params) +concept getNextAppointmentChangeWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getNextAppointmentChange(std::move(params)) } }; }; template -concept NoParamsNextAppointmentChange = requires (TImpl impl) +concept getNextAppointmentChange = requires (TImpl impl) { { service::FieldResult> { impl.getNextAppointmentChange() } }; }; template -concept WithParamsNodeChange = requires (TImpl impl, service::FieldParams params, response::IdType idArg) +concept getNodeChangeWithParams = requires (TImpl impl, service::FieldParams params, response::IdType idArg) { - { service::FieldResult> { impl.getNodeChange(std::move(params), std::move(idArg)) } }; + { service::FieldResult> { impl.getNodeChange(std::move(params), std::move(idArg)) } }; }; template -concept NoParamsNodeChange = requires (TImpl impl, response::IdType idArg) +concept getNodeChange = requires (TImpl impl, response::IdType idArg) { - { service::FieldResult> { impl.getNodeChange(std::move(idArg)) } }; + { service::FieldResult> { impl.getNodeChange(std::move(idArg)) } }; }; template -concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.beginSelectionSet(params) }; }; template -concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.endSelectionSet(params) }; }; -} // namespace SubscriptionMethod +} // namespace SubscriptionHas -namespace AppointmentMethod { +namespace AppointmentHas { template -concept WithParamsId = requires (TImpl impl, service::FieldParams params) +concept getIdWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getId(std::move(params)) } }; }; template -concept NoParamsId = requires (TImpl impl) +concept getId = requires (TImpl impl) { { service::FieldResult { impl.getId() } }; }; template -concept WithParamsWhen = requires (TImpl impl, service::FieldParams params) +concept getWhenWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getWhen(std::move(params)) } }; }; template -concept NoParamsWhen = requires (TImpl impl) +concept getWhen = requires (TImpl impl) { { service::FieldResult> { impl.getWhen() } }; }; template -concept WithParamsSubject = requires (TImpl impl, service::FieldParams params) +concept getSubjectWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getSubject(std::move(params)) } }; }; template -concept NoParamsSubject = requires (TImpl impl) +concept getSubject = requires (TImpl impl) { { service::FieldResult> { impl.getSubject() } }; }; template -concept WithParamsIsNow = requires (TImpl impl, service::FieldParams params) +concept getIsNowWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getIsNow(std::move(params)) } }; }; template -concept NoParamsIsNow = requires (TImpl impl) +concept getIsNow = requires (TImpl impl) { { service::FieldResult { impl.getIsNow() } }; }; template -concept WithParamsForceError = requires (TImpl impl, service::FieldParams params) +concept getForceErrorWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getForceError(std::move(params)) } }; }; template -concept NoParamsForceError = requires (TImpl impl) +concept getForceError = requires (TImpl impl) { { service::FieldResult> { impl.getForceError() } }; }; template -concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.beginSelectionSet(params) }; }; template -concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.endSelectionSet(params) }; }; -} // namespace AppointmentMethod +} // namespace AppointmentHas -namespace TaskMethod { +namespace TaskHas { template -concept WithParamsId = requires (TImpl impl, service::FieldParams params) +concept getIdWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getId(std::move(params)) } }; }; template -concept NoParamsId = requires (TImpl impl) +concept getId = requires (TImpl impl) { { service::FieldResult { impl.getId() } }; }; template -concept WithParamsTitle = requires (TImpl impl, service::FieldParams params) +concept getTitleWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getTitle(std::move(params)) } }; }; template -concept NoParamsTitle = requires (TImpl impl) +concept getTitle = requires (TImpl impl) { { service::FieldResult> { impl.getTitle() } }; }; template -concept WithParamsIsComplete = requires (TImpl impl, service::FieldParams params) +concept getIsCompleteWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getIsComplete(std::move(params)) } }; }; template -concept NoParamsIsComplete = requires (TImpl impl) +concept getIsComplete = requires (TImpl impl) { { service::FieldResult { impl.getIsComplete() } }; }; template -concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.beginSelectionSet(params) }; }; template -concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.endSelectionSet(params) }; }; -} // namespace TaskMethod +} // namespace TaskHas -namespace FolderMethod { +namespace FolderHas { template -concept WithParamsId = requires (TImpl impl, service::FieldParams params) +concept getIdWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getId(std::move(params)) } }; }; template -concept NoParamsId = requires (TImpl impl) +concept getId = requires (TImpl impl) { { service::FieldResult { impl.getId() } }; }; template -concept WithParamsName = requires (TImpl impl, service::FieldParams params) +concept getNameWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getName(std::move(params)) } }; }; template -concept NoParamsName = requires (TImpl impl) +concept getName = requires (TImpl impl) { { service::FieldResult> { impl.getName() } }; }; template -concept WithParamsUnreadCount = requires (TImpl impl, service::FieldParams params) +concept getUnreadCountWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getUnreadCount(std::move(params)) } }; }; template -concept NoParamsUnreadCount = requires (TImpl impl) +concept getUnreadCount = requires (TImpl impl) { { service::FieldResult { impl.getUnreadCount() } }; }; template -concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.beginSelectionSet(params) }; }; template -concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.endSelectionSet(params) }; }; -} // namespace FolderMethod +} // namespace FolderHas -namespace NestedTypeMethod { +namespace NestedTypeHas { template -concept WithParamsDepth = requires (TImpl impl, service::FieldParams params) +concept getDepthWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getDepth(std::move(params)) } }; }; template -concept NoParamsDepth = requires (TImpl impl) +concept getDepth = requires (TImpl impl) { { service::FieldResult { impl.getDepth() } }; }; template -concept WithParamsNested = requires (TImpl impl, service::FieldParams params) +concept getNestedWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getNested(std::move(params)) } }; }; template -concept NoParamsNested = requires (TImpl impl) +concept getNested = requires (TImpl impl) { { service::FieldResult> { impl.getNested() } }; }; template -concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.beginSelectionSet(params) }; }; template -concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.endSelectionSet(params) }; }; -} // namespace NestedTypeMethod +} // namespace NestedTypeHas -namespace ExpensiveMethod { +namespace ExpensiveHas { template -concept WithParamsOrder = requires (TImpl impl, service::FieldParams params) +concept getOrderWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getOrder(std::move(params)) } }; }; template -concept NoParamsOrder = requires (TImpl impl) +concept getOrder = requires (TImpl impl) { { service::FieldResult { impl.getOrder() } }; }; template -concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.beginSelectionSet(params) }; }; template -concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.endSelectionSet(params) }; }; -} // namespace ExpensiveMethod +} // namespace ExpensiveHas } // namespace methods class Query : public service::Object { private: - service::AwaitableResolver resolveNode(service::ResolverParams&& params); - service::AwaitableResolver resolveAppointments(service::ResolverParams&& params); - service::AwaitableResolver resolveTasks(service::ResolverParams&& params); - service::AwaitableResolver resolveUnreadCounts(service::ResolverParams&& params); - service::AwaitableResolver resolveAppointmentsById(service::ResolverParams&& params); - service::AwaitableResolver resolveTasksById(service::ResolverParams&& params); - service::AwaitableResolver resolveUnreadCountsById(service::ResolverParams&& params); - service::AwaitableResolver resolveNested(service::ResolverParams&& params); - service::AwaitableResolver resolveUnimplemented(service::ResolverParams&& params); - service::AwaitableResolver resolveExpensive(service::ResolverParams&& params); - service::AwaitableResolver resolveTestTaskState(service::ResolverParams&& params); - service::AwaitableResolver resolveAnyType(service::ResolverParams&& params); - - service::AwaitableResolver resolve_typename(service::ResolverParams&& params); - service::AwaitableResolver resolve_schema(service::ResolverParams&& params); - service::AwaitableResolver resolve_type(service::ResolverParams&& params); + service::AwaitableResolver resolveNode(service::ResolverParams&& params) const; + service::AwaitableResolver resolveAppointments(service::ResolverParams&& params) const; + service::AwaitableResolver resolveTasks(service::ResolverParams&& params) const; + service::AwaitableResolver resolveUnreadCounts(service::ResolverParams&& params) const; + service::AwaitableResolver resolveAppointmentsById(service::ResolverParams&& params) const; + service::AwaitableResolver resolveTasksById(service::ResolverParams&& params) const; + service::AwaitableResolver resolveUnreadCountsById(service::ResolverParams&& params) const; + service::AwaitableResolver resolveNested(service::ResolverParams&& params) const; + service::AwaitableResolver resolveUnimplemented(service::ResolverParams&& params) const; + service::AwaitableResolver resolveExpensive(service::ResolverParams&& params) const; + service::AwaitableResolver resolveTestTaskState(service::ResolverParams&& params) const; + service::AwaitableResolver resolveAnyType(service::ResolverParams&& params) const; + + service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; + service::AwaitableResolver resolve_schema(service::ResolverParams&& params) const; + service::AwaitableResolver resolve_type(service::ResolverParams&& params) const; std::shared_ptr _schema; @@ -927,7 +998,7 @@ class Query virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual service::FieldResult> getNode(service::FieldParams&& params, response::IdType&& idArg) const = 0; + virtual service::FieldResult> getNode(service::FieldParams&& params, response::IdType&& idArg) const = 0; virtual service::FieldResult> getAppointments(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const = 0; virtual service::FieldResult> getTasks(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const = 0; virtual service::FieldResult> getUnreadCounts(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const = 0; @@ -950,13 +1021,13 @@ class Query { } - service::FieldResult> getNode(service::FieldParams&& params, response::IdType&& idArg) const final + service::FieldResult> getNode(service::FieldParams&& params, response::IdType&& idArg) const final { - if constexpr (methods::QueryMethod::WithParamsNode) + if constexpr (methods::QueryHas::getNodeWithParams) { return { _pimpl->getNode(std::move(params), std::move(idArg)) }; } - else if constexpr (methods::QueryMethod::NoParamsNode) + else if constexpr (methods::QueryHas::getNode) { return { _pimpl->getNode(std::move(idArg)) }; } @@ -968,11 +1039,11 @@ class Query service::FieldResult> getAppointments(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const final { - if constexpr (methods::QueryMethod::WithParamsAppointments) + if constexpr (methods::QueryHas::getAppointmentsWithParams) { return { _pimpl->getAppointments(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) }; } - else if constexpr (methods::QueryMethod::NoParamsAppointments) + else if constexpr (methods::QueryHas::getAppointments) { return { _pimpl->getAppointments(std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) }; } @@ -984,11 +1055,11 @@ class Query service::FieldResult> getTasks(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const final { - if constexpr (methods::QueryMethod::WithParamsTasks) + if constexpr (methods::QueryHas::getTasksWithParams) { return { _pimpl->getTasks(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) }; } - else if constexpr (methods::QueryMethod::NoParamsTasks) + else if constexpr (methods::QueryHas::getTasks) { return { _pimpl->getTasks(std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) }; } @@ -1000,11 +1071,11 @@ class Query service::FieldResult> getUnreadCounts(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const final { - if constexpr (methods::QueryMethod::WithParamsUnreadCounts) + if constexpr (methods::QueryHas::getUnreadCountsWithParams) { return { _pimpl->getUnreadCounts(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) }; } - else if constexpr (methods::QueryMethod::NoParamsUnreadCounts) + else if constexpr (methods::QueryHas::getUnreadCounts) { return { _pimpl->getUnreadCounts(std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) }; } @@ -1016,11 +1087,11 @@ class Query service::FieldResult>> getAppointmentsById(service::FieldParams&& params, std::vector&& idsArg) const final { - if constexpr (methods::QueryMethod::WithParamsAppointmentsById) + if constexpr (methods::QueryHas::getAppointmentsByIdWithParams) { return { _pimpl->getAppointmentsById(std::move(params), std::move(idsArg)) }; } - else if constexpr (methods::QueryMethod::NoParamsAppointmentsById) + else if constexpr (methods::QueryHas::getAppointmentsById) { return { _pimpl->getAppointmentsById(std::move(idsArg)) }; } @@ -1032,11 +1103,11 @@ class Query service::FieldResult>> getTasksById(service::FieldParams&& params, std::vector&& idsArg) const final { - if constexpr (methods::QueryMethod::WithParamsTasksById) + if constexpr (methods::QueryHas::getTasksByIdWithParams) { return { _pimpl->getTasksById(std::move(params), std::move(idsArg)) }; } - else if constexpr (methods::QueryMethod::NoParamsTasksById) + else if constexpr (methods::QueryHas::getTasksById) { return { _pimpl->getTasksById(std::move(idsArg)) }; } @@ -1048,11 +1119,11 @@ class Query service::FieldResult>> getUnreadCountsById(service::FieldParams&& params, std::vector&& idsArg) const final { - if constexpr (methods::QueryMethod::WithParamsUnreadCountsById) + if constexpr (methods::QueryHas::getUnreadCountsByIdWithParams) { return { _pimpl->getUnreadCountsById(std::move(params), std::move(idsArg)) }; } - else if constexpr (methods::QueryMethod::NoParamsUnreadCountsById) + else if constexpr (methods::QueryHas::getUnreadCountsById) { return { _pimpl->getUnreadCountsById(std::move(idsArg)) }; } @@ -1064,11 +1135,11 @@ class Query service::FieldResult> getNested(service::FieldParams&& params) const final { - if constexpr (methods::QueryMethod::WithParamsNested) + if constexpr (methods::QueryHas::getNestedWithParams) { return { _pimpl->getNested(std::move(params)) }; } - else if constexpr (methods::QueryMethod::NoParamsNested) + else if constexpr (methods::QueryHas::getNested) { return { _pimpl->getNested() }; } @@ -1080,11 +1151,11 @@ class Query service::FieldResult getUnimplemented(service::FieldParams&& params) const final { - if constexpr (methods::QueryMethod::WithParamsUnimplemented) + if constexpr (methods::QueryHas::getUnimplementedWithParams) { return { _pimpl->getUnimplemented(std::move(params)) }; } - else if constexpr (methods::QueryMethod::NoParamsUnimplemented) + else if constexpr (methods::QueryHas::getUnimplemented) { return { _pimpl->getUnimplemented() }; } @@ -1096,11 +1167,11 @@ class Query service::FieldResult>> getExpensive(service::FieldParams&& params) const final { - if constexpr (methods::QueryMethod::WithParamsExpensive) + if constexpr (methods::QueryHas::getExpensiveWithParams) { return { _pimpl->getExpensive(std::move(params)) }; } - else if constexpr (methods::QueryMethod::NoParamsExpensive) + else if constexpr (methods::QueryHas::getExpensive) { return { _pimpl->getExpensive() }; } @@ -1112,11 +1183,11 @@ class Query service::FieldResult getTestTaskState(service::FieldParams&& params) const final { - if constexpr (methods::QueryMethod::WithParamsTestTaskState) + if constexpr (methods::QueryHas::getTestTaskStateWithParams) { return { _pimpl->getTestTaskState(std::move(params)) }; } - else if constexpr (methods::QueryMethod::NoParamsTestTaskState) + else if constexpr (methods::QueryHas::getTestTaskState) { return { _pimpl->getTestTaskState() }; } @@ -1128,11 +1199,11 @@ class Query service::FieldResult>> getAnyType(service::FieldParams&& params, std::vector&& idsArg) const final { - if constexpr (methods::QueryMethod::WithParamsAnyType) + if constexpr (methods::QueryHas::getAnyTypeWithParams) { return { _pimpl->getAnyType(std::move(params), std::move(idsArg)) }; } - else if constexpr (methods::QueryMethod::NoParamsAnyType) + else if constexpr (methods::QueryHas::getAnyType) { return { _pimpl->getAnyType(std::move(idsArg)) }; } @@ -1144,7 +1215,7 @@ class Query void beginSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::QueryMethod::HasBeginSelectionSet) + if constexpr (methods::QueryHas::beginSelectionSet) { _pimpl->beginSelectionSet(params); } @@ -1152,7 +1223,7 @@ class Query void endSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::QueryMethod::HasEndSelectionSet) + if constexpr (methods::QueryHas::endSelectionSet) { _pimpl->endSelectionSet(params); } @@ -1162,7 +1233,10 @@ class Query const std::shared_ptr _pimpl; }; - Query(std::unique_ptr&& pimpl); + Query(std::unique_ptr&& pimpl) noexcept; + + service::TypeNames getTypeNames() const noexcept; + service::ResolverMap getResolvers() const noexcept; void beginSelectionSet(const service::SelectionSetParams& params) const final; void endSelectionSet(const service::SelectionSetParams& params) const final; @@ -1171,7 +1245,7 @@ class Query public: template - Query(std::shared_ptr pimpl) + Query(std::shared_ptr pimpl) noexcept : Query { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } @@ -1181,10 +1255,10 @@ class PageInfo : public service::Object { private: - service::AwaitableResolver resolveHasNextPage(service::ResolverParams&& params); - service::AwaitableResolver resolveHasPreviousPage(service::ResolverParams&& params); + service::AwaitableResolver resolveHasNextPage(service::ResolverParams&& params) const; + service::AwaitableResolver resolveHasPreviousPage(service::ResolverParams&& params) const; - service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; struct Concept { @@ -1208,11 +1282,11 @@ class PageInfo service::FieldResult getHasNextPage(service::FieldParams&& params) const final { - if constexpr (methods::PageInfoMethod::WithParamsHasNextPage) + if constexpr (methods::PageInfoHas::getHasNextPageWithParams) { return { _pimpl->getHasNextPage(std::move(params)) }; } - else if constexpr (methods::PageInfoMethod::NoParamsHasNextPage) + else if constexpr (methods::PageInfoHas::getHasNextPage) { return { _pimpl->getHasNextPage() }; } @@ -1224,11 +1298,11 @@ class PageInfo service::FieldResult getHasPreviousPage(service::FieldParams&& params) const final { - if constexpr (methods::PageInfoMethod::WithParamsHasPreviousPage) + if constexpr (methods::PageInfoHas::getHasPreviousPageWithParams) { return { _pimpl->getHasPreviousPage(std::move(params)) }; } - else if constexpr (methods::PageInfoMethod::NoParamsHasPreviousPage) + else if constexpr (methods::PageInfoHas::getHasPreviousPage) { return { _pimpl->getHasPreviousPage() }; } @@ -1240,7 +1314,7 @@ class PageInfo void beginSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::PageInfoMethod::HasBeginSelectionSet) + if constexpr (methods::PageInfoHas::beginSelectionSet) { _pimpl->beginSelectionSet(params); } @@ -1248,7 +1322,7 @@ class PageInfo void endSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::PageInfoMethod::HasEndSelectionSet) + if constexpr (methods::PageInfoHas::endSelectionSet) { _pimpl->endSelectionSet(params); } @@ -1258,7 +1332,10 @@ class PageInfo const std::shared_ptr _pimpl; }; - PageInfo(std::unique_ptr&& pimpl); + PageInfo(std::unique_ptr&& pimpl) noexcept; + + service::TypeNames getTypeNames() const noexcept; + service::ResolverMap getResolvers() const noexcept; void beginSelectionSet(const service::SelectionSetParams& params) const final; void endSelectionSet(const service::SelectionSetParams& params) const final; @@ -1267,7 +1344,7 @@ class PageInfo public: template - PageInfo(std::shared_ptr pimpl) + PageInfo(std::shared_ptr pimpl) noexcept : PageInfo { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } @@ -1277,10 +1354,10 @@ class AppointmentEdge : public service::Object { private: - service::AwaitableResolver resolveNode(service::ResolverParams&& params); - service::AwaitableResolver resolveCursor(service::ResolverParams&& params); + service::AwaitableResolver resolveNode(service::ResolverParams&& params) const; + service::AwaitableResolver resolveCursor(service::ResolverParams&& params) const; - service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; struct Concept { @@ -1304,11 +1381,11 @@ class AppointmentEdge service::FieldResult> getNode(service::FieldParams&& params) const final { - if constexpr (methods::AppointmentEdgeMethod::WithParamsNode) + if constexpr (methods::AppointmentEdgeHas::getNodeWithParams) { return { _pimpl->getNode(std::move(params)) }; } - else if constexpr (methods::AppointmentEdgeMethod::NoParamsNode) + else if constexpr (methods::AppointmentEdgeHas::getNode) { return { _pimpl->getNode() }; } @@ -1320,11 +1397,11 @@ class AppointmentEdge service::FieldResult getCursor(service::FieldParams&& params) const final { - if constexpr (methods::AppointmentEdgeMethod::WithParamsCursor) + if constexpr (methods::AppointmentEdgeHas::getCursorWithParams) { return { _pimpl->getCursor(std::move(params)) }; } - else if constexpr (methods::AppointmentEdgeMethod::NoParamsCursor) + else if constexpr (methods::AppointmentEdgeHas::getCursor) { return { _pimpl->getCursor() }; } @@ -1336,7 +1413,7 @@ class AppointmentEdge void beginSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::AppointmentEdgeMethod::HasBeginSelectionSet) + if constexpr (methods::AppointmentEdgeHas::beginSelectionSet) { _pimpl->beginSelectionSet(params); } @@ -1344,7 +1421,7 @@ class AppointmentEdge void endSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::AppointmentEdgeMethod::HasEndSelectionSet) + if constexpr (methods::AppointmentEdgeHas::endSelectionSet) { _pimpl->endSelectionSet(params); } @@ -1354,7 +1431,10 @@ class AppointmentEdge const std::shared_ptr _pimpl; }; - AppointmentEdge(std::unique_ptr&& pimpl); + AppointmentEdge(std::unique_ptr&& pimpl) noexcept; + + service::TypeNames getTypeNames() const noexcept; + service::ResolverMap getResolvers() const noexcept; void beginSelectionSet(const service::SelectionSetParams& params) const final; void endSelectionSet(const service::SelectionSetParams& params) const final; @@ -1363,7 +1443,7 @@ class AppointmentEdge public: template - AppointmentEdge(std::shared_ptr pimpl) + AppointmentEdge(std::shared_ptr pimpl) noexcept : AppointmentEdge { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } @@ -1373,10 +1453,10 @@ class AppointmentConnection : public service::Object { private: - service::AwaitableResolver resolvePageInfo(service::ResolverParams&& params); - service::AwaitableResolver resolveEdges(service::ResolverParams&& params); + service::AwaitableResolver resolvePageInfo(service::ResolverParams&& params) const; + service::AwaitableResolver resolveEdges(service::ResolverParams&& params) const; - service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; struct Concept { @@ -1400,11 +1480,11 @@ class AppointmentConnection service::FieldResult> getPageInfo(service::FieldParams&& params) const final { - if constexpr (methods::AppointmentConnectionMethod::WithParamsPageInfo) + if constexpr (methods::AppointmentConnectionHas::getPageInfoWithParams) { return { _pimpl->getPageInfo(std::move(params)) }; } - else if constexpr (methods::AppointmentConnectionMethod::NoParamsPageInfo) + else if constexpr (methods::AppointmentConnectionHas::getPageInfo) { return { _pimpl->getPageInfo() }; } @@ -1416,11 +1496,11 @@ class AppointmentConnection service::FieldResult>>> getEdges(service::FieldParams&& params) const final { - if constexpr (methods::AppointmentConnectionMethod::WithParamsEdges) + if constexpr (methods::AppointmentConnectionHas::getEdgesWithParams) { return { _pimpl->getEdges(std::move(params)) }; } - else if constexpr (methods::AppointmentConnectionMethod::NoParamsEdges) + else if constexpr (methods::AppointmentConnectionHas::getEdges) { return { _pimpl->getEdges() }; } @@ -1432,7 +1512,7 @@ class AppointmentConnection void beginSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::AppointmentConnectionMethod::HasBeginSelectionSet) + if constexpr (methods::AppointmentConnectionHas::beginSelectionSet) { _pimpl->beginSelectionSet(params); } @@ -1440,7 +1520,7 @@ class AppointmentConnection void endSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::AppointmentConnectionMethod::HasEndSelectionSet) + if constexpr (methods::AppointmentConnectionHas::endSelectionSet) { _pimpl->endSelectionSet(params); } @@ -1450,7 +1530,10 @@ class AppointmentConnection const std::shared_ptr _pimpl; }; - AppointmentConnection(std::unique_ptr&& pimpl); + AppointmentConnection(std::unique_ptr&& pimpl) noexcept; + + service::TypeNames getTypeNames() const noexcept; + service::ResolverMap getResolvers() const noexcept; void beginSelectionSet(const service::SelectionSetParams& params) const final; void endSelectionSet(const service::SelectionSetParams& params) const final; @@ -1459,7 +1542,7 @@ class AppointmentConnection public: template - AppointmentConnection(std::shared_ptr pimpl) + AppointmentConnection(std::shared_ptr pimpl) noexcept : AppointmentConnection { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } @@ -1469,10 +1552,10 @@ class TaskEdge : public service::Object { private: - service::AwaitableResolver resolveNode(service::ResolverParams&& params); - service::AwaitableResolver resolveCursor(service::ResolverParams&& params); + service::AwaitableResolver resolveNode(service::ResolverParams&& params) const; + service::AwaitableResolver resolveCursor(service::ResolverParams&& params) const; - service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; struct Concept { @@ -1496,11 +1579,11 @@ class TaskEdge service::FieldResult> getNode(service::FieldParams&& params) const final { - if constexpr (methods::TaskEdgeMethod::WithParamsNode) + if constexpr (methods::TaskEdgeHas::getNodeWithParams) { return { _pimpl->getNode(std::move(params)) }; } - else if constexpr (methods::TaskEdgeMethod::NoParamsNode) + else if constexpr (methods::TaskEdgeHas::getNode) { return { _pimpl->getNode() }; } @@ -1512,11 +1595,11 @@ class TaskEdge service::FieldResult getCursor(service::FieldParams&& params) const final { - if constexpr (methods::TaskEdgeMethod::WithParamsCursor) + if constexpr (methods::TaskEdgeHas::getCursorWithParams) { return { _pimpl->getCursor(std::move(params)) }; } - else if constexpr (methods::TaskEdgeMethod::NoParamsCursor) + else if constexpr (methods::TaskEdgeHas::getCursor) { return { _pimpl->getCursor() }; } @@ -1528,7 +1611,7 @@ class TaskEdge void beginSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::TaskEdgeMethod::HasBeginSelectionSet) + if constexpr (methods::TaskEdgeHas::beginSelectionSet) { _pimpl->beginSelectionSet(params); } @@ -1536,7 +1619,7 @@ class TaskEdge void endSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::TaskEdgeMethod::HasEndSelectionSet) + if constexpr (methods::TaskEdgeHas::endSelectionSet) { _pimpl->endSelectionSet(params); } @@ -1546,7 +1629,10 @@ class TaskEdge const std::shared_ptr _pimpl; }; - TaskEdge(std::unique_ptr&& pimpl); + TaskEdge(std::unique_ptr&& pimpl) noexcept; + + service::TypeNames getTypeNames() const noexcept; + service::ResolverMap getResolvers() const noexcept; void beginSelectionSet(const service::SelectionSetParams& params) const final; void endSelectionSet(const service::SelectionSetParams& params) const final; @@ -1555,7 +1641,7 @@ class TaskEdge public: template - TaskEdge(std::shared_ptr pimpl) + TaskEdge(std::shared_ptr pimpl) noexcept : TaskEdge { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } @@ -1565,10 +1651,10 @@ class TaskConnection : public service::Object { private: - service::AwaitableResolver resolvePageInfo(service::ResolverParams&& params); - service::AwaitableResolver resolveEdges(service::ResolverParams&& params); + service::AwaitableResolver resolvePageInfo(service::ResolverParams&& params) const; + service::AwaitableResolver resolveEdges(service::ResolverParams&& params) const; - service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; struct Concept { @@ -1592,11 +1678,11 @@ class TaskConnection service::FieldResult> getPageInfo(service::FieldParams&& params) const final { - if constexpr (methods::TaskConnectionMethod::WithParamsPageInfo) + if constexpr (methods::TaskConnectionHas::getPageInfoWithParams) { return { _pimpl->getPageInfo(std::move(params)) }; } - else if constexpr (methods::TaskConnectionMethod::NoParamsPageInfo) + else if constexpr (methods::TaskConnectionHas::getPageInfo) { return { _pimpl->getPageInfo() }; } @@ -1608,11 +1694,11 @@ class TaskConnection service::FieldResult>>> getEdges(service::FieldParams&& params) const final { - if constexpr (methods::TaskConnectionMethod::WithParamsEdges) + if constexpr (methods::TaskConnectionHas::getEdgesWithParams) { return { _pimpl->getEdges(std::move(params)) }; } - else if constexpr (methods::TaskConnectionMethod::NoParamsEdges) + else if constexpr (methods::TaskConnectionHas::getEdges) { return { _pimpl->getEdges() }; } @@ -1624,7 +1710,7 @@ class TaskConnection void beginSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::TaskConnectionMethod::HasBeginSelectionSet) + if constexpr (methods::TaskConnectionHas::beginSelectionSet) { _pimpl->beginSelectionSet(params); } @@ -1632,7 +1718,7 @@ class TaskConnection void endSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::TaskConnectionMethod::HasEndSelectionSet) + if constexpr (methods::TaskConnectionHas::endSelectionSet) { _pimpl->endSelectionSet(params); } @@ -1642,7 +1728,10 @@ class TaskConnection const std::shared_ptr _pimpl; }; - TaskConnection(std::unique_ptr&& pimpl); + TaskConnection(std::unique_ptr&& pimpl) noexcept; + + service::TypeNames getTypeNames() const noexcept; + service::ResolverMap getResolvers() const noexcept; void beginSelectionSet(const service::SelectionSetParams& params) const final; void endSelectionSet(const service::SelectionSetParams& params) const final; @@ -1651,7 +1740,7 @@ class TaskConnection public: template - TaskConnection(std::shared_ptr pimpl) + TaskConnection(std::shared_ptr pimpl) noexcept : TaskConnection { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } @@ -1661,10 +1750,10 @@ class FolderEdge : public service::Object { private: - service::AwaitableResolver resolveNode(service::ResolverParams&& params); - service::AwaitableResolver resolveCursor(service::ResolverParams&& params); + service::AwaitableResolver resolveNode(service::ResolverParams&& params) const; + service::AwaitableResolver resolveCursor(service::ResolverParams&& params) const; - service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; struct Concept { @@ -1688,11 +1777,11 @@ class FolderEdge service::FieldResult> getNode(service::FieldParams&& params) const final { - if constexpr (methods::FolderEdgeMethod::WithParamsNode) + if constexpr (methods::FolderEdgeHas::getNodeWithParams) { return { _pimpl->getNode(std::move(params)) }; } - else if constexpr (methods::FolderEdgeMethod::NoParamsNode) + else if constexpr (methods::FolderEdgeHas::getNode) { return { _pimpl->getNode() }; } @@ -1704,11 +1793,11 @@ class FolderEdge service::FieldResult getCursor(service::FieldParams&& params) const final { - if constexpr (methods::FolderEdgeMethod::WithParamsCursor) + if constexpr (methods::FolderEdgeHas::getCursorWithParams) { return { _pimpl->getCursor(std::move(params)) }; } - else if constexpr (methods::FolderEdgeMethod::NoParamsCursor) + else if constexpr (methods::FolderEdgeHas::getCursor) { return { _pimpl->getCursor() }; } @@ -1720,7 +1809,7 @@ class FolderEdge void beginSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::FolderEdgeMethod::HasBeginSelectionSet) + if constexpr (methods::FolderEdgeHas::beginSelectionSet) { _pimpl->beginSelectionSet(params); } @@ -1728,7 +1817,7 @@ class FolderEdge void endSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::FolderEdgeMethod::HasEndSelectionSet) + if constexpr (methods::FolderEdgeHas::endSelectionSet) { _pimpl->endSelectionSet(params); } @@ -1738,7 +1827,10 @@ class FolderEdge const std::shared_ptr _pimpl; }; - FolderEdge(std::unique_ptr&& pimpl); + FolderEdge(std::unique_ptr&& pimpl) noexcept; + + service::TypeNames getTypeNames() const noexcept; + service::ResolverMap getResolvers() const noexcept; void beginSelectionSet(const service::SelectionSetParams& params) const final; void endSelectionSet(const service::SelectionSetParams& params) const final; @@ -1747,7 +1839,7 @@ class FolderEdge public: template - FolderEdge(std::shared_ptr pimpl) + FolderEdge(std::shared_ptr pimpl) noexcept : FolderEdge { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } @@ -1757,10 +1849,10 @@ class FolderConnection : public service::Object { private: - service::AwaitableResolver resolvePageInfo(service::ResolverParams&& params); - service::AwaitableResolver resolveEdges(service::ResolverParams&& params); + service::AwaitableResolver resolvePageInfo(service::ResolverParams&& params) const; + service::AwaitableResolver resolveEdges(service::ResolverParams&& params) const; - service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; struct Concept { @@ -1784,11 +1876,11 @@ class FolderConnection service::FieldResult> getPageInfo(service::FieldParams&& params) const final { - if constexpr (methods::FolderConnectionMethod::WithParamsPageInfo) + if constexpr (methods::FolderConnectionHas::getPageInfoWithParams) { return { _pimpl->getPageInfo(std::move(params)) }; } - else if constexpr (methods::FolderConnectionMethod::NoParamsPageInfo) + else if constexpr (methods::FolderConnectionHas::getPageInfo) { return { _pimpl->getPageInfo() }; } @@ -1800,11 +1892,11 @@ class FolderConnection service::FieldResult>>> getEdges(service::FieldParams&& params) const final { - if constexpr (methods::FolderConnectionMethod::WithParamsEdges) + if constexpr (methods::FolderConnectionHas::getEdgesWithParams) { return { _pimpl->getEdges(std::move(params)) }; } - else if constexpr (methods::FolderConnectionMethod::NoParamsEdges) + else if constexpr (methods::FolderConnectionHas::getEdges) { return { _pimpl->getEdges() }; } @@ -1816,7 +1908,7 @@ class FolderConnection void beginSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::FolderConnectionMethod::HasBeginSelectionSet) + if constexpr (methods::FolderConnectionHas::beginSelectionSet) { _pimpl->beginSelectionSet(params); } @@ -1824,7 +1916,7 @@ class FolderConnection void endSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::FolderConnectionMethod::HasEndSelectionSet) + if constexpr (methods::FolderConnectionHas::endSelectionSet) { _pimpl->endSelectionSet(params); } @@ -1834,7 +1926,10 @@ class FolderConnection const std::shared_ptr _pimpl; }; - FolderConnection(std::unique_ptr&& pimpl); + FolderConnection(std::unique_ptr&& pimpl) noexcept; + + service::TypeNames getTypeNames() const noexcept; + service::ResolverMap getResolvers() const noexcept; void beginSelectionSet(const service::SelectionSetParams& params) const final; void endSelectionSet(const service::SelectionSetParams& params) const final; @@ -1843,7 +1938,7 @@ class FolderConnection public: template - FolderConnection(std::shared_ptr pimpl) + FolderConnection(std::shared_ptr pimpl) noexcept : FolderConnection { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } @@ -1853,10 +1948,10 @@ class CompleteTaskPayload : public service::Object { private: - service::AwaitableResolver resolveTask(service::ResolverParams&& params); - service::AwaitableResolver resolveClientMutationId(service::ResolverParams&& params); + service::AwaitableResolver resolveTask(service::ResolverParams&& params) const; + service::AwaitableResolver resolveClientMutationId(service::ResolverParams&& params) const; - service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; struct Concept { @@ -1880,11 +1975,11 @@ class CompleteTaskPayload service::FieldResult> getTask(service::FieldParams&& params) const final { - if constexpr (methods::CompleteTaskPayloadMethod::WithParamsTask) + if constexpr (methods::CompleteTaskPayloadHas::getTaskWithParams) { return { _pimpl->getTask(std::move(params)) }; } - else if constexpr (methods::CompleteTaskPayloadMethod::NoParamsTask) + else if constexpr (methods::CompleteTaskPayloadHas::getTask) { return { _pimpl->getTask() }; } @@ -1896,11 +1991,11 @@ class CompleteTaskPayload service::FieldResult> getClientMutationId(service::FieldParams&& params) const final { - if constexpr (methods::CompleteTaskPayloadMethod::WithParamsClientMutationId) + if constexpr (methods::CompleteTaskPayloadHas::getClientMutationIdWithParams) { return { _pimpl->getClientMutationId(std::move(params)) }; } - else if constexpr (methods::CompleteTaskPayloadMethod::NoParamsClientMutationId) + else if constexpr (methods::CompleteTaskPayloadHas::getClientMutationId) { return { _pimpl->getClientMutationId() }; } @@ -1912,7 +2007,7 @@ class CompleteTaskPayload void beginSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::CompleteTaskPayloadMethod::HasBeginSelectionSet) + if constexpr (methods::CompleteTaskPayloadHas::beginSelectionSet) { _pimpl->beginSelectionSet(params); } @@ -1920,7 +2015,7 @@ class CompleteTaskPayload void endSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::CompleteTaskPayloadMethod::HasEndSelectionSet) + if constexpr (methods::CompleteTaskPayloadHas::endSelectionSet) { _pimpl->endSelectionSet(params); } @@ -1930,7 +2025,10 @@ class CompleteTaskPayload const std::shared_ptr _pimpl; }; - CompleteTaskPayload(std::unique_ptr&& pimpl); + CompleteTaskPayload(std::unique_ptr&& pimpl) noexcept; + + service::TypeNames getTypeNames() const noexcept; + service::ResolverMap getResolvers() const noexcept; void beginSelectionSet(const service::SelectionSetParams& params) const final; void endSelectionSet(const service::SelectionSetParams& params) const final; @@ -1939,7 +2037,7 @@ class CompleteTaskPayload public: template - CompleteTaskPayload(std::shared_ptr pimpl) + CompleteTaskPayload(std::shared_ptr pimpl) noexcept : CompleteTaskPayload { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } @@ -1949,10 +2047,10 @@ class Mutation : public service::Object { private: - service::AwaitableResolver resolveCompleteTask(service::ResolverParams&& params); - service::AwaitableResolver resolveSetFloat(service::ResolverParams&& params); + service::AwaitableResolver resolveCompleteTask(service::ResolverParams&& params) const; + service::AwaitableResolver resolveSetFloat(service::ResolverParams&& params) const; - service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; struct Concept { @@ -1976,11 +2074,11 @@ class Mutation service::FieldResult> applyCompleteTask(service::FieldParams&& params, CompleteTaskInput&& inputArg) const final { - if constexpr (methods::MutationMethod::WithParamsCompleteTask) + if constexpr (methods::MutationHas::applyCompleteTaskWithParams) { return { _pimpl->applyCompleteTask(std::move(params), std::move(inputArg)) }; } - else if constexpr (methods::MutationMethod::NoParamsCompleteTask) + else if constexpr (methods::MutationHas::applyCompleteTask) { return { _pimpl->applyCompleteTask(std::move(inputArg)) }; } @@ -1992,11 +2090,11 @@ class Mutation service::FieldResult applySetFloat(service::FieldParams&& params, double&& valueArg) const final { - if constexpr (methods::MutationMethod::WithParamsSetFloat) + if constexpr (methods::MutationHas::applySetFloatWithParams) { return { _pimpl->applySetFloat(std::move(params), std::move(valueArg)) }; } - else if constexpr (methods::MutationMethod::NoParamsSetFloat) + else if constexpr (methods::MutationHas::applySetFloat) { return { _pimpl->applySetFloat(std::move(valueArg)) }; } @@ -2008,7 +2106,7 @@ class Mutation void beginSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::MutationMethod::HasBeginSelectionSet) + if constexpr (methods::MutationHas::beginSelectionSet) { _pimpl->beginSelectionSet(params); } @@ -2016,7 +2114,7 @@ class Mutation void endSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::MutationMethod::HasEndSelectionSet) + if constexpr (methods::MutationHas::endSelectionSet) { _pimpl->endSelectionSet(params); } @@ -2026,7 +2124,10 @@ class Mutation const std::shared_ptr _pimpl; }; - Mutation(std::unique_ptr&& pimpl); + Mutation(std::unique_ptr&& pimpl) noexcept; + + service::TypeNames getTypeNames() const noexcept; + service::ResolverMap getResolvers() const noexcept; void beginSelectionSet(const service::SelectionSetParams& params) const final; void endSelectionSet(const service::SelectionSetParams& params) const final; @@ -2035,7 +2136,7 @@ class Mutation public: template - Mutation(std::shared_ptr pimpl) + Mutation(std::shared_ptr pimpl) noexcept : Mutation { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } @@ -2045,10 +2146,10 @@ class Subscription : public service::Object { private: - service::AwaitableResolver resolveNextAppointmentChange(service::ResolverParams&& params); - service::AwaitableResolver resolveNodeChange(service::ResolverParams&& params); + service::AwaitableResolver resolveNextAppointmentChange(service::ResolverParams&& params) const; + service::AwaitableResolver resolveNodeChange(service::ResolverParams&& params) const; - service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; struct Concept { @@ -2058,7 +2159,7 @@ class Subscription virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; virtual service::FieldResult> getNextAppointmentChange(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getNodeChange(service::FieldParams&& params, response::IdType&& idArg) const = 0; + virtual service::FieldResult> getNodeChange(service::FieldParams&& params, response::IdType&& idArg) const = 0; }; template @@ -2072,11 +2173,11 @@ class Subscription service::FieldResult> getNextAppointmentChange(service::FieldParams&& params) const final { - if constexpr (methods::SubscriptionMethod::WithParamsNextAppointmentChange) + if constexpr (methods::SubscriptionHas::getNextAppointmentChangeWithParams) { return { _pimpl->getNextAppointmentChange(std::move(params)) }; } - else if constexpr (methods::SubscriptionMethod::NoParamsNextAppointmentChange) + else if constexpr (methods::SubscriptionHas::getNextAppointmentChange) { return { _pimpl->getNextAppointmentChange() }; } @@ -2086,13 +2187,13 @@ class Subscription } } - service::FieldResult> getNodeChange(service::FieldParams&& params, response::IdType&& idArg) const final + service::FieldResult> getNodeChange(service::FieldParams&& params, response::IdType&& idArg) const final { - if constexpr (methods::SubscriptionMethod::WithParamsNodeChange) + if constexpr (methods::SubscriptionHas::getNodeChangeWithParams) { return { _pimpl->getNodeChange(std::move(params), std::move(idArg)) }; } - else if constexpr (methods::SubscriptionMethod::NoParamsNodeChange) + else if constexpr (methods::SubscriptionHas::getNodeChange) { return { _pimpl->getNodeChange(std::move(idArg)) }; } @@ -2104,7 +2205,7 @@ class Subscription void beginSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::SubscriptionMethod::HasBeginSelectionSet) + if constexpr (methods::SubscriptionHas::beginSelectionSet) { _pimpl->beginSelectionSet(params); } @@ -2112,7 +2213,7 @@ class Subscription void endSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::SubscriptionMethod::HasEndSelectionSet) + if constexpr (methods::SubscriptionHas::endSelectionSet) { _pimpl->endSelectionSet(params); } @@ -2122,7 +2223,10 @@ class Subscription const std::shared_ptr _pimpl; }; - Subscription(std::unique_ptr&& pimpl); + Subscription(std::unique_ptr&& pimpl) noexcept; + + service::TypeNames getTypeNames() const noexcept; + service::ResolverMap getResolvers() const noexcept; void beginSelectionSet(const service::SelectionSetParams& params) const final; void endSelectionSet(const service::SelectionSetParams& params) const final; @@ -2131,7 +2235,7 @@ class Subscription public: template - Subscription(std::shared_ptr pimpl) + Subscription(std::shared_ptr pimpl) noexcept : Subscription { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } @@ -2141,22 +2245,22 @@ class Appointment : public service::Object { private: - service::AwaitableResolver resolveId(service::ResolverParams&& params); - service::AwaitableResolver resolveWhen(service::ResolverParams&& params); - service::AwaitableResolver resolveSubject(service::ResolverParams&& params); - service::AwaitableResolver resolveIsNow(service::ResolverParams&& params); - service::AwaitableResolver resolveForceError(service::ResolverParams&& params); + service::AwaitableResolver resolveId(service::ResolverParams&& params) const; + service::AwaitableResolver resolveWhen(service::ResolverParams&& params) const; + service::AwaitableResolver resolveSubject(service::ResolverParams&& params) const; + service::AwaitableResolver resolveIsNow(service::ResolverParams&& params) const; + service::AwaitableResolver resolveForceError(service::ResolverParams&& params) const; - service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; struct Concept - : Node { virtual ~Concept() = default; virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual service::FieldResult getId(service::FieldParams&& params) const = 0; virtual service::FieldResult> getWhen(service::FieldParams&& params) const = 0; virtual service::FieldResult> getSubject(service::FieldParams&& params) const = 0; virtual service::FieldResult getIsNow(service::FieldParams&& params) const = 0; @@ -2174,11 +2278,11 @@ class Appointment service::FieldResult getId(service::FieldParams&& params) const final { - if constexpr (methods::AppointmentMethod::WithParamsId) + if constexpr (methods::AppointmentHas::getIdWithParams) { return { _pimpl->getId(std::move(params)) }; } - else if constexpr (methods::AppointmentMethod::NoParamsId) + else if constexpr (methods::AppointmentHas::getId) { return { _pimpl->getId() }; } @@ -2190,11 +2294,11 @@ class Appointment service::FieldResult> getWhen(service::FieldParams&& params) const final { - if constexpr (methods::AppointmentMethod::WithParamsWhen) + if constexpr (methods::AppointmentHas::getWhenWithParams) { return { _pimpl->getWhen(std::move(params)) }; } - else if constexpr (methods::AppointmentMethod::NoParamsWhen) + else if constexpr (methods::AppointmentHas::getWhen) { return { _pimpl->getWhen() }; } @@ -2206,11 +2310,11 @@ class Appointment service::FieldResult> getSubject(service::FieldParams&& params) const final { - if constexpr (methods::AppointmentMethod::WithParamsSubject) + if constexpr (methods::AppointmentHas::getSubjectWithParams) { return { _pimpl->getSubject(std::move(params)) }; } - else if constexpr (methods::AppointmentMethod::NoParamsSubject) + else if constexpr (methods::AppointmentHas::getSubject) { return { _pimpl->getSubject() }; } @@ -2222,11 +2326,11 @@ class Appointment service::FieldResult getIsNow(service::FieldParams&& params) const final { - if constexpr (methods::AppointmentMethod::WithParamsIsNow) + if constexpr (methods::AppointmentHas::getIsNowWithParams) { return { _pimpl->getIsNow(std::move(params)) }; } - else if constexpr (methods::AppointmentMethod::NoParamsIsNow) + else if constexpr (methods::AppointmentHas::getIsNow) { return { _pimpl->getIsNow() }; } @@ -2238,11 +2342,11 @@ class Appointment service::FieldResult> getForceError(service::FieldParams&& params) const final { - if constexpr (methods::AppointmentMethod::WithParamsForceError) + if constexpr (methods::AppointmentHas::getForceErrorWithParams) { return { _pimpl->getForceError(std::move(params)) }; } - else if constexpr (methods::AppointmentMethod::NoParamsForceError) + else if constexpr (methods::AppointmentHas::getForceError) { return { _pimpl->getForceError() }; } @@ -2254,7 +2358,7 @@ class Appointment void beginSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::AppointmentMethod::HasBeginSelectionSet) + if constexpr (methods::AppointmentHas::beginSelectionSet) { _pimpl->beginSelectionSet(params); } @@ -2262,7 +2366,7 @@ class Appointment void endSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::AppointmentMethod::HasEndSelectionSet) + if constexpr (methods::AppointmentHas::endSelectionSet) { _pimpl->endSelectionSet(params); } @@ -2272,7 +2376,19 @@ class Appointment const std::shared_ptr _pimpl; }; - Appointment(std::unique_ptr&& pimpl); + Appointment(std::unique_ptr&& pimpl) noexcept; + + // Interface objects need access to these methods + friend Node; + + template + static constexpr bool implements() noexcept + { + return implements::AppointmentIs; + } + + service::TypeNames getTypeNames() const noexcept; + service::ResolverMap getResolvers() const noexcept; void beginSelectionSet(const service::SelectionSetParams& params) const final; void endSelectionSet(const service::SelectionSetParams& params) const final; @@ -2281,7 +2397,7 @@ class Appointment public: template - Appointment(std::shared_ptr pimpl) + Appointment(std::shared_ptr pimpl) noexcept : Appointment { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } @@ -2291,20 +2407,20 @@ class Task : public service::Object { private: - service::AwaitableResolver resolveId(service::ResolverParams&& params); - service::AwaitableResolver resolveTitle(service::ResolverParams&& params); - service::AwaitableResolver resolveIsComplete(service::ResolverParams&& params); + service::AwaitableResolver resolveId(service::ResolverParams&& params) const; + service::AwaitableResolver resolveTitle(service::ResolverParams&& params) const; + service::AwaitableResolver resolveIsComplete(service::ResolverParams&& params) const; - service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; struct Concept - : Node { virtual ~Concept() = default; virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual service::FieldResult getId(service::FieldParams&& params) const = 0; virtual service::FieldResult> getTitle(service::FieldParams&& params) const = 0; virtual service::FieldResult getIsComplete(service::FieldParams&& params) const = 0; }; @@ -2320,11 +2436,11 @@ class Task service::FieldResult getId(service::FieldParams&& params) const final { - if constexpr (methods::TaskMethod::WithParamsId) + if constexpr (methods::TaskHas::getIdWithParams) { return { _pimpl->getId(std::move(params)) }; } - else if constexpr (methods::TaskMethod::NoParamsId) + else if constexpr (methods::TaskHas::getId) { return { _pimpl->getId() }; } @@ -2336,11 +2452,11 @@ class Task service::FieldResult> getTitle(service::FieldParams&& params) const final { - if constexpr (methods::TaskMethod::WithParamsTitle) + if constexpr (methods::TaskHas::getTitleWithParams) { return { _pimpl->getTitle(std::move(params)) }; } - else if constexpr (methods::TaskMethod::NoParamsTitle) + else if constexpr (methods::TaskHas::getTitle) { return { _pimpl->getTitle() }; } @@ -2352,11 +2468,11 @@ class Task service::FieldResult getIsComplete(service::FieldParams&& params) const final { - if constexpr (methods::TaskMethod::WithParamsIsComplete) + if constexpr (methods::TaskHas::getIsCompleteWithParams) { return { _pimpl->getIsComplete(std::move(params)) }; } - else if constexpr (methods::TaskMethod::NoParamsIsComplete) + else if constexpr (methods::TaskHas::getIsComplete) { return { _pimpl->getIsComplete() }; } @@ -2368,7 +2484,7 @@ class Task void beginSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::TaskMethod::HasBeginSelectionSet) + if constexpr (methods::TaskHas::beginSelectionSet) { _pimpl->beginSelectionSet(params); } @@ -2376,7 +2492,7 @@ class Task void endSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::TaskMethod::HasEndSelectionSet) + if constexpr (methods::TaskHas::endSelectionSet) { _pimpl->endSelectionSet(params); } @@ -2386,7 +2502,19 @@ class Task const std::shared_ptr _pimpl; }; - Task(std::unique_ptr&& pimpl); + Task(std::unique_ptr&& pimpl) noexcept; + + // Interface objects need access to these methods + friend Node; + + template + static constexpr bool implements() noexcept + { + return implements::TaskIs; + } + + service::TypeNames getTypeNames() const noexcept; + service::ResolverMap getResolvers() const noexcept; void beginSelectionSet(const service::SelectionSetParams& params) const final; void endSelectionSet(const service::SelectionSetParams& params) const final; @@ -2395,7 +2523,7 @@ class Task public: template - Task(std::shared_ptr pimpl) + Task(std::shared_ptr pimpl) noexcept : Task { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } @@ -2405,20 +2533,20 @@ class Folder : public service::Object { private: - service::AwaitableResolver resolveId(service::ResolverParams&& params); - service::AwaitableResolver resolveName(service::ResolverParams&& params); - service::AwaitableResolver resolveUnreadCount(service::ResolverParams&& params); + service::AwaitableResolver resolveId(service::ResolverParams&& params) const; + service::AwaitableResolver resolveName(service::ResolverParams&& params) const; + service::AwaitableResolver resolveUnreadCount(service::ResolverParams&& params) const; - service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; struct Concept - : Node { virtual ~Concept() = default; virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual service::FieldResult getId(service::FieldParams&& params) const = 0; virtual service::FieldResult> getName(service::FieldParams&& params) const = 0; virtual service::FieldResult getUnreadCount(service::FieldParams&& params) const = 0; }; @@ -2434,11 +2562,11 @@ class Folder service::FieldResult getId(service::FieldParams&& params) const final { - if constexpr (methods::FolderMethod::WithParamsId) + if constexpr (methods::FolderHas::getIdWithParams) { return { _pimpl->getId(std::move(params)) }; } - else if constexpr (methods::FolderMethod::NoParamsId) + else if constexpr (methods::FolderHas::getId) { return { _pimpl->getId() }; } @@ -2450,11 +2578,11 @@ class Folder service::FieldResult> getName(service::FieldParams&& params) const final { - if constexpr (methods::FolderMethod::WithParamsName) + if constexpr (methods::FolderHas::getNameWithParams) { return { _pimpl->getName(std::move(params)) }; } - else if constexpr (methods::FolderMethod::NoParamsName) + else if constexpr (methods::FolderHas::getName) { return { _pimpl->getName() }; } @@ -2466,11 +2594,11 @@ class Folder service::FieldResult getUnreadCount(service::FieldParams&& params) const final { - if constexpr (methods::FolderMethod::WithParamsUnreadCount) + if constexpr (methods::FolderHas::getUnreadCountWithParams) { return { _pimpl->getUnreadCount(std::move(params)) }; } - else if constexpr (methods::FolderMethod::NoParamsUnreadCount) + else if constexpr (methods::FolderHas::getUnreadCount) { return { _pimpl->getUnreadCount() }; } @@ -2482,7 +2610,7 @@ class Folder void beginSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::FolderMethod::HasBeginSelectionSet) + if constexpr (methods::FolderHas::beginSelectionSet) { _pimpl->beginSelectionSet(params); } @@ -2490,7 +2618,7 @@ class Folder void endSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::FolderMethod::HasEndSelectionSet) + if constexpr (methods::FolderHas::endSelectionSet) { _pimpl->endSelectionSet(params); } @@ -2500,7 +2628,19 @@ class Folder const std::shared_ptr _pimpl; }; - Folder(std::unique_ptr&& pimpl); + Folder(std::unique_ptr&& pimpl) noexcept; + + // Interface objects need access to these methods + friend Node; + + template + static constexpr bool implements() noexcept + { + return implements::FolderIs; + } + + service::TypeNames getTypeNames() const noexcept; + service::ResolverMap getResolvers() const noexcept; void beginSelectionSet(const service::SelectionSetParams& params) const final; void endSelectionSet(const service::SelectionSetParams& params) const final; @@ -2509,7 +2649,7 @@ class Folder public: template - Folder(std::shared_ptr pimpl) + Folder(std::shared_ptr pimpl) noexcept : Folder { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } @@ -2519,10 +2659,10 @@ class NestedType : public service::Object { private: - service::AwaitableResolver resolveDepth(service::ResolverParams&& params); - service::AwaitableResolver resolveNested(service::ResolverParams&& params); + service::AwaitableResolver resolveDepth(service::ResolverParams&& params) const; + service::AwaitableResolver resolveNested(service::ResolverParams&& params) const; - service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; struct Concept { @@ -2546,11 +2686,11 @@ class NestedType service::FieldResult getDepth(service::FieldParams&& params) const final { - if constexpr (methods::NestedTypeMethod::WithParamsDepth) + if constexpr (methods::NestedTypeHas::getDepthWithParams) { return { _pimpl->getDepth(std::move(params)) }; } - else if constexpr (methods::NestedTypeMethod::NoParamsDepth) + else if constexpr (methods::NestedTypeHas::getDepth) { return { _pimpl->getDepth() }; } @@ -2562,11 +2702,11 @@ class NestedType service::FieldResult> getNested(service::FieldParams&& params) const final { - if constexpr (methods::NestedTypeMethod::WithParamsNested) + if constexpr (methods::NestedTypeHas::getNestedWithParams) { return { _pimpl->getNested(std::move(params)) }; } - else if constexpr (methods::NestedTypeMethod::NoParamsNested) + else if constexpr (methods::NestedTypeHas::getNested) { return { _pimpl->getNested() }; } @@ -2578,7 +2718,7 @@ class NestedType void beginSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::NestedTypeMethod::HasBeginSelectionSet) + if constexpr (methods::NestedTypeHas::beginSelectionSet) { _pimpl->beginSelectionSet(params); } @@ -2586,7 +2726,7 @@ class NestedType void endSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::NestedTypeMethod::HasEndSelectionSet) + if constexpr (methods::NestedTypeHas::endSelectionSet) { _pimpl->endSelectionSet(params); } @@ -2596,7 +2736,10 @@ class NestedType const std::shared_ptr _pimpl; }; - NestedType(std::unique_ptr&& pimpl); + NestedType(std::unique_ptr&& pimpl) noexcept; + + service::TypeNames getTypeNames() const noexcept; + service::ResolverMap getResolvers() const noexcept; void beginSelectionSet(const service::SelectionSetParams& params) const final; void endSelectionSet(const service::SelectionSetParams& params) const final; @@ -2605,7 +2748,7 @@ class NestedType public: template - NestedType(std::shared_ptr pimpl) + NestedType(std::shared_ptr pimpl) noexcept : NestedType { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } @@ -2615,9 +2758,9 @@ class Expensive : public service::Object { private: - service::AwaitableResolver resolveOrder(service::ResolverParams&& params); + service::AwaitableResolver resolveOrder(service::ResolverParams&& params) const; - service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; struct Concept { @@ -2640,11 +2783,11 @@ class Expensive service::FieldResult getOrder(service::FieldParams&& params) const final { - if constexpr (methods::ExpensiveMethod::WithParamsOrder) + if constexpr (methods::ExpensiveHas::getOrderWithParams) { return { _pimpl->getOrder(std::move(params)) }; } - else if constexpr (methods::ExpensiveMethod::NoParamsOrder) + else if constexpr (methods::ExpensiveHas::getOrder) { return { _pimpl->getOrder() }; } @@ -2656,7 +2799,7 @@ class Expensive void beginSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::ExpensiveMethod::HasBeginSelectionSet) + if constexpr (methods::ExpensiveHas::beginSelectionSet) { _pimpl->beginSelectionSet(params); } @@ -2664,7 +2807,7 @@ class Expensive void endSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::ExpensiveMethod::HasEndSelectionSet) + if constexpr (methods::ExpensiveHas::endSelectionSet) { _pimpl->endSelectionSet(params); } @@ -2674,7 +2817,10 @@ class Expensive const std::shared_ptr _pimpl; }; - Expensive(std::unique_ptr&& pimpl); + Expensive(std::unique_ptr&& pimpl) noexcept; + + service::TypeNames getTypeNames() const noexcept; + service::ResolverMap getResolvers() const noexcept; void beginSelectionSet(const service::SelectionSetParams& params) const final; void endSelectionSet(const service::SelectionSetParams& params) const final; @@ -2683,7 +2829,7 @@ class Expensive public: template - Expensive(std::shared_ptr pimpl) + Expensive(std::shared_ptr pimpl) noexcept : Expensive { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } diff --git a/samples/today/unified_nointrospection/TodaySchema.cpp b/samples/today/unified_nointrospection/TodaySchema.cpp index 21315b43..23df1bb4 100644 --- a/samples/today/unified_nointrospection/TodaySchema.cpp +++ b/samples/today/unified_nointrospection/TodaySchema.cpp @@ -141,10 +141,38 @@ today::FirstNestedInput ModifiedArgument::convert(const namespace today { namespace object { -Query::Query(std::unique_ptr&& pimpl) - : service::Object({ +Node::Node(std::unique_ptr&& pimpl) noexcept + : service::Object { pimpl->getTypeNames(), pimpl->getResolvers() } + , _pimpl { std::move(pimpl) } +{ +} + +void Node::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void Node::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} + +Query::Query(std::unique_ptr&& pimpl) noexcept + : service::Object{ getTypeNames(), getResolvers() } + , _pimpl { std::move(pimpl) } +{ +} + +service::TypeNames Query::getTypeNames() const noexcept +{ + return { "Query" - }, { + }; +} + +service::ResolverMap Query::getResolvers() const noexcept +{ + return { { R"gql(node)gql"sv, [this](service::ResolverParams&& params) { return resolveNode(std::move(params)); } }, { R"gql(tasks)gql"sv, [this](service::ResolverParams&& params) { return resolveTasks(std::move(params)); } }, { R"gql(nested)gql"sv, [this](service::ResolverParams&& params) { return resolveNested(std::move(params)); } }, @@ -158,9 +186,7 @@ Query::Query(std::unique_ptr&& pimpl) { R"gql(unimplemented)gql"sv, [this](service::ResolverParams&& params) { return resolveUnimplemented(std::move(params)); } }, { R"gql(appointmentsById)gql"sv, [this](service::ResolverParams&& params) { return resolveAppointmentsById(std::move(params)); } }, { R"gql(unreadCountsById)gql"sv, [this](service::ResolverParams&& params) { return resolveUnreadCountsById(std::move(params)); } } - }) - , _pimpl(std::move(pimpl)) -{ + }; } void Query::beginSelectionSet(const service::SelectionSetParams& params) const @@ -173,7 +199,7 @@ void Query::endSelectionSet(const service::SelectionSetParams& params) const _pimpl->endSelectionSet(params); } -service::AwaitableResolver Query::resolveNode(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveNode(service::ResolverParams&& params) const { auto argId = service::ModifiedArgument::require("id", params.arguments); std::unique_lock resolverLock(_resolverMutex); @@ -181,10 +207,10 @@ service::AwaitableResolver Query::resolveNode(service::ResolverParams&& params) auto result = _pimpl->getNode(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argId)); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Query::resolveAppointments(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveAppointments(service::ResolverParams&& params) const { auto argFirst = service::ModifiedArgument::require("first", params.arguments); auto argAfter = service::ModifiedArgument::require("after", params.arguments); @@ -198,7 +224,7 @@ service::AwaitableResolver Query::resolveAppointments(service::ResolverParams&& return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Query::resolveTasks(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveTasks(service::ResolverParams&& params) const { auto argFirst = service::ModifiedArgument::require("first", params.arguments); auto argAfter = service::ModifiedArgument::require("after", params.arguments); @@ -212,7 +238,7 @@ service::AwaitableResolver Query::resolveTasks(service::ResolverParams&& params) return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Query::resolveUnreadCounts(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveUnreadCounts(service::ResolverParams&& params) const { auto argFirst = service::ModifiedArgument::require("first", params.arguments); auto argAfter = service::ModifiedArgument::require("after", params.arguments); @@ -226,7 +252,7 @@ service::AwaitableResolver Query::resolveUnreadCounts(service::ResolverParams&& return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Query::resolveAppointmentsById(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveAppointmentsById(service::ResolverParams&& params) const { const auto defaultArguments = []() { @@ -259,7 +285,7 @@ service::AwaitableResolver Query::resolveAppointmentsById(service::ResolverParam return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Query::resolveTasksById(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveTasksById(service::ResolverParams&& params) const { auto argIds = service::ModifiedArgument::require("ids", params.arguments); std::unique_lock resolverLock(_resolverMutex); @@ -270,7 +296,7 @@ service::AwaitableResolver Query::resolveTasksById(service::ResolverParams&& par return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Query::resolveUnreadCountsById(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveUnreadCountsById(service::ResolverParams&& params) const { auto argIds = service::ModifiedArgument::require("ids", params.arguments); std::unique_lock resolverLock(_resolverMutex); @@ -281,7 +307,7 @@ service::AwaitableResolver Query::resolveUnreadCountsById(service::ResolverParam return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Query::resolveNested(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveNested(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -291,7 +317,7 @@ service::AwaitableResolver Query::resolveNested(service::ResolverParams&& params return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Query::resolveUnimplemented(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveUnimplemented(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -301,7 +327,7 @@ service::AwaitableResolver Query::resolveUnimplemented(service::ResolverParams&& return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Query::resolveExpensive(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveExpensive(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -311,7 +337,7 @@ service::AwaitableResolver Query::resolveExpensive(service::ResolverParams&& par return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Query::resolveTestTaskState(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveTestTaskState(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -321,7 +347,7 @@ service::AwaitableResolver Query::resolveTestTaskState(service::ResolverParams&& return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Query::resolveAnyType(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveAnyType(service::ResolverParams&& params) const { auto argIds = service::ModifiedArgument::require("ids", params.arguments); std::unique_lock resolverLock(_resolverMutex); @@ -332,21 +358,31 @@ service::AwaitableResolver Query::resolveAnyType(service::ResolverParams&& param return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Query::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver Query::resolve_typename(service::ResolverParams&& params) const { return service::ModifiedResult::convert(std::string{ R"gql(Query)gql" }, std::move(params)); } -PageInfo::PageInfo(std::unique_ptr&& pimpl) - : service::Object({ +PageInfo::PageInfo(std::unique_ptr&& pimpl) noexcept + : service::Object{ getTypeNames(), getResolvers() } + , _pimpl { std::move(pimpl) } +{ +} + +service::TypeNames PageInfo::getTypeNames() const noexcept +{ + return { "PageInfo" - }, { + }; +} + +service::ResolverMap PageInfo::getResolvers() const noexcept +{ + return { { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, { R"gql(hasNextPage)gql"sv, [this](service::ResolverParams&& params) { return resolveHasNextPage(std::move(params)); } }, { R"gql(hasPreviousPage)gql"sv, [this](service::ResolverParams&& params) { return resolveHasPreviousPage(std::move(params)); } } - }) - , _pimpl(std::move(pimpl)) -{ + }; } void PageInfo::beginSelectionSet(const service::SelectionSetParams& params) const @@ -359,7 +395,7 @@ void PageInfo::endSelectionSet(const service::SelectionSetParams& params) const _pimpl->endSelectionSet(params); } -service::AwaitableResolver PageInfo::resolveHasNextPage(service::ResolverParams&& params) +service::AwaitableResolver PageInfo::resolveHasNextPage(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -369,7 +405,7 @@ service::AwaitableResolver PageInfo::resolveHasNextPage(service::ResolverParams& return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver PageInfo::resolveHasPreviousPage(service::ResolverParams&& params) +service::AwaitableResolver PageInfo::resolveHasPreviousPage(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -379,21 +415,31 @@ service::AwaitableResolver PageInfo::resolveHasPreviousPage(service::ResolverPar return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver PageInfo::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver PageInfo::resolve_typename(service::ResolverParams&& params) const { return service::ModifiedResult::convert(std::string{ R"gql(PageInfo)gql" }, std::move(params)); } -AppointmentEdge::AppointmentEdge(std::unique_ptr&& pimpl) - : service::Object({ +AppointmentEdge::AppointmentEdge(std::unique_ptr&& pimpl) noexcept + : service::Object{ getTypeNames(), getResolvers() } + , _pimpl { std::move(pimpl) } +{ +} + +service::TypeNames AppointmentEdge::getTypeNames() const noexcept +{ + return { "AppointmentEdge" - }, { + }; +} + +service::ResolverMap AppointmentEdge::getResolvers() const noexcept +{ + return { { R"gql(node)gql"sv, [this](service::ResolverParams&& params) { return resolveNode(std::move(params)); } }, { R"gql(cursor)gql"sv, [this](service::ResolverParams&& params) { return resolveCursor(std::move(params)); } }, { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } } - }) - , _pimpl(std::move(pimpl)) -{ + }; } void AppointmentEdge::beginSelectionSet(const service::SelectionSetParams& params) const @@ -406,7 +452,7 @@ void AppointmentEdge::endSelectionSet(const service::SelectionSetParams& params) _pimpl->endSelectionSet(params); } -service::AwaitableResolver AppointmentEdge::resolveNode(service::ResolverParams&& params) +service::AwaitableResolver AppointmentEdge::resolveNode(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -416,7 +462,7 @@ service::AwaitableResolver AppointmentEdge::resolveNode(service::ResolverParams& return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver AppointmentEdge::resolveCursor(service::ResolverParams&& params) +service::AwaitableResolver AppointmentEdge::resolveCursor(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -426,21 +472,31 @@ service::AwaitableResolver AppointmentEdge::resolveCursor(service::ResolverParam return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver AppointmentEdge::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver AppointmentEdge::resolve_typename(service::ResolverParams&& params) const { return service::ModifiedResult::convert(std::string{ R"gql(AppointmentEdge)gql" }, std::move(params)); } -AppointmentConnection::AppointmentConnection(std::unique_ptr&& pimpl) - : service::Object({ +AppointmentConnection::AppointmentConnection(std::unique_ptr&& pimpl) noexcept + : service::Object{ getTypeNames(), getResolvers() } + , _pimpl { std::move(pimpl) } +{ +} + +service::TypeNames AppointmentConnection::getTypeNames() const noexcept +{ + return { "AppointmentConnection" - }, { + }; +} + +service::ResolverMap AppointmentConnection::getResolvers() const noexcept +{ + return { { R"gql(edges)gql"sv, [this](service::ResolverParams&& params) { return resolveEdges(std::move(params)); } }, { R"gql(pageInfo)gql"sv, [this](service::ResolverParams&& params) { return resolvePageInfo(std::move(params)); } }, { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } } - }) - , _pimpl(std::move(pimpl)) -{ + }; } void AppointmentConnection::beginSelectionSet(const service::SelectionSetParams& params) const @@ -453,7 +509,7 @@ void AppointmentConnection::endSelectionSet(const service::SelectionSetParams& p _pimpl->endSelectionSet(params); } -service::AwaitableResolver AppointmentConnection::resolvePageInfo(service::ResolverParams&& params) +service::AwaitableResolver AppointmentConnection::resolvePageInfo(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -463,7 +519,7 @@ service::AwaitableResolver AppointmentConnection::resolvePageInfo(service::Resol return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver AppointmentConnection::resolveEdges(service::ResolverParams&& params) +service::AwaitableResolver AppointmentConnection::resolveEdges(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -473,21 +529,31 @@ service::AwaitableResolver AppointmentConnection::resolveEdges(service::Resolver return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver AppointmentConnection::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver AppointmentConnection::resolve_typename(service::ResolverParams&& params) const { return service::ModifiedResult::convert(std::string{ R"gql(AppointmentConnection)gql" }, std::move(params)); } -TaskEdge::TaskEdge(std::unique_ptr&& pimpl) - : service::Object({ +TaskEdge::TaskEdge(std::unique_ptr&& pimpl) noexcept + : service::Object{ getTypeNames(), getResolvers() } + , _pimpl { std::move(pimpl) } +{ +} + +service::TypeNames TaskEdge::getTypeNames() const noexcept +{ + return { "TaskEdge" - }, { + }; +} + +service::ResolverMap TaskEdge::getResolvers() const noexcept +{ + return { { R"gql(node)gql"sv, [this](service::ResolverParams&& params) { return resolveNode(std::move(params)); } }, { R"gql(cursor)gql"sv, [this](service::ResolverParams&& params) { return resolveCursor(std::move(params)); } }, { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } } - }) - , _pimpl(std::move(pimpl)) -{ + }; } void TaskEdge::beginSelectionSet(const service::SelectionSetParams& params) const @@ -500,7 +566,7 @@ void TaskEdge::endSelectionSet(const service::SelectionSetParams& params) const _pimpl->endSelectionSet(params); } -service::AwaitableResolver TaskEdge::resolveNode(service::ResolverParams&& params) +service::AwaitableResolver TaskEdge::resolveNode(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -510,7 +576,7 @@ service::AwaitableResolver TaskEdge::resolveNode(service::ResolverParams&& param return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver TaskEdge::resolveCursor(service::ResolverParams&& params) +service::AwaitableResolver TaskEdge::resolveCursor(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -520,21 +586,31 @@ service::AwaitableResolver TaskEdge::resolveCursor(service::ResolverParams&& par return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver TaskEdge::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver TaskEdge::resolve_typename(service::ResolverParams&& params) const { return service::ModifiedResult::convert(std::string{ R"gql(TaskEdge)gql" }, std::move(params)); } -TaskConnection::TaskConnection(std::unique_ptr&& pimpl) - : service::Object({ +TaskConnection::TaskConnection(std::unique_ptr&& pimpl) noexcept + : service::Object{ getTypeNames(), getResolvers() } + , _pimpl { std::move(pimpl) } +{ +} + +service::TypeNames TaskConnection::getTypeNames() const noexcept +{ + return { "TaskConnection" - }, { + }; +} + +service::ResolverMap TaskConnection::getResolvers() const noexcept +{ + return { { R"gql(edges)gql"sv, [this](service::ResolverParams&& params) { return resolveEdges(std::move(params)); } }, { R"gql(pageInfo)gql"sv, [this](service::ResolverParams&& params) { return resolvePageInfo(std::move(params)); } }, { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } } - }) - , _pimpl(std::move(pimpl)) -{ + }; } void TaskConnection::beginSelectionSet(const service::SelectionSetParams& params) const @@ -547,7 +623,7 @@ void TaskConnection::endSelectionSet(const service::SelectionSetParams& params) _pimpl->endSelectionSet(params); } -service::AwaitableResolver TaskConnection::resolvePageInfo(service::ResolverParams&& params) +service::AwaitableResolver TaskConnection::resolvePageInfo(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -557,7 +633,7 @@ service::AwaitableResolver TaskConnection::resolvePageInfo(service::ResolverPara return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver TaskConnection::resolveEdges(service::ResolverParams&& params) +service::AwaitableResolver TaskConnection::resolveEdges(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -567,21 +643,31 @@ service::AwaitableResolver TaskConnection::resolveEdges(service::ResolverParams& return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver TaskConnection::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver TaskConnection::resolve_typename(service::ResolverParams&& params) const { return service::ModifiedResult::convert(std::string{ R"gql(TaskConnection)gql" }, std::move(params)); } -FolderEdge::FolderEdge(std::unique_ptr&& pimpl) - : service::Object({ +FolderEdge::FolderEdge(std::unique_ptr&& pimpl) noexcept + : service::Object{ getTypeNames(), getResolvers() } + , _pimpl { std::move(pimpl) } +{ +} + +service::TypeNames FolderEdge::getTypeNames() const noexcept +{ + return { "FolderEdge" - }, { + }; +} + +service::ResolverMap FolderEdge::getResolvers() const noexcept +{ + return { { R"gql(node)gql"sv, [this](service::ResolverParams&& params) { return resolveNode(std::move(params)); } }, { R"gql(cursor)gql"sv, [this](service::ResolverParams&& params) { return resolveCursor(std::move(params)); } }, { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } } - }) - , _pimpl(std::move(pimpl)) -{ + }; } void FolderEdge::beginSelectionSet(const service::SelectionSetParams& params) const @@ -594,7 +680,7 @@ void FolderEdge::endSelectionSet(const service::SelectionSetParams& params) cons _pimpl->endSelectionSet(params); } -service::AwaitableResolver FolderEdge::resolveNode(service::ResolverParams&& params) +service::AwaitableResolver FolderEdge::resolveNode(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -604,7 +690,7 @@ service::AwaitableResolver FolderEdge::resolveNode(service::ResolverParams&& par return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver FolderEdge::resolveCursor(service::ResolverParams&& params) +service::AwaitableResolver FolderEdge::resolveCursor(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -614,21 +700,31 @@ service::AwaitableResolver FolderEdge::resolveCursor(service::ResolverParams&& p return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver FolderEdge::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver FolderEdge::resolve_typename(service::ResolverParams&& params) const { return service::ModifiedResult::convert(std::string{ R"gql(FolderEdge)gql" }, std::move(params)); } -FolderConnection::FolderConnection(std::unique_ptr&& pimpl) - : service::Object({ +FolderConnection::FolderConnection(std::unique_ptr&& pimpl) noexcept + : service::Object{ getTypeNames(), getResolvers() } + , _pimpl { std::move(pimpl) } +{ +} + +service::TypeNames FolderConnection::getTypeNames() const noexcept +{ + return { "FolderConnection" - }, { + }; +} + +service::ResolverMap FolderConnection::getResolvers() const noexcept +{ + return { { R"gql(edges)gql"sv, [this](service::ResolverParams&& params) { return resolveEdges(std::move(params)); } }, { R"gql(pageInfo)gql"sv, [this](service::ResolverParams&& params) { return resolvePageInfo(std::move(params)); } }, { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } } - }) - , _pimpl(std::move(pimpl)) -{ + }; } void FolderConnection::beginSelectionSet(const service::SelectionSetParams& params) const @@ -641,7 +737,7 @@ void FolderConnection::endSelectionSet(const service::SelectionSetParams& params _pimpl->endSelectionSet(params); } -service::AwaitableResolver FolderConnection::resolvePageInfo(service::ResolverParams&& params) +service::AwaitableResolver FolderConnection::resolvePageInfo(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -651,7 +747,7 @@ service::AwaitableResolver FolderConnection::resolvePageInfo(service::ResolverPa return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver FolderConnection::resolveEdges(service::ResolverParams&& params) +service::AwaitableResolver FolderConnection::resolveEdges(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -661,21 +757,31 @@ service::AwaitableResolver FolderConnection::resolveEdges(service::ResolverParam return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver FolderConnection::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver FolderConnection::resolve_typename(service::ResolverParams&& params) const { return service::ModifiedResult::convert(std::string{ R"gql(FolderConnection)gql" }, std::move(params)); } -CompleteTaskPayload::CompleteTaskPayload(std::unique_ptr&& pimpl) - : service::Object({ +CompleteTaskPayload::CompleteTaskPayload(std::unique_ptr&& pimpl) noexcept + : service::Object{ getTypeNames(), getResolvers() } + , _pimpl { std::move(pimpl) } +{ +} + +service::TypeNames CompleteTaskPayload::getTypeNames() const noexcept +{ + return { "CompleteTaskPayload" - }, { + }; +} + +service::ResolverMap CompleteTaskPayload::getResolvers() const noexcept +{ + return { { R"gql(task)gql"sv, [this](service::ResolverParams&& params) { return resolveTask(std::move(params)); } }, { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, { R"gql(clientMutationId)gql"sv, [this](service::ResolverParams&& params) { return resolveClientMutationId(std::move(params)); } } - }) - , _pimpl(std::move(pimpl)) -{ + }; } void CompleteTaskPayload::beginSelectionSet(const service::SelectionSetParams& params) const @@ -688,7 +794,7 @@ void CompleteTaskPayload::endSelectionSet(const service::SelectionSetParams& par _pimpl->endSelectionSet(params); } -service::AwaitableResolver CompleteTaskPayload::resolveTask(service::ResolverParams&& params) +service::AwaitableResolver CompleteTaskPayload::resolveTask(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -698,7 +804,7 @@ service::AwaitableResolver CompleteTaskPayload::resolveTask(service::ResolverPar return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver CompleteTaskPayload::resolveClientMutationId(service::ResolverParams&& params) +service::AwaitableResolver CompleteTaskPayload::resolveClientMutationId(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -708,21 +814,31 @@ service::AwaitableResolver CompleteTaskPayload::resolveClientMutationId(service: return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver CompleteTaskPayload::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver CompleteTaskPayload::resolve_typename(service::ResolverParams&& params) const { return service::ModifiedResult::convert(std::string{ R"gql(CompleteTaskPayload)gql" }, std::move(params)); } -Mutation::Mutation(std::unique_ptr&& pimpl) - : service::Object({ +Mutation::Mutation(std::unique_ptr&& pimpl) noexcept + : service::Object{ getTypeNames(), getResolvers() } + , _pimpl { std::move(pimpl) } +{ +} + +service::TypeNames Mutation::getTypeNames() const noexcept +{ + return { "Mutation" - }, { + }; +} + +service::ResolverMap Mutation::getResolvers() const noexcept +{ + return { { R"gql(setFloat)gql"sv, [this](service::ResolverParams&& params) { return resolveSetFloat(std::move(params)); } }, { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, { R"gql(completeTask)gql"sv, [this](service::ResolverParams&& params) { return resolveCompleteTask(std::move(params)); } } - }) - , _pimpl(std::move(pimpl)) -{ + }; } void Mutation::beginSelectionSet(const service::SelectionSetParams& params) const @@ -735,7 +851,7 @@ void Mutation::endSelectionSet(const service::SelectionSetParams& params) const _pimpl->endSelectionSet(params); } -service::AwaitableResolver Mutation::resolveCompleteTask(service::ResolverParams&& params) +service::AwaitableResolver Mutation::resolveCompleteTask(service::ResolverParams&& params) const { auto argInput = service::ModifiedArgument::require("input", params.arguments); std::unique_lock resolverLock(_resolverMutex); @@ -746,7 +862,7 @@ service::AwaitableResolver Mutation::resolveCompleteTask(service::ResolverParams return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Mutation::resolveSetFloat(service::ResolverParams&& params) +service::AwaitableResolver Mutation::resolveSetFloat(service::ResolverParams&& params) const { auto argValue = service::ModifiedArgument::require("value", params.arguments); std::unique_lock resolverLock(_resolverMutex); @@ -757,21 +873,31 @@ service::AwaitableResolver Mutation::resolveSetFloat(service::ResolverParams&& p return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Mutation::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver Mutation::resolve_typename(service::ResolverParams&& params) const { return service::ModifiedResult::convert(std::string{ R"gql(Mutation)gql" }, std::move(params)); } -Subscription::Subscription(std::unique_ptr&& pimpl) - : service::Object({ +Subscription::Subscription(std::unique_ptr&& pimpl) noexcept + : service::Object{ getTypeNames(), getResolvers() } + , _pimpl { std::move(pimpl) } +{ +} + +service::TypeNames Subscription::getTypeNames() const noexcept +{ + return { "Subscription" - }, { + }; +} + +service::ResolverMap Subscription::getResolvers() const noexcept +{ + return { { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, { R"gql(nodeChange)gql"sv, [this](service::ResolverParams&& params) { return resolveNodeChange(std::move(params)); } }, { R"gql(nextAppointmentChange)gql"sv, [this](service::ResolverParams&& params) { return resolveNextAppointmentChange(std::move(params)); } } - }) - , _pimpl(std::move(pimpl)) -{ + }; } void Subscription::beginSelectionSet(const service::SelectionSetParams& params) const @@ -784,7 +910,7 @@ void Subscription::endSelectionSet(const service::SelectionSetParams& params) co _pimpl->endSelectionSet(params); } -service::AwaitableResolver Subscription::resolveNextAppointmentChange(service::ResolverParams&& params) +service::AwaitableResolver Subscription::resolveNextAppointmentChange(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -794,7 +920,7 @@ service::AwaitableResolver Subscription::resolveNextAppointmentChange(service::R return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Subscription::resolveNodeChange(service::ResolverParams&& params) +service::AwaitableResolver Subscription::resolveNodeChange(service::ResolverParams&& params) const { auto argId = service::ModifiedArgument::require("id", params.arguments); std::unique_lock resolverLock(_resolverMutex); @@ -802,29 +928,39 @@ service::AwaitableResolver Subscription::resolveNodeChange(service::ResolverPara auto result = _pimpl->getNodeChange(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argId)); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Subscription::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver Subscription::resolve_typename(service::ResolverParams&& params) const { return service::ModifiedResult::convert(std::string{ R"gql(Subscription)gql" }, std::move(params)); } -Appointment::Appointment(std::unique_ptr&& pimpl) - : service::Object({ +Appointment::Appointment(std::unique_ptr&& pimpl) noexcept + : service::Object{ getTypeNames(), getResolvers() } + , _pimpl { std::move(pimpl) } +{ +} + +service::TypeNames Appointment::getTypeNames() const noexcept +{ + return { "Node", "UnionType", "Appointment" - }, { + }; +} + +service::ResolverMap Appointment::getResolvers() const noexcept +{ + return { { R"gql(id)gql"sv, [this](service::ResolverParams&& params) { return resolveId(std::move(params)); } }, { R"gql(when)gql"sv, [this](service::ResolverParams&& params) { return resolveWhen(std::move(params)); } }, { R"gql(isNow)gql"sv, [this](service::ResolverParams&& params) { return resolveIsNow(std::move(params)); } }, { R"gql(subject)gql"sv, [this](service::ResolverParams&& params) { return resolveSubject(std::move(params)); } }, { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, { R"gql(forceError)gql"sv, [this](service::ResolverParams&& params) { return resolveForceError(std::move(params)); } } - }) - , _pimpl(std::move(pimpl)) -{ + }; } void Appointment::beginSelectionSet(const service::SelectionSetParams& params) const @@ -837,7 +973,7 @@ void Appointment::endSelectionSet(const service::SelectionSetParams& params) con _pimpl->endSelectionSet(params); } -service::AwaitableResolver Appointment::resolveId(service::ResolverParams&& params) +service::AwaitableResolver Appointment::resolveId(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -847,7 +983,7 @@ service::AwaitableResolver Appointment::resolveId(service::ResolverParams&& para return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Appointment::resolveWhen(service::ResolverParams&& params) +service::AwaitableResolver Appointment::resolveWhen(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -857,7 +993,7 @@ service::AwaitableResolver Appointment::resolveWhen(service::ResolverParams&& pa return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Appointment::resolveSubject(service::ResolverParams&& params) +service::AwaitableResolver Appointment::resolveSubject(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -867,7 +1003,7 @@ service::AwaitableResolver Appointment::resolveSubject(service::ResolverParams&& return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Appointment::resolveIsNow(service::ResolverParams&& params) +service::AwaitableResolver Appointment::resolveIsNow(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -877,7 +1013,7 @@ service::AwaitableResolver Appointment::resolveIsNow(service::ResolverParams&& p return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Appointment::resolveForceError(service::ResolverParams&& params) +service::AwaitableResolver Appointment::resolveForceError(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -887,24 +1023,34 @@ service::AwaitableResolver Appointment::resolveForceError(service::ResolverParam return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Appointment::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver Appointment::resolve_typename(service::ResolverParams&& params) const { return service::ModifiedResult::convert(std::string{ R"gql(Appointment)gql" }, std::move(params)); } -Task::Task(std::unique_ptr&& pimpl) - : service::Object({ +Task::Task(std::unique_ptr&& pimpl) noexcept + : service::Object{ getTypeNames(), getResolvers() } + , _pimpl { std::move(pimpl) } +{ +} + +service::TypeNames Task::getTypeNames() const noexcept +{ + return { "Node", "UnionType", "Task" - }, { + }; +} + +service::ResolverMap Task::getResolvers() const noexcept +{ + return { { R"gql(id)gql"sv, [this](service::ResolverParams&& params) { return resolveId(std::move(params)); } }, { R"gql(title)gql"sv, [this](service::ResolverParams&& params) { return resolveTitle(std::move(params)); } }, { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, { R"gql(isComplete)gql"sv, [this](service::ResolverParams&& params) { return resolveIsComplete(std::move(params)); } } - }) - , _pimpl(std::move(pimpl)) -{ + }; } void Task::beginSelectionSet(const service::SelectionSetParams& params) const @@ -917,7 +1063,7 @@ void Task::endSelectionSet(const service::SelectionSetParams& params) const _pimpl->endSelectionSet(params); } -service::AwaitableResolver Task::resolveId(service::ResolverParams&& params) +service::AwaitableResolver Task::resolveId(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -927,7 +1073,7 @@ service::AwaitableResolver Task::resolveId(service::ResolverParams&& params) return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Task::resolveTitle(service::ResolverParams&& params) +service::AwaitableResolver Task::resolveTitle(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -937,7 +1083,7 @@ service::AwaitableResolver Task::resolveTitle(service::ResolverParams&& params) return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Task::resolveIsComplete(service::ResolverParams&& params) +service::AwaitableResolver Task::resolveIsComplete(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -947,24 +1093,34 @@ service::AwaitableResolver Task::resolveIsComplete(service::ResolverParams&& par return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Task::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver Task::resolve_typename(service::ResolverParams&& params) const { return service::ModifiedResult::convert(std::string{ R"gql(Task)gql" }, std::move(params)); } -Folder::Folder(std::unique_ptr&& pimpl) - : service::Object({ +Folder::Folder(std::unique_ptr&& pimpl) noexcept + : service::Object{ getTypeNames(), getResolvers() } + , _pimpl { std::move(pimpl) } +{ +} + +service::TypeNames Folder::getTypeNames() const noexcept +{ + return { "Node", "UnionType", "Folder" - }, { + }; +} + +service::ResolverMap Folder::getResolvers() const noexcept +{ + return { { R"gql(id)gql"sv, [this](service::ResolverParams&& params) { return resolveId(std::move(params)); } }, { R"gql(name)gql"sv, [this](service::ResolverParams&& params) { return resolveName(std::move(params)); } }, { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, { R"gql(unreadCount)gql"sv, [this](service::ResolverParams&& params) { return resolveUnreadCount(std::move(params)); } } - }) - , _pimpl(std::move(pimpl)) -{ + }; } void Folder::beginSelectionSet(const service::SelectionSetParams& params) const @@ -977,7 +1133,7 @@ void Folder::endSelectionSet(const service::SelectionSetParams& params) const _pimpl->endSelectionSet(params); } -service::AwaitableResolver Folder::resolveId(service::ResolverParams&& params) +service::AwaitableResolver Folder::resolveId(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -987,7 +1143,7 @@ service::AwaitableResolver Folder::resolveId(service::ResolverParams&& params) return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Folder::resolveName(service::ResolverParams&& params) +service::AwaitableResolver Folder::resolveName(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -997,7 +1153,7 @@ service::AwaitableResolver Folder::resolveName(service::ResolverParams&& params) return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Folder::resolveUnreadCount(service::ResolverParams&& params) +service::AwaitableResolver Folder::resolveUnreadCount(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -1007,21 +1163,31 @@ service::AwaitableResolver Folder::resolveUnreadCount(service::ResolverParams&& return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Folder::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver Folder::resolve_typename(service::ResolverParams&& params) const { return service::ModifiedResult::convert(std::string{ R"gql(Folder)gql" }, std::move(params)); } -NestedType::NestedType(std::unique_ptr&& pimpl) - : service::Object({ +NestedType::NestedType(std::unique_ptr&& pimpl) noexcept + : service::Object{ getTypeNames(), getResolvers() } + , _pimpl { std::move(pimpl) } +{ +} + +service::TypeNames NestedType::getTypeNames() const noexcept +{ + return { "NestedType" - }, { + }; +} + +service::ResolverMap NestedType::getResolvers() const noexcept +{ + return { { R"gql(depth)gql"sv, [this](service::ResolverParams&& params) { return resolveDepth(std::move(params)); } }, { R"gql(nested)gql"sv, [this](service::ResolverParams&& params) { return resolveNested(std::move(params)); } }, { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } } - }) - , _pimpl(std::move(pimpl)) -{ + }; } void NestedType::beginSelectionSet(const service::SelectionSetParams& params) const @@ -1034,7 +1200,7 @@ void NestedType::endSelectionSet(const service::SelectionSetParams& params) cons _pimpl->endSelectionSet(params); } -service::AwaitableResolver NestedType::resolveDepth(service::ResolverParams&& params) +service::AwaitableResolver NestedType::resolveDepth(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -1044,7 +1210,7 @@ service::AwaitableResolver NestedType::resolveDepth(service::ResolverParams&& pa return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver NestedType::resolveNested(service::ResolverParams&& params) +service::AwaitableResolver NestedType::resolveNested(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -1054,20 +1220,30 @@ service::AwaitableResolver NestedType::resolveNested(service::ResolverParams&& p return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver NestedType::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver NestedType::resolve_typename(service::ResolverParams&& params) const { return service::ModifiedResult::convert(std::string{ R"gql(NestedType)gql" }, std::move(params)); } -Expensive::Expensive(std::unique_ptr&& pimpl) - : service::Object({ +Expensive::Expensive(std::unique_ptr&& pimpl) noexcept + : service::Object{ getTypeNames(), getResolvers() } + , _pimpl { std::move(pimpl) } +{ +} + +service::TypeNames Expensive::getTypeNames() const noexcept +{ + return { "Expensive" - }, { + }; +} + +service::ResolverMap Expensive::getResolvers() const noexcept +{ + return { { R"gql(order)gql"sv, [this](service::ResolverParams&& params) { return resolveOrder(std::move(params)); } }, { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } } - }) - , _pimpl(std::move(pimpl)) -{ + }; } void Expensive::beginSelectionSet(const service::SelectionSetParams& params) const @@ -1080,7 +1256,7 @@ void Expensive::endSelectionSet(const service::SelectionSetParams& params) const _pimpl->endSelectionSet(params); } -service::AwaitableResolver Expensive::resolveOrder(service::ResolverParams&& params) +service::AwaitableResolver Expensive::resolveOrder(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -1090,7 +1266,7 @@ service::AwaitableResolver Expensive::resolveOrder(service::ResolverParams&& par return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Expensive::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver Expensive::resolve_typename(service::ResolverParams&& params) const { return service::ModifiedResult::convert(std::string{ R"gql(Expensive)gql" }, std::move(params)); } diff --git a/samples/today/unified_nointrospection/TodaySchema.h b/samples/today/unified_nointrospection/TodaySchema.h index c73499dd..98d71cfb 100644 --- a/samples/today/unified_nointrospection/TodaySchema.h +++ b/samples/today/unified_nointrospection/TodaySchema.h @@ -62,6 +62,8 @@ struct FirstNestedInput namespace object { +class Node; + class Query; class PageInfo; class AppointmentEdge; @@ -79,842 +81,911 @@ class Folder; class NestedType; class Expensive; -} // namespace object - -struct Node +class Node + : public service::Object { - virtual service::FieldResult getId(service::FieldParams&& params) const = 0; +private: + struct Concept + { + virtual ~Concept() = default; + + virtual service::TypeNames getTypeNames() const noexcept = 0; + virtual service::ResolverMap getResolvers() const noexcept = 0; + + virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::TypeNames getTypeNames() const noexcept final + { + return _pimpl->getTypeNames(); + } + + service::ResolverMap getResolvers() const noexcept final + { + return _pimpl->getResolvers(); + } + + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + _pimpl->beginSelectionSet(params); + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + _pimpl->endSelectionSet(params); + } + + private: + const std::shared_ptr _pimpl; + }; + + Node(std::unique_ptr&& pimpl) noexcept; + + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; + + const std::unique_ptr _pimpl; + +public: + template + Node(std::shared_ptr pimpl) noexcept + : Node { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } + { + static_assert(T::template implements(), "Node is not implemented"); + } }; -namespace object { +namespace implements { + +template +concept AppointmentIs = std::is_same_v; + +template +concept TaskIs = std::is_same_v; + +template +concept FolderIs = std::is_same_v; + +} // namespace implements + namespace methods { -namespace QueryMethod { +namespace QueryHas { template -concept WithParamsNode = requires (TImpl impl, service::FieldParams params, response::IdType idArg) +concept getNodeWithParams = requires (TImpl impl, service::FieldParams params, response::IdType idArg) { - { service::FieldResult> { impl.getNode(std::move(params), std::move(idArg)) } }; + { service::FieldResult> { impl.getNode(std::move(params), std::move(idArg)) } }; }; template -concept NoParamsNode = requires (TImpl impl, response::IdType idArg) +concept getNode = requires (TImpl impl, response::IdType idArg) { - { service::FieldResult> { impl.getNode(std::move(idArg)) } }; + { service::FieldResult> { impl.getNode(std::move(idArg)) } }; }; template -concept WithParamsAppointments = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) +concept getAppointmentsWithParams = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) { { service::FieldResult> { impl.getAppointments(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; }; template -concept NoParamsAppointments = requires (TImpl impl, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) +concept getAppointments = requires (TImpl impl, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) { { service::FieldResult> { impl.getAppointments(std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; }; template -concept WithParamsTasks = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) +concept getTasksWithParams = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) { { service::FieldResult> { impl.getTasks(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; }; template -concept NoParamsTasks = requires (TImpl impl, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) +concept getTasks = requires (TImpl impl, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) { { service::FieldResult> { impl.getTasks(std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; }; template -concept WithParamsUnreadCounts = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) +concept getUnreadCountsWithParams = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) { { service::FieldResult> { impl.getUnreadCounts(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; }; template -concept NoParamsUnreadCounts = requires (TImpl impl, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) +concept getUnreadCounts = requires (TImpl impl, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) { { service::FieldResult> { impl.getUnreadCounts(std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; }; template -concept WithParamsAppointmentsById = requires (TImpl impl, service::FieldParams params, std::vector idsArg) +concept getAppointmentsByIdWithParams = requires (TImpl impl, service::FieldParams params, std::vector idsArg) { { service::FieldResult>> { impl.getAppointmentsById(std::move(params), std::move(idsArg)) } }; }; template -concept NoParamsAppointmentsById = requires (TImpl impl, std::vector idsArg) +concept getAppointmentsById = requires (TImpl impl, std::vector idsArg) { { service::FieldResult>> { impl.getAppointmentsById(std::move(idsArg)) } }; }; template -concept WithParamsTasksById = requires (TImpl impl, service::FieldParams params, std::vector idsArg) +concept getTasksByIdWithParams = requires (TImpl impl, service::FieldParams params, std::vector idsArg) { { service::FieldResult>> { impl.getTasksById(std::move(params), std::move(idsArg)) } }; }; template -concept NoParamsTasksById = requires (TImpl impl, std::vector idsArg) +concept getTasksById = requires (TImpl impl, std::vector idsArg) { { service::FieldResult>> { impl.getTasksById(std::move(idsArg)) } }; }; template -concept WithParamsUnreadCountsById = requires (TImpl impl, service::FieldParams params, std::vector idsArg) +concept getUnreadCountsByIdWithParams = requires (TImpl impl, service::FieldParams params, std::vector idsArg) { { service::FieldResult>> { impl.getUnreadCountsById(std::move(params), std::move(idsArg)) } }; }; template -concept NoParamsUnreadCountsById = requires (TImpl impl, std::vector idsArg) +concept getUnreadCountsById = requires (TImpl impl, std::vector idsArg) { { service::FieldResult>> { impl.getUnreadCountsById(std::move(idsArg)) } }; }; template -concept WithParamsNested = requires (TImpl impl, service::FieldParams params) +concept getNestedWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getNested(std::move(params)) } }; }; template -concept NoParamsNested = requires (TImpl impl) +concept getNested = requires (TImpl impl) { { service::FieldResult> { impl.getNested() } }; }; template -concept WithParamsUnimplemented = requires (TImpl impl, service::FieldParams params) +concept getUnimplementedWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getUnimplemented(std::move(params)) } }; }; template -concept NoParamsUnimplemented = requires (TImpl impl) +concept getUnimplemented = requires (TImpl impl) { { service::FieldResult { impl.getUnimplemented() } }; }; template -concept WithParamsExpensive = requires (TImpl impl, service::FieldParams params) +concept getExpensiveWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult>> { impl.getExpensive(std::move(params)) } }; }; template -concept NoParamsExpensive = requires (TImpl impl) +concept getExpensive = requires (TImpl impl) { { service::FieldResult>> { impl.getExpensive() } }; }; template -concept WithParamsTestTaskState = requires (TImpl impl, service::FieldParams params) +concept getTestTaskStateWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getTestTaskState(std::move(params)) } }; }; template -concept NoParamsTestTaskState = requires (TImpl impl) +concept getTestTaskState = requires (TImpl impl) { { service::FieldResult { impl.getTestTaskState() } }; }; template -concept WithParamsAnyType = requires (TImpl impl, service::FieldParams params, std::vector idsArg) +concept getAnyTypeWithParams = requires (TImpl impl, service::FieldParams params, std::vector idsArg) { { service::FieldResult>> { impl.getAnyType(std::move(params), std::move(idsArg)) } }; }; template -concept NoParamsAnyType = requires (TImpl impl, std::vector idsArg) +concept getAnyType = requires (TImpl impl, std::vector idsArg) { { service::FieldResult>> { impl.getAnyType(std::move(idsArg)) } }; }; template -concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.beginSelectionSet(params) }; }; template -concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.endSelectionSet(params) }; }; -} // namespace QueryMethod +} // namespace QueryHas -namespace PageInfoMethod { +namespace PageInfoHas { template -concept WithParamsHasNextPage = requires (TImpl impl, service::FieldParams params) +concept getHasNextPageWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getHasNextPage(std::move(params)) } }; }; template -concept NoParamsHasNextPage = requires (TImpl impl) +concept getHasNextPage = requires (TImpl impl) { { service::FieldResult { impl.getHasNextPage() } }; }; template -concept WithParamsHasPreviousPage = requires (TImpl impl, service::FieldParams params) +concept getHasPreviousPageWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getHasPreviousPage(std::move(params)) } }; }; template -concept NoParamsHasPreviousPage = requires (TImpl impl) +concept getHasPreviousPage = requires (TImpl impl) { { service::FieldResult { impl.getHasPreviousPage() } }; }; template -concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.beginSelectionSet(params) }; }; template -concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.endSelectionSet(params) }; }; -} // namespace PageInfoMethod +} // namespace PageInfoHas -namespace AppointmentEdgeMethod { +namespace AppointmentEdgeHas { template -concept WithParamsNode = requires (TImpl impl, service::FieldParams params) +concept getNodeWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getNode(std::move(params)) } }; }; template -concept NoParamsNode = requires (TImpl impl) +concept getNode = requires (TImpl impl) { { service::FieldResult> { impl.getNode() } }; }; template -concept WithParamsCursor = requires (TImpl impl, service::FieldParams params) +concept getCursorWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getCursor(std::move(params)) } }; }; template -concept NoParamsCursor = requires (TImpl impl) +concept getCursor = requires (TImpl impl) { { service::FieldResult { impl.getCursor() } }; }; template -concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.beginSelectionSet(params) }; }; template -concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.endSelectionSet(params) }; }; -} // namespace AppointmentEdgeMethod +} // namespace AppointmentEdgeHas -namespace AppointmentConnectionMethod { +namespace AppointmentConnectionHas { template -concept WithParamsPageInfo = requires (TImpl impl, service::FieldParams params) +concept getPageInfoWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getPageInfo(std::move(params)) } }; }; template -concept NoParamsPageInfo = requires (TImpl impl) +concept getPageInfo = requires (TImpl impl) { { service::FieldResult> { impl.getPageInfo() } }; }; template -concept WithParamsEdges = requires (TImpl impl, service::FieldParams params) +concept getEdgesWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult>>> { impl.getEdges(std::move(params)) } }; }; template -concept NoParamsEdges = requires (TImpl impl) +concept getEdges = requires (TImpl impl) { { service::FieldResult>>> { impl.getEdges() } }; }; template -concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.beginSelectionSet(params) }; }; template -concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.endSelectionSet(params) }; }; -} // namespace AppointmentConnectionMethod +} // namespace AppointmentConnectionHas -namespace TaskEdgeMethod { +namespace TaskEdgeHas { template -concept WithParamsNode = requires (TImpl impl, service::FieldParams params) +concept getNodeWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getNode(std::move(params)) } }; }; template -concept NoParamsNode = requires (TImpl impl) +concept getNode = requires (TImpl impl) { { service::FieldResult> { impl.getNode() } }; }; template -concept WithParamsCursor = requires (TImpl impl, service::FieldParams params) +concept getCursorWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getCursor(std::move(params)) } }; }; template -concept NoParamsCursor = requires (TImpl impl) +concept getCursor = requires (TImpl impl) { { service::FieldResult { impl.getCursor() } }; }; template -concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.beginSelectionSet(params) }; }; template -concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.endSelectionSet(params) }; }; -} // namespace TaskEdgeMethod +} // namespace TaskEdgeHas -namespace TaskConnectionMethod { +namespace TaskConnectionHas { template -concept WithParamsPageInfo = requires (TImpl impl, service::FieldParams params) +concept getPageInfoWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getPageInfo(std::move(params)) } }; }; template -concept NoParamsPageInfo = requires (TImpl impl) +concept getPageInfo = requires (TImpl impl) { { service::FieldResult> { impl.getPageInfo() } }; }; template -concept WithParamsEdges = requires (TImpl impl, service::FieldParams params) +concept getEdgesWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult>>> { impl.getEdges(std::move(params)) } }; }; template -concept NoParamsEdges = requires (TImpl impl) +concept getEdges = requires (TImpl impl) { { service::FieldResult>>> { impl.getEdges() } }; }; template -concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.beginSelectionSet(params) }; }; template -concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.endSelectionSet(params) }; }; -} // namespace TaskConnectionMethod +} // namespace TaskConnectionHas -namespace FolderEdgeMethod { +namespace FolderEdgeHas { template -concept WithParamsNode = requires (TImpl impl, service::FieldParams params) +concept getNodeWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getNode(std::move(params)) } }; }; template -concept NoParamsNode = requires (TImpl impl) +concept getNode = requires (TImpl impl) { { service::FieldResult> { impl.getNode() } }; }; template -concept WithParamsCursor = requires (TImpl impl, service::FieldParams params) +concept getCursorWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getCursor(std::move(params)) } }; }; template -concept NoParamsCursor = requires (TImpl impl) +concept getCursor = requires (TImpl impl) { { service::FieldResult { impl.getCursor() } }; }; template -concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.beginSelectionSet(params) }; }; template -concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.endSelectionSet(params) }; }; -} // namespace FolderEdgeMethod +} // namespace FolderEdgeHas -namespace FolderConnectionMethod { +namespace FolderConnectionHas { template -concept WithParamsPageInfo = requires (TImpl impl, service::FieldParams params) +concept getPageInfoWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getPageInfo(std::move(params)) } }; }; template -concept NoParamsPageInfo = requires (TImpl impl) +concept getPageInfo = requires (TImpl impl) { { service::FieldResult> { impl.getPageInfo() } }; }; template -concept WithParamsEdges = requires (TImpl impl, service::FieldParams params) +concept getEdgesWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult>>> { impl.getEdges(std::move(params)) } }; }; template -concept NoParamsEdges = requires (TImpl impl) +concept getEdges = requires (TImpl impl) { { service::FieldResult>>> { impl.getEdges() } }; }; template -concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.beginSelectionSet(params) }; }; template -concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.endSelectionSet(params) }; }; -} // namespace FolderConnectionMethod +} // namespace FolderConnectionHas -namespace CompleteTaskPayloadMethod { +namespace CompleteTaskPayloadHas { template -concept WithParamsTask = requires (TImpl impl, service::FieldParams params) +concept getTaskWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getTask(std::move(params)) } }; }; template -concept NoParamsTask = requires (TImpl impl) +concept getTask = requires (TImpl impl) { { service::FieldResult> { impl.getTask() } }; }; template -concept WithParamsClientMutationId = requires (TImpl impl, service::FieldParams params) +concept getClientMutationIdWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getClientMutationId(std::move(params)) } }; }; template -concept NoParamsClientMutationId = requires (TImpl impl) +concept getClientMutationId = requires (TImpl impl) { { service::FieldResult> { impl.getClientMutationId() } }; }; template -concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.beginSelectionSet(params) }; }; template -concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.endSelectionSet(params) }; }; -} // namespace CompleteTaskPayloadMethod +} // namespace CompleteTaskPayloadHas -namespace MutationMethod { +namespace MutationHas { template -concept WithParamsCompleteTask = requires (TImpl impl, service::FieldParams params, CompleteTaskInput inputArg) +concept applyCompleteTaskWithParams = requires (TImpl impl, service::FieldParams params, CompleteTaskInput inputArg) { { service::FieldResult> { impl.applyCompleteTask(std::move(params), std::move(inputArg)) } }; }; template -concept NoParamsCompleteTask = requires (TImpl impl, CompleteTaskInput inputArg) +concept applyCompleteTask = requires (TImpl impl, CompleteTaskInput inputArg) { { service::FieldResult> { impl.applyCompleteTask(std::move(inputArg)) } }; }; template -concept WithParamsSetFloat = requires (TImpl impl, service::FieldParams params, double valueArg) +concept applySetFloatWithParams = requires (TImpl impl, service::FieldParams params, double valueArg) { { service::FieldResult { impl.applySetFloat(std::move(params), std::move(valueArg)) } }; }; template -concept NoParamsSetFloat = requires (TImpl impl, double valueArg) +concept applySetFloat = requires (TImpl impl, double valueArg) { { service::FieldResult { impl.applySetFloat(std::move(valueArg)) } }; }; template -concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.beginSelectionSet(params) }; }; template -concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.endSelectionSet(params) }; }; -} // namespace MutationMethod +} // namespace MutationHas -namespace SubscriptionMethod { +namespace SubscriptionHas { template -concept WithParamsNextAppointmentChange = requires (TImpl impl, service::FieldParams params) +concept getNextAppointmentChangeWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getNextAppointmentChange(std::move(params)) } }; }; template -concept NoParamsNextAppointmentChange = requires (TImpl impl) +concept getNextAppointmentChange = requires (TImpl impl) { { service::FieldResult> { impl.getNextAppointmentChange() } }; }; template -concept WithParamsNodeChange = requires (TImpl impl, service::FieldParams params, response::IdType idArg) +concept getNodeChangeWithParams = requires (TImpl impl, service::FieldParams params, response::IdType idArg) { - { service::FieldResult> { impl.getNodeChange(std::move(params), std::move(idArg)) } }; + { service::FieldResult> { impl.getNodeChange(std::move(params), std::move(idArg)) } }; }; template -concept NoParamsNodeChange = requires (TImpl impl, response::IdType idArg) +concept getNodeChange = requires (TImpl impl, response::IdType idArg) { - { service::FieldResult> { impl.getNodeChange(std::move(idArg)) } }; + { service::FieldResult> { impl.getNodeChange(std::move(idArg)) } }; }; template -concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.beginSelectionSet(params) }; }; template -concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.endSelectionSet(params) }; }; -} // namespace SubscriptionMethod +} // namespace SubscriptionHas -namespace AppointmentMethod { +namespace AppointmentHas { template -concept WithParamsId = requires (TImpl impl, service::FieldParams params) +concept getIdWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getId(std::move(params)) } }; }; template -concept NoParamsId = requires (TImpl impl) +concept getId = requires (TImpl impl) { { service::FieldResult { impl.getId() } }; }; template -concept WithParamsWhen = requires (TImpl impl, service::FieldParams params) +concept getWhenWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getWhen(std::move(params)) } }; }; template -concept NoParamsWhen = requires (TImpl impl) +concept getWhen = requires (TImpl impl) { { service::FieldResult> { impl.getWhen() } }; }; template -concept WithParamsSubject = requires (TImpl impl, service::FieldParams params) +concept getSubjectWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getSubject(std::move(params)) } }; }; template -concept NoParamsSubject = requires (TImpl impl) +concept getSubject = requires (TImpl impl) { { service::FieldResult> { impl.getSubject() } }; }; template -concept WithParamsIsNow = requires (TImpl impl, service::FieldParams params) +concept getIsNowWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getIsNow(std::move(params)) } }; }; template -concept NoParamsIsNow = requires (TImpl impl) +concept getIsNow = requires (TImpl impl) { { service::FieldResult { impl.getIsNow() } }; }; template -concept WithParamsForceError = requires (TImpl impl, service::FieldParams params) +concept getForceErrorWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getForceError(std::move(params)) } }; }; template -concept NoParamsForceError = requires (TImpl impl) +concept getForceError = requires (TImpl impl) { { service::FieldResult> { impl.getForceError() } }; }; template -concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.beginSelectionSet(params) }; }; template -concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.endSelectionSet(params) }; }; -} // namespace AppointmentMethod +} // namespace AppointmentHas -namespace TaskMethod { +namespace TaskHas { template -concept WithParamsId = requires (TImpl impl, service::FieldParams params) +concept getIdWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getId(std::move(params)) } }; }; template -concept NoParamsId = requires (TImpl impl) +concept getId = requires (TImpl impl) { { service::FieldResult { impl.getId() } }; }; template -concept WithParamsTitle = requires (TImpl impl, service::FieldParams params) +concept getTitleWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getTitle(std::move(params)) } }; }; template -concept NoParamsTitle = requires (TImpl impl) +concept getTitle = requires (TImpl impl) { { service::FieldResult> { impl.getTitle() } }; }; template -concept WithParamsIsComplete = requires (TImpl impl, service::FieldParams params) +concept getIsCompleteWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getIsComplete(std::move(params)) } }; }; template -concept NoParamsIsComplete = requires (TImpl impl) +concept getIsComplete = requires (TImpl impl) { { service::FieldResult { impl.getIsComplete() } }; }; template -concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.beginSelectionSet(params) }; }; template -concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.endSelectionSet(params) }; }; -} // namespace TaskMethod +} // namespace TaskHas -namespace FolderMethod { +namespace FolderHas { template -concept WithParamsId = requires (TImpl impl, service::FieldParams params) +concept getIdWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getId(std::move(params)) } }; }; template -concept NoParamsId = requires (TImpl impl) +concept getId = requires (TImpl impl) { { service::FieldResult { impl.getId() } }; }; template -concept WithParamsName = requires (TImpl impl, service::FieldParams params) +concept getNameWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getName(std::move(params)) } }; }; template -concept NoParamsName = requires (TImpl impl) +concept getName = requires (TImpl impl) { { service::FieldResult> { impl.getName() } }; }; template -concept WithParamsUnreadCount = requires (TImpl impl, service::FieldParams params) +concept getUnreadCountWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getUnreadCount(std::move(params)) } }; }; template -concept NoParamsUnreadCount = requires (TImpl impl) +concept getUnreadCount = requires (TImpl impl) { { service::FieldResult { impl.getUnreadCount() } }; }; template -concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.beginSelectionSet(params) }; }; template -concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.endSelectionSet(params) }; }; -} // namespace FolderMethod +} // namespace FolderHas -namespace NestedTypeMethod { +namespace NestedTypeHas { template -concept WithParamsDepth = requires (TImpl impl, service::FieldParams params) +concept getDepthWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getDepth(std::move(params)) } }; }; template -concept NoParamsDepth = requires (TImpl impl) +concept getDepth = requires (TImpl impl) { { service::FieldResult { impl.getDepth() } }; }; template -concept WithParamsNested = requires (TImpl impl, service::FieldParams params) +concept getNestedWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getNested(std::move(params)) } }; }; template -concept NoParamsNested = requires (TImpl impl) +concept getNested = requires (TImpl impl) { { service::FieldResult> { impl.getNested() } }; }; template -concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.beginSelectionSet(params) }; }; template -concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.endSelectionSet(params) }; }; -} // namespace NestedTypeMethod +} // namespace NestedTypeHas -namespace ExpensiveMethod { +namespace ExpensiveHas { template -concept WithParamsOrder = requires (TImpl impl, service::FieldParams params) +concept getOrderWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getOrder(std::move(params)) } }; }; template -concept NoParamsOrder = requires (TImpl impl) +concept getOrder = requires (TImpl impl) { { service::FieldResult { impl.getOrder() } }; }; template -concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.beginSelectionSet(params) }; }; template -concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.endSelectionSet(params) }; }; -} // namespace ExpensiveMethod +} // namespace ExpensiveHas } // namespace methods class Query : public service::Object { private: - service::AwaitableResolver resolveNode(service::ResolverParams&& params); - service::AwaitableResolver resolveAppointments(service::ResolverParams&& params); - service::AwaitableResolver resolveTasks(service::ResolverParams&& params); - service::AwaitableResolver resolveUnreadCounts(service::ResolverParams&& params); - service::AwaitableResolver resolveAppointmentsById(service::ResolverParams&& params); - service::AwaitableResolver resolveTasksById(service::ResolverParams&& params); - service::AwaitableResolver resolveUnreadCountsById(service::ResolverParams&& params); - service::AwaitableResolver resolveNested(service::ResolverParams&& params); - service::AwaitableResolver resolveUnimplemented(service::ResolverParams&& params); - service::AwaitableResolver resolveExpensive(service::ResolverParams&& params); - service::AwaitableResolver resolveTestTaskState(service::ResolverParams&& params); - service::AwaitableResolver resolveAnyType(service::ResolverParams&& params); - - service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolveNode(service::ResolverParams&& params) const; + service::AwaitableResolver resolveAppointments(service::ResolverParams&& params) const; + service::AwaitableResolver resolveTasks(service::ResolverParams&& params) const; + service::AwaitableResolver resolveUnreadCounts(service::ResolverParams&& params) const; + service::AwaitableResolver resolveAppointmentsById(service::ResolverParams&& params) const; + service::AwaitableResolver resolveTasksById(service::ResolverParams&& params) const; + service::AwaitableResolver resolveUnreadCountsById(service::ResolverParams&& params) const; + service::AwaitableResolver resolveNested(service::ResolverParams&& params) const; + service::AwaitableResolver resolveUnimplemented(service::ResolverParams&& params) const; + service::AwaitableResolver resolveExpensive(service::ResolverParams&& params) const; + service::AwaitableResolver resolveTestTaskState(service::ResolverParams&& params) const; + service::AwaitableResolver resolveAnyType(service::ResolverParams&& params) const; + + service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; struct Concept { @@ -923,7 +994,7 @@ class Query virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual service::FieldResult> getNode(service::FieldParams&& params, response::IdType&& idArg) const = 0; + virtual service::FieldResult> getNode(service::FieldParams&& params, response::IdType&& idArg) const = 0; virtual service::FieldResult> getAppointments(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const = 0; virtual service::FieldResult> getTasks(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const = 0; virtual service::FieldResult> getUnreadCounts(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const = 0; @@ -946,13 +1017,13 @@ class Query { } - service::FieldResult> getNode(service::FieldParams&& params, response::IdType&& idArg) const final + service::FieldResult> getNode(service::FieldParams&& params, response::IdType&& idArg) const final { - if constexpr (methods::QueryMethod::WithParamsNode) + if constexpr (methods::QueryHas::getNodeWithParams) { return { _pimpl->getNode(std::move(params), std::move(idArg)) }; } - else if constexpr (methods::QueryMethod::NoParamsNode) + else if constexpr (methods::QueryHas::getNode) { return { _pimpl->getNode(std::move(idArg)) }; } @@ -964,11 +1035,11 @@ class Query service::FieldResult> getAppointments(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const final { - if constexpr (methods::QueryMethod::WithParamsAppointments) + if constexpr (methods::QueryHas::getAppointmentsWithParams) { return { _pimpl->getAppointments(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) }; } - else if constexpr (methods::QueryMethod::NoParamsAppointments) + else if constexpr (methods::QueryHas::getAppointments) { return { _pimpl->getAppointments(std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) }; } @@ -980,11 +1051,11 @@ class Query service::FieldResult> getTasks(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const final { - if constexpr (methods::QueryMethod::WithParamsTasks) + if constexpr (methods::QueryHas::getTasksWithParams) { return { _pimpl->getTasks(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) }; } - else if constexpr (methods::QueryMethod::NoParamsTasks) + else if constexpr (methods::QueryHas::getTasks) { return { _pimpl->getTasks(std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) }; } @@ -996,11 +1067,11 @@ class Query service::FieldResult> getUnreadCounts(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const final { - if constexpr (methods::QueryMethod::WithParamsUnreadCounts) + if constexpr (methods::QueryHas::getUnreadCountsWithParams) { return { _pimpl->getUnreadCounts(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) }; } - else if constexpr (methods::QueryMethod::NoParamsUnreadCounts) + else if constexpr (methods::QueryHas::getUnreadCounts) { return { _pimpl->getUnreadCounts(std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) }; } @@ -1012,11 +1083,11 @@ class Query service::FieldResult>> getAppointmentsById(service::FieldParams&& params, std::vector&& idsArg) const final { - if constexpr (methods::QueryMethod::WithParamsAppointmentsById) + if constexpr (methods::QueryHas::getAppointmentsByIdWithParams) { return { _pimpl->getAppointmentsById(std::move(params), std::move(idsArg)) }; } - else if constexpr (methods::QueryMethod::NoParamsAppointmentsById) + else if constexpr (methods::QueryHas::getAppointmentsById) { return { _pimpl->getAppointmentsById(std::move(idsArg)) }; } @@ -1028,11 +1099,11 @@ class Query service::FieldResult>> getTasksById(service::FieldParams&& params, std::vector&& idsArg) const final { - if constexpr (methods::QueryMethod::WithParamsTasksById) + if constexpr (methods::QueryHas::getTasksByIdWithParams) { return { _pimpl->getTasksById(std::move(params), std::move(idsArg)) }; } - else if constexpr (methods::QueryMethod::NoParamsTasksById) + else if constexpr (methods::QueryHas::getTasksById) { return { _pimpl->getTasksById(std::move(idsArg)) }; } @@ -1044,11 +1115,11 @@ class Query service::FieldResult>> getUnreadCountsById(service::FieldParams&& params, std::vector&& idsArg) const final { - if constexpr (methods::QueryMethod::WithParamsUnreadCountsById) + if constexpr (methods::QueryHas::getUnreadCountsByIdWithParams) { return { _pimpl->getUnreadCountsById(std::move(params), std::move(idsArg)) }; } - else if constexpr (methods::QueryMethod::NoParamsUnreadCountsById) + else if constexpr (methods::QueryHas::getUnreadCountsById) { return { _pimpl->getUnreadCountsById(std::move(idsArg)) }; } @@ -1060,11 +1131,11 @@ class Query service::FieldResult> getNested(service::FieldParams&& params) const final { - if constexpr (methods::QueryMethod::WithParamsNested) + if constexpr (methods::QueryHas::getNestedWithParams) { return { _pimpl->getNested(std::move(params)) }; } - else if constexpr (methods::QueryMethod::NoParamsNested) + else if constexpr (methods::QueryHas::getNested) { return { _pimpl->getNested() }; } @@ -1076,11 +1147,11 @@ class Query service::FieldResult getUnimplemented(service::FieldParams&& params) const final { - if constexpr (methods::QueryMethod::WithParamsUnimplemented) + if constexpr (methods::QueryHas::getUnimplementedWithParams) { return { _pimpl->getUnimplemented(std::move(params)) }; } - else if constexpr (methods::QueryMethod::NoParamsUnimplemented) + else if constexpr (methods::QueryHas::getUnimplemented) { return { _pimpl->getUnimplemented() }; } @@ -1092,11 +1163,11 @@ class Query service::FieldResult>> getExpensive(service::FieldParams&& params) const final { - if constexpr (methods::QueryMethod::WithParamsExpensive) + if constexpr (methods::QueryHas::getExpensiveWithParams) { return { _pimpl->getExpensive(std::move(params)) }; } - else if constexpr (methods::QueryMethod::NoParamsExpensive) + else if constexpr (methods::QueryHas::getExpensive) { return { _pimpl->getExpensive() }; } @@ -1108,11 +1179,11 @@ class Query service::FieldResult getTestTaskState(service::FieldParams&& params) const final { - if constexpr (methods::QueryMethod::WithParamsTestTaskState) + if constexpr (methods::QueryHas::getTestTaskStateWithParams) { return { _pimpl->getTestTaskState(std::move(params)) }; } - else if constexpr (methods::QueryMethod::NoParamsTestTaskState) + else if constexpr (methods::QueryHas::getTestTaskState) { return { _pimpl->getTestTaskState() }; } @@ -1124,11 +1195,11 @@ class Query service::FieldResult>> getAnyType(service::FieldParams&& params, std::vector&& idsArg) const final { - if constexpr (methods::QueryMethod::WithParamsAnyType) + if constexpr (methods::QueryHas::getAnyTypeWithParams) { return { _pimpl->getAnyType(std::move(params), std::move(idsArg)) }; } - else if constexpr (methods::QueryMethod::NoParamsAnyType) + else if constexpr (methods::QueryHas::getAnyType) { return { _pimpl->getAnyType(std::move(idsArg)) }; } @@ -1140,7 +1211,7 @@ class Query void beginSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::QueryMethod::HasBeginSelectionSet) + if constexpr (methods::QueryHas::beginSelectionSet) { _pimpl->beginSelectionSet(params); } @@ -1148,7 +1219,7 @@ class Query void endSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::QueryMethod::HasEndSelectionSet) + if constexpr (methods::QueryHas::endSelectionSet) { _pimpl->endSelectionSet(params); } @@ -1158,7 +1229,10 @@ class Query const std::shared_ptr _pimpl; }; - Query(std::unique_ptr&& pimpl); + Query(std::unique_ptr&& pimpl) noexcept; + + service::TypeNames getTypeNames() const noexcept; + service::ResolverMap getResolvers() const noexcept; void beginSelectionSet(const service::SelectionSetParams& params) const final; void endSelectionSet(const service::SelectionSetParams& params) const final; @@ -1167,7 +1241,7 @@ class Query public: template - Query(std::shared_ptr pimpl) + Query(std::shared_ptr pimpl) noexcept : Query { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } @@ -1177,10 +1251,10 @@ class PageInfo : public service::Object { private: - service::AwaitableResolver resolveHasNextPage(service::ResolverParams&& params); - service::AwaitableResolver resolveHasPreviousPage(service::ResolverParams&& params); + service::AwaitableResolver resolveHasNextPage(service::ResolverParams&& params) const; + service::AwaitableResolver resolveHasPreviousPage(service::ResolverParams&& params) const; - service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; struct Concept { @@ -1204,11 +1278,11 @@ class PageInfo service::FieldResult getHasNextPage(service::FieldParams&& params) const final { - if constexpr (methods::PageInfoMethod::WithParamsHasNextPage) + if constexpr (methods::PageInfoHas::getHasNextPageWithParams) { return { _pimpl->getHasNextPage(std::move(params)) }; } - else if constexpr (methods::PageInfoMethod::NoParamsHasNextPage) + else if constexpr (methods::PageInfoHas::getHasNextPage) { return { _pimpl->getHasNextPage() }; } @@ -1220,11 +1294,11 @@ class PageInfo service::FieldResult getHasPreviousPage(service::FieldParams&& params) const final { - if constexpr (methods::PageInfoMethod::WithParamsHasPreviousPage) + if constexpr (methods::PageInfoHas::getHasPreviousPageWithParams) { return { _pimpl->getHasPreviousPage(std::move(params)) }; } - else if constexpr (methods::PageInfoMethod::NoParamsHasPreviousPage) + else if constexpr (methods::PageInfoHas::getHasPreviousPage) { return { _pimpl->getHasPreviousPage() }; } @@ -1236,7 +1310,7 @@ class PageInfo void beginSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::PageInfoMethod::HasBeginSelectionSet) + if constexpr (methods::PageInfoHas::beginSelectionSet) { _pimpl->beginSelectionSet(params); } @@ -1244,7 +1318,7 @@ class PageInfo void endSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::PageInfoMethod::HasEndSelectionSet) + if constexpr (methods::PageInfoHas::endSelectionSet) { _pimpl->endSelectionSet(params); } @@ -1254,7 +1328,10 @@ class PageInfo const std::shared_ptr _pimpl; }; - PageInfo(std::unique_ptr&& pimpl); + PageInfo(std::unique_ptr&& pimpl) noexcept; + + service::TypeNames getTypeNames() const noexcept; + service::ResolverMap getResolvers() const noexcept; void beginSelectionSet(const service::SelectionSetParams& params) const final; void endSelectionSet(const service::SelectionSetParams& params) const final; @@ -1263,7 +1340,7 @@ class PageInfo public: template - PageInfo(std::shared_ptr pimpl) + PageInfo(std::shared_ptr pimpl) noexcept : PageInfo { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } @@ -1273,10 +1350,10 @@ class AppointmentEdge : public service::Object { private: - service::AwaitableResolver resolveNode(service::ResolverParams&& params); - service::AwaitableResolver resolveCursor(service::ResolverParams&& params); + service::AwaitableResolver resolveNode(service::ResolverParams&& params) const; + service::AwaitableResolver resolveCursor(service::ResolverParams&& params) const; - service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; struct Concept { @@ -1300,11 +1377,11 @@ class AppointmentEdge service::FieldResult> getNode(service::FieldParams&& params) const final { - if constexpr (methods::AppointmentEdgeMethod::WithParamsNode) + if constexpr (methods::AppointmentEdgeHas::getNodeWithParams) { return { _pimpl->getNode(std::move(params)) }; } - else if constexpr (methods::AppointmentEdgeMethod::NoParamsNode) + else if constexpr (methods::AppointmentEdgeHas::getNode) { return { _pimpl->getNode() }; } @@ -1316,11 +1393,11 @@ class AppointmentEdge service::FieldResult getCursor(service::FieldParams&& params) const final { - if constexpr (methods::AppointmentEdgeMethod::WithParamsCursor) + if constexpr (methods::AppointmentEdgeHas::getCursorWithParams) { return { _pimpl->getCursor(std::move(params)) }; } - else if constexpr (methods::AppointmentEdgeMethod::NoParamsCursor) + else if constexpr (methods::AppointmentEdgeHas::getCursor) { return { _pimpl->getCursor() }; } @@ -1332,7 +1409,7 @@ class AppointmentEdge void beginSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::AppointmentEdgeMethod::HasBeginSelectionSet) + if constexpr (methods::AppointmentEdgeHas::beginSelectionSet) { _pimpl->beginSelectionSet(params); } @@ -1340,7 +1417,7 @@ class AppointmentEdge void endSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::AppointmentEdgeMethod::HasEndSelectionSet) + if constexpr (methods::AppointmentEdgeHas::endSelectionSet) { _pimpl->endSelectionSet(params); } @@ -1350,7 +1427,10 @@ class AppointmentEdge const std::shared_ptr _pimpl; }; - AppointmentEdge(std::unique_ptr&& pimpl); + AppointmentEdge(std::unique_ptr&& pimpl) noexcept; + + service::TypeNames getTypeNames() const noexcept; + service::ResolverMap getResolvers() const noexcept; void beginSelectionSet(const service::SelectionSetParams& params) const final; void endSelectionSet(const service::SelectionSetParams& params) const final; @@ -1359,7 +1439,7 @@ class AppointmentEdge public: template - AppointmentEdge(std::shared_ptr pimpl) + AppointmentEdge(std::shared_ptr pimpl) noexcept : AppointmentEdge { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } @@ -1369,10 +1449,10 @@ class AppointmentConnection : public service::Object { private: - service::AwaitableResolver resolvePageInfo(service::ResolverParams&& params); - service::AwaitableResolver resolveEdges(service::ResolverParams&& params); + service::AwaitableResolver resolvePageInfo(service::ResolverParams&& params) const; + service::AwaitableResolver resolveEdges(service::ResolverParams&& params) const; - service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; struct Concept { @@ -1396,11 +1476,11 @@ class AppointmentConnection service::FieldResult> getPageInfo(service::FieldParams&& params) const final { - if constexpr (methods::AppointmentConnectionMethod::WithParamsPageInfo) + if constexpr (methods::AppointmentConnectionHas::getPageInfoWithParams) { return { _pimpl->getPageInfo(std::move(params)) }; } - else if constexpr (methods::AppointmentConnectionMethod::NoParamsPageInfo) + else if constexpr (methods::AppointmentConnectionHas::getPageInfo) { return { _pimpl->getPageInfo() }; } @@ -1412,11 +1492,11 @@ class AppointmentConnection service::FieldResult>>> getEdges(service::FieldParams&& params) const final { - if constexpr (methods::AppointmentConnectionMethod::WithParamsEdges) + if constexpr (methods::AppointmentConnectionHas::getEdgesWithParams) { return { _pimpl->getEdges(std::move(params)) }; } - else if constexpr (methods::AppointmentConnectionMethod::NoParamsEdges) + else if constexpr (methods::AppointmentConnectionHas::getEdges) { return { _pimpl->getEdges() }; } @@ -1428,7 +1508,7 @@ class AppointmentConnection void beginSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::AppointmentConnectionMethod::HasBeginSelectionSet) + if constexpr (methods::AppointmentConnectionHas::beginSelectionSet) { _pimpl->beginSelectionSet(params); } @@ -1436,7 +1516,7 @@ class AppointmentConnection void endSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::AppointmentConnectionMethod::HasEndSelectionSet) + if constexpr (methods::AppointmentConnectionHas::endSelectionSet) { _pimpl->endSelectionSet(params); } @@ -1446,7 +1526,10 @@ class AppointmentConnection const std::shared_ptr _pimpl; }; - AppointmentConnection(std::unique_ptr&& pimpl); + AppointmentConnection(std::unique_ptr&& pimpl) noexcept; + + service::TypeNames getTypeNames() const noexcept; + service::ResolverMap getResolvers() const noexcept; void beginSelectionSet(const service::SelectionSetParams& params) const final; void endSelectionSet(const service::SelectionSetParams& params) const final; @@ -1455,7 +1538,7 @@ class AppointmentConnection public: template - AppointmentConnection(std::shared_ptr pimpl) + AppointmentConnection(std::shared_ptr pimpl) noexcept : AppointmentConnection { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } @@ -1465,10 +1548,10 @@ class TaskEdge : public service::Object { private: - service::AwaitableResolver resolveNode(service::ResolverParams&& params); - service::AwaitableResolver resolveCursor(service::ResolverParams&& params); + service::AwaitableResolver resolveNode(service::ResolverParams&& params) const; + service::AwaitableResolver resolveCursor(service::ResolverParams&& params) const; - service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; struct Concept { @@ -1492,11 +1575,11 @@ class TaskEdge service::FieldResult> getNode(service::FieldParams&& params) const final { - if constexpr (methods::TaskEdgeMethod::WithParamsNode) + if constexpr (methods::TaskEdgeHas::getNodeWithParams) { return { _pimpl->getNode(std::move(params)) }; } - else if constexpr (methods::TaskEdgeMethod::NoParamsNode) + else if constexpr (methods::TaskEdgeHas::getNode) { return { _pimpl->getNode() }; } @@ -1508,11 +1591,11 @@ class TaskEdge service::FieldResult getCursor(service::FieldParams&& params) const final { - if constexpr (methods::TaskEdgeMethod::WithParamsCursor) + if constexpr (methods::TaskEdgeHas::getCursorWithParams) { return { _pimpl->getCursor(std::move(params)) }; } - else if constexpr (methods::TaskEdgeMethod::NoParamsCursor) + else if constexpr (methods::TaskEdgeHas::getCursor) { return { _pimpl->getCursor() }; } @@ -1524,7 +1607,7 @@ class TaskEdge void beginSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::TaskEdgeMethod::HasBeginSelectionSet) + if constexpr (methods::TaskEdgeHas::beginSelectionSet) { _pimpl->beginSelectionSet(params); } @@ -1532,7 +1615,7 @@ class TaskEdge void endSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::TaskEdgeMethod::HasEndSelectionSet) + if constexpr (methods::TaskEdgeHas::endSelectionSet) { _pimpl->endSelectionSet(params); } @@ -1542,7 +1625,10 @@ class TaskEdge const std::shared_ptr _pimpl; }; - TaskEdge(std::unique_ptr&& pimpl); + TaskEdge(std::unique_ptr&& pimpl) noexcept; + + service::TypeNames getTypeNames() const noexcept; + service::ResolverMap getResolvers() const noexcept; void beginSelectionSet(const service::SelectionSetParams& params) const final; void endSelectionSet(const service::SelectionSetParams& params) const final; @@ -1551,7 +1637,7 @@ class TaskEdge public: template - TaskEdge(std::shared_ptr pimpl) + TaskEdge(std::shared_ptr pimpl) noexcept : TaskEdge { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } @@ -1561,10 +1647,10 @@ class TaskConnection : public service::Object { private: - service::AwaitableResolver resolvePageInfo(service::ResolverParams&& params); - service::AwaitableResolver resolveEdges(service::ResolverParams&& params); + service::AwaitableResolver resolvePageInfo(service::ResolverParams&& params) const; + service::AwaitableResolver resolveEdges(service::ResolverParams&& params) const; - service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; struct Concept { @@ -1588,11 +1674,11 @@ class TaskConnection service::FieldResult> getPageInfo(service::FieldParams&& params) const final { - if constexpr (methods::TaskConnectionMethod::WithParamsPageInfo) + if constexpr (methods::TaskConnectionHas::getPageInfoWithParams) { return { _pimpl->getPageInfo(std::move(params)) }; } - else if constexpr (methods::TaskConnectionMethod::NoParamsPageInfo) + else if constexpr (methods::TaskConnectionHas::getPageInfo) { return { _pimpl->getPageInfo() }; } @@ -1604,11 +1690,11 @@ class TaskConnection service::FieldResult>>> getEdges(service::FieldParams&& params) const final { - if constexpr (methods::TaskConnectionMethod::WithParamsEdges) + if constexpr (methods::TaskConnectionHas::getEdgesWithParams) { return { _pimpl->getEdges(std::move(params)) }; } - else if constexpr (methods::TaskConnectionMethod::NoParamsEdges) + else if constexpr (methods::TaskConnectionHas::getEdges) { return { _pimpl->getEdges() }; } @@ -1620,7 +1706,7 @@ class TaskConnection void beginSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::TaskConnectionMethod::HasBeginSelectionSet) + if constexpr (methods::TaskConnectionHas::beginSelectionSet) { _pimpl->beginSelectionSet(params); } @@ -1628,7 +1714,7 @@ class TaskConnection void endSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::TaskConnectionMethod::HasEndSelectionSet) + if constexpr (methods::TaskConnectionHas::endSelectionSet) { _pimpl->endSelectionSet(params); } @@ -1638,7 +1724,10 @@ class TaskConnection const std::shared_ptr _pimpl; }; - TaskConnection(std::unique_ptr&& pimpl); + TaskConnection(std::unique_ptr&& pimpl) noexcept; + + service::TypeNames getTypeNames() const noexcept; + service::ResolverMap getResolvers() const noexcept; void beginSelectionSet(const service::SelectionSetParams& params) const final; void endSelectionSet(const service::SelectionSetParams& params) const final; @@ -1647,7 +1736,7 @@ class TaskConnection public: template - TaskConnection(std::shared_ptr pimpl) + TaskConnection(std::shared_ptr pimpl) noexcept : TaskConnection { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } @@ -1657,10 +1746,10 @@ class FolderEdge : public service::Object { private: - service::AwaitableResolver resolveNode(service::ResolverParams&& params); - service::AwaitableResolver resolveCursor(service::ResolverParams&& params); + service::AwaitableResolver resolveNode(service::ResolverParams&& params) const; + service::AwaitableResolver resolveCursor(service::ResolverParams&& params) const; - service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; struct Concept { @@ -1684,11 +1773,11 @@ class FolderEdge service::FieldResult> getNode(service::FieldParams&& params) const final { - if constexpr (methods::FolderEdgeMethod::WithParamsNode) + if constexpr (methods::FolderEdgeHas::getNodeWithParams) { return { _pimpl->getNode(std::move(params)) }; } - else if constexpr (methods::FolderEdgeMethod::NoParamsNode) + else if constexpr (methods::FolderEdgeHas::getNode) { return { _pimpl->getNode() }; } @@ -1700,11 +1789,11 @@ class FolderEdge service::FieldResult getCursor(service::FieldParams&& params) const final { - if constexpr (methods::FolderEdgeMethod::WithParamsCursor) + if constexpr (methods::FolderEdgeHas::getCursorWithParams) { return { _pimpl->getCursor(std::move(params)) }; } - else if constexpr (methods::FolderEdgeMethod::NoParamsCursor) + else if constexpr (methods::FolderEdgeHas::getCursor) { return { _pimpl->getCursor() }; } @@ -1716,7 +1805,7 @@ class FolderEdge void beginSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::FolderEdgeMethod::HasBeginSelectionSet) + if constexpr (methods::FolderEdgeHas::beginSelectionSet) { _pimpl->beginSelectionSet(params); } @@ -1724,7 +1813,7 @@ class FolderEdge void endSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::FolderEdgeMethod::HasEndSelectionSet) + if constexpr (methods::FolderEdgeHas::endSelectionSet) { _pimpl->endSelectionSet(params); } @@ -1734,7 +1823,10 @@ class FolderEdge const std::shared_ptr _pimpl; }; - FolderEdge(std::unique_ptr&& pimpl); + FolderEdge(std::unique_ptr&& pimpl) noexcept; + + service::TypeNames getTypeNames() const noexcept; + service::ResolverMap getResolvers() const noexcept; void beginSelectionSet(const service::SelectionSetParams& params) const final; void endSelectionSet(const service::SelectionSetParams& params) const final; @@ -1743,7 +1835,7 @@ class FolderEdge public: template - FolderEdge(std::shared_ptr pimpl) + FolderEdge(std::shared_ptr pimpl) noexcept : FolderEdge { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } @@ -1753,10 +1845,10 @@ class FolderConnection : public service::Object { private: - service::AwaitableResolver resolvePageInfo(service::ResolverParams&& params); - service::AwaitableResolver resolveEdges(service::ResolverParams&& params); + service::AwaitableResolver resolvePageInfo(service::ResolverParams&& params) const; + service::AwaitableResolver resolveEdges(service::ResolverParams&& params) const; - service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; struct Concept { @@ -1780,11 +1872,11 @@ class FolderConnection service::FieldResult> getPageInfo(service::FieldParams&& params) const final { - if constexpr (methods::FolderConnectionMethod::WithParamsPageInfo) + if constexpr (methods::FolderConnectionHas::getPageInfoWithParams) { return { _pimpl->getPageInfo(std::move(params)) }; } - else if constexpr (methods::FolderConnectionMethod::NoParamsPageInfo) + else if constexpr (methods::FolderConnectionHas::getPageInfo) { return { _pimpl->getPageInfo() }; } @@ -1796,11 +1888,11 @@ class FolderConnection service::FieldResult>>> getEdges(service::FieldParams&& params) const final { - if constexpr (methods::FolderConnectionMethod::WithParamsEdges) + if constexpr (methods::FolderConnectionHas::getEdgesWithParams) { return { _pimpl->getEdges(std::move(params)) }; } - else if constexpr (methods::FolderConnectionMethod::NoParamsEdges) + else if constexpr (methods::FolderConnectionHas::getEdges) { return { _pimpl->getEdges() }; } @@ -1812,7 +1904,7 @@ class FolderConnection void beginSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::FolderConnectionMethod::HasBeginSelectionSet) + if constexpr (methods::FolderConnectionHas::beginSelectionSet) { _pimpl->beginSelectionSet(params); } @@ -1820,7 +1912,7 @@ class FolderConnection void endSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::FolderConnectionMethod::HasEndSelectionSet) + if constexpr (methods::FolderConnectionHas::endSelectionSet) { _pimpl->endSelectionSet(params); } @@ -1830,7 +1922,10 @@ class FolderConnection const std::shared_ptr _pimpl; }; - FolderConnection(std::unique_ptr&& pimpl); + FolderConnection(std::unique_ptr&& pimpl) noexcept; + + service::TypeNames getTypeNames() const noexcept; + service::ResolverMap getResolvers() const noexcept; void beginSelectionSet(const service::SelectionSetParams& params) const final; void endSelectionSet(const service::SelectionSetParams& params) const final; @@ -1839,7 +1934,7 @@ class FolderConnection public: template - FolderConnection(std::shared_ptr pimpl) + FolderConnection(std::shared_ptr pimpl) noexcept : FolderConnection { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } @@ -1849,10 +1944,10 @@ class CompleteTaskPayload : public service::Object { private: - service::AwaitableResolver resolveTask(service::ResolverParams&& params); - service::AwaitableResolver resolveClientMutationId(service::ResolverParams&& params); + service::AwaitableResolver resolveTask(service::ResolverParams&& params) const; + service::AwaitableResolver resolveClientMutationId(service::ResolverParams&& params) const; - service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; struct Concept { @@ -1876,11 +1971,11 @@ class CompleteTaskPayload service::FieldResult> getTask(service::FieldParams&& params) const final { - if constexpr (methods::CompleteTaskPayloadMethod::WithParamsTask) + if constexpr (methods::CompleteTaskPayloadHas::getTaskWithParams) { return { _pimpl->getTask(std::move(params)) }; } - else if constexpr (methods::CompleteTaskPayloadMethod::NoParamsTask) + else if constexpr (methods::CompleteTaskPayloadHas::getTask) { return { _pimpl->getTask() }; } @@ -1892,11 +1987,11 @@ class CompleteTaskPayload service::FieldResult> getClientMutationId(service::FieldParams&& params) const final { - if constexpr (methods::CompleteTaskPayloadMethod::WithParamsClientMutationId) + if constexpr (methods::CompleteTaskPayloadHas::getClientMutationIdWithParams) { return { _pimpl->getClientMutationId(std::move(params)) }; } - else if constexpr (methods::CompleteTaskPayloadMethod::NoParamsClientMutationId) + else if constexpr (methods::CompleteTaskPayloadHas::getClientMutationId) { return { _pimpl->getClientMutationId() }; } @@ -1908,7 +2003,7 @@ class CompleteTaskPayload void beginSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::CompleteTaskPayloadMethod::HasBeginSelectionSet) + if constexpr (methods::CompleteTaskPayloadHas::beginSelectionSet) { _pimpl->beginSelectionSet(params); } @@ -1916,7 +2011,7 @@ class CompleteTaskPayload void endSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::CompleteTaskPayloadMethod::HasEndSelectionSet) + if constexpr (methods::CompleteTaskPayloadHas::endSelectionSet) { _pimpl->endSelectionSet(params); } @@ -1926,7 +2021,10 @@ class CompleteTaskPayload const std::shared_ptr _pimpl; }; - CompleteTaskPayload(std::unique_ptr&& pimpl); + CompleteTaskPayload(std::unique_ptr&& pimpl) noexcept; + + service::TypeNames getTypeNames() const noexcept; + service::ResolverMap getResolvers() const noexcept; void beginSelectionSet(const service::SelectionSetParams& params) const final; void endSelectionSet(const service::SelectionSetParams& params) const final; @@ -1935,7 +2033,7 @@ class CompleteTaskPayload public: template - CompleteTaskPayload(std::shared_ptr pimpl) + CompleteTaskPayload(std::shared_ptr pimpl) noexcept : CompleteTaskPayload { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } @@ -1945,10 +2043,10 @@ class Mutation : public service::Object { private: - service::AwaitableResolver resolveCompleteTask(service::ResolverParams&& params); - service::AwaitableResolver resolveSetFloat(service::ResolverParams&& params); + service::AwaitableResolver resolveCompleteTask(service::ResolverParams&& params) const; + service::AwaitableResolver resolveSetFloat(service::ResolverParams&& params) const; - service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; struct Concept { @@ -1972,11 +2070,11 @@ class Mutation service::FieldResult> applyCompleteTask(service::FieldParams&& params, CompleteTaskInput&& inputArg) const final { - if constexpr (methods::MutationMethod::WithParamsCompleteTask) + if constexpr (methods::MutationHas::applyCompleteTaskWithParams) { return { _pimpl->applyCompleteTask(std::move(params), std::move(inputArg)) }; } - else if constexpr (methods::MutationMethod::NoParamsCompleteTask) + else if constexpr (methods::MutationHas::applyCompleteTask) { return { _pimpl->applyCompleteTask(std::move(inputArg)) }; } @@ -1988,11 +2086,11 @@ class Mutation service::FieldResult applySetFloat(service::FieldParams&& params, double&& valueArg) const final { - if constexpr (methods::MutationMethod::WithParamsSetFloat) + if constexpr (methods::MutationHas::applySetFloatWithParams) { return { _pimpl->applySetFloat(std::move(params), std::move(valueArg)) }; } - else if constexpr (methods::MutationMethod::NoParamsSetFloat) + else if constexpr (methods::MutationHas::applySetFloat) { return { _pimpl->applySetFloat(std::move(valueArg)) }; } @@ -2004,7 +2102,7 @@ class Mutation void beginSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::MutationMethod::HasBeginSelectionSet) + if constexpr (methods::MutationHas::beginSelectionSet) { _pimpl->beginSelectionSet(params); } @@ -2012,7 +2110,7 @@ class Mutation void endSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::MutationMethod::HasEndSelectionSet) + if constexpr (methods::MutationHas::endSelectionSet) { _pimpl->endSelectionSet(params); } @@ -2022,7 +2120,10 @@ class Mutation const std::shared_ptr _pimpl; }; - Mutation(std::unique_ptr&& pimpl); + Mutation(std::unique_ptr&& pimpl) noexcept; + + service::TypeNames getTypeNames() const noexcept; + service::ResolverMap getResolvers() const noexcept; void beginSelectionSet(const service::SelectionSetParams& params) const final; void endSelectionSet(const service::SelectionSetParams& params) const final; @@ -2031,7 +2132,7 @@ class Mutation public: template - Mutation(std::shared_ptr pimpl) + Mutation(std::shared_ptr pimpl) noexcept : Mutation { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } @@ -2041,10 +2142,10 @@ class Subscription : public service::Object { private: - service::AwaitableResolver resolveNextAppointmentChange(service::ResolverParams&& params); - service::AwaitableResolver resolveNodeChange(service::ResolverParams&& params); + service::AwaitableResolver resolveNextAppointmentChange(service::ResolverParams&& params) const; + service::AwaitableResolver resolveNodeChange(service::ResolverParams&& params) const; - service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; struct Concept { @@ -2054,7 +2155,7 @@ class Subscription virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; virtual service::FieldResult> getNextAppointmentChange(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getNodeChange(service::FieldParams&& params, response::IdType&& idArg) const = 0; + virtual service::FieldResult> getNodeChange(service::FieldParams&& params, response::IdType&& idArg) const = 0; }; template @@ -2068,11 +2169,11 @@ class Subscription service::FieldResult> getNextAppointmentChange(service::FieldParams&& params) const final { - if constexpr (methods::SubscriptionMethod::WithParamsNextAppointmentChange) + if constexpr (methods::SubscriptionHas::getNextAppointmentChangeWithParams) { return { _pimpl->getNextAppointmentChange(std::move(params)) }; } - else if constexpr (methods::SubscriptionMethod::NoParamsNextAppointmentChange) + else if constexpr (methods::SubscriptionHas::getNextAppointmentChange) { return { _pimpl->getNextAppointmentChange() }; } @@ -2082,13 +2183,13 @@ class Subscription } } - service::FieldResult> getNodeChange(service::FieldParams&& params, response::IdType&& idArg) const final + service::FieldResult> getNodeChange(service::FieldParams&& params, response::IdType&& idArg) const final { - if constexpr (methods::SubscriptionMethod::WithParamsNodeChange) + if constexpr (methods::SubscriptionHas::getNodeChangeWithParams) { return { _pimpl->getNodeChange(std::move(params), std::move(idArg)) }; } - else if constexpr (methods::SubscriptionMethod::NoParamsNodeChange) + else if constexpr (methods::SubscriptionHas::getNodeChange) { return { _pimpl->getNodeChange(std::move(idArg)) }; } @@ -2100,7 +2201,7 @@ class Subscription void beginSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::SubscriptionMethod::HasBeginSelectionSet) + if constexpr (methods::SubscriptionHas::beginSelectionSet) { _pimpl->beginSelectionSet(params); } @@ -2108,7 +2209,7 @@ class Subscription void endSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::SubscriptionMethod::HasEndSelectionSet) + if constexpr (methods::SubscriptionHas::endSelectionSet) { _pimpl->endSelectionSet(params); } @@ -2118,7 +2219,10 @@ class Subscription const std::shared_ptr _pimpl; }; - Subscription(std::unique_ptr&& pimpl); + Subscription(std::unique_ptr&& pimpl) noexcept; + + service::TypeNames getTypeNames() const noexcept; + service::ResolverMap getResolvers() const noexcept; void beginSelectionSet(const service::SelectionSetParams& params) const final; void endSelectionSet(const service::SelectionSetParams& params) const final; @@ -2127,7 +2231,7 @@ class Subscription public: template - Subscription(std::shared_ptr pimpl) + Subscription(std::shared_ptr pimpl) noexcept : Subscription { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } @@ -2137,22 +2241,22 @@ class Appointment : public service::Object { private: - service::AwaitableResolver resolveId(service::ResolverParams&& params); - service::AwaitableResolver resolveWhen(service::ResolverParams&& params); - service::AwaitableResolver resolveSubject(service::ResolverParams&& params); - service::AwaitableResolver resolveIsNow(service::ResolverParams&& params); - service::AwaitableResolver resolveForceError(service::ResolverParams&& params); + service::AwaitableResolver resolveId(service::ResolverParams&& params) const; + service::AwaitableResolver resolveWhen(service::ResolverParams&& params) const; + service::AwaitableResolver resolveSubject(service::ResolverParams&& params) const; + service::AwaitableResolver resolveIsNow(service::ResolverParams&& params) const; + service::AwaitableResolver resolveForceError(service::ResolverParams&& params) const; - service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; struct Concept - : Node { virtual ~Concept() = default; virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual service::FieldResult getId(service::FieldParams&& params) const = 0; virtual service::FieldResult> getWhen(service::FieldParams&& params) const = 0; virtual service::FieldResult> getSubject(service::FieldParams&& params) const = 0; virtual service::FieldResult getIsNow(service::FieldParams&& params) const = 0; @@ -2170,11 +2274,11 @@ class Appointment service::FieldResult getId(service::FieldParams&& params) const final { - if constexpr (methods::AppointmentMethod::WithParamsId) + if constexpr (methods::AppointmentHas::getIdWithParams) { return { _pimpl->getId(std::move(params)) }; } - else if constexpr (methods::AppointmentMethod::NoParamsId) + else if constexpr (methods::AppointmentHas::getId) { return { _pimpl->getId() }; } @@ -2186,11 +2290,11 @@ class Appointment service::FieldResult> getWhen(service::FieldParams&& params) const final { - if constexpr (methods::AppointmentMethod::WithParamsWhen) + if constexpr (methods::AppointmentHas::getWhenWithParams) { return { _pimpl->getWhen(std::move(params)) }; } - else if constexpr (methods::AppointmentMethod::NoParamsWhen) + else if constexpr (methods::AppointmentHas::getWhen) { return { _pimpl->getWhen() }; } @@ -2202,11 +2306,11 @@ class Appointment service::FieldResult> getSubject(service::FieldParams&& params) const final { - if constexpr (methods::AppointmentMethod::WithParamsSubject) + if constexpr (methods::AppointmentHas::getSubjectWithParams) { return { _pimpl->getSubject(std::move(params)) }; } - else if constexpr (methods::AppointmentMethod::NoParamsSubject) + else if constexpr (methods::AppointmentHas::getSubject) { return { _pimpl->getSubject() }; } @@ -2218,11 +2322,11 @@ class Appointment service::FieldResult getIsNow(service::FieldParams&& params) const final { - if constexpr (methods::AppointmentMethod::WithParamsIsNow) + if constexpr (methods::AppointmentHas::getIsNowWithParams) { return { _pimpl->getIsNow(std::move(params)) }; } - else if constexpr (methods::AppointmentMethod::NoParamsIsNow) + else if constexpr (methods::AppointmentHas::getIsNow) { return { _pimpl->getIsNow() }; } @@ -2234,11 +2338,11 @@ class Appointment service::FieldResult> getForceError(service::FieldParams&& params) const final { - if constexpr (methods::AppointmentMethod::WithParamsForceError) + if constexpr (methods::AppointmentHas::getForceErrorWithParams) { return { _pimpl->getForceError(std::move(params)) }; } - else if constexpr (methods::AppointmentMethod::NoParamsForceError) + else if constexpr (methods::AppointmentHas::getForceError) { return { _pimpl->getForceError() }; } @@ -2250,7 +2354,7 @@ class Appointment void beginSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::AppointmentMethod::HasBeginSelectionSet) + if constexpr (methods::AppointmentHas::beginSelectionSet) { _pimpl->beginSelectionSet(params); } @@ -2258,7 +2362,7 @@ class Appointment void endSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::AppointmentMethod::HasEndSelectionSet) + if constexpr (methods::AppointmentHas::endSelectionSet) { _pimpl->endSelectionSet(params); } @@ -2268,7 +2372,19 @@ class Appointment const std::shared_ptr _pimpl; }; - Appointment(std::unique_ptr&& pimpl); + Appointment(std::unique_ptr&& pimpl) noexcept; + + // Interface objects need access to these methods + friend Node; + + template + static constexpr bool implements() noexcept + { + return implements::AppointmentIs; + } + + service::TypeNames getTypeNames() const noexcept; + service::ResolverMap getResolvers() const noexcept; void beginSelectionSet(const service::SelectionSetParams& params) const final; void endSelectionSet(const service::SelectionSetParams& params) const final; @@ -2277,7 +2393,7 @@ class Appointment public: template - Appointment(std::shared_ptr pimpl) + Appointment(std::shared_ptr pimpl) noexcept : Appointment { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } @@ -2287,20 +2403,20 @@ class Task : public service::Object { private: - service::AwaitableResolver resolveId(service::ResolverParams&& params); - service::AwaitableResolver resolveTitle(service::ResolverParams&& params); - service::AwaitableResolver resolveIsComplete(service::ResolverParams&& params); + service::AwaitableResolver resolveId(service::ResolverParams&& params) const; + service::AwaitableResolver resolveTitle(service::ResolverParams&& params) const; + service::AwaitableResolver resolveIsComplete(service::ResolverParams&& params) const; - service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; struct Concept - : Node { virtual ~Concept() = default; virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual service::FieldResult getId(service::FieldParams&& params) const = 0; virtual service::FieldResult> getTitle(service::FieldParams&& params) const = 0; virtual service::FieldResult getIsComplete(service::FieldParams&& params) const = 0; }; @@ -2316,11 +2432,11 @@ class Task service::FieldResult getId(service::FieldParams&& params) const final { - if constexpr (methods::TaskMethod::WithParamsId) + if constexpr (methods::TaskHas::getIdWithParams) { return { _pimpl->getId(std::move(params)) }; } - else if constexpr (methods::TaskMethod::NoParamsId) + else if constexpr (methods::TaskHas::getId) { return { _pimpl->getId() }; } @@ -2332,11 +2448,11 @@ class Task service::FieldResult> getTitle(service::FieldParams&& params) const final { - if constexpr (methods::TaskMethod::WithParamsTitle) + if constexpr (methods::TaskHas::getTitleWithParams) { return { _pimpl->getTitle(std::move(params)) }; } - else if constexpr (methods::TaskMethod::NoParamsTitle) + else if constexpr (methods::TaskHas::getTitle) { return { _pimpl->getTitle() }; } @@ -2348,11 +2464,11 @@ class Task service::FieldResult getIsComplete(service::FieldParams&& params) const final { - if constexpr (methods::TaskMethod::WithParamsIsComplete) + if constexpr (methods::TaskHas::getIsCompleteWithParams) { return { _pimpl->getIsComplete(std::move(params)) }; } - else if constexpr (methods::TaskMethod::NoParamsIsComplete) + else if constexpr (methods::TaskHas::getIsComplete) { return { _pimpl->getIsComplete() }; } @@ -2364,7 +2480,7 @@ class Task void beginSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::TaskMethod::HasBeginSelectionSet) + if constexpr (methods::TaskHas::beginSelectionSet) { _pimpl->beginSelectionSet(params); } @@ -2372,7 +2488,7 @@ class Task void endSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::TaskMethod::HasEndSelectionSet) + if constexpr (methods::TaskHas::endSelectionSet) { _pimpl->endSelectionSet(params); } @@ -2382,7 +2498,19 @@ class Task const std::shared_ptr _pimpl; }; - Task(std::unique_ptr&& pimpl); + Task(std::unique_ptr&& pimpl) noexcept; + + // Interface objects need access to these methods + friend Node; + + template + static constexpr bool implements() noexcept + { + return implements::TaskIs; + } + + service::TypeNames getTypeNames() const noexcept; + service::ResolverMap getResolvers() const noexcept; void beginSelectionSet(const service::SelectionSetParams& params) const final; void endSelectionSet(const service::SelectionSetParams& params) const final; @@ -2391,7 +2519,7 @@ class Task public: template - Task(std::shared_ptr pimpl) + Task(std::shared_ptr pimpl) noexcept : Task { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } @@ -2401,20 +2529,20 @@ class Folder : public service::Object { private: - service::AwaitableResolver resolveId(service::ResolverParams&& params); - service::AwaitableResolver resolveName(service::ResolverParams&& params); - service::AwaitableResolver resolveUnreadCount(service::ResolverParams&& params); + service::AwaitableResolver resolveId(service::ResolverParams&& params) const; + service::AwaitableResolver resolveName(service::ResolverParams&& params) const; + service::AwaitableResolver resolveUnreadCount(service::ResolverParams&& params) const; - service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; struct Concept - : Node { virtual ~Concept() = default; virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual service::FieldResult getId(service::FieldParams&& params) const = 0; virtual service::FieldResult> getName(service::FieldParams&& params) const = 0; virtual service::FieldResult getUnreadCount(service::FieldParams&& params) const = 0; }; @@ -2430,11 +2558,11 @@ class Folder service::FieldResult getId(service::FieldParams&& params) const final { - if constexpr (methods::FolderMethod::WithParamsId) + if constexpr (methods::FolderHas::getIdWithParams) { return { _pimpl->getId(std::move(params)) }; } - else if constexpr (methods::FolderMethod::NoParamsId) + else if constexpr (methods::FolderHas::getId) { return { _pimpl->getId() }; } @@ -2446,11 +2574,11 @@ class Folder service::FieldResult> getName(service::FieldParams&& params) const final { - if constexpr (methods::FolderMethod::WithParamsName) + if constexpr (methods::FolderHas::getNameWithParams) { return { _pimpl->getName(std::move(params)) }; } - else if constexpr (methods::FolderMethod::NoParamsName) + else if constexpr (methods::FolderHas::getName) { return { _pimpl->getName() }; } @@ -2462,11 +2590,11 @@ class Folder service::FieldResult getUnreadCount(service::FieldParams&& params) const final { - if constexpr (methods::FolderMethod::WithParamsUnreadCount) + if constexpr (methods::FolderHas::getUnreadCountWithParams) { return { _pimpl->getUnreadCount(std::move(params)) }; } - else if constexpr (methods::FolderMethod::NoParamsUnreadCount) + else if constexpr (methods::FolderHas::getUnreadCount) { return { _pimpl->getUnreadCount() }; } @@ -2478,7 +2606,7 @@ class Folder void beginSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::FolderMethod::HasBeginSelectionSet) + if constexpr (methods::FolderHas::beginSelectionSet) { _pimpl->beginSelectionSet(params); } @@ -2486,7 +2614,7 @@ class Folder void endSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::FolderMethod::HasEndSelectionSet) + if constexpr (methods::FolderHas::endSelectionSet) { _pimpl->endSelectionSet(params); } @@ -2496,7 +2624,19 @@ class Folder const std::shared_ptr _pimpl; }; - Folder(std::unique_ptr&& pimpl); + Folder(std::unique_ptr&& pimpl) noexcept; + + // Interface objects need access to these methods + friend Node; + + template + static constexpr bool implements() noexcept + { + return implements::FolderIs; + } + + service::TypeNames getTypeNames() const noexcept; + service::ResolverMap getResolvers() const noexcept; void beginSelectionSet(const service::SelectionSetParams& params) const final; void endSelectionSet(const service::SelectionSetParams& params) const final; @@ -2505,7 +2645,7 @@ class Folder public: template - Folder(std::shared_ptr pimpl) + Folder(std::shared_ptr pimpl) noexcept : Folder { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } @@ -2515,10 +2655,10 @@ class NestedType : public service::Object { private: - service::AwaitableResolver resolveDepth(service::ResolverParams&& params); - service::AwaitableResolver resolveNested(service::ResolverParams&& params); + service::AwaitableResolver resolveDepth(service::ResolverParams&& params) const; + service::AwaitableResolver resolveNested(service::ResolverParams&& params) const; - service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; struct Concept { @@ -2542,11 +2682,11 @@ class NestedType service::FieldResult getDepth(service::FieldParams&& params) const final { - if constexpr (methods::NestedTypeMethod::WithParamsDepth) + if constexpr (methods::NestedTypeHas::getDepthWithParams) { return { _pimpl->getDepth(std::move(params)) }; } - else if constexpr (methods::NestedTypeMethod::NoParamsDepth) + else if constexpr (methods::NestedTypeHas::getDepth) { return { _pimpl->getDepth() }; } @@ -2558,11 +2698,11 @@ class NestedType service::FieldResult> getNested(service::FieldParams&& params) const final { - if constexpr (methods::NestedTypeMethod::WithParamsNested) + if constexpr (methods::NestedTypeHas::getNestedWithParams) { return { _pimpl->getNested(std::move(params)) }; } - else if constexpr (methods::NestedTypeMethod::NoParamsNested) + else if constexpr (methods::NestedTypeHas::getNested) { return { _pimpl->getNested() }; } @@ -2574,7 +2714,7 @@ class NestedType void beginSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::NestedTypeMethod::HasBeginSelectionSet) + if constexpr (methods::NestedTypeHas::beginSelectionSet) { _pimpl->beginSelectionSet(params); } @@ -2582,7 +2722,7 @@ class NestedType void endSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::NestedTypeMethod::HasEndSelectionSet) + if constexpr (methods::NestedTypeHas::endSelectionSet) { _pimpl->endSelectionSet(params); } @@ -2592,7 +2732,10 @@ class NestedType const std::shared_ptr _pimpl; }; - NestedType(std::unique_ptr&& pimpl); + NestedType(std::unique_ptr&& pimpl) noexcept; + + service::TypeNames getTypeNames() const noexcept; + service::ResolverMap getResolvers() const noexcept; void beginSelectionSet(const service::SelectionSetParams& params) const final; void endSelectionSet(const service::SelectionSetParams& params) const final; @@ -2601,7 +2744,7 @@ class NestedType public: template - NestedType(std::shared_ptr pimpl) + NestedType(std::shared_ptr pimpl) noexcept : NestedType { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } @@ -2611,9 +2754,9 @@ class Expensive : public service::Object { private: - service::AwaitableResolver resolveOrder(service::ResolverParams&& params); + service::AwaitableResolver resolveOrder(service::ResolverParams&& params) const; - service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; struct Concept { @@ -2636,11 +2779,11 @@ class Expensive service::FieldResult getOrder(service::FieldParams&& params) const final { - if constexpr (methods::ExpensiveMethod::WithParamsOrder) + if constexpr (methods::ExpensiveHas::getOrderWithParams) { return { _pimpl->getOrder(std::move(params)) }; } - else if constexpr (methods::ExpensiveMethod::NoParamsOrder) + else if constexpr (methods::ExpensiveHas::getOrder) { return { _pimpl->getOrder() }; } @@ -2652,7 +2795,7 @@ class Expensive void beginSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::ExpensiveMethod::HasBeginSelectionSet) + if constexpr (methods::ExpensiveHas::beginSelectionSet) { _pimpl->beginSelectionSet(params); } @@ -2660,7 +2803,7 @@ class Expensive void endSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::ExpensiveMethod::HasEndSelectionSet) + if constexpr (methods::ExpensiveHas::endSelectionSet) { _pimpl->endSelectionSet(params); } @@ -2670,7 +2813,10 @@ class Expensive const std::shared_ptr _pimpl; }; - Expensive(std::unique_ptr&& pimpl); + Expensive(std::unique_ptr&& pimpl) noexcept; + + service::TypeNames getTypeNames() const noexcept; + service::ResolverMap getResolvers() const noexcept; void beginSelectionSet(const service::SelectionSetParams& params) const final; void endSelectionSet(const service::SelectionSetParams& params) const final; @@ -2679,7 +2825,7 @@ class Expensive public: template - Expensive(std::shared_ptr pimpl) + Expensive(std::shared_ptr pimpl) noexcept : Expensive { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } diff --git a/samples/validation/schema/ValidationSchema.cpp b/samples/validation/schema/ValidationSchema.cpp index 4cabc028..40a76761 100644 --- a/samples/validation/schema/ValidationSchema.cpp +++ b/samples/validation/schema/ValidationSchema.cpp @@ -112,10 +112,54 @@ validation::ComplexInput ModifiedArgument::convert(con namespace validation { namespace object { -Query::Query(std::unique_ptr&& pimpl) - : service::Object({ +Sentient::Sentient(std::unique_ptr&& pimpl) noexcept + : service::Object { pimpl->getTypeNames(), pimpl->getResolvers() } + , _pimpl { std::move(pimpl) } +{ +} + +void Sentient::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void Sentient::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} + +Pet::Pet(std::unique_ptr&& pimpl) noexcept + : service::Object { pimpl->getTypeNames(), pimpl->getResolvers() } + , _pimpl { std::move(pimpl) } +{ +} + +void Pet::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void Pet::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} + +Query::Query(std::unique_ptr&& pimpl) noexcept + : service::Object{ getTypeNames(), getResolvers() } + , _pimpl { std::move(pimpl) } +{ +} + +service::TypeNames Query::getTypeNames() const noexcept +{ + return { "Query" - }, { + }; +} + +service::ResolverMap Query::getResolvers() const noexcept +{ + return { { R"gql(dog)gql"sv, [this](service::ResolverParams&& params) { return resolveDog(std::move(params)); } }, { R"gql(pet)gql"sv, [this](service::ResolverParams&& params) { return resolvePet(std::move(params)); } }, { R"gql(human)gql"sv, [this](service::ResolverParams&& params) { return resolveHuman(std::move(params)); } }, @@ -124,9 +168,7 @@ Query::Query(std::unique_ptr&& pimpl) { R"gql(arguments)gql"sv, [this](service::ResolverParams&& params) { return resolveArguments(std::move(params)); } }, { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, { R"gql(booleanList)gql"sv, [this](service::ResolverParams&& params) { return resolveBooleanList(std::move(params)); } } - }) - , _pimpl(std::move(pimpl)) -{ + }; } void Query::beginSelectionSet(const service::SelectionSetParams& params) const @@ -139,7 +181,7 @@ void Query::endSelectionSet(const service::SelectionSetParams& params) const _pimpl->endSelectionSet(params); } -service::AwaitableResolver Query::resolveDog(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveDog(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -149,7 +191,7 @@ service::AwaitableResolver Query::resolveDog(service::ResolverParams&& params) return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Query::resolveHuman(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveHuman(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -159,17 +201,17 @@ service::AwaitableResolver Query::resolveHuman(service::ResolverParams&& params) return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Query::resolvePet(service::ResolverParams&& params) +service::AwaitableResolver Query::resolvePet(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); auto result = _pimpl->getPet(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Query::resolveCatOrDog(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveCatOrDog(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -179,7 +221,7 @@ service::AwaitableResolver Query::resolveCatOrDog(service::ResolverParams&& para return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Query::resolveArguments(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveArguments(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -189,7 +231,7 @@ service::AwaitableResolver Query::resolveArguments(service::ResolverParams&& par return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Query::resolveFindDog(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveFindDog(service::ResolverParams&& params) const { auto argComplex = service::ModifiedArgument::require("complex", params.arguments); std::unique_lock resolverLock(_resolverMutex); @@ -200,7 +242,7 @@ service::AwaitableResolver Query::resolveFindDog(service::ResolverParams&& param return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Query::resolveBooleanList(service::ResolverParams&& params) +service::AwaitableResolver Query::resolveBooleanList(service::ResolverParams&& params) const { auto argBooleanListArg = service::ModifiedArgument::require("booleanListArg", params.arguments); std::unique_lock resolverLock(_resolverMutex); @@ -211,18 +253,30 @@ service::AwaitableResolver Query::resolveBooleanList(service::ResolverParams&& p return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Query::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver Query::resolve_typename(service::ResolverParams&& params) const { return service::ModifiedResult::convert(std::string{ R"gql(Query)gql" }, std::move(params)); } -Dog::Dog(std::unique_ptr&& pimpl) - : service::Object({ +Dog::Dog(std::unique_ptr&& pimpl) noexcept + : service::Object{ getTypeNames(), getResolvers() } + , _pimpl { std::move(pimpl) } +{ +} + +service::TypeNames Dog::getTypeNames() const noexcept +{ + return { "Pet", "CatOrDog", "DogOrHuman", "Dog" - }, { + }; +} + +service::ResolverMap Dog::getResolvers() const noexcept +{ + return { { R"gql(name)gql"sv, [this](service::ResolverParams&& params) { return resolveName(std::move(params)); } }, { R"gql(owner)gql"sv, [this](service::ResolverParams&& params) { return resolveOwner(std::move(params)); } }, { R"gql(nickname)gql"sv, [this](service::ResolverParams&& params) { return resolveNickname(std::move(params)); } }, @@ -230,9 +284,7 @@ Dog::Dog(std::unique_ptr&& pimpl) { R"gql(barkVolume)gql"sv, [this](service::ResolverParams&& params) { return resolveBarkVolume(std::move(params)); } }, { R"gql(isHousetrained)gql"sv, [this](service::ResolverParams&& params) { return resolveIsHousetrained(std::move(params)); } }, { R"gql(doesKnowCommand)gql"sv, [this](service::ResolverParams&& params) { return resolveDoesKnowCommand(std::move(params)); } } - }) - , _pimpl(std::move(pimpl)) -{ + }; } void Dog::beginSelectionSet(const service::SelectionSetParams& params) const @@ -245,7 +297,7 @@ void Dog::endSelectionSet(const service::SelectionSetParams& params) const _pimpl->endSelectionSet(params); } -service::AwaitableResolver Dog::resolveName(service::ResolverParams&& params) +service::AwaitableResolver Dog::resolveName(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -255,7 +307,7 @@ service::AwaitableResolver Dog::resolveName(service::ResolverParams&& params) return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Dog::resolveNickname(service::ResolverParams&& params) +service::AwaitableResolver Dog::resolveNickname(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -265,7 +317,7 @@ service::AwaitableResolver Dog::resolveNickname(service::ResolverParams&& params return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Dog::resolveBarkVolume(service::ResolverParams&& params) +service::AwaitableResolver Dog::resolveBarkVolume(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -275,7 +327,7 @@ service::AwaitableResolver Dog::resolveBarkVolume(service::ResolverParams&& para return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Dog::resolveDoesKnowCommand(service::ResolverParams&& params) +service::AwaitableResolver Dog::resolveDoesKnowCommand(service::ResolverParams&& params) const { auto argDogCommand = service::ModifiedArgument::require("dogCommand", params.arguments); std::unique_lock resolverLock(_resolverMutex); @@ -286,7 +338,7 @@ service::AwaitableResolver Dog::resolveDoesKnowCommand(service::ResolverParams&& return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Dog::resolveIsHousetrained(service::ResolverParams&& params) +service::AwaitableResolver Dog::resolveIsHousetrained(service::ResolverParams&& params) const { auto argAtOtherHomes = service::ModifiedArgument::require("atOtherHomes", params.arguments); std::unique_lock resolverLock(_resolverMutex); @@ -297,7 +349,7 @@ service::AwaitableResolver Dog::resolveIsHousetrained(service::ResolverParams&& return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Dog::resolveOwner(service::ResolverParams&& params) +service::AwaitableResolver Dog::resolveOwner(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -307,23 +359,33 @@ service::AwaitableResolver Dog::resolveOwner(service::ResolverParams&& params) return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Dog::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver Dog::resolve_typename(service::ResolverParams&& params) const { return service::ModifiedResult::convert(std::string{ R"gql(Dog)gql" }, std::move(params)); } -Alien::Alien(std::unique_ptr&& pimpl) - : service::Object({ +Alien::Alien(std::unique_ptr&& pimpl) noexcept + : service::Object{ getTypeNames(), getResolvers() } + , _pimpl { std::move(pimpl) } +{ +} + +service::TypeNames Alien::getTypeNames() const noexcept +{ + return { "Sentient", "HumanOrAlien", "Alien" - }, { + }; +} + +service::ResolverMap Alien::getResolvers() const noexcept +{ + return { { R"gql(name)gql"sv, [this](service::ResolverParams&& params) { return resolveName(std::move(params)); } }, { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, { R"gql(homePlanet)gql"sv, [this](service::ResolverParams&& params) { return resolveHomePlanet(std::move(params)); } } - }) - , _pimpl(std::move(pimpl)) -{ + }; } void Alien::beginSelectionSet(const service::SelectionSetParams& params) const @@ -336,7 +398,7 @@ void Alien::endSelectionSet(const service::SelectionSetParams& params) const _pimpl->endSelectionSet(params); } -service::AwaitableResolver Alien::resolveName(service::ResolverParams&& params) +service::AwaitableResolver Alien::resolveName(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -346,7 +408,7 @@ service::AwaitableResolver Alien::resolveName(service::ResolverParams&& params) return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Alien::resolveHomePlanet(service::ResolverParams&& params) +service::AwaitableResolver Alien::resolveHomePlanet(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -356,24 +418,34 @@ service::AwaitableResolver Alien::resolveHomePlanet(service::ResolverParams&& pa return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Alien::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver Alien::resolve_typename(service::ResolverParams&& params) const { return service::ModifiedResult::convert(std::string{ R"gql(Alien)gql" }, std::move(params)); } -Human::Human(std::unique_ptr&& pimpl) - : service::Object({ +Human::Human(std::unique_ptr&& pimpl) noexcept + : service::Object{ getTypeNames(), getResolvers() } + , _pimpl { std::move(pimpl) } +{ +} + +service::TypeNames Human::getTypeNames() const noexcept +{ + return { "Sentient", "DogOrHuman", "HumanOrAlien", "Human" - }, { + }; +} + +service::ResolverMap Human::getResolvers() const noexcept +{ + return { { R"gql(name)gql"sv, [this](service::ResolverParams&& params) { return resolveName(std::move(params)); } }, { R"gql(pets)gql"sv, [this](service::ResolverParams&& params) { return resolvePets(std::move(params)); } }, { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } } - }) - , _pimpl(std::move(pimpl)) -{ + }; } void Human::beginSelectionSet(const service::SelectionSetParams& params) const @@ -386,7 +458,7 @@ void Human::endSelectionSet(const service::SelectionSetParams& params) const _pimpl->endSelectionSet(params); } -service::AwaitableResolver Human::resolveName(service::ResolverParams&& params) +service::AwaitableResolver Human::resolveName(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -396,35 +468,45 @@ service::AwaitableResolver Human::resolveName(service::ResolverParams&& params) return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Human::resolvePets(service::ResolverParams&& params) +service::AwaitableResolver Human::resolvePets(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); auto result = _pimpl->getPets(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Human::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver Human::resolve_typename(service::ResolverParams&& params) const { return service::ModifiedResult::convert(std::string{ R"gql(Human)gql" }, std::move(params)); } -Cat::Cat(std::unique_ptr&& pimpl) - : service::Object({ +Cat::Cat(std::unique_ptr&& pimpl) noexcept + : service::Object{ getTypeNames(), getResolvers() } + , _pimpl { std::move(pimpl) } +{ +} + +service::TypeNames Cat::getTypeNames() const noexcept +{ + return { "Pet", "CatOrDog", "Cat" - }, { + }; +} + +service::ResolverMap Cat::getResolvers() const noexcept +{ + return { { R"gql(name)gql"sv, [this](service::ResolverParams&& params) { return resolveName(std::move(params)); } }, { R"gql(nickname)gql"sv, [this](service::ResolverParams&& params) { return resolveNickname(std::move(params)); } }, { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, { R"gql(meowVolume)gql"sv, [this](service::ResolverParams&& params) { return resolveMeowVolume(std::move(params)); } }, { R"gql(doesKnowCommand)gql"sv, [this](service::ResolverParams&& params) { return resolveDoesKnowCommand(std::move(params)); } } - }) - , _pimpl(std::move(pimpl)) -{ + }; } void Cat::beginSelectionSet(const service::SelectionSetParams& params) const @@ -437,7 +519,7 @@ void Cat::endSelectionSet(const service::SelectionSetParams& params) const _pimpl->endSelectionSet(params); } -service::AwaitableResolver Cat::resolveName(service::ResolverParams&& params) +service::AwaitableResolver Cat::resolveName(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -447,7 +529,7 @@ service::AwaitableResolver Cat::resolveName(service::ResolverParams&& params) return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Cat::resolveNickname(service::ResolverParams&& params) +service::AwaitableResolver Cat::resolveNickname(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -457,7 +539,7 @@ service::AwaitableResolver Cat::resolveNickname(service::ResolverParams&& params return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Cat::resolveDoesKnowCommand(service::ResolverParams&& params) +service::AwaitableResolver Cat::resolveDoesKnowCommand(service::ResolverParams&& params) const { auto argCatCommand = service::ModifiedArgument::require("catCommand", params.arguments); std::unique_lock resolverLock(_resolverMutex); @@ -468,7 +550,7 @@ service::AwaitableResolver Cat::resolveDoesKnowCommand(service::ResolverParams&& return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Cat::resolveMeowVolume(service::ResolverParams&& params) +service::AwaitableResolver Cat::resolveMeowVolume(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -478,20 +560,30 @@ service::AwaitableResolver Cat::resolveMeowVolume(service::ResolverParams&& para return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Cat::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver Cat::resolve_typename(service::ResolverParams&& params) const { return service::ModifiedResult::convert(std::string{ R"gql(Cat)gql" }, std::move(params)); } -Mutation::Mutation(std::unique_ptr&& pimpl) - : service::Object({ +Mutation::Mutation(std::unique_ptr&& pimpl) noexcept + : service::Object{ getTypeNames(), getResolvers() } + , _pimpl { std::move(pimpl) } +{ +} + +service::TypeNames Mutation::getTypeNames() const noexcept +{ + return { "Mutation" - }, { + }; +} + +service::ResolverMap Mutation::getResolvers() const noexcept +{ + return { { R"gql(mutateDog)gql"sv, [this](service::ResolverParams&& params) { return resolveMutateDog(std::move(params)); } }, { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } } - }) - , _pimpl(std::move(pimpl)) -{ + }; } void Mutation::beginSelectionSet(const service::SelectionSetParams& params) const @@ -504,7 +596,7 @@ void Mutation::endSelectionSet(const service::SelectionSetParams& params) const _pimpl->endSelectionSet(params); } -service::AwaitableResolver Mutation::resolveMutateDog(service::ResolverParams&& params) +service::AwaitableResolver Mutation::resolveMutateDog(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -514,20 +606,30 @@ service::AwaitableResolver Mutation::resolveMutateDog(service::ResolverParams&& return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Mutation::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver Mutation::resolve_typename(service::ResolverParams&& params) const { return service::ModifiedResult::convert(std::string{ R"gql(Mutation)gql" }, std::move(params)); } -MutateDogResult::MutateDogResult(std::unique_ptr&& pimpl) - : service::Object({ +MutateDogResult::MutateDogResult(std::unique_ptr&& pimpl) noexcept + : service::Object{ getTypeNames(), getResolvers() } + , _pimpl { std::move(pimpl) } +{ +} + +service::TypeNames MutateDogResult::getTypeNames() const noexcept +{ + return { "MutateDogResult" - }, { + }; +} + +service::ResolverMap MutateDogResult::getResolvers() const noexcept +{ + return { { R"gql(id)gql"sv, [this](service::ResolverParams&& params) { return resolveId(std::move(params)); } }, { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } } - }) - , _pimpl(std::move(pimpl)) -{ + }; } void MutateDogResult::beginSelectionSet(const service::SelectionSetParams& params) const @@ -540,7 +642,7 @@ void MutateDogResult::endSelectionSet(const service::SelectionSetParams& params) _pimpl->endSelectionSet(params); } -service::AwaitableResolver MutateDogResult::resolveId(service::ResolverParams&& params) +service::AwaitableResolver MutateDogResult::resolveId(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -550,21 +652,31 @@ service::AwaitableResolver MutateDogResult::resolveId(service::ResolverParams&& return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver MutateDogResult::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver MutateDogResult::resolve_typename(service::ResolverParams&& params) const { return service::ModifiedResult::convert(std::string{ R"gql(MutateDogResult)gql" }, std::move(params)); } -Subscription::Subscription(std::unique_ptr&& pimpl) - : service::Object({ +Subscription::Subscription(std::unique_ptr&& pimpl) noexcept + : service::Object{ getTypeNames(), getResolvers() } + , _pimpl { std::move(pimpl) } +{ +} + +service::TypeNames Subscription::getTypeNames() const noexcept +{ + return { "Subscription" - }, { + }; +} + +service::ResolverMap Subscription::getResolvers() const noexcept +{ + return { { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, { R"gql(newMessage)gql"sv, [this](service::ResolverParams&& params) { return resolveNewMessage(std::move(params)); } }, { R"gql(disallowedSecondRootField)gql"sv, [this](service::ResolverParams&& params) { return resolveDisallowedSecondRootField(std::move(params)); } } - }) - , _pimpl(std::move(pimpl)) -{ + }; } void Subscription::beginSelectionSet(const service::SelectionSetParams& params) const @@ -577,7 +689,7 @@ void Subscription::endSelectionSet(const service::SelectionSetParams& params) co _pimpl->endSelectionSet(params); } -service::AwaitableResolver Subscription::resolveNewMessage(service::ResolverParams&& params) +service::AwaitableResolver Subscription::resolveNewMessage(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -587,7 +699,7 @@ service::AwaitableResolver Subscription::resolveNewMessage(service::ResolverPara return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Subscription::resolveDisallowedSecondRootField(service::ResolverParams&& params) +service::AwaitableResolver Subscription::resolveDisallowedSecondRootField(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -597,21 +709,31 @@ service::AwaitableResolver Subscription::resolveDisallowedSecondRootField(servic return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Subscription::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver Subscription::resolve_typename(service::ResolverParams&& params) const { return service::ModifiedResult::convert(std::string{ R"gql(Subscription)gql" }, std::move(params)); } -Message::Message(std::unique_ptr&& pimpl) - : service::Object({ +Message::Message(std::unique_ptr&& pimpl) noexcept + : service::Object{ getTypeNames(), getResolvers() } + , _pimpl { std::move(pimpl) } +{ +} + +service::TypeNames Message::getTypeNames() const noexcept +{ + return { "Message" - }, { + }; +} + +service::ResolverMap Message::getResolvers() const noexcept +{ + return { { R"gql(body)gql"sv, [this](service::ResolverParams&& params) { return resolveBody(std::move(params)); } }, { R"gql(sender)gql"sv, [this](service::ResolverParams&& params) { return resolveSender(std::move(params)); } }, { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } } - }) - , _pimpl(std::move(pimpl)) -{ + }; } void Message::beginSelectionSet(const service::SelectionSetParams& params) const @@ -624,7 +746,7 @@ void Message::endSelectionSet(const service::SelectionSetParams& params) const _pimpl->endSelectionSet(params); } -service::AwaitableResolver Message::resolveBody(service::ResolverParams&& params) +service::AwaitableResolver Message::resolveBody(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -634,7 +756,7 @@ service::AwaitableResolver Message::resolveBody(service::ResolverParams&& params return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Message::resolveSender(service::ResolverParams&& params) +service::AwaitableResolver Message::resolveSender(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -644,15 +766,27 @@ service::AwaitableResolver Message::resolveSender(service::ResolverParams&& para return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Message::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver Message::resolve_typename(service::ResolverParams&& params) const { return service::ModifiedResult::convert(std::string{ R"gql(Message)gql" }, std::move(params)); } -Arguments::Arguments(std::unique_ptr&& pimpl) - : service::Object({ +Arguments::Arguments(std::unique_ptr&& pimpl) noexcept + : service::Object{ getTypeNames(), getResolvers() } + , _pimpl { std::move(pimpl) } +{ +} + +service::TypeNames Arguments::getTypeNames() const noexcept +{ + return { "Arguments" - }, { + }; +} + +service::ResolverMap Arguments::getResolvers() const noexcept +{ + return { { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, { R"gql(intArgField)gql"sv, [this](service::ResolverParams&& params) { return resolveIntArgField(std::move(params)); } }, { R"gql(multipleReqs)gql"sv, [this](service::ResolverParams&& params) { return resolveMultipleReqs(std::move(params)); } }, @@ -662,9 +796,7 @@ Arguments::Arguments(std::unique_ptr&& pimpl) { R"gql(nonNullBooleanArgField)gql"sv, [this](service::ResolverParams&& params) { return resolveNonNullBooleanArgField(std::move(params)); } }, { R"gql(nonNullBooleanListField)gql"sv, [this](service::ResolverParams&& params) { return resolveNonNullBooleanListField(std::move(params)); } }, { R"gql(optionalNonNullBooleanArgField)gql"sv, [this](service::ResolverParams&& params) { return resolveOptionalNonNullBooleanArgField(std::move(params)); } } - }) - , _pimpl(std::move(pimpl)) -{ + }; } void Arguments::beginSelectionSet(const service::SelectionSetParams& params) const @@ -677,7 +809,7 @@ void Arguments::endSelectionSet(const service::SelectionSetParams& params) const _pimpl->endSelectionSet(params); } -service::AwaitableResolver Arguments::resolveMultipleReqs(service::ResolverParams&& params) +service::AwaitableResolver Arguments::resolveMultipleReqs(service::ResolverParams&& params) const { auto argX = service::ModifiedArgument::require("x", params.arguments); auto argY = service::ModifiedArgument::require("y", params.arguments); @@ -689,7 +821,7 @@ service::AwaitableResolver Arguments::resolveMultipleReqs(service::ResolverParam return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Arguments::resolveBooleanArgField(service::ResolverParams&& params) +service::AwaitableResolver Arguments::resolveBooleanArgField(service::ResolverParams&& params) const { auto argBooleanArg = service::ModifiedArgument::require("booleanArg", params.arguments); std::unique_lock resolverLock(_resolverMutex); @@ -700,7 +832,7 @@ service::AwaitableResolver Arguments::resolveBooleanArgField(service::ResolverPa return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Arguments::resolveFloatArgField(service::ResolverParams&& params) +service::AwaitableResolver Arguments::resolveFloatArgField(service::ResolverParams&& params) const { auto argFloatArg = service::ModifiedArgument::require("floatArg", params.arguments); std::unique_lock resolverLock(_resolverMutex); @@ -711,7 +843,7 @@ service::AwaitableResolver Arguments::resolveFloatArgField(service::ResolverPara return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Arguments::resolveIntArgField(service::ResolverParams&& params) +service::AwaitableResolver Arguments::resolveIntArgField(service::ResolverParams&& params) const { auto argIntArg = service::ModifiedArgument::require("intArg", params.arguments); std::unique_lock resolverLock(_resolverMutex); @@ -722,7 +854,7 @@ service::AwaitableResolver Arguments::resolveIntArgField(service::ResolverParams return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Arguments::resolveNonNullBooleanArgField(service::ResolverParams&& params) +service::AwaitableResolver Arguments::resolveNonNullBooleanArgField(service::ResolverParams&& params) const { auto argNonNullBooleanArg = service::ModifiedArgument::require("nonNullBooleanArg", params.arguments); std::unique_lock resolverLock(_resolverMutex); @@ -733,7 +865,7 @@ service::AwaitableResolver Arguments::resolveNonNullBooleanArgField(service::Res return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Arguments::resolveNonNullBooleanListField(service::ResolverParams&& params) +service::AwaitableResolver Arguments::resolveNonNullBooleanListField(service::ResolverParams&& params) const { auto argNonNullBooleanListArg = service::ModifiedArgument::require("nonNullBooleanListArg", params.arguments); std::unique_lock resolverLock(_resolverMutex); @@ -744,7 +876,7 @@ service::AwaitableResolver Arguments::resolveNonNullBooleanListField(service::Re return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Arguments::resolveBooleanListArgField(service::ResolverParams&& params) +service::AwaitableResolver Arguments::resolveBooleanListArgField(service::ResolverParams&& params) const { auto argBooleanListArg = service::ModifiedArgument::require("booleanListArg", params.arguments); std::unique_lock resolverLock(_resolverMutex); @@ -755,7 +887,7 @@ service::AwaitableResolver Arguments::resolveBooleanListArgField(service::Resolv return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Arguments::resolveOptionalNonNullBooleanArgField(service::ResolverParams&& params) +service::AwaitableResolver Arguments::resolveOptionalNonNullBooleanArgField(service::ResolverParams&& params) const { const auto defaultArguments = []() { @@ -780,7 +912,7 @@ service::AwaitableResolver Arguments::resolveOptionalNonNullBooleanArgField(serv return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Arguments::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver Arguments::resolve_typename(service::ResolverParams&& params) const { return service::ModifiedResult::convert(std::string{ R"gql(Arguments)gql" }, std::move(params)); } diff --git a/samples/validation/schema/ValidationSchema.h b/samples/validation/schema/ValidationSchema.h index 2992c596..d35c12fa 100644 --- a/samples/validation/schema/ValidationSchema.h +++ b/samples/validation/schema/ValidationSchema.h @@ -41,6 +41,9 @@ struct ComplexInput namespace object { +class Sentient; +class Pet; + class Query; class Dog; class Alien; @@ -52,617 +55,745 @@ class Subscription; class Message; class Arguments; -} // namespace object +class Sentient + : public service::Object +{ +private: + struct Concept + { + virtual ~Concept() = default; -struct Sentient; -struct Pet; + virtual service::TypeNames getTypeNames() const noexcept = 0; + virtual service::ResolverMap getResolvers() const noexcept = 0; -struct Sentient -{ - virtual service::FieldResult getName(service::FieldParams&& params) const = 0; + virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::TypeNames getTypeNames() const noexcept final + { + return _pimpl->getTypeNames(); + } + + service::ResolverMap getResolvers() const noexcept final + { + return _pimpl->getResolvers(); + } + + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + _pimpl->beginSelectionSet(params); + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + _pimpl->endSelectionSet(params); + } + + private: + const std::shared_ptr _pimpl; + }; + + Sentient(std::unique_ptr&& pimpl) noexcept; + + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; + + const std::unique_ptr _pimpl; + +public: + template + Sentient(std::shared_ptr pimpl) noexcept + : Sentient { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } + { + static_assert(T::template implements(), "Sentient is not implemented"); + } }; -struct Pet +class Pet + : public service::Object { - virtual service::FieldResult getName(service::FieldParams&& params) const = 0; +private: + struct Concept + { + virtual ~Concept() = default; + + virtual service::TypeNames getTypeNames() const noexcept = 0; + virtual service::ResolverMap getResolvers() const noexcept = 0; + + virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::TypeNames getTypeNames() const noexcept final + { + return _pimpl->getTypeNames(); + } + + service::ResolverMap getResolvers() const noexcept final + { + return _pimpl->getResolvers(); + } + + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + _pimpl->beginSelectionSet(params); + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + _pimpl->endSelectionSet(params); + } + + private: + const std::shared_ptr _pimpl; + }; + + Pet(std::unique_ptr&& pimpl) noexcept; + + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; + + const std::unique_ptr _pimpl; + +public: + template + Pet(std::shared_ptr pimpl) noexcept + : Pet { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } + { + static_assert(T::template implements(), "Pet is not implemented"); + } }; -namespace object { +namespace implements { + +template +concept DogIs = std::is_same_v; + +template +concept AlienIs = std::is_same_v; + +template +concept HumanIs = std::is_same_v; + +template +concept CatIs = std::is_same_v; + +} // namespace implements + namespace methods { -namespace QueryMethod { +namespace QueryHas { template -concept WithParamsDog = requires (TImpl impl, service::FieldParams params) +concept getDogWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getDog(std::move(params)) } }; }; template -concept NoParamsDog = requires (TImpl impl) +concept getDog = requires (TImpl impl) { { service::FieldResult> { impl.getDog() } }; }; template -concept WithParamsHuman = requires (TImpl impl, service::FieldParams params) +concept getHumanWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getHuman(std::move(params)) } }; }; template -concept NoParamsHuman = requires (TImpl impl) +concept getHuman = requires (TImpl impl) { { service::FieldResult> { impl.getHuman() } }; }; template -concept WithParamsPet = requires (TImpl impl, service::FieldParams params) +concept getPetWithParams = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult> { impl.getPet(std::move(params)) } }; + { service::FieldResult> { impl.getPet(std::move(params)) } }; }; template -concept NoParamsPet = requires (TImpl impl) +concept getPet = requires (TImpl impl) { - { service::FieldResult> { impl.getPet() } }; + { service::FieldResult> { impl.getPet() } }; }; template -concept WithParamsCatOrDog = requires (TImpl impl, service::FieldParams params) +concept getCatOrDogWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getCatOrDog(std::move(params)) } }; }; template -concept NoParamsCatOrDog = requires (TImpl impl) +concept getCatOrDog = requires (TImpl impl) { { service::FieldResult> { impl.getCatOrDog() } }; }; template -concept WithParamsArguments = requires (TImpl impl, service::FieldParams params) +concept getArgumentsWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getArguments(std::move(params)) } }; }; template -concept NoParamsArguments = requires (TImpl impl) +concept getArguments = requires (TImpl impl) { { service::FieldResult> { impl.getArguments() } }; }; template -concept WithParamsFindDog = requires (TImpl impl, service::FieldParams params, std::optional complexArg) +concept getFindDogWithParams = requires (TImpl impl, service::FieldParams params, std::optional complexArg) { { service::FieldResult> { impl.getFindDog(std::move(params), std::move(complexArg)) } }; }; template -concept NoParamsFindDog = requires (TImpl impl, std::optional complexArg) +concept getFindDog = requires (TImpl impl, std::optional complexArg) { { service::FieldResult> { impl.getFindDog(std::move(complexArg)) } }; }; template -concept WithParamsBooleanList = requires (TImpl impl, service::FieldParams params, std::optional> booleanListArgArg) +concept getBooleanListWithParams = requires (TImpl impl, service::FieldParams params, std::optional> booleanListArgArg) { { service::FieldResult> { impl.getBooleanList(std::move(params), std::move(booleanListArgArg)) } }; }; template -concept NoParamsBooleanList = requires (TImpl impl, std::optional> booleanListArgArg) +concept getBooleanList = requires (TImpl impl, std::optional> booleanListArgArg) { { service::FieldResult> { impl.getBooleanList(std::move(booleanListArgArg)) } }; }; template -concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.beginSelectionSet(params) }; }; template -concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.endSelectionSet(params) }; }; -} // namespace QueryMethod +} // namespace QueryHas -namespace DogMethod { +namespace DogHas { template -concept WithParamsName = requires (TImpl impl, service::FieldParams params) +concept getNameWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getName(std::move(params)) } }; }; template -concept NoParamsName = requires (TImpl impl) +concept getName = requires (TImpl impl) { { service::FieldResult { impl.getName() } }; }; template -concept WithParamsNickname = requires (TImpl impl, service::FieldParams params) +concept getNicknameWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getNickname(std::move(params)) } }; }; template -concept NoParamsNickname = requires (TImpl impl) +concept getNickname = requires (TImpl impl) { { service::FieldResult> { impl.getNickname() } }; }; template -concept WithParamsBarkVolume = requires (TImpl impl, service::FieldParams params) +concept getBarkVolumeWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getBarkVolume(std::move(params)) } }; }; template -concept NoParamsBarkVolume = requires (TImpl impl) +concept getBarkVolume = requires (TImpl impl) { { service::FieldResult> { impl.getBarkVolume() } }; }; template -concept WithParamsDoesKnowCommand = requires (TImpl impl, service::FieldParams params, DogCommand dogCommandArg) +concept getDoesKnowCommandWithParams = requires (TImpl impl, service::FieldParams params, DogCommand dogCommandArg) { { service::FieldResult { impl.getDoesKnowCommand(std::move(params), std::move(dogCommandArg)) } }; }; template -concept NoParamsDoesKnowCommand = requires (TImpl impl, DogCommand dogCommandArg) +concept getDoesKnowCommand = requires (TImpl impl, DogCommand dogCommandArg) { { service::FieldResult { impl.getDoesKnowCommand(std::move(dogCommandArg)) } }; }; template -concept WithParamsIsHousetrained = requires (TImpl impl, service::FieldParams params, std::optional atOtherHomesArg) +concept getIsHousetrainedWithParams = requires (TImpl impl, service::FieldParams params, std::optional atOtherHomesArg) { { service::FieldResult { impl.getIsHousetrained(std::move(params), std::move(atOtherHomesArg)) } }; }; template -concept NoParamsIsHousetrained = requires (TImpl impl, std::optional atOtherHomesArg) +concept getIsHousetrained = requires (TImpl impl, std::optional atOtherHomesArg) { { service::FieldResult { impl.getIsHousetrained(std::move(atOtherHomesArg)) } }; }; template -concept WithParamsOwner = requires (TImpl impl, service::FieldParams params) +concept getOwnerWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getOwner(std::move(params)) } }; }; template -concept NoParamsOwner = requires (TImpl impl) +concept getOwner = requires (TImpl impl) { { service::FieldResult> { impl.getOwner() } }; }; template -concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.beginSelectionSet(params) }; }; template -concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.endSelectionSet(params) }; }; -} // namespace DogMethod +} // namespace DogHas -namespace AlienMethod { +namespace AlienHas { template -concept WithParamsName = requires (TImpl impl, service::FieldParams params) +concept getNameWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getName(std::move(params)) } }; }; template -concept NoParamsName = requires (TImpl impl) +concept getName = requires (TImpl impl) { { service::FieldResult { impl.getName() } }; }; template -concept WithParamsHomePlanet = requires (TImpl impl, service::FieldParams params) +concept getHomePlanetWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getHomePlanet(std::move(params)) } }; }; template -concept NoParamsHomePlanet = requires (TImpl impl) +concept getHomePlanet = requires (TImpl impl) { { service::FieldResult> { impl.getHomePlanet() } }; }; template -concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.beginSelectionSet(params) }; }; template -concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.endSelectionSet(params) }; }; -} // namespace AlienMethod +} // namespace AlienHas -namespace HumanMethod { +namespace HumanHas { template -concept WithParamsName = requires (TImpl impl, service::FieldParams params) +concept getNameWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getName(std::move(params)) } }; }; template -concept NoParamsName = requires (TImpl impl) +concept getName = requires (TImpl impl) { { service::FieldResult { impl.getName() } }; }; template -concept WithParamsPets = requires (TImpl impl, service::FieldParams params) +concept getPetsWithParams = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult>> { impl.getPets(std::move(params)) } }; + { service::FieldResult>> { impl.getPets(std::move(params)) } }; }; template -concept NoParamsPets = requires (TImpl impl) +concept getPets = requires (TImpl impl) { - { service::FieldResult>> { impl.getPets() } }; + { service::FieldResult>> { impl.getPets() } }; }; template -concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.beginSelectionSet(params) }; }; template -concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.endSelectionSet(params) }; }; -} // namespace HumanMethod +} // namespace HumanHas -namespace CatMethod { +namespace CatHas { template -concept WithParamsName = requires (TImpl impl, service::FieldParams params) +concept getNameWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getName(std::move(params)) } }; }; template -concept NoParamsName = requires (TImpl impl) +concept getName = requires (TImpl impl) { { service::FieldResult { impl.getName() } }; }; template -concept WithParamsNickname = requires (TImpl impl, service::FieldParams params) +concept getNicknameWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getNickname(std::move(params)) } }; }; template -concept NoParamsNickname = requires (TImpl impl) +concept getNickname = requires (TImpl impl) { { service::FieldResult> { impl.getNickname() } }; }; template -concept WithParamsDoesKnowCommand = requires (TImpl impl, service::FieldParams params, CatCommand catCommandArg) +concept getDoesKnowCommandWithParams = requires (TImpl impl, service::FieldParams params, CatCommand catCommandArg) { { service::FieldResult { impl.getDoesKnowCommand(std::move(params), std::move(catCommandArg)) } }; }; template -concept NoParamsDoesKnowCommand = requires (TImpl impl, CatCommand catCommandArg) +concept getDoesKnowCommand = requires (TImpl impl, CatCommand catCommandArg) { { service::FieldResult { impl.getDoesKnowCommand(std::move(catCommandArg)) } }; }; template -concept WithParamsMeowVolume = requires (TImpl impl, service::FieldParams params) +concept getMeowVolumeWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getMeowVolume(std::move(params)) } }; }; template -concept NoParamsMeowVolume = requires (TImpl impl) +concept getMeowVolume = requires (TImpl impl) { { service::FieldResult> { impl.getMeowVolume() } }; }; template -concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.beginSelectionSet(params) }; }; template -concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.endSelectionSet(params) }; }; -} // namespace CatMethod +} // namespace CatHas -namespace MutationMethod { +namespace MutationHas { template -concept WithParamsMutateDog = requires (TImpl impl, service::FieldParams params) +concept applyMutateDogWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.applyMutateDog(std::move(params)) } }; }; template -concept NoParamsMutateDog = requires (TImpl impl) +concept applyMutateDog = requires (TImpl impl) { { service::FieldResult> { impl.applyMutateDog() } }; }; template -concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.beginSelectionSet(params) }; }; template -concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.endSelectionSet(params) }; }; -} // namespace MutationMethod +} // namespace MutationHas -namespace MutateDogResultMethod { +namespace MutateDogResultHas { template -concept WithParamsId = requires (TImpl impl, service::FieldParams params) +concept getIdWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getId(std::move(params)) } }; }; template -concept NoParamsId = requires (TImpl impl) +concept getId = requires (TImpl impl) { { service::FieldResult { impl.getId() } }; }; template -concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.beginSelectionSet(params) }; }; template -concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.endSelectionSet(params) }; }; -} // namespace MutateDogResultMethod +} // namespace MutateDogResultHas -namespace SubscriptionMethod { +namespace SubscriptionHas { template -concept WithParamsNewMessage = requires (TImpl impl, service::FieldParams params) +concept getNewMessageWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getNewMessage(std::move(params)) } }; }; template -concept NoParamsNewMessage = requires (TImpl impl) +concept getNewMessage = requires (TImpl impl) { { service::FieldResult> { impl.getNewMessage() } }; }; template -concept WithParamsDisallowedSecondRootField = requires (TImpl impl, service::FieldParams params) +concept getDisallowedSecondRootFieldWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getDisallowedSecondRootField(std::move(params)) } }; }; template -concept NoParamsDisallowedSecondRootField = requires (TImpl impl) +concept getDisallowedSecondRootField = requires (TImpl impl) { { service::FieldResult { impl.getDisallowedSecondRootField() } }; }; template -concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.beginSelectionSet(params) }; }; template -concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.endSelectionSet(params) }; }; -} // namespace SubscriptionMethod +} // namespace SubscriptionHas -namespace MessageMethod { +namespace MessageHas { template -concept WithParamsBody = requires (TImpl impl, service::FieldParams params) +concept getBodyWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult> { impl.getBody(std::move(params)) } }; }; template -concept NoParamsBody = requires (TImpl impl) +concept getBody = requires (TImpl impl) { { service::FieldResult> { impl.getBody() } }; }; template -concept WithParamsSender = requires (TImpl impl, service::FieldParams params) +concept getSenderWithParams = requires (TImpl impl, service::FieldParams params) { { service::FieldResult { impl.getSender(std::move(params)) } }; }; template -concept NoParamsSender = requires (TImpl impl) +concept getSender = requires (TImpl impl) { { service::FieldResult { impl.getSender() } }; }; template -concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.beginSelectionSet(params) }; }; template -concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.endSelectionSet(params) }; }; -} // namespace MessageMethod +} // namespace MessageHas -namespace ArgumentsMethod { +namespace ArgumentsHas { template -concept WithParamsMultipleReqs = requires (TImpl impl, service::FieldParams params, int xArg, int yArg) +concept getMultipleReqsWithParams = requires (TImpl impl, service::FieldParams params, int xArg, int yArg) { { service::FieldResult { impl.getMultipleReqs(std::move(params), std::move(xArg), std::move(yArg)) } }; }; template -concept NoParamsMultipleReqs = requires (TImpl impl, int xArg, int yArg) +concept getMultipleReqs = requires (TImpl impl, int xArg, int yArg) { { service::FieldResult { impl.getMultipleReqs(std::move(xArg), std::move(yArg)) } }; }; template -concept WithParamsBooleanArgField = requires (TImpl impl, service::FieldParams params, std::optional booleanArgArg) +concept getBooleanArgFieldWithParams = requires (TImpl impl, service::FieldParams params, std::optional booleanArgArg) { { service::FieldResult> { impl.getBooleanArgField(std::move(params), std::move(booleanArgArg)) } }; }; template -concept NoParamsBooleanArgField = requires (TImpl impl, std::optional booleanArgArg) +concept getBooleanArgField = requires (TImpl impl, std::optional booleanArgArg) { { service::FieldResult> { impl.getBooleanArgField(std::move(booleanArgArg)) } }; }; template -concept WithParamsFloatArgField = requires (TImpl impl, service::FieldParams params, std::optional floatArgArg) +concept getFloatArgFieldWithParams = requires (TImpl impl, service::FieldParams params, std::optional floatArgArg) { { service::FieldResult> { impl.getFloatArgField(std::move(params), std::move(floatArgArg)) } }; }; template -concept NoParamsFloatArgField = requires (TImpl impl, std::optional floatArgArg) +concept getFloatArgField = requires (TImpl impl, std::optional floatArgArg) { { service::FieldResult> { impl.getFloatArgField(std::move(floatArgArg)) } }; }; template -concept WithParamsIntArgField = requires (TImpl impl, service::FieldParams params, std::optional intArgArg) +concept getIntArgFieldWithParams = requires (TImpl impl, service::FieldParams params, std::optional intArgArg) { { service::FieldResult> { impl.getIntArgField(std::move(params), std::move(intArgArg)) } }; }; template -concept NoParamsIntArgField = requires (TImpl impl, std::optional intArgArg) +concept getIntArgField = requires (TImpl impl, std::optional intArgArg) { { service::FieldResult> { impl.getIntArgField(std::move(intArgArg)) } }; }; template -concept WithParamsNonNullBooleanArgField = requires (TImpl impl, service::FieldParams params, bool nonNullBooleanArgArg) +concept getNonNullBooleanArgFieldWithParams = requires (TImpl impl, service::FieldParams params, bool nonNullBooleanArgArg) { { service::FieldResult { impl.getNonNullBooleanArgField(std::move(params), std::move(nonNullBooleanArgArg)) } }; }; template -concept NoParamsNonNullBooleanArgField = requires (TImpl impl, bool nonNullBooleanArgArg) +concept getNonNullBooleanArgField = requires (TImpl impl, bool nonNullBooleanArgArg) { { service::FieldResult { impl.getNonNullBooleanArgField(std::move(nonNullBooleanArgArg)) } }; }; template -concept WithParamsNonNullBooleanListField = requires (TImpl impl, service::FieldParams params, std::optional> nonNullBooleanListArgArg) +concept getNonNullBooleanListFieldWithParams = requires (TImpl impl, service::FieldParams params, std::optional> nonNullBooleanListArgArg) { { service::FieldResult>> { impl.getNonNullBooleanListField(std::move(params), std::move(nonNullBooleanListArgArg)) } }; }; template -concept NoParamsNonNullBooleanListField = requires (TImpl impl, std::optional> nonNullBooleanListArgArg) +concept getNonNullBooleanListField = requires (TImpl impl, std::optional> nonNullBooleanListArgArg) { { service::FieldResult>> { impl.getNonNullBooleanListField(std::move(nonNullBooleanListArgArg)) } }; }; template -concept WithParamsBooleanListArgField = requires (TImpl impl, service::FieldParams params, std::vector> booleanListArgArg) +concept getBooleanListArgFieldWithParams = requires (TImpl impl, service::FieldParams params, std::vector> booleanListArgArg) { { service::FieldResult>>> { impl.getBooleanListArgField(std::move(params), std::move(booleanListArgArg)) } }; }; template -concept NoParamsBooleanListArgField = requires (TImpl impl, std::vector> booleanListArgArg) +concept getBooleanListArgField = requires (TImpl impl, std::vector> booleanListArgArg) { { service::FieldResult>>> { impl.getBooleanListArgField(std::move(booleanListArgArg)) } }; }; template -concept WithParamsOptionalNonNullBooleanArgField = requires (TImpl impl, service::FieldParams params, bool optionalBooleanArgArg) +concept getOptionalNonNullBooleanArgFieldWithParams = requires (TImpl impl, service::FieldParams params, bool optionalBooleanArgArg) { { service::FieldResult { impl.getOptionalNonNullBooleanArgField(std::move(params), std::move(optionalBooleanArgArg)) } }; }; template -concept NoParamsOptionalNonNullBooleanArgField = requires (TImpl impl, bool optionalBooleanArgArg) +concept getOptionalNonNullBooleanArgField = requires (TImpl impl, bool optionalBooleanArgArg) { { service::FieldResult { impl.getOptionalNonNullBooleanArgField(std::move(optionalBooleanArgArg)) } }; }; template -concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.beginSelectionSet(params) }; }; template -concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.endSelectionSet(params) }; }; -} // namespace ArgumentsMethod +} // namespace ArgumentsHas } // namespace methods class Query : public service::Object { private: - service::AwaitableResolver resolveDog(service::ResolverParams&& params); - service::AwaitableResolver resolveHuman(service::ResolverParams&& params); - service::AwaitableResolver resolvePet(service::ResolverParams&& params); - service::AwaitableResolver resolveCatOrDog(service::ResolverParams&& params); - service::AwaitableResolver resolveArguments(service::ResolverParams&& params); - service::AwaitableResolver resolveFindDog(service::ResolverParams&& params); - service::AwaitableResolver resolveBooleanList(service::ResolverParams&& params); + service::AwaitableResolver resolveDog(service::ResolverParams&& params) const; + service::AwaitableResolver resolveHuman(service::ResolverParams&& params) const; + service::AwaitableResolver resolvePet(service::ResolverParams&& params) const; + service::AwaitableResolver resolveCatOrDog(service::ResolverParams&& params) const; + service::AwaitableResolver resolveArguments(service::ResolverParams&& params) const; + service::AwaitableResolver resolveFindDog(service::ResolverParams&& params) const; + service::AwaitableResolver resolveBooleanList(service::ResolverParams&& params) const; - service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; struct Concept { @@ -673,7 +804,7 @@ class Query virtual service::FieldResult> getDog(service::FieldParams&& params) const = 0; virtual service::FieldResult> getHuman(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getPet(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getPet(service::FieldParams&& params) const = 0; virtual service::FieldResult> getCatOrDog(service::FieldParams&& params) const = 0; virtual service::FieldResult> getArguments(service::FieldParams&& params) const = 0; virtual service::FieldResult> getFindDog(service::FieldParams&& params, std::optional&& complexArg) const = 0; @@ -691,11 +822,11 @@ class Query service::FieldResult> getDog(service::FieldParams&& params) const final { - if constexpr (methods::QueryMethod::WithParamsDog) + if constexpr (methods::QueryHas::getDogWithParams) { return { _pimpl->getDog(std::move(params)) }; } - else if constexpr (methods::QueryMethod::NoParamsDog) + else if constexpr (methods::QueryHas::getDog) { return { _pimpl->getDog() }; } @@ -707,11 +838,11 @@ class Query service::FieldResult> getHuman(service::FieldParams&& params) const final { - if constexpr (methods::QueryMethod::WithParamsHuman) + if constexpr (methods::QueryHas::getHumanWithParams) { return { _pimpl->getHuman(std::move(params)) }; } - else if constexpr (methods::QueryMethod::NoParamsHuman) + else if constexpr (methods::QueryHas::getHuman) { return { _pimpl->getHuman() }; } @@ -721,13 +852,13 @@ class Query } } - service::FieldResult> getPet(service::FieldParams&& params) const final + service::FieldResult> getPet(service::FieldParams&& params) const final { - if constexpr (methods::QueryMethod::WithParamsPet) + if constexpr (methods::QueryHas::getPetWithParams) { return { _pimpl->getPet(std::move(params)) }; } - else if constexpr (methods::QueryMethod::NoParamsPet) + else if constexpr (methods::QueryHas::getPet) { return { _pimpl->getPet() }; } @@ -739,11 +870,11 @@ class Query service::FieldResult> getCatOrDog(service::FieldParams&& params) const final { - if constexpr (methods::QueryMethod::WithParamsCatOrDog) + if constexpr (methods::QueryHas::getCatOrDogWithParams) { return { _pimpl->getCatOrDog(std::move(params)) }; } - else if constexpr (methods::QueryMethod::NoParamsCatOrDog) + else if constexpr (methods::QueryHas::getCatOrDog) { return { _pimpl->getCatOrDog() }; } @@ -755,11 +886,11 @@ class Query service::FieldResult> getArguments(service::FieldParams&& params) const final { - if constexpr (methods::QueryMethod::WithParamsArguments) + if constexpr (methods::QueryHas::getArgumentsWithParams) { return { _pimpl->getArguments(std::move(params)) }; } - else if constexpr (methods::QueryMethod::NoParamsArguments) + else if constexpr (methods::QueryHas::getArguments) { return { _pimpl->getArguments() }; } @@ -771,11 +902,11 @@ class Query service::FieldResult> getFindDog(service::FieldParams&& params, std::optional&& complexArg) const final { - if constexpr (methods::QueryMethod::WithParamsFindDog) + if constexpr (methods::QueryHas::getFindDogWithParams) { return { _pimpl->getFindDog(std::move(params), std::move(complexArg)) }; } - else if constexpr (methods::QueryMethod::NoParamsFindDog) + else if constexpr (methods::QueryHas::getFindDog) { return { _pimpl->getFindDog(std::move(complexArg)) }; } @@ -787,11 +918,11 @@ class Query service::FieldResult> getBooleanList(service::FieldParams&& params, std::optional>&& booleanListArgArg) const final { - if constexpr (methods::QueryMethod::WithParamsBooleanList) + if constexpr (methods::QueryHas::getBooleanListWithParams) { return { _pimpl->getBooleanList(std::move(params), std::move(booleanListArgArg)) }; } - else if constexpr (methods::QueryMethod::NoParamsBooleanList) + else if constexpr (methods::QueryHas::getBooleanList) { return { _pimpl->getBooleanList(std::move(booleanListArgArg)) }; } @@ -803,7 +934,7 @@ class Query void beginSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::QueryMethod::HasBeginSelectionSet) + if constexpr (methods::QueryHas::beginSelectionSet) { _pimpl->beginSelectionSet(params); } @@ -811,7 +942,7 @@ class Query void endSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::QueryMethod::HasEndSelectionSet) + if constexpr (methods::QueryHas::endSelectionSet) { _pimpl->endSelectionSet(params); } @@ -821,7 +952,10 @@ class Query const std::shared_ptr _pimpl; }; - Query(std::unique_ptr&& pimpl); + Query(std::unique_ptr&& pimpl) noexcept; + + service::TypeNames getTypeNames() const noexcept; + service::ResolverMap getResolvers() const noexcept; void beginSelectionSet(const service::SelectionSetParams& params) const final; void endSelectionSet(const service::SelectionSetParams& params) const final; @@ -830,7 +964,7 @@ class Query public: template - Query(std::shared_ptr pimpl) + Query(std::shared_ptr pimpl) noexcept : Query { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } @@ -840,23 +974,23 @@ class Dog : public service::Object { private: - service::AwaitableResolver resolveName(service::ResolverParams&& params); - service::AwaitableResolver resolveNickname(service::ResolverParams&& params); - service::AwaitableResolver resolveBarkVolume(service::ResolverParams&& params); - service::AwaitableResolver resolveDoesKnowCommand(service::ResolverParams&& params); - service::AwaitableResolver resolveIsHousetrained(service::ResolverParams&& params); - service::AwaitableResolver resolveOwner(service::ResolverParams&& params); + service::AwaitableResolver resolveName(service::ResolverParams&& params) const; + service::AwaitableResolver resolveNickname(service::ResolverParams&& params) const; + service::AwaitableResolver resolveBarkVolume(service::ResolverParams&& params) const; + service::AwaitableResolver resolveDoesKnowCommand(service::ResolverParams&& params) const; + service::AwaitableResolver resolveIsHousetrained(service::ResolverParams&& params) const; + service::AwaitableResolver resolveOwner(service::ResolverParams&& params) const; - service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; struct Concept - : Pet { virtual ~Concept() = default; virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual service::FieldResult getName(service::FieldParams&& params) const = 0; virtual service::FieldResult> getNickname(service::FieldParams&& params) const = 0; virtual service::FieldResult> getBarkVolume(service::FieldParams&& params) const = 0; virtual service::FieldResult getDoesKnowCommand(service::FieldParams&& params, DogCommand&& dogCommandArg) const = 0; @@ -875,11 +1009,11 @@ class Dog service::FieldResult getName(service::FieldParams&& params) const final { - if constexpr (methods::DogMethod::WithParamsName) + if constexpr (methods::DogHas::getNameWithParams) { return { _pimpl->getName(std::move(params)) }; } - else if constexpr (methods::DogMethod::NoParamsName) + else if constexpr (methods::DogHas::getName) { return { _pimpl->getName() }; } @@ -891,11 +1025,11 @@ class Dog service::FieldResult> getNickname(service::FieldParams&& params) const final { - if constexpr (methods::DogMethod::WithParamsNickname) + if constexpr (methods::DogHas::getNicknameWithParams) { return { _pimpl->getNickname(std::move(params)) }; } - else if constexpr (methods::DogMethod::NoParamsNickname) + else if constexpr (methods::DogHas::getNickname) { return { _pimpl->getNickname() }; } @@ -907,11 +1041,11 @@ class Dog service::FieldResult> getBarkVolume(service::FieldParams&& params) const final { - if constexpr (methods::DogMethod::WithParamsBarkVolume) + if constexpr (methods::DogHas::getBarkVolumeWithParams) { return { _pimpl->getBarkVolume(std::move(params)) }; } - else if constexpr (methods::DogMethod::NoParamsBarkVolume) + else if constexpr (methods::DogHas::getBarkVolume) { return { _pimpl->getBarkVolume() }; } @@ -923,11 +1057,11 @@ class Dog service::FieldResult getDoesKnowCommand(service::FieldParams&& params, DogCommand&& dogCommandArg) const final { - if constexpr (methods::DogMethod::WithParamsDoesKnowCommand) + if constexpr (methods::DogHas::getDoesKnowCommandWithParams) { return { _pimpl->getDoesKnowCommand(std::move(params), std::move(dogCommandArg)) }; } - else if constexpr (methods::DogMethod::NoParamsDoesKnowCommand) + else if constexpr (methods::DogHas::getDoesKnowCommand) { return { _pimpl->getDoesKnowCommand(std::move(dogCommandArg)) }; } @@ -939,11 +1073,11 @@ class Dog service::FieldResult getIsHousetrained(service::FieldParams&& params, std::optional&& atOtherHomesArg) const final { - if constexpr (methods::DogMethod::WithParamsIsHousetrained) + if constexpr (methods::DogHas::getIsHousetrainedWithParams) { return { _pimpl->getIsHousetrained(std::move(params), std::move(atOtherHomesArg)) }; } - else if constexpr (methods::DogMethod::NoParamsIsHousetrained) + else if constexpr (methods::DogHas::getIsHousetrained) { return { _pimpl->getIsHousetrained(std::move(atOtherHomesArg)) }; } @@ -955,11 +1089,11 @@ class Dog service::FieldResult> getOwner(service::FieldParams&& params) const final { - if constexpr (methods::DogMethod::WithParamsOwner) + if constexpr (methods::DogHas::getOwnerWithParams) { return { _pimpl->getOwner(std::move(params)) }; } - else if constexpr (methods::DogMethod::NoParamsOwner) + else if constexpr (methods::DogHas::getOwner) { return { _pimpl->getOwner() }; } @@ -971,7 +1105,7 @@ class Dog void beginSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::DogMethod::HasBeginSelectionSet) + if constexpr (methods::DogHas::beginSelectionSet) { _pimpl->beginSelectionSet(params); } @@ -979,7 +1113,7 @@ class Dog void endSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::DogMethod::HasEndSelectionSet) + if constexpr (methods::DogHas::endSelectionSet) { _pimpl->endSelectionSet(params); } @@ -989,7 +1123,19 @@ class Dog const std::shared_ptr _pimpl; }; - Dog(std::unique_ptr&& pimpl); + Dog(std::unique_ptr&& pimpl) noexcept; + + // Interface objects need access to these methods + friend Pet; + + template + static constexpr bool implements() noexcept + { + return implements::DogIs; + } + + service::TypeNames getTypeNames() const noexcept; + service::ResolverMap getResolvers() const noexcept; void beginSelectionSet(const service::SelectionSetParams& params) const final; void endSelectionSet(const service::SelectionSetParams& params) const final; @@ -998,7 +1144,7 @@ class Dog public: template - Dog(std::shared_ptr pimpl) + Dog(std::shared_ptr pimpl) noexcept : Dog { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } @@ -1008,19 +1154,19 @@ class Alien : public service::Object { private: - service::AwaitableResolver resolveName(service::ResolverParams&& params); - service::AwaitableResolver resolveHomePlanet(service::ResolverParams&& params); + service::AwaitableResolver resolveName(service::ResolverParams&& params) const; + service::AwaitableResolver resolveHomePlanet(service::ResolverParams&& params) const; - service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; struct Concept - : Sentient { virtual ~Concept() = default; virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual service::FieldResult getName(service::FieldParams&& params) const = 0; virtual service::FieldResult> getHomePlanet(service::FieldParams&& params) const = 0; }; @@ -1035,11 +1181,11 @@ class Alien service::FieldResult getName(service::FieldParams&& params) const final { - if constexpr (methods::AlienMethod::WithParamsName) + if constexpr (methods::AlienHas::getNameWithParams) { return { _pimpl->getName(std::move(params)) }; } - else if constexpr (methods::AlienMethod::NoParamsName) + else if constexpr (methods::AlienHas::getName) { return { _pimpl->getName() }; } @@ -1051,11 +1197,11 @@ class Alien service::FieldResult> getHomePlanet(service::FieldParams&& params) const final { - if constexpr (methods::AlienMethod::WithParamsHomePlanet) + if constexpr (methods::AlienHas::getHomePlanetWithParams) { return { _pimpl->getHomePlanet(std::move(params)) }; } - else if constexpr (methods::AlienMethod::NoParamsHomePlanet) + else if constexpr (methods::AlienHas::getHomePlanet) { return { _pimpl->getHomePlanet() }; } @@ -1067,7 +1213,7 @@ class Alien void beginSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::AlienMethod::HasBeginSelectionSet) + if constexpr (methods::AlienHas::beginSelectionSet) { _pimpl->beginSelectionSet(params); } @@ -1075,7 +1221,7 @@ class Alien void endSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::AlienMethod::HasEndSelectionSet) + if constexpr (methods::AlienHas::endSelectionSet) { _pimpl->endSelectionSet(params); } @@ -1085,7 +1231,19 @@ class Alien const std::shared_ptr _pimpl; }; - Alien(std::unique_ptr&& pimpl); + Alien(std::unique_ptr&& pimpl) noexcept; + + // Interface objects need access to these methods + friend Sentient; + + template + static constexpr bool implements() noexcept + { + return implements::AlienIs; + } + + service::TypeNames getTypeNames() const noexcept; + service::ResolverMap getResolvers() const noexcept; void beginSelectionSet(const service::SelectionSetParams& params) const final; void endSelectionSet(const service::SelectionSetParams& params) const final; @@ -1094,7 +1252,7 @@ class Alien public: template - Alien(std::shared_ptr pimpl) + Alien(std::shared_ptr pimpl) noexcept : Alien { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } @@ -1104,20 +1262,20 @@ class Human : public service::Object { private: - service::AwaitableResolver resolveName(service::ResolverParams&& params); - service::AwaitableResolver resolvePets(service::ResolverParams&& params); + service::AwaitableResolver resolveName(service::ResolverParams&& params) const; + service::AwaitableResolver resolvePets(service::ResolverParams&& params) const; - service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; struct Concept - : Sentient { virtual ~Concept() = default; virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual service::FieldResult>> getPets(service::FieldParams&& params) const = 0; + virtual service::FieldResult getName(service::FieldParams&& params) const = 0; + virtual service::FieldResult>> getPets(service::FieldParams&& params) const = 0; }; template @@ -1131,11 +1289,11 @@ class Human service::FieldResult getName(service::FieldParams&& params) const final { - if constexpr (methods::HumanMethod::WithParamsName) + if constexpr (methods::HumanHas::getNameWithParams) { return { _pimpl->getName(std::move(params)) }; } - else if constexpr (methods::HumanMethod::NoParamsName) + else if constexpr (methods::HumanHas::getName) { return { _pimpl->getName() }; } @@ -1145,13 +1303,13 @@ class Human } } - service::FieldResult>> getPets(service::FieldParams&& params) const final + service::FieldResult>> getPets(service::FieldParams&& params) const final { - if constexpr (methods::HumanMethod::WithParamsPets) + if constexpr (methods::HumanHas::getPetsWithParams) { return { _pimpl->getPets(std::move(params)) }; } - else if constexpr (methods::HumanMethod::NoParamsPets) + else if constexpr (methods::HumanHas::getPets) { return { _pimpl->getPets() }; } @@ -1163,7 +1321,7 @@ class Human void beginSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::HumanMethod::HasBeginSelectionSet) + if constexpr (methods::HumanHas::beginSelectionSet) { _pimpl->beginSelectionSet(params); } @@ -1171,7 +1329,7 @@ class Human void endSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::HumanMethod::HasEndSelectionSet) + if constexpr (methods::HumanHas::endSelectionSet) { _pimpl->endSelectionSet(params); } @@ -1181,7 +1339,19 @@ class Human const std::shared_ptr _pimpl; }; - Human(std::unique_ptr&& pimpl); + Human(std::unique_ptr&& pimpl) noexcept; + + // Interface objects need access to these methods + friend Sentient; + + template + static constexpr bool implements() noexcept + { + return implements::HumanIs; + } + + service::TypeNames getTypeNames() const noexcept; + service::ResolverMap getResolvers() const noexcept; void beginSelectionSet(const service::SelectionSetParams& params) const final; void endSelectionSet(const service::SelectionSetParams& params) const final; @@ -1190,7 +1360,7 @@ class Human public: template - Human(std::shared_ptr pimpl) + Human(std::shared_ptr pimpl) noexcept : Human { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } @@ -1200,21 +1370,21 @@ class Cat : public service::Object { private: - service::AwaitableResolver resolveName(service::ResolverParams&& params); - service::AwaitableResolver resolveNickname(service::ResolverParams&& params); - service::AwaitableResolver resolveDoesKnowCommand(service::ResolverParams&& params); - service::AwaitableResolver resolveMeowVolume(service::ResolverParams&& params); + service::AwaitableResolver resolveName(service::ResolverParams&& params) const; + service::AwaitableResolver resolveNickname(service::ResolverParams&& params) const; + service::AwaitableResolver resolveDoesKnowCommand(service::ResolverParams&& params) const; + service::AwaitableResolver resolveMeowVolume(service::ResolverParams&& params) const; - service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; struct Concept - : Pet { virtual ~Concept() = default; virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual service::FieldResult getName(service::FieldParams&& params) const = 0; virtual service::FieldResult> getNickname(service::FieldParams&& params) const = 0; virtual service::FieldResult getDoesKnowCommand(service::FieldParams&& params, CatCommand&& catCommandArg) const = 0; virtual service::FieldResult> getMeowVolume(service::FieldParams&& params) const = 0; @@ -1231,11 +1401,11 @@ class Cat service::FieldResult getName(service::FieldParams&& params) const final { - if constexpr (methods::CatMethod::WithParamsName) + if constexpr (methods::CatHas::getNameWithParams) { return { _pimpl->getName(std::move(params)) }; } - else if constexpr (methods::CatMethod::NoParamsName) + else if constexpr (methods::CatHas::getName) { return { _pimpl->getName() }; } @@ -1247,11 +1417,11 @@ class Cat service::FieldResult> getNickname(service::FieldParams&& params) const final { - if constexpr (methods::CatMethod::WithParamsNickname) + if constexpr (methods::CatHas::getNicknameWithParams) { return { _pimpl->getNickname(std::move(params)) }; } - else if constexpr (methods::CatMethod::NoParamsNickname) + else if constexpr (methods::CatHas::getNickname) { return { _pimpl->getNickname() }; } @@ -1263,11 +1433,11 @@ class Cat service::FieldResult getDoesKnowCommand(service::FieldParams&& params, CatCommand&& catCommandArg) const final { - if constexpr (methods::CatMethod::WithParamsDoesKnowCommand) + if constexpr (methods::CatHas::getDoesKnowCommandWithParams) { return { _pimpl->getDoesKnowCommand(std::move(params), std::move(catCommandArg)) }; } - else if constexpr (methods::CatMethod::NoParamsDoesKnowCommand) + else if constexpr (methods::CatHas::getDoesKnowCommand) { return { _pimpl->getDoesKnowCommand(std::move(catCommandArg)) }; } @@ -1279,11 +1449,11 @@ class Cat service::FieldResult> getMeowVolume(service::FieldParams&& params) const final { - if constexpr (methods::CatMethod::WithParamsMeowVolume) + if constexpr (methods::CatHas::getMeowVolumeWithParams) { return { _pimpl->getMeowVolume(std::move(params)) }; } - else if constexpr (methods::CatMethod::NoParamsMeowVolume) + else if constexpr (methods::CatHas::getMeowVolume) { return { _pimpl->getMeowVolume() }; } @@ -1295,7 +1465,7 @@ class Cat void beginSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::CatMethod::HasBeginSelectionSet) + if constexpr (methods::CatHas::beginSelectionSet) { _pimpl->beginSelectionSet(params); } @@ -1303,7 +1473,7 @@ class Cat void endSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::CatMethod::HasEndSelectionSet) + if constexpr (methods::CatHas::endSelectionSet) { _pimpl->endSelectionSet(params); } @@ -1313,7 +1483,19 @@ class Cat const std::shared_ptr _pimpl; }; - Cat(std::unique_ptr&& pimpl); + Cat(std::unique_ptr&& pimpl) noexcept; + + // Interface objects need access to these methods + friend Pet; + + template + static constexpr bool implements() noexcept + { + return implements::CatIs; + } + + service::TypeNames getTypeNames() const noexcept; + service::ResolverMap getResolvers() const noexcept; void beginSelectionSet(const service::SelectionSetParams& params) const final; void endSelectionSet(const service::SelectionSetParams& params) const final; @@ -1322,7 +1504,7 @@ class Cat public: template - Cat(std::shared_ptr pimpl) + Cat(std::shared_ptr pimpl) noexcept : Cat { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } @@ -1332,9 +1514,9 @@ class Mutation : public service::Object { private: - service::AwaitableResolver resolveMutateDog(service::ResolverParams&& params); + service::AwaitableResolver resolveMutateDog(service::ResolverParams&& params) const; - service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; struct Concept { @@ -1357,11 +1539,11 @@ class Mutation service::FieldResult> applyMutateDog(service::FieldParams&& params) const final { - if constexpr (methods::MutationMethod::WithParamsMutateDog) + if constexpr (methods::MutationHas::applyMutateDogWithParams) { return { _pimpl->applyMutateDog(std::move(params)) }; } - else if constexpr (methods::MutationMethod::NoParamsMutateDog) + else if constexpr (methods::MutationHas::applyMutateDog) { return { _pimpl->applyMutateDog() }; } @@ -1373,7 +1555,7 @@ class Mutation void beginSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::MutationMethod::HasBeginSelectionSet) + if constexpr (methods::MutationHas::beginSelectionSet) { _pimpl->beginSelectionSet(params); } @@ -1381,7 +1563,7 @@ class Mutation void endSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::MutationMethod::HasEndSelectionSet) + if constexpr (methods::MutationHas::endSelectionSet) { _pimpl->endSelectionSet(params); } @@ -1391,7 +1573,10 @@ class Mutation const std::shared_ptr _pimpl; }; - Mutation(std::unique_ptr&& pimpl); + Mutation(std::unique_ptr&& pimpl) noexcept; + + service::TypeNames getTypeNames() const noexcept; + service::ResolverMap getResolvers() const noexcept; void beginSelectionSet(const service::SelectionSetParams& params) const final; void endSelectionSet(const service::SelectionSetParams& params) const final; @@ -1400,7 +1585,7 @@ class Mutation public: template - Mutation(std::shared_ptr pimpl) + Mutation(std::shared_ptr pimpl) noexcept : Mutation { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } @@ -1410,9 +1595,9 @@ class MutateDogResult : public service::Object { private: - service::AwaitableResolver resolveId(service::ResolverParams&& params); + service::AwaitableResolver resolveId(service::ResolverParams&& params) const; - service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; struct Concept { @@ -1435,11 +1620,11 @@ class MutateDogResult service::FieldResult getId(service::FieldParams&& params) const final { - if constexpr (methods::MutateDogResultMethod::WithParamsId) + if constexpr (methods::MutateDogResultHas::getIdWithParams) { return { _pimpl->getId(std::move(params)) }; } - else if constexpr (methods::MutateDogResultMethod::NoParamsId) + else if constexpr (methods::MutateDogResultHas::getId) { return { _pimpl->getId() }; } @@ -1451,7 +1636,7 @@ class MutateDogResult void beginSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::MutateDogResultMethod::HasBeginSelectionSet) + if constexpr (methods::MutateDogResultHas::beginSelectionSet) { _pimpl->beginSelectionSet(params); } @@ -1459,7 +1644,7 @@ class MutateDogResult void endSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::MutateDogResultMethod::HasEndSelectionSet) + if constexpr (methods::MutateDogResultHas::endSelectionSet) { _pimpl->endSelectionSet(params); } @@ -1469,7 +1654,10 @@ class MutateDogResult const std::shared_ptr _pimpl; }; - MutateDogResult(std::unique_ptr&& pimpl); + MutateDogResult(std::unique_ptr&& pimpl) noexcept; + + service::TypeNames getTypeNames() const noexcept; + service::ResolverMap getResolvers() const noexcept; void beginSelectionSet(const service::SelectionSetParams& params) const final; void endSelectionSet(const service::SelectionSetParams& params) const final; @@ -1478,7 +1666,7 @@ class MutateDogResult public: template - MutateDogResult(std::shared_ptr pimpl) + MutateDogResult(std::shared_ptr pimpl) noexcept : MutateDogResult { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } @@ -1488,10 +1676,10 @@ class Subscription : public service::Object { private: - service::AwaitableResolver resolveNewMessage(service::ResolverParams&& params); - service::AwaitableResolver resolveDisallowedSecondRootField(service::ResolverParams&& params); + service::AwaitableResolver resolveNewMessage(service::ResolverParams&& params) const; + service::AwaitableResolver resolveDisallowedSecondRootField(service::ResolverParams&& params) const; - service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; struct Concept { @@ -1515,11 +1703,11 @@ class Subscription service::FieldResult> getNewMessage(service::FieldParams&& params) const final { - if constexpr (methods::SubscriptionMethod::WithParamsNewMessage) + if constexpr (methods::SubscriptionHas::getNewMessageWithParams) { return { _pimpl->getNewMessage(std::move(params)) }; } - else if constexpr (methods::SubscriptionMethod::NoParamsNewMessage) + else if constexpr (methods::SubscriptionHas::getNewMessage) { return { _pimpl->getNewMessage() }; } @@ -1531,11 +1719,11 @@ class Subscription service::FieldResult getDisallowedSecondRootField(service::FieldParams&& params) const final { - if constexpr (methods::SubscriptionMethod::WithParamsDisallowedSecondRootField) + if constexpr (methods::SubscriptionHas::getDisallowedSecondRootFieldWithParams) { return { _pimpl->getDisallowedSecondRootField(std::move(params)) }; } - else if constexpr (methods::SubscriptionMethod::NoParamsDisallowedSecondRootField) + else if constexpr (methods::SubscriptionHas::getDisallowedSecondRootField) { return { _pimpl->getDisallowedSecondRootField() }; } @@ -1547,7 +1735,7 @@ class Subscription void beginSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::SubscriptionMethod::HasBeginSelectionSet) + if constexpr (methods::SubscriptionHas::beginSelectionSet) { _pimpl->beginSelectionSet(params); } @@ -1555,7 +1743,7 @@ class Subscription void endSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::SubscriptionMethod::HasEndSelectionSet) + if constexpr (methods::SubscriptionHas::endSelectionSet) { _pimpl->endSelectionSet(params); } @@ -1565,7 +1753,10 @@ class Subscription const std::shared_ptr _pimpl; }; - Subscription(std::unique_ptr&& pimpl); + Subscription(std::unique_ptr&& pimpl) noexcept; + + service::TypeNames getTypeNames() const noexcept; + service::ResolverMap getResolvers() const noexcept; void beginSelectionSet(const service::SelectionSetParams& params) const final; void endSelectionSet(const service::SelectionSetParams& params) const final; @@ -1574,7 +1765,7 @@ class Subscription public: template - Subscription(std::shared_ptr pimpl) + Subscription(std::shared_ptr pimpl) noexcept : Subscription { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } @@ -1584,10 +1775,10 @@ class Message : public service::Object { private: - service::AwaitableResolver resolveBody(service::ResolverParams&& params); - service::AwaitableResolver resolveSender(service::ResolverParams&& params); + service::AwaitableResolver resolveBody(service::ResolverParams&& params) const; + service::AwaitableResolver resolveSender(service::ResolverParams&& params) const; - service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; struct Concept { @@ -1611,11 +1802,11 @@ class Message service::FieldResult> getBody(service::FieldParams&& params) const final { - if constexpr (methods::MessageMethod::WithParamsBody) + if constexpr (methods::MessageHas::getBodyWithParams) { return { _pimpl->getBody(std::move(params)) }; } - else if constexpr (methods::MessageMethod::NoParamsBody) + else if constexpr (methods::MessageHas::getBody) { return { _pimpl->getBody() }; } @@ -1627,11 +1818,11 @@ class Message service::FieldResult getSender(service::FieldParams&& params) const final { - if constexpr (methods::MessageMethod::WithParamsSender) + if constexpr (methods::MessageHas::getSenderWithParams) { return { _pimpl->getSender(std::move(params)) }; } - else if constexpr (methods::MessageMethod::NoParamsSender) + else if constexpr (methods::MessageHas::getSender) { return { _pimpl->getSender() }; } @@ -1643,7 +1834,7 @@ class Message void beginSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::MessageMethod::HasBeginSelectionSet) + if constexpr (methods::MessageHas::beginSelectionSet) { _pimpl->beginSelectionSet(params); } @@ -1651,7 +1842,7 @@ class Message void endSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::MessageMethod::HasEndSelectionSet) + if constexpr (methods::MessageHas::endSelectionSet) { _pimpl->endSelectionSet(params); } @@ -1661,7 +1852,10 @@ class Message const std::shared_ptr _pimpl; }; - Message(std::unique_ptr&& pimpl); + Message(std::unique_ptr&& pimpl) noexcept; + + service::TypeNames getTypeNames() const noexcept; + service::ResolverMap getResolvers() const noexcept; void beginSelectionSet(const service::SelectionSetParams& params) const final; void endSelectionSet(const service::SelectionSetParams& params) const final; @@ -1670,7 +1864,7 @@ class Message public: template - Message(std::shared_ptr pimpl) + Message(std::shared_ptr pimpl) noexcept : Message { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } @@ -1680,16 +1874,16 @@ class Arguments : public service::Object { private: - service::AwaitableResolver resolveMultipleReqs(service::ResolverParams&& params); - service::AwaitableResolver resolveBooleanArgField(service::ResolverParams&& params); - service::AwaitableResolver resolveFloatArgField(service::ResolverParams&& params); - service::AwaitableResolver resolveIntArgField(service::ResolverParams&& params); - service::AwaitableResolver resolveNonNullBooleanArgField(service::ResolverParams&& params); - service::AwaitableResolver resolveNonNullBooleanListField(service::ResolverParams&& params); - service::AwaitableResolver resolveBooleanListArgField(service::ResolverParams&& params); - service::AwaitableResolver resolveOptionalNonNullBooleanArgField(service::ResolverParams&& params); + service::AwaitableResolver resolveMultipleReqs(service::ResolverParams&& params) const; + service::AwaitableResolver resolveBooleanArgField(service::ResolverParams&& params) const; + service::AwaitableResolver resolveFloatArgField(service::ResolverParams&& params) const; + service::AwaitableResolver resolveIntArgField(service::ResolverParams&& params) const; + service::AwaitableResolver resolveNonNullBooleanArgField(service::ResolverParams&& params) const; + service::AwaitableResolver resolveNonNullBooleanListField(service::ResolverParams&& params) const; + service::AwaitableResolver resolveBooleanListArgField(service::ResolverParams&& params) const; + service::AwaitableResolver resolveOptionalNonNullBooleanArgField(service::ResolverParams&& params) const; - service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; struct Concept { @@ -1719,11 +1913,11 @@ class Arguments service::FieldResult getMultipleReqs(service::FieldParams&& params, int&& xArg, int&& yArg) const final { - if constexpr (methods::ArgumentsMethod::WithParamsMultipleReqs) + if constexpr (methods::ArgumentsHas::getMultipleReqsWithParams) { return { _pimpl->getMultipleReqs(std::move(params), std::move(xArg), std::move(yArg)) }; } - else if constexpr (methods::ArgumentsMethod::NoParamsMultipleReqs) + else if constexpr (methods::ArgumentsHas::getMultipleReqs) { return { _pimpl->getMultipleReqs(std::move(xArg), std::move(yArg)) }; } @@ -1735,11 +1929,11 @@ class Arguments service::FieldResult> getBooleanArgField(service::FieldParams&& params, std::optional&& booleanArgArg) const final { - if constexpr (methods::ArgumentsMethod::WithParamsBooleanArgField) + if constexpr (methods::ArgumentsHas::getBooleanArgFieldWithParams) { return { _pimpl->getBooleanArgField(std::move(params), std::move(booleanArgArg)) }; } - else if constexpr (methods::ArgumentsMethod::NoParamsBooleanArgField) + else if constexpr (methods::ArgumentsHas::getBooleanArgField) { return { _pimpl->getBooleanArgField(std::move(booleanArgArg)) }; } @@ -1751,11 +1945,11 @@ class Arguments service::FieldResult> getFloatArgField(service::FieldParams&& params, std::optional&& floatArgArg) const final { - if constexpr (methods::ArgumentsMethod::WithParamsFloatArgField) + if constexpr (methods::ArgumentsHas::getFloatArgFieldWithParams) { return { _pimpl->getFloatArgField(std::move(params), std::move(floatArgArg)) }; } - else if constexpr (methods::ArgumentsMethod::NoParamsFloatArgField) + else if constexpr (methods::ArgumentsHas::getFloatArgField) { return { _pimpl->getFloatArgField(std::move(floatArgArg)) }; } @@ -1767,11 +1961,11 @@ class Arguments service::FieldResult> getIntArgField(service::FieldParams&& params, std::optional&& intArgArg) const final { - if constexpr (methods::ArgumentsMethod::WithParamsIntArgField) + if constexpr (methods::ArgumentsHas::getIntArgFieldWithParams) { return { _pimpl->getIntArgField(std::move(params), std::move(intArgArg)) }; } - else if constexpr (methods::ArgumentsMethod::NoParamsIntArgField) + else if constexpr (methods::ArgumentsHas::getIntArgField) { return { _pimpl->getIntArgField(std::move(intArgArg)) }; } @@ -1783,11 +1977,11 @@ class Arguments service::FieldResult getNonNullBooleanArgField(service::FieldParams&& params, bool&& nonNullBooleanArgArg) const final { - if constexpr (methods::ArgumentsMethod::WithParamsNonNullBooleanArgField) + if constexpr (methods::ArgumentsHas::getNonNullBooleanArgFieldWithParams) { return { _pimpl->getNonNullBooleanArgField(std::move(params), std::move(nonNullBooleanArgArg)) }; } - else if constexpr (methods::ArgumentsMethod::NoParamsNonNullBooleanArgField) + else if constexpr (methods::ArgumentsHas::getNonNullBooleanArgField) { return { _pimpl->getNonNullBooleanArgField(std::move(nonNullBooleanArgArg)) }; } @@ -1799,11 +1993,11 @@ class Arguments service::FieldResult>> getNonNullBooleanListField(service::FieldParams&& params, std::optional>&& nonNullBooleanListArgArg) const final { - if constexpr (methods::ArgumentsMethod::WithParamsNonNullBooleanListField) + if constexpr (methods::ArgumentsHas::getNonNullBooleanListFieldWithParams) { return { _pimpl->getNonNullBooleanListField(std::move(params), std::move(nonNullBooleanListArgArg)) }; } - else if constexpr (methods::ArgumentsMethod::NoParamsNonNullBooleanListField) + else if constexpr (methods::ArgumentsHas::getNonNullBooleanListField) { return { _pimpl->getNonNullBooleanListField(std::move(nonNullBooleanListArgArg)) }; } @@ -1815,11 +2009,11 @@ class Arguments service::FieldResult>>> getBooleanListArgField(service::FieldParams&& params, std::vector>&& booleanListArgArg) const final { - if constexpr (methods::ArgumentsMethod::WithParamsBooleanListArgField) + if constexpr (methods::ArgumentsHas::getBooleanListArgFieldWithParams) { return { _pimpl->getBooleanListArgField(std::move(params), std::move(booleanListArgArg)) }; } - else if constexpr (methods::ArgumentsMethod::NoParamsBooleanListArgField) + else if constexpr (methods::ArgumentsHas::getBooleanListArgField) { return { _pimpl->getBooleanListArgField(std::move(booleanListArgArg)) }; } @@ -1831,11 +2025,11 @@ class Arguments service::FieldResult getOptionalNonNullBooleanArgField(service::FieldParams&& params, bool&& optionalBooleanArgArg) const final { - if constexpr (methods::ArgumentsMethod::WithParamsOptionalNonNullBooleanArgField) + if constexpr (methods::ArgumentsHas::getOptionalNonNullBooleanArgFieldWithParams) { return { _pimpl->getOptionalNonNullBooleanArgField(std::move(params), std::move(optionalBooleanArgArg)) }; } - else if constexpr (methods::ArgumentsMethod::NoParamsOptionalNonNullBooleanArgField) + else if constexpr (methods::ArgumentsHas::getOptionalNonNullBooleanArgField) { return { _pimpl->getOptionalNonNullBooleanArgField(std::move(optionalBooleanArgArg)) }; } @@ -1847,7 +2041,7 @@ class Arguments void beginSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::ArgumentsMethod::HasBeginSelectionSet) + if constexpr (methods::ArgumentsHas::beginSelectionSet) { _pimpl->beginSelectionSet(params); } @@ -1855,7 +2049,7 @@ class Arguments void endSelectionSet(const service::SelectionSetParams& params) const final { - if constexpr (methods::ArgumentsMethod::HasEndSelectionSet) + if constexpr (methods::ArgumentsHas::endSelectionSet) { _pimpl->endSelectionSet(params); } @@ -1865,7 +2059,10 @@ class Arguments const std::shared_ptr _pimpl; }; - Arguments(std::unique_ptr&& pimpl); + Arguments(std::unique_ptr&& pimpl) noexcept; + + service::TypeNames getTypeNames() const noexcept; + service::ResolverMap getResolvers() const noexcept; void beginSelectionSet(const service::SelectionSetParams& params) const final; void endSelectionSet(const service::SelectionSetParams& params) const final; @@ -1874,7 +2071,7 @@ class Arguments public: template - Arguments(std::shared_ptr pimpl) + Arguments(std::shared_ptr pimpl) noexcept : Arguments { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { } diff --git a/src/GraphQLService.cpp b/src/GraphQLService.cpp index dfa3d956..4c8e172b 100644 --- a/src/GraphQLService.cpp +++ b/src/GraphQLService.cpp @@ -1084,7 +1084,7 @@ void SelectionVisitor::visitInlineFragment(const peg::ast_node& inlineFragment) } } -Object::Object(TypeNames&& typeNames, ResolverMap&& resolvers) +Object::Object(TypeNames&& typeNames, ResolverMap&& resolvers) noexcept : _typeNames(std::move(typeNames)) , _resolvers(std::move(resolvers)) { diff --git a/src/IntrospectionSchema.cpp b/src/IntrospectionSchema.cpp index cb8189ac..84c7ed0d 100644 --- a/src/IntrospectionSchema.cpp +++ b/src/IntrospectionSchema.cpp @@ -120,18 +120,9 @@ service::AwaitableResolver ModifiedResult::con namespace introspection { namespace object { -Schema::Schema(std::shared_ptr pimpl) - : service::Object({ - "__Schema" - }, { - { R"gql(types)gql"sv, [this](service::ResolverParams&& params) { return resolveTypes(std::move(params)); } }, - { R"gql(queryType)gql"sv, [this](service::ResolverParams&& params) { return resolveQueryType(std::move(params)); } }, - { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, - { R"gql(directives)gql"sv, [this](service::ResolverParams&& params) { return resolveDirectives(std::move(params)); } }, - { R"gql(mutationType)gql"sv, [this](service::ResolverParams&& params) { return resolveMutationType(std::move(params)); } }, - { R"gql(subscriptionType)gql"sv, [this](service::ResolverParams&& params) { return resolveSubscriptionType(std::move(params)); } } - }) - , _pimpl(std::make_unique>(std::move(pimpl))) +Schema::Schema(std::shared_ptr pimpl) noexcept + : service::Object{ getTypeNames(), getResolvers() } + , _pimpl { std::make_unique>(std::move(pimpl)) } { } @@ -141,7 +132,26 @@ Schema::~Schema() // of the implementation type. } -service::AwaitableResolver Schema::resolveTypes(service::ResolverParams&& params) +service::TypeNames Schema::getTypeNames() const noexcept +{ + return { + "__Schema" + }; +} + +service::ResolverMap Schema::getResolvers() const noexcept +{ + return { + { R"gql(types)gql"sv, [this](service::ResolverParams&& params) { return resolveTypes(std::move(params)); } }, + { R"gql(queryType)gql"sv, [this](service::ResolverParams&& params) { return resolveQueryType(std::move(params)); } }, + { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, + { R"gql(directives)gql"sv, [this](service::ResolverParams&& params) { return resolveDirectives(std::move(params)); } }, + { R"gql(mutationType)gql"sv, [this](service::ResolverParams&& params) { return resolveMutationType(std::move(params)); } }, + { R"gql(subscriptionType)gql"sv, [this](service::ResolverParams&& params) { return resolveSubscriptionType(std::move(params)); } } + }; +} + +service::AwaitableResolver Schema::resolveTypes(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -151,7 +161,7 @@ service::AwaitableResolver Schema::resolveTypes(service::ResolverParams&& params return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Schema::resolveQueryType(service::ResolverParams&& params) +service::AwaitableResolver Schema::resolveQueryType(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -161,7 +171,7 @@ service::AwaitableResolver Schema::resolveQueryType(service::ResolverParams&& pa return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Schema::resolveMutationType(service::ResolverParams&& params) +service::AwaitableResolver Schema::resolveMutationType(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -171,7 +181,7 @@ service::AwaitableResolver Schema::resolveMutationType(service::ResolverParams&& return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Schema::resolveSubscriptionType(service::ResolverParams&& params) +service::AwaitableResolver Schema::resolveSubscriptionType(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -181,7 +191,7 @@ service::AwaitableResolver Schema::resolveSubscriptionType(service::ResolverPara return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Schema::resolveDirectives(service::ResolverParams&& params) +service::AwaitableResolver Schema::resolveDirectives(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -191,15 +201,33 @@ service::AwaitableResolver Schema::resolveDirectives(service::ResolverParams&& p return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Schema::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver Schema::resolve_typename(service::ResolverParams&& params) const { return service::ModifiedResult::convert(std::string{ R"gql(__Schema)gql" }, std::move(params)); } -Type::Type(std::shared_ptr pimpl) - : service::Object({ +Type::Type(std::shared_ptr pimpl) noexcept + : service::Object{ getTypeNames(), getResolvers() } + , _pimpl { std::make_unique>(std::move(pimpl)) } +{ +} + +Type::~Type() +{ + // This is empty, but explicitly defined here so that it can access the un-exported destructor + // of the implementation type. +} + +service::TypeNames Type::getTypeNames() const noexcept +{ + return { "__Type" - }, { + }; +} + +service::ResolverMap Type::getResolvers() const noexcept +{ + return { { R"gql(kind)gql"sv, [this](service::ResolverParams&& params) { return resolveKind(std::move(params)); } }, { R"gql(name)gql"sv, [this](service::ResolverParams&& params) { return resolveName(std::move(params)); } }, { R"gql(fields)gql"sv, [this](service::ResolverParams&& params) { return resolveFields(std::move(params)); } }, @@ -210,18 +238,10 @@ Type::Type(std::shared_ptr pimpl) { R"gql(description)gql"sv, [this](service::ResolverParams&& params) { return resolveDescription(std::move(params)); } }, { R"gql(inputFields)gql"sv, [this](service::ResolverParams&& params) { return resolveInputFields(std::move(params)); } }, { R"gql(possibleTypes)gql"sv, [this](service::ResolverParams&& params) { return resolvePossibleTypes(std::move(params)); } } - }) - , _pimpl(std::make_unique>(std::move(pimpl))) -{ + }; } -Type::~Type() -{ - // This is empty, but explicitly defined here so that it can access the un-exported destructor - // of the implementation type. -} - -service::AwaitableResolver Type::resolveKind(service::ResolverParams&& params) +service::AwaitableResolver Type::resolveKind(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -231,7 +251,7 @@ service::AwaitableResolver Type::resolveKind(service::ResolverParams&& params) return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Type::resolveName(service::ResolverParams&& params) +service::AwaitableResolver Type::resolveName(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -241,7 +261,7 @@ service::AwaitableResolver Type::resolveName(service::ResolverParams&& params) return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Type::resolveDescription(service::ResolverParams&& params) +service::AwaitableResolver Type::resolveDescription(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -251,7 +271,7 @@ service::AwaitableResolver Type::resolveDescription(service::ResolverParams&& pa return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Type::resolveFields(service::ResolverParams&& params) +service::AwaitableResolver Type::resolveFields(service::ResolverParams&& params) const { const auto defaultArguments = []() { @@ -276,7 +296,7 @@ service::AwaitableResolver Type::resolveFields(service::ResolverParams&& params) return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Type::resolveInterfaces(service::ResolverParams&& params) +service::AwaitableResolver Type::resolveInterfaces(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -286,7 +306,7 @@ service::AwaitableResolver Type::resolveInterfaces(service::ResolverParams&& par return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Type::resolvePossibleTypes(service::ResolverParams&& params) +service::AwaitableResolver Type::resolvePossibleTypes(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -296,7 +316,7 @@ service::AwaitableResolver Type::resolvePossibleTypes(service::ResolverParams&& return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Type::resolveEnumValues(service::ResolverParams&& params) +service::AwaitableResolver Type::resolveEnumValues(service::ResolverParams&& params) const { const auto defaultArguments = []() { @@ -321,7 +341,7 @@ service::AwaitableResolver Type::resolveEnumValues(service::ResolverParams&& par return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Type::resolveInputFields(service::ResolverParams&& params) +service::AwaitableResolver Type::resolveInputFields(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -331,7 +351,7 @@ service::AwaitableResolver Type::resolveInputFields(service::ResolverParams&& pa return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Type::resolveOfType(service::ResolverParams&& params) +service::AwaitableResolver Type::resolveOfType(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -341,15 +361,33 @@ service::AwaitableResolver Type::resolveOfType(service::ResolverParams&& params) return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Type::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver Type::resolve_typename(service::ResolverParams&& params) const { return service::ModifiedResult::convert(std::string{ R"gql(__Type)gql" }, std::move(params)); } -Field::Field(std::shared_ptr pimpl) - : service::Object({ +Field::Field(std::shared_ptr pimpl) noexcept + : service::Object{ getTypeNames(), getResolvers() } + , _pimpl { std::make_unique>(std::move(pimpl)) } +{ +} + +Field::~Field() +{ + // This is empty, but explicitly defined here so that it can access the un-exported destructor + // of the implementation type. +} + +service::TypeNames Field::getTypeNames() const noexcept +{ + return { "__Field" - }, { + }; +} + +service::ResolverMap Field::getResolvers() const noexcept +{ + return { { R"gql(args)gql"sv, [this](service::ResolverParams&& params) { return resolveArgs(std::move(params)); } }, { R"gql(name)gql"sv, [this](service::ResolverParams&& params) { return resolveName(std::move(params)); } }, { R"gql(type)gql"sv, [this](service::ResolverParams&& params) { return resolveType(std::move(params)); } }, @@ -357,18 +395,10 @@ Field::Field(std::shared_ptr pimpl) { R"gql(description)gql"sv, [this](service::ResolverParams&& params) { return resolveDescription(std::move(params)); } }, { R"gql(isDeprecated)gql"sv, [this](service::ResolverParams&& params) { return resolveIsDeprecated(std::move(params)); } }, { R"gql(deprecationReason)gql"sv, [this](service::ResolverParams&& params) { return resolveDeprecationReason(std::move(params)); } } - }) - , _pimpl(std::make_unique>(std::move(pimpl))) -{ -} - -Field::~Field() -{ - // This is empty, but explicitly defined here so that it can access the un-exported destructor - // of the implementation type. + }; } -service::AwaitableResolver Field::resolveName(service::ResolverParams&& params) +service::AwaitableResolver Field::resolveName(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -378,7 +408,7 @@ service::AwaitableResolver Field::resolveName(service::ResolverParams&& params) return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Field::resolveDescription(service::ResolverParams&& params) +service::AwaitableResolver Field::resolveDescription(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -388,7 +418,7 @@ service::AwaitableResolver Field::resolveDescription(service::ResolverParams&& p return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Field::resolveArgs(service::ResolverParams&& params) +service::AwaitableResolver Field::resolveArgs(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -398,7 +428,7 @@ service::AwaitableResolver Field::resolveArgs(service::ResolverParams&& params) return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Field::resolveType(service::ResolverParams&& params) +service::AwaitableResolver Field::resolveType(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -408,7 +438,7 @@ service::AwaitableResolver Field::resolveType(service::ResolverParams&& params) return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Field::resolveIsDeprecated(service::ResolverParams&& params) +service::AwaitableResolver Field::resolveIsDeprecated(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -418,7 +448,7 @@ service::AwaitableResolver Field::resolveIsDeprecated(service::ResolverParams&& return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Field::resolveDeprecationReason(service::ResolverParams&& params) +service::AwaitableResolver Field::resolveDeprecationReason(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -428,22 +458,14 @@ service::AwaitableResolver Field::resolveDeprecationReason(service::ResolverPara return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Field::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver Field::resolve_typename(service::ResolverParams&& params) const { return service::ModifiedResult::convert(std::string{ R"gql(__Field)gql" }, std::move(params)); } -InputValue::InputValue(std::shared_ptr pimpl) - : service::Object({ - "__InputValue" - }, { - { R"gql(name)gql"sv, [this](service::ResolverParams&& params) { return resolveName(std::move(params)); } }, - { R"gql(type)gql"sv, [this](service::ResolverParams&& params) { return resolveType(std::move(params)); } }, - { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, - { R"gql(description)gql"sv, [this](service::ResolverParams&& params) { return resolveDescription(std::move(params)); } }, - { R"gql(defaultValue)gql"sv, [this](service::ResolverParams&& params) { return resolveDefaultValue(std::move(params)); } } - }) - , _pimpl(std::make_unique>(std::move(pimpl))) +InputValue::InputValue(std::shared_ptr pimpl) noexcept + : service::Object{ getTypeNames(), getResolvers() } + , _pimpl { std::make_unique>(std::move(pimpl)) } { } @@ -453,7 +475,25 @@ InputValue::~InputValue() // of the implementation type. } -service::AwaitableResolver InputValue::resolveName(service::ResolverParams&& params) +service::TypeNames InputValue::getTypeNames() const noexcept +{ + return { + "__InputValue" + }; +} + +service::ResolverMap InputValue::getResolvers() const noexcept +{ + return { + { R"gql(name)gql"sv, [this](service::ResolverParams&& params) { return resolveName(std::move(params)); } }, + { R"gql(type)gql"sv, [this](service::ResolverParams&& params) { return resolveType(std::move(params)); } }, + { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, + { R"gql(description)gql"sv, [this](service::ResolverParams&& params) { return resolveDescription(std::move(params)); } }, + { R"gql(defaultValue)gql"sv, [this](service::ResolverParams&& params) { return resolveDefaultValue(std::move(params)); } } + }; +} + +service::AwaitableResolver InputValue::resolveName(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -463,7 +503,7 @@ service::AwaitableResolver InputValue::resolveName(service::ResolverParams&& par return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver InputValue::resolveDescription(service::ResolverParams&& params) +service::AwaitableResolver InputValue::resolveDescription(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -473,7 +513,7 @@ service::AwaitableResolver InputValue::resolveDescription(service::ResolverParam return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver InputValue::resolveType(service::ResolverParams&& params) +service::AwaitableResolver InputValue::resolveType(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -483,7 +523,7 @@ service::AwaitableResolver InputValue::resolveType(service::ResolverParams&& par return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver InputValue::resolveDefaultValue(service::ResolverParams&& params) +service::AwaitableResolver InputValue::resolveDefaultValue(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -493,22 +533,14 @@ service::AwaitableResolver InputValue::resolveDefaultValue(service::ResolverPara return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver InputValue::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver InputValue::resolve_typename(service::ResolverParams&& params) const { return service::ModifiedResult::convert(std::string{ R"gql(__InputValue)gql" }, std::move(params)); } -EnumValue::EnumValue(std::shared_ptr pimpl) - : service::Object({ - "__EnumValue" - }, { - { R"gql(name)gql"sv, [this](service::ResolverParams&& params) { return resolveName(std::move(params)); } }, - { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, - { R"gql(description)gql"sv, [this](service::ResolverParams&& params) { return resolveDescription(std::move(params)); } }, - { R"gql(isDeprecated)gql"sv, [this](service::ResolverParams&& params) { return resolveIsDeprecated(std::move(params)); } }, - { R"gql(deprecationReason)gql"sv, [this](service::ResolverParams&& params) { return resolveDeprecationReason(std::move(params)); } } - }) - , _pimpl(std::make_unique>(std::move(pimpl))) +EnumValue::EnumValue(std::shared_ptr pimpl) noexcept + : service::Object{ getTypeNames(), getResolvers() } + , _pimpl { std::make_unique>(std::move(pimpl)) } { } @@ -518,7 +550,25 @@ EnumValue::~EnumValue() // of the implementation type. } -service::AwaitableResolver EnumValue::resolveName(service::ResolverParams&& params) +service::TypeNames EnumValue::getTypeNames() const noexcept +{ + return { + "__EnumValue" + }; +} + +service::ResolverMap EnumValue::getResolvers() const noexcept +{ + return { + { R"gql(name)gql"sv, [this](service::ResolverParams&& params) { return resolveName(std::move(params)); } }, + { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, + { R"gql(description)gql"sv, [this](service::ResolverParams&& params) { return resolveDescription(std::move(params)); } }, + { R"gql(isDeprecated)gql"sv, [this](service::ResolverParams&& params) { return resolveIsDeprecated(std::move(params)); } }, + { R"gql(deprecationReason)gql"sv, [this](service::ResolverParams&& params) { return resolveDeprecationReason(std::move(params)); } } + }; +} + +service::AwaitableResolver EnumValue::resolveName(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -528,7 +578,7 @@ service::AwaitableResolver EnumValue::resolveName(service::ResolverParams&& para return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver EnumValue::resolveDescription(service::ResolverParams&& params) +service::AwaitableResolver EnumValue::resolveDescription(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -538,7 +588,7 @@ service::AwaitableResolver EnumValue::resolveDescription(service::ResolverParams return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver EnumValue::resolveIsDeprecated(service::ResolverParams&& params) +service::AwaitableResolver EnumValue::resolveIsDeprecated(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -548,7 +598,7 @@ service::AwaitableResolver EnumValue::resolveIsDeprecated(service::ResolverParam return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver EnumValue::resolveDeprecationReason(service::ResolverParams&& params) +service::AwaitableResolver EnumValue::resolveDeprecationReason(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -558,22 +608,14 @@ service::AwaitableResolver EnumValue::resolveDeprecationReason(service::Resolver return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver EnumValue::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver EnumValue::resolve_typename(service::ResolverParams&& params) const { return service::ModifiedResult::convert(std::string{ R"gql(__EnumValue)gql" }, std::move(params)); } -Directive::Directive(std::shared_ptr pimpl) - : service::Object({ - "__Directive" - }, { - { R"gql(args)gql"sv, [this](service::ResolverParams&& params) { return resolveArgs(std::move(params)); } }, - { R"gql(name)gql"sv, [this](service::ResolverParams&& params) { return resolveName(std::move(params)); } }, - { R"gql(locations)gql"sv, [this](service::ResolverParams&& params) { return resolveLocations(std::move(params)); } }, - { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, - { R"gql(description)gql"sv, [this](service::ResolverParams&& params) { return resolveDescription(std::move(params)); } } - }) - , _pimpl(std::make_unique>(std::move(pimpl))) +Directive::Directive(std::shared_ptr pimpl) noexcept + : service::Object{ getTypeNames(), getResolvers() } + , _pimpl { std::make_unique>(std::move(pimpl)) } { } @@ -583,7 +625,25 @@ Directive::~Directive() // of the implementation type. } -service::AwaitableResolver Directive::resolveName(service::ResolverParams&& params) +service::TypeNames Directive::getTypeNames() const noexcept +{ + return { + "__Directive" + }; +} + +service::ResolverMap Directive::getResolvers() const noexcept +{ + return { + { R"gql(args)gql"sv, [this](service::ResolverParams&& params) { return resolveArgs(std::move(params)); } }, + { R"gql(name)gql"sv, [this](service::ResolverParams&& params) { return resolveName(std::move(params)); } }, + { R"gql(locations)gql"sv, [this](service::ResolverParams&& params) { return resolveLocations(std::move(params)); } }, + { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, + { R"gql(description)gql"sv, [this](service::ResolverParams&& params) { return resolveDescription(std::move(params)); } } + }; +} + +service::AwaitableResolver Directive::resolveName(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -593,7 +653,7 @@ service::AwaitableResolver Directive::resolveName(service::ResolverParams&& para return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Directive::resolveDescription(service::ResolverParams&& params) +service::AwaitableResolver Directive::resolveDescription(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -603,7 +663,7 @@ service::AwaitableResolver Directive::resolveDescription(service::ResolverParams return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Directive::resolveLocations(service::ResolverParams&& params) +service::AwaitableResolver Directive::resolveLocations(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -613,7 +673,7 @@ service::AwaitableResolver Directive::resolveLocations(service::ResolverParams&& return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Directive::resolveArgs(service::ResolverParams&& params) +service::AwaitableResolver Directive::resolveArgs(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); auto directives = std::move(params.fieldDirectives); @@ -623,7 +683,7 @@ service::AwaitableResolver Directive::resolveArgs(service::ResolverParams&& para return service::ModifiedResult::convert(std::move(result), std::move(params)); } -service::AwaitableResolver Directive::resolve_typename(service::ResolverParams&& params) +service::AwaitableResolver Directive::resolve_typename(service::ResolverParams&& params) const { return service::ModifiedResult::convert(std::string{ R"gql(__Directive)gql" }, std::move(params)); } diff --git a/src/SchemaGenerator.cpp b/src/SchemaGenerator.cpp index 70aff75c..bea38113 100644 --- a/src/SchemaGenerator.cpp +++ b/src/SchemaGenerator.cpp @@ -250,10 +250,30 @@ static_assert(graphql::internal::MinorVersion == )cpp" } } + if (!_loader.getInterfaceTypes().empty()) + { + objectNamespace.enter(); + headerFile << std::endl; + + // Forward declare all of the interface types + for (const auto& interfaceType : _loader.getInterfaceTypes()) + { + headerFile << R"cpp(class )cpp" << interfaceType.cppType << R"cpp(; +)cpp"; + } + + headerFile << std::endl; + } + if (!_loader.getObjectTypes().empty()) { if (_loader.isIntrospection()) { + if (objectNamespace.exit()) + { + headerFile << std::endl; + } + // Forward declare all of the concrete types for the Introspection schema for (const auto& objectType : _loader.getObjectTypes()) { @@ -264,8 +284,10 @@ static_assert(graphql::internal::MinorVersion == )cpp" headerFile << std::endl; } - objectNamespace.enter(); - headerFile << std::endl; + if (objectNamespace.enter()) + { + headerFile << std::endl; + } // Forward declare all of the object types for (const auto& objectType : _loader.getObjectTypes()) @@ -277,78 +299,77 @@ static_assert(graphql::internal::MinorVersion == )cpp" headerFile << std::endl; } - if (!_loader.getInterfaceTypes().empty()) + if (_options.mergeFiles) { - if (objectNamespace.exit()) - { - headerFile << std::endl; - } - - // Forward declare all of the interface types - if (_loader.getInterfaceTypes().size() > 1) + if (!_loader.getInterfaceTypes().empty()) { + // Output the full declarations for (const auto& interfaceType : _loader.getInterfaceTypes()) { - headerFile << R"cpp(struct )cpp" << interfaceType.cppType << R"cpp(; -)cpp"; + outputInterfaceDeclaration(headerFile, interfaceType); + headerFile << std::endl; } - - headerFile << std::endl; } - // Output the full declarations - for (const auto& interfaceType : _loader.getInterfaceTypes()) + if (!_loader.getObjectTypes().empty()) { - headerFile << R"cpp(struct )cpp" << interfaceType.cppType << R"cpp( -{ -)cpp"; - - for (const auto& outputField : interfaceType.fields) + if (!_loader.isIntrospection()) { - headerFile << getFieldDeclaration(outputField); - } + objectNamespace.enter(); - headerFile << R"cpp(}; + NamespaceScope implementsNamespace { headerFile, R"cpp(implements)cpp", true }; -)cpp"; - } - } + for (const auto& objectType : _loader.getObjectTypes()) + { + if (objectType.interfaces.empty()) + { + continue; + } - if (!_loader.getObjectTypes().empty() && _options.mergeFiles) - { - if (!_loader.isIntrospection()) - { - objectNamespace.enter(); + if (implementsNamespace.enter()) + { + headerFile << std::endl; + } - NamespaceScope stubNamespace { headerFile, "methods", true }; + // Output the implements concept declarations + outputObjectImplements(headerFile, objectType); + } - // Output the stub concept declarations - for (const auto& objectType : _loader.getObjectTypes()) - { - if (!stubNamespace.enter()) + if (implementsNamespace.exit()) { headerFile << std::endl; } - std::ostringstream ossConceptNamespace; + NamespaceScope stubNamespace { headerFile, "methods", true }; - ossConceptNamespace << objectType.cppType << R"cpp(Method)cpp"; + // Output the stub concept declarations + for (const auto& objectType : _loader.getObjectTypes()) + { + if (!stubNamespace.enter()) + { + headerFile << std::endl; + } - const auto conceptNamespace = ossConceptNamespace.str(); - NamespaceScope conceptSubNamespace { headerFile, conceptNamespace }; + std::ostringstream ossConceptNamespace; - outputObjectStubs(headerFile, objectType); - } + ossConceptNamespace << objectType.cppType << R"cpp(Has)cpp"; - stubNamespace.exit(); - headerFile << std::endl; - } + const auto conceptNamespace = ossConceptNamespace.str(); + NamespaceScope conceptSubNamespace { headerFile, conceptNamespace }; - // Output the full declarations - for (const auto& objectType : _loader.getObjectTypes()) - { - outputObjectDeclaration(headerFile, objectType, objectType.type == queryType); - headerFile << std::endl; + outputObjectStubs(headerFile, objectType); + } + + stubNamespace.exit(); + headerFile << std::endl; + } + + // Output the full declarations + for (const auto& objectType : _loader.getObjectTypes()) + { + outputObjectDeclaration(headerFile, objectType, objectType.type == queryType); + headerFile << std::endl; + } } } @@ -455,18 +476,35 @@ static_assert(graphql::internal::MinorVersion == )cpp" )cpp"; } - if (!_loader.getObjectTypes().empty() && !_options.mergeFiles) + if (!_options.mergeFiles) { - for (const auto& objectType : _loader.getObjectTypes()) + if (!_loader.getInterfaceTypes().empty()) { - headerFile << R"cpp(void Add)cpp" << objectType.cppType - << R"cpp(Details(std::shared_ptr type)cpp" - << objectType.cppType - << R"cpp(, const std::shared_ptr& schema); + for (const auto& interfaceType : _loader.getInterfaceTypes()) + { + headerFile << R"cpp(void Add)cpp" << interfaceType.cppType + << R"cpp(Details(const std::shared_ptr& type)cpp" + << interfaceType.cppType + << R"cpp(, const std::shared_ptr& schema); )cpp"; + } + + headerFile << std::endl; } - headerFile << std::endl; + if (!_loader.getObjectTypes().empty()) + { + for (const auto& objectType : _loader.getObjectTypes()) + { + headerFile << R"cpp(void Add)cpp" << objectType.cppType + << R"cpp(Details(const std::shared_ptr& type)cpp" + << objectType.cppType + << R"cpp(, const std::shared_ptr& schema); +)cpp"; + } + + headerFile << std::endl; + } } if (_loader.isIntrospection()) @@ -534,104 +572,194 @@ GRAPHQLINTROSPECTION_EXPORT )cpp" return true; } -void Generator::outputObjectStubs(std::ostream& headerFile, const ObjectType& objectType) const +void Generator::outputInterfaceDeclaration( + std::ostream& headerFile, const InterfaceType& interfaceType) const { - if (!_loader.isIntrospection()) + headerFile + << R"cpp(class )cpp" << interfaceType.cppType << R"cpp( + : public service::Object +{ +private: + struct Concept { - for (const auto& outputField : objectType.fields) + virtual ~Concept() = default; + + virtual service::TypeNames getTypeNames() const noexcept = 0; + virtual service::ResolverMap getResolvers() const noexcept = 0; + + virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } { - std::string fieldName(outputField.cppName); + } - fieldName[0] = - static_cast(std::toupper(static_cast(fieldName[0]))); + service::TypeNames getTypeNames() const noexcept final + { + return _pimpl->getTypeNames(); + } - std::ostringstream ossPassedArguments; - bool firstArgument = true; + service::ResolverMap getResolvers() const noexcept final + { + return _pimpl->getResolvers(); + } - for (const auto& argument : outputField.arguments) - { - if (!firstArgument) - { - ossPassedArguments << R"cpp(, )cpp"; - } + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + _pimpl->beginSelectionSet(params); + } - ossPassedArguments << R"cpp(std::move()cpp" << argument.cppName << R"cpp(Arg))cpp"; - firstArgument = false; - } + void endSelectionSet(const service::SelectionSetParams& params) const final + { + _pimpl->endSelectionSet(params); + } - const auto passedArguments = ossPassedArguments.str(); + private: + const std::shared_ptr _pimpl; + }; - headerFile << R"cpp( -template -concept WithParams)cpp" << fieldName - << R"cpp( = requires (TImpl impl, service::FieldParams params)cpp"; - for (const auto& argument : outputField.arguments) + )cpp" + << interfaceType.cppType << R"cpp((std::unique_ptr&& pimpl) noexcept; + + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; + + const std::unique_ptr _pimpl; + +public: + template + )cpp" + << interfaceType.cppType << R"cpp((std::shared_ptr pimpl) noexcept + : )cpp" + << interfaceType.cppType + << R"cpp( { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } + { + static_assert(T::template implements<)cpp" + << interfaceType.cppType << R"cpp(>(), ")cpp" << interfaceType.cppType + << R"cpp( is not implemented"); + } +}; +)cpp"; +} + +void Generator::outputObjectImplements(std::ostream& headerFile, const ObjectType& objectType) const +{ + headerFile << R"cpp(template +concept )cpp" << objectType.cppType + << R"cpp(Is = )cpp"; + + bool firstInterface = true; + + for (auto interfaceName : objectType.interfaces) + { + if (!firstInterface) + { + headerFile << R"cpp( || )cpp"; + } + + headerFile << R"cpp(std::is_same_v)cpp"; + firstInterface = false; + } + + headerFile << R"cpp(; + +)cpp"; +} + +void Generator::outputObjectStubs(std::ostream& headerFile, const ObjectType& objectType) const +{ + for (const auto& outputField : objectType.fields) + { + std::string fieldName(outputField.cppName); + + fieldName[0] = static_cast(std::toupper(static_cast(fieldName[0]))); + + std::ostringstream ossPassedArguments; + bool firstArgument = true; + + for (const auto& argument : outputField.arguments) + { + if (!firstArgument) { - headerFile << R"cpp(, )cpp" << _loader.getInputCppType(argument) << R"cpp( )cpp" - << argument.cppName << R"cpp(Arg)cpp"; + ossPassedArguments << R"cpp(, )cpp"; } - headerFile << R"cpp() + ossPassedArguments << R"cpp(std::move()cpp" << argument.cppName << R"cpp(Arg))cpp"; + firstArgument = false; + } + + const auto passedArguments = ossPassedArguments.str(); + + headerFile << R"cpp( +template +concept )cpp" << outputField.accessor + << fieldName + << R"cpp(WithParams = requires (TImpl impl, service::FieldParams params)cpp"; + for (const auto& argument : outputField.arguments) + { + headerFile << R"cpp(, )cpp" << _loader.getInputCppType(argument) << R"cpp( )cpp" + << argument.cppName << R"cpp(Arg)cpp"; + } + + headerFile << R"cpp() { { service::FieldResult<)cpp" - << _loader.getOutputCppType(outputField) << R"cpp(> { impl.)cpp" - << outputField.accessor << fieldName << R"cpp((std::move(params))cpp"; + << _loader.getOutputCppType(outputField) << R"cpp(> { impl.)cpp" + << outputField.accessor << fieldName << R"cpp((std::move(params))cpp"; - if (!passedArguments.empty()) - { - headerFile << R"cpp(, )cpp" << passedArguments; - } + if (!passedArguments.empty()) + { + headerFile << R"cpp(, )cpp" << passedArguments; + } - headerFile << R"cpp() } }; + headerFile << R"cpp() } }; }; template -concept NoParams)cpp" << fieldName - << R"cpp( = requires (TImpl impl)cpp"; - for (const auto& argument : outputField.arguments) - { - headerFile << R"cpp(, )cpp" << _loader.getInputCppType(argument) << R"cpp( )cpp" - << argument.cppName << R"cpp(Arg)cpp"; - } +concept )cpp" << outputField.accessor + << fieldName << R"cpp( = requires (TImpl impl)cpp"; + for (const auto& argument : outputField.arguments) + { + headerFile << R"cpp(, )cpp" << _loader.getInputCppType(argument) << R"cpp( )cpp" + << argument.cppName << R"cpp(Arg)cpp"; + } - headerFile << R"cpp() + headerFile << R"cpp() { { service::FieldResult<)cpp" - << _loader.getOutputCppType(outputField) << R"cpp(> { impl.)cpp" - << outputField.accessor << fieldName << R"cpp(()cpp"; + << _loader.getOutputCppType(outputField) << R"cpp(> { impl.)cpp" + << outputField.accessor << fieldName << R"cpp(()cpp"; - if (!passedArguments.empty()) - { - headerFile << passedArguments; - } + if (!passedArguments.empty()) + { + headerFile << passedArguments; + } - headerFile << R"cpp() } }; + headerFile << R"cpp() } }; }; )cpp"; - } } - if (_loader.isIntrospection()) - { - headerFile << std::endl; - } - else - { - headerFile << R"cpp( + headerFile << R"cpp( template -concept HasBeginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.beginSelectionSet(params) }; }; template -concept HasEndSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) { { impl.endSelectionSet(params) }; }; )cpp"; - } } void Generator::outputObjectDeclaration( @@ -649,46 +777,21 @@ void Generator::outputObjectDeclaration( } headerFile << R"cpp( - service::AwaitableResolver resolve_typename(service::ResolverParams&& params); + service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; )cpp"; if (!_options.noIntrospection && isQueryType) { headerFile - << R"cpp( service::AwaitableResolver resolve_schema(service::ResolverParams&& params); - service::AwaitableResolver resolve_type(service::ResolverParams&& params); + << R"cpp( service::AwaitableResolver resolve_schema(service::ResolverParams&& params) const; + service::AwaitableResolver resolve_type(service::ResolverParams&& params) const; std::shared_ptr _schema; )cpp"; } headerFile << R"cpp( - struct Concept)cpp"; - - if (!objectType.interfaces.empty()) - { - bool firstInterface = true; - - for (const auto& interfaceName : objectType.interfaces) - { - headerFile << R"cpp( - )cpp"; - - if (firstInterface) - { - headerFile << R"cpp(: )cpp"; - firstInterface = false; - } - else - { - headerFile << R"cpp(, )cpp"; - } - - headerFile << _loader.getSafeCppName(interfaceName); - } - } - - headerFile << R"cpp( + struct Concept { virtual ~Concept() = default; @@ -705,11 +808,6 @@ void Generator::outputObjectDeclaration( for (const auto& outputField : objectType.fields) { - if (outputField.inheritedField) - { - continue; - } - headerFile << R"cpp( )cpp" << getFieldDeclaration(outputField); } @@ -782,7 +880,8 @@ void Generator::outputObjectDeclaration( else { headerFile << R"cpp(if constexpr (methods::)cpp" << objectType.cppType - << R"cpp(Method::WithParams)cpp" << fieldName << R"cpp() + << R"cpp(Has::)cpp" << outputField.accessor << fieldName + << R"cpp(WithParams) { return { _pimpl->)cpp" << outputField.accessor << fieldName << R"cpp((std::move(params))cpp"; @@ -801,15 +900,15 @@ void Generator::outputObjectDeclaration( headerFile << R"cpp( { static_assert(methods::)cpp" - << objectType.cppType << R"cpp(Method::NoParams)cpp" << fieldName - << R"cpp(, R"msg()cpp" << objectType.cppType << R"cpp(::)cpp" - << outputField.accessor << fieldName + << objectType.cppType << R"cpp(Has::)cpp" << outputField.accessor + << fieldName << R"cpp(, R"msg()cpp" << objectType.cppType + << R"cpp(::)cpp" << outputField.accessor << fieldName << R"cpp( is not implemented)msg");)cpp"; } else { headerFile << R"cpp( if constexpr (methods::)cpp" << objectType.cppType - << R"cpp(Method::NoParams)cpp" << fieldName << R"cpp() + << R"cpp(Has::)cpp" << outputField.accessor << fieldName << R"cpp() {)cpp"; } @@ -848,7 +947,7 @@ void Generator::outputObjectDeclaration( void beginSelectionSet(const service::SelectionSetParams& params) const final { if constexpr (methods::)cpp" - << objectType.cppType << R"cpp(Method::HasBeginSelectionSet) + << objectType.cppType << R"cpp(Has::beginSelectionSet) { _pimpl->beginSelectionSet(params); } @@ -857,7 +956,7 @@ void Generator::outputObjectDeclaration( void endSelectionSet(const service::SelectionSetParams& params) const final { if constexpr (methods::)cpp" - << objectType.cppType << R"cpp(Method::HasEndSelectionSet) + << objectType.cppType << R"cpp(Has::endSelectionSet) { _pimpl->endSelectionSet(params); } @@ -870,17 +969,20 @@ void Generator::outputObjectDeclaration( const std::shared_ptr _pimpl; }; - )cpp"; +)cpp"; if (_loader.isIntrospection()) { - headerFile << R"cpp(const std::unique_ptr _pimpl; + headerFile << R"cpp( const std::unique_ptr _pimpl; + + service::TypeNames getTypeNames() const noexcept; + service::ResolverMap getResolvers() const noexcept; public: GRAPHQLINTROSPECTION_EXPORT )cpp" << objectType.cppType << R"cpp((std::shared_ptr<)cpp" << SchemaLoader::getIntrospectionNamespace() << R"cpp(::)cpp" - << objectType.cppType << R"cpp(> pimpl); + << objectType.cppType << R"cpp(> pimpl) noexcept; GRAPHQLINTROSPECTION_EXPORT ~)cpp" << objectType.cppType << R"cpp((); }; @@ -888,8 +990,36 @@ void Generator::outputObjectDeclaration( } else { + headerFile << R"cpp( )cpp" << objectType.cppType + << R"cpp((std::unique_ptr&& pimpl) noexcept; + +)cpp"; + + if (!objectType.interfaces.empty()) + { + headerFile << R"cpp( // Interface objects need access to these methods +)cpp"; + + for (auto interfaceName : objectType.interfaces) + { + headerFile << R"cpp( friend )cpp" << interfaceName << R"cpp(; +)cpp"; + } + + headerFile << R"cpp( + template + static constexpr bool implements() noexcept + { + return implements::)cpp" + << objectType.cppType << R"cpp(Is; + } + +)cpp"; + } + headerFile - << objectType.cppType << R"cpp((std::unique_ptr&& pimpl); + << R"cpp( service::TypeNames getTypeNames() const noexcept; + service::ResolverMap getResolvers() const noexcept; void beginSelectionSet(const service::SelectionSetParams& params) const final; void endSelectionSet(const service::SelectionSetParams& params) const final; @@ -899,7 +1029,7 @@ void Generator::outputObjectDeclaration( public: template )cpp" << objectType.cppType - << R"cpp((std::shared_ptr pimpl) + << R"cpp((std::shared_ptr pimpl) noexcept : )cpp" << objectType.cppType << R"cpp( { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } @@ -948,7 +1078,7 @@ std::string Generator::getResolverDeclaration(const OutputField& outputField) co fieldName[0] = static_cast(std::toupper(static_cast(fieldName[0]))); output << R"cpp( service::AwaitableResolver resolve)cpp" << fieldName - << R"cpp((service::ResolverParams&& params); + << R"cpp((service::ResolverParams&& params) const; )cpp"; return output.str(); @@ -1171,14 +1301,28 @@ service::AwaitableResolver ModifiedResult<)cpp" } } - if (!_loader.getObjectTypes().empty() && _options.mergeFiles) + if (_options.mergeFiles) { - NamespaceScope objectNamespace { sourceFile, "object" }; + NamespaceScope objectNamespace { sourceFile, "object", true }; - sourceFile << std::endl; + for (const auto& interfaceType : _loader.getInterfaceTypes()) + { + if (objectNamespace.enter()) + { + sourceFile << std::endl; + } + + outputInterfaceImplementation(sourceFile, interfaceType); + sourceFile << std::endl; + } for (const auto& objectType : _loader.getObjectTypes()) { + if (objectNamespace.enter()) + { + sourceFile << std::endl; + } + outputObjectImplementation(sourceFile, objectType, objectType.type == queryType); sourceFile << std::endl; } @@ -1495,7 +1639,8 @@ Operations::Operations()cpp"; { bool firstValue = true; - sourceFile << R"cpp( type)cpp" << unionType.cppType << R"cpp(->AddPossibleTypes({ + sourceFile << R"cpp( type)cpp" << unionType.cppType + << R"cpp(->AddPossibleTypes({ )cpp"; for (const auto& unionOption : unionType.options) @@ -1522,89 +1667,20 @@ Operations::Operations()cpp"; { sourceFile << std::endl; - for (const auto& interfaceType : _loader.getInterfaceTypes()) - { - if (!interfaceType.fields.empty()) - { - bool firstValue = true; - - sourceFile << R"cpp( type)cpp" << interfaceType.cppType << R"cpp(->AddFields({ -)cpp"; - - for (const auto& interfaceField : interfaceType.fields) - { - if (!firstValue) - { - sourceFile << R"cpp(, -)cpp"; - } - - firstValue = false; - sourceFile << R"cpp( schema::Field::Make(R"gql()cpp" - << interfaceField.name << R"cpp()gql"sv, R"md()cpp"; - - if (!_options.noIntrospection) - { - sourceFile << interfaceField.description; - } - - sourceFile << R"cpp()md"sv, )cpp"; - - if (interfaceField.deprecationReason) - { - sourceFile << R"cpp(std::make_optional(R"md()cpp" - << *interfaceField.deprecationReason << R"cpp()md"sv))cpp"; - } - else - { - sourceFile << R"cpp(std::nullopt)cpp"; - } - - sourceFile << R"cpp(, )cpp" - << getIntrospectionType(interfaceField.type, - interfaceField.modifiers); - - if (!interfaceField.arguments.empty()) - { - bool firstArgument = true; - - sourceFile << R"cpp(, { -)cpp"; - - for (const auto& argument : interfaceField.arguments) - { - if (!firstArgument) - { - sourceFile << R"cpp(, -)cpp"; - } - - firstArgument = false; - sourceFile << R"cpp( schema::InputValue::Make(R"gql()cpp" - << argument.name << R"cpp()gql"sv, R"md()cpp"; - - if (!_options.noIntrospection) - { - sourceFile << argument.description; - } - - sourceFile << R"cpp()md"sv, )cpp" - << getIntrospectionType(argument.type, argument.modifiers) - << R"cpp(, R"gql()cpp" << argument.defaultValueString - << R"cpp()gql"sv))cpp"; - } - - sourceFile << R"cpp( - })cpp"; - } - - sourceFile << R"cpp())cpp"; - } - - sourceFile << R"cpp( - }); + const std::vector emptyInterfaces {}; + + for (const auto& interfaceType : _loader.getInterfaceTypes()) + { + if (!_options.mergeFiles) + { + sourceFile << R"cpp( Add)cpp" << interfaceType.cppType << R"cpp(Details(type)cpp" + << interfaceType.cppType << R"cpp(, schema); )cpp"; } + else + { + outputInterfaceIntrospection(sourceFile, interfaceType); + } } } @@ -1753,6 +1829,41 @@ Operations::Operations()cpp"; return true; } +void Generator::outputInterfaceImplementation( + std::ostream& sourceFile, const InterfaceType& interfaceType) const +{ + // Output the private constructor which calls through to the service::Object constructor + // with arguments that declare the set of types it implements and bind the fields to the + // resolver methods. + sourceFile << interfaceType.cppType << R"cpp(::)cpp" << interfaceType.cppType + << R"cpp((std::unique_ptr&& pimpl) noexcept + : service::Object { pimpl->getTypeNames(), pimpl->getResolvers() } + , _pimpl { std::move(pimpl) } +{ +} +)cpp"; + + sourceFile << R"cpp( +void )cpp" << interfaceType.cppType + << R"cpp(::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void )cpp" << interfaceType.cppType + << R"cpp(::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} +)cpp"; +} + +void Generator::outputInterfaceIntrospection( + std::ostream& sourceFile, const InterfaceType& interfaceType) const +{ + outputIntrospectionFields(sourceFile, interfaceType.cppType, interfaceType.fields); +} + void Generator::outputObjectImplementation( std::ostream& sourceFile, const ObjectType& objectType, bool isQueryType) const { @@ -1765,9 +1876,7 @@ void Generator::outputObjectImplementation( // resolver methods. sourceFile << objectType.cppType << R"cpp(::)cpp" << objectType.cppType << R"cpp((std::shared_ptr<)cpp" << SchemaLoader::getIntrospectionNamespace() - << R"cpp(::)cpp" << objectType.cppType << R"cpp(> pimpl) - : service::Object({ -)cpp"; + << R"cpp(::)cpp" << objectType.cppType << R"cpp(> pimpl))cpp"; } else { @@ -1775,11 +1884,54 @@ void Generator::outputObjectImplementation( // with arguments that declare the set of types it implements and bind the fields to the // resolver methods. sourceFile << objectType.cppType << R"cpp(::)cpp" << objectType.cppType - << R"cpp((std::unique_ptr&& pimpl) - : service::Object({ + << R"cpp((std::unique_ptr&& pimpl))cpp"; + } + + sourceFile << R"cpp( noexcept + : service::Object{ getTypeNames(), getResolvers() })cpp"; + + if (!_options.noIntrospection && isQueryType) + { + sourceFile << R"cpp( + , _schema { GetSchema() })cpp"; + } + + if (_loader.isIntrospection()) + { + sourceFile << R"cpp( + , _pimpl { std::make_unique>(std::move(pimpl)) })cpp"; + } + else + { + sourceFile << R"cpp( + , _pimpl { std::move(pimpl) })cpp"; + } + sourceFile << R"cpp( +{ +} +)cpp"; + + if (_loader.isIntrospection()) + { + sourceFile << R"cpp( +)cpp" << objectType.cppType + << R"cpp(::~)cpp" << objectType.cppType << R"cpp(() +{ + // This is empty, but explicitly defined here so that it can access the un-exported destructor + // of the implementation type. +} )cpp"; } + sourceFile << R"cpp( +service::TypeNames )cpp" + << objectType.cppType << R"cpp(::getTypeNames() const noexcept +{ + return { +)cpp"; + for (const auto& interfaceName : objectType.interfaces) { sourceFile << R"cpp( ")cpp" << interfaceName << R"cpp(", @@ -1793,7 +1945,13 @@ void Generator::outputObjectImplementation( } sourceFile << R"cpp( ")cpp" << objectType.type << R"cpp(" - }, { + }; +} + +service::ResolverMap )cpp" + << objectType.cppType << R"cpp(::getResolvers() const noexcept +{ + return { )cpp"; std::map resolvers; @@ -1842,43 +2000,11 @@ void Generator::outputObjectImplementation( } sourceFile << R"cpp( - }))cpp"; - - if (!_options.noIntrospection && isQueryType) - { - sourceFile << R"cpp( - , _schema(GetSchema()))cpp"; - } - - if (_loader.isIntrospection()) - { - sourceFile << R"cpp( - , _pimpl(std::make_unique>(std::move(pimpl))))cpp"; - } - else - { - sourceFile << R"cpp( - , _pimpl(std::move(pimpl)))cpp"; - } - sourceFile << R"cpp( -{ + }; } )cpp"; - if (_loader.isIntrospection()) - { - sourceFile << R"cpp( -)cpp" << objectType.cppType - << R"cpp(::~)cpp" << objectType.cppType << R"cpp(() -{ - // This is empty, but explicitly defined here so that it can access the un-exported destructor - // of the implementation type. -} -)cpp"; - } - else + if (!_loader.isIntrospection()) { sourceFile << R"cpp( void )cpp" << objectType.cppType @@ -1906,7 +2032,7 @@ void )cpp" << objectType.cppType sourceFile << R"cpp( service::AwaitableResolver )cpp" << objectType.cppType << R"cpp(::resolve)cpp" << fieldName - << R"cpp((service::ResolverParams&& params) + << R"cpp((service::ResolverParams&& params) const { )cpp"; @@ -1986,7 +2112,8 @@ service::AwaitableResolver )cpp" sourceFile << R"cpp( service::AwaitableResolver )cpp" - << objectType.cppType << R"cpp(::resolve_typename(service::ResolverParams&& params) + << objectType.cppType + << R"cpp(::resolve_typename(service::ResolverParams&& params) const { return service::ModifiedResult::convert(std::string{ R"gql()cpp" << objectType.type << R"cpp()gql" }, std::move(params)); @@ -1998,7 +2125,7 @@ service::AwaitableResolver )cpp" sourceFile << R"cpp( service::AwaitableResolver )cpp" - << objectType.cppType << R"cpp(::resolve_schema(service::ResolverParams&& params) + << objectType.cppType << R"cpp(::resolve_schema(service::ResolverParams&& params) const { return service::ModifiedResult::convert(std::static_pointer_cast(std::make_shared<)cpp" << SchemaLoader::getIntrospectionNamespace() @@ -2008,7 +2135,7 @@ service::AwaitableResolver )cpp" } service::AwaitableResolver )cpp" - << objectType.cppType << R"cpp(::resolve_type(service::ResolverParams&& params) + << objectType.cppType << R"cpp(::resolve_type(service::ResolverParams&& params) const { auto argName = service::ModifiedArgument::require("name", params.arguments); const auto& baseType = _schema->LookupType(argName); @@ -2064,86 +2191,94 @@ void Generator::outputObjectIntrospection( )cpp"; } - if (!objectType.fields.empty()) + outputIntrospectionFields(sourceFile, objectType.cppType, objectType.fields); +} + +void Generator::outputIntrospectionFields( + std::ostream& sourceFile, std::string_view cppType, const OutputFieldList& fields) const +{ + if (fields.empty()) { - bool firstValue = true; + return; + } + + bool firstValue = true; - sourceFile << R"cpp( type)cpp" << objectType.cppType << R"cpp(->AddFields({ + sourceFile << R"cpp( type)cpp" << cppType << R"cpp(->AddFields({ )cpp"; - for (const auto& objectField : objectType.fields) + for (const auto& objectField : fields) + { + if (!firstValue) { - if (!firstValue) - { - sourceFile << R"cpp(, + sourceFile << R"cpp(, )cpp"; - } + } - firstValue = false; - sourceFile << R"cpp( schema::Field::Make(R"gql()cpp" << objectField.name - << R"cpp()gql"sv, R"md()cpp"; + firstValue = false; + sourceFile << R"cpp( schema::Field::Make(R"gql()cpp" << objectField.name + << R"cpp()gql"sv, R"md()cpp"; - if (!_options.noIntrospection) - { - sourceFile << objectField.description; - } + if (!_options.noIntrospection) + { + sourceFile << objectField.description; + } - sourceFile << R"cpp()md"sv, )cpp"; + sourceFile << R"cpp()md"sv, )cpp"; - if (objectField.deprecationReason) - { - sourceFile << R"cpp(std::make_optional(R"md()cpp" << *objectField.deprecationReason - << R"cpp()md"sv))cpp"; - } - else - { - sourceFile << R"cpp(std::nullopt)cpp"; - } + if (objectField.deprecationReason) + { + sourceFile << R"cpp(std::make_optional(R"md()cpp" << *objectField.deprecationReason + << R"cpp()md"sv))cpp"; + } + else + { + sourceFile << R"cpp(std::nullopt)cpp"; + } - sourceFile << R"cpp(, )cpp" - << getIntrospectionType(objectField.type, objectField.modifiers); + sourceFile << R"cpp(, )cpp" + << getIntrospectionType(objectField.type, objectField.modifiers); - if (!objectField.arguments.empty()) - { - bool firstArgument = true; + if (!objectField.arguments.empty()) + { + bool firstArgument = true; - sourceFile << R"cpp(, { + sourceFile << R"cpp(, { )cpp"; - for (const auto& argument : objectField.arguments) + for (const auto& argument : objectField.arguments) + { + if (!firstArgument) { - if (!firstArgument) - { - sourceFile << R"cpp(, + sourceFile << R"cpp(, )cpp"; - } - - firstArgument = false; - sourceFile << R"cpp( schema::InputValue::Make(R"gql()cpp" - << argument.name << R"cpp()gql"sv, R"md()cpp"; + } - if (!_options.noIntrospection) - { - sourceFile << argument.description; - } + firstArgument = false; + sourceFile << R"cpp( schema::InputValue::Make(R"gql()cpp" + << argument.name << R"cpp()gql"sv, R"md()cpp"; - sourceFile << R"cpp()md"sv, )cpp" - << getIntrospectionType(argument.type, argument.modifiers) - << R"cpp(, R"gql()cpp" << argument.defaultValueString - << R"cpp()gql"sv))cpp"; + if (!_options.noIntrospection) + { + sourceFile << argument.description; } - sourceFile << R"cpp( - })cpp"; + sourceFile << R"cpp()md"sv, )cpp" + << getIntrospectionType(argument.type, argument.modifiers) + << R"cpp(, R"gql()cpp" << argument.defaultValueString + << R"cpp()gql"sv))cpp"; } - sourceFile << R"cpp())cpp"; + sourceFile << R"cpp( + })cpp"; } - sourceFile << R"cpp( + sourceFile << R"cpp())cpp"; + } + + sourceFile << R"cpp( }); )cpp"; - } } std::string Generator::getArgumentDefaultValue( @@ -2353,6 +2488,7 @@ std::string Generator::getResultAccessType(const OutputField& result) const noex case OutputFieldType::Builtin: case OutputFieldType::Enum: case OutputFieldType::Object: + case OutputFieldType::Interface: resultType << _loader.getCppType(result.type); break; @@ -2361,7 +2497,6 @@ std::string Generator::getResultAccessType(const OutputField& result) const noex break; case OutputFieldType::Union: - case OutputFieldType::Interface: resultType << R"cpp(service::Object)cpp"; break; } @@ -2486,9 +2621,9 @@ std::string Generator::getIntrospectionType( std::vector Generator::outputSeparateFiles() const noexcept { - std::vector files; const fs::path headerDir(_headerDir); const fs::path sourceDir(_sourceDir); + std::vector files; std::string_view queryType; for (const auto& operation : _loader.getOperationTypes()) @@ -2510,6 +2645,14 @@ std::vector Generator::outputSeparateFiles() const noexcept )cpp"; + for (const auto& interfaceType : _loader.getInterfaceTypes()) + { + const auto headerFilename = std::string(interfaceType.cppType) + "Object.h"; + + objectHeaderFile << R"cpp(#include ")cpp" << headerFilename << R"cpp(" +)cpp"; + } + for (const auto& objectType : _loader.getObjectTypes()) { const auto headerFilename = std::string(objectType.cppType) + "Object.h"; @@ -2523,13 +2666,91 @@ std::vector Generator::outputSeparateFiles() const noexcept files.push_back({ _objectHeaderPath }); } - for (const auto& objectType : _loader.getObjectTypes()) + const std::vector emptyInterfacesAndUnions {}; + + for (const auto& interfaceType : _loader.getInterfaceTypes()) { + const auto headerFilename = std::string(interfaceType.cppType) + "Object.h"; + auto headerPath = (headerDir / headerFilename).string(); + std::ofstream headerFile(headerPath, std::ios_base::trunc); + IncludeGuardScope includeGuard { headerFile, headerFilename }; + + headerFile << R"cpp(#include ")cpp" << fs::path(_headerPath).filename().string() << R"cpp(" + +)cpp"; + std::ostringstream ossNamespace; ossNamespace << R"cpp(graphql::)cpp" << _loader.getSchemaNamespace(); const auto schemaNamespace = ossNamespace.str(); + std::ostringstream ossInterfaceNamespace; + + ossInterfaceNamespace << schemaNamespace << R"cpp(::object)cpp"; + + const auto objectNamespace = ossInterfaceNamespace.str(); + NamespaceScope headerNamespace { headerFile, objectNamespace }; + + // Output the full declaration + headerFile << std::endl; + outputInterfaceDeclaration(headerFile, interfaceType); + headerFile << std::endl; + + if (_options.verbose) + { + files.push_back(std::move(headerPath)); + } + + const auto sourceFilename = std::string(interfaceType.cppType) + "Object.cpp"; + auto sourcePath = (sourceDir / sourceFilename).string(); + std::ofstream sourceFile(sourcePath, std::ios_base::trunc); + + sourceFile << R"cpp(// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// WARNING! Do not edit this file manually, your changes will be overwritten. + +#include ")cpp" << fs::path(_objectHeaderPath).filename().string() + << R"cpp(" + +#include "graphqlservice/introspection/Introspection.h" + +#include +#include +#include +#include +#include + +using namespace std::literals; + +)cpp"; + + NamespaceScope sourceSchemaNamespace { sourceFile, schemaNamespace }; + NamespaceScope sourceInterfaceNamespace { sourceFile, "object" }; + + sourceFile << std::endl; + outputInterfaceImplementation(sourceFile, interfaceType); + sourceFile << std::endl; + + sourceInterfaceNamespace.exit(); + sourceFile << std::endl; + + sourceFile << R"cpp(void Add)cpp" << interfaceType.cppType + << R"cpp(Details(const std::shared_ptr& type)cpp" + << interfaceType.cppType + << R"cpp(, const std::shared_ptr& schema) +{ +)cpp"; + outputInterfaceIntrospection(sourceFile, interfaceType); + sourceFile << R"cpp(} + +)cpp"; + + files.push_back(std::move(sourcePath)); + } + + for (const auto& objectType : _loader.getObjectTypes()) + { const bool isQueryType = objectType.type == queryType; const auto headerFilename = std::string(objectType.cppType) + "Object.h"; auto headerPath = (headerDir / headerFilename).string(); @@ -2540,6 +2761,22 @@ std::vector Generator::outputSeparateFiles() const noexcept )cpp"; + if (!objectType.interfaces.empty()) + { + for (auto interfaceName : objectType.interfaces) + { + headerFile << R"cpp(#include ")cpp" << interfaceName << R"cpp(Object.h" +)cpp"; + } + + headerFile << std::endl; + } + + std::ostringstream ossNamespace; + + ossNamespace << R"cpp(graphql::)cpp" << _loader.getSchemaNamespace(); + + const auto schemaNamespace = ossNamespace.str(); std::ostringstream ossObjectNamespace; ossObjectNamespace << schemaNamespace << R"cpp(::object)cpp"; @@ -2547,10 +2784,21 @@ std::vector Generator::outputSeparateFiles() const noexcept const auto objectNamespace = ossObjectNamespace.str(); NamespaceScope headerNamespace { headerFile, objectNamespace }; + if (!objectType.interfaces.empty()) + { + NamespaceScope implementsNamespace { headerFile, R"cpp(implements)cpp" }; + + headerFile << std::endl; + outputObjectImplements(headerFile, objectType); + + implementsNamespace.exit(); + headerFile << std::endl; + } + // Output the stub concepts std::ostringstream ossConceptNamespace; - ossConceptNamespace << R"cpp(methods::)cpp" << objectType.cppType << R"cpp(Method)cpp"; + ossConceptNamespace << R"cpp(methods::)cpp" << objectType.cppType << R"cpp(Has)cpp"; const auto conceptNamespace = ossConceptNamespace.str(); NamespaceScope stubNamespace { headerFile, conceptNamespace }; @@ -2603,7 +2851,7 @@ using namespace std::literals; sourceFile << std::endl; sourceFile << R"cpp(void Add)cpp" << objectType.cppType - << R"cpp(Details(std::shared_ptr type)cpp" + << R"cpp(Details(const std::shared_ptr& type)cpp" << objectType.cppType << R"cpp(, const std::shared_ptr& schema) { )cpp"; diff --git a/src/SchemaLoader.cpp b/src/SchemaLoader.cpp index f82768b9..ae465e45 100644 --- a/src/SchemaLoader.cpp +++ b/src/SchemaLoader.cpp @@ -1446,16 +1446,11 @@ std::string SchemaLoader::getOutputCppType(const OutputField& field) const noexc break; case OutputFieldType::Object: - if (field.interfaceField) - { - outputType << R"cpp(object::)cpp"; - } - + case OutputFieldType::Interface: outputType << getSafeCppName(field.type); break; case OutputFieldType::Union: - case OutputFieldType::Interface: outputType << R"cpp(service::Object)cpp"; break; } diff --git a/test/TodayTests.cpp b/test/TodayTests.cpp index c4a1bbf1..b47633ea 100644 --- a/test/TodayTests.cpp +++ b/test/TodayTests.cpp @@ -675,8 +675,7 @@ TEST_F(TodayServiceCase, SubscribeNextAppointmentChangeOverride) result = std::move(response); }); _service->deliver("nextAppointmentChange", - std::static_pointer_cast( - std::make_shared(std::move(subscriptionObject)))); + std::make_shared(std::move(subscriptionObject))); _service->unsubscribe(key); try @@ -1193,11 +1192,11 @@ TEST_F(TodayServiceCase, SubscribeNodeChangeMatchingId) auto state = std::make_shared(13); auto subscriptionObject = std::make_shared( [this](const std::shared_ptr& state, - response::IdType&& idArg) -> std::shared_ptr { + response::IdType&& idArg) -> std::shared_ptr { EXPECT_EQ(13, std::static_pointer_cast(state)->requestId) << "should pass the RequestState to the subscription resolvers"; EXPECT_EQ(_fakeTaskId, idArg); - return std::static_pointer_cast(std::make_shared( + return std::make_shared(std::make_shared( std::make_shared(response::IdType(_fakeTaskId), "Don't forget", true))); @@ -1212,8 +1211,7 @@ TEST_F(TodayServiceCase, SubscribeNodeChangeMatchingId) }); _service->deliver("nodeChange", { { "id", response::Value(std::string("ZmFrZVRhc2tJZA==")) } }, - std::static_pointer_cast( - std::make_shared(std::move(subscriptionObject)))); + std::make_shared(std::move(subscriptionObject))); _service->unsubscribe(key); try @@ -1255,7 +1253,7 @@ TEST_F(TodayServiceCase, SubscribeNodeChangeMismatchedId) bool calledResolver = false; auto subscriptionObject = std::make_shared( [this, &calledResolver](const std::shared_ptr& state, - response::IdType&& idArg) -> std::shared_ptr { + response::IdType&& idArg) -> std::shared_ptr { calledResolver = true; return nullptr; }); @@ -1269,8 +1267,7 @@ TEST_F(TodayServiceCase, SubscribeNodeChangeMismatchedId) }); _service->deliver("nodeChange", { { "id", response::Value(std::string("ZmFrZUFwcG9pbnRtZW50SWQ=")) } }, - std::static_pointer_cast( - std::make_shared(std::move(subscriptionObject)))); + std::make_shared(std::move(subscriptionObject))); _service->unsubscribe(key); try @@ -1308,13 +1305,13 @@ TEST_F(TodayServiceCase, SubscribeNodeChangeFuzzyComparator) }; auto subscriptionObject = std::make_shared( [this](const std::shared_ptr& state, - response::IdType&& idArg) -> std::shared_ptr { + response::IdType&& idArg) -> std::shared_ptr { const response::IdType fuzzyId { 'f', 'a', 'k' }; EXPECT_EQ(14, std::static_pointer_cast(state)->requestId) << "should pass the RequestState to the subscription resolvers"; EXPECT_EQ(fuzzyId, idArg); - return std::static_pointer_cast(std::make_shared( + return std::make_shared(std::make_shared( std::make_shared(response::IdType(_fakeTaskId), "Don't forget", true))); @@ -1329,8 +1326,7 @@ TEST_F(TodayServiceCase, SubscribeNodeChangeFuzzyComparator) }); _service->deliver("nodeChange", filterCallback, - std::static_pointer_cast( - std::make_shared(std::move(subscriptionObject)))); + std::make_shared(std::move(subscriptionObject))); _service->unsubscribe(key); try @@ -1382,7 +1378,7 @@ TEST_F(TodayServiceCase, SubscribeNodeChangeFuzzyMismatch) bool calledResolver = false; auto subscriptionObject = std::make_shared( [this, &calledResolver](const std::shared_ptr& state, - response::IdType&& idArg) -> std::shared_ptr { + response::IdType&& idArg) -> std::shared_ptr { calledResolver = true; return nullptr; }); @@ -1396,8 +1392,7 @@ TEST_F(TodayServiceCase, SubscribeNodeChangeFuzzyMismatch) }); _service->deliver("nodeChange", filterCallback, - std::static_pointer_cast( - std::make_shared(std::move(subscriptionObject)))); + std::make_shared(std::move(subscriptionObject))); _service->unsubscribe(key); try @@ -1428,11 +1423,11 @@ TEST_F(TodayServiceCase, SubscribeNodeChangeMatchingVariable) auto state = std::make_shared(14); auto subscriptionObject = std::make_shared( [this](const std::shared_ptr& state, - response::IdType&& idArg) -> std::shared_ptr { + response::IdType&& idArg) -> std::shared_ptr { EXPECT_EQ(14, std::static_pointer_cast(state)->requestId) << "should pass the RequestState to the subscription resolvers"; EXPECT_EQ(_fakeTaskId, idArg); - return std::static_pointer_cast(std::make_shared( + return std::make_shared(std::make_shared( std::make_shared(response::IdType(_fakeTaskId), "Don't forget", true))); @@ -1447,8 +1442,7 @@ TEST_F(TodayServiceCase, SubscribeNodeChangeMatchingVariable) }); _service->deliver("nodeChange", { { "id", response::Value(std::string("ZmFrZVRhc2tJZA==")) } }, - std::static_pointer_cast( - std::make_shared(std::move(subscriptionObject)))); + std::make_shared(std::move(subscriptionObject))); _service->unsubscribe(key); try From b2afbafd77263302700f35ca1213cccdfe6815c1 Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Wed, 8 Dec 2021 13:29:23 -0800 Subject: [PATCH 058/119] Add make_hero utility functions to learn sample --- samples/learn/CMakeLists.txt | 1 + samples/learn/DroidData.cpp | 19 +------------- samples/learn/HeroData.cpp | 49 ++++++++++++++++++++++++++++++++++++ samples/learn/HeroData.h | 9 +++++++ samples/learn/HumanData.cpp | 19 +------------- samples/learn/QueryData.cpp | 17 +------------ 6 files changed, 62 insertions(+), 52 deletions(-) create mode 100644 samples/learn/HeroData.cpp diff --git a/samples/learn/CMakeLists.txt b/samples/learn/CMakeLists.txt index 1821b10b..cda78c75 100644 --- a/samples/learn/CMakeLists.txt +++ b/samples/learn/CMakeLists.txt @@ -5,6 +5,7 @@ cmake_minimum_required(VERSION 3.15) add_subdirectory(schema) add_library(star_wars STATIC + HeroData.cpp DroidData.cpp HumanData.cpp QueryData.cpp diff --git a/samples/learn/DroidData.cpp b/samples/learn/DroidData.cpp index f1654aec..79793c21 100644 --- a/samples/learn/DroidData.cpp +++ b/samples/learn/DroidData.cpp @@ -1,8 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -#include "CharacterObject.h" - #include "DroidData.h" #include "HumanData.h" @@ -55,22 +53,7 @@ std::optional>> Droid::getFriends friends_.end(), result.begin(), [](const auto& wpFriend) noexcept { - return std::visit( - [](const auto& hero) noexcept { - using hero_t = std::decay_t; - - if constexpr (std::is_same_v, hero_t>) - { - return std::make_shared( - std::make_shared(hero.lock())); - } - else if constexpr (std::is_same_v, hero_t>) - { - return std::make_shared( - std::make_shared(hero.lock())); - } - }, - wpFriend); + return make_hero(wpFriend); }); result.erase(std::remove_if(result.begin(), result.end(), diff --git a/samples/learn/HeroData.cpp b/samples/learn/HeroData.cpp new file mode 100644 index 00000000..2b2c68ce --- /dev/null +++ b/samples/learn/HeroData.cpp @@ -0,0 +1,49 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +#include "HeroData.h" + +#include "DroidData.h" +#include "HumanData.h" + +namespace graphql::learn { + +std::shared_ptr make_hero(const SharedHero& hero) noexcept +{ + return std::visit( + [](const auto& hero) noexcept { + using hero_t = std::decay_t; + + if constexpr (std::is_same_v, hero_t>) + { + return std::make_shared(std::make_shared(hero)); + } + else if constexpr (std::is_same_v, hero_t>) + { + return std::make_shared(std::make_shared(hero)); + } + }, + hero); +} + +std::shared_ptr make_hero(const WeakHero& hero) noexcept +{ + return std::visit( + [](const auto& hero) noexcept { + using hero_t = std::decay_t; + + if constexpr (std::is_same_v, hero_t>) + { + return std::make_shared( + std::make_shared(hero.lock())); + } + else if constexpr (std::is_same_v, hero_t>) + { + return std::make_shared( + std::make_shared(hero.lock())); + } + }, + hero); +} + +} // namespace graphql::learn diff --git a/samples/learn/HeroData.h b/samples/learn/HeroData.h index 849929ff..0681905a 100644 --- a/samples/learn/HeroData.h +++ b/samples/learn/HeroData.h @@ -17,6 +17,15 @@ class Human; using SharedHero = std::variant, std::shared_ptr>; using WeakHero = std::variant, std::weak_ptr>; +namespace object { + +class Character; + +} // namespace object + +std::shared_ptr make_hero(const SharedHero& hero) noexcept; +std::shared_ptr make_hero(const WeakHero& hero) noexcept; + } // namespace graphql::learn #endif // HERODATA_H diff --git a/samples/learn/HumanData.cpp b/samples/learn/HumanData.cpp index 7ba4f0f1..5364e115 100644 --- a/samples/learn/HumanData.cpp +++ b/samples/learn/HumanData.cpp @@ -1,8 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -#include "CharacterObject.h" - #include "HumanData.h" #include "DroidData.h" @@ -54,22 +52,7 @@ std::optional>> Human::getFriends friends_.end(), result.begin(), [](const auto& wpFriend) noexcept { - return std::visit( - [](const auto& hero) noexcept { - using hero_t = std::decay_t; - - if constexpr (std::is_same_v, hero_t>) - { - return std::make_shared( - std::make_shared(hero.lock())); - } - else if constexpr (std::is_same_v, hero_t>) - { - return std::make_shared( - std::make_shared(hero.lock())); - } - }, - wpFriend); + return make_hero(wpFriend); }); result.erase(std::remove_if(result.begin(), result.end(), diff --git a/samples/learn/QueryData.cpp b/samples/learn/QueryData.cpp index 8b25efa6..eb6dec9a 100644 --- a/samples/learn/QueryData.cpp +++ b/samples/learn/QueryData.cpp @@ -23,22 +23,7 @@ std::shared_ptr Query::getHero(std::optional episode if (const auto itr = heroes_.find(episode); itr != heroes_.end()) { - result = std::visit( - [](const auto& hero) noexcept { - using hero_t = std::decay_t; - - if constexpr (std::is_same_v, hero_t>) - { - return std::make_shared( - std::make_shared(hero)); - } - else if constexpr (std::is_same_v, hero_t>) - { - return std::make_shared( - std::make_shared(hero)); - } - }, - itr->second); + result = make_hero(itr->second); } return result; From c04d0d848de8b60f5ac3fb562524887355c6e65e Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Wed, 8 Dec 2021 13:38:38 -0800 Subject: [PATCH 059/119] Remove unused headers from interface types and add sv literal --- samples/learn/schema/CharacterObject.cpp | 14 +- samples/learn/schema/DroidObject.cpp | 10 +- samples/learn/schema/HumanObject.cpp | 10 +- samples/learn/schema/MutationObject.cpp | 6 +- samples/learn/schema/QueryObject.cpp | 12 +- samples/learn/schema/ReviewObject.cpp | 4 +- samples/learn/schema/StarWarsSchema.cpp | 4 +- .../separate/AppointmentConnectionObject.cpp | 4 +- .../today/separate/AppointmentEdgeObject.cpp | 4 +- samples/today/separate/AppointmentObject.cpp | 10 +- .../separate/CompleteTaskPayloadObject.cpp | 4 +- samples/today/separate/ExpensiveObject.cpp | 2 +- .../today/separate/FolderConnectionObject.cpp | 4 +- samples/today/separate/FolderEdgeObject.cpp | 4 +- samples/today/separate/FolderObject.cpp | 6 +- samples/today/separate/MutationObject.cpp | 8 +- samples/today/separate/NestedTypeObject.cpp | 4 +- samples/today/separate/NodeObject.cpp | 8 +- samples/today/separate/PageInfoObject.cpp | 4 +- samples/today/separate/QueryObject.cpp | 58 +++--- samples/today/separate/SubscriptionObject.cpp | 6 +- .../today/separate/TaskConnectionObject.cpp | 4 +- samples/today/separate/TaskEdgeObject.cpp | 4 +- samples/today/separate/TaskObject.cpp | 6 +- samples/today/separate/TodaySchema.cpp | 34 ++-- .../AppointmentConnectionObject.cpp | 4 +- .../AppointmentEdgeObject.cpp | 4 +- .../AppointmentObject.cpp | 10 +- .../CompleteTaskPayloadObject.cpp | 4 +- .../ExpensiveObject.cpp | 2 +- .../FolderConnectionObject.cpp | 4 +- .../FolderEdgeObject.cpp | 4 +- .../separate_nointrospection/FolderObject.cpp | 6 +- .../MutationObject.cpp | 8 +- .../NestedTypeObject.cpp | 4 +- .../separate_nointrospection/NodeObject.cpp | 8 +- .../PageInfoObject.cpp | 4 +- .../separate_nointrospection/QueryObject.cpp | 58 +++--- .../SubscriptionObject.cpp | 6 +- .../TaskConnectionObject.cpp | 4 +- .../TaskEdgeObject.cpp | 4 +- .../separate_nointrospection/TaskObject.cpp | 6 +- .../separate_nointrospection/TodaySchema.cpp | 34 ++-- samples/today/unified/TodaySchema.cpp | 168 +++++++++--------- .../unified_nointrospection/TodaySchema.cpp | 168 +++++++++--------- .../validation/schema/ValidationSchema.cpp | 106 +++++------ src/IntrospectionSchema.cpp | 74 ++++---- src/SchemaGenerator.cpp | 8 +- 48 files changed, 454 insertions(+), 478 deletions(-) diff --git a/samples/learn/schema/CharacterObject.cpp b/samples/learn/schema/CharacterObject.cpp index 2c41c0e4..57953a85 100644 --- a/samples/learn/schema/CharacterObject.cpp +++ b/samples/learn/schema/CharacterObject.cpp @@ -7,12 +7,6 @@ #include "graphqlservice/introspection/Introspection.h" -#include -#include -#include -#include -#include - using namespace std::literals; namespace graphql::learn { @@ -39,10 +33,10 @@ void Character::endSelectionSet(const service::SelectionSetParams& params) const void AddCharacterDetails(const std::shared_ptr& typeCharacter, const std::shared_ptr& schema) { typeCharacter->AddFields({ - schema::Field::Make(R"gql(id)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("String"))), - schema::Field::Make(R"gql(name)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType("String")), - schema::Field::Make(R"gql(friends)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::LIST, schema->LookupType("Character"))), - schema::Field::Make(R"gql(appearsIn)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::LIST, schema->LookupType("Episode"))) + schema::Field::Make(R"gql(id)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(String)gql"sv))), + schema::Field::Make(R"gql(name)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(String)gql"sv)), + schema::Field::Make(R"gql(friends)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::LIST, schema->LookupType(R"gql(Character)gql"sv))), + schema::Field::Make(R"gql(appearsIn)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::LIST, schema->LookupType(R"gql(Episode)gql"sv))) }); } diff --git a/samples/learn/schema/DroidObject.cpp b/samples/learn/schema/DroidObject.cpp index e2bdc889..98aae70d 100644 --- a/samples/learn/schema/DroidObject.cpp +++ b/samples/learn/schema/DroidObject.cpp @@ -117,11 +117,11 @@ void AddDroidDetails(const std::shared_ptr& typeDroid, const std::static_pointer_cast(schema->LookupType(R"gql(Character)gql"sv)) }); typeDroid->AddFields({ - schema::Field::Make(R"gql(id)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("String"))), - schema::Field::Make(R"gql(name)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType("String")), - schema::Field::Make(R"gql(friends)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::LIST, schema->LookupType("Character"))), - schema::Field::Make(R"gql(appearsIn)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::LIST, schema->LookupType("Episode"))), - schema::Field::Make(R"gql(primaryFunction)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType("String")) + schema::Field::Make(R"gql(id)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(String)gql"sv))), + schema::Field::Make(R"gql(name)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(String)gql"sv)), + schema::Field::Make(R"gql(friends)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::LIST, schema->LookupType(R"gql(Character)gql"sv))), + schema::Field::Make(R"gql(appearsIn)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::LIST, schema->LookupType(R"gql(Episode)gql"sv))), + schema::Field::Make(R"gql(primaryFunction)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(String)gql"sv)) }); } diff --git a/samples/learn/schema/HumanObject.cpp b/samples/learn/schema/HumanObject.cpp index eef34f4b..ed40654f 100644 --- a/samples/learn/schema/HumanObject.cpp +++ b/samples/learn/schema/HumanObject.cpp @@ -117,11 +117,11 @@ void AddHumanDetails(const std::shared_ptr& typeHuman, const std::static_pointer_cast(schema->LookupType(R"gql(Character)gql"sv)) }); typeHuman->AddFields({ - schema::Field::Make(R"gql(id)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("String"))), - schema::Field::Make(R"gql(name)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType("String")), - schema::Field::Make(R"gql(friends)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::LIST, schema->LookupType("Character"))), - schema::Field::Make(R"gql(appearsIn)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::LIST, schema->LookupType("Episode"))), - schema::Field::Make(R"gql(homePlanet)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType("String")) + schema::Field::Make(R"gql(id)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(String)gql"sv))), + schema::Field::Make(R"gql(name)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(String)gql"sv)), + schema::Field::Make(R"gql(friends)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::LIST, schema->LookupType(R"gql(Character)gql"sv))), + schema::Field::Make(R"gql(appearsIn)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::LIST, schema->LookupType(R"gql(Episode)gql"sv))), + schema::Field::Make(R"gql(homePlanet)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(String)gql"sv)) }); } diff --git a/samples/learn/schema/MutationObject.cpp b/samples/learn/schema/MutationObject.cpp index cf071707..45a1fa2d 100644 --- a/samples/learn/schema/MutationObject.cpp +++ b/samples/learn/schema/MutationObject.cpp @@ -71,9 +71,9 @@ service::AwaitableResolver Mutation::resolve_typename(service::ResolverParams&& void AddMutationDetails(const std::shared_ptr& typeMutation, const std::shared_ptr& schema) { typeMutation->AddFields({ - schema::Field::Make(R"gql(createReview)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("Review")), { - schema::InputValue::Make(R"gql(ep)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("Episode")), R"gql()gql"sv), - schema::InputValue::Make(R"gql(review)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("ReviewInput")), R"gql()gql"sv) + schema::Field::Make(R"gql(createReview)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Review)gql"sv)), { + schema::InputValue::Make(R"gql(ep)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Episode)gql"sv)), R"gql()gql"sv), + schema::InputValue::Make(R"gql(review)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ReviewInput)gql"sv)), R"gql()gql"sv) }) }); } diff --git a/samples/learn/schema/QueryObject.cpp b/samples/learn/schema/QueryObject.cpp index 3bbab1aa..b8e2187b 100644 --- a/samples/learn/schema/QueryObject.cpp +++ b/samples/learn/schema/QueryObject.cpp @@ -111,14 +111,14 @@ service::AwaitableResolver Query::resolve_type(service::ResolverParams&& params) void AddQueryDetails(const std::shared_ptr& typeQuery, const std::shared_ptr& schema) { typeQuery->AddFields({ - schema::Field::Make(R"gql(hero)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType("Character"), { - schema::InputValue::Make(R"gql(episode)gql"sv, R"md()md"sv, schema->LookupType("Episode"), R"gql()gql"sv) + schema::Field::Make(R"gql(hero)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(Character)gql"sv), { + schema::InputValue::Make(R"gql(episode)gql"sv, R"md()md"sv, schema->LookupType(R"gql(Episode)gql"sv), R"gql()gql"sv) }), - schema::Field::Make(R"gql(human)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType("Human"), { - schema::InputValue::Make(R"gql(id)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("String")), R"gql()gql"sv) + schema::Field::Make(R"gql(human)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(Human)gql"sv), { + schema::InputValue::Make(R"gql(id)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(String)gql"sv)), R"gql()gql"sv) }), - schema::Field::Make(R"gql(droid)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType("Droid"), { - schema::InputValue::Make(R"gql(id)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("String")), R"gql()gql"sv) + schema::Field::Make(R"gql(droid)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(Droid)gql"sv), { + schema::InputValue::Make(R"gql(id)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(String)gql"sv)), R"gql()gql"sv) }) }); } diff --git a/samples/learn/schema/ReviewObject.cpp b/samples/learn/schema/ReviewObject.cpp index fd773a95..0b8a6367 100644 --- a/samples/learn/schema/ReviewObject.cpp +++ b/samples/learn/schema/ReviewObject.cpp @@ -80,8 +80,8 @@ service::AwaitableResolver Review::resolve_typename(service::ResolverParams&& pa void AddReviewDetails(const std::shared_ptr& typeReview, const std::shared_ptr& schema) { typeReview->AddFields({ - schema::Field::Make(R"gql(stars)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("Int"))), - schema::Field::Make(R"gql(commentary)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType("String")) + schema::Field::Make(R"gql(stars)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Int)gql"sv))), + schema::Field::Make(R"gql(commentary)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(String)gql"sv)) }); } diff --git a/samples/learn/schema/StarWarsSchema.cpp b/samples/learn/schema/StarWarsSchema.cpp index a61a98c4..4bcfd08b 100644 --- a/samples/learn/schema/StarWarsSchema.cpp +++ b/samples/learn/schema/StarWarsSchema.cpp @@ -111,8 +111,8 @@ void AddTypesToSchema(const std::shared_ptr& schema) }); typeReviewInput->AddInputValues({ - schema::InputValue::Make(R"gql(stars)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("Int")), R"gql()gql"sv), - schema::InputValue::Make(R"gql(commentary)gql"sv, R"md()md"sv, schema->LookupType("String"), R"gql()gql"sv) + schema::InputValue::Make(R"gql(stars)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Int)gql"sv)), R"gql()gql"sv), + schema::InputValue::Make(R"gql(commentary)gql"sv, R"md()md"sv, schema->LookupType(R"gql(String)gql"sv), R"gql()gql"sv) }); AddCharacterDetails(typeCharacter, schema); diff --git a/samples/today/separate/AppointmentConnectionObject.cpp b/samples/today/separate/AppointmentConnectionObject.cpp index 446723de..d76c2276 100644 --- a/samples/today/separate/AppointmentConnectionObject.cpp +++ b/samples/today/separate/AppointmentConnectionObject.cpp @@ -80,8 +80,8 @@ service::AwaitableResolver AppointmentConnection::resolve_typename(service::Reso void AddAppointmentConnectionDetails(const std::shared_ptr& typeAppointmentConnection, const std::shared_ptr& schema) { typeAppointmentConnection->AddFields({ - schema::Field::Make(R"gql(pageInfo)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("PageInfo"))), - schema::Field::Make(R"gql(edges)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::LIST, schema->LookupType("AppointmentEdge"))) + schema::Field::Make(R"gql(pageInfo)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(PageInfo)gql"sv))), + schema::Field::Make(R"gql(edges)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::LIST, schema->LookupType(R"gql(AppointmentEdge)gql"sv))) }); } diff --git a/samples/today/separate/AppointmentEdgeObject.cpp b/samples/today/separate/AppointmentEdgeObject.cpp index 84742a4a..a9e09f8d 100644 --- a/samples/today/separate/AppointmentEdgeObject.cpp +++ b/samples/today/separate/AppointmentEdgeObject.cpp @@ -80,8 +80,8 @@ service::AwaitableResolver AppointmentEdge::resolve_typename(service::ResolverPa void AddAppointmentEdgeDetails(const std::shared_ptr& typeAppointmentEdge, const std::shared_ptr& schema) { typeAppointmentEdge->AddFields({ - schema::Field::Make(R"gql(node)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType("Appointment")), - schema::Field::Make(R"gql(cursor)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("ItemCursor"))) + schema::Field::Make(R"gql(node)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(Appointment)gql"sv)), + schema::Field::Make(R"gql(cursor)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ItemCursor)gql"sv))) }); } diff --git a/samples/today/separate/AppointmentObject.cpp b/samples/today/separate/AppointmentObject.cpp index 3bc3745d..0225df19 100644 --- a/samples/today/separate/AppointmentObject.cpp +++ b/samples/today/separate/AppointmentObject.cpp @@ -118,11 +118,11 @@ void AddAppointmentDetails(const std::shared_ptr& typeAppoin std::static_pointer_cast(schema->LookupType(R"gql(Node)gql"sv)) }); typeAppointment->AddFields({ - schema::Field::Make(R"gql(id)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("ID"))), - schema::Field::Make(R"gql(when)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType("DateTime")), - schema::Field::Make(R"gql(subject)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType("String")), - schema::Field::Make(R"gql(isNow)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("Boolean"))), - schema::Field::Make(R"gql(forceError)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType("String")) + schema::Field::Make(R"gql(id)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ID)gql"sv))), + schema::Field::Make(R"gql(when)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(DateTime)gql"sv)), + schema::Field::Make(R"gql(subject)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(String)gql"sv)), + schema::Field::Make(R"gql(isNow)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Boolean)gql"sv))), + schema::Field::Make(R"gql(forceError)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(String)gql"sv)) }); } diff --git a/samples/today/separate/CompleteTaskPayloadObject.cpp b/samples/today/separate/CompleteTaskPayloadObject.cpp index aca47fd0..c47c1043 100644 --- a/samples/today/separate/CompleteTaskPayloadObject.cpp +++ b/samples/today/separate/CompleteTaskPayloadObject.cpp @@ -80,8 +80,8 @@ service::AwaitableResolver CompleteTaskPayload::resolve_typename(service::Resolv void AddCompleteTaskPayloadDetails(const std::shared_ptr& typeCompleteTaskPayload, const std::shared_ptr& schema) { typeCompleteTaskPayload->AddFields({ - schema::Field::Make(R"gql(task)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType("Task")), - schema::Field::Make(R"gql(clientMutationId)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType("String")) + schema::Field::Make(R"gql(task)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(Task)gql"sv)), + schema::Field::Make(R"gql(clientMutationId)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(String)gql"sv)) }); } diff --git a/samples/today/separate/ExpensiveObject.cpp b/samples/today/separate/ExpensiveObject.cpp index ab1b1008..c565b6b5 100644 --- a/samples/today/separate/ExpensiveObject.cpp +++ b/samples/today/separate/ExpensiveObject.cpp @@ -69,7 +69,7 @@ service::AwaitableResolver Expensive::resolve_typename(service::ResolverParams&& void AddExpensiveDetails(const std::shared_ptr& typeExpensive, const std::shared_ptr& schema) { typeExpensive->AddFields({ - schema::Field::Make(R"gql(order)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("Int"))) + schema::Field::Make(R"gql(order)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Int)gql"sv))) }); } diff --git a/samples/today/separate/FolderConnectionObject.cpp b/samples/today/separate/FolderConnectionObject.cpp index 1408c541..a2d54d07 100644 --- a/samples/today/separate/FolderConnectionObject.cpp +++ b/samples/today/separate/FolderConnectionObject.cpp @@ -80,8 +80,8 @@ service::AwaitableResolver FolderConnection::resolve_typename(service::ResolverP void AddFolderConnectionDetails(const std::shared_ptr& typeFolderConnection, const std::shared_ptr& schema) { typeFolderConnection->AddFields({ - schema::Field::Make(R"gql(pageInfo)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("PageInfo"))), - schema::Field::Make(R"gql(edges)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::LIST, schema->LookupType("FolderEdge"))) + schema::Field::Make(R"gql(pageInfo)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(PageInfo)gql"sv))), + schema::Field::Make(R"gql(edges)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::LIST, schema->LookupType(R"gql(FolderEdge)gql"sv))) }); } diff --git a/samples/today/separate/FolderEdgeObject.cpp b/samples/today/separate/FolderEdgeObject.cpp index 6022c600..64a84afb 100644 --- a/samples/today/separate/FolderEdgeObject.cpp +++ b/samples/today/separate/FolderEdgeObject.cpp @@ -80,8 +80,8 @@ service::AwaitableResolver FolderEdge::resolve_typename(service::ResolverParams& void AddFolderEdgeDetails(const std::shared_ptr& typeFolderEdge, const std::shared_ptr& schema) { typeFolderEdge->AddFields({ - schema::Field::Make(R"gql(node)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType("Folder")), - schema::Field::Make(R"gql(cursor)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("ItemCursor"))) + schema::Field::Make(R"gql(node)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(Folder)gql"sv)), + schema::Field::Make(R"gql(cursor)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ItemCursor)gql"sv))) }); } diff --git a/samples/today/separate/FolderObject.cpp b/samples/today/separate/FolderObject.cpp index 8c7406a2..18570792 100644 --- a/samples/today/separate/FolderObject.cpp +++ b/samples/today/separate/FolderObject.cpp @@ -96,9 +96,9 @@ void AddFolderDetails(const std::shared_ptr& typeFolder, con std::static_pointer_cast(schema->LookupType(R"gql(Node)gql"sv)) }); typeFolder->AddFields({ - schema::Field::Make(R"gql(id)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("ID"))), - schema::Field::Make(R"gql(name)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType("String")), - schema::Field::Make(R"gql(unreadCount)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("Int"))) + schema::Field::Make(R"gql(id)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ID)gql"sv))), + schema::Field::Make(R"gql(name)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(String)gql"sv)), + schema::Field::Make(R"gql(unreadCount)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Int)gql"sv))) }); } diff --git a/samples/today/separate/MutationObject.cpp b/samples/today/separate/MutationObject.cpp index a0ed9b90..cc915077 100644 --- a/samples/today/separate/MutationObject.cpp +++ b/samples/today/separate/MutationObject.cpp @@ -82,11 +82,11 @@ service::AwaitableResolver Mutation::resolve_typename(service::ResolverParams&& void AddMutationDetails(const std::shared_ptr& typeMutation, const std::shared_ptr& schema) { typeMutation->AddFields({ - schema::Field::Make(R"gql(completeTask)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("CompleteTaskPayload")), { - schema::InputValue::Make(R"gql(input)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("CompleteTaskInput")), R"gql()gql"sv) + schema::Field::Make(R"gql(completeTask)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(CompleteTaskPayload)gql"sv)), { + schema::InputValue::Make(R"gql(input)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(CompleteTaskInput)gql"sv)), R"gql()gql"sv) }), - schema::Field::Make(R"gql(setFloat)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("Float")), { - schema::InputValue::Make(R"gql(value)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("Float")), R"gql()gql"sv) + schema::Field::Make(R"gql(setFloat)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Float)gql"sv)), { + schema::InputValue::Make(R"gql(value)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Float)gql"sv)), R"gql()gql"sv) }) }); } diff --git a/samples/today/separate/NestedTypeObject.cpp b/samples/today/separate/NestedTypeObject.cpp index c93e820a..ff46e6a4 100644 --- a/samples/today/separate/NestedTypeObject.cpp +++ b/samples/today/separate/NestedTypeObject.cpp @@ -80,8 +80,8 @@ service::AwaitableResolver NestedType::resolve_typename(service::ResolverParams& void AddNestedTypeDetails(const std::shared_ptr& typeNestedType, const std::shared_ptr& schema) { typeNestedType->AddFields({ - schema::Field::Make(R"gql(depth)gql"sv, R"md(Depth of the nested element)md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("Int"))), - schema::Field::Make(R"gql(nested)gql"sv, R"md(Link to the next level)md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("NestedType"))) + schema::Field::Make(R"gql(depth)gql"sv, R"md(Depth of the nested element)md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Int)gql"sv))), + schema::Field::Make(R"gql(nested)gql"sv, R"md(Link to the next level)md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(NestedType)gql"sv))) }); } diff --git a/samples/today/separate/NodeObject.cpp b/samples/today/separate/NodeObject.cpp index 7196db2b..73ea28b2 100644 --- a/samples/today/separate/NodeObject.cpp +++ b/samples/today/separate/NodeObject.cpp @@ -7,12 +7,6 @@ #include "graphqlservice/introspection/Introspection.h" -#include -#include -#include -#include -#include - using namespace std::literals; namespace graphql::today { @@ -39,7 +33,7 @@ void Node::endSelectionSet(const service::SelectionSetParams& params) const void AddNodeDetails(const std::shared_ptr& typeNode, const std::shared_ptr& schema) { typeNode->AddFields({ - schema::Field::Make(R"gql(id)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("ID"))) + schema::Field::Make(R"gql(id)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ID)gql"sv))) }); } diff --git a/samples/today/separate/PageInfoObject.cpp b/samples/today/separate/PageInfoObject.cpp index 87112979..d5b1758b 100644 --- a/samples/today/separate/PageInfoObject.cpp +++ b/samples/today/separate/PageInfoObject.cpp @@ -80,8 +80,8 @@ service::AwaitableResolver PageInfo::resolve_typename(service::ResolverParams&& void AddPageInfoDetails(const std::shared_ptr& typePageInfo, const std::shared_ptr& schema) { typePageInfo->AddFields({ - schema::Field::Make(R"gql(hasNextPage)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("Boolean"))), - schema::Field::Make(R"gql(hasPreviousPage)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("Boolean"))) + schema::Field::Make(R"gql(hasNextPage)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Boolean)gql"sv))), + schema::Field::Make(R"gql(hasPreviousPage)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Boolean)gql"sv))) }); } diff --git a/samples/today/separate/QueryObject.cpp b/samples/today/separate/QueryObject.cpp index 7890b96f..4c8b147d 100644 --- a/samples/today/separate/QueryObject.cpp +++ b/samples/today/separate/QueryObject.cpp @@ -246,42 +246,42 @@ service::AwaitableResolver Query::resolve_type(service::ResolverParams&& params) void AddQueryDetails(const std::shared_ptr& typeQuery, const std::shared_ptr& schema) { typeQuery->AddFields({ - schema::Field::Make(R"gql(node)gql"sv, R"md([Object Identification](https://facebook.github.io/relay/docs/en/graphql-server-specification.html#object-identification))md"sv, std::nullopt, schema->LookupType("Node"), { - schema::InputValue::Make(R"gql(id)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("ID")), R"gql()gql"sv) + schema::Field::Make(R"gql(node)gql"sv, R"md([Object Identification](https://facebook.github.io/relay/docs/en/graphql-server-specification.html#object-identification))md"sv, std::nullopt, schema->LookupType(R"gql(Node)gql"sv), { + schema::InputValue::Make(R"gql(id)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ID)gql"sv)), R"gql()gql"sv) }), - schema::Field::Make(R"gql(appointments)gql"sv, R"md(Appointments [Connection](https://facebook.github.io/relay/docs/en/graphql-server-specification.html#connections))md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("AppointmentConnection")), { - schema::InputValue::Make(R"gql(first)gql"sv, R"md()md"sv, schema->LookupType("Int"), R"gql()gql"sv), - schema::InputValue::Make(R"gql(after)gql"sv, R"md()md"sv, schema->LookupType("ItemCursor"), R"gql()gql"sv), - schema::InputValue::Make(R"gql(last)gql"sv, R"md()md"sv, schema->LookupType("Int"), R"gql()gql"sv), - schema::InputValue::Make(R"gql(before)gql"sv, R"md()md"sv, schema->LookupType("ItemCursor"), R"gql()gql"sv) + schema::Field::Make(R"gql(appointments)gql"sv, R"md(Appointments [Connection](https://facebook.github.io/relay/docs/en/graphql-server-specification.html#connections))md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(AppointmentConnection)gql"sv)), { + schema::InputValue::Make(R"gql(first)gql"sv, R"md()md"sv, schema->LookupType(R"gql(Int)gql"sv), R"gql()gql"sv), + schema::InputValue::Make(R"gql(after)gql"sv, R"md()md"sv, schema->LookupType(R"gql(ItemCursor)gql"sv), R"gql()gql"sv), + schema::InputValue::Make(R"gql(last)gql"sv, R"md()md"sv, schema->LookupType(R"gql(Int)gql"sv), R"gql()gql"sv), + schema::InputValue::Make(R"gql(before)gql"sv, R"md()md"sv, schema->LookupType(R"gql(ItemCursor)gql"sv), R"gql()gql"sv) }), - schema::Field::Make(R"gql(tasks)gql"sv, R"md(Tasks [Connection](https://facebook.github.io/relay/docs/en/graphql-server-specification.html#connections))md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("TaskConnection")), { - schema::InputValue::Make(R"gql(first)gql"sv, R"md()md"sv, schema->LookupType("Int"), R"gql()gql"sv), - schema::InputValue::Make(R"gql(after)gql"sv, R"md()md"sv, schema->LookupType("ItemCursor"), R"gql()gql"sv), - schema::InputValue::Make(R"gql(last)gql"sv, R"md()md"sv, schema->LookupType("Int"), R"gql()gql"sv), - schema::InputValue::Make(R"gql(before)gql"sv, R"md()md"sv, schema->LookupType("ItemCursor"), R"gql()gql"sv) + schema::Field::Make(R"gql(tasks)gql"sv, R"md(Tasks [Connection](https://facebook.github.io/relay/docs/en/graphql-server-specification.html#connections))md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(TaskConnection)gql"sv)), { + schema::InputValue::Make(R"gql(first)gql"sv, R"md()md"sv, schema->LookupType(R"gql(Int)gql"sv), R"gql()gql"sv), + schema::InputValue::Make(R"gql(after)gql"sv, R"md()md"sv, schema->LookupType(R"gql(ItemCursor)gql"sv), R"gql()gql"sv), + schema::InputValue::Make(R"gql(last)gql"sv, R"md()md"sv, schema->LookupType(R"gql(Int)gql"sv), R"gql()gql"sv), + schema::InputValue::Make(R"gql(before)gql"sv, R"md()md"sv, schema->LookupType(R"gql(ItemCursor)gql"sv), R"gql()gql"sv) }), - schema::Field::Make(R"gql(unreadCounts)gql"sv, R"md(Folder unread counts [Connection](https://facebook.github.io/relay/docs/en/graphql-server-specification.html#connections))md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("FolderConnection")), { - schema::InputValue::Make(R"gql(first)gql"sv, R"md()md"sv, schema->LookupType("Int"), R"gql()gql"sv), - schema::InputValue::Make(R"gql(after)gql"sv, R"md()md"sv, schema->LookupType("ItemCursor"), R"gql()gql"sv), - schema::InputValue::Make(R"gql(last)gql"sv, R"md()md"sv, schema->LookupType("Int"), R"gql()gql"sv), - schema::InputValue::Make(R"gql(before)gql"sv, R"md()md"sv, schema->LookupType("ItemCursor"), R"gql()gql"sv) + schema::Field::Make(R"gql(unreadCounts)gql"sv, R"md(Folder unread counts [Connection](https://facebook.github.io/relay/docs/en/graphql-server-specification.html#connections))md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(FolderConnection)gql"sv)), { + schema::InputValue::Make(R"gql(first)gql"sv, R"md()md"sv, schema->LookupType(R"gql(Int)gql"sv), R"gql()gql"sv), + schema::InputValue::Make(R"gql(after)gql"sv, R"md()md"sv, schema->LookupType(R"gql(ItemCursor)gql"sv), R"gql()gql"sv), + schema::InputValue::Make(R"gql(last)gql"sv, R"md()md"sv, schema->LookupType(R"gql(Int)gql"sv), R"gql()gql"sv), + schema::InputValue::Make(R"gql(before)gql"sv, R"md()md"sv, schema->LookupType(R"gql(ItemCursor)gql"sv), R"gql()gql"sv) }), - schema::Field::Make(R"gql(appointmentsById)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->LookupType("Appointment"))), { - schema::InputValue::Make(R"gql(ids)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("ID")))), R"gql(["ZmFrZUFwcG9pbnRtZW50SWQ="])gql"sv) + schema::Field::Make(R"gql(appointmentsById)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->LookupType(R"gql(Appointment)gql"sv))), { + schema::InputValue::Make(R"gql(ids)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ID)gql"sv)))), R"gql(["ZmFrZUFwcG9pbnRtZW50SWQ="])gql"sv) }), - schema::Field::Make(R"gql(tasksById)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->LookupType("Task"))), { - schema::InputValue::Make(R"gql(ids)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("ID")))), R"gql()gql"sv) + schema::Field::Make(R"gql(tasksById)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->LookupType(R"gql(Task)gql"sv))), { + schema::InputValue::Make(R"gql(ids)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ID)gql"sv)))), R"gql()gql"sv) }), - schema::Field::Make(R"gql(unreadCountsById)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->LookupType("Folder"))), { - schema::InputValue::Make(R"gql(ids)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("ID")))), R"gql()gql"sv) + schema::Field::Make(R"gql(unreadCountsById)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->LookupType(R"gql(Folder)gql"sv))), { + schema::InputValue::Make(R"gql(ids)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ID)gql"sv)))), R"gql()gql"sv) }), - schema::Field::Make(R"gql(nested)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("NestedType"))), - schema::Field::Make(R"gql(unimplemented)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("String"))), - schema::Field::Make(R"gql(expensive)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("Expensive"))))), - schema::Field::Make(R"gql(testTaskState)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("TaskState"))), - schema::Field::Make(R"gql(anyType)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->LookupType("UnionType"))), { - schema::InputValue::Make(R"gql(ids)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("ID")))), R"gql()gql"sv) + schema::Field::Make(R"gql(nested)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(NestedType)gql"sv))), + schema::Field::Make(R"gql(unimplemented)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(String)gql"sv))), + schema::Field::Make(R"gql(expensive)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Expensive)gql"sv))))), + schema::Field::Make(R"gql(testTaskState)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(TaskState)gql"sv))), + schema::Field::Make(R"gql(anyType)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->LookupType(R"gql(UnionType)gql"sv))), { + schema::InputValue::Make(R"gql(ids)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ID)gql"sv)))), R"gql()gql"sv) }) }); } diff --git a/samples/today/separate/SubscriptionObject.cpp b/samples/today/separate/SubscriptionObject.cpp index 8c7b5321..45df7373 100644 --- a/samples/today/separate/SubscriptionObject.cpp +++ b/samples/today/separate/SubscriptionObject.cpp @@ -81,9 +81,9 @@ service::AwaitableResolver Subscription::resolve_typename(service::ResolverParam void AddSubscriptionDetails(const std::shared_ptr& typeSubscription, const std::shared_ptr& schema) { typeSubscription->AddFields({ - schema::Field::Make(R"gql(nextAppointmentChange)gql"sv, R"md()md"sv, std::make_optional(R"md(Need to deprecate a [field](http://spec.graphql.org/June2018/#sec-Deprecation))md"sv), schema->LookupType("Appointment")), - schema::Field::Make(R"gql(nodeChange)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("Node")), { - schema::InputValue::Make(R"gql(id)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("ID")), R"gql()gql"sv) + schema::Field::Make(R"gql(nextAppointmentChange)gql"sv, R"md()md"sv, std::make_optional(R"md(Need to deprecate a [field](http://spec.graphql.org/June2018/#sec-Deprecation))md"sv), schema->LookupType(R"gql(Appointment)gql"sv)), + schema::Field::Make(R"gql(nodeChange)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Node)gql"sv)), { + schema::InputValue::Make(R"gql(id)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ID)gql"sv)), R"gql()gql"sv) }) }); } diff --git a/samples/today/separate/TaskConnectionObject.cpp b/samples/today/separate/TaskConnectionObject.cpp index b1e9da1f..64917a00 100644 --- a/samples/today/separate/TaskConnectionObject.cpp +++ b/samples/today/separate/TaskConnectionObject.cpp @@ -80,8 +80,8 @@ service::AwaitableResolver TaskConnection::resolve_typename(service::ResolverPar void AddTaskConnectionDetails(const std::shared_ptr& typeTaskConnection, const std::shared_ptr& schema) { typeTaskConnection->AddFields({ - schema::Field::Make(R"gql(pageInfo)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("PageInfo"))), - schema::Field::Make(R"gql(edges)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::LIST, schema->LookupType("TaskEdge"))) + schema::Field::Make(R"gql(pageInfo)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(PageInfo)gql"sv))), + schema::Field::Make(R"gql(edges)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::LIST, schema->LookupType(R"gql(TaskEdge)gql"sv))) }); } diff --git a/samples/today/separate/TaskEdgeObject.cpp b/samples/today/separate/TaskEdgeObject.cpp index ff7758d4..c8780958 100644 --- a/samples/today/separate/TaskEdgeObject.cpp +++ b/samples/today/separate/TaskEdgeObject.cpp @@ -80,8 +80,8 @@ service::AwaitableResolver TaskEdge::resolve_typename(service::ResolverParams&& void AddTaskEdgeDetails(const std::shared_ptr& typeTaskEdge, const std::shared_ptr& schema) { typeTaskEdge->AddFields({ - schema::Field::Make(R"gql(node)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType("Task")), - schema::Field::Make(R"gql(cursor)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("ItemCursor"))) + schema::Field::Make(R"gql(node)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(Task)gql"sv)), + schema::Field::Make(R"gql(cursor)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ItemCursor)gql"sv))) }); } diff --git a/samples/today/separate/TaskObject.cpp b/samples/today/separate/TaskObject.cpp index bdc7596c..46d6e2a1 100644 --- a/samples/today/separate/TaskObject.cpp +++ b/samples/today/separate/TaskObject.cpp @@ -96,9 +96,9 @@ void AddTaskDetails(const std::shared_ptr& typeTask, const s std::static_pointer_cast(schema->LookupType(R"gql(Node)gql"sv)) }); typeTask->AddFields({ - schema::Field::Make(R"gql(id)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("ID"))), - schema::Field::Make(R"gql(title)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType("String")), - schema::Field::Make(R"gql(isComplete)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("Boolean"))) + schema::Field::Make(R"gql(id)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ID)gql"sv))), + schema::Field::Make(R"gql(title)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(String)gql"sv)), + schema::Field::Make(R"gql(isComplete)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Boolean)gql"sv))) }); } diff --git a/samples/today/separate/TodaySchema.cpp b/samples/today/separate/TodaySchema.cpp index e11d4626..0a3ebf2b 100644 --- a/samples/today/separate/TodaySchema.cpp +++ b/samples/today/separate/TodaySchema.cpp @@ -213,25 +213,25 @@ void AddTypesToSchema(const std::shared_ptr& schema) }); typeCompleteTaskInput->AddInputValues({ - schema::InputValue::Make(R"gql(id)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("ID")), R"gql()gql"sv), - schema::InputValue::Make(R"gql(testTaskState)gql"sv, R"md()md"sv, schema->LookupType("TaskState"), R"gql()gql"sv), - schema::InputValue::Make(R"gql(isComplete)gql"sv, R"md()md"sv, schema->LookupType("Boolean"), R"gql(true)gql"sv), - schema::InputValue::Make(R"gql(clientMutationId)gql"sv, R"md()md"sv, schema->LookupType("String"), R"gql()gql"sv) + schema::InputValue::Make(R"gql(id)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ID)gql"sv)), R"gql()gql"sv), + schema::InputValue::Make(R"gql(testTaskState)gql"sv, R"md()md"sv, schema->LookupType(R"gql(TaskState)gql"sv), R"gql()gql"sv), + schema::InputValue::Make(R"gql(isComplete)gql"sv, R"md()md"sv, schema->LookupType(R"gql(Boolean)gql"sv), R"gql(true)gql"sv), + schema::InputValue::Make(R"gql(clientMutationId)gql"sv, R"md()md"sv, schema->LookupType(R"gql(String)gql"sv), R"gql()gql"sv) }); typeThirdNestedInput->AddInputValues({ - schema::InputValue::Make(R"gql(id)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("ID")), R"gql()gql"sv) + schema::InputValue::Make(R"gql(id)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ID)gql"sv)), R"gql()gql"sv) }); typeFourthNestedInput->AddInputValues({ - schema::InputValue::Make(R"gql(id)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("ID")), R"gql()gql"sv) + schema::InputValue::Make(R"gql(id)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ID)gql"sv)), R"gql()gql"sv) }); typeSecondNestedInput->AddInputValues({ - schema::InputValue::Make(R"gql(id)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("ID")), R"gql()gql"sv), - schema::InputValue::Make(R"gql(third)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("ThirdNestedInput")), R"gql()gql"sv) + schema::InputValue::Make(R"gql(id)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ID)gql"sv)), R"gql()gql"sv), + schema::InputValue::Make(R"gql(third)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ThirdNestedInput)gql"sv)), R"gql()gql"sv) }); typeFirstNestedInput->AddInputValues({ - schema::InputValue::Make(R"gql(id)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("ID")), R"gql()gql"sv), - schema::InputValue::Make(R"gql(second)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("SecondNestedInput")), R"gql()gql"sv), - schema::InputValue::Make(R"gql(third)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("ThirdNestedInput")), R"gql()gql"sv) + schema::InputValue::Make(R"gql(id)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ID)gql"sv)), R"gql()gql"sv), + schema::InputValue::Make(R"gql(second)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(SecondNestedInput)gql"sv)), R"gql()gql"sv), + schema::InputValue::Make(R"gql(third)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ThirdNestedInput)gql"sv)), R"gql()gql"sv) }); typeUnionType->AddPossibleTypes({ @@ -265,32 +265,32 @@ void AddTypesToSchema(const std::shared_ptr& schema) schema->AddDirective(schema::Directive::Make(R"gql(subscriptionTag)gql"sv, R"md()md"sv, { introspection::DirectiveLocation::SUBSCRIPTION }, { - schema::InputValue::Make(R"gql(field)gql"sv, R"md()md"sv, schema->LookupType("String"), R"gql()gql"sv) + schema::InputValue::Make(R"gql(field)gql"sv, R"md()md"sv, schema->LookupType(R"gql(String)gql"sv), R"gql()gql"sv) })); schema->AddDirective(schema::Directive::Make(R"gql(queryTag)gql"sv, R"md()md"sv, { introspection::DirectiveLocation::QUERY }, { - schema::InputValue::Make(R"gql(query)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("String")), R"gql()gql"sv) + schema::InputValue::Make(R"gql(query)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(String)gql"sv)), R"gql()gql"sv) })); schema->AddDirective(schema::Directive::Make(R"gql(fieldTag)gql"sv, R"md()md"sv, { introspection::DirectiveLocation::FIELD }, { - schema::InputValue::Make(R"gql(field)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("String")), R"gql()gql"sv) + schema::InputValue::Make(R"gql(field)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(String)gql"sv)), R"gql()gql"sv) })); schema->AddDirective(schema::Directive::Make(R"gql(fragmentDefinitionTag)gql"sv, R"md()md"sv, { introspection::DirectiveLocation::FRAGMENT_DEFINITION }, { - schema::InputValue::Make(R"gql(fragmentDefinition)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("String")), R"gql()gql"sv) + schema::InputValue::Make(R"gql(fragmentDefinition)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(String)gql"sv)), R"gql()gql"sv) })); schema->AddDirective(schema::Directive::Make(R"gql(fragmentSpreadTag)gql"sv, R"md()md"sv, { introspection::DirectiveLocation::FRAGMENT_SPREAD }, { - schema::InputValue::Make(R"gql(fragmentSpread)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("String")), R"gql()gql"sv) + schema::InputValue::Make(R"gql(fragmentSpread)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(String)gql"sv)), R"gql()gql"sv) })); schema->AddDirective(schema::Directive::Make(R"gql(inlineFragmentTag)gql"sv, R"md()md"sv, { introspection::DirectiveLocation::INLINE_FRAGMENT }, { - schema::InputValue::Make(R"gql(inlineFragment)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("String")), R"gql()gql"sv) + schema::InputValue::Make(R"gql(inlineFragment)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(String)gql"sv)), R"gql()gql"sv) })); schema->AddQueryType(typeQuery); diff --git a/samples/today/separate_nointrospection/AppointmentConnectionObject.cpp b/samples/today/separate_nointrospection/AppointmentConnectionObject.cpp index 446723de..d76c2276 100644 --- a/samples/today/separate_nointrospection/AppointmentConnectionObject.cpp +++ b/samples/today/separate_nointrospection/AppointmentConnectionObject.cpp @@ -80,8 +80,8 @@ service::AwaitableResolver AppointmentConnection::resolve_typename(service::Reso void AddAppointmentConnectionDetails(const std::shared_ptr& typeAppointmentConnection, const std::shared_ptr& schema) { typeAppointmentConnection->AddFields({ - schema::Field::Make(R"gql(pageInfo)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("PageInfo"))), - schema::Field::Make(R"gql(edges)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::LIST, schema->LookupType("AppointmentEdge"))) + schema::Field::Make(R"gql(pageInfo)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(PageInfo)gql"sv))), + schema::Field::Make(R"gql(edges)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::LIST, schema->LookupType(R"gql(AppointmentEdge)gql"sv))) }); } diff --git a/samples/today/separate_nointrospection/AppointmentEdgeObject.cpp b/samples/today/separate_nointrospection/AppointmentEdgeObject.cpp index 84742a4a..a9e09f8d 100644 --- a/samples/today/separate_nointrospection/AppointmentEdgeObject.cpp +++ b/samples/today/separate_nointrospection/AppointmentEdgeObject.cpp @@ -80,8 +80,8 @@ service::AwaitableResolver AppointmentEdge::resolve_typename(service::ResolverPa void AddAppointmentEdgeDetails(const std::shared_ptr& typeAppointmentEdge, const std::shared_ptr& schema) { typeAppointmentEdge->AddFields({ - schema::Field::Make(R"gql(node)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType("Appointment")), - schema::Field::Make(R"gql(cursor)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("ItemCursor"))) + schema::Field::Make(R"gql(node)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(Appointment)gql"sv)), + schema::Field::Make(R"gql(cursor)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ItemCursor)gql"sv))) }); } diff --git a/samples/today/separate_nointrospection/AppointmentObject.cpp b/samples/today/separate_nointrospection/AppointmentObject.cpp index 3bc3745d..0225df19 100644 --- a/samples/today/separate_nointrospection/AppointmentObject.cpp +++ b/samples/today/separate_nointrospection/AppointmentObject.cpp @@ -118,11 +118,11 @@ void AddAppointmentDetails(const std::shared_ptr& typeAppoin std::static_pointer_cast(schema->LookupType(R"gql(Node)gql"sv)) }); typeAppointment->AddFields({ - schema::Field::Make(R"gql(id)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("ID"))), - schema::Field::Make(R"gql(when)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType("DateTime")), - schema::Field::Make(R"gql(subject)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType("String")), - schema::Field::Make(R"gql(isNow)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("Boolean"))), - schema::Field::Make(R"gql(forceError)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType("String")) + schema::Field::Make(R"gql(id)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ID)gql"sv))), + schema::Field::Make(R"gql(when)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(DateTime)gql"sv)), + schema::Field::Make(R"gql(subject)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(String)gql"sv)), + schema::Field::Make(R"gql(isNow)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Boolean)gql"sv))), + schema::Field::Make(R"gql(forceError)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(String)gql"sv)) }); } diff --git a/samples/today/separate_nointrospection/CompleteTaskPayloadObject.cpp b/samples/today/separate_nointrospection/CompleteTaskPayloadObject.cpp index aca47fd0..c47c1043 100644 --- a/samples/today/separate_nointrospection/CompleteTaskPayloadObject.cpp +++ b/samples/today/separate_nointrospection/CompleteTaskPayloadObject.cpp @@ -80,8 +80,8 @@ service::AwaitableResolver CompleteTaskPayload::resolve_typename(service::Resolv void AddCompleteTaskPayloadDetails(const std::shared_ptr& typeCompleteTaskPayload, const std::shared_ptr& schema) { typeCompleteTaskPayload->AddFields({ - schema::Field::Make(R"gql(task)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType("Task")), - schema::Field::Make(R"gql(clientMutationId)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType("String")) + schema::Field::Make(R"gql(task)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(Task)gql"sv)), + schema::Field::Make(R"gql(clientMutationId)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(String)gql"sv)) }); } diff --git a/samples/today/separate_nointrospection/ExpensiveObject.cpp b/samples/today/separate_nointrospection/ExpensiveObject.cpp index ab1b1008..c565b6b5 100644 --- a/samples/today/separate_nointrospection/ExpensiveObject.cpp +++ b/samples/today/separate_nointrospection/ExpensiveObject.cpp @@ -69,7 +69,7 @@ service::AwaitableResolver Expensive::resolve_typename(service::ResolverParams&& void AddExpensiveDetails(const std::shared_ptr& typeExpensive, const std::shared_ptr& schema) { typeExpensive->AddFields({ - schema::Field::Make(R"gql(order)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("Int"))) + schema::Field::Make(R"gql(order)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Int)gql"sv))) }); } diff --git a/samples/today/separate_nointrospection/FolderConnectionObject.cpp b/samples/today/separate_nointrospection/FolderConnectionObject.cpp index 1408c541..a2d54d07 100644 --- a/samples/today/separate_nointrospection/FolderConnectionObject.cpp +++ b/samples/today/separate_nointrospection/FolderConnectionObject.cpp @@ -80,8 +80,8 @@ service::AwaitableResolver FolderConnection::resolve_typename(service::ResolverP void AddFolderConnectionDetails(const std::shared_ptr& typeFolderConnection, const std::shared_ptr& schema) { typeFolderConnection->AddFields({ - schema::Field::Make(R"gql(pageInfo)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("PageInfo"))), - schema::Field::Make(R"gql(edges)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::LIST, schema->LookupType("FolderEdge"))) + schema::Field::Make(R"gql(pageInfo)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(PageInfo)gql"sv))), + schema::Field::Make(R"gql(edges)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::LIST, schema->LookupType(R"gql(FolderEdge)gql"sv))) }); } diff --git a/samples/today/separate_nointrospection/FolderEdgeObject.cpp b/samples/today/separate_nointrospection/FolderEdgeObject.cpp index 6022c600..64a84afb 100644 --- a/samples/today/separate_nointrospection/FolderEdgeObject.cpp +++ b/samples/today/separate_nointrospection/FolderEdgeObject.cpp @@ -80,8 +80,8 @@ service::AwaitableResolver FolderEdge::resolve_typename(service::ResolverParams& void AddFolderEdgeDetails(const std::shared_ptr& typeFolderEdge, const std::shared_ptr& schema) { typeFolderEdge->AddFields({ - schema::Field::Make(R"gql(node)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType("Folder")), - schema::Field::Make(R"gql(cursor)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("ItemCursor"))) + schema::Field::Make(R"gql(node)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(Folder)gql"sv)), + schema::Field::Make(R"gql(cursor)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ItemCursor)gql"sv))) }); } diff --git a/samples/today/separate_nointrospection/FolderObject.cpp b/samples/today/separate_nointrospection/FolderObject.cpp index 8c7406a2..18570792 100644 --- a/samples/today/separate_nointrospection/FolderObject.cpp +++ b/samples/today/separate_nointrospection/FolderObject.cpp @@ -96,9 +96,9 @@ void AddFolderDetails(const std::shared_ptr& typeFolder, con std::static_pointer_cast(schema->LookupType(R"gql(Node)gql"sv)) }); typeFolder->AddFields({ - schema::Field::Make(R"gql(id)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("ID"))), - schema::Field::Make(R"gql(name)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType("String")), - schema::Field::Make(R"gql(unreadCount)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("Int"))) + schema::Field::Make(R"gql(id)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ID)gql"sv))), + schema::Field::Make(R"gql(name)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(String)gql"sv)), + schema::Field::Make(R"gql(unreadCount)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Int)gql"sv))) }); } diff --git a/samples/today/separate_nointrospection/MutationObject.cpp b/samples/today/separate_nointrospection/MutationObject.cpp index a0ed9b90..cc915077 100644 --- a/samples/today/separate_nointrospection/MutationObject.cpp +++ b/samples/today/separate_nointrospection/MutationObject.cpp @@ -82,11 +82,11 @@ service::AwaitableResolver Mutation::resolve_typename(service::ResolverParams&& void AddMutationDetails(const std::shared_ptr& typeMutation, const std::shared_ptr& schema) { typeMutation->AddFields({ - schema::Field::Make(R"gql(completeTask)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("CompleteTaskPayload")), { - schema::InputValue::Make(R"gql(input)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("CompleteTaskInput")), R"gql()gql"sv) + schema::Field::Make(R"gql(completeTask)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(CompleteTaskPayload)gql"sv)), { + schema::InputValue::Make(R"gql(input)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(CompleteTaskInput)gql"sv)), R"gql()gql"sv) }), - schema::Field::Make(R"gql(setFloat)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("Float")), { - schema::InputValue::Make(R"gql(value)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("Float")), R"gql()gql"sv) + schema::Field::Make(R"gql(setFloat)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Float)gql"sv)), { + schema::InputValue::Make(R"gql(value)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Float)gql"sv)), R"gql()gql"sv) }) }); } diff --git a/samples/today/separate_nointrospection/NestedTypeObject.cpp b/samples/today/separate_nointrospection/NestedTypeObject.cpp index 4d8c7a94..a60f2597 100644 --- a/samples/today/separate_nointrospection/NestedTypeObject.cpp +++ b/samples/today/separate_nointrospection/NestedTypeObject.cpp @@ -80,8 +80,8 @@ service::AwaitableResolver NestedType::resolve_typename(service::ResolverParams& void AddNestedTypeDetails(const std::shared_ptr& typeNestedType, const std::shared_ptr& schema) { typeNestedType->AddFields({ - schema::Field::Make(R"gql(depth)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("Int"))), - schema::Field::Make(R"gql(nested)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("NestedType"))) + schema::Field::Make(R"gql(depth)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Int)gql"sv))), + schema::Field::Make(R"gql(nested)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(NestedType)gql"sv))) }); } diff --git a/samples/today/separate_nointrospection/NodeObject.cpp b/samples/today/separate_nointrospection/NodeObject.cpp index 7196db2b..73ea28b2 100644 --- a/samples/today/separate_nointrospection/NodeObject.cpp +++ b/samples/today/separate_nointrospection/NodeObject.cpp @@ -7,12 +7,6 @@ #include "graphqlservice/introspection/Introspection.h" -#include -#include -#include -#include -#include - using namespace std::literals; namespace graphql::today { @@ -39,7 +33,7 @@ void Node::endSelectionSet(const service::SelectionSetParams& params) const void AddNodeDetails(const std::shared_ptr& typeNode, const std::shared_ptr& schema) { typeNode->AddFields({ - schema::Field::Make(R"gql(id)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("ID"))) + schema::Field::Make(R"gql(id)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ID)gql"sv))) }); } diff --git a/samples/today/separate_nointrospection/PageInfoObject.cpp b/samples/today/separate_nointrospection/PageInfoObject.cpp index 87112979..d5b1758b 100644 --- a/samples/today/separate_nointrospection/PageInfoObject.cpp +++ b/samples/today/separate_nointrospection/PageInfoObject.cpp @@ -80,8 +80,8 @@ service::AwaitableResolver PageInfo::resolve_typename(service::ResolverParams&& void AddPageInfoDetails(const std::shared_ptr& typePageInfo, const std::shared_ptr& schema) { typePageInfo->AddFields({ - schema::Field::Make(R"gql(hasNextPage)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("Boolean"))), - schema::Field::Make(R"gql(hasPreviousPage)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("Boolean"))) + schema::Field::Make(R"gql(hasNextPage)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Boolean)gql"sv))), + schema::Field::Make(R"gql(hasPreviousPage)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Boolean)gql"sv))) }); } diff --git a/samples/today/separate_nointrospection/QueryObject.cpp b/samples/today/separate_nointrospection/QueryObject.cpp index cc7d9fcc..3139b75a 100644 --- a/samples/today/separate_nointrospection/QueryObject.cpp +++ b/samples/today/separate_nointrospection/QueryObject.cpp @@ -229,42 +229,42 @@ service::AwaitableResolver Query::resolve_typename(service::ResolverParams&& par void AddQueryDetails(const std::shared_ptr& typeQuery, const std::shared_ptr& schema) { typeQuery->AddFields({ - schema::Field::Make(R"gql(node)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType("Node"), { - schema::InputValue::Make(R"gql(id)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("ID")), R"gql()gql"sv) + schema::Field::Make(R"gql(node)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(Node)gql"sv), { + schema::InputValue::Make(R"gql(id)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ID)gql"sv)), R"gql()gql"sv) }), - schema::Field::Make(R"gql(appointments)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("AppointmentConnection")), { - schema::InputValue::Make(R"gql(first)gql"sv, R"md()md"sv, schema->LookupType("Int"), R"gql()gql"sv), - schema::InputValue::Make(R"gql(after)gql"sv, R"md()md"sv, schema->LookupType("ItemCursor"), R"gql()gql"sv), - schema::InputValue::Make(R"gql(last)gql"sv, R"md()md"sv, schema->LookupType("Int"), R"gql()gql"sv), - schema::InputValue::Make(R"gql(before)gql"sv, R"md()md"sv, schema->LookupType("ItemCursor"), R"gql()gql"sv) + schema::Field::Make(R"gql(appointments)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(AppointmentConnection)gql"sv)), { + schema::InputValue::Make(R"gql(first)gql"sv, R"md()md"sv, schema->LookupType(R"gql(Int)gql"sv), R"gql()gql"sv), + schema::InputValue::Make(R"gql(after)gql"sv, R"md()md"sv, schema->LookupType(R"gql(ItemCursor)gql"sv), R"gql()gql"sv), + schema::InputValue::Make(R"gql(last)gql"sv, R"md()md"sv, schema->LookupType(R"gql(Int)gql"sv), R"gql()gql"sv), + schema::InputValue::Make(R"gql(before)gql"sv, R"md()md"sv, schema->LookupType(R"gql(ItemCursor)gql"sv), R"gql()gql"sv) }), - schema::Field::Make(R"gql(tasks)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("TaskConnection")), { - schema::InputValue::Make(R"gql(first)gql"sv, R"md()md"sv, schema->LookupType("Int"), R"gql()gql"sv), - schema::InputValue::Make(R"gql(after)gql"sv, R"md()md"sv, schema->LookupType("ItemCursor"), R"gql()gql"sv), - schema::InputValue::Make(R"gql(last)gql"sv, R"md()md"sv, schema->LookupType("Int"), R"gql()gql"sv), - schema::InputValue::Make(R"gql(before)gql"sv, R"md()md"sv, schema->LookupType("ItemCursor"), R"gql()gql"sv) + schema::Field::Make(R"gql(tasks)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(TaskConnection)gql"sv)), { + schema::InputValue::Make(R"gql(first)gql"sv, R"md()md"sv, schema->LookupType(R"gql(Int)gql"sv), R"gql()gql"sv), + schema::InputValue::Make(R"gql(after)gql"sv, R"md()md"sv, schema->LookupType(R"gql(ItemCursor)gql"sv), R"gql()gql"sv), + schema::InputValue::Make(R"gql(last)gql"sv, R"md()md"sv, schema->LookupType(R"gql(Int)gql"sv), R"gql()gql"sv), + schema::InputValue::Make(R"gql(before)gql"sv, R"md()md"sv, schema->LookupType(R"gql(ItemCursor)gql"sv), R"gql()gql"sv) }), - schema::Field::Make(R"gql(unreadCounts)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("FolderConnection")), { - schema::InputValue::Make(R"gql(first)gql"sv, R"md()md"sv, schema->LookupType("Int"), R"gql()gql"sv), - schema::InputValue::Make(R"gql(after)gql"sv, R"md()md"sv, schema->LookupType("ItemCursor"), R"gql()gql"sv), - schema::InputValue::Make(R"gql(last)gql"sv, R"md()md"sv, schema->LookupType("Int"), R"gql()gql"sv), - schema::InputValue::Make(R"gql(before)gql"sv, R"md()md"sv, schema->LookupType("ItemCursor"), R"gql()gql"sv) + schema::Field::Make(R"gql(unreadCounts)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(FolderConnection)gql"sv)), { + schema::InputValue::Make(R"gql(first)gql"sv, R"md()md"sv, schema->LookupType(R"gql(Int)gql"sv), R"gql()gql"sv), + schema::InputValue::Make(R"gql(after)gql"sv, R"md()md"sv, schema->LookupType(R"gql(ItemCursor)gql"sv), R"gql()gql"sv), + schema::InputValue::Make(R"gql(last)gql"sv, R"md()md"sv, schema->LookupType(R"gql(Int)gql"sv), R"gql()gql"sv), + schema::InputValue::Make(R"gql(before)gql"sv, R"md()md"sv, schema->LookupType(R"gql(ItemCursor)gql"sv), R"gql()gql"sv) }), - schema::Field::Make(R"gql(appointmentsById)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->LookupType("Appointment"))), { - schema::InputValue::Make(R"gql(ids)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("ID")))), R"gql(["ZmFrZUFwcG9pbnRtZW50SWQ="])gql"sv) + schema::Field::Make(R"gql(appointmentsById)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->LookupType(R"gql(Appointment)gql"sv))), { + schema::InputValue::Make(R"gql(ids)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ID)gql"sv)))), R"gql(["ZmFrZUFwcG9pbnRtZW50SWQ="])gql"sv) }), - schema::Field::Make(R"gql(tasksById)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->LookupType("Task"))), { - schema::InputValue::Make(R"gql(ids)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("ID")))), R"gql()gql"sv) + schema::Field::Make(R"gql(tasksById)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->LookupType(R"gql(Task)gql"sv))), { + schema::InputValue::Make(R"gql(ids)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ID)gql"sv)))), R"gql()gql"sv) }), - schema::Field::Make(R"gql(unreadCountsById)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->LookupType("Folder"))), { - schema::InputValue::Make(R"gql(ids)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("ID")))), R"gql()gql"sv) + schema::Field::Make(R"gql(unreadCountsById)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->LookupType(R"gql(Folder)gql"sv))), { + schema::InputValue::Make(R"gql(ids)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ID)gql"sv)))), R"gql()gql"sv) }), - schema::Field::Make(R"gql(nested)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("NestedType"))), - schema::Field::Make(R"gql(unimplemented)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("String"))), - schema::Field::Make(R"gql(expensive)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("Expensive"))))), - schema::Field::Make(R"gql(testTaskState)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("TaskState"))), - schema::Field::Make(R"gql(anyType)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->LookupType("UnionType"))), { - schema::InputValue::Make(R"gql(ids)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("ID")))), R"gql()gql"sv) + schema::Field::Make(R"gql(nested)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(NestedType)gql"sv))), + schema::Field::Make(R"gql(unimplemented)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(String)gql"sv))), + schema::Field::Make(R"gql(expensive)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Expensive)gql"sv))))), + schema::Field::Make(R"gql(testTaskState)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(TaskState)gql"sv))), + schema::Field::Make(R"gql(anyType)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->LookupType(R"gql(UnionType)gql"sv))), { + schema::InputValue::Make(R"gql(ids)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ID)gql"sv)))), R"gql()gql"sv) }) }); } diff --git a/samples/today/separate_nointrospection/SubscriptionObject.cpp b/samples/today/separate_nointrospection/SubscriptionObject.cpp index 8c7b5321..45df7373 100644 --- a/samples/today/separate_nointrospection/SubscriptionObject.cpp +++ b/samples/today/separate_nointrospection/SubscriptionObject.cpp @@ -81,9 +81,9 @@ service::AwaitableResolver Subscription::resolve_typename(service::ResolverParam void AddSubscriptionDetails(const std::shared_ptr& typeSubscription, const std::shared_ptr& schema) { typeSubscription->AddFields({ - schema::Field::Make(R"gql(nextAppointmentChange)gql"sv, R"md()md"sv, std::make_optional(R"md(Need to deprecate a [field](http://spec.graphql.org/June2018/#sec-Deprecation))md"sv), schema->LookupType("Appointment")), - schema::Field::Make(R"gql(nodeChange)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("Node")), { - schema::InputValue::Make(R"gql(id)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("ID")), R"gql()gql"sv) + schema::Field::Make(R"gql(nextAppointmentChange)gql"sv, R"md()md"sv, std::make_optional(R"md(Need to deprecate a [field](http://spec.graphql.org/June2018/#sec-Deprecation))md"sv), schema->LookupType(R"gql(Appointment)gql"sv)), + schema::Field::Make(R"gql(nodeChange)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Node)gql"sv)), { + schema::InputValue::Make(R"gql(id)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ID)gql"sv)), R"gql()gql"sv) }) }); } diff --git a/samples/today/separate_nointrospection/TaskConnectionObject.cpp b/samples/today/separate_nointrospection/TaskConnectionObject.cpp index b1e9da1f..64917a00 100644 --- a/samples/today/separate_nointrospection/TaskConnectionObject.cpp +++ b/samples/today/separate_nointrospection/TaskConnectionObject.cpp @@ -80,8 +80,8 @@ service::AwaitableResolver TaskConnection::resolve_typename(service::ResolverPar void AddTaskConnectionDetails(const std::shared_ptr& typeTaskConnection, const std::shared_ptr& schema) { typeTaskConnection->AddFields({ - schema::Field::Make(R"gql(pageInfo)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("PageInfo"))), - schema::Field::Make(R"gql(edges)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::LIST, schema->LookupType("TaskEdge"))) + schema::Field::Make(R"gql(pageInfo)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(PageInfo)gql"sv))), + schema::Field::Make(R"gql(edges)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::LIST, schema->LookupType(R"gql(TaskEdge)gql"sv))) }); } diff --git a/samples/today/separate_nointrospection/TaskEdgeObject.cpp b/samples/today/separate_nointrospection/TaskEdgeObject.cpp index ff7758d4..c8780958 100644 --- a/samples/today/separate_nointrospection/TaskEdgeObject.cpp +++ b/samples/today/separate_nointrospection/TaskEdgeObject.cpp @@ -80,8 +80,8 @@ service::AwaitableResolver TaskEdge::resolve_typename(service::ResolverParams&& void AddTaskEdgeDetails(const std::shared_ptr& typeTaskEdge, const std::shared_ptr& schema) { typeTaskEdge->AddFields({ - schema::Field::Make(R"gql(node)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType("Task")), - schema::Field::Make(R"gql(cursor)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("ItemCursor"))) + schema::Field::Make(R"gql(node)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(Task)gql"sv)), + schema::Field::Make(R"gql(cursor)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ItemCursor)gql"sv))) }); } diff --git a/samples/today/separate_nointrospection/TaskObject.cpp b/samples/today/separate_nointrospection/TaskObject.cpp index bdc7596c..46d6e2a1 100644 --- a/samples/today/separate_nointrospection/TaskObject.cpp +++ b/samples/today/separate_nointrospection/TaskObject.cpp @@ -96,9 +96,9 @@ void AddTaskDetails(const std::shared_ptr& typeTask, const s std::static_pointer_cast(schema->LookupType(R"gql(Node)gql"sv)) }); typeTask->AddFields({ - schema::Field::Make(R"gql(id)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("ID"))), - schema::Field::Make(R"gql(title)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType("String")), - schema::Field::Make(R"gql(isComplete)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("Boolean"))) + schema::Field::Make(R"gql(id)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ID)gql"sv))), + schema::Field::Make(R"gql(title)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(String)gql"sv)), + schema::Field::Make(R"gql(isComplete)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Boolean)gql"sv))) }); } diff --git a/samples/today/separate_nointrospection/TodaySchema.cpp b/samples/today/separate_nointrospection/TodaySchema.cpp index 88fc302b..87e2308a 100644 --- a/samples/today/separate_nointrospection/TodaySchema.cpp +++ b/samples/today/separate_nointrospection/TodaySchema.cpp @@ -213,25 +213,25 @@ void AddTypesToSchema(const std::shared_ptr& schema) }); typeCompleteTaskInput->AddInputValues({ - schema::InputValue::Make(R"gql(id)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("ID")), R"gql()gql"sv), - schema::InputValue::Make(R"gql(testTaskState)gql"sv, R"md()md"sv, schema->LookupType("TaskState"), R"gql()gql"sv), - schema::InputValue::Make(R"gql(isComplete)gql"sv, R"md()md"sv, schema->LookupType("Boolean"), R"gql(true)gql"sv), - schema::InputValue::Make(R"gql(clientMutationId)gql"sv, R"md()md"sv, schema->LookupType("String"), R"gql()gql"sv) + schema::InputValue::Make(R"gql(id)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ID)gql"sv)), R"gql()gql"sv), + schema::InputValue::Make(R"gql(testTaskState)gql"sv, R"md()md"sv, schema->LookupType(R"gql(TaskState)gql"sv), R"gql()gql"sv), + schema::InputValue::Make(R"gql(isComplete)gql"sv, R"md()md"sv, schema->LookupType(R"gql(Boolean)gql"sv), R"gql(true)gql"sv), + schema::InputValue::Make(R"gql(clientMutationId)gql"sv, R"md()md"sv, schema->LookupType(R"gql(String)gql"sv), R"gql()gql"sv) }); typeThirdNestedInput->AddInputValues({ - schema::InputValue::Make(R"gql(id)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("ID")), R"gql()gql"sv) + schema::InputValue::Make(R"gql(id)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ID)gql"sv)), R"gql()gql"sv) }); typeFourthNestedInput->AddInputValues({ - schema::InputValue::Make(R"gql(id)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("ID")), R"gql()gql"sv) + schema::InputValue::Make(R"gql(id)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ID)gql"sv)), R"gql()gql"sv) }); typeSecondNestedInput->AddInputValues({ - schema::InputValue::Make(R"gql(id)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("ID")), R"gql()gql"sv), - schema::InputValue::Make(R"gql(third)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("ThirdNestedInput")), R"gql()gql"sv) + schema::InputValue::Make(R"gql(id)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ID)gql"sv)), R"gql()gql"sv), + schema::InputValue::Make(R"gql(third)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ThirdNestedInput)gql"sv)), R"gql()gql"sv) }); typeFirstNestedInput->AddInputValues({ - schema::InputValue::Make(R"gql(id)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("ID")), R"gql()gql"sv), - schema::InputValue::Make(R"gql(second)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("SecondNestedInput")), R"gql()gql"sv), - schema::InputValue::Make(R"gql(third)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("ThirdNestedInput")), R"gql()gql"sv) + schema::InputValue::Make(R"gql(id)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ID)gql"sv)), R"gql()gql"sv), + schema::InputValue::Make(R"gql(second)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(SecondNestedInput)gql"sv)), R"gql()gql"sv), + schema::InputValue::Make(R"gql(third)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ThirdNestedInput)gql"sv)), R"gql()gql"sv) }); typeUnionType->AddPossibleTypes({ @@ -265,32 +265,32 @@ void AddTypesToSchema(const std::shared_ptr& schema) schema->AddDirective(schema::Directive::Make(R"gql(subscriptionTag)gql"sv, R"md()md"sv, { introspection::DirectiveLocation::SUBSCRIPTION }, { - schema::InputValue::Make(R"gql(field)gql"sv, R"md()md"sv, schema->LookupType("String"), R"gql()gql"sv) + schema::InputValue::Make(R"gql(field)gql"sv, R"md()md"sv, schema->LookupType(R"gql(String)gql"sv), R"gql()gql"sv) })); schema->AddDirective(schema::Directive::Make(R"gql(queryTag)gql"sv, R"md()md"sv, { introspection::DirectiveLocation::QUERY }, { - schema::InputValue::Make(R"gql(query)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("String")), R"gql()gql"sv) + schema::InputValue::Make(R"gql(query)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(String)gql"sv)), R"gql()gql"sv) })); schema->AddDirective(schema::Directive::Make(R"gql(fieldTag)gql"sv, R"md()md"sv, { introspection::DirectiveLocation::FIELD }, { - schema::InputValue::Make(R"gql(field)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("String")), R"gql()gql"sv) + schema::InputValue::Make(R"gql(field)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(String)gql"sv)), R"gql()gql"sv) })); schema->AddDirective(schema::Directive::Make(R"gql(fragmentDefinitionTag)gql"sv, R"md()md"sv, { introspection::DirectiveLocation::FRAGMENT_DEFINITION }, { - schema::InputValue::Make(R"gql(fragmentDefinition)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("String")), R"gql()gql"sv) + schema::InputValue::Make(R"gql(fragmentDefinition)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(String)gql"sv)), R"gql()gql"sv) })); schema->AddDirective(schema::Directive::Make(R"gql(fragmentSpreadTag)gql"sv, R"md()md"sv, { introspection::DirectiveLocation::FRAGMENT_SPREAD }, { - schema::InputValue::Make(R"gql(fragmentSpread)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("String")), R"gql()gql"sv) + schema::InputValue::Make(R"gql(fragmentSpread)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(String)gql"sv)), R"gql()gql"sv) })); schema->AddDirective(schema::Directive::Make(R"gql(inlineFragmentTag)gql"sv, R"md()md"sv, { introspection::DirectiveLocation::INLINE_FRAGMENT }, { - schema::InputValue::Make(R"gql(inlineFragment)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("String")), R"gql()gql"sv) + schema::InputValue::Make(R"gql(inlineFragment)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(String)gql"sv)), R"gql()gql"sv) })); schema->AddQueryType(typeQuery); diff --git a/samples/today/unified/TodaySchema.cpp b/samples/today/unified/TodaySchema.cpp index 3688b3a8..071b4333 100644 --- a/samples/today/unified/TodaySchema.cpp +++ b/samples/today/unified/TodaySchema.cpp @@ -1363,25 +1363,25 @@ void AddTypesToSchema(const std::shared_ptr& schema) }); typeCompleteTaskInput->AddInputValues({ - schema::InputValue::Make(R"gql(id)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("ID")), R"gql()gql"sv), - schema::InputValue::Make(R"gql(testTaskState)gql"sv, R"md()md"sv, schema->LookupType("TaskState"), R"gql()gql"sv), - schema::InputValue::Make(R"gql(isComplete)gql"sv, R"md()md"sv, schema->LookupType("Boolean"), R"gql(true)gql"sv), - schema::InputValue::Make(R"gql(clientMutationId)gql"sv, R"md()md"sv, schema->LookupType("String"), R"gql()gql"sv) + schema::InputValue::Make(R"gql(id)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ID)gql"sv)), R"gql()gql"sv), + schema::InputValue::Make(R"gql(testTaskState)gql"sv, R"md()md"sv, schema->LookupType(R"gql(TaskState)gql"sv), R"gql()gql"sv), + schema::InputValue::Make(R"gql(isComplete)gql"sv, R"md()md"sv, schema->LookupType(R"gql(Boolean)gql"sv), R"gql(true)gql"sv), + schema::InputValue::Make(R"gql(clientMutationId)gql"sv, R"md()md"sv, schema->LookupType(R"gql(String)gql"sv), R"gql()gql"sv) }); typeThirdNestedInput->AddInputValues({ - schema::InputValue::Make(R"gql(id)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("ID")), R"gql()gql"sv) + schema::InputValue::Make(R"gql(id)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ID)gql"sv)), R"gql()gql"sv) }); typeFourthNestedInput->AddInputValues({ - schema::InputValue::Make(R"gql(id)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("ID")), R"gql()gql"sv) + schema::InputValue::Make(R"gql(id)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ID)gql"sv)), R"gql()gql"sv) }); typeSecondNestedInput->AddInputValues({ - schema::InputValue::Make(R"gql(id)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("ID")), R"gql()gql"sv), - schema::InputValue::Make(R"gql(third)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("ThirdNestedInput")), R"gql()gql"sv) + schema::InputValue::Make(R"gql(id)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ID)gql"sv)), R"gql()gql"sv), + schema::InputValue::Make(R"gql(third)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ThirdNestedInput)gql"sv)), R"gql()gql"sv) }); typeFirstNestedInput->AddInputValues({ - schema::InputValue::Make(R"gql(id)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("ID")), R"gql()gql"sv), - schema::InputValue::Make(R"gql(second)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("SecondNestedInput")), R"gql()gql"sv), - schema::InputValue::Make(R"gql(third)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("ThirdNestedInput")), R"gql()gql"sv) + schema::InputValue::Make(R"gql(id)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ID)gql"sv)), R"gql()gql"sv), + schema::InputValue::Make(R"gql(second)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(SecondNestedInput)gql"sv)), R"gql()gql"sv), + schema::InputValue::Make(R"gql(third)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ThirdNestedInput)gql"sv)), R"gql()gql"sv) }); typeUnionType->AddPossibleTypes({ @@ -1391,126 +1391,126 @@ void AddTypesToSchema(const std::shared_ptr& schema) }); typeNode->AddFields({ - schema::Field::Make(R"gql(id)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("ID"))) + schema::Field::Make(R"gql(id)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ID)gql"sv))) }); typeQuery->AddFields({ - schema::Field::Make(R"gql(node)gql"sv, R"md([Object Identification](https://facebook.github.io/relay/docs/en/graphql-server-specification.html#object-identification))md"sv, std::nullopt, schema->LookupType("Node"), { - schema::InputValue::Make(R"gql(id)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("ID")), R"gql()gql"sv) + schema::Field::Make(R"gql(node)gql"sv, R"md([Object Identification](https://facebook.github.io/relay/docs/en/graphql-server-specification.html#object-identification))md"sv, std::nullopt, schema->LookupType(R"gql(Node)gql"sv), { + schema::InputValue::Make(R"gql(id)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ID)gql"sv)), R"gql()gql"sv) }), - schema::Field::Make(R"gql(appointments)gql"sv, R"md(Appointments [Connection](https://facebook.github.io/relay/docs/en/graphql-server-specification.html#connections))md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("AppointmentConnection")), { - schema::InputValue::Make(R"gql(first)gql"sv, R"md()md"sv, schema->LookupType("Int"), R"gql()gql"sv), - schema::InputValue::Make(R"gql(after)gql"sv, R"md()md"sv, schema->LookupType("ItemCursor"), R"gql()gql"sv), - schema::InputValue::Make(R"gql(last)gql"sv, R"md()md"sv, schema->LookupType("Int"), R"gql()gql"sv), - schema::InputValue::Make(R"gql(before)gql"sv, R"md()md"sv, schema->LookupType("ItemCursor"), R"gql()gql"sv) + schema::Field::Make(R"gql(appointments)gql"sv, R"md(Appointments [Connection](https://facebook.github.io/relay/docs/en/graphql-server-specification.html#connections))md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(AppointmentConnection)gql"sv)), { + schema::InputValue::Make(R"gql(first)gql"sv, R"md()md"sv, schema->LookupType(R"gql(Int)gql"sv), R"gql()gql"sv), + schema::InputValue::Make(R"gql(after)gql"sv, R"md()md"sv, schema->LookupType(R"gql(ItemCursor)gql"sv), R"gql()gql"sv), + schema::InputValue::Make(R"gql(last)gql"sv, R"md()md"sv, schema->LookupType(R"gql(Int)gql"sv), R"gql()gql"sv), + schema::InputValue::Make(R"gql(before)gql"sv, R"md()md"sv, schema->LookupType(R"gql(ItemCursor)gql"sv), R"gql()gql"sv) }), - schema::Field::Make(R"gql(tasks)gql"sv, R"md(Tasks [Connection](https://facebook.github.io/relay/docs/en/graphql-server-specification.html#connections))md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("TaskConnection")), { - schema::InputValue::Make(R"gql(first)gql"sv, R"md()md"sv, schema->LookupType("Int"), R"gql()gql"sv), - schema::InputValue::Make(R"gql(after)gql"sv, R"md()md"sv, schema->LookupType("ItemCursor"), R"gql()gql"sv), - schema::InputValue::Make(R"gql(last)gql"sv, R"md()md"sv, schema->LookupType("Int"), R"gql()gql"sv), - schema::InputValue::Make(R"gql(before)gql"sv, R"md()md"sv, schema->LookupType("ItemCursor"), R"gql()gql"sv) + schema::Field::Make(R"gql(tasks)gql"sv, R"md(Tasks [Connection](https://facebook.github.io/relay/docs/en/graphql-server-specification.html#connections))md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(TaskConnection)gql"sv)), { + schema::InputValue::Make(R"gql(first)gql"sv, R"md()md"sv, schema->LookupType(R"gql(Int)gql"sv), R"gql()gql"sv), + schema::InputValue::Make(R"gql(after)gql"sv, R"md()md"sv, schema->LookupType(R"gql(ItemCursor)gql"sv), R"gql()gql"sv), + schema::InputValue::Make(R"gql(last)gql"sv, R"md()md"sv, schema->LookupType(R"gql(Int)gql"sv), R"gql()gql"sv), + schema::InputValue::Make(R"gql(before)gql"sv, R"md()md"sv, schema->LookupType(R"gql(ItemCursor)gql"sv), R"gql()gql"sv) }), - schema::Field::Make(R"gql(unreadCounts)gql"sv, R"md(Folder unread counts [Connection](https://facebook.github.io/relay/docs/en/graphql-server-specification.html#connections))md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("FolderConnection")), { - schema::InputValue::Make(R"gql(first)gql"sv, R"md()md"sv, schema->LookupType("Int"), R"gql()gql"sv), - schema::InputValue::Make(R"gql(after)gql"sv, R"md()md"sv, schema->LookupType("ItemCursor"), R"gql()gql"sv), - schema::InputValue::Make(R"gql(last)gql"sv, R"md()md"sv, schema->LookupType("Int"), R"gql()gql"sv), - schema::InputValue::Make(R"gql(before)gql"sv, R"md()md"sv, schema->LookupType("ItemCursor"), R"gql()gql"sv) + schema::Field::Make(R"gql(unreadCounts)gql"sv, R"md(Folder unread counts [Connection](https://facebook.github.io/relay/docs/en/graphql-server-specification.html#connections))md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(FolderConnection)gql"sv)), { + schema::InputValue::Make(R"gql(first)gql"sv, R"md()md"sv, schema->LookupType(R"gql(Int)gql"sv), R"gql()gql"sv), + schema::InputValue::Make(R"gql(after)gql"sv, R"md()md"sv, schema->LookupType(R"gql(ItemCursor)gql"sv), R"gql()gql"sv), + schema::InputValue::Make(R"gql(last)gql"sv, R"md()md"sv, schema->LookupType(R"gql(Int)gql"sv), R"gql()gql"sv), + schema::InputValue::Make(R"gql(before)gql"sv, R"md()md"sv, schema->LookupType(R"gql(ItemCursor)gql"sv), R"gql()gql"sv) }), - schema::Field::Make(R"gql(appointmentsById)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->LookupType("Appointment"))), { - schema::InputValue::Make(R"gql(ids)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("ID")))), R"gql(["ZmFrZUFwcG9pbnRtZW50SWQ="])gql"sv) + schema::Field::Make(R"gql(appointmentsById)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->LookupType(R"gql(Appointment)gql"sv))), { + schema::InputValue::Make(R"gql(ids)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ID)gql"sv)))), R"gql(["ZmFrZUFwcG9pbnRtZW50SWQ="])gql"sv) }), - schema::Field::Make(R"gql(tasksById)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->LookupType("Task"))), { - schema::InputValue::Make(R"gql(ids)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("ID")))), R"gql()gql"sv) + schema::Field::Make(R"gql(tasksById)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->LookupType(R"gql(Task)gql"sv))), { + schema::InputValue::Make(R"gql(ids)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ID)gql"sv)))), R"gql()gql"sv) }), - schema::Field::Make(R"gql(unreadCountsById)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->LookupType("Folder"))), { - schema::InputValue::Make(R"gql(ids)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("ID")))), R"gql()gql"sv) + schema::Field::Make(R"gql(unreadCountsById)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->LookupType(R"gql(Folder)gql"sv))), { + schema::InputValue::Make(R"gql(ids)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ID)gql"sv)))), R"gql()gql"sv) }), - schema::Field::Make(R"gql(nested)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("NestedType"))), - schema::Field::Make(R"gql(unimplemented)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("String"))), - schema::Field::Make(R"gql(expensive)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("Expensive"))))), - schema::Field::Make(R"gql(testTaskState)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("TaskState"))), - schema::Field::Make(R"gql(anyType)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->LookupType("UnionType"))), { - schema::InputValue::Make(R"gql(ids)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("ID")))), R"gql()gql"sv) + schema::Field::Make(R"gql(nested)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(NestedType)gql"sv))), + schema::Field::Make(R"gql(unimplemented)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(String)gql"sv))), + schema::Field::Make(R"gql(expensive)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Expensive)gql"sv))))), + schema::Field::Make(R"gql(testTaskState)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(TaskState)gql"sv))), + schema::Field::Make(R"gql(anyType)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->LookupType(R"gql(UnionType)gql"sv))), { + schema::InputValue::Make(R"gql(ids)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ID)gql"sv)))), R"gql()gql"sv) }) }); typePageInfo->AddFields({ - schema::Field::Make(R"gql(hasNextPage)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("Boolean"))), - schema::Field::Make(R"gql(hasPreviousPage)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("Boolean"))) + schema::Field::Make(R"gql(hasNextPage)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Boolean)gql"sv))), + schema::Field::Make(R"gql(hasPreviousPage)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Boolean)gql"sv))) }); typeAppointmentEdge->AddFields({ - schema::Field::Make(R"gql(node)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType("Appointment")), - schema::Field::Make(R"gql(cursor)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("ItemCursor"))) + schema::Field::Make(R"gql(node)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(Appointment)gql"sv)), + schema::Field::Make(R"gql(cursor)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ItemCursor)gql"sv))) }); typeAppointmentConnection->AddFields({ - schema::Field::Make(R"gql(pageInfo)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("PageInfo"))), - schema::Field::Make(R"gql(edges)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::LIST, schema->LookupType("AppointmentEdge"))) + schema::Field::Make(R"gql(pageInfo)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(PageInfo)gql"sv))), + schema::Field::Make(R"gql(edges)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::LIST, schema->LookupType(R"gql(AppointmentEdge)gql"sv))) }); typeTaskEdge->AddFields({ - schema::Field::Make(R"gql(node)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType("Task")), - schema::Field::Make(R"gql(cursor)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("ItemCursor"))) + schema::Field::Make(R"gql(node)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(Task)gql"sv)), + schema::Field::Make(R"gql(cursor)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ItemCursor)gql"sv))) }); typeTaskConnection->AddFields({ - schema::Field::Make(R"gql(pageInfo)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("PageInfo"))), - schema::Field::Make(R"gql(edges)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::LIST, schema->LookupType("TaskEdge"))) + schema::Field::Make(R"gql(pageInfo)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(PageInfo)gql"sv))), + schema::Field::Make(R"gql(edges)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::LIST, schema->LookupType(R"gql(TaskEdge)gql"sv))) }); typeFolderEdge->AddFields({ - schema::Field::Make(R"gql(node)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType("Folder")), - schema::Field::Make(R"gql(cursor)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("ItemCursor"))) + schema::Field::Make(R"gql(node)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(Folder)gql"sv)), + schema::Field::Make(R"gql(cursor)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ItemCursor)gql"sv))) }); typeFolderConnection->AddFields({ - schema::Field::Make(R"gql(pageInfo)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("PageInfo"))), - schema::Field::Make(R"gql(edges)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::LIST, schema->LookupType("FolderEdge"))) + schema::Field::Make(R"gql(pageInfo)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(PageInfo)gql"sv))), + schema::Field::Make(R"gql(edges)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::LIST, schema->LookupType(R"gql(FolderEdge)gql"sv))) }); typeCompleteTaskPayload->AddFields({ - schema::Field::Make(R"gql(task)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType("Task")), - schema::Field::Make(R"gql(clientMutationId)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType("String")) + schema::Field::Make(R"gql(task)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(Task)gql"sv)), + schema::Field::Make(R"gql(clientMutationId)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(String)gql"sv)) }); typeMutation->AddFields({ - schema::Field::Make(R"gql(completeTask)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("CompleteTaskPayload")), { - schema::InputValue::Make(R"gql(input)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("CompleteTaskInput")), R"gql()gql"sv) + schema::Field::Make(R"gql(completeTask)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(CompleteTaskPayload)gql"sv)), { + schema::InputValue::Make(R"gql(input)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(CompleteTaskInput)gql"sv)), R"gql()gql"sv) }), - schema::Field::Make(R"gql(setFloat)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("Float")), { - schema::InputValue::Make(R"gql(value)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("Float")), R"gql()gql"sv) + schema::Field::Make(R"gql(setFloat)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Float)gql"sv)), { + schema::InputValue::Make(R"gql(value)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Float)gql"sv)), R"gql()gql"sv) }) }); typeSubscription->AddFields({ - schema::Field::Make(R"gql(nextAppointmentChange)gql"sv, R"md()md"sv, std::make_optional(R"md(Need to deprecate a [field](http://spec.graphql.org/June2018/#sec-Deprecation))md"sv), schema->LookupType("Appointment")), - schema::Field::Make(R"gql(nodeChange)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("Node")), { - schema::InputValue::Make(R"gql(id)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("ID")), R"gql()gql"sv) + schema::Field::Make(R"gql(nextAppointmentChange)gql"sv, R"md()md"sv, std::make_optional(R"md(Need to deprecate a [field](http://spec.graphql.org/June2018/#sec-Deprecation))md"sv), schema->LookupType(R"gql(Appointment)gql"sv)), + schema::Field::Make(R"gql(nodeChange)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Node)gql"sv)), { + schema::InputValue::Make(R"gql(id)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ID)gql"sv)), R"gql()gql"sv) }) }); typeAppointment->AddInterfaces({ typeNode }); typeAppointment->AddFields({ - schema::Field::Make(R"gql(id)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("ID"))), - schema::Field::Make(R"gql(when)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType("DateTime")), - schema::Field::Make(R"gql(subject)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType("String")), - schema::Field::Make(R"gql(isNow)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("Boolean"))), - schema::Field::Make(R"gql(forceError)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType("String")) + schema::Field::Make(R"gql(id)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ID)gql"sv))), + schema::Field::Make(R"gql(when)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(DateTime)gql"sv)), + schema::Field::Make(R"gql(subject)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(String)gql"sv)), + schema::Field::Make(R"gql(isNow)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Boolean)gql"sv))), + schema::Field::Make(R"gql(forceError)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(String)gql"sv)) }); typeTask->AddInterfaces({ typeNode }); typeTask->AddFields({ - schema::Field::Make(R"gql(id)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("ID"))), - schema::Field::Make(R"gql(title)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType("String")), - schema::Field::Make(R"gql(isComplete)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("Boolean"))) + schema::Field::Make(R"gql(id)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ID)gql"sv))), + schema::Field::Make(R"gql(title)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(String)gql"sv)), + schema::Field::Make(R"gql(isComplete)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Boolean)gql"sv))) }); typeFolder->AddInterfaces({ typeNode }); typeFolder->AddFields({ - schema::Field::Make(R"gql(id)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("ID"))), - schema::Field::Make(R"gql(name)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType("String")), - schema::Field::Make(R"gql(unreadCount)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("Int"))) + schema::Field::Make(R"gql(id)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ID)gql"sv))), + schema::Field::Make(R"gql(name)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(String)gql"sv)), + schema::Field::Make(R"gql(unreadCount)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Int)gql"sv))) }); typeNestedType->AddFields({ - schema::Field::Make(R"gql(depth)gql"sv, R"md(Depth of the nested element)md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("Int"))), - schema::Field::Make(R"gql(nested)gql"sv, R"md(Link to the next level)md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("NestedType"))) + schema::Field::Make(R"gql(depth)gql"sv, R"md(Depth of the nested element)md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Int)gql"sv))), + schema::Field::Make(R"gql(nested)gql"sv, R"md(Link to the next level)md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(NestedType)gql"sv))) }); typeExpensive->AddFields({ - schema::Field::Make(R"gql(order)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("Int"))) + schema::Field::Make(R"gql(order)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Int)gql"sv))) }); schema->AddDirective(schema::Directive::Make(R"gql(id)gql"sv, R"md()md"sv, { @@ -1519,32 +1519,32 @@ void AddTypesToSchema(const std::shared_ptr& schema) schema->AddDirective(schema::Directive::Make(R"gql(subscriptionTag)gql"sv, R"md()md"sv, { introspection::DirectiveLocation::SUBSCRIPTION }, { - schema::InputValue::Make(R"gql(field)gql"sv, R"md()md"sv, schema->LookupType("String"), R"gql()gql"sv) + schema::InputValue::Make(R"gql(field)gql"sv, R"md()md"sv, schema->LookupType(R"gql(String)gql"sv), R"gql()gql"sv) })); schema->AddDirective(schema::Directive::Make(R"gql(queryTag)gql"sv, R"md()md"sv, { introspection::DirectiveLocation::QUERY }, { - schema::InputValue::Make(R"gql(query)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("String")), R"gql()gql"sv) + schema::InputValue::Make(R"gql(query)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(String)gql"sv)), R"gql()gql"sv) })); schema->AddDirective(schema::Directive::Make(R"gql(fieldTag)gql"sv, R"md()md"sv, { introspection::DirectiveLocation::FIELD }, { - schema::InputValue::Make(R"gql(field)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("String")), R"gql()gql"sv) + schema::InputValue::Make(R"gql(field)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(String)gql"sv)), R"gql()gql"sv) })); schema->AddDirective(schema::Directive::Make(R"gql(fragmentDefinitionTag)gql"sv, R"md()md"sv, { introspection::DirectiveLocation::FRAGMENT_DEFINITION }, { - schema::InputValue::Make(R"gql(fragmentDefinition)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("String")), R"gql()gql"sv) + schema::InputValue::Make(R"gql(fragmentDefinition)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(String)gql"sv)), R"gql()gql"sv) })); schema->AddDirective(schema::Directive::Make(R"gql(fragmentSpreadTag)gql"sv, R"md()md"sv, { introspection::DirectiveLocation::FRAGMENT_SPREAD }, { - schema::InputValue::Make(R"gql(fragmentSpread)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("String")), R"gql()gql"sv) + schema::InputValue::Make(R"gql(fragmentSpread)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(String)gql"sv)), R"gql()gql"sv) })); schema->AddDirective(schema::Directive::Make(R"gql(inlineFragmentTag)gql"sv, R"md()md"sv, { introspection::DirectiveLocation::INLINE_FRAGMENT }, { - schema::InputValue::Make(R"gql(inlineFragment)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("String")), R"gql()gql"sv) + schema::InputValue::Make(R"gql(inlineFragment)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(String)gql"sv)), R"gql()gql"sv) })); schema->AddQueryType(typeQuery); diff --git a/samples/today/unified_nointrospection/TodaySchema.cpp b/samples/today/unified_nointrospection/TodaySchema.cpp index 23df1bb4..2b0d44f4 100644 --- a/samples/today/unified_nointrospection/TodaySchema.cpp +++ b/samples/today/unified_nointrospection/TodaySchema.cpp @@ -1346,25 +1346,25 @@ void AddTypesToSchema(const std::shared_ptr& schema) }); typeCompleteTaskInput->AddInputValues({ - schema::InputValue::Make(R"gql(id)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("ID")), R"gql()gql"sv), - schema::InputValue::Make(R"gql(testTaskState)gql"sv, R"md()md"sv, schema->LookupType("TaskState"), R"gql()gql"sv), - schema::InputValue::Make(R"gql(isComplete)gql"sv, R"md()md"sv, schema->LookupType("Boolean"), R"gql(true)gql"sv), - schema::InputValue::Make(R"gql(clientMutationId)gql"sv, R"md()md"sv, schema->LookupType("String"), R"gql()gql"sv) + schema::InputValue::Make(R"gql(id)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ID)gql"sv)), R"gql()gql"sv), + schema::InputValue::Make(R"gql(testTaskState)gql"sv, R"md()md"sv, schema->LookupType(R"gql(TaskState)gql"sv), R"gql()gql"sv), + schema::InputValue::Make(R"gql(isComplete)gql"sv, R"md()md"sv, schema->LookupType(R"gql(Boolean)gql"sv), R"gql(true)gql"sv), + schema::InputValue::Make(R"gql(clientMutationId)gql"sv, R"md()md"sv, schema->LookupType(R"gql(String)gql"sv), R"gql()gql"sv) }); typeThirdNestedInput->AddInputValues({ - schema::InputValue::Make(R"gql(id)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("ID")), R"gql()gql"sv) + schema::InputValue::Make(R"gql(id)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ID)gql"sv)), R"gql()gql"sv) }); typeFourthNestedInput->AddInputValues({ - schema::InputValue::Make(R"gql(id)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("ID")), R"gql()gql"sv) + schema::InputValue::Make(R"gql(id)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ID)gql"sv)), R"gql()gql"sv) }); typeSecondNestedInput->AddInputValues({ - schema::InputValue::Make(R"gql(id)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("ID")), R"gql()gql"sv), - schema::InputValue::Make(R"gql(third)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("ThirdNestedInput")), R"gql()gql"sv) + schema::InputValue::Make(R"gql(id)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ID)gql"sv)), R"gql()gql"sv), + schema::InputValue::Make(R"gql(third)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ThirdNestedInput)gql"sv)), R"gql()gql"sv) }); typeFirstNestedInput->AddInputValues({ - schema::InputValue::Make(R"gql(id)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("ID")), R"gql()gql"sv), - schema::InputValue::Make(R"gql(second)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("SecondNestedInput")), R"gql()gql"sv), - schema::InputValue::Make(R"gql(third)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("ThirdNestedInput")), R"gql()gql"sv) + schema::InputValue::Make(R"gql(id)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ID)gql"sv)), R"gql()gql"sv), + schema::InputValue::Make(R"gql(second)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(SecondNestedInput)gql"sv)), R"gql()gql"sv), + schema::InputValue::Make(R"gql(third)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ThirdNestedInput)gql"sv)), R"gql()gql"sv) }); typeUnionType->AddPossibleTypes({ @@ -1374,126 +1374,126 @@ void AddTypesToSchema(const std::shared_ptr& schema) }); typeNode->AddFields({ - schema::Field::Make(R"gql(id)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("ID"))) + schema::Field::Make(R"gql(id)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ID)gql"sv))) }); typeQuery->AddFields({ - schema::Field::Make(R"gql(node)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType("Node"), { - schema::InputValue::Make(R"gql(id)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("ID")), R"gql()gql"sv) + schema::Field::Make(R"gql(node)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(Node)gql"sv), { + schema::InputValue::Make(R"gql(id)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ID)gql"sv)), R"gql()gql"sv) }), - schema::Field::Make(R"gql(appointments)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("AppointmentConnection")), { - schema::InputValue::Make(R"gql(first)gql"sv, R"md()md"sv, schema->LookupType("Int"), R"gql()gql"sv), - schema::InputValue::Make(R"gql(after)gql"sv, R"md()md"sv, schema->LookupType("ItemCursor"), R"gql()gql"sv), - schema::InputValue::Make(R"gql(last)gql"sv, R"md()md"sv, schema->LookupType("Int"), R"gql()gql"sv), - schema::InputValue::Make(R"gql(before)gql"sv, R"md()md"sv, schema->LookupType("ItemCursor"), R"gql()gql"sv) + schema::Field::Make(R"gql(appointments)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(AppointmentConnection)gql"sv)), { + schema::InputValue::Make(R"gql(first)gql"sv, R"md()md"sv, schema->LookupType(R"gql(Int)gql"sv), R"gql()gql"sv), + schema::InputValue::Make(R"gql(after)gql"sv, R"md()md"sv, schema->LookupType(R"gql(ItemCursor)gql"sv), R"gql()gql"sv), + schema::InputValue::Make(R"gql(last)gql"sv, R"md()md"sv, schema->LookupType(R"gql(Int)gql"sv), R"gql()gql"sv), + schema::InputValue::Make(R"gql(before)gql"sv, R"md()md"sv, schema->LookupType(R"gql(ItemCursor)gql"sv), R"gql()gql"sv) }), - schema::Field::Make(R"gql(tasks)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("TaskConnection")), { - schema::InputValue::Make(R"gql(first)gql"sv, R"md()md"sv, schema->LookupType("Int"), R"gql()gql"sv), - schema::InputValue::Make(R"gql(after)gql"sv, R"md()md"sv, schema->LookupType("ItemCursor"), R"gql()gql"sv), - schema::InputValue::Make(R"gql(last)gql"sv, R"md()md"sv, schema->LookupType("Int"), R"gql()gql"sv), - schema::InputValue::Make(R"gql(before)gql"sv, R"md()md"sv, schema->LookupType("ItemCursor"), R"gql()gql"sv) + schema::Field::Make(R"gql(tasks)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(TaskConnection)gql"sv)), { + schema::InputValue::Make(R"gql(first)gql"sv, R"md()md"sv, schema->LookupType(R"gql(Int)gql"sv), R"gql()gql"sv), + schema::InputValue::Make(R"gql(after)gql"sv, R"md()md"sv, schema->LookupType(R"gql(ItemCursor)gql"sv), R"gql()gql"sv), + schema::InputValue::Make(R"gql(last)gql"sv, R"md()md"sv, schema->LookupType(R"gql(Int)gql"sv), R"gql()gql"sv), + schema::InputValue::Make(R"gql(before)gql"sv, R"md()md"sv, schema->LookupType(R"gql(ItemCursor)gql"sv), R"gql()gql"sv) }), - schema::Field::Make(R"gql(unreadCounts)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("FolderConnection")), { - schema::InputValue::Make(R"gql(first)gql"sv, R"md()md"sv, schema->LookupType("Int"), R"gql()gql"sv), - schema::InputValue::Make(R"gql(after)gql"sv, R"md()md"sv, schema->LookupType("ItemCursor"), R"gql()gql"sv), - schema::InputValue::Make(R"gql(last)gql"sv, R"md()md"sv, schema->LookupType("Int"), R"gql()gql"sv), - schema::InputValue::Make(R"gql(before)gql"sv, R"md()md"sv, schema->LookupType("ItemCursor"), R"gql()gql"sv) + schema::Field::Make(R"gql(unreadCounts)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(FolderConnection)gql"sv)), { + schema::InputValue::Make(R"gql(first)gql"sv, R"md()md"sv, schema->LookupType(R"gql(Int)gql"sv), R"gql()gql"sv), + schema::InputValue::Make(R"gql(after)gql"sv, R"md()md"sv, schema->LookupType(R"gql(ItemCursor)gql"sv), R"gql()gql"sv), + schema::InputValue::Make(R"gql(last)gql"sv, R"md()md"sv, schema->LookupType(R"gql(Int)gql"sv), R"gql()gql"sv), + schema::InputValue::Make(R"gql(before)gql"sv, R"md()md"sv, schema->LookupType(R"gql(ItemCursor)gql"sv), R"gql()gql"sv) }), - schema::Field::Make(R"gql(appointmentsById)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->LookupType("Appointment"))), { - schema::InputValue::Make(R"gql(ids)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("ID")))), R"gql(["ZmFrZUFwcG9pbnRtZW50SWQ="])gql"sv) + schema::Field::Make(R"gql(appointmentsById)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->LookupType(R"gql(Appointment)gql"sv))), { + schema::InputValue::Make(R"gql(ids)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ID)gql"sv)))), R"gql(["ZmFrZUFwcG9pbnRtZW50SWQ="])gql"sv) }), - schema::Field::Make(R"gql(tasksById)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->LookupType("Task"))), { - schema::InputValue::Make(R"gql(ids)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("ID")))), R"gql()gql"sv) + schema::Field::Make(R"gql(tasksById)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->LookupType(R"gql(Task)gql"sv))), { + schema::InputValue::Make(R"gql(ids)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ID)gql"sv)))), R"gql()gql"sv) }), - schema::Field::Make(R"gql(unreadCountsById)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->LookupType("Folder"))), { - schema::InputValue::Make(R"gql(ids)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("ID")))), R"gql()gql"sv) + schema::Field::Make(R"gql(unreadCountsById)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->LookupType(R"gql(Folder)gql"sv))), { + schema::InputValue::Make(R"gql(ids)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ID)gql"sv)))), R"gql()gql"sv) }), - schema::Field::Make(R"gql(nested)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("NestedType"))), - schema::Field::Make(R"gql(unimplemented)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("String"))), - schema::Field::Make(R"gql(expensive)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("Expensive"))))), - schema::Field::Make(R"gql(testTaskState)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("TaskState"))), - schema::Field::Make(R"gql(anyType)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->LookupType("UnionType"))), { - schema::InputValue::Make(R"gql(ids)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("ID")))), R"gql()gql"sv) + schema::Field::Make(R"gql(nested)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(NestedType)gql"sv))), + schema::Field::Make(R"gql(unimplemented)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(String)gql"sv))), + schema::Field::Make(R"gql(expensive)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Expensive)gql"sv))))), + schema::Field::Make(R"gql(testTaskState)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(TaskState)gql"sv))), + schema::Field::Make(R"gql(anyType)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->LookupType(R"gql(UnionType)gql"sv))), { + schema::InputValue::Make(R"gql(ids)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ID)gql"sv)))), R"gql()gql"sv) }) }); typePageInfo->AddFields({ - schema::Field::Make(R"gql(hasNextPage)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("Boolean"))), - schema::Field::Make(R"gql(hasPreviousPage)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("Boolean"))) + schema::Field::Make(R"gql(hasNextPage)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Boolean)gql"sv))), + schema::Field::Make(R"gql(hasPreviousPage)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Boolean)gql"sv))) }); typeAppointmentEdge->AddFields({ - schema::Field::Make(R"gql(node)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType("Appointment")), - schema::Field::Make(R"gql(cursor)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("ItemCursor"))) + schema::Field::Make(R"gql(node)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(Appointment)gql"sv)), + schema::Field::Make(R"gql(cursor)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ItemCursor)gql"sv))) }); typeAppointmentConnection->AddFields({ - schema::Field::Make(R"gql(pageInfo)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("PageInfo"))), - schema::Field::Make(R"gql(edges)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::LIST, schema->LookupType("AppointmentEdge"))) + schema::Field::Make(R"gql(pageInfo)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(PageInfo)gql"sv))), + schema::Field::Make(R"gql(edges)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::LIST, schema->LookupType(R"gql(AppointmentEdge)gql"sv))) }); typeTaskEdge->AddFields({ - schema::Field::Make(R"gql(node)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType("Task")), - schema::Field::Make(R"gql(cursor)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("ItemCursor"))) + schema::Field::Make(R"gql(node)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(Task)gql"sv)), + schema::Field::Make(R"gql(cursor)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ItemCursor)gql"sv))) }); typeTaskConnection->AddFields({ - schema::Field::Make(R"gql(pageInfo)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("PageInfo"))), - schema::Field::Make(R"gql(edges)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::LIST, schema->LookupType("TaskEdge"))) + schema::Field::Make(R"gql(pageInfo)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(PageInfo)gql"sv))), + schema::Field::Make(R"gql(edges)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::LIST, schema->LookupType(R"gql(TaskEdge)gql"sv))) }); typeFolderEdge->AddFields({ - schema::Field::Make(R"gql(node)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType("Folder")), - schema::Field::Make(R"gql(cursor)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("ItemCursor"))) + schema::Field::Make(R"gql(node)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(Folder)gql"sv)), + schema::Field::Make(R"gql(cursor)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ItemCursor)gql"sv))) }); typeFolderConnection->AddFields({ - schema::Field::Make(R"gql(pageInfo)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("PageInfo"))), - schema::Field::Make(R"gql(edges)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::LIST, schema->LookupType("FolderEdge"))) + schema::Field::Make(R"gql(pageInfo)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(PageInfo)gql"sv))), + schema::Field::Make(R"gql(edges)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::LIST, schema->LookupType(R"gql(FolderEdge)gql"sv))) }); typeCompleteTaskPayload->AddFields({ - schema::Field::Make(R"gql(task)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType("Task")), - schema::Field::Make(R"gql(clientMutationId)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType("String")) + schema::Field::Make(R"gql(task)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(Task)gql"sv)), + schema::Field::Make(R"gql(clientMutationId)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(String)gql"sv)) }); typeMutation->AddFields({ - schema::Field::Make(R"gql(completeTask)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("CompleteTaskPayload")), { - schema::InputValue::Make(R"gql(input)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("CompleteTaskInput")), R"gql()gql"sv) + schema::Field::Make(R"gql(completeTask)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(CompleteTaskPayload)gql"sv)), { + schema::InputValue::Make(R"gql(input)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(CompleteTaskInput)gql"sv)), R"gql()gql"sv) }), - schema::Field::Make(R"gql(setFloat)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("Float")), { - schema::InputValue::Make(R"gql(value)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("Float")), R"gql()gql"sv) + schema::Field::Make(R"gql(setFloat)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Float)gql"sv)), { + schema::InputValue::Make(R"gql(value)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Float)gql"sv)), R"gql()gql"sv) }) }); typeSubscription->AddFields({ - schema::Field::Make(R"gql(nextAppointmentChange)gql"sv, R"md()md"sv, std::make_optional(R"md(Need to deprecate a [field](http://spec.graphql.org/June2018/#sec-Deprecation))md"sv), schema->LookupType("Appointment")), - schema::Field::Make(R"gql(nodeChange)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("Node")), { - schema::InputValue::Make(R"gql(id)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("ID")), R"gql()gql"sv) + schema::Field::Make(R"gql(nextAppointmentChange)gql"sv, R"md()md"sv, std::make_optional(R"md(Need to deprecate a [field](http://spec.graphql.org/June2018/#sec-Deprecation))md"sv), schema->LookupType(R"gql(Appointment)gql"sv)), + schema::Field::Make(R"gql(nodeChange)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Node)gql"sv)), { + schema::InputValue::Make(R"gql(id)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ID)gql"sv)), R"gql()gql"sv) }) }); typeAppointment->AddInterfaces({ typeNode }); typeAppointment->AddFields({ - schema::Field::Make(R"gql(id)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("ID"))), - schema::Field::Make(R"gql(when)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType("DateTime")), - schema::Field::Make(R"gql(subject)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType("String")), - schema::Field::Make(R"gql(isNow)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("Boolean"))), - schema::Field::Make(R"gql(forceError)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType("String")) + schema::Field::Make(R"gql(id)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ID)gql"sv))), + schema::Field::Make(R"gql(when)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(DateTime)gql"sv)), + schema::Field::Make(R"gql(subject)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(String)gql"sv)), + schema::Field::Make(R"gql(isNow)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Boolean)gql"sv))), + schema::Field::Make(R"gql(forceError)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(String)gql"sv)) }); typeTask->AddInterfaces({ typeNode }); typeTask->AddFields({ - schema::Field::Make(R"gql(id)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("ID"))), - schema::Field::Make(R"gql(title)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType("String")), - schema::Field::Make(R"gql(isComplete)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("Boolean"))) + schema::Field::Make(R"gql(id)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ID)gql"sv))), + schema::Field::Make(R"gql(title)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(String)gql"sv)), + schema::Field::Make(R"gql(isComplete)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Boolean)gql"sv))) }); typeFolder->AddInterfaces({ typeNode }); typeFolder->AddFields({ - schema::Field::Make(R"gql(id)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("ID"))), - schema::Field::Make(R"gql(name)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType("String")), - schema::Field::Make(R"gql(unreadCount)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("Int"))) + schema::Field::Make(R"gql(id)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ID)gql"sv))), + schema::Field::Make(R"gql(name)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(String)gql"sv)), + schema::Field::Make(R"gql(unreadCount)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Int)gql"sv))) }); typeNestedType->AddFields({ - schema::Field::Make(R"gql(depth)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("Int"))), - schema::Field::Make(R"gql(nested)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("NestedType"))) + schema::Field::Make(R"gql(depth)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Int)gql"sv))), + schema::Field::Make(R"gql(nested)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(NestedType)gql"sv))) }); typeExpensive->AddFields({ - schema::Field::Make(R"gql(order)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("Int"))) + schema::Field::Make(R"gql(order)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Int)gql"sv))) }); schema->AddDirective(schema::Directive::Make(R"gql(id)gql"sv, R"md()md"sv, { @@ -1502,32 +1502,32 @@ void AddTypesToSchema(const std::shared_ptr& schema) schema->AddDirective(schema::Directive::Make(R"gql(subscriptionTag)gql"sv, R"md()md"sv, { introspection::DirectiveLocation::SUBSCRIPTION }, { - schema::InputValue::Make(R"gql(field)gql"sv, R"md()md"sv, schema->LookupType("String"), R"gql()gql"sv) + schema::InputValue::Make(R"gql(field)gql"sv, R"md()md"sv, schema->LookupType(R"gql(String)gql"sv), R"gql()gql"sv) })); schema->AddDirective(schema::Directive::Make(R"gql(queryTag)gql"sv, R"md()md"sv, { introspection::DirectiveLocation::QUERY }, { - schema::InputValue::Make(R"gql(query)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("String")), R"gql()gql"sv) + schema::InputValue::Make(R"gql(query)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(String)gql"sv)), R"gql()gql"sv) })); schema->AddDirective(schema::Directive::Make(R"gql(fieldTag)gql"sv, R"md()md"sv, { introspection::DirectiveLocation::FIELD }, { - schema::InputValue::Make(R"gql(field)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("String")), R"gql()gql"sv) + schema::InputValue::Make(R"gql(field)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(String)gql"sv)), R"gql()gql"sv) })); schema->AddDirective(schema::Directive::Make(R"gql(fragmentDefinitionTag)gql"sv, R"md()md"sv, { introspection::DirectiveLocation::FRAGMENT_DEFINITION }, { - schema::InputValue::Make(R"gql(fragmentDefinition)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("String")), R"gql()gql"sv) + schema::InputValue::Make(R"gql(fragmentDefinition)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(String)gql"sv)), R"gql()gql"sv) })); schema->AddDirective(schema::Directive::Make(R"gql(fragmentSpreadTag)gql"sv, R"md()md"sv, { introspection::DirectiveLocation::FRAGMENT_SPREAD }, { - schema::InputValue::Make(R"gql(fragmentSpread)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("String")), R"gql()gql"sv) + schema::InputValue::Make(R"gql(fragmentSpread)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(String)gql"sv)), R"gql()gql"sv) })); schema->AddDirective(schema::Directive::Make(R"gql(inlineFragmentTag)gql"sv, R"md()md"sv, { introspection::DirectiveLocation::INLINE_FRAGMENT }, { - schema::InputValue::Make(R"gql(inlineFragment)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("String")), R"gql()gql"sv) + schema::InputValue::Make(R"gql(inlineFragment)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(String)gql"sv)), R"gql()gql"sv) })); schema->AddQueryType(typeQuery); diff --git a/samples/validation/schema/ValidationSchema.cpp b/samples/validation/schema/ValidationSchema.cpp index 40a76761..5bf00f24 100644 --- a/samples/validation/schema/ValidationSchema.cpp +++ b/samples/validation/schema/ValidationSchema.cpp @@ -980,8 +980,8 @@ void AddTypesToSchema(const std::shared_ptr& schema) }); typeComplexInput->AddInputValues({ - schema::InputValue::Make(R"gql(name)gql"sv, R"md()md"sv, schema->LookupType("String"), R"gql()gql"sv), - schema::InputValue::Make(R"gql(owner)gql"sv, R"md()md"sv, schema->LookupType("String"), R"gql()gql"sv) + schema::InputValue::Make(R"gql(name)gql"sv, R"md()md"sv, schema->LookupType(R"gql(String)gql"sv), R"gql()gql"sv), + schema::InputValue::Make(R"gql(owner)gql"sv, R"md()md"sv, schema->LookupType(R"gql(String)gql"sv), R"gql()gql"sv) }); typeCatOrDog->AddPossibleTypes({ @@ -998,104 +998,104 @@ void AddTypesToSchema(const std::shared_ptr& schema) }); typeSentient->AddFields({ - schema::Field::Make(R"gql(name)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("String"))) + schema::Field::Make(R"gql(name)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(String)gql"sv))) }); typePet->AddFields({ - schema::Field::Make(R"gql(name)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("String"))) + schema::Field::Make(R"gql(name)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(String)gql"sv))) }); typeQuery->AddFields({ - schema::Field::Make(R"gql(dog)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType("Dog")), - schema::Field::Make(R"gql(human)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType("Human")), - schema::Field::Make(R"gql(pet)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType("Pet")), - schema::Field::Make(R"gql(catOrDog)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType("CatOrDog")), - schema::Field::Make(R"gql(arguments)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType("Arguments")), - schema::Field::Make(R"gql(findDog)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType("Dog"), { - schema::InputValue::Make(R"gql(complex)gql"sv, R"md()md"sv, schema->LookupType("ComplexInput"), R"gql()gql"sv) + schema::Field::Make(R"gql(dog)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(Dog)gql"sv)), + schema::Field::Make(R"gql(human)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(Human)gql"sv)), + schema::Field::Make(R"gql(pet)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(Pet)gql"sv)), + schema::Field::Make(R"gql(catOrDog)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(CatOrDog)gql"sv)), + schema::Field::Make(R"gql(arguments)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(Arguments)gql"sv)), + schema::Field::Make(R"gql(findDog)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(Dog)gql"sv), { + schema::InputValue::Make(R"gql(complex)gql"sv, R"md()md"sv, schema->LookupType(R"gql(ComplexInput)gql"sv), R"gql()gql"sv) }), - schema::Field::Make(R"gql(booleanList)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType("Boolean"), { - schema::InputValue::Make(R"gql(booleanListArg)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("Boolean"))), R"gql()gql"sv) + schema::Field::Make(R"gql(booleanList)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(Boolean)gql"sv), { + schema::InputValue::Make(R"gql(booleanListArg)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Boolean)gql"sv))), R"gql()gql"sv) }) }); typeDog->AddInterfaces({ typePet }); typeDog->AddFields({ - schema::Field::Make(R"gql(name)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("String"))), - schema::Field::Make(R"gql(nickname)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType("String")), - schema::Field::Make(R"gql(barkVolume)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType("Int")), - schema::Field::Make(R"gql(doesKnowCommand)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("Boolean")), { - schema::InputValue::Make(R"gql(dogCommand)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("DogCommand")), R"gql()gql"sv) + schema::Field::Make(R"gql(name)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(String)gql"sv))), + schema::Field::Make(R"gql(nickname)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(String)gql"sv)), + schema::Field::Make(R"gql(barkVolume)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(Int)gql"sv)), + schema::Field::Make(R"gql(doesKnowCommand)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Boolean)gql"sv)), { + schema::InputValue::Make(R"gql(dogCommand)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(DogCommand)gql"sv)), R"gql()gql"sv) }), - schema::Field::Make(R"gql(isHousetrained)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("Boolean")), { - schema::InputValue::Make(R"gql(atOtherHomes)gql"sv, R"md()md"sv, schema->LookupType("Boolean"), R"gql()gql"sv) + schema::Field::Make(R"gql(isHousetrained)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Boolean)gql"sv)), { + schema::InputValue::Make(R"gql(atOtherHomes)gql"sv, R"md()md"sv, schema->LookupType(R"gql(Boolean)gql"sv), R"gql()gql"sv) }), - schema::Field::Make(R"gql(owner)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType("Human")) + schema::Field::Make(R"gql(owner)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(Human)gql"sv)) }); typeAlien->AddInterfaces({ typeSentient }); typeAlien->AddFields({ - schema::Field::Make(R"gql(name)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("String"))), - schema::Field::Make(R"gql(homePlanet)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType("String")) + schema::Field::Make(R"gql(name)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(String)gql"sv))), + schema::Field::Make(R"gql(homePlanet)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(String)gql"sv)) }); typeHuman->AddInterfaces({ typeSentient }); typeHuman->AddFields({ - schema::Field::Make(R"gql(name)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("String"))), - schema::Field::Make(R"gql(pets)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("Pet"))))) + schema::Field::Make(R"gql(name)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(String)gql"sv))), + schema::Field::Make(R"gql(pets)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Pet)gql"sv))))) }); typeCat->AddInterfaces({ typePet }); typeCat->AddFields({ - schema::Field::Make(R"gql(name)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("String"))), - schema::Field::Make(R"gql(nickname)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType("String")), - schema::Field::Make(R"gql(doesKnowCommand)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("Boolean")), { - schema::InputValue::Make(R"gql(catCommand)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("CatCommand")), R"gql()gql"sv) + schema::Field::Make(R"gql(name)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(String)gql"sv))), + schema::Field::Make(R"gql(nickname)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(String)gql"sv)), + schema::Field::Make(R"gql(doesKnowCommand)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Boolean)gql"sv)), { + schema::InputValue::Make(R"gql(catCommand)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(CatCommand)gql"sv)), R"gql()gql"sv) }), - schema::Field::Make(R"gql(meowVolume)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType("Int")) + schema::Field::Make(R"gql(meowVolume)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(Int)gql"sv)) }); typeMutation->AddFields({ - schema::Field::Make(R"gql(mutateDog)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType("MutateDogResult")) + schema::Field::Make(R"gql(mutateDog)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(MutateDogResult)gql"sv)) }); typeMutateDogResult->AddFields({ - schema::Field::Make(R"gql(id)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("ID"))) + schema::Field::Make(R"gql(id)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ID)gql"sv))) }); typeSubscription->AddFields({ - schema::Field::Make(R"gql(newMessage)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("Message"))), - schema::Field::Make(R"gql(disallowedSecondRootField)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("Boolean"))) + schema::Field::Make(R"gql(newMessage)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Message)gql"sv))), + schema::Field::Make(R"gql(disallowedSecondRootField)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Boolean)gql"sv))) }); typeMessage->AddFields({ - schema::Field::Make(R"gql(body)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType("String")), - schema::Field::Make(R"gql(sender)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("ID"))) + schema::Field::Make(R"gql(body)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(String)gql"sv)), + schema::Field::Make(R"gql(sender)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ID)gql"sv))) }); typeArguments->AddFields({ - schema::Field::Make(R"gql(multipleReqs)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("Int")), { - schema::InputValue::Make(R"gql(x)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("Int")), R"gql()gql"sv), - schema::InputValue::Make(R"gql(y)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("Int")), R"gql()gql"sv) + schema::Field::Make(R"gql(multipleReqs)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Int)gql"sv)), { + schema::InputValue::Make(R"gql(x)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Int)gql"sv)), R"gql()gql"sv), + schema::InputValue::Make(R"gql(y)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Int)gql"sv)), R"gql()gql"sv) }), - schema::Field::Make(R"gql(booleanArgField)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType("Boolean"), { - schema::InputValue::Make(R"gql(booleanArg)gql"sv, R"md()md"sv, schema->LookupType("Boolean"), R"gql()gql"sv) + schema::Field::Make(R"gql(booleanArgField)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(Boolean)gql"sv), { + schema::InputValue::Make(R"gql(booleanArg)gql"sv, R"md()md"sv, schema->LookupType(R"gql(Boolean)gql"sv), R"gql()gql"sv) }), - schema::Field::Make(R"gql(floatArgField)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType("Float"), { - schema::InputValue::Make(R"gql(floatArg)gql"sv, R"md()md"sv, schema->LookupType("Float"), R"gql()gql"sv) + schema::Field::Make(R"gql(floatArgField)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(Float)gql"sv), { + schema::InputValue::Make(R"gql(floatArg)gql"sv, R"md()md"sv, schema->LookupType(R"gql(Float)gql"sv), R"gql()gql"sv) }), - schema::Field::Make(R"gql(intArgField)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType("Int"), { - schema::InputValue::Make(R"gql(intArg)gql"sv, R"md()md"sv, schema->LookupType("Int"), R"gql()gql"sv) + schema::Field::Make(R"gql(intArgField)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(Int)gql"sv), { + schema::InputValue::Make(R"gql(intArg)gql"sv, R"md()md"sv, schema->LookupType(R"gql(Int)gql"sv), R"gql()gql"sv) }), - schema::Field::Make(R"gql(nonNullBooleanArgField)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("Boolean")), { - schema::InputValue::Make(R"gql(nonNullBooleanArg)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("Boolean")), R"gql()gql"sv) + schema::Field::Make(R"gql(nonNullBooleanArgField)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Boolean)gql"sv)), { + schema::InputValue::Make(R"gql(nonNullBooleanArg)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Boolean)gql"sv)), R"gql()gql"sv) }), - schema::Field::Make(R"gql(nonNullBooleanListField)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("Boolean"))), { - schema::InputValue::Make(R"gql(nonNullBooleanListArg)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("Boolean"))), R"gql()gql"sv) + schema::Field::Make(R"gql(nonNullBooleanListField)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Boolean)gql"sv))), { + schema::InputValue::Make(R"gql(nonNullBooleanListArg)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Boolean)gql"sv))), R"gql()gql"sv) }), - schema::Field::Make(R"gql(booleanListArgField)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::LIST, schema->LookupType("Boolean")), { - schema::InputValue::Make(R"gql(booleanListArg)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->LookupType("Boolean"))), R"gql()gql"sv) + schema::Field::Make(R"gql(booleanListArgField)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::LIST, schema->LookupType(R"gql(Boolean)gql"sv)), { + schema::InputValue::Make(R"gql(booleanListArg)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->LookupType(R"gql(Boolean)gql"sv))), R"gql()gql"sv) }), - schema::Field::Make(R"gql(optionalNonNullBooleanArgField)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("Boolean")), { - schema::InputValue::Make(R"gql(optionalBooleanArg)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("Boolean")), R"gql(false)gql"sv) + schema::Field::Make(R"gql(optionalNonNullBooleanArgField)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Boolean)gql"sv)), { + schema::InputValue::Make(R"gql(optionalBooleanArg)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Boolean)gql"sv)), R"gql(false)gql"sv) }) }); diff --git a/src/IntrospectionSchema.cpp b/src/IntrospectionSchema.cpp index 84c7ed0d..76d9a59d 100644 --- a/src/IntrospectionSchema.cpp +++ b/src/IntrospectionSchema.cpp @@ -746,52 +746,52 @@ void AddTypesToSchema(const std::shared_ptr& schema) }); typeSchema->AddFields({ - schema::Field::Make(R"gql(types)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("__Type"))))), - schema::Field::Make(R"gql(queryType)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("__Type"))), - schema::Field::Make(R"gql(mutationType)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType("__Type")), - schema::Field::Make(R"gql(subscriptionType)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType("__Type")), - schema::Field::Make(R"gql(directives)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("__Directive"))))) + schema::Field::Make(R"gql(types)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(__Type)gql"sv))))), + schema::Field::Make(R"gql(queryType)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(__Type)gql"sv))), + schema::Field::Make(R"gql(mutationType)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(__Type)gql"sv)), + schema::Field::Make(R"gql(subscriptionType)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(__Type)gql"sv)), + schema::Field::Make(R"gql(directives)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(__Directive)gql"sv))))) }); typeType->AddFields({ - schema::Field::Make(R"gql(kind)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("__TypeKind"))), - schema::Field::Make(R"gql(name)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType("String")), - schema::Field::Make(R"gql(description)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType("String")), - schema::Field::Make(R"gql(fields)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("__Field"))), { - schema::InputValue::Make(R"gql(includeDeprecated)gql"sv, R"md()md"sv, schema->LookupType("Boolean"), R"gql(false)gql"sv) + schema::Field::Make(R"gql(kind)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(__TypeKind)gql"sv))), + schema::Field::Make(R"gql(name)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(String)gql"sv)), + schema::Field::Make(R"gql(description)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(String)gql"sv)), + schema::Field::Make(R"gql(fields)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(__Field)gql"sv))), { + schema::InputValue::Make(R"gql(includeDeprecated)gql"sv, R"md()md"sv, schema->LookupType(R"gql(Boolean)gql"sv), R"gql(false)gql"sv) }), - schema::Field::Make(R"gql(interfaces)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("__Type")))), - schema::Field::Make(R"gql(possibleTypes)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("__Type")))), - schema::Field::Make(R"gql(enumValues)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("__EnumValue"))), { - schema::InputValue::Make(R"gql(includeDeprecated)gql"sv, R"md()md"sv, schema->LookupType("Boolean"), R"gql(false)gql"sv) + schema::Field::Make(R"gql(interfaces)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(__Type)gql"sv)))), + schema::Field::Make(R"gql(possibleTypes)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(__Type)gql"sv)))), + schema::Field::Make(R"gql(enumValues)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(__EnumValue)gql"sv))), { + schema::InputValue::Make(R"gql(includeDeprecated)gql"sv, R"md()md"sv, schema->LookupType(R"gql(Boolean)gql"sv), R"gql(false)gql"sv) }), - schema::Field::Make(R"gql(inputFields)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("__InputValue")))), - schema::Field::Make(R"gql(ofType)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType("__Type")) + schema::Field::Make(R"gql(inputFields)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(__InputValue)gql"sv)))), + schema::Field::Make(R"gql(ofType)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(__Type)gql"sv)) }); typeField->AddFields({ - schema::Field::Make(R"gql(name)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("String"))), - schema::Field::Make(R"gql(description)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType("String")), - schema::Field::Make(R"gql(args)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("__InputValue"))))), - schema::Field::Make(R"gql(type)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("__Type"))), - schema::Field::Make(R"gql(isDeprecated)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("Boolean"))), - schema::Field::Make(R"gql(deprecationReason)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType("String")) + schema::Field::Make(R"gql(name)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(String)gql"sv))), + schema::Field::Make(R"gql(description)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(String)gql"sv)), + schema::Field::Make(R"gql(args)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(__InputValue)gql"sv))))), + schema::Field::Make(R"gql(type)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(__Type)gql"sv))), + schema::Field::Make(R"gql(isDeprecated)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Boolean)gql"sv))), + schema::Field::Make(R"gql(deprecationReason)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(String)gql"sv)) }); typeInputValue->AddFields({ - schema::Field::Make(R"gql(name)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("String"))), - schema::Field::Make(R"gql(description)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType("String")), - schema::Field::Make(R"gql(type)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("__Type"))), - schema::Field::Make(R"gql(defaultValue)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType("String")) + schema::Field::Make(R"gql(name)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(String)gql"sv))), + schema::Field::Make(R"gql(description)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(String)gql"sv)), + schema::Field::Make(R"gql(type)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(__Type)gql"sv))), + schema::Field::Make(R"gql(defaultValue)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(String)gql"sv)) }); typeEnumValue->AddFields({ - schema::Field::Make(R"gql(name)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("String"))), - schema::Field::Make(R"gql(description)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType("String")), - schema::Field::Make(R"gql(isDeprecated)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("Boolean"))), - schema::Field::Make(R"gql(deprecationReason)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType("String")) + schema::Field::Make(R"gql(name)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(String)gql"sv))), + schema::Field::Make(R"gql(description)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(String)gql"sv)), + schema::Field::Make(R"gql(isDeprecated)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Boolean)gql"sv))), + schema::Field::Make(R"gql(deprecationReason)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(String)gql"sv)) }); typeDirective->AddFields({ - schema::Field::Make(R"gql(name)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("String"))), - schema::Field::Make(R"gql(description)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType("String")), - schema::Field::Make(R"gql(locations)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("__DirectiveLocation"))))), - schema::Field::Make(R"gql(args)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("__InputValue"))))) + schema::Field::Make(R"gql(name)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(String)gql"sv))), + schema::Field::Make(R"gql(description)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(String)gql"sv)), + schema::Field::Make(R"gql(locations)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(__DirectiveLocation)gql"sv))))), + schema::Field::Make(R"gql(args)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(__InputValue)gql"sv))))) }); schema->AddDirective(schema::Directive::Make(R"gql(skip)gql"sv, R"md()md"sv, { @@ -799,20 +799,20 @@ void AddTypesToSchema(const std::shared_ptr& schema) introspection::DirectiveLocation::FRAGMENT_SPREAD, introspection::DirectiveLocation::INLINE_FRAGMENT }, { - schema::InputValue::Make(R"gql(if)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("Boolean")), R"gql()gql"sv) + schema::InputValue::Make(R"gql(if)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Boolean)gql"sv)), R"gql()gql"sv) })); schema->AddDirective(schema::Directive::Make(R"gql(include)gql"sv, R"md()md"sv, { introspection::DirectiveLocation::FIELD, introspection::DirectiveLocation::FRAGMENT_SPREAD, introspection::DirectiveLocation::INLINE_FRAGMENT }, { - schema::InputValue::Make(R"gql(if)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType("Boolean")), R"gql()gql"sv) + schema::InputValue::Make(R"gql(if)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Boolean)gql"sv)), R"gql()gql"sv) })); schema->AddDirective(schema::Directive::Make(R"gql(deprecated)gql"sv, R"md()md"sv, { introspection::DirectiveLocation::FIELD_DEFINITION, introspection::DirectiveLocation::ENUM_VALUE }, { - schema::InputValue::Make(R"gql(reason)gql"sv, R"md()md"sv, schema->LookupType("String"), R"gql("No longer supported")gql"sv) + schema::InputValue::Make(R"gql(reason)gql"sv, R"md()md"sv, schema->LookupType(R"gql(String)gql"sv), R"gql("No longer supported")gql"sv) })); } diff --git a/src/SchemaGenerator.cpp b/src/SchemaGenerator.cpp index bea38113..b79954b1 100644 --- a/src/SchemaGenerator.cpp +++ b/src/SchemaGenerator.cpp @@ -2609,7 +2609,7 @@ std::string Generator::getIntrospectionType( ++wrapperCount; } - introspectionType << R"cpp(schema->LookupType(")cpp" << type << R"cpp("))cpp"; + introspectionType << R"cpp(schema->LookupType(R"gql()cpp" << type << R"cpp()gql"sv))cpp"; for (size_t i = 0; i < wrapperCount; ++i) { @@ -2715,12 +2715,6 @@ std::vector Generator::outputSeparateFiles() const noexcept #include "graphqlservice/introspection/Introspection.h" -#include -#include -#include -#include -#include - using namespace std::literals; )cpp"; From a0b455310bb11563c22d3f2135089d3970fb114d Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Wed, 8 Dec 2021 13:43:43 -0800 Subject: [PATCH 060/119] Use R"gql(...)gql"sv for names in getTypeNames --- samples/learn/schema/DroidObject.cpp | 4 +- samples/learn/schema/HumanObject.cpp | 4 +- samples/learn/schema/MutationObject.cpp | 2 +- samples/learn/schema/QueryObject.cpp | 2 +- samples/learn/schema/ReviewObject.cpp | 2 +- .../separate/AppointmentConnectionObject.cpp | 2 +- .../today/separate/AppointmentEdgeObject.cpp | 2 +- samples/today/separate/AppointmentObject.cpp | 6 +-- .../separate/CompleteTaskPayloadObject.cpp | 2 +- samples/today/separate/ExpensiveObject.cpp | 2 +- .../today/separate/FolderConnectionObject.cpp | 2 +- samples/today/separate/FolderEdgeObject.cpp | 2 +- samples/today/separate/FolderObject.cpp | 6 +-- samples/today/separate/MutationObject.cpp | 2 +- samples/today/separate/NestedTypeObject.cpp | 2 +- samples/today/separate/PageInfoObject.cpp | 2 +- samples/today/separate/QueryObject.cpp | 2 +- samples/today/separate/SubscriptionObject.cpp | 2 +- .../today/separate/TaskConnectionObject.cpp | 2 +- samples/today/separate/TaskEdgeObject.cpp | 2 +- samples/today/separate/TaskObject.cpp | 6 +-- .../AppointmentConnectionObject.cpp | 2 +- .../AppointmentEdgeObject.cpp | 2 +- .../AppointmentObject.cpp | 6 +-- .../CompleteTaskPayloadObject.cpp | 2 +- .../ExpensiveObject.cpp | 2 +- .../FolderConnectionObject.cpp | 2 +- .../FolderEdgeObject.cpp | 2 +- .../separate_nointrospection/FolderObject.cpp | 6 +-- .../MutationObject.cpp | 2 +- .../NestedTypeObject.cpp | 2 +- .../PageInfoObject.cpp | 2 +- .../separate_nointrospection/QueryObject.cpp | 2 +- .../SubscriptionObject.cpp | 2 +- .../TaskConnectionObject.cpp | 2 +- .../TaskEdgeObject.cpp | 2 +- .../separate_nointrospection/TaskObject.cpp | 6 +-- samples/today/unified/TodaySchema.cpp | 44 +++++++++---------- .../unified_nointrospection/TodaySchema.cpp | 44 +++++++++---------- .../validation/schema/ValidationSchema.cpp | 40 ++++++++--------- src/IntrospectionSchema.cpp | 12 ++--- src/SchemaGenerator.cpp | 6 +-- 42 files changed, 124 insertions(+), 124 deletions(-) diff --git a/samples/learn/schema/DroidObject.cpp b/samples/learn/schema/DroidObject.cpp index 98aae70d..3ac977f9 100644 --- a/samples/learn/schema/DroidObject.cpp +++ b/samples/learn/schema/DroidObject.cpp @@ -27,8 +27,8 @@ Droid::Droid(std::unique_ptr&& pimpl) noexcept service::TypeNames Droid::getTypeNames() const noexcept { return { - "Character", - "Droid" + R"gql(Character)gql"sv, + R"gql(Droid)gql"sv }; } diff --git a/samples/learn/schema/HumanObject.cpp b/samples/learn/schema/HumanObject.cpp index ed40654f..bfdb356f 100644 --- a/samples/learn/schema/HumanObject.cpp +++ b/samples/learn/schema/HumanObject.cpp @@ -27,8 +27,8 @@ Human::Human(std::unique_ptr&& pimpl) noexcept service::TypeNames Human::getTypeNames() const noexcept { return { - "Character", - "Human" + R"gql(Character)gql"sv, + R"gql(Human)gql"sv }; } diff --git a/samples/learn/schema/MutationObject.cpp b/samples/learn/schema/MutationObject.cpp index 45a1fa2d..a4fb3fea 100644 --- a/samples/learn/schema/MutationObject.cpp +++ b/samples/learn/schema/MutationObject.cpp @@ -27,7 +27,7 @@ Mutation::Mutation(std::unique_ptr&& pimpl) noexcept service::TypeNames Mutation::getTypeNames() const noexcept { return { - "Mutation" + R"gql(Mutation)gql"sv }; } diff --git a/samples/learn/schema/QueryObject.cpp b/samples/learn/schema/QueryObject.cpp index b8e2187b..913677cf 100644 --- a/samples/learn/schema/QueryObject.cpp +++ b/samples/learn/schema/QueryObject.cpp @@ -28,7 +28,7 @@ Query::Query(std::unique_ptr&& pimpl) noexcept service::TypeNames Query::getTypeNames() const noexcept { return { - "Query" + R"gql(Query)gql"sv }; } diff --git a/samples/learn/schema/ReviewObject.cpp b/samples/learn/schema/ReviewObject.cpp index 0b8a6367..4ed93d41 100644 --- a/samples/learn/schema/ReviewObject.cpp +++ b/samples/learn/schema/ReviewObject.cpp @@ -27,7 +27,7 @@ Review::Review(std::unique_ptr&& pimpl) noexcept service::TypeNames Review::getTypeNames() const noexcept { return { - "Review" + R"gql(Review)gql"sv }; } diff --git a/samples/today/separate/AppointmentConnectionObject.cpp b/samples/today/separate/AppointmentConnectionObject.cpp index d76c2276..d131a073 100644 --- a/samples/today/separate/AppointmentConnectionObject.cpp +++ b/samples/today/separate/AppointmentConnectionObject.cpp @@ -27,7 +27,7 @@ AppointmentConnection::AppointmentConnection(std::unique_ptr&& pimpl) n service::TypeNames AppointmentConnection::getTypeNames() const noexcept { return { - "AppointmentConnection" + R"gql(AppointmentConnection)gql"sv }; } diff --git a/samples/today/separate/AppointmentEdgeObject.cpp b/samples/today/separate/AppointmentEdgeObject.cpp index a9e09f8d..33e97006 100644 --- a/samples/today/separate/AppointmentEdgeObject.cpp +++ b/samples/today/separate/AppointmentEdgeObject.cpp @@ -27,7 +27,7 @@ AppointmentEdge::AppointmentEdge(std::unique_ptr&& pimpl) noexcept service::TypeNames AppointmentEdge::getTypeNames() const noexcept { return { - "AppointmentEdge" + R"gql(AppointmentEdge)gql"sv }; } diff --git a/samples/today/separate/AppointmentObject.cpp b/samples/today/separate/AppointmentObject.cpp index 0225df19..46f096c3 100644 --- a/samples/today/separate/AppointmentObject.cpp +++ b/samples/today/separate/AppointmentObject.cpp @@ -27,9 +27,9 @@ Appointment::Appointment(std::unique_ptr&& pimpl) noexcept service::TypeNames Appointment::getTypeNames() const noexcept { return { - "Node", - "UnionType", - "Appointment" + R"gql(Node)gql"sv, + R"gql(UnionType)gql"sv, + R"gql(Appointment)gql"sv }; } diff --git a/samples/today/separate/CompleteTaskPayloadObject.cpp b/samples/today/separate/CompleteTaskPayloadObject.cpp index c47c1043..ca3e2533 100644 --- a/samples/today/separate/CompleteTaskPayloadObject.cpp +++ b/samples/today/separate/CompleteTaskPayloadObject.cpp @@ -27,7 +27,7 @@ CompleteTaskPayload::CompleteTaskPayload(std::unique_ptr&& pimpl) noexc service::TypeNames CompleteTaskPayload::getTypeNames() const noexcept { return { - "CompleteTaskPayload" + R"gql(CompleteTaskPayload)gql"sv }; } diff --git a/samples/today/separate/ExpensiveObject.cpp b/samples/today/separate/ExpensiveObject.cpp index c565b6b5..79600744 100644 --- a/samples/today/separate/ExpensiveObject.cpp +++ b/samples/today/separate/ExpensiveObject.cpp @@ -27,7 +27,7 @@ Expensive::Expensive(std::unique_ptr&& pimpl) noexcept service::TypeNames Expensive::getTypeNames() const noexcept { return { - "Expensive" + R"gql(Expensive)gql"sv }; } diff --git a/samples/today/separate/FolderConnectionObject.cpp b/samples/today/separate/FolderConnectionObject.cpp index a2d54d07..56393333 100644 --- a/samples/today/separate/FolderConnectionObject.cpp +++ b/samples/today/separate/FolderConnectionObject.cpp @@ -27,7 +27,7 @@ FolderConnection::FolderConnection(std::unique_ptr&& pimpl) noexcept service::TypeNames FolderConnection::getTypeNames() const noexcept { return { - "FolderConnection" + R"gql(FolderConnection)gql"sv }; } diff --git a/samples/today/separate/FolderEdgeObject.cpp b/samples/today/separate/FolderEdgeObject.cpp index 64a84afb..91721638 100644 --- a/samples/today/separate/FolderEdgeObject.cpp +++ b/samples/today/separate/FolderEdgeObject.cpp @@ -27,7 +27,7 @@ FolderEdge::FolderEdge(std::unique_ptr&& pimpl) noexcept service::TypeNames FolderEdge::getTypeNames() const noexcept { return { - "FolderEdge" + R"gql(FolderEdge)gql"sv }; } diff --git a/samples/today/separate/FolderObject.cpp b/samples/today/separate/FolderObject.cpp index 18570792..7f4e0fa4 100644 --- a/samples/today/separate/FolderObject.cpp +++ b/samples/today/separate/FolderObject.cpp @@ -27,9 +27,9 @@ Folder::Folder(std::unique_ptr&& pimpl) noexcept service::TypeNames Folder::getTypeNames() const noexcept { return { - "Node", - "UnionType", - "Folder" + R"gql(Node)gql"sv, + R"gql(UnionType)gql"sv, + R"gql(Folder)gql"sv }; } diff --git a/samples/today/separate/MutationObject.cpp b/samples/today/separate/MutationObject.cpp index cc915077..c0357075 100644 --- a/samples/today/separate/MutationObject.cpp +++ b/samples/today/separate/MutationObject.cpp @@ -27,7 +27,7 @@ Mutation::Mutation(std::unique_ptr&& pimpl) noexcept service::TypeNames Mutation::getTypeNames() const noexcept { return { - "Mutation" + R"gql(Mutation)gql"sv }; } diff --git a/samples/today/separate/NestedTypeObject.cpp b/samples/today/separate/NestedTypeObject.cpp index ff46e6a4..f994b6c0 100644 --- a/samples/today/separate/NestedTypeObject.cpp +++ b/samples/today/separate/NestedTypeObject.cpp @@ -27,7 +27,7 @@ NestedType::NestedType(std::unique_ptr&& pimpl) noexcept service::TypeNames NestedType::getTypeNames() const noexcept { return { - "NestedType" + R"gql(NestedType)gql"sv }; } diff --git a/samples/today/separate/PageInfoObject.cpp b/samples/today/separate/PageInfoObject.cpp index d5b1758b..96c4a35b 100644 --- a/samples/today/separate/PageInfoObject.cpp +++ b/samples/today/separate/PageInfoObject.cpp @@ -27,7 +27,7 @@ PageInfo::PageInfo(std::unique_ptr&& pimpl) noexcept service::TypeNames PageInfo::getTypeNames() const noexcept { return { - "PageInfo" + R"gql(PageInfo)gql"sv }; } diff --git a/samples/today/separate/QueryObject.cpp b/samples/today/separate/QueryObject.cpp index 4c8b147d..032416d3 100644 --- a/samples/today/separate/QueryObject.cpp +++ b/samples/today/separate/QueryObject.cpp @@ -28,7 +28,7 @@ Query::Query(std::unique_ptr&& pimpl) noexcept service::TypeNames Query::getTypeNames() const noexcept { return { - "Query" + R"gql(Query)gql"sv }; } diff --git a/samples/today/separate/SubscriptionObject.cpp b/samples/today/separate/SubscriptionObject.cpp index 45df7373..ad310259 100644 --- a/samples/today/separate/SubscriptionObject.cpp +++ b/samples/today/separate/SubscriptionObject.cpp @@ -27,7 +27,7 @@ Subscription::Subscription(std::unique_ptr&& pimpl) noexcept service::TypeNames Subscription::getTypeNames() const noexcept { return { - "Subscription" + R"gql(Subscription)gql"sv }; } diff --git a/samples/today/separate/TaskConnectionObject.cpp b/samples/today/separate/TaskConnectionObject.cpp index 64917a00..da1c45a4 100644 --- a/samples/today/separate/TaskConnectionObject.cpp +++ b/samples/today/separate/TaskConnectionObject.cpp @@ -27,7 +27,7 @@ TaskConnection::TaskConnection(std::unique_ptr&& pimpl) noexcept service::TypeNames TaskConnection::getTypeNames() const noexcept { return { - "TaskConnection" + R"gql(TaskConnection)gql"sv }; } diff --git a/samples/today/separate/TaskEdgeObject.cpp b/samples/today/separate/TaskEdgeObject.cpp index c8780958..37f531eb 100644 --- a/samples/today/separate/TaskEdgeObject.cpp +++ b/samples/today/separate/TaskEdgeObject.cpp @@ -27,7 +27,7 @@ TaskEdge::TaskEdge(std::unique_ptr&& pimpl) noexcept service::TypeNames TaskEdge::getTypeNames() const noexcept { return { - "TaskEdge" + R"gql(TaskEdge)gql"sv }; } diff --git a/samples/today/separate/TaskObject.cpp b/samples/today/separate/TaskObject.cpp index 46d6e2a1..082c203c 100644 --- a/samples/today/separate/TaskObject.cpp +++ b/samples/today/separate/TaskObject.cpp @@ -27,9 +27,9 @@ Task::Task(std::unique_ptr&& pimpl) noexcept service::TypeNames Task::getTypeNames() const noexcept { return { - "Node", - "UnionType", - "Task" + R"gql(Node)gql"sv, + R"gql(UnionType)gql"sv, + R"gql(Task)gql"sv }; } diff --git a/samples/today/separate_nointrospection/AppointmentConnectionObject.cpp b/samples/today/separate_nointrospection/AppointmentConnectionObject.cpp index d76c2276..d131a073 100644 --- a/samples/today/separate_nointrospection/AppointmentConnectionObject.cpp +++ b/samples/today/separate_nointrospection/AppointmentConnectionObject.cpp @@ -27,7 +27,7 @@ AppointmentConnection::AppointmentConnection(std::unique_ptr&& pimpl) n service::TypeNames AppointmentConnection::getTypeNames() const noexcept { return { - "AppointmentConnection" + R"gql(AppointmentConnection)gql"sv }; } diff --git a/samples/today/separate_nointrospection/AppointmentEdgeObject.cpp b/samples/today/separate_nointrospection/AppointmentEdgeObject.cpp index a9e09f8d..33e97006 100644 --- a/samples/today/separate_nointrospection/AppointmentEdgeObject.cpp +++ b/samples/today/separate_nointrospection/AppointmentEdgeObject.cpp @@ -27,7 +27,7 @@ AppointmentEdge::AppointmentEdge(std::unique_ptr&& pimpl) noexcept service::TypeNames AppointmentEdge::getTypeNames() const noexcept { return { - "AppointmentEdge" + R"gql(AppointmentEdge)gql"sv }; } diff --git a/samples/today/separate_nointrospection/AppointmentObject.cpp b/samples/today/separate_nointrospection/AppointmentObject.cpp index 0225df19..46f096c3 100644 --- a/samples/today/separate_nointrospection/AppointmentObject.cpp +++ b/samples/today/separate_nointrospection/AppointmentObject.cpp @@ -27,9 +27,9 @@ Appointment::Appointment(std::unique_ptr&& pimpl) noexcept service::TypeNames Appointment::getTypeNames() const noexcept { return { - "Node", - "UnionType", - "Appointment" + R"gql(Node)gql"sv, + R"gql(UnionType)gql"sv, + R"gql(Appointment)gql"sv }; } diff --git a/samples/today/separate_nointrospection/CompleteTaskPayloadObject.cpp b/samples/today/separate_nointrospection/CompleteTaskPayloadObject.cpp index c47c1043..ca3e2533 100644 --- a/samples/today/separate_nointrospection/CompleteTaskPayloadObject.cpp +++ b/samples/today/separate_nointrospection/CompleteTaskPayloadObject.cpp @@ -27,7 +27,7 @@ CompleteTaskPayload::CompleteTaskPayload(std::unique_ptr&& pimpl) noexc service::TypeNames CompleteTaskPayload::getTypeNames() const noexcept { return { - "CompleteTaskPayload" + R"gql(CompleteTaskPayload)gql"sv }; } diff --git a/samples/today/separate_nointrospection/ExpensiveObject.cpp b/samples/today/separate_nointrospection/ExpensiveObject.cpp index c565b6b5..79600744 100644 --- a/samples/today/separate_nointrospection/ExpensiveObject.cpp +++ b/samples/today/separate_nointrospection/ExpensiveObject.cpp @@ -27,7 +27,7 @@ Expensive::Expensive(std::unique_ptr&& pimpl) noexcept service::TypeNames Expensive::getTypeNames() const noexcept { return { - "Expensive" + R"gql(Expensive)gql"sv }; } diff --git a/samples/today/separate_nointrospection/FolderConnectionObject.cpp b/samples/today/separate_nointrospection/FolderConnectionObject.cpp index a2d54d07..56393333 100644 --- a/samples/today/separate_nointrospection/FolderConnectionObject.cpp +++ b/samples/today/separate_nointrospection/FolderConnectionObject.cpp @@ -27,7 +27,7 @@ FolderConnection::FolderConnection(std::unique_ptr&& pimpl) noexcept service::TypeNames FolderConnection::getTypeNames() const noexcept { return { - "FolderConnection" + R"gql(FolderConnection)gql"sv }; } diff --git a/samples/today/separate_nointrospection/FolderEdgeObject.cpp b/samples/today/separate_nointrospection/FolderEdgeObject.cpp index 64a84afb..91721638 100644 --- a/samples/today/separate_nointrospection/FolderEdgeObject.cpp +++ b/samples/today/separate_nointrospection/FolderEdgeObject.cpp @@ -27,7 +27,7 @@ FolderEdge::FolderEdge(std::unique_ptr&& pimpl) noexcept service::TypeNames FolderEdge::getTypeNames() const noexcept { return { - "FolderEdge" + R"gql(FolderEdge)gql"sv }; } diff --git a/samples/today/separate_nointrospection/FolderObject.cpp b/samples/today/separate_nointrospection/FolderObject.cpp index 18570792..7f4e0fa4 100644 --- a/samples/today/separate_nointrospection/FolderObject.cpp +++ b/samples/today/separate_nointrospection/FolderObject.cpp @@ -27,9 +27,9 @@ Folder::Folder(std::unique_ptr&& pimpl) noexcept service::TypeNames Folder::getTypeNames() const noexcept { return { - "Node", - "UnionType", - "Folder" + R"gql(Node)gql"sv, + R"gql(UnionType)gql"sv, + R"gql(Folder)gql"sv }; } diff --git a/samples/today/separate_nointrospection/MutationObject.cpp b/samples/today/separate_nointrospection/MutationObject.cpp index cc915077..c0357075 100644 --- a/samples/today/separate_nointrospection/MutationObject.cpp +++ b/samples/today/separate_nointrospection/MutationObject.cpp @@ -27,7 +27,7 @@ Mutation::Mutation(std::unique_ptr&& pimpl) noexcept service::TypeNames Mutation::getTypeNames() const noexcept { return { - "Mutation" + R"gql(Mutation)gql"sv }; } diff --git a/samples/today/separate_nointrospection/NestedTypeObject.cpp b/samples/today/separate_nointrospection/NestedTypeObject.cpp index a60f2597..9a43d8a3 100644 --- a/samples/today/separate_nointrospection/NestedTypeObject.cpp +++ b/samples/today/separate_nointrospection/NestedTypeObject.cpp @@ -27,7 +27,7 @@ NestedType::NestedType(std::unique_ptr&& pimpl) noexcept service::TypeNames NestedType::getTypeNames() const noexcept { return { - "NestedType" + R"gql(NestedType)gql"sv }; } diff --git a/samples/today/separate_nointrospection/PageInfoObject.cpp b/samples/today/separate_nointrospection/PageInfoObject.cpp index d5b1758b..96c4a35b 100644 --- a/samples/today/separate_nointrospection/PageInfoObject.cpp +++ b/samples/today/separate_nointrospection/PageInfoObject.cpp @@ -27,7 +27,7 @@ PageInfo::PageInfo(std::unique_ptr&& pimpl) noexcept service::TypeNames PageInfo::getTypeNames() const noexcept { return { - "PageInfo" + R"gql(PageInfo)gql"sv }; } diff --git a/samples/today/separate_nointrospection/QueryObject.cpp b/samples/today/separate_nointrospection/QueryObject.cpp index 3139b75a..3a071b06 100644 --- a/samples/today/separate_nointrospection/QueryObject.cpp +++ b/samples/today/separate_nointrospection/QueryObject.cpp @@ -27,7 +27,7 @@ Query::Query(std::unique_ptr&& pimpl) noexcept service::TypeNames Query::getTypeNames() const noexcept { return { - "Query" + R"gql(Query)gql"sv }; } diff --git a/samples/today/separate_nointrospection/SubscriptionObject.cpp b/samples/today/separate_nointrospection/SubscriptionObject.cpp index 45df7373..ad310259 100644 --- a/samples/today/separate_nointrospection/SubscriptionObject.cpp +++ b/samples/today/separate_nointrospection/SubscriptionObject.cpp @@ -27,7 +27,7 @@ Subscription::Subscription(std::unique_ptr&& pimpl) noexcept service::TypeNames Subscription::getTypeNames() const noexcept { return { - "Subscription" + R"gql(Subscription)gql"sv }; } diff --git a/samples/today/separate_nointrospection/TaskConnectionObject.cpp b/samples/today/separate_nointrospection/TaskConnectionObject.cpp index 64917a00..da1c45a4 100644 --- a/samples/today/separate_nointrospection/TaskConnectionObject.cpp +++ b/samples/today/separate_nointrospection/TaskConnectionObject.cpp @@ -27,7 +27,7 @@ TaskConnection::TaskConnection(std::unique_ptr&& pimpl) noexcept service::TypeNames TaskConnection::getTypeNames() const noexcept { return { - "TaskConnection" + R"gql(TaskConnection)gql"sv }; } diff --git a/samples/today/separate_nointrospection/TaskEdgeObject.cpp b/samples/today/separate_nointrospection/TaskEdgeObject.cpp index c8780958..37f531eb 100644 --- a/samples/today/separate_nointrospection/TaskEdgeObject.cpp +++ b/samples/today/separate_nointrospection/TaskEdgeObject.cpp @@ -27,7 +27,7 @@ TaskEdge::TaskEdge(std::unique_ptr&& pimpl) noexcept service::TypeNames TaskEdge::getTypeNames() const noexcept { return { - "TaskEdge" + R"gql(TaskEdge)gql"sv }; } diff --git a/samples/today/separate_nointrospection/TaskObject.cpp b/samples/today/separate_nointrospection/TaskObject.cpp index 46d6e2a1..082c203c 100644 --- a/samples/today/separate_nointrospection/TaskObject.cpp +++ b/samples/today/separate_nointrospection/TaskObject.cpp @@ -27,9 +27,9 @@ Task::Task(std::unique_ptr&& pimpl) noexcept service::TypeNames Task::getTypeNames() const noexcept { return { - "Node", - "UnionType", - "Task" + R"gql(Node)gql"sv, + R"gql(UnionType)gql"sv, + R"gql(Task)gql"sv }; } diff --git a/samples/today/unified/TodaySchema.cpp b/samples/today/unified/TodaySchema.cpp index 071b4333..04509c05 100644 --- a/samples/today/unified/TodaySchema.cpp +++ b/samples/today/unified/TodaySchema.cpp @@ -167,7 +167,7 @@ Query::Query(std::unique_ptr&& pimpl) noexcept service::TypeNames Query::getTypeNames() const noexcept { return { - "Query" + R"gql(Query)gql"sv }; } @@ -389,7 +389,7 @@ PageInfo::PageInfo(std::unique_ptr&& pimpl) noexcept service::TypeNames PageInfo::getTypeNames() const noexcept { return { - "PageInfo" + R"gql(PageInfo)gql"sv }; } @@ -446,7 +446,7 @@ AppointmentEdge::AppointmentEdge(std::unique_ptr&& pimpl) noexcept service::TypeNames AppointmentEdge::getTypeNames() const noexcept { return { - "AppointmentEdge" + R"gql(AppointmentEdge)gql"sv }; } @@ -503,7 +503,7 @@ AppointmentConnection::AppointmentConnection(std::unique_ptr&& pimpl) n service::TypeNames AppointmentConnection::getTypeNames() const noexcept { return { - "AppointmentConnection" + R"gql(AppointmentConnection)gql"sv }; } @@ -560,7 +560,7 @@ TaskEdge::TaskEdge(std::unique_ptr&& pimpl) noexcept service::TypeNames TaskEdge::getTypeNames() const noexcept { return { - "TaskEdge" + R"gql(TaskEdge)gql"sv }; } @@ -617,7 +617,7 @@ TaskConnection::TaskConnection(std::unique_ptr&& pimpl) noexcept service::TypeNames TaskConnection::getTypeNames() const noexcept { return { - "TaskConnection" + R"gql(TaskConnection)gql"sv }; } @@ -674,7 +674,7 @@ FolderEdge::FolderEdge(std::unique_ptr&& pimpl) noexcept service::TypeNames FolderEdge::getTypeNames() const noexcept { return { - "FolderEdge" + R"gql(FolderEdge)gql"sv }; } @@ -731,7 +731,7 @@ FolderConnection::FolderConnection(std::unique_ptr&& pimpl) noexcept service::TypeNames FolderConnection::getTypeNames() const noexcept { return { - "FolderConnection" + R"gql(FolderConnection)gql"sv }; } @@ -788,7 +788,7 @@ CompleteTaskPayload::CompleteTaskPayload(std::unique_ptr&& pimpl) noexc service::TypeNames CompleteTaskPayload::getTypeNames() const noexcept { return { - "CompleteTaskPayload" + R"gql(CompleteTaskPayload)gql"sv }; } @@ -845,7 +845,7 @@ Mutation::Mutation(std::unique_ptr&& pimpl) noexcept service::TypeNames Mutation::getTypeNames() const noexcept { return { - "Mutation" + R"gql(Mutation)gql"sv }; } @@ -904,7 +904,7 @@ Subscription::Subscription(std::unique_ptr&& pimpl) noexcept service::TypeNames Subscription::getTypeNames() const noexcept { return { - "Subscription" + R"gql(Subscription)gql"sv }; } @@ -962,9 +962,9 @@ Appointment::Appointment(std::unique_ptr&& pimpl) noexcept service::TypeNames Appointment::getTypeNames() const noexcept { return { - "Node", - "UnionType", - "Appointment" + R"gql(Node)gql"sv, + R"gql(UnionType)gql"sv, + R"gql(Appointment)gql"sv }; } @@ -1054,9 +1054,9 @@ Task::Task(std::unique_ptr&& pimpl) noexcept service::TypeNames Task::getTypeNames() const noexcept { return { - "Node", - "UnionType", - "Task" + R"gql(Node)gql"sv, + R"gql(UnionType)gql"sv, + R"gql(Task)gql"sv }; } @@ -1124,9 +1124,9 @@ Folder::Folder(std::unique_ptr&& pimpl) noexcept service::TypeNames Folder::getTypeNames() const noexcept { return { - "Node", - "UnionType", - "Folder" + R"gql(Node)gql"sv, + R"gql(UnionType)gql"sv, + R"gql(Folder)gql"sv }; } @@ -1194,7 +1194,7 @@ NestedType::NestedType(std::unique_ptr&& pimpl) noexcept service::TypeNames NestedType::getTypeNames() const noexcept { return { - "NestedType" + R"gql(NestedType)gql"sv }; } @@ -1251,7 +1251,7 @@ Expensive::Expensive(std::unique_ptr&& pimpl) noexcept service::TypeNames Expensive::getTypeNames() const noexcept { return { - "Expensive" + R"gql(Expensive)gql"sv }; } diff --git a/samples/today/unified_nointrospection/TodaySchema.cpp b/samples/today/unified_nointrospection/TodaySchema.cpp index 2b0d44f4..f67d339c 100644 --- a/samples/today/unified_nointrospection/TodaySchema.cpp +++ b/samples/today/unified_nointrospection/TodaySchema.cpp @@ -166,7 +166,7 @@ Query::Query(std::unique_ptr&& pimpl) noexcept service::TypeNames Query::getTypeNames() const noexcept { return { - "Query" + R"gql(Query)gql"sv }; } @@ -372,7 +372,7 @@ PageInfo::PageInfo(std::unique_ptr&& pimpl) noexcept service::TypeNames PageInfo::getTypeNames() const noexcept { return { - "PageInfo" + R"gql(PageInfo)gql"sv }; } @@ -429,7 +429,7 @@ AppointmentEdge::AppointmentEdge(std::unique_ptr&& pimpl) noexcept service::TypeNames AppointmentEdge::getTypeNames() const noexcept { return { - "AppointmentEdge" + R"gql(AppointmentEdge)gql"sv }; } @@ -486,7 +486,7 @@ AppointmentConnection::AppointmentConnection(std::unique_ptr&& pimpl) n service::TypeNames AppointmentConnection::getTypeNames() const noexcept { return { - "AppointmentConnection" + R"gql(AppointmentConnection)gql"sv }; } @@ -543,7 +543,7 @@ TaskEdge::TaskEdge(std::unique_ptr&& pimpl) noexcept service::TypeNames TaskEdge::getTypeNames() const noexcept { return { - "TaskEdge" + R"gql(TaskEdge)gql"sv }; } @@ -600,7 +600,7 @@ TaskConnection::TaskConnection(std::unique_ptr&& pimpl) noexcept service::TypeNames TaskConnection::getTypeNames() const noexcept { return { - "TaskConnection" + R"gql(TaskConnection)gql"sv }; } @@ -657,7 +657,7 @@ FolderEdge::FolderEdge(std::unique_ptr&& pimpl) noexcept service::TypeNames FolderEdge::getTypeNames() const noexcept { return { - "FolderEdge" + R"gql(FolderEdge)gql"sv }; } @@ -714,7 +714,7 @@ FolderConnection::FolderConnection(std::unique_ptr&& pimpl) noexcept service::TypeNames FolderConnection::getTypeNames() const noexcept { return { - "FolderConnection" + R"gql(FolderConnection)gql"sv }; } @@ -771,7 +771,7 @@ CompleteTaskPayload::CompleteTaskPayload(std::unique_ptr&& pimpl) noexc service::TypeNames CompleteTaskPayload::getTypeNames() const noexcept { return { - "CompleteTaskPayload" + R"gql(CompleteTaskPayload)gql"sv }; } @@ -828,7 +828,7 @@ Mutation::Mutation(std::unique_ptr&& pimpl) noexcept service::TypeNames Mutation::getTypeNames() const noexcept { return { - "Mutation" + R"gql(Mutation)gql"sv }; } @@ -887,7 +887,7 @@ Subscription::Subscription(std::unique_ptr&& pimpl) noexcept service::TypeNames Subscription::getTypeNames() const noexcept { return { - "Subscription" + R"gql(Subscription)gql"sv }; } @@ -945,9 +945,9 @@ Appointment::Appointment(std::unique_ptr&& pimpl) noexcept service::TypeNames Appointment::getTypeNames() const noexcept { return { - "Node", - "UnionType", - "Appointment" + R"gql(Node)gql"sv, + R"gql(UnionType)gql"sv, + R"gql(Appointment)gql"sv }; } @@ -1037,9 +1037,9 @@ Task::Task(std::unique_ptr&& pimpl) noexcept service::TypeNames Task::getTypeNames() const noexcept { return { - "Node", - "UnionType", - "Task" + R"gql(Node)gql"sv, + R"gql(UnionType)gql"sv, + R"gql(Task)gql"sv }; } @@ -1107,9 +1107,9 @@ Folder::Folder(std::unique_ptr&& pimpl) noexcept service::TypeNames Folder::getTypeNames() const noexcept { return { - "Node", - "UnionType", - "Folder" + R"gql(Node)gql"sv, + R"gql(UnionType)gql"sv, + R"gql(Folder)gql"sv }; } @@ -1177,7 +1177,7 @@ NestedType::NestedType(std::unique_ptr&& pimpl) noexcept service::TypeNames NestedType::getTypeNames() const noexcept { return { - "NestedType" + R"gql(NestedType)gql"sv }; } @@ -1234,7 +1234,7 @@ Expensive::Expensive(std::unique_ptr&& pimpl) noexcept service::TypeNames Expensive::getTypeNames() const noexcept { return { - "Expensive" + R"gql(Expensive)gql"sv }; } diff --git a/samples/validation/schema/ValidationSchema.cpp b/samples/validation/schema/ValidationSchema.cpp index 5bf00f24..04eeba73 100644 --- a/samples/validation/schema/ValidationSchema.cpp +++ b/samples/validation/schema/ValidationSchema.cpp @@ -153,7 +153,7 @@ Query::Query(std::unique_ptr&& pimpl) noexcept service::TypeNames Query::getTypeNames() const noexcept { return { - "Query" + R"gql(Query)gql"sv }; } @@ -267,10 +267,10 @@ Dog::Dog(std::unique_ptr&& pimpl) noexcept service::TypeNames Dog::getTypeNames() const noexcept { return { - "Pet", - "CatOrDog", - "DogOrHuman", - "Dog" + R"gql(Pet)gql"sv, + R"gql(CatOrDog)gql"sv, + R"gql(DogOrHuman)gql"sv, + R"gql(Dog)gql"sv }; } @@ -373,9 +373,9 @@ Alien::Alien(std::unique_ptr&& pimpl) noexcept service::TypeNames Alien::getTypeNames() const noexcept { return { - "Sentient", - "HumanOrAlien", - "Alien" + R"gql(Sentient)gql"sv, + R"gql(HumanOrAlien)gql"sv, + R"gql(Alien)gql"sv }; } @@ -432,10 +432,10 @@ Human::Human(std::unique_ptr&& pimpl) noexcept service::TypeNames Human::getTypeNames() const noexcept { return { - "Sentient", - "DogOrHuman", - "HumanOrAlien", - "Human" + R"gql(Sentient)gql"sv, + R"gql(DogOrHuman)gql"sv, + R"gql(HumanOrAlien)gql"sv, + R"gql(Human)gql"sv }; } @@ -492,9 +492,9 @@ Cat::Cat(std::unique_ptr&& pimpl) noexcept service::TypeNames Cat::getTypeNames() const noexcept { return { - "Pet", - "CatOrDog", - "Cat" + R"gql(Pet)gql"sv, + R"gql(CatOrDog)gql"sv, + R"gql(Cat)gql"sv }; } @@ -574,7 +574,7 @@ Mutation::Mutation(std::unique_ptr&& pimpl) noexcept service::TypeNames Mutation::getTypeNames() const noexcept { return { - "Mutation" + R"gql(Mutation)gql"sv }; } @@ -620,7 +620,7 @@ MutateDogResult::MutateDogResult(std::unique_ptr&& pimpl) noexcept service::TypeNames MutateDogResult::getTypeNames() const noexcept { return { - "MutateDogResult" + R"gql(MutateDogResult)gql"sv }; } @@ -666,7 +666,7 @@ Subscription::Subscription(std::unique_ptr&& pimpl) noexcept service::TypeNames Subscription::getTypeNames() const noexcept { return { - "Subscription" + R"gql(Subscription)gql"sv }; } @@ -723,7 +723,7 @@ Message::Message(std::unique_ptr&& pimpl) noexcept service::TypeNames Message::getTypeNames() const noexcept { return { - "Message" + R"gql(Message)gql"sv }; } @@ -780,7 +780,7 @@ Arguments::Arguments(std::unique_ptr&& pimpl) noexcept service::TypeNames Arguments::getTypeNames() const noexcept { return { - "Arguments" + R"gql(Arguments)gql"sv }; } diff --git a/src/IntrospectionSchema.cpp b/src/IntrospectionSchema.cpp index 76d9a59d..dced80f2 100644 --- a/src/IntrospectionSchema.cpp +++ b/src/IntrospectionSchema.cpp @@ -135,7 +135,7 @@ Schema::~Schema() service::TypeNames Schema::getTypeNames() const noexcept { return { - "__Schema" + R"gql(__Schema)gql"sv }; } @@ -221,7 +221,7 @@ Type::~Type() service::TypeNames Type::getTypeNames() const noexcept { return { - "__Type" + R"gql(__Type)gql"sv }; } @@ -381,7 +381,7 @@ Field::~Field() service::TypeNames Field::getTypeNames() const noexcept { return { - "__Field" + R"gql(__Field)gql"sv }; } @@ -478,7 +478,7 @@ InputValue::~InputValue() service::TypeNames InputValue::getTypeNames() const noexcept { return { - "__InputValue" + R"gql(__InputValue)gql"sv }; } @@ -553,7 +553,7 @@ EnumValue::~EnumValue() service::TypeNames EnumValue::getTypeNames() const noexcept { return { - "__EnumValue" + R"gql(__EnumValue)gql"sv }; } @@ -628,7 +628,7 @@ Directive::~Directive() service::TypeNames Directive::getTypeNames() const noexcept { return { - "__Directive" + R"gql(__Directive)gql"sv }; } diff --git a/src/SchemaGenerator.cpp b/src/SchemaGenerator.cpp index b79954b1..ce7b5d53 100644 --- a/src/SchemaGenerator.cpp +++ b/src/SchemaGenerator.cpp @@ -1934,17 +1934,17 @@ service::TypeNames )cpp" for (const auto& interfaceName : objectType.interfaces) { - sourceFile << R"cpp( ")cpp" << interfaceName << R"cpp(", + sourceFile << R"cpp( R"gql()cpp" << interfaceName << R"cpp()gql"sv, )cpp"; } for (const auto& unionName : objectType.unions) { - sourceFile << R"cpp( ")cpp" << unionName << R"cpp(", + sourceFile << R"cpp( R"gql()cpp" << unionName << R"cpp()gql"sv, )cpp"; } - sourceFile << R"cpp( ")cpp" << objectType.type << R"cpp(" + sourceFile << R"cpp( R"gql()cpp" << objectType.type << R"cpp()gql"sv }; } From 74e40688b623d9550605e3c840620e383b392d85 Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Wed, 8 Dec 2021 13:51:06 -0800 Subject: [PATCH 061/119] Escape string literals with GraphQL tokens --- samples/learn/schema/StarWarsSchema.cpp | 10 ++-- samples/today/separate/TodaySchema.cpp | 12 ++-- .../separate_nointrospection/TodaySchema.cpp | 12 ++-- samples/today/unified/TodaySchema.cpp | 12 ++-- .../unified_nointrospection/TodaySchema.cpp | 12 ++-- .../validation/schema/ValidationSchema.cpp | 16 ++--- src/IntrospectionSchema.cpp | 60 +++++++++---------- src/SchemaGenerator.cpp | 10 ++-- 8 files changed, 72 insertions(+), 72 deletions(-) diff --git a/samples/learn/schema/StarWarsSchema.cpp b/samples/learn/schema/StarWarsSchema.cpp index 4bcfd08b..034ec47f 100644 --- a/samples/learn/schema/StarWarsSchema.cpp +++ b/samples/learn/schema/StarWarsSchema.cpp @@ -22,9 +22,9 @@ namespace graphql { namespace service { static const std::array s_namesEpisode = { - "NEW_HOPE"sv, - "EMPIRE"sv, - "JEDI"sv + R"gql(NEW_HOPE)gql"sv, + R"gql(EMPIRE)gql"sv, + R"gql(JEDI)gql"sv }; template <> @@ -32,14 +32,14 @@ learn::Episode ModifiedArgument::convert(const response::Value& { if (!value.maybe_enum()) { - throw service::schema_exception { { "not a valid Episode value" } }; + throw service::schema_exception { { R"ex(not a valid Episode value)ex" } }; } const auto itr = std::find(s_namesEpisode.cbegin(), s_namesEpisode.cend(), value.get()); if (itr == s_namesEpisode.cend()) { - throw service::schema_exception { { "not a valid Episode value" } }; + throw service::schema_exception { { R"ex(not a valid Episode value)ex" } }; } return static_cast(itr - s_namesEpisode.cbegin()); diff --git a/samples/today/separate/TodaySchema.cpp b/samples/today/separate/TodaySchema.cpp index 0a3ebf2b..4cabf9aa 100644 --- a/samples/today/separate/TodaySchema.cpp +++ b/samples/today/separate/TodaySchema.cpp @@ -22,10 +22,10 @@ namespace graphql { namespace service { static const std::array s_namesTaskState = { - "New"sv, - "Started"sv, - "Complete"sv, - "Unassigned"sv + R"gql(New)gql"sv, + R"gql(Started)gql"sv, + R"gql(Complete)gql"sv, + R"gql(Unassigned)gql"sv }; template <> @@ -33,14 +33,14 @@ today::TaskState ModifiedArgument::convert(const response::Val { if (!value.maybe_enum()) { - throw service::schema_exception { { "not a valid TaskState value" } }; + throw service::schema_exception { { R"ex(not a valid TaskState value)ex" } }; } const auto itr = std::find(s_namesTaskState.cbegin(), s_namesTaskState.cend(), value.get()); if (itr == s_namesTaskState.cend()) { - throw service::schema_exception { { "not a valid TaskState value" } }; + throw service::schema_exception { { R"ex(not a valid TaskState value)ex" } }; } return static_cast(itr - s_namesTaskState.cbegin()); diff --git a/samples/today/separate_nointrospection/TodaySchema.cpp b/samples/today/separate_nointrospection/TodaySchema.cpp index 87e2308a..f896da1b 100644 --- a/samples/today/separate_nointrospection/TodaySchema.cpp +++ b/samples/today/separate_nointrospection/TodaySchema.cpp @@ -22,10 +22,10 @@ namespace graphql { namespace service { static const std::array s_namesTaskState = { - "New"sv, - "Started"sv, - "Complete"sv, - "Unassigned"sv + R"gql(New)gql"sv, + R"gql(Started)gql"sv, + R"gql(Complete)gql"sv, + R"gql(Unassigned)gql"sv }; template <> @@ -33,14 +33,14 @@ today::TaskState ModifiedArgument::convert(const response::Val { if (!value.maybe_enum()) { - throw service::schema_exception { { "not a valid TaskState value" } }; + throw service::schema_exception { { R"ex(not a valid TaskState value)ex" } }; } const auto itr = std::find(s_namesTaskState.cbegin(), s_namesTaskState.cend(), value.get()); if (itr == s_namesTaskState.cend()) { - throw service::schema_exception { { "not a valid TaskState value" } }; + throw service::schema_exception { { R"ex(not a valid TaskState value)ex" } }; } return static_cast(itr - s_namesTaskState.cbegin()); diff --git a/samples/today/unified/TodaySchema.cpp b/samples/today/unified/TodaySchema.cpp index 04509c05..9411863f 100644 --- a/samples/today/unified/TodaySchema.cpp +++ b/samples/today/unified/TodaySchema.cpp @@ -22,10 +22,10 @@ namespace graphql { namespace service { static const std::array s_namesTaskState = { - "New"sv, - "Started"sv, - "Complete"sv, - "Unassigned"sv + R"gql(New)gql"sv, + R"gql(Started)gql"sv, + R"gql(Complete)gql"sv, + R"gql(Unassigned)gql"sv }; template <> @@ -33,14 +33,14 @@ today::TaskState ModifiedArgument::convert(const response::Val { if (!value.maybe_enum()) { - throw service::schema_exception { { "not a valid TaskState value" } }; + throw service::schema_exception { { R"ex(not a valid TaskState value)ex" } }; } const auto itr = std::find(s_namesTaskState.cbegin(), s_namesTaskState.cend(), value.get()); if (itr == s_namesTaskState.cend()) { - throw service::schema_exception { { "not a valid TaskState value" } }; + throw service::schema_exception { { R"ex(not a valid TaskState value)ex" } }; } return static_cast(itr - s_namesTaskState.cbegin()); diff --git a/samples/today/unified_nointrospection/TodaySchema.cpp b/samples/today/unified_nointrospection/TodaySchema.cpp index f67d339c..99d27fd6 100644 --- a/samples/today/unified_nointrospection/TodaySchema.cpp +++ b/samples/today/unified_nointrospection/TodaySchema.cpp @@ -22,10 +22,10 @@ namespace graphql { namespace service { static const std::array s_namesTaskState = { - "New"sv, - "Started"sv, - "Complete"sv, - "Unassigned"sv + R"gql(New)gql"sv, + R"gql(Started)gql"sv, + R"gql(Complete)gql"sv, + R"gql(Unassigned)gql"sv }; template <> @@ -33,14 +33,14 @@ today::TaskState ModifiedArgument::convert(const response::Val { if (!value.maybe_enum()) { - throw service::schema_exception { { "not a valid TaskState value" } }; + throw service::schema_exception { { R"ex(not a valid TaskState value)ex" } }; } const auto itr = std::find(s_namesTaskState.cbegin(), s_namesTaskState.cend(), value.get()); if (itr == s_namesTaskState.cend()) { - throw service::schema_exception { { "not a valid TaskState value" } }; + throw service::schema_exception { { R"ex(not a valid TaskState value)ex" } }; } return static_cast(itr - s_namesTaskState.cbegin()); diff --git a/samples/validation/schema/ValidationSchema.cpp b/samples/validation/schema/ValidationSchema.cpp index 04eeba73..d0cb00a3 100644 --- a/samples/validation/schema/ValidationSchema.cpp +++ b/samples/validation/schema/ValidationSchema.cpp @@ -22,9 +22,9 @@ namespace graphql { namespace service { static const std::array s_namesDogCommand = { - "SIT"sv, - "DOWN"sv, - "HEEL"sv + R"gql(SIT)gql"sv, + R"gql(DOWN)gql"sv, + R"gql(HEEL)gql"sv }; template <> @@ -32,14 +32,14 @@ validation::DogCommand ModifiedArgument::convert(const r { if (!value.maybe_enum()) { - throw service::schema_exception { { "not a valid DogCommand value" } }; + throw service::schema_exception { { R"ex(not a valid DogCommand value)ex" } }; } const auto itr = std::find(s_namesDogCommand.cbegin(), s_namesDogCommand.cend(), value.get()); if (itr == s_namesDogCommand.cend()) { - throw service::schema_exception { { "not a valid DogCommand value" } }; + throw service::schema_exception { { R"ex(not a valid DogCommand value)ex" } }; } return static_cast(itr - s_namesDogCommand.cbegin()); @@ -60,7 +60,7 @@ service::AwaitableResolver ModifiedResult::convert(servi } static const std::array s_namesCatCommand = { - "JUMP"sv + R"gql(JUMP)gql"sv }; template <> @@ -68,14 +68,14 @@ validation::CatCommand ModifiedArgument::convert(const r { if (!value.maybe_enum()) { - throw service::schema_exception { { "not a valid CatCommand value" } }; + throw service::schema_exception { { R"ex(not a valid CatCommand value)ex" } }; } const auto itr = std::find(s_namesCatCommand.cbegin(), s_namesCatCommand.cend(), value.get()); if (itr == s_namesCatCommand.cend()) { - throw service::schema_exception { { "not a valid CatCommand value" } }; + throw service::schema_exception { { R"ex(not a valid CatCommand value)ex" } }; } return static_cast(itr - s_namesCatCommand.cbegin()); diff --git a/src/IntrospectionSchema.cpp b/src/IntrospectionSchema.cpp index dced80f2..dc2d20d7 100644 --- a/src/IntrospectionSchema.cpp +++ b/src/IntrospectionSchema.cpp @@ -20,14 +20,14 @@ namespace graphql { namespace service { static const std::array s_namesTypeKind = { - "SCALAR"sv, - "OBJECT"sv, - "INTERFACE"sv, - "UNION"sv, - "ENUM"sv, - "INPUT_OBJECT"sv, - "LIST"sv, - "NON_NULL"sv + R"gql(SCALAR)gql"sv, + R"gql(OBJECT)gql"sv, + R"gql(INTERFACE)gql"sv, + R"gql(UNION)gql"sv, + R"gql(ENUM)gql"sv, + R"gql(INPUT_OBJECT)gql"sv, + R"gql(LIST)gql"sv, + R"gql(NON_NULL)gql"sv }; template <> @@ -35,14 +35,14 @@ introspection::TypeKind ModifiedArgument::convert(const { if (!value.maybe_enum()) { - throw service::schema_exception { { "not a valid __TypeKind value" } }; + throw service::schema_exception { { R"ex(not a valid __TypeKind value)ex" } }; } const auto itr = std::find(s_namesTypeKind.cbegin(), s_namesTypeKind.cend(), value.get()); if (itr == s_namesTypeKind.cend()) { - throw service::schema_exception { { "not a valid __TypeKind value" } }; + throw service::schema_exception { { R"ex(not a valid __TypeKind value)ex" } }; } return static_cast(itr - s_namesTypeKind.cbegin()); @@ -63,24 +63,24 @@ service::AwaitableResolver ModifiedResult::convert(serv } static const std::array s_namesDirectiveLocation = { - "QUERY"sv, - "MUTATION"sv, - "SUBSCRIPTION"sv, - "FIELD"sv, - "FRAGMENT_DEFINITION"sv, - "FRAGMENT_SPREAD"sv, - "INLINE_FRAGMENT"sv, - "SCHEMA"sv, - "SCALAR"sv, - "OBJECT"sv, - "FIELD_DEFINITION"sv, - "ARGUMENT_DEFINITION"sv, - "INTERFACE"sv, - "UNION"sv, - "ENUM"sv, - "ENUM_VALUE"sv, - "INPUT_OBJECT"sv, - "INPUT_FIELD_DEFINITION"sv + R"gql(QUERY)gql"sv, + R"gql(MUTATION)gql"sv, + R"gql(SUBSCRIPTION)gql"sv, + R"gql(FIELD)gql"sv, + R"gql(FRAGMENT_DEFINITION)gql"sv, + R"gql(FRAGMENT_SPREAD)gql"sv, + R"gql(INLINE_FRAGMENT)gql"sv, + R"gql(SCHEMA)gql"sv, + R"gql(SCALAR)gql"sv, + R"gql(OBJECT)gql"sv, + R"gql(FIELD_DEFINITION)gql"sv, + R"gql(ARGUMENT_DEFINITION)gql"sv, + R"gql(INTERFACE)gql"sv, + R"gql(UNION)gql"sv, + R"gql(ENUM)gql"sv, + R"gql(ENUM_VALUE)gql"sv, + R"gql(INPUT_OBJECT)gql"sv, + R"gql(INPUT_FIELD_DEFINITION)gql"sv }; template <> @@ -88,14 +88,14 @@ introspection::DirectiveLocation ModifiedArgument()); if (itr == s_namesDirectiveLocation.cend()) { - throw service::schema_exception { { "not a valid __DirectiveLocation value" } }; + throw service::schema_exception { { R"ex(not a valid __DirectiveLocation value)ex" } }; } return static_cast(itr - s_namesDirectiveLocation.cbegin()); diff --git a/src/SchemaGenerator.cpp b/src/SchemaGenerator.cpp index ce7b5d53..1f3dcfb0 100644 --- a/src/SchemaGenerator.cpp +++ b/src/SchemaGenerator.cpp @@ -1144,7 +1144,7 @@ using namespace std::literals; } firstValue = false; - sourceFile << R"cpp( ")cpp" << value.value << R"cpp("sv)cpp"; + sourceFile << R"cpp( R"gql()cpp" << value.value << R"cpp()gql"sv)cpp"; } sourceFile << R"cpp( @@ -1158,8 +1158,8 @@ template <> { if (!value.maybe_enum()) { - throw service::schema_exception { { "not a valid )cpp" - << enumType.type << R"cpp( value" } }; + throw service::schema_exception { { R"ex(not a valid )cpp" + << enumType.type << R"cpp( value)ex" } }; } const auto itr = std::find(s_names)cpp" @@ -1169,8 +1169,8 @@ template <> if (itr == s_names)cpp" << enumType.cppType << R"cpp(.cend()) { - throw service::schema_exception { { "not a valid )cpp" - << enumType.type << R"cpp( value" } }; + throw service::schema_exception { { R"ex(not a valid )cpp" + << enumType.type << R"cpp( value)ex" } }; } return static_cast<)cpp" From 8d1a60f5796140631c6467b0c3f9501d27454f18 Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Wed, 8 Dec 2021 15:58:25 -0800 Subject: [PATCH 062/119] Implement type-erased union object types --- include/SchemaGenerator.h | 7 +- samples/learn/schema/DroidObject.h | 2 +- samples/learn/schema/HumanObject.h | 2 +- samples/today/TodayMock.cpp | 6 +- samples/today/TodayMock.h | 2 +- samples/today/separate/AppointmentObject.h | 8 +- samples/today/separate/FolderObject.h | 8 +- samples/today/separate/QueryObject.cpp | 2 +- samples/today/separate/QueryObject.h | 8 +- samples/today/separate/TaskObject.h | 8 +- samples/today/separate/TodayObjects.h | 1 + samples/today/separate/TodaySchema.cpp | 12 +- samples/today/separate/TodaySchema.h | 2 + samples/today/separate/UnionTypeObject.cpp | 42 +++ samples/today/separate/UnionTypeObject.h | 81 +++++ samples/today/separate/separate_schema_files | 1 + .../AppointmentObject.h | 8 +- .../separate_nointrospection/FolderObject.h | 8 +- .../separate_nointrospection/QueryObject.cpp | 2 +- .../separate_nointrospection/QueryObject.h | 8 +- .../separate_nointrospection/TaskObject.h | 8 +- .../separate_nointrospection/TodayObjects.h | 1 + .../separate_nointrospection/TodaySchema.cpp | 12 +- .../separate_nointrospection/TodaySchema.h | 2 + .../UnionTypeObject.cpp | 42 +++ .../UnionTypeObject.h | 81 +++++ .../separate_nointrospection_schema_files | 1 + samples/today/unified/TodaySchema.cpp | 30 +- samples/today/unified/TodaySchema.h | 93 +++++- .../unified_nointrospection/TodaySchema.cpp | 30 +- .../unified_nointrospection/TodaySchema.h | 93 +++++- .../validation/schema/ValidationSchema.cpp | 72 +++- samples/validation/schema/ValidationSchema.h | 230 ++++++++++++- src/SchemaGenerator.cpp | 310 ++++++++++++++---- src/SchemaLoader.cpp | 7 +- 35 files changed, 1048 insertions(+), 182 deletions(-) create mode 100644 samples/today/separate/UnionTypeObject.cpp create mode 100644 samples/today/separate/UnionTypeObject.h create mode 100644 samples/today/separate_nointrospection/UnionTypeObject.cpp create mode 100644 samples/today/separate_nointrospection/UnionTypeObject.h diff --git a/include/SchemaGenerator.h b/include/SchemaGenerator.h index 07dab141..49b3865c 100644 --- a/include/SchemaGenerator.h +++ b/include/SchemaGenerator.h @@ -42,8 +42,7 @@ class Generator std::string getSourcePath() const noexcept; bool outputHeader() const noexcept; - void outputInterfaceDeclaration( - std::ostream& headerFile, const InterfaceType& interfaceType) const; + void outputInterfaceDeclaration(std::ostream& headerFile, std::string_view cppType) const; void outputObjectImplements(std::ostream& headerFile, const ObjectType& objectType) const; void outputObjectStubs(std::ostream& headerFile, const ObjectType& objectType) const; void outputObjectDeclaration( @@ -53,10 +52,10 @@ class Generator std::string getResolverDeclaration(const OutputField& outputField) const noexcept; bool outputSource() const noexcept; - void outputInterfaceImplementation( - std::ostream& sourceFile, const InterfaceType& interfaceType) const; + void outputInterfaceImplementation(std::ostream& sourceFile, std::string_view cppType) const; void outputInterfaceIntrospection( std::ostream& sourceFile, const InterfaceType& interfaceType) const; + void outputUnionIntrospection(std::ostream& sourceFile, const UnionType& unionType) const; void outputObjectImplementation( std::ostream& sourceFile, const ObjectType& objectType, bool isQueryType) const; void outputObjectIntrospection(std::ostream& sourceFile, const ObjectType& objectType) const; diff --git a/samples/learn/schema/DroidObject.h b/samples/learn/schema/DroidObject.h index af339dbe..87ab955e 100644 --- a/samples/learn/schema/DroidObject.h +++ b/samples/learn/schema/DroidObject.h @@ -218,7 +218,7 @@ class Droid Droid(std::unique_ptr&& pimpl) noexcept; - // Interface objects need access to these methods + // Interfaces which this type implements friend Character; template diff --git a/samples/learn/schema/HumanObject.h b/samples/learn/schema/HumanObject.h index 4f62db54..3c20dc02 100644 --- a/samples/learn/schema/HumanObject.h +++ b/samples/learn/schema/HumanObject.h @@ -218,7 +218,7 @@ class Human Human(std::unique_ptr&& pimpl) noexcept; - // Interface objects need access to these methods + // Interfaces which this type implements friend Character; template diff --git a/samples/today/TodayMock.cpp b/samples/today/TodayMock.cpp index 34d3f7d2..66c85817 100644 --- a/samples/today/TodayMock.cpp +++ b/samples/today/TodayMock.cpp @@ -446,18 +446,18 @@ TaskState Query::getTestTaskState() return TaskState::Unassigned; } -std::vector> Query::getAnyType( +std::vector> Query::getAnyType( const service::FieldParams& params, const std::vector&) { loadAppointments(params.state); - std::vector> result(_appointments.size()); + std::vector> result(_appointments.size()); std::transform(_appointments.cbegin(), _appointments.cend(), result.begin(), [](const auto& appointment) noexcept { - return std::static_pointer_cast( + return std::make_shared( std::make_shared(appointment)); }); diff --git a/samples/today/TodayMock.h b/samples/today/TodayMock.h index b8af2cd2..e86a972a 100644 --- a/samples/today/TodayMock.h +++ b/samples/today/TodayMock.h @@ -73,7 +73,7 @@ class Query : public std::enable_shared_from_this std::shared_ptr getNested(service::FieldParams&& params); std::vector> getExpensive(); TaskState getTestTaskState(); - std::vector> getAnyType( + std::vector> getAnyType( const service::FieldParams& params, const std::vector& ids); private: diff --git a/samples/today/separate/AppointmentObject.h b/samples/today/separate/AppointmentObject.h index b394859d..70b29eff 100644 --- a/samples/today/separate/AppointmentObject.h +++ b/samples/today/separate/AppointmentObject.h @@ -11,12 +11,13 @@ #include "TodaySchema.h" #include "NodeObject.h" +#include "UnionTypeObject.h" namespace graphql::today::object { namespace implements { template -concept AppointmentIs = std::is_same_v; +concept AppointmentIs = std::is_same_v || std::is_same_v; } // namespace implements @@ -233,9 +234,12 @@ class Appointment Appointment(std::unique_ptr&& pimpl) noexcept; - // Interface objects need access to these methods + // Interfaces which this type implements friend Node; + // Unions which include this type + friend UnionType; + template static constexpr bool implements() noexcept { diff --git a/samples/today/separate/FolderObject.h b/samples/today/separate/FolderObject.h index 38fe33d4..01dadb1d 100644 --- a/samples/today/separate/FolderObject.h +++ b/samples/today/separate/FolderObject.h @@ -11,12 +11,13 @@ #include "TodaySchema.h" #include "NodeObject.h" +#include "UnionTypeObject.h" namespace graphql::today::object { namespace implements { template -concept FolderIs = std::is_same_v; +concept FolderIs = std::is_same_v || std::is_same_v; } // namespace implements @@ -173,9 +174,12 @@ class Folder Folder(std::unique_ptr&& pimpl) noexcept; - // Interface objects need access to these methods + // Interfaces which this type implements friend Node; + // Unions which include this type + friend UnionType; + template static constexpr bool implements() noexcept { diff --git a/samples/today/separate/QueryObject.cpp b/samples/today/separate/QueryObject.cpp index 032416d3..198cdc7b 100644 --- a/samples/today/separate/QueryObject.cpp +++ b/samples/today/separate/QueryObject.cpp @@ -219,7 +219,7 @@ service::AwaitableResolver Query::resolveAnyType(service::ResolverParams&& param auto result = _pimpl->getAnyType(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argIds)); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } service::AwaitableResolver Query::resolve_typename(service::ResolverParams&& params) const diff --git a/samples/today/separate/QueryObject.h b/samples/today/separate/QueryObject.h index 043d869c..31af69a6 100644 --- a/samples/today/separate/QueryObject.h +++ b/samples/today/separate/QueryObject.h @@ -148,13 +148,13 @@ concept getTestTaskState = requires (TImpl impl) template concept getAnyTypeWithParams = requires (TImpl impl, service::FieldParams params, std::vector idsArg) { - { service::FieldResult>> { impl.getAnyType(std::move(params), std::move(idsArg)) } }; + { service::FieldResult>> { impl.getAnyType(std::move(params), std::move(idsArg)) } }; }; template concept getAnyType = requires (TImpl impl, std::vector idsArg) { - { service::FieldResult>> { impl.getAnyType(std::move(idsArg)) } }; + { service::FieldResult>> { impl.getAnyType(std::move(idsArg)) } }; }; template @@ -212,7 +212,7 @@ class Query virtual service::FieldResult getUnimplemented(service::FieldParams&& params) const = 0; virtual service::FieldResult>> getExpensive(service::FieldParams&& params) const = 0; virtual service::FieldResult getTestTaskState(service::FieldParams&& params) const = 0; - virtual service::FieldResult>> getAnyType(service::FieldParams&& params, std::vector&& idsArg) const = 0; + virtual service::FieldResult>> getAnyType(service::FieldParams&& params, std::vector&& idsArg) const = 0; }; template @@ -400,7 +400,7 @@ class Query } } - service::FieldResult>> getAnyType(service::FieldParams&& params, std::vector&& idsArg) const final + service::FieldResult>> getAnyType(service::FieldParams&& params, std::vector&& idsArg) const final { if constexpr (methods::QueryHas::getAnyTypeWithParams) { diff --git a/samples/today/separate/TaskObject.h b/samples/today/separate/TaskObject.h index 5cadd3de..e3ef83fb 100644 --- a/samples/today/separate/TaskObject.h +++ b/samples/today/separate/TaskObject.h @@ -11,12 +11,13 @@ #include "TodaySchema.h" #include "NodeObject.h" +#include "UnionTypeObject.h" namespace graphql::today::object { namespace implements { template -concept TaskIs = std::is_same_v; +concept TaskIs = std::is_same_v || std::is_same_v; } // namespace implements @@ -173,9 +174,12 @@ class Task Task(std::unique_ptr&& pimpl) noexcept; - // Interface objects need access to these methods + // Interfaces which this type implements friend Node; + // Unions which include this type + friend UnionType; + template static constexpr bool implements() noexcept { diff --git a/samples/today/separate/TodayObjects.h b/samples/today/separate/TodayObjects.h index b9dda2ce..a172c18f 100644 --- a/samples/today/separate/TodayObjects.h +++ b/samples/today/separate/TodayObjects.h @@ -11,6 +11,7 @@ #include "TodaySchema.h" #include "NodeObject.h" +#include "UnionTypeObject.h" #include "QueryObject.h" #include "PageInfoObject.h" #include "AppointmentEdgeObject.h" diff --git a/samples/today/separate/TodaySchema.cpp b/samples/today/separate/TodaySchema.cpp index 4cabf9aa..61c0b93d 100644 --- a/samples/today/separate/TodaySchema.cpp +++ b/samples/today/separate/TodaySchema.cpp @@ -168,10 +168,10 @@ void AddTypesToSchema(const std::shared_ptr& schema) schema->AddType(R"gql(SecondNestedInput)gql"sv, typeSecondNestedInput); auto typeFirstNestedInput = schema::InputObjectType::Make(R"gql(FirstNestedInput)gql"sv, R"md()md"sv); schema->AddType(R"gql(FirstNestedInput)gql"sv, typeFirstNestedInput); - auto typeUnionType = schema::UnionType::Make(R"gql(UnionType)gql"sv, R"md()md"sv); - schema->AddType(R"gql(UnionType)gql"sv, typeUnionType); auto typeNode = schema::InterfaceType::Make(R"gql(Node)gql"sv, R"md(Node interface for Relay support)md"sv); schema->AddType(R"gql(Node)gql"sv, typeNode); + auto typeUnionType = schema::UnionType::Make(R"gql(UnionType)gql"sv, R"md()md"sv); + schema->AddType(R"gql(UnionType)gql"sv, typeUnionType); auto typeQuery = schema::ObjectType::Make(R"gql(Query)gql"sv, R"md(Root Query type)md"); schema->AddType(R"gql(Query)gql"sv, typeQuery); auto typePageInfo = schema::ObjectType::Make(R"gql(PageInfo)gql"sv, R"md()md"); @@ -234,14 +234,10 @@ void AddTypesToSchema(const std::shared_ptr& schema) schema::InputValue::Make(R"gql(third)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ThirdNestedInput)gql"sv)), R"gql()gql"sv) }); - typeUnionType->AddPossibleTypes({ - schema->LookupType(R"gql(Appointment)gql"sv), - schema->LookupType(R"gql(Task)gql"sv), - schema->LookupType(R"gql(Folder)gql"sv) - }); - AddNodeDetails(typeNode, schema); + AddUnionTypeDetails(typeUnionType, schema); + AddQueryDetails(typeQuery, schema); AddPageInfoDetails(typePageInfo, schema); AddAppointmentEdgeDetails(typeAppointmentEdge, schema); diff --git a/samples/today/separate/TodaySchema.h b/samples/today/separate/TodaySchema.h index c3042f81..acba377c 100644 --- a/samples/today/separate/TodaySchema.h +++ b/samples/today/separate/TodaySchema.h @@ -103,6 +103,8 @@ class Operations void AddNodeDetails(const std::shared_ptr& typeNode, const std::shared_ptr& schema); +void AddUnionTypeDetails(const std::shared_ptr& typeUnionType, const std::shared_ptr& schema); + void AddQueryDetails(const std::shared_ptr& typeQuery, const std::shared_ptr& schema); void AddPageInfoDetails(const std::shared_ptr& typePageInfo, const std::shared_ptr& schema); void AddAppointmentEdgeDetails(const std::shared_ptr& typeAppointmentEdge, const std::shared_ptr& schema); diff --git a/samples/today/separate/UnionTypeObject.cpp b/samples/today/separate/UnionTypeObject.cpp new file mode 100644 index 00000000..16786779 --- /dev/null +++ b/samples/today/separate/UnionTypeObject.cpp @@ -0,0 +1,42 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// WARNING! Do not edit this file manually, your changes will be overwritten. + +#include "TodayObjects.h" + +#include "graphqlservice/introspection/Introspection.h" + +using namespace std::literals; + +namespace graphql::today { +namespace object { + +UnionType::UnionType(std::unique_ptr&& pimpl) noexcept + : service::Object { pimpl->getTypeNames(), pimpl->getResolvers() } + , _pimpl { std::move(pimpl) } +{ +} + +void UnionType::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void UnionType::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} + +} // namespace object + +void AddUnionTypeDetails(const std::shared_ptr& typeUnionType, const std::shared_ptr& schema) +{ + typeUnionType->AddPossibleTypes({ + schema->LookupType(R"gql(Appointment)gql"sv), + schema->LookupType(R"gql(Task)gql"sv), + schema->LookupType(R"gql(Folder)gql"sv) + }); +} + +} // namespace graphql::today diff --git a/samples/today/separate/UnionTypeObject.h b/samples/today/separate/UnionTypeObject.h new file mode 100644 index 00000000..4e1ec759 --- /dev/null +++ b/samples/today/separate/UnionTypeObject.h @@ -0,0 +1,81 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// WARNING! Do not edit this file manually, your changes will be overwritten. + +#pragma once + +#ifndef UNIONTYPEOBJECT_H +#define UNIONTYPEOBJECT_H + +#include "TodaySchema.h" + +namespace graphql::today::object { + +class UnionType + : public service::Object +{ +private: + struct Concept + { + virtual ~Concept() = default; + + virtual service::TypeNames getTypeNames() const noexcept = 0; + virtual service::ResolverMap getResolvers() const noexcept = 0; + + virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::TypeNames getTypeNames() const noexcept final + { + return _pimpl->getTypeNames(); + } + + service::ResolverMap getResolvers() const noexcept final + { + return _pimpl->getResolvers(); + } + + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + _pimpl->beginSelectionSet(params); + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + _pimpl->endSelectionSet(params); + } + + private: + const std::shared_ptr _pimpl; + }; + + UnionType(std::unique_ptr&& pimpl) noexcept; + + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; + + const std::unique_ptr _pimpl; + +public: + template + UnionType(std::shared_ptr pimpl) noexcept + : UnionType { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } + { + static_assert(T::template implements(), "UnionType is not implemented"); + } +}; + +} // namespace graphql::today::object + +#endif // UNIONTYPEOBJECT_H diff --git a/samples/today/separate/separate_schema_files b/samples/today/separate/separate_schema_files index bb9ce34b..a9ed9ecf 100644 --- a/samples/today/separate/separate_schema_files +++ b/samples/today/separate/separate_schema_files @@ -1,5 +1,6 @@ TodaySchema.cpp NodeObject.cpp +UnionTypeObject.cpp QueryObject.cpp PageInfoObject.cpp AppointmentEdgeObject.cpp diff --git a/samples/today/separate_nointrospection/AppointmentObject.h b/samples/today/separate_nointrospection/AppointmentObject.h index b394859d..70b29eff 100644 --- a/samples/today/separate_nointrospection/AppointmentObject.h +++ b/samples/today/separate_nointrospection/AppointmentObject.h @@ -11,12 +11,13 @@ #include "TodaySchema.h" #include "NodeObject.h" +#include "UnionTypeObject.h" namespace graphql::today::object { namespace implements { template -concept AppointmentIs = std::is_same_v; +concept AppointmentIs = std::is_same_v || std::is_same_v; } // namespace implements @@ -233,9 +234,12 @@ class Appointment Appointment(std::unique_ptr&& pimpl) noexcept; - // Interface objects need access to these methods + // Interfaces which this type implements friend Node; + // Unions which include this type + friend UnionType; + template static constexpr bool implements() noexcept { diff --git a/samples/today/separate_nointrospection/FolderObject.h b/samples/today/separate_nointrospection/FolderObject.h index 38fe33d4..01dadb1d 100644 --- a/samples/today/separate_nointrospection/FolderObject.h +++ b/samples/today/separate_nointrospection/FolderObject.h @@ -11,12 +11,13 @@ #include "TodaySchema.h" #include "NodeObject.h" +#include "UnionTypeObject.h" namespace graphql::today::object { namespace implements { template -concept FolderIs = std::is_same_v; +concept FolderIs = std::is_same_v || std::is_same_v; } // namespace implements @@ -173,9 +174,12 @@ class Folder Folder(std::unique_ptr&& pimpl) noexcept; - // Interface objects need access to these methods + // Interfaces which this type implements friend Node; + // Unions which include this type + friend UnionType; + template static constexpr bool implements() noexcept { diff --git a/samples/today/separate_nointrospection/QueryObject.cpp b/samples/today/separate_nointrospection/QueryObject.cpp index 3a071b06..69d1356e 100644 --- a/samples/today/separate_nointrospection/QueryObject.cpp +++ b/samples/today/separate_nointrospection/QueryObject.cpp @@ -216,7 +216,7 @@ service::AwaitableResolver Query::resolveAnyType(service::ResolverParams&& param auto result = _pimpl->getAnyType(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argIds)); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } service::AwaitableResolver Query::resolve_typename(service::ResolverParams&& params) const diff --git a/samples/today/separate_nointrospection/QueryObject.h b/samples/today/separate_nointrospection/QueryObject.h index fbd11bc4..9840cdb9 100644 --- a/samples/today/separate_nointrospection/QueryObject.h +++ b/samples/today/separate_nointrospection/QueryObject.h @@ -148,13 +148,13 @@ concept getTestTaskState = requires (TImpl impl) template concept getAnyTypeWithParams = requires (TImpl impl, service::FieldParams params, std::vector idsArg) { - { service::FieldResult>> { impl.getAnyType(std::move(params), std::move(idsArg)) } }; + { service::FieldResult>> { impl.getAnyType(std::move(params), std::move(idsArg)) } }; }; template concept getAnyType = requires (TImpl impl, std::vector idsArg) { - { service::FieldResult>> { impl.getAnyType(std::move(idsArg)) } }; + { service::FieldResult>> { impl.getAnyType(std::move(idsArg)) } }; }; template @@ -208,7 +208,7 @@ class Query virtual service::FieldResult getUnimplemented(service::FieldParams&& params) const = 0; virtual service::FieldResult>> getExpensive(service::FieldParams&& params) const = 0; virtual service::FieldResult getTestTaskState(service::FieldParams&& params) const = 0; - virtual service::FieldResult>> getAnyType(service::FieldParams&& params, std::vector&& idsArg) const = 0; + virtual service::FieldResult>> getAnyType(service::FieldParams&& params, std::vector&& idsArg) const = 0; }; template @@ -396,7 +396,7 @@ class Query } } - service::FieldResult>> getAnyType(service::FieldParams&& params, std::vector&& idsArg) const final + service::FieldResult>> getAnyType(service::FieldParams&& params, std::vector&& idsArg) const final { if constexpr (methods::QueryHas::getAnyTypeWithParams) { diff --git a/samples/today/separate_nointrospection/TaskObject.h b/samples/today/separate_nointrospection/TaskObject.h index 5cadd3de..e3ef83fb 100644 --- a/samples/today/separate_nointrospection/TaskObject.h +++ b/samples/today/separate_nointrospection/TaskObject.h @@ -11,12 +11,13 @@ #include "TodaySchema.h" #include "NodeObject.h" +#include "UnionTypeObject.h" namespace graphql::today::object { namespace implements { template -concept TaskIs = std::is_same_v; +concept TaskIs = std::is_same_v || std::is_same_v; } // namespace implements @@ -173,9 +174,12 @@ class Task Task(std::unique_ptr&& pimpl) noexcept; - // Interface objects need access to these methods + // Interfaces which this type implements friend Node; + // Unions which include this type + friend UnionType; + template static constexpr bool implements() noexcept { diff --git a/samples/today/separate_nointrospection/TodayObjects.h b/samples/today/separate_nointrospection/TodayObjects.h index b9dda2ce..a172c18f 100644 --- a/samples/today/separate_nointrospection/TodayObjects.h +++ b/samples/today/separate_nointrospection/TodayObjects.h @@ -11,6 +11,7 @@ #include "TodaySchema.h" #include "NodeObject.h" +#include "UnionTypeObject.h" #include "QueryObject.h" #include "PageInfoObject.h" #include "AppointmentEdgeObject.h" diff --git a/samples/today/separate_nointrospection/TodaySchema.cpp b/samples/today/separate_nointrospection/TodaySchema.cpp index f896da1b..bea6f9f2 100644 --- a/samples/today/separate_nointrospection/TodaySchema.cpp +++ b/samples/today/separate_nointrospection/TodaySchema.cpp @@ -168,10 +168,10 @@ void AddTypesToSchema(const std::shared_ptr& schema) schema->AddType(R"gql(SecondNestedInput)gql"sv, typeSecondNestedInput); auto typeFirstNestedInput = schema::InputObjectType::Make(R"gql(FirstNestedInput)gql"sv, R"md()md"sv); schema->AddType(R"gql(FirstNestedInput)gql"sv, typeFirstNestedInput); - auto typeUnionType = schema::UnionType::Make(R"gql(UnionType)gql"sv, R"md()md"sv); - schema->AddType(R"gql(UnionType)gql"sv, typeUnionType); auto typeNode = schema::InterfaceType::Make(R"gql(Node)gql"sv, R"md()md"sv); schema->AddType(R"gql(Node)gql"sv, typeNode); + auto typeUnionType = schema::UnionType::Make(R"gql(UnionType)gql"sv, R"md()md"sv); + schema->AddType(R"gql(UnionType)gql"sv, typeUnionType); auto typeQuery = schema::ObjectType::Make(R"gql(Query)gql"sv, R"md()md"); schema->AddType(R"gql(Query)gql"sv, typeQuery); auto typePageInfo = schema::ObjectType::Make(R"gql(PageInfo)gql"sv, R"md()md"); @@ -234,14 +234,10 @@ void AddTypesToSchema(const std::shared_ptr& schema) schema::InputValue::Make(R"gql(third)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ThirdNestedInput)gql"sv)), R"gql()gql"sv) }); - typeUnionType->AddPossibleTypes({ - schema->LookupType(R"gql(Appointment)gql"sv), - schema->LookupType(R"gql(Task)gql"sv), - schema->LookupType(R"gql(Folder)gql"sv) - }); - AddNodeDetails(typeNode, schema); + AddUnionTypeDetails(typeUnionType, schema); + AddQueryDetails(typeQuery, schema); AddPageInfoDetails(typePageInfo, schema); AddAppointmentEdgeDetails(typeAppointmentEdge, schema); diff --git a/samples/today/separate_nointrospection/TodaySchema.h b/samples/today/separate_nointrospection/TodaySchema.h index c3042f81..acba377c 100644 --- a/samples/today/separate_nointrospection/TodaySchema.h +++ b/samples/today/separate_nointrospection/TodaySchema.h @@ -103,6 +103,8 @@ class Operations void AddNodeDetails(const std::shared_ptr& typeNode, const std::shared_ptr& schema); +void AddUnionTypeDetails(const std::shared_ptr& typeUnionType, const std::shared_ptr& schema); + void AddQueryDetails(const std::shared_ptr& typeQuery, const std::shared_ptr& schema); void AddPageInfoDetails(const std::shared_ptr& typePageInfo, const std::shared_ptr& schema); void AddAppointmentEdgeDetails(const std::shared_ptr& typeAppointmentEdge, const std::shared_ptr& schema); diff --git a/samples/today/separate_nointrospection/UnionTypeObject.cpp b/samples/today/separate_nointrospection/UnionTypeObject.cpp new file mode 100644 index 00000000..16786779 --- /dev/null +++ b/samples/today/separate_nointrospection/UnionTypeObject.cpp @@ -0,0 +1,42 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// WARNING! Do not edit this file manually, your changes will be overwritten. + +#include "TodayObjects.h" + +#include "graphqlservice/introspection/Introspection.h" + +using namespace std::literals; + +namespace graphql::today { +namespace object { + +UnionType::UnionType(std::unique_ptr&& pimpl) noexcept + : service::Object { pimpl->getTypeNames(), pimpl->getResolvers() } + , _pimpl { std::move(pimpl) } +{ +} + +void UnionType::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void UnionType::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} + +} // namespace object + +void AddUnionTypeDetails(const std::shared_ptr& typeUnionType, const std::shared_ptr& schema) +{ + typeUnionType->AddPossibleTypes({ + schema->LookupType(R"gql(Appointment)gql"sv), + schema->LookupType(R"gql(Task)gql"sv), + schema->LookupType(R"gql(Folder)gql"sv) + }); +} + +} // namespace graphql::today diff --git a/samples/today/separate_nointrospection/UnionTypeObject.h b/samples/today/separate_nointrospection/UnionTypeObject.h new file mode 100644 index 00000000..4e1ec759 --- /dev/null +++ b/samples/today/separate_nointrospection/UnionTypeObject.h @@ -0,0 +1,81 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// WARNING! Do not edit this file manually, your changes will be overwritten. + +#pragma once + +#ifndef UNIONTYPEOBJECT_H +#define UNIONTYPEOBJECT_H + +#include "TodaySchema.h" + +namespace graphql::today::object { + +class UnionType + : public service::Object +{ +private: + struct Concept + { + virtual ~Concept() = default; + + virtual service::TypeNames getTypeNames() const noexcept = 0; + virtual service::ResolverMap getResolvers() const noexcept = 0; + + virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::TypeNames getTypeNames() const noexcept final + { + return _pimpl->getTypeNames(); + } + + service::ResolverMap getResolvers() const noexcept final + { + return _pimpl->getResolvers(); + } + + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + _pimpl->beginSelectionSet(params); + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + _pimpl->endSelectionSet(params); + } + + private: + const std::shared_ptr _pimpl; + }; + + UnionType(std::unique_ptr&& pimpl) noexcept; + + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; + + const std::unique_ptr _pimpl; + +public: + template + UnionType(std::shared_ptr pimpl) noexcept + : UnionType { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } + { + static_assert(T::template implements(), "UnionType is not implemented"); + } +}; + +} // namespace graphql::today::object + +#endif // UNIONTYPEOBJECT_H diff --git a/samples/today/separate_nointrospection/separate_nointrospection_schema_files b/samples/today/separate_nointrospection/separate_nointrospection_schema_files index bb9ce34b..a9ed9ecf 100644 --- a/samples/today/separate_nointrospection/separate_nointrospection_schema_files +++ b/samples/today/separate_nointrospection/separate_nointrospection_schema_files @@ -1,5 +1,6 @@ TodaySchema.cpp NodeObject.cpp +UnionTypeObject.cpp QueryObject.cpp PageInfoObject.cpp AppointmentEdgeObject.cpp diff --git a/samples/today/unified/TodaySchema.cpp b/samples/today/unified/TodaySchema.cpp index 9411863f..c1a0a02c 100644 --- a/samples/today/unified/TodaySchema.cpp +++ b/samples/today/unified/TodaySchema.cpp @@ -157,6 +157,22 @@ void Node::endSelectionSet(const service::SelectionSetParams& params) const _pimpl->endSelectionSet(params); } +UnionType::UnionType(std::unique_ptr&& pimpl) noexcept + : service::Object { pimpl->getTypeNames(), pimpl->getResolvers() } + , _pimpl { std::move(pimpl) } +{ +} + +void UnionType::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void UnionType::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} + Query::Query(std::unique_ptr&& pimpl) noexcept : service::Object{ getTypeNames(), getResolvers() } , _schema { GetSchema() } @@ -358,7 +374,7 @@ service::AwaitableResolver Query::resolveAnyType(service::ResolverParams&& param auto result = _pimpl->getAnyType(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argIds)); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } service::AwaitableResolver Query::resolve_typename(service::ResolverParams&& params) const @@ -1318,10 +1334,10 @@ void AddTypesToSchema(const std::shared_ptr& schema) schema->AddType(R"gql(SecondNestedInput)gql"sv, typeSecondNestedInput); auto typeFirstNestedInput = schema::InputObjectType::Make(R"gql(FirstNestedInput)gql"sv, R"md()md"sv); schema->AddType(R"gql(FirstNestedInput)gql"sv, typeFirstNestedInput); - auto typeUnionType = schema::UnionType::Make(R"gql(UnionType)gql"sv, R"md()md"sv); - schema->AddType(R"gql(UnionType)gql"sv, typeUnionType); auto typeNode = schema::InterfaceType::Make(R"gql(Node)gql"sv, R"md(Node interface for Relay support)md"sv); schema->AddType(R"gql(Node)gql"sv, typeNode); + auto typeUnionType = schema::UnionType::Make(R"gql(UnionType)gql"sv, R"md()md"sv); + schema->AddType(R"gql(UnionType)gql"sv, typeUnionType); auto typeQuery = schema::ObjectType::Make(R"gql(Query)gql"sv, R"md(Root Query type)md"); schema->AddType(R"gql(Query)gql"sv, typeQuery); auto typePageInfo = schema::ObjectType::Make(R"gql(PageInfo)gql"sv, R"md()md"); @@ -1384,16 +1400,16 @@ void AddTypesToSchema(const std::shared_ptr& schema) schema::InputValue::Make(R"gql(third)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ThirdNestedInput)gql"sv)), R"gql()gql"sv) }); + typeNode->AddFields({ + schema::Field::Make(R"gql(id)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ID)gql"sv))) + }); + typeUnionType->AddPossibleTypes({ schema->LookupType(R"gql(Appointment)gql"sv), schema->LookupType(R"gql(Task)gql"sv), schema->LookupType(R"gql(Folder)gql"sv) }); - typeNode->AddFields({ - schema::Field::Make(R"gql(id)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ID)gql"sv))) - }); - typeQuery->AddFields({ schema::Field::Make(R"gql(node)gql"sv, R"md([Object Identification](https://facebook.github.io/relay/docs/en/graphql-server-specification.html#object-identification))md"sv, std::nullopt, schema->LookupType(R"gql(Node)gql"sv), { schema::InputValue::Make(R"gql(id)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ID)gql"sv)), R"gql()gql"sv) diff --git a/samples/today/unified/TodaySchema.h b/samples/today/unified/TodaySchema.h index 736cfac9..a1997452 100644 --- a/samples/today/unified/TodaySchema.h +++ b/samples/today/unified/TodaySchema.h @@ -145,16 +145,80 @@ class Node } }; +class UnionType + : public service::Object +{ +private: + struct Concept + { + virtual ~Concept() = default; + + virtual service::TypeNames getTypeNames() const noexcept = 0; + virtual service::ResolverMap getResolvers() const noexcept = 0; + + virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::TypeNames getTypeNames() const noexcept final + { + return _pimpl->getTypeNames(); + } + + service::ResolverMap getResolvers() const noexcept final + { + return _pimpl->getResolvers(); + } + + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + _pimpl->beginSelectionSet(params); + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + _pimpl->endSelectionSet(params); + } + + private: + const std::shared_ptr _pimpl; + }; + + UnionType(std::unique_ptr&& pimpl) noexcept; + + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; + + const std::unique_ptr _pimpl; + +public: + template + UnionType(std::shared_ptr pimpl) noexcept + : UnionType { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } + { + static_assert(T::template implements(), "UnionType is not implemented"); + } +}; + namespace implements { template -concept AppointmentIs = std::is_same_v; +concept AppointmentIs = std::is_same_v || std::is_same_v; template -concept TaskIs = std::is_same_v; +concept TaskIs = std::is_same_v || std::is_same_v; template -concept FolderIs = std::is_same_v; +concept FolderIs = std::is_same_v || std::is_same_v; } // namespace implements @@ -296,13 +360,13 @@ concept getTestTaskState = requires (TImpl impl) template concept getAnyTypeWithParams = requires (TImpl impl, service::FieldParams params, std::vector idsArg) { - { service::FieldResult>> { impl.getAnyType(std::move(params), std::move(idsArg)) } }; + { service::FieldResult>> { impl.getAnyType(std::move(params), std::move(idsArg)) } }; }; template concept getAnyType = requires (TImpl impl, std::vector idsArg) { - { service::FieldResult>> { impl.getAnyType(std::move(idsArg)) } }; + { service::FieldResult>> { impl.getAnyType(std::move(idsArg)) } }; }; template @@ -1009,7 +1073,7 @@ class Query virtual service::FieldResult getUnimplemented(service::FieldParams&& params) const = 0; virtual service::FieldResult>> getExpensive(service::FieldParams&& params) const = 0; virtual service::FieldResult getTestTaskState(service::FieldParams&& params) const = 0; - virtual service::FieldResult>> getAnyType(service::FieldParams&& params, std::vector&& idsArg) const = 0; + virtual service::FieldResult>> getAnyType(service::FieldParams&& params, std::vector&& idsArg) const = 0; }; template @@ -1197,7 +1261,7 @@ class Query } } - service::FieldResult>> getAnyType(service::FieldParams&& params, std::vector&& idsArg) const final + service::FieldResult>> getAnyType(service::FieldParams&& params, std::vector&& idsArg) const final { if constexpr (methods::QueryHas::getAnyTypeWithParams) { @@ -2378,9 +2442,12 @@ class Appointment Appointment(std::unique_ptr&& pimpl) noexcept; - // Interface objects need access to these methods + // Interfaces which this type implements friend Node; + // Unions which include this type + friend UnionType; + template static constexpr bool implements() noexcept { @@ -2504,9 +2571,12 @@ class Task Task(std::unique_ptr&& pimpl) noexcept; - // Interface objects need access to these methods + // Interfaces which this type implements friend Node; + // Unions which include this type + friend UnionType; + template static constexpr bool implements() noexcept { @@ -2630,9 +2700,12 @@ class Folder Folder(std::unique_ptr&& pimpl) noexcept; - // Interface objects need access to these methods + // Interfaces which this type implements friend Node; + // Unions which include this type + friend UnionType; + template static constexpr bool implements() noexcept { diff --git a/samples/today/unified_nointrospection/TodaySchema.cpp b/samples/today/unified_nointrospection/TodaySchema.cpp index 99d27fd6..5fe82b26 100644 --- a/samples/today/unified_nointrospection/TodaySchema.cpp +++ b/samples/today/unified_nointrospection/TodaySchema.cpp @@ -157,6 +157,22 @@ void Node::endSelectionSet(const service::SelectionSetParams& params) const _pimpl->endSelectionSet(params); } +UnionType::UnionType(std::unique_ptr&& pimpl) noexcept + : service::Object { pimpl->getTypeNames(), pimpl->getResolvers() } + , _pimpl { std::move(pimpl) } +{ +} + +void UnionType::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void UnionType::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} + Query::Query(std::unique_ptr&& pimpl) noexcept : service::Object{ getTypeNames(), getResolvers() } , _pimpl { std::move(pimpl) } @@ -355,7 +371,7 @@ service::AwaitableResolver Query::resolveAnyType(service::ResolverParams&& param auto result = _pimpl->getAnyType(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argIds)); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } service::AwaitableResolver Query::resolve_typename(service::ResolverParams&& params) const @@ -1301,10 +1317,10 @@ void AddTypesToSchema(const std::shared_ptr& schema) schema->AddType(R"gql(SecondNestedInput)gql"sv, typeSecondNestedInput); auto typeFirstNestedInput = schema::InputObjectType::Make(R"gql(FirstNestedInput)gql"sv, R"md()md"sv); schema->AddType(R"gql(FirstNestedInput)gql"sv, typeFirstNestedInput); - auto typeUnionType = schema::UnionType::Make(R"gql(UnionType)gql"sv, R"md()md"sv); - schema->AddType(R"gql(UnionType)gql"sv, typeUnionType); auto typeNode = schema::InterfaceType::Make(R"gql(Node)gql"sv, R"md()md"sv); schema->AddType(R"gql(Node)gql"sv, typeNode); + auto typeUnionType = schema::UnionType::Make(R"gql(UnionType)gql"sv, R"md()md"sv); + schema->AddType(R"gql(UnionType)gql"sv, typeUnionType); auto typeQuery = schema::ObjectType::Make(R"gql(Query)gql"sv, R"md()md"); schema->AddType(R"gql(Query)gql"sv, typeQuery); auto typePageInfo = schema::ObjectType::Make(R"gql(PageInfo)gql"sv, R"md()md"); @@ -1367,16 +1383,16 @@ void AddTypesToSchema(const std::shared_ptr& schema) schema::InputValue::Make(R"gql(third)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ThirdNestedInput)gql"sv)), R"gql()gql"sv) }); + typeNode->AddFields({ + schema::Field::Make(R"gql(id)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ID)gql"sv))) + }); + typeUnionType->AddPossibleTypes({ schema->LookupType(R"gql(Appointment)gql"sv), schema->LookupType(R"gql(Task)gql"sv), schema->LookupType(R"gql(Folder)gql"sv) }); - typeNode->AddFields({ - schema::Field::Make(R"gql(id)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ID)gql"sv))) - }); - typeQuery->AddFields({ schema::Field::Make(R"gql(node)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(Node)gql"sv), { schema::InputValue::Make(R"gql(id)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ID)gql"sv)), R"gql()gql"sv) diff --git a/samples/today/unified_nointrospection/TodaySchema.h b/samples/today/unified_nointrospection/TodaySchema.h index 98d71cfb..1213ab50 100644 --- a/samples/today/unified_nointrospection/TodaySchema.h +++ b/samples/today/unified_nointrospection/TodaySchema.h @@ -145,16 +145,80 @@ class Node } }; +class UnionType + : public service::Object +{ +private: + struct Concept + { + virtual ~Concept() = default; + + virtual service::TypeNames getTypeNames() const noexcept = 0; + virtual service::ResolverMap getResolvers() const noexcept = 0; + + virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::TypeNames getTypeNames() const noexcept final + { + return _pimpl->getTypeNames(); + } + + service::ResolverMap getResolvers() const noexcept final + { + return _pimpl->getResolvers(); + } + + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + _pimpl->beginSelectionSet(params); + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + _pimpl->endSelectionSet(params); + } + + private: + const std::shared_ptr _pimpl; + }; + + UnionType(std::unique_ptr&& pimpl) noexcept; + + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; + + const std::unique_ptr _pimpl; + +public: + template + UnionType(std::shared_ptr pimpl) noexcept + : UnionType { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } + { + static_assert(T::template implements(), "UnionType is not implemented"); + } +}; + namespace implements { template -concept AppointmentIs = std::is_same_v; +concept AppointmentIs = std::is_same_v || std::is_same_v; template -concept TaskIs = std::is_same_v; +concept TaskIs = std::is_same_v || std::is_same_v; template -concept FolderIs = std::is_same_v; +concept FolderIs = std::is_same_v || std::is_same_v; } // namespace implements @@ -296,13 +360,13 @@ concept getTestTaskState = requires (TImpl impl) template concept getAnyTypeWithParams = requires (TImpl impl, service::FieldParams params, std::vector idsArg) { - { service::FieldResult>> { impl.getAnyType(std::move(params), std::move(idsArg)) } }; + { service::FieldResult>> { impl.getAnyType(std::move(params), std::move(idsArg)) } }; }; template concept getAnyType = requires (TImpl impl, std::vector idsArg) { - { service::FieldResult>> { impl.getAnyType(std::move(idsArg)) } }; + { service::FieldResult>> { impl.getAnyType(std::move(idsArg)) } }; }; template @@ -1005,7 +1069,7 @@ class Query virtual service::FieldResult getUnimplemented(service::FieldParams&& params) const = 0; virtual service::FieldResult>> getExpensive(service::FieldParams&& params) const = 0; virtual service::FieldResult getTestTaskState(service::FieldParams&& params) const = 0; - virtual service::FieldResult>> getAnyType(service::FieldParams&& params, std::vector&& idsArg) const = 0; + virtual service::FieldResult>> getAnyType(service::FieldParams&& params, std::vector&& idsArg) const = 0; }; template @@ -1193,7 +1257,7 @@ class Query } } - service::FieldResult>> getAnyType(service::FieldParams&& params, std::vector&& idsArg) const final + service::FieldResult>> getAnyType(service::FieldParams&& params, std::vector&& idsArg) const final { if constexpr (methods::QueryHas::getAnyTypeWithParams) { @@ -2374,9 +2438,12 @@ class Appointment Appointment(std::unique_ptr&& pimpl) noexcept; - // Interface objects need access to these methods + // Interfaces which this type implements friend Node; + // Unions which include this type + friend UnionType; + template static constexpr bool implements() noexcept { @@ -2500,9 +2567,12 @@ class Task Task(std::unique_ptr&& pimpl) noexcept; - // Interface objects need access to these methods + // Interfaces which this type implements friend Node; + // Unions which include this type + friend UnionType; + template static constexpr bool implements() noexcept { @@ -2626,9 +2696,12 @@ class Folder Folder(std::unique_ptr&& pimpl) noexcept; - // Interface objects need access to these methods + // Interfaces which this type implements friend Node; + // Unions which include this type + friend UnionType; + template static constexpr bool implements() noexcept { diff --git a/samples/validation/schema/ValidationSchema.cpp b/samples/validation/schema/ValidationSchema.cpp index d0cb00a3..b6ec2dc7 100644 --- a/samples/validation/schema/ValidationSchema.cpp +++ b/samples/validation/schema/ValidationSchema.cpp @@ -144,6 +144,54 @@ void Pet::endSelectionSet(const service::SelectionSetParams& params) const _pimpl->endSelectionSet(params); } +CatOrDog::CatOrDog(std::unique_ptr&& pimpl) noexcept + : service::Object { pimpl->getTypeNames(), pimpl->getResolvers() } + , _pimpl { std::move(pimpl) } +{ +} + +void CatOrDog::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void CatOrDog::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} + +DogOrHuman::DogOrHuman(std::unique_ptr&& pimpl) noexcept + : service::Object { pimpl->getTypeNames(), pimpl->getResolvers() } + , _pimpl { std::move(pimpl) } +{ +} + +void DogOrHuman::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void DogOrHuman::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} + +HumanOrAlien::HumanOrAlien(std::unique_ptr&& pimpl) noexcept + : service::Object { pimpl->getTypeNames(), pimpl->getResolvers() } + , _pimpl { std::move(pimpl) } +{ +} + +void HumanOrAlien::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void HumanOrAlien::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} + Query::Query(std::unique_ptr&& pimpl) noexcept : service::Object{ getTypeNames(), getResolvers() } , _pimpl { std::move(pimpl) } @@ -218,7 +266,7 @@ service::AwaitableResolver Query::resolveCatOrDog(service::ResolverParams&& para auto result = _pimpl->getCatOrDog(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); resolverLock.unlock(); - return service::ModifiedResult::convert(std::move(result), std::move(params)); + return service::ModifiedResult::convert(std::move(result), std::move(params)); } service::AwaitableResolver Query::resolveArguments(service::ResolverParams&& params) const @@ -939,16 +987,16 @@ void AddTypesToSchema(const std::shared_ptr& schema) schema->AddType(R"gql(CatCommand)gql"sv, typeCatCommand); auto typeComplexInput = schema::InputObjectType::Make(R"gql(ComplexInput)gql"sv, R"md()md"sv); schema->AddType(R"gql(ComplexInput)gql"sv, typeComplexInput); + auto typeSentient = schema::InterfaceType::Make(R"gql(Sentient)gql"sv, R"md()md"sv); + schema->AddType(R"gql(Sentient)gql"sv, typeSentient); + auto typePet = schema::InterfaceType::Make(R"gql(Pet)gql"sv, R"md()md"sv); + schema->AddType(R"gql(Pet)gql"sv, typePet); auto typeCatOrDog = schema::UnionType::Make(R"gql(CatOrDog)gql"sv, R"md()md"sv); schema->AddType(R"gql(CatOrDog)gql"sv, typeCatOrDog); auto typeDogOrHuman = schema::UnionType::Make(R"gql(DogOrHuman)gql"sv, R"md()md"sv); schema->AddType(R"gql(DogOrHuman)gql"sv, typeDogOrHuman); auto typeHumanOrAlien = schema::UnionType::Make(R"gql(HumanOrAlien)gql"sv, R"md()md"sv); schema->AddType(R"gql(HumanOrAlien)gql"sv, typeHumanOrAlien); - auto typeSentient = schema::InterfaceType::Make(R"gql(Sentient)gql"sv, R"md()md"sv); - schema->AddType(R"gql(Sentient)gql"sv, typeSentient); - auto typePet = schema::InterfaceType::Make(R"gql(Pet)gql"sv, R"md()md"sv); - schema->AddType(R"gql(Pet)gql"sv, typePet); auto typeQuery = schema::ObjectType::Make(R"gql(Query)gql"sv, R"md()md"); schema->AddType(R"gql(Query)gql"sv, typeQuery); auto typeDog = schema::ObjectType::Make(R"gql(Dog)gql"sv, R"md()md"); @@ -984,6 +1032,13 @@ void AddTypesToSchema(const std::shared_ptr& schema) schema::InputValue::Make(R"gql(owner)gql"sv, R"md()md"sv, schema->LookupType(R"gql(String)gql"sv), R"gql()gql"sv) }); + typeSentient->AddFields({ + schema::Field::Make(R"gql(name)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(String)gql"sv))) + }); + typePet->AddFields({ + schema::Field::Make(R"gql(name)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(String)gql"sv))) + }); + typeCatOrDog->AddPossibleTypes({ schema->LookupType(R"gql(Cat)gql"sv), schema->LookupType(R"gql(Dog)gql"sv) @@ -997,13 +1052,6 @@ void AddTypesToSchema(const std::shared_ptr& schema) schema->LookupType(R"gql(Alien)gql"sv) }); - typeSentient->AddFields({ - schema::Field::Make(R"gql(name)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(String)gql"sv))) - }); - typePet->AddFields({ - schema::Field::Make(R"gql(name)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(String)gql"sv))) - }); - typeQuery->AddFields({ schema::Field::Make(R"gql(dog)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(Dog)gql"sv)), schema::Field::Make(R"gql(human)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(Human)gql"sv)), diff --git a/samples/validation/schema/ValidationSchema.h b/samples/validation/schema/ValidationSchema.h index d35c12fa..57a61c42 100644 --- a/samples/validation/schema/ValidationSchema.h +++ b/samples/validation/schema/ValidationSchema.h @@ -183,19 +183,211 @@ class Pet } }; +class CatOrDog + : public service::Object +{ +private: + struct Concept + { + virtual ~Concept() = default; + + virtual service::TypeNames getTypeNames() const noexcept = 0; + virtual service::ResolverMap getResolvers() const noexcept = 0; + + virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::TypeNames getTypeNames() const noexcept final + { + return _pimpl->getTypeNames(); + } + + service::ResolverMap getResolvers() const noexcept final + { + return _pimpl->getResolvers(); + } + + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + _pimpl->beginSelectionSet(params); + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + _pimpl->endSelectionSet(params); + } + + private: + const std::shared_ptr _pimpl; + }; + + CatOrDog(std::unique_ptr&& pimpl) noexcept; + + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; + + const std::unique_ptr _pimpl; + +public: + template + CatOrDog(std::shared_ptr pimpl) noexcept + : CatOrDog { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } + { + static_assert(T::template implements(), "CatOrDog is not implemented"); + } +}; + +class DogOrHuman + : public service::Object +{ +private: + struct Concept + { + virtual ~Concept() = default; + + virtual service::TypeNames getTypeNames() const noexcept = 0; + virtual service::ResolverMap getResolvers() const noexcept = 0; + + virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::TypeNames getTypeNames() const noexcept final + { + return _pimpl->getTypeNames(); + } + + service::ResolverMap getResolvers() const noexcept final + { + return _pimpl->getResolvers(); + } + + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + _pimpl->beginSelectionSet(params); + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + _pimpl->endSelectionSet(params); + } + + private: + const std::shared_ptr _pimpl; + }; + + DogOrHuman(std::unique_ptr&& pimpl) noexcept; + + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; + + const std::unique_ptr _pimpl; + +public: + template + DogOrHuman(std::shared_ptr pimpl) noexcept + : DogOrHuman { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } + { + static_assert(T::template implements(), "DogOrHuman is not implemented"); + } +}; + +class HumanOrAlien + : public service::Object +{ +private: + struct Concept + { + virtual ~Concept() = default; + + virtual service::TypeNames getTypeNames() const noexcept = 0; + virtual service::ResolverMap getResolvers() const noexcept = 0; + + virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::TypeNames getTypeNames() const noexcept final + { + return _pimpl->getTypeNames(); + } + + service::ResolverMap getResolvers() const noexcept final + { + return _pimpl->getResolvers(); + } + + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + _pimpl->beginSelectionSet(params); + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + _pimpl->endSelectionSet(params); + } + + private: + const std::shared_ptr _pimpl; + }; + + HumanOrAlien(std::unique_ptr&& pimpl) noexcept; + + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; + + const std::unique_ptr _pimpl; + +public: + template + HumanOrAlien(std::shared_ptr pimpl) noexcept + : HumanOrAlien { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } + { + static_assert(T::template implements(), "HumanOrAlien is not implemented"); + } +}; + namespace implements { template -concept DogIs = std::is_same_v; +concept DogIs = std::is_same_v || std::is_same_v || std::is_same_v; template -concept AlienIs = std::is_same_v; +concept AlienIs = std::is_same_v || std::is_same_v; template -concept HumanIs = std::is_same_v; +concept HumanIs = std::is_same_v || std::is_same_v || std::is_same_v; template -concept CatIs = std::is_same_v; +concept CatIs = std::is_same_v || std::is_same_v; } // namespace implements @@ -241,13 +433,13 @@ concept getPet = requires (TImpl impl) template concept getCatOrDogWithParams = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult> { impl.getCatOrDog(std::move(params)) } }; + { service::FieldResult> { impl.getCatOrDog(std::move(params)) } }; }; template concept getCatOrDog = requires (TImpl impl) { - { service::FieldResult> { impl.getCatOrDog() } }; + { service::FieldResult> { impl.getCatOrDog() } }; }; template @@ -805,7 +997,7 @@ class Query virtual service::FieldResult> getDog(service::FieldParams&& params) const = 0; virtual service::FieldResult> getHuman(service::FieldParams&& params) const = 0; virtual service::FieldResult> getPet(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getCatOrDog(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getCatOrDog(service::FieldParams&& params) const = 0; virtual service::FieldResult> getArguments(service::FieldParams&& params) const = 0; virtual service::FieldResult> getFindDog(service::FieldParams&& params, std::optional&& complexArg) const = 0; virtual service::FieldResult> getBooleanList(service::FieldParams&& params, std::optional>&& booleanListArgArg) const = 0; @@ -868,7 +1060,7 @@ class Query } } - service::FieldResult> getCatOrDog(service::FieldParams&& params) const final + service::FieldResult> getCatOrDog(service::FieldParams&& params) const final { if constexpr (methods::QueryHas::getCatOrDogWithParams) { @@ -1125,9 +1317,13 @@ class Dog Dog(std::unique_ptr&& pimpl) noexcept; - // Interface objects need access to these methods + // Interfaces which this type implements friend Pet; + // Unions which include this type + friend CatOrDog; + friend DogOrHuman; + template static constexpr bool implements() noexcept { @@ -1233,9 +1429,12 @@ class Alien Alien(std::unique_ptr&& pimpl) noexcept; - // Interface objects need access to these methods + // Interfaces which this type implements friend Sentient; + // Unions which include this type + friend HumanOrAlien; + template static constexpr bool implements() noexcept { @@ -1341,9 +1540,13 @@ class Human Human(std::unique_ptr&& pimpl) noexcept; - // Interface objects need access to these methods + // Interfaces which this type implements friend Sentient; + // Unions which include this type + friend DogOrHuman; + friend HumanOrAlien; + template static constexpr bool implements() noexcept { @@ -1485,9 +1688,12 @@ class Cat Cat(std::unique_ptr&& pimpl) noexcept; - // Interface objects need access to these methods + // Interfaces which this type implements friend Pet; + // Unions which include this type + friend CatOrDog; + template static constexpr bool implements() noexcept { diff --git a/src/SchemaGenerator.cpp b/src/SchemaGenerator.cpp index 1f3dcfb0..cfc062f3 100644 --- a/src/SchemaGenerator.cpp +++ b/src/SchemaGenerator.cpp @@ -306,7 +306,17 @@ static_assert(graphql::internal::MinorVersion == )cpp" // Output the full declarations for (const auto& interfaceType : _loader.getInterfaceTypes()) { - outputInterfaceDeclaration(headerFile, interfaceType); + outputInterfaceDeclaration(headerFile, interfaceType.cppType); + headerFile << std::endl; + } + } + + if (!_loader.getUnionTypes().empty()) + { + // Output the full declarations + for (const auto& unionType : _loader.getUnionTypes()) + { + outputInterfaceDeclaration(headerFile, unionType.cppType); headerFile << std::endl; } } @@ -492,6 +502,20 @@ static_assert(graphql::internal::MinorVersion == )cpp" headerFile << std::endl; } + if (!_loader.getUnionTypes().empty()) + { + for (const auto& unionType : _loader.getUnionTypes()) + { + headerFile << R"cpp(void Add)cpp" << unionType.cppType + << R"cpp(Details(const std::shared_ptr& type)cpp" + << unionType.cppType + << R"cpp(, const std::shared_ptr& schema); +)cpp"; + } + + headerFile << std::endl; + } + if (!_loader.getObjectTypes().empty()) { for (const auto& objectType : _loader.getObjectTypes()) @@ -572,11 +596,10 @@ GRAPHQLINTROSPECTION_EXPORT )cpp" return true; } -void Generator::outputInterfaceDeclaration( - std::ostream& headerFile, const InterfaceType& interfaceType) const +void Generator::outputInterfaceDeclaration(std::ostream& headerFile, std::string_view cppType) const { headerFile - << R"cpp(class )cpp" << interfaceType.cppType << R"cpp( + << R"cpp(class )cpp" << cppType << R"cpp( : public service::Object { private: @@ -625,7 +648,7 @@ void Generator::outputInterfaceDeclaration( }; )cpp" - << interfaceType.cppType << R"cpp((std::unique_ptr&& pimpl) noexcept; + << cppType << R"cpp((std::unique_ptr&& pimpl) noexcept; void beginSelectionSet(const service::SelectionSetParams& params) const final; void endSelectionSet(const service::SelectionSetParams& params) const final; @@ -635,14 +658,13 @@ void Generator::outputInterfaceDeclaration( public: template )cpp" - << interfaceType.cppType << R"cpp((std::shared_ptr pimpl) noexcept + << cppType << R"cpp((std::shared_ptr pimpl) noexcept : )cpp" - << interfaceType.cppType + << cppType << R"cpp( { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } { static_assert(T::template implements<)cpp" - << interfaceType.cppType << R"cpp(>(), ")cpp" << interfaceType.cppType - << R"cpp( is not implemented"); + << cppType << R"cpp(>(), ")cpp" << cppType << R"cpp( is not implemented"); } }; )cpp"; @@ -663,7 +685,20 @@ concept )cpp" << objectType.cppType headerFile << R"cpp( || )cpp"; } - headerFile << R"cpp(std::is_same_v)cpp"; + headerFile << R"cpp(std::is_same_v)cpp"; + firstInterface = false; + } + + for (auto unionName : objectType.unions) + { + if (!firstInterface) + { + headerFile << R"cpp( || )cpp"; + } + + headerFile << R"cpp(std::is_same_v)cpp"; firstInterface = false; } @@ -997,17 +1032,38 @@ void Generator::outputObjectDeclaration( if (!objectType.interfaces.empty()) { - headerFile << R"cpp( // Interface objects need access to these methods + headerFile << R"cpp( // Interfaces which this type implements )cpp"; for (auto interfaceName : objectType.interfaces) { - headerFile << R"cpp( friend )cpp" << interfaceName << R"cpp(; + headerFile << R"cpp( friend )cpp" << _loader.getSafeCppName(interfaceName) + << R"cpp(; )cpp"; } - headerFile << R"cpp( - template + headerFile << std::endl; + } + + if (!objectType.unions.empty()) + { + headerFile << R"cpp( // Unions which include this type +)cpp"; + + for (auto unionName : objectType.unions) + { + headerFile << R"cpp( friend )cpp" << _loader.getSafeCppName(unionName) + << R"cpp(; +)cpp"; + } + + headerFile << std::endl; + } + + if (!objectType.interfaces.empty() || !objectType.unions.empty()) + { + + headerFile << R"cpp( template static constexpr bool implements() noexcept { return implements::)cpp" @@ -1312,7 +1368,18 @@ service::AwaitableResolver ModifiedResult<)cpp" sourceFile << std::endl; } - outputInterfaceImplementation(sourceFile, interfaceType); + outputInterfaceImplementation(sourceFile, interfaceType.cppType); + sourceFile << std::endl; + } + + for (const auto& unionType : _loader.getUnionTypes()) + { + if (objectNamespace.enter()) + { + sourceFile << std::endl; + } + + outputInterfaceImplementation(sourceFile, unionType.cppType); sourceFile << std::endl; } @@ -1469,43 +1536,43 @@ Operations::Operations()cpp"; } } - if (!_loader.getUnionTypes().empty()) + if (!_loader.getInterfaceTypes().empty()) { - for (const auto& unionType : _loader.getUnionTypes()) + for (const auto& interfaceType : _loader.getInterfaceTypes()) { - sourceFile << R"cpp( auto type)cpp" << unionType.cppType - << R"cpp( = schema::UnionType::Make(R"gql()cpp" << unionType.type + sourceFile << R"cpp( auto type)cpp" << interfaceType.cppType + << R"cpp( = schema::InterfaceType::Make(R"gql()cpp" << interfaceType.type << R"cpp()gql"sv, R"md()cpp"; if (!_options.noIntrospection) { - sourceFile << unionType.description; + sourceFile << interfaceType.description; } sourceFile << R"cpp()md"sv); schema->AddType(R"gql()cpp" - << unionType.type << R"cpp()gql"sv, type)cpp" << unionType.cppType + << interfaceType.type << R"cpp()gql"sv, type)cpp" << interfaceType.cppType << R"cpp(); )cpp"; } } - if (!_loader.getInterfaceTypes().empty()) + if (!_loader.getUnionTypes().empty()) { - for (const auto& interfaceType : _loader.getInterfaceTypes()) + for (const auto& unionType : _loader.getUnionTypes()) { - sourceFile << R"cpp( auto type)cpp" << interfaceType.cppType - << R"cpp( = schema::InterfaceType::Make(R"gql()cpp" << interfaceType.type + sourceFile << R"cpp( auto type)cpp" << unionType.cppType + << R"cpp( = schema::UnionType::Make(R"gql()cpp" << unionType.type << R"cpp()gql"sv, R"md()cpp"; if (!_options.noIntrospection) { - sourceFile << interfaceType.description; + sourceFile << unionType.description; } sourceFile << R"cpp()md"sv); schema->AddType(R"gql()cpp" - << interfaceType.type << R"cpp()gql"sv, type)cpp" << interfaceType.cppType + << unionType.type << R"cpp()gql"sv, type)cpp" << unionType.cppType << R"cpp(); )cpp"; } @@ -1629,57 +1696,42 @@ Operations::Operations()cpp"; } } - if (!_loader.getUnionTypes().empty()) + if (!_loader.getInterfaceTypes().empty()) { sourceFile << std::endl; - for (const auto& unionType : _loader.getUnionTypes()) + const std::vector emptyInterfaces {}; + + for (const auto& interfaceType : _loader.getInterfaceTypes()) { - if (!unionType.options.empty()) + if (!_options.mergeFiles) { - bool firstValue = true; - - sourceFile << R"cpp( type)cpp" << unionType.cppType - << R"cpp(->AddPossibleTypes({ -)cpp"; - - for (const auto& unionOption : unionType.options) - { - if (!firstValue) - { - sourceFile << R"cpp(, -)cpp"; - } - - firstValue = false; - sourceFile << R"cpp( schema->LookupType(R"gql()cpp" << unionOption - << R"cpp()gql"sv))cpp"; - } - - sourceFile << R"cpp( - }); + sourceFile << R"cpp( Add)cpp" << interfaceType.cppType << R"cpp(Details(type)cpp" + << interfaceType.cppType << R"cpp(, schema); )cpp"; } + else + { + outputInterfaceIntrospection(sourceFile, interfaceType); + } } } - if (!_loader.getInterfaceTypes().empty()) + if (!_loader.getUnionTypes().empty()) { sourceFile << std::endl; - const std::vector emptyInterfaces {}; - - for (const auto& interfaceType : _loader.getInterfaceTypes()) + for (const auto& unionType : _loader.getUnionTypes()) { if (!_options.mergeFiles) { - sourceFile << R"cpp( Add)cpp" << interfaceType.cppType << R"cpp(Details(type)cpp" - << interfaceType.cppType << R"cpp(, schema); + sourceFile << R"cpp( Add)cpp" << unionType.cppType << R"cpp(Details(type)cpp" + << unionType.cppType << R"cpp(, schema); )cpp"; } else { - outputInterfaceIntrospection(sourceFile, interfaceType); + outputUnionIntrospection(sourceFile, unionType); } } } @@ -1830,12 +1882,12 @@ Operations::Operations()cpp"; } void Generator::outputInterfaceImplementation( - std::ostream& sourceFile, const InterfaceType& interfaceType) const + std::ostream& sourceFile, std::string_view cppType) const { // Output the private constructor which calls through to the service::Object constructor // with arguments that declare the set of types it implements and bind the fields to the // resolver methods. - sourceFile << interfaceType.cppType << R"cpp(::)cpp" << interfaceType.cppType + sourceFile << cppType << R"cpp(::)cpp" << cppType << R"cpp((std::unique_ptr&& pimpl) noexcept : service::Object { pimpl->getTypeNames(), pimpl->getResolvers() } , _pimpl { std::move(pimpl) } @@ -1844,13 +1896,13 @@ void Generator::outputInterfaceImplementation( )cpp"; sourceFile << R"cpp( -void )cpp" << interfaceType.cppType +void )cpp" << cppType << R"cpp(::beginSelectionSet(const service::SelectionSetParams& params) const { _pimpl->beginSelectionSet(params); } -void )cpp" << interfaceType.cppType +void )cpp" << cppType << R"cpp(::endSelectionSet(const service::SelectionSetParams& params) const { _pimpl->endSelectionSet(params); @@ -1864,6 +1916,36 @@ void Generator::outputInterfaceIntrospection( outputIntrospectionFields(sourceFile, interfaceType.cppType, interfaceType.fields); } +void Generator::outputUnionIntrospection(std::ostream& sourceFile, const UnionType& unionType) const +{ + if (unionType.options.empty()) + { + return; + } + + bool firstValue = true; + + sourceFile << R"cpp( type)cpp" << unionType.cppType << R"cpp(->AddPossibleTypes({ +)cpp"; + + for (const auto& unionOption : unionType.options) + { + if (!firstValue) + { + sourceFile << R"cpp(, +)cpp"; + } + + firstValue = false; + sourceFile << R"cpp( schema->LookupType(R"gql()cpp" << unionOption + << R"cpp()gql"sv))cpp"; + } + + sourceFile << R"cpp( + }); +)cpp"; +} + void Generator::outputObjectImplementation( std::ostream& sourceFile, const ObjectType& objectType, bool isQueryType) const { @@ -2487,18 +2569,15 @@ std::string Generator::getResultAccessType(const OutputField& result) const noex { case OutputFieldType::Builtin: case OutputFieldType::Enum: - case OutputFieldType::Object: case OutputFieldType::Interface: + case OutputFieldType::Union: + case OutputFieldType::Object: resultType << _loader.getCppType(result.type); break; case OutputFieldType::Scalar: resultType << R"cpp(response::Value)cpp"; break; - - case OutputFieldType::Union: - resultType << R"cpp(service::Object)cpp"; - break; } resultType << R"cpp(>)cpp"; @@ -2653,6 +2732,14 @@ std::vector Generator::outputSeparateFiles() const noexcept )cpp"; } + for (const auto& unionType : _loader.getUnionTypes()) + { + const auto headerFilename = std::string(unionType.cppType) + "Object.h"; + + objectHeaderFile << R"cpp(#include ")cpp" << headerFilename << R"cpp(" +)cpp"; + } + for (const auto& objectType : _loader.getObjectTypes()) { const auto headerFilename = std::string(objectType.cppType) + "Object.h"; @@ -2693,7 +2780,7 @@ std::vector Generator::outputSeparateFiles() const noexcept // Output the full declaration headerFile << std::endl; - outputInterfaceDeclaration(headerFile, interfaceType); + outputInterfaceDeclaration(headerFile, interfaceType.cppType); headerFile << std::endl; if (_options.verbose) @@ -2723,7 +2810,7 @@ using namespace std::literals; NamespaceScope sourceInterfaceNamespace { sourceFile, "object" }; sourceFile << std::endl; - outputInterfaceImplementation(sourceFile, interfaceType); + outputInterfaceImplementation(sourceFile, interfaceType.cppType); sourceFile << std::endl; sourceInterfaceNamespace.exit(); @@ -2738,6 +2825,80 @@ using namespace std::literals; outputInterfaceIntrospection(sourceFile, interfaceType); sourceFile << R"cpp(} +)cpp"; + + files.push_back(std::move(sourcePath)); + } + + for (const auto& unionType : _loader.getUnionTypes()) + { + const auto headerFilename = std::string(unionType.cppType) + "Object.h"; + auto headerPath = (headerDir / headerFilename).string(); + std::ofstream headerFile(headerPath, std::ios_base::trunc); + IncludeGuardScope includeGuard { headerFile, headerFilename }; + + headerFile << R"cpp(#include ")cpp" << fs::path(_headerPath).filename().string() << R"cpp(" + +)cpp"; + + std::ostringstream ossNamespace; + + ossNamespace << R"cpp(graphql::)cpp" << _loader.getSchemaNamespace(); + + const auto schemaNamespace = ossNamespace.str(); + std::ostringstream ossUnionNamespace; + + ossUnionNamespace << schemaNamespace << R"cpp(::object)cpp"; + + const auto objectNamespace = ossUnionNamespace.str(); + NamespaceScope headerNamespace { headerFile, objectNamespace }; + + // Output the full declaration + headerFile << std::endl; + outputInterfaceDeclaration(headerFile, unionType.cppType); + headerFile << std::endl; + + if (_options.verbose) + { + files.push_back(std::move(headerPath)); + } + + const auto sourceFilename = std::string(unionType.cppType) + "Object.cpp"; + auto sourcePath = (sourceDir / sourceFilename).string(); + std::ofstream sourceFile(sourcePath, std::ios_base::trunc); + + sourceFile << R"cpp(// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// WARNING! Do not edit this file manually, your changes will be overwritten. + +#include ")cpp" << fs::path(_objectHeaderPath).filename().string() + << R"cpp(" + +#include "graphqlservice/introspection/Introspection.h" + +using namespace std::literals; + +)cpp"; + + NamespaceScope sourceSchemaNamespace { sourceFile, schemaNamespace }; + NamespaceScope sourceUnionNamespace { sourceFile, "object" }; + + sourceFile << std::endl; + outputInterfaceImplementation(sourceFile, unionType.cppType); + sourceFile << std::endl; + + sourceUnionNamespace.exit(); + sourceFile << std::endl; + + sourceFile << R"cpp(void Add)cpp" << unionType.cppType + << R"cpp(Details(const std::shared_ptr& type)cpp" + << unionType.cppType << R"cpp(, const std::shared_ptr& schema) +{ +)cpp"; + outputUnionIntrospection(sourceFile, unionType); + sourceFile << R"cpp(} + )cpp"; files.push_back(std::move(sourcePath)); @@ -2755,11 +2916,18 @@ using namespace std::literals; )cpp"; - if (!objectType.interfaces.empty()) + if (!objectType.interfaces.empty() || !objectType.unions.empty()) { for (auto interfaceName : objectType.interfaces) { - headerFile << R"cpp(#include ")cpp" << interfaceName << R"cpp(Object.h" + headerFile << R"cpp(#include ")cpp" << _loader.getSafeCppName(interfaceName) + << R"cpp(Object.h" +)cpp"; + } + + for (auto unionName : objectType.unions) + { + headerFile << R"cpp(#include ")cpp" << unionName << R"cpp(Object.h" )cpp"; } diff --git a/src/SchemaLoader.cpp b/src/SchemaLoader.cpp index ae465e45..d6232fa0 100644 --- a/src/SchemaLoader.cpp +++ b/src/SchemaLoader.cpp @@ -1445,13 +1445,10 @@ std::string SchemaLoader::getOutputCppType(const OutputField& field) const noexc outputType << getCppType(field.type); break; - case OutputFieldType::Object: case OutputFieldType::Interface: - outputType << getSafeCppName(field.type); - break; - case OutputFieldType::Union: - outputType << R"cpp(service::Object)cpp"; + case OutputFieldType::Object: + outputType << getSafeCppName(field.type); break; } From 53dac3401c518fb1c2bbec373d4ffc8e49ea8125 Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Wed, 8 Dec 2021 16:41:15 -0800 Subject: [PATCH 063/119] Add forward declarations for union types --- samples/today/separate/TodaySchema.h | 2 ++ .../separate_nointrospection/TodaySchema.h | 2 ++ samples/today/unified/TodaySchema.h | 2 ++ .../today/unified_nointrospection/TodaySchema.h | 2 ++ samples/validation/schema/ValidationSchema.h | 4 ++++ src/SchemaGenerator.cpp | 17 +++++++++++++++++ 6 files changed, 29 insertions(+) diff --git a/samples/today/separate/TodaySchema.h b/samples/today/separate/TodaySchema.h index acba377c..053a5157 100644 --- a/samples/today/separate/TodaySchema.h +++ b/samples/today/separate/TodaySchema.h @@ -64,6 +64,8 @@ namespace object { class Node; +class UnionType; + class Query; class PageInfo; class AppointmentEdge; diff --git a/samples/today/separate_nointrospection/TodaySchema.h b/samples/today/separate_nointrospection/TodaySchema.h index acba377c..053a5157 100644 --- a/samples/today/separate_nointrospection/TodaySchema.h +++ b/samples/today/separate_nointrospection/TodaySchema.h @@ -64,6 +64,8 @@ namespace object { class Node; +class UnionType; + class Query; class PageInfo; class AppointmentEdge; diff --git a/samples/today/unified/TodaySchema.h b/samples/today/unified/TodaySchema.h index a1997452..0ee8ed5a 100644 --- a/samples/today/unified/TodaySchema.h +++ b/samples/today/unified/TodaySchema.h @@ -64,6 +64,8 @@ namespace object { class Node; +class UnionType; + class Query; class PageInfo; class AppointmentEdge; diff --git a/samples/today/unified_nointrospection/TodaySchema.h b/samples/today/unified_nointrospection/TodaySchema.h index 1213ab50..2b45e036 100644 --- a/samples/today/unified_nointrospection/TodaySchema.h +++ b/samples/today/unified_nointrospection/TodaySchema.h @@ -64,6 +64,8 @@ namespace object { class Node; +class UnionType; + class Query; class PageInfo; class AppointmentEdge; diff --git a/samples/validation/schema/ValidationSchema.h b/samples/validation/schema/ValidationSchema.h index 57a61c42..f8b632a8 100644 --- a/samples/validation/schema/ValidationSchema.h +++ b/samples/validation/schema/ValidationSchema.h @@ -44,6 +44,10 @@ namespace object { class Sentient; class Pet; +class CatOrDog; +class DogOrHuman; +class HumanOrAlien; + class Query; class Dog; class Alien; diff --git a/src/SchemaGenerator.cpp b/src/SchemaGenerator.cpp index cfc062f3..94c18369 100644 --- a/src/SchemaGenerator.cpp +++ b/src/SchemaGenerator.cpp @@ -265,6 +265,23 @@ static_assert(graphql::internal::MinorVersion == )cpp" headerFile << std::endl; } + if (!_loader.getUnionTypes().empty()) + { + if (objectNamespace.enter()) + { + headerFile << std::endl; + } + + // Forward declare all of the interface types + for (const auto& unionType : _loader.getUnionTypes()) + { + headerFile << R"cpp(class )cpp" << unionType.cppType << R"cpp(; +)cpp"; + } + + headerFile << std::endl; + } + if (!_loader.getObjectTypes().empty()) { if (_loader.isIntrospection()) From fdb5c9fdaf637aabb51d30ee1c2bb7e9166bafa2 Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Wed, 8 Dec 2021 16:43:00 -0800 Subject: [PATCH 064/119] Fix comment --- src/SchemaGenerator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SchemaGenerator.cpp b/src/SchemaGenerator.cpp index 94c18369..2950b8b6 100644 --- a/src/SchemaGenerator.cpp +++ b/src/SchemaGenerator.cpp @@ -272,7 +272,7 @@ static_assert(graphql::internal::MinorVersion == )cpp" headerFile << std::endl; } - // Forward declare all of the interface types + // Forward declare all of the union types for (const auto& unionType : _loader.getUnionTypes()) { headerFile << R"cpp(class )cpp" << unionType.cppType << R"cpp(; From 835f9a0cdf7deba7d8dcbabe218d1cd44e7b9be4 Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Wed, 8 Dec 2021 17:29:30 -0800 Subject: [PATCH 065/119] Include fewer headers and rely on forward declaration in ...Schema.h --- samples/learn/HeroData.cpp | 2 ++ samples/learn/schema/DroidObject.h | 2 -- samples/learn/schema/HumanObject.h | 2 -- samples/learn/schema/StarWarsSchema.cpp | 3 +- samples/today/separate/AppointmentObject.h | 3 -- samples/today/separate/FolderObject.h | 3 -- samples/today/separate/TaskObject.h | 3 -- samples/today/separate/TodaySchema.cpp | 4 ++- .../AppointmentObject.h | 3 -- .../separate_nointrospection/FolderObject.h | 3 -- .../separate_nointrospection/TaskObject.h | 3 -- .../separate_nointrospection/TodaySchema.cpp | 4 ++- src/SchemaGenerator.cpp | 36 +++++++++---------- 13 files changed, 26 insertions(+), 45 deletions(-) diff --git a/samples/learn/HeroData.cpp b/samples/learn/HeroData.cpp index 2b2c68ce..757c382c 100644 --- a/samples/learn/HeroData.cpp +++ b/samples/learn/HeroData.cpp @@ -6,6 +6,8 @@ #include "DroidData.h" #include "HumanData.h" +#include "CharacterObject.h" + namespace graphql::learn { std::shared_ptr make_hero(const SharedHero& hero) noexcept diff --git a/samples/learn/schema/DroidObject.h b/samples/learn/schema/DroidObject.h index 87ab955e..edd290b9 100644 --- a/samples/learn/schema/DroidObject.h +++ b/samples/learn/schema/DroidObject.h @@ -10,8 +10,6 @@ #include "StarWarsSchema.h" -#include "CharacterObject.h" - namespace graphql::learn::object { namespace implements { diff --git a/samples/learn/schema/HumanObject.h b/samples/learn/schema/HumanObject.h index 3c20dc02..60b0ced4 100644 --- a/samples/learn/schema/HumanObject.h +++ b/samples/learn/schema/HumanObject.h @@ -10,8 +10,6 @@ #include "StarWarsSchema.h" -#include "CharacterObject.h" - namespace graphql::learn::object { namespace implements { diff --git a/samples/learn/schema/StarWarsSchema.cpp b/samples/learn/schema/StarWarsSchema.cpp index 034ec47f..235d6561 100644 --- a/samples/learn/schema/StarWarsSchema.cpp +++ b/samples/learn/schema/StarWarsSchema.cpp @@ -3,7 +3,8 @@ // WARNING! Do not edit this file manually, your changes will be overwritten. -#include "StarWarsObjects.h" +#include "QueryObject.h" +#include "MutationObject.h" #include "graphqlservice/introspection/Introspection.h" diff --git a/samples/today/separate/AppointmentObject.h b/samples/today/separate/AppointmentObject.h index 70b29eff..b55c94d1 100644 --- a/samples/today/separate/AppointmentObject.h +++ b/samples/today/separate/AppointmentObject.h @@ -10,9 +10,6 @@ #include "TodaySchema.h" -#include "NodeObject.h" -#include "UnionTypeObject.h" - namespace graphql::today::object { namespace implements { diff --git a/samples/today/separate/FolderObject.h b/samples/today/separate/FolderObject.h index 01dadb1d..7928ba74 100644 --- a/samples/today/separate/FolderObject.h +++ b/samples/today/separate/FolderObject.h @@ -10,9 +10,6 @@ #include "TodaySchema.h" -#include "NodeObject.h" -#include "UnionTypeObject.h" - namespace graphql::today::object { namespace implements { diff --git a/samples/today/separate/TaskObject.h b/samples/today/separate/TaskObject.h index e3ef83fb..49f6bb02 100644 --- a/samples/today/separate/TaskObject.h +++ b/samples/today/separate/TaskObject.h @@ -10,9 +10,6 @@ #include "TodaySchema.h" -#include "NodeObject.h" -#include "UnionTypeObject.h" - namespace graphql::today::object { namespace implements { diff --git a/samples/today/separate/TodaySchema.cpp b/samples/today/separate/TodaySchema.cpp index 61c0b93d..f241e2be 100644 --- a/samples/today/separate/TodaySchema.cpp +++ b/samples/today/separate/TodaySchema.cpp @@ -3,7 +3,9 @@ // WARNING! Do not edit this file manually, your changes will be overwritten. -#include "TodayObjects.h" +#include "QueryObject.h" +#include "MutationObject.h" +#include "SubscriptionObject.h" #include "graphqlservice/introspection/Introspection.h" diff --git a/samples/today/separate_nointrospection/AppointmentObject.h b/samples/today/separate_nointrospection/AppointmentObject.h index 70b29eff..b55c94d1 100644 --- a/samples/today/separate_nointrospection/AppointmentObject.h +++ b/samples/today/separate_nointrospection/AppointmentObject.h @@ -10,9 +10,6 @@ #include "TodaySchema.h" -#include "NodeObject.h" -#include "UnionTypeObject.h" - namespace graphql::today::object { namespace implements { diff --git a/samples/today/separate_nointrospection/FolderObject.h b/samples/today/separate_nointrospection/FolderObject.h index 01dadb1d..7928ba74 100644 --- a/samples/today/separate_nointrospection/FolderObject.h +++ b/samples/today/separate_nointrospection/FolderObject.h @@ -10,9 +10,6 @@ #include "TodaySchema.h" -#include "NodeObject.h" -#include "UnionTypeObject.h" - namespace graphql::today::object { namespace implements { diff --git a/samples/today/separate_nointrospection/TaskObject.h b/samples/today/separate_nointrospection/TaskObject.h index e3ef83fb..49f6bb02 100644 --- a/samples/today/separate_nointrospection/TaskObject.h +++ b/samples/today/separate_nointrospection/TaskObject.h @@ -10,9 +10,6 @@ #include "TodaySchema.h" -#include "NodeObject.h" -#include "UnionTypeObject.h" - namespace graphql::today::object { namespace implements { diff --git a/samples/today/separate_nointrospection/TodaySchema.cpp b/samples/today/separate_nointrospection/TodaySchema.cpp index bea6f9f2..c9558b01 100644 --- a/samples/today/separate_nointrospection/TodaySchema.cpp +++ b/samples/today/separate_nointrospection/TodaySchema.cpp @@ -3,7 +3,9 @@ // WARNING! Do not edit this file manually, your changes will be overwritten. -#include "TodayObjects.h" +#include "QueryObject.h" +#include "MutationObject.h" +#include "SubscriptionObject.h" #include "graphqlservice/introspection/Introspection.h" diff --git a/src/SchemaGenerator.cpp b/src/SchemaGenerator.cpp index 2950b8b6..8a8203f5 100644 --- a/src/SchemaGenerator.cpp +++ b/src/SchemaGenerator.cpp @@ -1170,10 +1170,24 @@ bool Generator::outputSource() const noexcept if (!_loader.isIntrospection()) { - sourceFile << R"cpp(#include ")cpp" << fs::path(_objectHeaderPath).filename().string() - << R"cpp(" + if (_options.mergeFiles) + { + sourceFile << R"cpp(#include ")cpp" << fs::path(_headerPath).filename().string() + << R"cpp(" + +)cpp"; + } + else + { + for (const auto& operation : _loader.getOperationTypes()) + { + sourceFile << R"cpp(#include ")cpp" << operation.cppType << R"cpp(Object.h" )cpp"; + } + + sourceFile << std::endl; + } } sourceFile << R"cpp(#include "graphqlservice/introspection/Introspection.h" @@ -2933,24 +2947,6 @@ using namespace std::literals; )cpp"; - if (!objectType.interfaces.empty() || !objectType.unions.empty()) - { - for (auto interfaceName : objectType.interfaces) - { - headerFile << R"cpp(#include ")cpp" << _loader.getSafeCppName(interfaceName) - << R"cpp(Object.h" -)cpp"; - } - - for (auto unionName : objectType.unions) - { - headerFile << R"cpp(#include ")cpp" << unionName << R"cpp(Object.h" -)cpp"; - } - - headerFile << std::endl; - } - std::ostringstream ossNamespace; ossNamespace << R"cpp(graphql::)cpp" << _loader.getSchemaNamespace(); From f603111bef9fdb0f9e1a4abc40a580a7656b57f9 Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Wed, 8 Dec 2021 17:50:39 -0800 Subject: [PATCH 066/119] Fix #156 --- samples/learn/schema/CharacterObject.cpp | 2 +- samples/learn/schema/DroidObject.cpp | 3 +- samples/learn/schema/HumanObject.cpp | 3 +- samples/learn/schema/MutationObject.cpp | 3 +- samples/learn/schema/QueryObject.cpp | 5 ++- samples/learn/schema/ReviewObject.cpp | 2 +- .../separate/AppointmentConnectionObject.cpp | 4 ++- .../today/separate/AppointmentEdgeObject.cpp | 3 +- samples/today/separate/AppointmentObject.cpp | 2 +- .../separate/CompleteTaskPayloadObject.cpp | 3 +- samples/today/separate/ExpensiveObject.cpp | 2 +- .../today/separate/FolderConnectionObject.cpp | 4 ++- samples/today/separate/FolderEdgeObject.cpp | 3 +- samples/today/separate/FolderObject.cpp | 2 +- samples/today/separate/MutationObject.cpp | 3 +- samples/today/separate/NestedTypeObject.cpp | 3 +- samples/today/separate/NodeObject.cpp | 2 +- samples/today/separate/PageInfoObject.cpp | 2 +- samples/today/separate/QueryObject.cpp | 12 ++++++- samples/today/separate/SubscriptionObject.cpp | 4 ++- .../today/separate/TaskConnectionObject.cpp | 4 ++- samples/today/separate/TaskEdgeObject.cpp | 3 +- samples/today/separate/TaskObject.cpp | 2 +- samples/today/separate/UnionTypeObject.cpp | 2 +- .../AppointmentConnectionObject.cpp | 4 ++- .../AppointmentEdgeObject.cpp | 3 +- .../AppointmentObject.cpp | 2 +- .../CompleteTaskPayloadObject.cpp | 3 +- .../ExpensiveObject.cpp | 2 +- .../FolderConnectionObject.cpp | 4 ++- .../FolderEdgeObject.cpp | 3 +- .../separate_nointrospection/FolderObject.cpp | 2 +- .../MutationObject.cpp | 3 +- .../NestedTypeObject.cpp | 3 +- .../separate_nointrospection/NodeObject.cpp | 2 +- .../PageInfoObject.cpp | 2 +- .../separate_nointrospection/QueryObject.cpp | 12 ++++++- .../SubscriptionObject.cpp | 4 ++- .../TaskConnectionObject.cpp | 4 ++- .../TaskEdgeObject.cpp | 3 +- .../separate_nointrospection/TaskObject.cpp | 2 +- .../UnionTypeObject.cpp | 2 +- src/SchemaGenerator.cpp | 31 +++++++++++++++++-- 43 files changed, 124 insertions(+), 45 deletions(-) diff --git a/samples/learn/schema/CharacterObject.cpp b/samples/learn/schema/CharacterObject.cpp index 57953a85..c4d361b0 100644 --- a/samples/learn/schema/CharacterObject.cpp +++ b/samples/learn/schema/CharacterObject.cpp @@ -3,7 +3,7 @@ // WARNING! Do not edit this file manually, your changes will be overwritten. -#include "StarWarsObjects.h" +#include "CharacterObject.h" #include "graphqlservice/introspection/Introspection.h" diff --git a/samples/learn/schema/DroidObject.cpp b/samples/learn/schema/DroidObject.cpp index 3ac977f9..33ab5986 100644 --- a/samples/learn/schema/DroidObject.cpp +++ b/samples/learn/schema/DroidObject.cpp @@ -3,7 +3,8 @@ // WARNING! Do not edit this file manually, your changes will be overwritten. -#include "StarWarsObjects.h" +#include "DroidObject.h" +#include "CharacterObject.h" #include "graphqlservice/introspection/Introspection.h" diff --git a/samples/learn/schema/HumanObject.cpp b/samples/learn/schema/HumanObject.cpp index bfdb356f..ade5dd79 100644 --- a/samples/learn/schema/HumanObject.cpp +++ b/samples/learn/schema/HumanObject.cpp @@ -3,7 +3,8 @@ // WARNING! Do not edit this file manually, your changes will be overwritten. -#include "StarWarsObjects.h" +#include "HumanObject.h" +#include "CharacterObject.h" #include "graphqlservice/introspection/Introspection.h" diff --git a/samples/learn/schema/MutationObject.cpp b/samples/learn/schema/MutationObject.cpp index a4fb3fea..c93ea1b2 100644 --- a/samples/learn/schema/MutationObject.cpp +++ b/samples/learn/schema/MutationObject.cpp @@ -3,7 +3,8 @@ // WARNING! Do not edit this file manually, your changes will be overwritten. -#include "StarWarsObjects.h" +#include "MutationObject.h" +#include "ReviewObject.h" #include "graphqlservice/introspection/Introspection.h" diff --git a/samples/learn/schema/QueryObject.cpp b/samples/learn/schema/QueryObject.cpp index 913677cf..b1e331b5 100644 --- a/samples/learn/schema/QueryObject.cpp +++ b/samples/learn/schema/QueryObject.cpp @@ -3,7 +3,10 @@ // WARNING! Do not edit this file manually, your changes will be overwritten. -#include "StarWarsObjects.h" +#include "QueryObject.h" +#include "CharacterObject.h" +#include "HumanObject.h" +#include "DroidObject.h" #include "graphqlservice/introspection/Introspection.h" diff --git a/samples/learn/schema/ReviewObject.cpp b/samples/learn/schema/ReviewObject.cpp index 4ed93d41..07f604f1 100644 --- a/samples/learn/schema/ReviewObject.cpp +++ b/samples/learn/schema/ReviewObject.cpp @@ -3,7 +3,7 @@ // WARNING! Do not edit this file manually, your changes will be overwritten. -#include "StarWarsObjects.h" +#include "ReviewObject.h" #include "graphqlservice/introspection/Introspection.h" diff --git a/samples/today/separate/AppointmentConnectionObject.cpp b/samples/today/separate/AppointmentConnectionObject.cpp index d131a073..acb05f2c 100644 --- a/samples/today/separate/AppointmentConnectionObject.cpp +++ b/samples/today/separate/AppointmentConnectionObject.cpp @@ -3,7 +3,9 @@ // WARNING! Do not edit this file manually, your changes will be overwritten. -#include "TodayObjects.h" +#include "AppointmentConnectionObject.h" +#include "PageInfoObject.h" +#include "AppointmentEdgeObject.h" #include "graphqlservice/introspection/Introspection.h" diff --git a/samples/today/separate/AppointmentEdgeObject.cpp b/samples/today/separate/AppointmentEdgeObject.cpp index 33e97006..4daf5740 100644 --- a/samples/today/separate/AppointmentEdgeObject.cpp +++ b/samples/today/separate/AppointmentEdgeObject.cpp @@ -3,7 +3,8 @@ // WARNING! Do not edit this file manually, your changes will be overwritten. -#include "TodayObjects.h" +#include "AppointmentEdgeObject.h" +#include "AppointmentObject.h" #include "graphqlservice/introspection/Introspection.h" diff --git a/samples/today/separate/AppointmentObject.cpp b/samples/today/separate/AppointmentObject.cpp index 46f096c3..63748bd1 100644 --- a/samples/today/separate/AppointmentObject.cpp +++ b/samples/today/separate/AppointmentObject.cpp @@ -3,7 +3,7 @@ // WARNING! Do not edit this file manually, your changes will be overwritten. -#include "TodayObjects.h" +#include "AppointmentObject.h" #include "graphqlservice/introspection/Introspection.h" diff --git a/samples/today/separate/CompleteTaskPayloadObject.cpp b/samples/today/separate/CompleteTaskPayloadObject.cpp index ca3e2533..ccba911f 100644 --- a/samples/today/separate/CompleteTaskPayloadObject.cpp +++ b/samples/today/separate/CompleteTaskPayloadObject.cpp @@ -3,7 +3,8 @@ // WARNING! Do not edit this file manually, your changes will be overwritten. -#include "TodayObjects.h" +#include "CompleteTaskPayloadObject.h" +#include "TaskObject.h" #include "graphqlservice/introspection/Introspection.h" diff --git a/samples/today/separate/ExpensiveObject.cpp b/samples/today/separate/ExpensiveObject.cpp index 79600744..76ec6277 100644 --- a/samples/today/separate/ExpensiveObject.cpp +++ b/samples/today/separate/ExpensiveObject.cpp @@ -3,7 +3,7 @@ // WARNING! Do not edit this file manually, your changes will be overwritten. -#include "TodayObjects.h" +#include "ExpensiveObject.h" #include "graphqlservice/introspection/Introspection.h" diff --git a/samples/today/separate/FolderConnectionObject.cpp b/samples/today/separate/FolderConnectionObject.cpp index 56393333..64d3a6f9 100644 --- a/samples/today/separate/FolderConnectionObject.cpp +++ b/samples/today/separate/FolderConnectionObject.cpp @@ -3,7 +3,9 @@ // WARNING! Do not edit this file manually, your changes will be overwritten. -#include "TodayObjects.h" +#include "FolderConnectionObject.h" +#include "PageInfoObject.h" +#include "FolderEdgeObject.h" #include "graphqlservice/introspection/Introspection.h" diff --git a/samples/today/separate/FolderEdgeObject.cpp b/samples/today/separate/FolderEdgeObject.cpp index 91721638..fd54275c 100644 --- a/samples/today/separate/FolderEdgeObject.cpp +++ b/samples/today/separate/FolderEdgeObject.cpp @@ -3,7 +3,8 @@ // WARNING! Do not edit this file manually, your changes will be overwritten. -#include "TodayObjects.h" +#include "FolderEdgeObject.h" +#include "FolderObject.h" #include "graphqlservice/introspection/Introspection.h" diff --git a/samples/today/separate/FolderObject.cpp b/samples/today/separate/FolderObject.cpp index 7f4e0fa4..85cf4a6a 100644 --- a/samples/today/separate/FolderObject.cpp +++ b/samples/today/separate/FolderObject.cpp @@ -3,7 +3,7 @@ // WARNING! Do not edit this file manually, your changes will be overwritten. -#include "TodayObjects.h" +#include "FolderObject.h" #include "graphqlservice/introspection/Introspection.h" diff --git a/samples/today/separate/MutationObject.cpp b/samples/today/separate/MutationObject.cpp index c0357075..703e2aa2 100644 --- a/samples/today/separate/MutationObject.cpp +++ b/samples/today/separate/MutationObject.cpp @@ -3,7 +3,8 @@ // WARNING! Do not edit this file manually, your changes will be overwritten. -#include "TodayObjects.h" +#include "MutationObject.h" +#include "CompleteTaskPayloadObject.h" #include "graphqlservice/introspection/Introspection.h" diff --git a/samples/today/separate/NestedTypeObject.cpp b/samples/today/separate/NestedTypeObject.cpp index f994b6c0..c3a52e5e 100644 --- a/samples/today/separate/NestedTypeObject.cpp +++ b/samples/today/separate/NestedTypeObject.cpp @@ -3,7 +3,8 @@ // WARNING! Do not edit this file manually, your changes will be overwritten. -#include "TodayObjects.h" +#include "NestedTypeObject.h" +#include "NestedTypeObject.h" #include "graphqlservice/introspection/Introspection.h" diff --git a/samples/today/separate/NodeObject.cpp b/samples/today/separate/NodeObject.cpp index 73ea28b2..eb0a6dcc 100644 --- a/samples/today/separate/NodeObject.cpp +++ b/samples/today/separate/NodeObject.cpp @@ -3,7 +3,7 @@ // WARNING! Do not edit this file manually, your changes will be overwritten. -#include "TodayObjects.h" +#include "NodeObject.h" #include "graphqlservice/introspection/Introspection.h" diff --git a/samples/today/separate/PageInfoObject.cpp b/samples/today/separate/PageInfoObject.cpp index 96c4a35b..9c6412af 100644 --- a/samples/today/separate/PageInfoObject.cpp +++ b/samples/today/separate/PageInfoObject.cpp @@ -3,7 +3,7 @@ // WARNING! Do not edit this file manually, your changes will be overwritten. -#include "TodayObjects.h" +#include "PageInfoObject.h" #include "graphqlservice/introspection/Introspection.h" diff --git a/samples/today/separate/QueryObject.cpp b/samples/today/separate/QueryObject.cpp index 198cdc7b..d3460dc0 100644 --- a/samples/today/separate/QueryObject.cpp +++ b/samples/today/separate/QueryObject.cpp @@ -3,7 +3,17 @@ // WARNING! Do not edit this file manually, your changes will be overwritten. -#include "TodayObjects.h" +#include "QueryObject.h" +#include "NodeObject.h" +#include "AppointmentConnectionObject.h" +#include "TaskConnectionObject.h" +#include "FolderConnectionObject.h" +#include "AppointmentObject.h" +#include "TaskObject.h" +#include "FolderObject.h" +#include "NestedTypeObject.h" +#include "ExpensiveObject.h" +#include "UnionTypeObject.h" #include "graphqlservice/introspection/Introspection.h" diff --git a/samples/today/separate/SubscriptionObject.cpp b/samples/today/separate/SubscriptionObject.cpp index ad310259..6c936e6a 100644 --- a/samples/today/separate/SubscriptionObject.cpp +++ b/samples/today/separate/SubscriptionObject.cpp @@ -3,7 +3,9 @@ // WARNING! Do not edit this file manually, your changes will be overwritten. -#include "TodayObjects.h" +#include "SubscriptionObject.h" +#include "AppointmentObject.h" +#include "NodeObject.h" #include "graphqlservice/introspection/Introspection.h" diff --git a/samples/today/separate/TaskConnectionObject.cpp b/samples/today/separate/TaskConnectionObject.cpp index da1c45a4..5231eb62 100644 --- a/samples/today/separate/TaskConnectionObject.cpp +++ b/samples/today/separate/TaskConnectionObject.cpp @@ -3,7 +3,9 @@ // WARNING! Do not edit this file manually, your changes will be overwritten. -#include "TodayObjects.h" +#include "TaskConnectionObject.h" +#include "PageInfoObject.h" +#include "TaskEdgeObject.h" #include "graphqlservice/introspection/Introspection.h" diff --git a/samples/today/separate/TaskEdgeObject.cpp b/samples/today/separate/TaskEdgeObject.cpp index 37f531eb..3e58f857 100644 --- a/samples/today/separate/TaskEdgeObject.cpp +++ b/samples/today/separate/TaskEdgeObject.cpp @@ -3,7 +3,8 @@ // WARNING! Do not edit this file manually, your changes will be overwritten. -#include "TodayObjects.h" +#include "TaskEdgeObject.h" +#include "TaskObject.h" #include "graphqlservice/introspection/Introspection.h" diff --git a/samples/today/separate/TaskObject.cpp b/samples/today/separate/TaskObject.cpp index 082c203c..8c719282 100644 --- a/samples/today/separate/TaskObject.cpp +++ b/samples/today/separate/TaskObject.cpp @@ -3,7 +3,7 @@ // WARNING! Do not edit this file manually, your changes will be overwritten. -#include "TodayObjects.h" +#include "TaskObject.h" #include "graphqlservice/introspection/Introspection.h" diff --git a/samples/today/separate/UnionTypeObject.cpp b/samples/today/separate/UnionTypeObject.cpp index 16786779..7e3f0874 100644 --- a/samples/today/separate/UnionTypeObject.cpp +++ b/samples/today/separate/UnionTypeObject.cpp @@ -3,7 +3,7 @@ // WARNING! Do not edit this file manually, your changes will be overwritten. -#include "TodayObjects.h" +#include "UnionTypeObject.h" #include "graphqlservice/introspection/Introspection.h" diff --git a/samples/today/separate_nointrospection/AppointmentConnectionObject.cpp b/samples/today/separate_nointrospection/AppointmentConnectionObject.cpp index d131a073..acb05f2c 100644 --- a/samples/today/separate_nointrospection/AppointmentConnectionObject.cpp +++ b/samples/today/separate_nointrospection/AppointmentConnectionObject.cpp @@ -3,7 +3,9 @@ // WARNING! Do not edit this file manually, your changes will be overwritten. -#include "TodayObjects.h" +#include "AppointmentConnectionObject.h" +#include "PageInfoObject.h" +#include "AppointmentEdgeObject.h" #include "graphqlservice/introspection/Introspection.h" diff --git a/samples/today/separate_nointrospection/AppointmentEdgeObject.cpp b/samples/today/separate_nointrospection/AppointmentEdgeObject.cpp index 33e97006..4daf5740 100644 --- a/samples/today/separate_nointrospection/AppointmentEdgeObject.cpp +++ b/samples/today/separate_nointrospection/AppointmentEdgeObject.cpp @@ -3,7 +3,8 @@ // WARNING! Do not edit this file manually, your changes will be overwritten. -#include "TodayObjects.h" +#include "AppointmentEdgeObject.h" +#include "AppointmentObject.h" #include "graphqlservice/introspection/Introspection.h" diff --git a/samples/today/separate_nointrospection/AppointmentObject.cpp b/samples/today/separate_nointrospection/AppointmentObject.cpp index 46f096c3..63748bd1 100644 --- a/samples/today/separate_nointrospection/AppointmentObject.cpp +++ b/samples/today/separate_nointrospection/AppointmentObject.cpp @@ -3,7 +3,7 @@ // WARNING! Do not edit this file manually, your changes will be overwritten. -#include "TodayObjects.h" +#include "AppointmentObject.h" #include "graphqlservice/introspection/Introspection.h" diff --git a/samples/today/separate_nointrospection/CompleteTaskPayloadObject.cpp b/samples/today/separate_nointrospection/CompleteTaskPayloadObject.cpp index ca3e2533..ccba911f 100644 --- a/samples/today/separate_nointrospection/CompleteTaskPayloadObject.cpp +++ b/samples/today/separate_nointrospection/CompleteTaskPayloadObject.cpp @@ -3,7 +3,8 @@ // WARNING! Do not edit this file manually, your changes will be overwritten. -#include "TodayObjects.h" +#include "CompleteTaskPayloadObject.h" +#include "TaskObject.h" #include "graphqlservice/introspection/Introspection.h" diff --git a/samples/today/separate_nointrospection/ExpensiveObject.cpp b/samples/today/separate_nointrospection/ExpensiveObject.cpp index 79600744..76ec6277 100644 --- a/samples/today/separate_nointrospection/ExpensiveObject.cpp +++ b/samples/today/separate_nointrospection/ExpensiveObject.cpp @@ -3,7 +3,7 @@ // WARNING! Do not edit this file manually, your changes will be overwritten. -#include "TodayObjects.h" +#include "ExpensiveObject.h" #include "graphqlservice/introspection/Introspection.h" diff --git a/samples/today/separate_nointrospection/FolderConnectionObject.cpp b/samples/today/separate_nointrospection/FolderConnectionObject.cpp index 56393333..64d3a6f9 100644 --- a/samples/today/separate_nointrospection/FolderConnectionObject.cpp +++ b/samples/today/separate_nointrospection/FolderConnectionObject.cpp @@ -3,7 +3,9 @@ // WARNING! Do not edit this file manually, your changes will be overwritten. -#include "TodayObjects.h" +#include "FolderConnectionObject.h" +#include "PageInfoObject.h" +#include "FolderEdgeObject.h" #include "graphqlservice/introspection/Introspection.h" diff --git a/samples/today/separate_nointrospection/FolderEdgeObject.cpp b/samples/today/separate_nointrospection/FolderEdgeObject.cpp index 91721638..fd54275c 100644 --- a/samples/today/separate_nointrospection/FolderEdgeObject.cpp +++ b/samples/today/separate_nointrospection/FolderEdgeObject.cpp @@ -3,7 +3,8 @@ // WARNING! Do not edit this file manually, your changes will be overwritten. -#include "TodayObjects.h" +#include "FolderEdgeObject.h" +#include "FolderObject.h" #include "graphqlservice/introspection/Introspection.h" diff --git a/samples/today/separate_nointrospection/FolderObject.cpp b/samples/today/separate_nointrospection/FolderObject.cpp index 7f4e0fa4..85cf4a6a 100644 --- a/samples/today/separate_nointrospection/FolderObject.cpp +++ b/samples/today/separate_nointrospection/FolderObject.cpp @@ -3,7 +3,7 @@ // WARNING! Do not edit this file manually, your changes will be overwritten. -#include "TodayObjects.h" +#include "FolderObject.h" #include "graphqlservice/introspection/Introspection.h" diff --git a/samples/today/separate_nointrospection/MutationObject.cpp b/samples/today/separate_nointrospection/MutationObject.cpp index c0357075..703e2aa2 100644 --- a/samples/today/separate_nointrospection/MutationObject.cpp +++ b/samples/today/separate_nointrospection/MutationObject.cpp @@ -3,7 +3,8 @@ // WARNING! Do not edit this file manually, your changes will be overwritten. -#include "TodayObjects.h" +#include "MutationObject.h" +#include "CompleteTaskPayloadObject.h" #include "graphqlservice/introspection/Introspection.h" diff --git a/samples/today/separate_nointrospection/NestedTypeObject.cpp b/samples/today/separate_nointrospection/NestedTypeObject.cpp index 9a43d8a3..3574d829 100644 --- a/samples/today/separate_nointrospection/NestedTypeObject.cpp +++ b/samples/today/separate_nointrospection/NestedTypeObject.cpp @@ -3,7 +3,8 @@ // WARNING! Do not edit this file manually, your changes will be overwritten. -#include "TodayObjects.h" +#include "NestedTypeObject.h" +#include "NestedTypeObject.h" #include "graphqlservice/introspection/Introspection.h" diff --git a/samples/today/separate_nointrospection/NodeObject.cpp b/samples/today/separate_nointrospection/NodeObject.cpp index 73ea28b2..eb0a6dcc 100644 --- a/samples/today/separate_nointrospection/NodeObject.cpp +++ b/samples/today/separate_nointrospection/NodeObject.cpp @@ -3,7 +3,7 @@ // WARNING! Do not edit this file manually, your changes will be overwritten. -#include "TodayObjects.h" +#include "NodeObject.h" #include "graphqlservice/introspection/Introspection.h" diff --git a/samples/today/separate_nointrospection/PageInfoObject.cpp b/samples/today/separate_nointrospection/PageInfoObject.cpp index 96c4a35b..9c6412af 100644 --- a/samples/today/separate_nointrospection/PageInfoObject.cpp +++ b/samples/today/separate_nointrospection/PageInfoObject.cpp @@ -3,7 +3,7 @@ // WARNING! Do not edit this file manually, your changes will be overwritten. -#include "TodayObjects.h" +#include "PageInfoObject.h" #include "graphqlservice/introspection/Introspection.h" diff --git a/samples/today/separate_nointrospection/QueryObject.cpp b/samples/today/separate_nointrospection/QueryObject.cpp index 69d1356e..701cb42e 100644 --- a/samples/today/separate_nointrospection/QueryObject.cpp +++ b/samples/today/separate_nointrospection/QueryObject.cpp @@ -3,7 +3,17 @@ // WARNING! Do not edit this file manually, your changes will be overwritten. -#include "TodayObjects.h" +#include "QueryObject.h" +#include "NodeObject.h" +#include "AppointmentConnectionObject.h" +#include "TaskConnectionObject.h" +#include "FolderConnectionObject.h" +#include "AppointmentObject.h" +#include "TaskObject.h" +#include "FolderObject.h" +#include "NestedTypeObject.h" +#include "ExpensiveObject.h" +#include "UnionTypeObject.h" #include "graphqlservice/introspection/Introspection.h" diff --git a/samples/today/separate_nointrospection/SubscriptionObject.cpp b/samples/today/separate_nointrospection/SubscriptionObject.cpp index ad310259..6c936e6a 100644 --- a/samples/today/separate_nointrospection/SubscriptionObject.cpp +++ b/samples/today/separate_nointrospection/SubscriptionObject.cpp @@ -3,7 +3,9 @@ // WARNING! Do not edit this file manually, your changes will be overwritten. -#include "TodayObjects.h" +#include "SubscriptionObject.h" +#include "AppointmentObject.h" +#include "NodeObject.h" #include "graphqlservice/introspection/Introspection.h" diff --git a/samples/today/separate_nointrospection/TaskConnectionObject.cpp b/samples/today/separate_nointrospection/TaskConnectionObject.cpp index da1c45a4..5231eb62 100644 --- a/samples/today/separate_nointrospection/TaskConnectionObject.cpp +++ b/samples/today/separate_nointrospection/TaskConnectionObject.cpp @@ -3,7 +3,9 @@ // WARNING! Do not edit this file manually, your changes will be overwritten. -#include "TodayObjects.h" +#include "TaskConnectionObject.h" +#include "PageInfoObject.h" +#include "TaskEdgeObject.h" #include "graphqlservice/introspection/Introspection.h" diff --git a/samples/today/separate_nointrospection/TaskEdgeObject.cpp b/samples/today/separate_nointrospection/TaskEdgeObject.cpp index 37f531eb..3e58f857 100644 --- a/samples/today/separate_nointrospection/TaskEdgeObject.cpp +++ b/samples/today/separate_nointrospection/TaskEdgeObject.cpp @@ -3,7 +3,8 @@ // WARNING! Do not edit this file manually, your changes will be overwritten. -#include "TodayObjects.h" +#include "TaskEdgeObject.h" +#include "TaskObject.h" #include "graphqlservice/introspection/Introspection.h" diff --git a/samples/today/separate_nointrospection/TaskObject.cpp b/samples/today/separate_nointrospection/TaskObject.cpp index 082c203c..8c719282 100644 --- a/samples/today/separate_nointrospection/TaskObject.cpp +++ b/samples/today/separate_nointrospection/TaskObject.cpp @@ -3,7 +3,7 @@ // WARNING! Do not edit this file manually, your changes will be overwritten. -#include "TodayObjects.h" +#include "TaskObject.h" #include "graphqlservice/introspection/Introspection.h" diff --git a/samples/today/separate_nointrospection/UnionTypeObject.cpp b/samples/today/separate_nointrospection/UnionTypeObject.cpp index 16786779..7e3f0874 100644 --- a/samples/today/separate_nointrospection/UnionTypeObject.cpp +++ b/samples/today/separate_nointrospection/UnionTypeObject.cpp @@ -3,7 +3,7 @@ // WARNING! Do not edit this file manually, your changes will be overwritten. -#include "TodayObjects.h" +#include "UnionTypeObject.h" #include "graphqlservice/introspection/Introspection.h" diff --git a/src/SchemaGenerator.cpp b/src/SchemaGenerator.cpp index 8a8203f5..a9c5c4f8 100644 --- a/src/SchemaGenerator.cpp +++ b/src/SchemaGenerator.cpp @@ -41,6 +41,7 @@ #include #include #include +#include using namespace std::literals; @@ -2828,7 +2829,7 @@ std::vector Generator::outputSeparateFiles() const noexcept // WARNING! Do not edit this file manually, your changes will be overwritten. -#include ")cpp" << fs::path(_objectHeaderPath).filename().string() +#include ")cpp" << headerFilename << R"cpp(" #include "graphqlservice/introspection/Introspection.h" @@ -2903,7 +2904,7 @@ using namespace std::literals; // WARNING! Do not edit this file manually, your changes will be overwritten. -#include ")cpp" << fs::path(_objectHeaderPath).filename().string() +#include ")cpp" << headerFilename << R"cpp(" #include "graphqlservice/introspection/Introspection.h" @@ -3000,9 +3001,33 @@ using namespace std::literals; // WARNING! Do not edit this file manually, your changes will be overwritten. -#include ")cpp" << fs::path(_objectHeaderPath).filename().string() +#include ")cpp" << headerFilename << R"cpp(" +)cpp"; + + std::unordered_set includedObjects; + + for (const auto& field : objectType.fields) + { + switch (field.fieldType) + { + case OutputFieldType::Interface: + case OutputFieldType::Union: + case OutputFieldType::Object: + if (includedObjects.insert(field.type).second) + { + sourceFile << R"cpp(#include ")cpp" << _loader.getSafeCppName(field.type) + << R"cpp(Object.h" +)cpp"; + } + break; + default: + break; + } + } + + sourceFile << R"cpp( #include "graphqlservice/introspection/Introspection.h" #include From 9427a8646f5b7793d9a2c399cd33d82911f14f45 Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Wed, 8 Dec 2021 17:58:25 -0800 Subject: [PATCH 067/119] StarWarsData.cpp doesn't need the convenience header --- samples/learn/StarWarsData.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/samples/learn/StarWarsData.cpp b/samples/learn/StarWarsData.cpp index 7f85383c..57a89a99 100644 --- a/samples/learn/StarWarsData.cpp +++ b/samples/learn/StarWarsData.cpp @@ -9,8 +9,6 @@ #include "QueryData.h" #include "ReviewData.h" -#include "StarWarsObjects.h" - using namespace std::literals; namespace graphql::star_wars { From 09a4e80b6c4ad5d0270bc965f4fa8821cffb101e Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Wed, 8 Dec 2021 18:44:22 -0800 Subject: [PATCH 068/119] Convert validation schema to separate files --- samples/validation/ValidationMock.h | 4 + samples/validation/schema/AlienObject.cpp | 93 + samples/validation/schema/AlienObject.h | 174 ++ samples/validation/schema/ArgumentsObject.cpp | 200 ++ samples/validation/schema/ArgumentsObject.h | 335 +++ samples/validation/schema/CMakeLists.txt | 2 +- samples/validation/schema/CatObject.cpp | 120 + samples/validation/schema/CatObject.h | 234 ++ samples/validation/schema/CatOrDogObject.cpp | 41 + samples/validation/schema/CatOrDogObject.h | 81 + samples/validation/schema/DogObject.cpp | 149 ++ samples/validation/schema/DogObject.h | 295 +++ .../validation/schema/DogOrHumanObject.cpp | 41 + samples/validation/schema/DogOrHumanObject.h | 81 + samples/validation/schema/HumanObject.cpp | 95 + samples/validation/schema/HumanObject.h | 175 ++ .../validation/schema/HumanOrAlienObject.cpp | 41 + .../validation/schema/HumanOrAlienObject.h | 81 + samples/validation/schema/MessageObject.cpp | 88 + samples/validation/schema/MessageObject.h | 155 ++ .../schema/MutateDogResultObject.cpp | 76 + .../validation/schema/MutateDogResultObject.h | 125 + samples/validation/schema/MutationObject.cpp | 77 + samples/validation/schema/MutationObject.h | 125 + samples/validation/schema/PetObject.cpp | 40 + samples/validation/schema/PetObject.h | 81 + samples/validation/schema/QueryObject.cpp | 159 ++ samples/validation/schema/QueryObject.h | 305 +++ samples/validation/schema/SentientObject.cpp | 40 + samples/validation/schema/SentientObject.h | 81 + .../validation/schema/SubscriptionObject.cpp | 89 + .../validation/schema/SubscriptionObject.h | 155 ++ samples/validation/schema/ValidationObjects.h | 29 + .../validation/schema/ValidationSchema.cpp | 987 +------- samples/validation/schema/ValidationSchema.h | 2246 +---------------- .../validation/schema/validation_schema_files | 15 + 36 files changed, 3917 insertions(+), 3198 deletions(-) create mode 100644 samples/validation/schema/AlienObject.cpp create mode 100644 samples/validation/schema/AlienObject.h create mode 100644 samples/validation/schema/ArgumentsObject.cpp create mode 100644 samples/validation/schema/ArgumentsObject.h create mode 100644 samples/validation/schema/CatObject.cpp create mode 100644 samples/validation/schema/CatObject.h create mode 100644 samples/validation/schema/CatOrDogObject.cpp create mode 100644 samples/validation/schema/CatOrDogObject.h create mode 100644 samples/validation/schema/DogObject.cpp create mode 100644 samples/validation/schema/DogObject.h create mode 100644 samples/validation/schema/DogOrHumanObject.cpp create mode 100644 samples/validation/schema/DogOrHumanObject.h create mode 100644 samples/validation/schema/HumanObject.cpp create mode 100644 samples/validation/schema/HumanObject.h create mode 100644 samples/validation/schema/HumanOrAlienObject.cpp create mode 100644 samples/validation/schema/HumanOrAlienObject.h create mode 100644 samples/validation/schema/MessageObject.cpp create mode 100644 samples/validation/schema/MessageObject.h create mode 100644 samples/validation/schema/MutateDogResultObject.cpp create mode 100644 samples/validation/schema/MutateDogResultObject.h create mode 100644 samples/validation/schema/MutationObject.cpp create mode 100644 samples/validation/schema/MutationObject.h create mode 100644 samples/validation/schema/PetObject.cpp create mode 100644 samples/validation/schema/PetObject.h create mode 100644 samples/validation/schema/QueryObject.cpp create mode 100644 samples/validation/schema/QueryObject.h create mode 100644 samples/validation/schema/SentientObject.cpp create mode 100644 samples/validation/schema/SentientObject.h create mode 100644 samples/validation/schema/SubscriptionObject.cpp create mode 100644 samples/validation/schema/SubscriptionObject.h create mode 100644 samples/validation/schema/ValidationObjects.h diff --git a/samples/validation/ValidationMock.h b/samples/validation/ValidationMock.h index 1f382528..8c079aab 100644 --- a/samples/validation/ValidationMock.h +++ b/samples/validation/ValidationMock.h @@ -8,6 +8,10 @@ #include "ValidationSchema.h" +#include "QueryObject.h" +#include "MutationObject.h" +#include "SubscriptionObject.h" + namespace graphql::validation { class Query diff --git a/samples/validation/schema/AlienObject.cpp b/samples/validation/schema/AlienObject.cpp new file mode 100644 index 00000000..21be21f3 --- /dev/null +++ b/samples/validation/schema/AlienObject.cpp @@ -0,0 +1,93 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// WARNING! Do not edit this file manually, your changes will be overwritten. + +#include "AlienObject.h" + +#include "graphqlservice/introspection/Introspection.h" + +#include +#include +#include +#include +#include + +using namespace std::literals; + +namespace graphql::validation { +namespace object { + +Alien::Alien(std::unique_ptr&& pimpl) noexcept + : service::Object{ getTypeNames(), getResolvers() } + , _pimpl { std::move(pimpl) } +{ +} + +service::TypeNames Alien::getTypeNames() const noexcept +{ + return { + R"gql(Sentient)gql"sv, + R"gql(HumanOrAlien)gql"sv, + R"gql(Alien)gql"sv + }; +} + +service::ResolverMap Alien::getResolvers() const noexcept +{ + return { + { R"gql(name)gql"sv, [this](service::ResolverParams&& params) { return resolveName(std::move(params)); } }, + { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, + { R"gql(homePlanet)gql"sv, [this](service::ResolverParams&& params) { return resolveHomePlanet(std::move(params)); } } + }; +} + +void Alien::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void Alien::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} + +service::AwaitableResolver Alien::resolveName(service::ResolverParams&& params) const +{ + std::unique_lock resolverLock(_resolverMutex); + auto directives = std::move(params.fieldDirectives); + auto result = _pimpl->getName(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + resolverLock.unlock(); + + return service::ModifiedResult::convert(std::move(result), std::move(params)); +} + +service::AwaitableResolver Alien::resolveHomePlanet(service::ResolverParams&& params) const +{ + std::unique_lock resolverLock(_resolverMutex); + auto directives = std::move(params.fieldDirectives); + auto result = _pimpl->getHomePlanet(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + resolverLock.unlock(); + + return service::ModifiedResult::convert(std::move(result), std::move(params)); +} + +service::AwaitableResolver Alien::resolve_typename(service::ResolverParams&& params) const +{ + return service::ModifiedResult::convert(std::string{ R"gql(Alien)gql" }, std::move(params)); +} + +} // namespace object + +void AddAlienDetails(const std::shared_ptr& typeAlien, const std::shared_ptr& schema) +{ + typeAlien->AddInterfaces({ + std::static_pointer_cast(schema->LookupType(R"gql(Sentient)gql"sv)) + }); + typeAlien->AddFields({ + schema::Field::Make(R"gql(name)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(String)gql"sv))), + schema::Field::Make(R"gql(homePlanet)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(String)gql"sv)) + }); +} + +} // namespace graphql::validation diff --git a/samples/validation/schema/AlienObject.h b/samples/validation/schema/AlienObject.h new file mode 100644 index 00000000..3b46405e --- /dev/null +++ b/samples/validation/schema/AlienObject.h @@ -0,0 +1,174 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// WARNING! Do not edit this file manually, your changes will be overwritten. + +#pragma once + +#ifndef ALIENOBJECT_H +#define ALIENOBJECT_H + +#include "ValidationSchema.h" + +namespace graphql::validation::object { +namespace implements { + +template +concept AlienIs = std::is_same_v || std::is_same_v; + +} // namespace implements + +namespace methods::AlienHas { + +template +concept getNameWithParams = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult { impl.getName(std::move(params)) } }; +}; + +template +concept getName = requires (TImpl impl) +{ + { service::FieldResult { impl.getName() } }; +}; + +template +concept getHomePlanetWithParams = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult> { impl.getHomePlanet(std::move(params)) } }; +}; + +template +concept getHomePlanet = requires (TImpl impl) +{ + { service::FieldResult> { impl.getHomePlanet() } }; +}; + +template +concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.beginSelectionSet(params) }; +}; + +template +concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.endSelectionSet(params) }; +}; + +} // namespace methods::AlienHas + +class Alien + : public service::Object +{ +private: + service::AwaitableResolver resolveName(service::ResolverParams&& params) const; + service::AwaitableResolver resolveHomePlanet(service::ResolverParams&& params) const; + + service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; + + struct Concept + { + virtual ~Concept() = default; + + virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + + virtual service::FieldResult getName(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getHomePlanet(service::FieldParams&& params) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::FieldResult getName(service::FieldParams&& params) const final + { + if constexpr (methods::AlienHas::getNameWithParams) + { + return { _pimpl->getName(std::move(params)) }; + } + else if constexpr (methods::AlienHas::getName) + { + return { _pimpl->getName() }; + } + else + { + throw std::runtime_error(R"ex(Alien::getName is not implemented)ex"); + } + } + + service::FieldResult> getHomePlanet(service::FieldParams&& params) const final + { + if constexpr (methods::AlienHas::getHomePlanetWithParams) + { + return { _pimpl->getHomePlanet(std::move(params)) }; + } + else if constexpr (methods::AlienHas::getHomePlanet) + { + return { _pimpl->getHomePlanet() }; + } + else + { + throw std::runtime_error(R"ex(Alien::getHomePlanet is not implemented)ex"); + } + } + + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::AlienHas::beginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::AlienHas::endSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + + private: + const std::shared_ptr _pimpl; + }; + + Alien(std::unique_ptr&& pimpl) noexcept; + + // Interfaces which this type implements + friend Sentient; + + // Unions which include this type + friend HumanOrAlien; + + template + static constexpr bool implements() noexcept + { + return implements::AlienIs; + } + + service::TypeNames getTypeNames() const noexcept; + service::ResolverMap getResolvers() const noexcept; + + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; + + const std::unique_ptr _pimpl; + +public: + template + Alien(std::shared_ptr pimpl) noexcept + : Alien { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } + { + } +}; + +} // namespace graphql::validation::object + +#endif // ALIENOBJECT_H diff --git a/samples/validation/schema/ArgumentsObject.cpp b/samples/validation/schema/ArgumentsObject.cpp new file mode 100644 index 00000000..08828077 --- /dev/null +++ b/samples/validation/schema/ArgumentsObject.cpp @@ -0,0 +1,200 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// WARNING! Do not edit this file manually, your changes will be overwritten. + +#include "ArgumentsObject.h" + +#include "graphqlservice/introspection/Introspection.h" + +#include +#include +#include +#include +#include + +using namespace std::literals; + +namespace graphql::validation { +namespace object { + +Arguments::Arguments(std::unique_ptr&& pimpl) noexcept + : service::Object{ getTypeNames(), getResolvers() } + , _pimpl { std::move(pimpl) } +{ +} + +service::TypeNames Arguments::getTypeNames() const noexcept +{ + return { + R"gql(Arguments)gql"sv + }; +} + +service::ResolverMap Arguments::getResolvers() const noexcept +{ + return { + { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, + { R"gql(intArgField)gql"sv, [this](service::ResolverParams&& params) { return resolveIntArgField(std::move(params)); } }, + { R"gql(multipleReqs)gql"sv, [this](service::ResolverParams&& params) { return resolveMultipleReqs(std::move(params)); } }, + { R"gql(floatArgField)gql"sv, [this](service::ResolverParams&& params) { return resolveFloatArgField(std::move(params)); } }, + { R"gql(booleanArgField)gql"sv, [this](service::ResolverParams&& params) { return resolveBooleanArgField(std::move(params)); } }, + { R"gql(booleanListArgField)gql"sv, [this](service::ResolverParams&& params) { return resolveBooleanListArgField(std::move(params)); } }, + { R"gql(nonNullBooleanArgField)gql"sv, [this](service::ResolverParams&& params) { return resolveNonNullBooleanArgField(std::move(params)); } }, + { R"gql(nonNullBooleanListField)gql"sv, [this](service::ResolverParams&& params) { return resolveNonNullBooleanListField(std::move(params)); } }, + { R"gql(optionalNonNullBooleanArgField)gql"sv, [this](service::ResolverParams&& params) { return resolveOptionalNonNullBooleanArgField(std::move(params)); } } + }; +} + +void Arguments::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void Arguments::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} + +service::AwaitableResolver Arguments::resolveMultipleReqs(service::ResolverParams&& params) const +{ + auto argX = service::ModifiedArgument::require("x", params.arguments); + auto argY = service::ModifiedArgument::require("y", params.arguments); + std::unique_lock resolverLock(_resolverMutex); + auto directives = std::move(params.fieldDirectives); + auto result = _pimpl->getMultipleReqs(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argX), std::move(argY)); + resolverLock.unlock(); + + return service::ModifiedResult::convert(std::move(result), std::move(params)); +} + +service::AwaitableResolver Arguments::resolveBooleanArgField(service::ResolverParams&& params) const +{ + auto argBooleanArg = service::ModifiedArgument::require("booleanArg", params.arguments); + std::unique_lock resolverLock(_resolverMutex); + auto directives = std::move(params.fieldDirectives); + auto result = _pimpl->getBooleanArgField(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argBooleanArg)); + resolverLock.unlock(); + + return service::ModifiedResult::convert(std::move(result), std::move(params)); +} + +service::AwaitableResolver Arguments::resolveFloatArgField(service::ResolverParams&& params) const +{ + auto argFloatArg = service::ModifiedArgument::require("floatArg", params.arguments); + std::unique_lock resolverLock(_resolverMutex); + auto directives = std::move(params.fieldDirectives); + auto result = _pimpl->getFloatArgField(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argFloatArg)); + resolverLock.unlock(); + + return service::ModifiedResult::convert(std::move(result), std::move(params)); +} + +service::AwaitableResolver Arguments::resolveIntArgField(service::ResolverParams&& params) const +{ + auto argIntArg = service::ModifiedArgument::require("intArg", params.arguments); + std::unique_lock resolverLock(_resolverMutex); + auto directives = std::move(params.fieldDirectives); + auto result = _pimpl->getIntArgField(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argIntArg)); + resolverLock.unlock(); + + return service::ModifiedResult::convert(std::move(result), std::move(params)); +} + +service::AwaitableResolver Arguments::resolveNonNullBooleanArgField(service::ResolverParams&& params) const +{ + auto argNonNullBooleanArg = service::ModifiedArgument::require("nonNullBooleanArg", params.arguments); + std::unique_lock resolverLock(_resolverMutex); + auto directives = std::move(params.fieldDirectives); + auto result = _pimpl->getNonNullBooleanArgField(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argNonNullBooleanArg)); + resolverLock.unlock(); + + return service::ModifiedResult::convert(std::move(result), std::move(params)); +} + +service::AwaitableResolver Arguments::resolveNonNullBooleanListField(service::ResolverParams&& params) const +{ + auto argNonNullBooleanListArg = service::ModifiedArgument::require("nonNullBooleanListArg", params.arguments); + std::unique_lock resolverLock(_resolverMutex); + auto directives = std::move(params.fieldDirectives); + auto result = _pimpl->getNonNullBooleanListField(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argNonNullBooleanListArg)); + resolverLock.unlock(); + + return service::ModifiedResult::convert(std::move(result), std::move(params)); +} + +service::AwaitableResolver Arguments::resolveBooleanListArgField(service::ResolverParams&& params) const +{ + auto argBooleanListArg = service::ModifiedArgument::require("booleanListArg", params.arguments); + std::unique_lock resolverLock(_resolverMutex); + auto directives = std::move(params.fieldDirectives); + auto result = _pimpl->getBooleanListArgField(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argBooleanListArg)); + resolverLock.unlock(); + + return service::ModifiedResult::convert(std::move(result), std::move(params)); +} + +service::AwaitableResolver Arguments::resolveOptionalNonNullBooleanArgField(service::ResolverParams&& params) const +{ + const auto defaultArguments = []() + { + response::Value values(response::Type::Map); + response::Value entry; + + entry = response::Value(false); + values.emplace_back("optionalBooleanArg", std::move(entry)); + + return values; + }(); + + auto pairOptionalBooleanArg = service::ModifiedArgument::find("optionalBooleanArg", params.arguments); + auto argOptionalBooleanArg = (pairOptionalBooleanArg.second + ? std::move(pairOptionalBooleanArg.first) + : service::ModifiedArgument::require("optionalBooleanArg", defaultArguments)); + std::unique_lock resolverLock(_resolverMutex); + auto directives = std::move(params.fieldDirectives); + auto result = _pimpl->getOptionalNonNullBooleanArgField(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argOptionalBooleanArg)); + resolverLock.unlock(); + + return service::ModifiedResult::convert(std::move(result), std::move(params)); +} + +service::AwaitableResolver Arguments::resolve_typename(service::ResolverParams&& params) const +{ + return service::ModifiedResult::convert(std::string{ R"gql(Arguments)gql" }, std::move(params)); +} + +} // namespace object + +void AddArgumentsDetails(const std::shared_ptr& typeArguments, const std::shared_ptr& schema) +{ + typeArguments->AddFields({ + schema::Field::Make(R"gql(multipleReqs)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Int)gql"sv)), { + schema::InputValue::Make(R"gql(x)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Int)gql"sv)), R"gql()gql"sv), + schema::InputValue::Make(R"gql(y)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Int)gql"sv)), R"gql()gql"sv) + }), + schema::Field::Make(R"gql(booleanArgField)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(Boolean)gql"sv), { + schema::InputValue::Make(R"gql(booleanArg)gql"sv, R"md()md"sv, schema->LookupType(R"gql(Boolean)gql"sv), R"gql()gql"sv) + }), + schema::Field::Make(R"gql(floatArgField)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(Float)gql"sv), { + schema::InputValue::Make(R"gql(floatArg)gql"sv, R"md()md"sv, schema->LookupType(R"gql(Float)gql"sv), R"gql()gql"sv) + }), + schema::Field::Make(R"gql(intArgField)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(Int)gql"sv), { + schema::InputValue::Make(R"gql(intArg)gql"sv, R"md()md"sv, schema->LookupType(R"gql(Int)gql"sv), R"gql()gql"sv) + }), + schema::Field::Make(R"gql(nonNullBooleanArgField)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Boolean)gql"sv)), { + schema::InputValue::Make(R"gql(nonNullBooleanArg)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Boolean)gql"sv)), R"gql()gql"sv) + }), + schema::Field::Make(R"gql(nonNullBooleanListField)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Boolean)gql"sv))), { + schema::InputValue::Make(R"gql(nonNullBooleanListArg)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Boolean)gql"sv))), R"gql()gql"sv) + }), + schema::Field::Make(R"gql(booleanListArgField)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::LIST, schema->LookupType(R"gql(Boolean)gql"sv)), { + schema::InputValue::Make(R"gql(booleanListArg)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->LookupType(R"gql(Boolean)gql"sv))), R"gql()gql"sv) + }), + schema::Field::Make(R"gql(optionalNonNullBooleanArgField)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Boolean)gql"sv)), { + schema::InputValue::Make(R"gql(optionalBooleanArg)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Boolean)gql"sv)), R"gql(false)gql"sv) + }) + }); +} + +} // namespace graphql::validation diff --git a/samples/validation/schema/ArgumentsObject.h b/samples/validation/schema/ArgumentsObject.h new file mode 100644 index 00000000..3e719ab8 --- /dev/null +++ b/samples/validation/schema/ArgumentsObject.h @@ -0,0 +1,335 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// WARNING! Do not edit this file manually, your changes will be overwritten. + +#pragma once + +#ifndef ARGUMENTSOBJECT_H +#define ARGUMENTSOBJECT_H + +#include "ValidationSchema.h" + +namespace graphql::validation::object { +namespace methods::ArgumentsHas { + +template +concept getMultipleReqsWithParams = requires (TImpl impl, service::FieldParams params, int xArg, int yArg) +{ + { service::FieldResult { impl.getMultipleReqs(std::move(params), std::move(xArg), std::move(yArg)) } }; +}; + +template +concept getMultipleReqs = requires (TImpl impl, int xArg, int yArg) +{ + { service::FieldResult { impl.getMultipleReqs(std::move(xArg), std::move(yArg)) } }; +}; + +template +concept getBooleanArgFieldWithParams = requires (TImpl impl, service::FieldParams params, std::optional booleanArgArg) +{ + { service::FieldResult> { impl.getBooleanArgField(std::move(params), std::move(booleanArgArg)) } }; +}; + +template +concept getBooleanArgField = requires (TImpl impl, std::optional booleanArgArg) +{ + { service::FieldResult> { impl.getBooleanArgField(std::move(booleanArgArg)) } }; +}; + +template +concept getFloatArgFieldWithParams = requires (TImpl impl, service::FieldParams params, std::optional floatArgArg) +{ + { service::FieldResult> { impl.getFloatArgField(std::move(params), std::move(floatArgArg)) } }; +}; + +template +concept getFloatArgField = requires (TImpl impl, std::optional floatArgArg) +{ + { service::FieldResult> { impl.getFloatArgField(std::move(floatArgArg)) } }; +}; + +template +concept getIntArgFieldWithParams = requires (TImpl impl, service::FieldParams params, std::optional intArgArg) +{ + { service::FieldResult> { impl.getIntArgField(std::move(params), std::move(intArgArg)) } }; +}; + +template +concept getIntArgField = requires (TImpl impl, std::optional intArgArg) +{ + { service::FieldResult> { impl.getIntArgField(std::move(intArgArg)) } }; +}; + +template +concept getNonNullBooleanArgFieldWithParams = requires (TImpl impl, service::FieldParams params, bool nonNullBooleanArgArg) +{ + { service::FieldResult { impl.getNonNullBooleanArgField(std::move(params), std::move(nonNullBooleanArgArg)) } }; +}; + +template +concept getNonNullBooleanArgField = requires (TImpl impl, bool nonNullBooleanArgArg) +{ + { service::FieldResult { impl.getNonNullBooleanArgField(std::move(nonNullBooleanArgArg)) } }; +}; + +template +concept getNonNullBooleanListFieldWithParams = requires (TImpl impl, service::FieldParams params, std::optional> nonNullBooleanListArgArg) +{ + { service::FieldResult>> { impl.getNonNullBooleanListField(std::move(params), std::move(nonNullBooleanListArgArg)) } }; +}; + +template +concept getNonNullBooleanListField = requires (TImpl impl, std::optional> nonNullBooleanListArgArg) +{ + { service::FieldResult>> { impl.getNonNullBooleanListField(std::move(nonNullBooleanListArgArg)) } }; +}; + +template +concept getBooleanListArgFieldWithParams = requires (TImpl impl, service::FieldParams params, std::vector> booleanListArgArg) +{ + { service::FieldResult>>> { impl.getBooleanListArgField(std::move(params), std::move(booleanListArgArg)) } }; +}; + +template +concept getBooleanListArgField = requires (TImpl impl, std::vector> booleanListArgArg) +{ + { service::FieldResult>>> { impl.getBooleanListArgField(std::move(booleanListArgArg)) } }; +}; + +template +concept getOptionalNonNullBooleanArgFieldWithParams = requires (TImpl impl, service::FieldParams params, bool optionalBooleanArgArg) +{ + { service::FieldResult { impl.getOptionalNonNullBooleanArgField(std::move(params), std::move(optionalBooleanArgArg)) } }; +}; + +template +concept getOptionalNonNullBooleanArgField = requires (TImpl impl, bool optionalBooleanArgArg) +{ + { service::FieldResult { impl.getOptionalNonNullBooleanArgField(std::move(optionalBooleanArgArg)) } }; +}; + +template +concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.beginSelectionSet(params) }; +}; + +template +concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.endSelectionSet(params) }; +}; + +} // namespace methods::ArgumentsHas + +class Arguments + : public service::Object +{ +private: + service::AwaitableResolver resolveMultipleReqs(service::ResolverParams&& params) const; + service::AwaitableResolver resolveBooleanArgField(service::ResolverParams&& params) const; + service::AwaitableResolver resolveFloatArgField(service::ResolverParams&& params) const; + service::AwaitableResolver resolveIntArgField(service::ResolverParams&& params) const; + service::AwaitableResolver resolveNonNullBooleanArgField(service::ResolverParams&& params) const; + service::AwaitableResolver resolveNonNullBooleanListField(service::ResolverParams&& params) const; + service::AwaitableResolver resolveBooleanListArgField(service::ResolverParams&& params) const; + service::AwaitableResolver resolveOptionalNonNullBooleanArgField(service::ResolverParams&& params) const; + + service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; + + struct Concept + { + virtual ~Concept() = default; + + virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + + virtual service::FieldResult getMultipleReqs(service::FieldParams&& params, int&& xArg, int&& yArg) const = 0; + virtual service::FieldResult> getBooleanArgField(service::FieldParams&& params, std::optional&& booleanArgArg) const = 0; + virtual service::FieldResult> getFloatArgField(service::FieldParams&& params, std::optional&& floatArgArg) const = 0; + virtual service::FieldResult> getIntArgField(service::FieldParams&& params, std::optional&& intArgArg) const = 0; + virtual service::FieldResult getNonNullBooleanArgField(service::FieldParams&& params, bool&& nonNullBooleanArgArg) const = 0; + virtual service::FieldResult>> getNonNullBooleanListField(service::FieldParams&& params, std::optional>&& nonNullBooleanListArgArg) const = 0; + virtual service::FieldResult>>> getBooleanListArgField(service::FieldParams&& params, std::vector>&& booleanListArgArg) const = 0; + virtual service::FieldResult getOptionalNonNullBooleanArgField(service::FieldParams&& params, bool&& optionalBooleanArgArg) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::FieldResult getMultipleReqs(service::FieldParams&& params, int&& xArg, int&& yArg) const final + { + if constexpr (methods::ArgumentsHas::getMultipleReqsWithParams) + { + return { _pimpl->getMultipleReqs(std::move(params), std::move(xArg), std::move(yArg)) }; + } + else if constexpr (methods::ArgumentsHas::getMultipleReqs) + { + return { _pimpl->getMultipleReqs(std::move(xArg), std::move(yArg)) }; + } + else + { + throw std::runtime_error(R"ex(Arguments::getMultipleReqs is not implemented)ex"); + } + } + + service::FieldResult> getBooleanArgField(service::FieldParams&& params, std::optional&& booleanArgArg) const final + { + if constexpr (methods::ArgumentsHas::getBooleanArgFieldWithParams) + { + return { _pimpl->getBooleanArgField(std::move(params), std::move(booleanArgArg)) }; + } + else if constexpr (methods::ArgumentsHas::getBooleanArgField) + { + return { _pimpl->getBooleanArgField(std::move(booleanArgArg)) }; + } + else + { + throw std::runtime_error(R"ex(Arguments::getBooleanArgField is not implemented)ex"); + } + } + + service::FieldResult> getFloatArgField(service::FieldParams&& params, std::optional&& floatArgArg) const final + { + if constexpr (methods::ArgumentsHas::getFloatArgFieldWithParams) + { + return { _pimpl->getFloatArgField(std::move(params), std::move(floatArgArg)) }; + } + else if constexpr (methods::ArgumentsHas::getFloatArgField) + { + return { _pimpl->getFloatArgField(std::move(floatArgArg)) }; + } + else + { + throw std::runtime_error(R"ex(Arguments::getFloatArgField is not implemented)ex"); + } + } + + service::FieldResult> getIntArgField(service::FieldParams&& params, std::optional&& intArgArg) const final + { + if constexpr (methods::ArgumentsHas::getIntArgFieldWithParams) + { + return { _pimpl->getIntArgField(std::move(params), std::move(intArgArg)) }; + } + else if constexpr (methods::ArgumentsHas::getIntArgField) + { + return { _pimpl->getIntArgField(std::move(intArgArg)) }; + } + else + { + throw std::runtime_error(R"ex(Arguments::getIntArgField is not implemented)ex"); + } + } + + service::FieldResult getNonNullBooleanArgField(service::FieldParams&& params, bool&& nonNullBooleanArgArg) const final + { + if constexpr (methods::ArgumentsHas::getNonNullBooleanArgFieldWithParams) + { + return { _pimpl->getNonNullBooleanArgField(std::move(params), std::move(nonNullBooleanArgArg)) }; + } + else if constexpr (methods::ArgumentsHas::getNonNullBooleanArgField) + { + return { _pimpl->getNonNullBooleanArgField(std::move(nonNullBooleanArgArg)) }; + } + else + { + throw std::runtime_error(R"ex(Arguments::getNonNullBooleanArgField is not implemented)ex"); + } + } + + service::FieldResult>> getNonNullBooleanListField(service::FieldParams&& params, std::optional>&& nonNullBooleanListArgArg) const final + { + if constexpr (methods::ArgumentsHas::getNonNullBooleanListFieldWithParams) + { + return { _pimpl->getNonNullBooleanListField(std::move(params), std::move(nonNullBooleanListArgArg)) }; + } + else if constexpr (methods::ArgumentsHas::getNonNullBooleanListField) + { + return { _pimpl->getNonNullBooleanListField(std::move(nonNullBooleanListArgArg)) }; + } + else + { + throw std::runtime_error(R"ex(Arguments::getNonNullBooleanListField is not implemented)ex"); + } + } + + service::FieldResult>>> getBooleanListArgField(service::FieldParams&& params, std::vector>&& booleanListArgArg) const final + { + if constexpr (methods::ArgumentsHas::getBooleanListArgFieldWithParams) + { + return { _pimpl->getBooleanListArgField(std::move(params), std::move(booleanListArgArg)) }; + } + else if constexpr (methods::ArgumentsHas::getBooleanListArgField) + { + return { _pimpl->getBooleanListArgField(std::move(booleanListArgArg)) }; + } + else + { + throw std::runtime_error(R"ex(Arguments::getBooleanListArgField is not implemented)ex"); + } + } + + service::FieldResult getOptionalNonNullBooleanArgField(service::FieldParams&& params, bool&& optionalBooleanArgArg) const final + { + if constexpr (methods::ArgumentsHas::getOptionalNonNullBooleanArgFieldWithParams) + { + return { _pimpl->getOptionalNonNullBooleanArgField(std::move(params), std::move(optionalBooleanArgArg)) }; + } + else if constexpr (methods::ArgumentsHas::getOptionalNonNullBooleanArgField) + { + return { _pimpl->getOptionalNonNullBooleanArgField(std::move(optionalBooleanArgArg)) }; + } + else + { + throw std::runtime_error(R"ex(Arguments::getOptionalNonNullBooleanArgField is not implemented)ex"); + } + } + + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::ArgumentsHas::beginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::ArgumentsHas::endSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + + private: + const std::shared_ptr _pimpl; + }; + + Arguments(std::unique_ptr&& pimpl) noexcept; + + service::TypeNames getTypeNames() const noexcept; + service::ResolverMap getResolvers() const noexcept; + + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; + + const std::unique_ptr _pimpl; + +public: + template + Arguments(std::shared_ptr pimpl) noexcept + : Arguments { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } + { + } +}; + +} // namespace graphql::validation::object + +#endif // ARGUMENTSOBJECT_H diff --git a/samples/validation/schema/CMakeLists.txt b/samples/validation/schema/CMakeLists.txt index 1aad121c..739d675e 100644 --- a/samples/validation/schema/CMakeLists.txt +++ b/samples/validation/schema/CMakeLists.txt @@ -7,7 +7,7 @@ cmake_minimum_required(VERSION 3.15) include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/cppgraphqlgen-functions.cmake) if(GRAPHQL_UPDATE_SAMPLES) - update_graphql_schema_files(validation schema.validation.graphql Validation validation --stubs --merge-files --no-introspection) + update_graphql_schema_files(validation schema.validation.graphql Validation validation --stubs --no-introspection) endif() add_graphql_schema_no_introspection_target(validation) diff --git a/samples/validation/schema/CatObject.cpp b/samples/validation/schema/CatObject.cpp new file mode 100644 index 00000000..62d3a270 --- /dev/null +++ b/samples/validation/schema/CatObject.cpp @@ -0,0 +1,120 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// WARNING! Do not edit this file manually, your changes will be overwritten. + +#include "CatObject.h" + +#include "graphqlservice/introspection/Introspection.h" + +#include +#include +#include +#include +#include + +using namespace std::literals; + +namespace graphql::validation { +namespace object { + +Cat::Cat(std::unique_ptr&& pimpl) noexcept + : service::Object{ getTypeNames(), getResolvers() } + , _pimpl { std::move(pimpl) } +{ +} + +service::TypeNames Cat::getTypeNames() const noexcept +{ + return { + R"gql(Pet)gql"sv, + R"gql(CatOrDog)gql"sv, + R"gql(Cat)gql"sv + }; +} + +service::ResolverMap Cat::getResolvers() const noexcept +{ + return { + { R"gql(name)gql"sv, [this](service::ResolverParams&& params) { return resolveName(std::move(params)); } }, + { R"gql(nickname)gql"sv, [this](service::ResolverParams&& params) { return resolveNickname(std::move(params)); } }, + { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, + { R"gql(meowVolume)gql"sv, [this](service::ResolverParams&& params) { return resolveMeowVolume(std::move(params)); } }, + { R"gql(doesKnowCommand)gql"sv, [this](service::ResolverParams&& params) { return resolveDoesKnowCommand(std::move(params)); } } + }; +} + +void Cat::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void Cat::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} + +service::AwaitableResolver Cat::resolveName(service::ResolverParams&& params) const +{ + std::unique_lock resolverLock(_resolverMutex); + auto directives = std::move(params.fieldDirectives); + auto result = _pimpl->getName(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + resolverLock.unlock(); + + return service::ModifiedResult::convert(std::move(result), std::move(params)); +} + +service::AwaitableResolver Cat::resolveNickname(service::ResolverParams&& params) const +{ + std::unique_lock resolverLock(_resolverMutex); + auto directives = std::move(params.fieldDirectives); + auto result = _pimpl->getNickname(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + resolverLock.unlock(); + + return service::ModifiedResult::convert(std::move(result), std::move(params)); +} + +service::AwaitableResolver Cat::resolveDoesKnowCommand(service::ResolverParams&& params) const +{ + auto argCatCommand = service::ModifiedArgument::require("catCommand", params.arguments); + std::unique_lock resolverLock(_resolverMutex); + auto directives = std::move(params.fieldDirectives); + auto result = _pimpl->getDoesKnowCommand(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argCatCommand)); + resolverLock.unlock(); + + return service::ModifiedResult::convert(std::move(result), std::move(params)); +} + +service::AwaitableResolver Cat::resolveMeowVolume(service::ResolverParams&& params) const +{ + std::unique_lock resolverLock(_resolverMutex); + auto directives = std::move(params.fieldDirectives); + auto result = _pimpl->getMeowVolume(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + resolverLock.unlock(); + + return service::ModifiedResult::convert(std::move(result), std::move(params)); +} + +service::AwaitableResolver Cat::resolve_typename(service::ResolverParams&& params) const +{ + return service::ModifiedResult::convert(std::string{ R"gql(Cat)gql" }, std::move(params)); +} + +} // namespace object + +void AddCatDetails(const std::shared_ptr& typeCat, const std::shared_ptr& schema) +{ + typeCat->AddInterfaces({ + std::static_pointer_cast(schema->LookupType(R"gql(Pet)gql"sv)) + }); + typeCat->AddFields({ + schema::Field::Make(R"gql(name)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(String)gql"sv))), + schema::Field::Make(R"gql(nickname)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(String)gql"sv)), + schema::Field::Make(R"gql(doesKnowCommand)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Boolean)gql"sv)), { + schema::InputValue::Make(R"gql(catCommand)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(CatCommand)gql"sv)), R"gql()gql"sv) + }), + schema::Field::Make(R"gql(meowVolume)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(Int)gql"sv)) + }); +} + +} // namespace graphql::validation diff --git a/samples/validation/schema/CatObject.h b/samples/validation/schema/CatObject.h new file mode 100644 index 00000000..857b9363 --- /dev/null +++ b/samples/validation/schema/CatObject.h @@ -0,0 +1,234 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// WARNING! Do not edit this file manually, your changes will be overwritten. + +#pragma once + +#ifndef CATOBJECT_H +#define CATOBJECT_H + +#include "ValidationSchema.h" + +namespace graphql::validation::object { +namespace implements { + +template +concept CatIs = std::is_same_v || std::is_same_v; + +} // namespace implements + +namespace methods::CatHas { + +template +concept getNameWithParams = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult { impl.getName(std::move(params)) } }; +}; + +template +concept getName = requires (TImpl impl) +{ + { service::FieldResult { impl.getName() } }; +}; + +template +concept getNicknameWithParams = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult> { impl.getNickname(std::move(params)) } }; +}; + +template +concept getNickname = requires (TImpl impl) +{ + { service::FieldResult> { impl.getNickname() } }; +}; + +template +concept getDoesKnowCommandWithParams = requires (TImpl impl, service::FieldParams params, CatCommand catCommandArg) +{ + { service::FieldResult { impl.getDoesKnowCommand(std::move(params), std::move(catCommandArg)) } }; +}; + +template +concept getDoesKnowCommand = requires (TImpl impl, CatCommand catCommandArg) +{ + { service::FieldResult { impl.getDoesKnowCommand(std::move(catCommandArg)) } }; +}; + +template +concept getMeowVolumeWithParams = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult> { impl.getMeowVolume(std::move(params)) } }; +}; + +template +concept getMeowVolume = requires (TImpl impl) +{ + { service::FieldResult> { impl.getMeowVolume() } }; +}; + +template +concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.beginSelectionSet(params) }; +}; + +template +concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.endSelectionSet(params) }; +}; + +} // namespace methods::CatHas + +class Cat + : public service::Object +{ +private: + service::AwaitableResolver resolveName(service::ResolverParams&& params) const; + service::AwaitableResolver resolveNickname(service::ResolverParams&& params) const; + service::AwaitableResolver resolveDoesKnowCommand(service::ResolverParams&& params) const; + service::AwaitableResolver resolveMeowVolume(service::ResolverParams&& params) const; + + service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; + + struct Concept + { + virtual ~Concept() = default; + + virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + + virtual service::FieldResult getName(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getNickname(service::FieldParams&& params) const = 0; + virtual service::FieldResult getDoesKnowCommand(service::FieldParams&& params, CatCommand&& catCommandArg) const = 0; + virtual service::FieldResult> getMeowVolume(service::FieldParams&& params) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::FieldResult getName(service::FieldParams&& params) const final + { + if constexpr (methods::CatHas::getNameWithParams) + { + return { _pimpl->getName(std::move(params)) }; + } + else if constexpr (methods::CatHas::getName) + { + return { _pimpl->getName() }; + } + else + { + throw std::runtime_error(R"ex(Cat::getName is not implemented)ex"); + } + } + + service::FieldResult> getNickname(service::FieldParams&& params) const final + { + if constexpr (methods::CatHas::getNicknameWithParams) + { + return { _pimpl->getNickname(std::move(params)) }; + } + else if constexpr (methods::CatHas::getNickname) + { + return { _pimpl->getNickname() }; + } + else + { + throw std::runtime_error(R"ex(Cat::getNickname is not implemented)ex"); + } + } + + service::FieldResult getDoesKnowCommand(service::FieldParams&& params, CatCommand&& catCommandArg) const final + { + if constexpr (methods::CatHas::getDoesKnowCommandWithParams) + { + return { _pimpl->getDoesKnowCommand(std::move(params), std::move(catCommandArg)) }; + } + else if constexpr (methods::CatHas::getDoesKnowCommand) + { + return { _pimpl->getDoesKnowCommand(std::move(catCommandArg)) }; + } + else + { + throw std::runtime_error(R"ex(Cat::getDoesKnowCommand is not implemented)ex"); + } + } + + service::FieldResult> getMeowVolume(service::FieldParams&& params) const final + { + if constexpr (methods::CatHas::getMeowVolumeWithParams) + { + return { _pimpl->getMeowVolume(std::move(params)) }; + } + else if constexpr (methods::CatHas::getMeowVolume) + { + return { _pimpl->getMeowVolume() }; + } + else + { + throw std::runtime_error(R"ex(Cat::getMeowVolume is not implemented)ex"); + } + } + + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::CatHas::beginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::CatHas::endSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + + private: + const std::shared_ptr _pimpl; + }; + + Cat(std::unique_ptr&& pimpl) noexcept; + + // Interfaces which this type implements + friend Pet; + + // Unions which include this type + friend CatOrDog; + + template + static constexpr bool implements() noexcept + { + return implements::CatIs; + } + + service::TypeNames getTypeNames() const noexcept; + service::ResolverMap getResolvers() const noexcept; + + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; + + const std::unique_ptr _pimpl; + +public: + template + Cat(std::shared_ptr pimpl) noexcept + : Cat { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } + { + } +}; + +} // namespace graphql::validation::object + +#endif // CATOBJECT_H diff --git a/samples/validation/schema/CatOrDogObject.cpp b/samples/validation/schema/CatOrDogObject.cpp new file mode 100644 index 00000000..a826efa7 --- /dev/null +++ b/samples/validation/schema/CatOrDogObject.cpp @@ -0,0 +1,41 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// WARNING! Do not edit this file manually, your changes will be overwritten. + +#include "CatOrDogObject.h" + +#include "graphqlservice/introspection/Introspection.h" + +using namespace std::literals; + +namespace graphql::validation { +namespace object { + +CatOrDog::CatOrDog(std::unique_ptr&& pimpl) noexcept + : service::Object { pimpl->getTypeNames(), pimpl->getResolvers() } + , _pimpl { std::move(pimpl) } +{ +} + +void CatOrDog::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void CatOrDog::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} + +} // namespace object + +void AddCatOrDogDetails(const std::shared_ptr& typeCatOrDog, const std::shared_ptr& schema) +{ + typeCatOrDog->AddPossibleTypes({ + schema->LookupType(R"gql(Cat)gql"sv), + schema->LookupType(R"gql(Dog)gql"sv) + }); +} + +} // namespace graphql::validation diff --git a/samples/validation/schema/CatOrDogObject.h b/samples/validation/schema/CatOrDogObject.h new file mode 100644 index 00000000..c6b43a7e --- /dev/null +++ b/samples/validation/schema/CatOrDogObject.h @@ -0,0 +1,81 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// WARNING! Do not edit this file manually, your changes will be overwritten. + +#pragma once + +#ifndef CATORDOGOBJECT_H +#define CATORDOGOBJECT_H + +#include "ValidationSchema.h" + +namespace graphql::validation::object { + +class CatOrDog + : public service::Object +{ +private: + struct Concept + { + virtual ~Concept() = default; + + virtual service::TypeNames getTypeNames() const noexcept = 0; + virtual service::ResolverMap getResolvers() const noexcept = 0; + + virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::TypeNames getTypeNames() const noexcept final + { + return _pimpl->getTypeNames(); + } + + service::ResolverMap getResolvers() const noexcept final + { + return _pimpl->getResolvers(); + } + + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + _pimpl->beginSelectionSet(params); + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + _pimpl->endSelectionSet(params); + } + + private: + const std::shared_ptr _pimpl; + }; + + CatOrDog(std::unique_ptr&& pimpl) noexcept; + + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; + + const std::unique_ptr _pimpl; + +public: + template + CatOrDog(std::shared_ptr pimpl) noexcept + : CatOrDog { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } + { + static_assert(T::template implements(), "CatOrDog is not implemented"); + } +}; + +} // namespace graphql::validation::object + +#endif // CATORDOGOBJECT_H diff --git a/samples/validation/schema/DogObject.cpp b/samples/validation/schema/DogObject.cpp new file mode 100644 index 00000000..8ff7c70d --- /dev/null +++ b/samples/validation/schema/DogObject.cpp @@ -0,0 +1,149 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// WARNING! Do not edit this file manually, your changes will be overwritten. + +#include "DogObject.h" +#include "HumanObject.h" + +#include "graphqlservice/introspection/Introspection.h" + +#include +#include +#include +#include +#include + +using namespace std::literals; + +namespace graphql::validation { +namespace object { + +Dog::Dog(std::unique_ptr&& pimpl) noexcept + : service::Object{ getTypeNames(), getResolvers() } + , _pimpl { std::move(pimpl) } +{ +} + +service::TypeNames Dog::getTypeNames() const noexcept +{ + return { + R"gql(Pet)gql"sv, + R"gql(CatOrDog)gql"sv, + R"gql(DogOrHuman)gql"sv, + R"gql(Dog)gql"sv + }; +} + +service::ResolverMap Dog::getResolvers() const noexcept +{ + return { + { R"gql(name)gql"sv, [this](service::ResolverParams&& params) { return resolveName(std::move(params)); } }, + { R"gql(owner)gql"sv, [this](service::ResolverParams&& params) { return resolveOwner(std::move(params)); } }, + { R"gql(nickname)gql"sv, [this](service::ResolverParams&& params) { return resolveNickname(std::move(params)); } }, + { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, + { R"gql(barkVolume)gql"sv, [this](service::ResolverParams&& params) { return resolveBarkVolume(std::move(params)); } }, + { R"gql(isHousetrained)gql"sv, [this](service::ResolverParams&& params) { return resolveIsHousetrained(std::move(params)); } }, + { R"gql(doesKnowCommand)gql"sv, [this](service::ResolverParams&& params) { return resolveDoesKnowCommand(std::move(params)); } } + }; +} + +void Dog::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void Dog::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} + +service::AwaitableResolver Dog::resolveName(service::ResolverParams&& params) const +{ + std::unique_lock resolverLock(_resolverMutex); + auto directives = std::move(params.fieldDirectives); + auto result = _pimpl->getName(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + resolverLock.unlock(); + + return service::ModifiedResult::convert(std::move(result), std::move(params)); +} + +service::AwaitableResolver Dog::resolveNickname(service::ResolverParams&& params) const +{ + std::unique_lock resolverLock(_resolverMutex); + auto directives = std::move(params.fieldDirectives); + auto result = _pimpl->getNickname(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + resolverLock.unlock(); + + return service::ModifiedResult::convert(std::move(result), std::move(params)); +} + +service::AwaitableResolver Dog::resolveBarkVolume(service::ResolverParams&& params) const +{ + std::unique_lock resolverLock(_resolverMutex); + auto directives = std::move(params.fieldDirectives); + auto result = _pimpl->getBarkVolume(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + resolverLock.unlock(); + + return service::ModifiedResult::convert(std::move(result), std::move(params)); +} + +service::AwaitableResolver Dog::resolveDoesKnowCommand(service::ResolverParams&& params) const +{ + auto argDogCommand = service::ModifiedArgument::require("dogCommand", params.arguments); + std::unique_lock resolverLock(_resolverMutex); + auto directives = std::move(params.fieldDirectives); + auto result = _pimpl->getDoesKnowCommand(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argDogCommand)); + resolverLock.unlock(); + + return service::ModifiedResult::convert(std::move(result), std::move(params)); +} + +service::AwaitableResolver Dog::resolveIsHousetrained(service::ResolverParams&& params) const +{ + auto argAtOtherHomes = service::ModifiedArgument::require("atOtherHomes", params.arguments); + std::unique_lock resolverLock(_resolverMutex); + auto directives = std::move(params.fieldDirectives); + auto result = _pimpl->getIsHousetrained(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argAtOtherHomes)); + resolverLock.unlock(); + + return service::ModifiedResult::convert(std::move(result), std::move(params)); +} + +service::AwaitableResolver Dog::resolveOwner(service::ResolverParams&& params) const +{ + std::unique_lock resolverLock(_resolverMutex); + auto directives = std::move(params.fieldDirectives); + auto result = _pimpl->getOwner(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + resolverLock.unlock(); + + return service::ModifiedResult::convert(std::move(result), std::move(params)); +} + +service::AwaitableResolver Dog::resolve_typename(service::ResolverParams&& params) const +{ + return service::ModifiedResult::convert(std::string{ R"gql(Dog)gql" }, std::move(params)); +} + +} // namespace object + +void AddDogDetails(const std::shared_ptr& typeDog, const std::shared_ptr& schema) +{ + typeDog->AddInterfaces({ + std::static_pointer_cast(schema->LookupType(R"gql(Pet)gql"sv)) + }); + typeDog->AddFields({ + schema::Field::Make(R"gql(name)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(String)gql"sv))), + schema::Field::Make(R"gql(nickname)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(String)gql"sv)), + schema::Field::Make(R"gql(barkVolume)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(Int)gql"sv)), + schema::Field::Make(R"gql(doesKnowCommand)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Boolean)gql"sv)), { + schema::InputValue::Make(R"gql(dogCommand)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(DogCommand)gql"sv)), R"gql()gql"sv) + }), + schema::Field::Make(R"gql(isHousetrained)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Boolean)gql"sv)), { + schema::InputValue::Make(R"gql(atOtherHomes)gql"sv, R"md()md"sv, schema->LookupType(R"gql(Boolean)gql"sv), R"gql()gql"sv) + }), + schema::Field::Make(R"gql(owner)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(Human)gql"sv)) + }); +} + +} // namespace graphql::validation diff --git a/samples/validation/schema/DogObject.h b/samples/validation/schema/DogObject.h new file mode 100644 index 00000000..d50eba34 --- /dev/null +++ b/samples/validation/schema/DogObject.h @@ -0,0 +1,295 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// WARNING! Do not edit this file manually, your changes will be overwritten. + +#pragma once + +#ifndef DOGOBJECT_H +#define DOGOBJECT_H + +#include "ValidationSchema.h" + +namespace graphql::validation::object { +namespace implements { + +template +concept DogIs = std::is_same_v || std::is_same_v || std::is_same_v; + +} // namespace implements + +namespace methods::DogHas { + +template +concept getNameWithParams = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult { impl.getName(std::move(params)) } }; +}; + +template +concept getName = requires (TImpl impl) +{ + { service::FieldResult { impl.getName() } }; +}; + +template +concept getNicknameWithParams = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult> { impl.getNickname(std::move(params)) } }; +}; + +template +concept getNickname = requires (TImpl impl) +{ + { service::FieldResult> { impl.getNickname() } }; +}; + +template +concept getBarkVolumeWithParams = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult> { impl.getBarkVolume(std::move(params)) } }; +}; + +template +concept getBarkVolume = requires (TImpl impl) +{ + { service::FieldResult> { impl.getBarkVolume() } }; +}; + +template +concept getDoesKnowCommandWithParams = requires (TImpl impl, service::FieldParams params, DogCommand dogCommandArg) +{ + { service::FieldResult { impl.getDoesKnowCommand(std::move(params), std::move(dogCommandArg)) } }; +}; + +template +concept getDoesKnowCommand = requires (TImpl impl, DogCommand dogCommandArg) +{ + { service::FieldResult { impl.getDoesKnowCommand(std::move(dogCommandArg)) } }; +}; + +template +concept getIsHousetrainedWithParams = requires (TImpl impl, service::FieldParams params, std::optional atOtherHomesArg) +{ + { service::FieldResult { impl.getIsHousetrained(std::move(params), std::move(atOtherHomesArg)) } }; +}; + +template +concept getIsHousetrained = requires (TImpl impl, std::optional atOtherHomesArg) +{ + { service::FieldResult { impl.getIsHousetrained(std::move(atOtherHomesArg)) } }; +}; + +template +concept getOwnerWithParams = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult> { impl.getOwner(std::move(params)) } }; +}; + +template +concept getOwner = requires (TImpl impl) +{ + { service::FieldResult> { impl.getOwner() } }; +}; + +template +concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.beginSelectionSet(params) }; +}; + +template +concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.endSelectionSet(params) }; +}; + +} // namespace methods::DogHas + +class Dog + : public service::Object +{ +private: + service::AwaitableResolver resolveName(service::ResolverParams&& params) const; + service::AwaitableResolver resolveNickname(service::ResolverParams&& params) const; + service::AwaitableResolver resolveBarkVolume(service::ResolverParams&& params) const; + service::AwaitableResolver resolveDoesKnowCommand(service::ResolverParams&& params) const; + service::AwaitableResolver resolveIsHousetrained(service::ResolverParams&& params) const; + service::AwaitableResolver resolveOwner(service::ResolverParams&& params) const; + + service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; + + struct Concept + { + virtual ~Concept() = default; + + virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + + virtual service::FieldResult getName(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getNickname(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getBarkVolume(service::FieldParams&& params) const = 0; + virtual service::FieldResult getDoesKnowCommand(service::FieldParams&& params, DogCommand&& dogCommandArg) const = 0; + virtual service::FieldResult getIsHousetrained(service::FieldParams&& params, std::optional&& atOtherHomesArg) const = 0; + virtual service::FieldResult> getOwner(service::FieldParams&& params) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::FieldResult getName(service::FieldParams&& params) const final + { + if constexpr (methods::DogHas::getNameWithParams) + { + return { _pimpl->getName(std::move(params)) }; + } + else if constexpr (methods::DogHas::getName) + { + return { _pimpl->getName() }; + } + else + { + throw std::runtime_error(R"ex(Dog::getName is not implemented)ex"); + } + } + + service::FieldResult> getNickname(service::FieldParams&& params) const final + { + if constexpr (methods::DogHas::getNicknameWithParams) + { + return { _pimpl->getNickname(std::move(params)) }; + } + else if constexpr (methods::DogHas::getNickname) + { + return { _pimpl->getNickname() }; + } + else + { + throw std::runtime_error(R"ex(Dog::getNickname is not implemented)ex"); + } + } + + service::FieldResult> getBarkVolume(service::FieldParams&& params) const final + { + if constexpr (methods::DogHas::getBarkVolumeWithParams) + { + return { _pimpl->getBarkVolume(std::move(params)) }; + } + else if constexpr (methods::DogHas::getBarkVolume) + { + return { _pimpl->getBarkVolume() }; + } + else + { + throw std::runtime_error(R"ex(Dog::getBarkVolume is not implemented)ex"); + } + } + + service::FieldResult getDoesKnowCommand(service::FieldParams&& params, DogCommand&& dogCommandArg) const final + { + if constexpr (methods::DogHas::getDoesKnowCommandWithParams) + { + return { _pimpl->getDoesKnowCommand(std::move(params), std::move(dogCommandArg)) }; + } + else if constexpr (methods::DogHas::getDoesKnowCommand) + { + return { _pimpl->getDoesKnowCommand(std::move(dogCommandArg)) }; + } + else + { + throw std::runtime_error(R"ex(Dog::getDoesKnowCommand is not implemented)ex"); + } + } + + service::FieldResult getIsHousetrained(service::FieldParams&& params, std::optional&& atOtherHomesArg) const final + { + if constexpr (methods::DogHas::getIsHousetrainedWithParams) + { + return { _pimpl->getIsHousetrained(std::move(params), std::move(atOtherHomesArg)) }; + } + else if constexpr (methods::DogHas::getIsHousetrained) + { + return { _pimpl->getIsHousetrained(std::move(atOtherHomesArg)) }; + } + else + { + throw std::runtime_error(R"ex(Dog::getIsHousetrained is not implemented)ex"); + } + } + + service::FieldResult> getOwner(service::FieldParams&& params) const final + { + if constexpr (methods::DogHas::getOwnerWithParams) + { + return { _pimpl->getOwner(std::move(params)) }; + } + else if constexpr (methods::DogHas::getOwner) + { + return { _pimpl->getOwner() }; + } + else + { + throw std::runtime_error(R"ex(Dog::getOwner is not implemented)ex"); + } + } + + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::DogHas::beginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::DogHas::endSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + + private: + const std::shared_ptr _pimpl; + }; + + Dog(std::unique_ptr&& pimpl) noexcept; + + // Interfaces which this type implements + friend Pet; + + // Unions which include this type + friend CatOrDog; + friend DogOrHuman; + + template + static constexpr bool implements() noexcept + { + return implements::DogIs; + } + + service::TypeNames getTypeNames() const noexcept; + service::ResolverMap getResolvers() const noexcept; + + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; + + const std::unique_ptr _pimpl; + +public: + template + Dog(std::shared_ptr pimpl) noexcept + : Dog { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } + { + } +}; + +} // namespace graphql::validation::object + +#endif // DOGOBJECT_H diff --git a/samples/validation/schema/DogOrHumanObject.cpp b/samples/validation/schema/DogOrHumanObject.cpp new file mode 100644 index 00000000..bfa1f525 --- /dev/null +++ b/samples/validation/schema/DogOrHumanObject.cpp @@ -0,0 +1,41 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// WARNING! Do not edit this file manually, your changes will be overwritten. + +#include "DogOrHumanObject.h" + +#include "graphqlservice/introspection/Introspection.h" + +using namespace std::literals; + +namespace graphql::validation { +namespace object { + +DogOrHuman::DogOrHuman(std::unique_ptr&& pimpl) noexcept + : service::Object { pimpl->getTypeNames(), pimpl->getResolvers() } + , _pimpl { std::move(pimpl) } +{ +} + +void DogOrHuman::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void DogOrHuman::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} + +} // namespace object + +void AddDogOrHumanDetails(const std::shared_ptr& typeDogOrHuman, const std::shared_ptr& schema) +{ + typeDogOrHuman->AddPossibleTypes({ + schema->LookupType(R"gql(Dog)gql"sv), + schema->LookupType(R"gql(Human)gql"sv) + }); +} + +} // namespace graphql::validation diff --git a/samples/validation/schema/DogOrHumanObject.h b/samples/validation/schema/DogOrHumanObject.h new file mode 100644 index 00000000..917ce489 --- /dev/null +++ b/samples/validation/schema/DogOrHumanObject.h @@ -0,0 +1,81 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// WARNING! Do not edit this file manually, your changes will be overwritten. + +#pragma once + +#ifndef DOGORHUMANOBJECT_H +#define DOGORHUMANOBJECT_H + +#include "ValidationSchema.h" + +namespace graphql::validation::object { + +class DogOrHuman + : public service::Object +{ +private: + struct Concept + { + virtual ~Concept() = default; + + virtual service::TypeNames getTypeNames() const noexcept = 0; + virtual service::ResolverMap getResolvers() const noexcept = 0; + + virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::TypeNames getTypeNames() const noexcept final + { + return _pimpl->getTypeNames(); + } + + service::ResolverMap getResolvers() const noexcept final + { + return _pimpl->getResolvers(); + } + + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + _pimpl->beginSelectionSet(params); + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + _pimpl->endSelectionSet(params); + } + + private: + const std::shared_ptr _pimpl; + }; + + DogOrHuman(std::unique_ptr&& pimpl) noexcept; + + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; + + const std::unique_ptr _pimpl; + +public: + template + DogOrHuman(std::shared_ptr pimpl) noexcept + : DogOrHuman { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } + { + static_assert(T::template implements(), "DogOrHuman is not implemented"); + } +}; + +} // namespace graphql::validation::object + +#endif // DOGORHUMANOBJECT_H diff --git a/samples/validation/schema/HumanObject.cpp b/samples/validation/schema/HumanObject.cpp new file mode 100644 index 00000000..5dd1e6dd --- /dev/null +++ b/samples/validation/schema/HumanObject.cpp @@ -0,0 +1,95 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// WARNING! Do not edit this file manually, your changes will be overwritten. + +#include "HumanObject.h" +#include "PetObject.h" + +#include "graphqlservice/introspection/Introspection.h" + +#include +#include +#include +#include +#include + +using namespace std::literals; + +namespace graphql::validation { +namespace object { + +Human::Human(std::unique_ptr&& pimpl) noexcept + : service::Object{ getTypeNames(), getResolvers() } + , _pimpl { std::move(pimpl) } +{ +} + +service::TypeNames Human::getTypeNames() const noexcept +{ + return { + R"gql(Sentient)gql"sv, + R"gql(DogOrHuman)gql"sv, + R"gql(HumanOrAlien)gql"sv, + R"gql(Human)gql"sv + }; +} + +service::ResolverMap Human::getResolvers() const noexcept +{ + return { + { R"gql(name)gql"sv, [this](service::ResolverParams&& params) { return resolveName(std::move(params)); } }, + { R"gql(pets)gql"sv, [this](service::ResolverParams&& params) { return resolvePets(std::move(params)); } }, + { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } } + }; +} + +void Human::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void Human::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} + +service::AwaitableResolver Human::resolveName(service::ResolverParams&& params) const +{ + std::unique_lock resolverLock(_resolverMutex); + auto directives = std::move(params.fieldDirectives); + auto result = _pimpl->getName(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + resolverLock.unlock(); + + return service::ModifiedResult::convert(std::move(result), std::move(params)); +} + +service::AwaitableResolver Human::resolvePets(service::ResolverParams&& params) const +{ + std::unique_lock resolverLock(_resolverMutex); + auto directives = std::move(params.fieldDirectives); + auto result = _pimpl->getPets(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + resolverLock.unlock(); + + return service::ModifiedResult::convert(std::move(result), std::move(params)); +} + +service::AwaitableResolver Human::resolve_typename(service::ResolverParams&& params) const +{ + return service::ModifiedResult::convert(std::string{ R"gql(Human)gql" }, std::move(params)); +} + +} // namespace object + +void AddHumanDetails(const std::shared_ptr& typeHuman, const std::shared_ptr& schema) +{ + typeHuman->AddInterfaces({ + std::static_pointer_cast(schema->LookupType(R"gql(Sentient)gql"sv)) + }); + typeHuman->AddFields({ + schema::Field::Make(R"gql(name)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(String)gql"sv))), + schema::Field::Make(R"gql(pets)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Pet)gql"sv))))) + }); +} + +} // namespace graphql::validation diff --git a/samples/validation/schema/HumanObject.h b/samples/validation/schema/HumanObject.h new file mode 100644 index 00000000..7496a46f --- /dev/null +++ b/samples/validation/schema/HumanObject.h @@ -0,0 +1,175 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// WARNING! Do not edit this file manually, your changes will be overwritten. + +#pragma once + +#ifndef HUMANOBJECT_H +#define HUMANOBJECT_H + +#include "ValidationSchema.h" + +namespace graphql::validation::object { +namespace implements { + +template +concept HumanIs = std::is_same_v || std::is_same_v || std::is_same_v; + +} // namespace implements + +namespace methods::HumanHas { + +template +concept getNameWithParams = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult { impl.getName(std::move(params)) } }; +}; + +template +concept getName = requires (TImpl impl) +{ + { service::FieldResult { impl.getName() } }; +}; + +template +concept getPetsWithParams = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult>> { impl.getPets(std::move(params)) } }; +}; + +template +concept getPets = requires (TImpl impl) +{ + { service::FieldResult>> { impl.getPets() } }; +}; + +template +concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.beginSelectionSet(params) }; +}; + +template +concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.endSelectionSet(params) }; +}; + +} // namespace methods::HumanHas + +class Human + : public service::Object +{ +private: + service::AwaitableResolver resolveName(service::ResolverParams&& params) const; + service::AwaitableResolver resolvePets(service::ResolverParams&& params) const; + + service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; + + struct Concept + { + virtual ~Concept() = default; + + virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + + virtual service::FieldResult getName(service::FieldParams&& params) const = 0; + virtual service::FieldResult>> getPets(service::FieldParams&& params) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::FieldResult getName(service::FieldParams&& params) const final + { + if constexpr (methods::HumanHas::getNameWithParams) + { + return { _pimpl->getName(std::move(params)) }; + } + else if constexpr (methods::HumanHas::getName) + { + return { _pimpl->getName() }; + } + else + { + throw std::runtime_error(R"ex(Human::getName is not implemented)ex"); + } + } + + service::FieldResult>> getPets(service::FieldParams&& params) const final + { + if constexpr (methods::HumanHas::getPetsWithParams) + { + return { _pimpl->getPets(std::move(params)) }; + } + else if constexpr (methods::HumanHas::getPets) + { + return { _pimpl->getPets() }; + } + else + { + throw std::runtime_error(R"ex(Human::getPets is not implemented)ex"); + } + } + + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::HumanHas::beginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::HumanHas::endSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + + private: + const std::shared_ptr _pimpl; + }; + + Human(std::unique_ptr&& pimpl) noexcept; + + // Interfaces which this type implements + friend Sentient; + + // Unions which include this type + friend DogOrHuman; + friend HumanOrAlien; + + template + static constexpr bool implements() noexcept + { + return implements::HumanIs; + } + + service::TypeNames getTypeNames() const noexcept; + service::ResolverMap getResolvers() const noexcept; + + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; + + const std::unique_ptr _pimpl; + +public: + template + Human(std::shared_ptr pimpl) noexcept + : Human { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } + { + } +}; + +} // namespace graphql::validation::object + +#endif // HUMANOBJECT_H diff --git a/samples/validation/schema/HumanOrAlienObject.cpp b/samples/validation/schema/HumanOrAlienObject.cpp new file mode 100644 index 00000000..85af61e0 --- /dev/null +++ b/samples/validation/schema/HumanOrAlienObject.cpp @@ -0,0 +1,41 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// WARNING! Do not edit this file manually, your changes will be overwritten. + +#include "HumanOrAlienObject.h" + +#include "graphqlservice/introspection/Introspection.h" + +using namespace std::literals; + +namespace graphql::validation { +namespace object { + +HumanOrAlien::HumanOrAlien(std::unique_ptr&& pimpl) noexcept + : service::Object { pimpl->getTypeNames(), pimpl->getResolvers() } + , _pimpl { std::move(pimpl) } +{ +} + +void HumanOrAlien::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void HumanOrAlien::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} + +} // namespace object + +void AddHumanOrAlienDetails(const std::shared_ptr& typeHumanOrAlien, const std::shared_ptr& schema) +{ + typeHumanOrAlien->AddPossibleTypes({ + schema->LookupType(R"gql(Human)gql"sv), + schema->LookupType(R"gql(Alien)gql"sv) + }); +} + +} // namespace graphql::validation diff --git a/samples/validation/schema/HumanOrAlienObject.h b/samples/validation/schema/HumanOrAlienObject.h new file mode 100644 index 00000000..1f1e9297 --- /dev/null +++ b/samples/validation/schema/HumanOrAlienObject.h @@ -0,0 +1,81 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// WARNING! Do not edit this file manually, your changes will be overwritten. + +#pragma once + +#ifndef HUMANORALIENOBJECT_H +#define HUMANORALIENOBJECT_H + +#include "ValidationSchema.h" + +namespace graphql::validation::object { + +class HumanOrAlien + : public service::Object +{ +private: + struct Concept + { + virtual ~Concept() = default; + + virtual service::TypeNames getTypeNames() const noexcept = 0; + virtual service::ResolverMap getResolvers() const noexcept = 0; + + virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::TypeNames getTypeNames() const noexcept final + { + return _pimpl->getTypeNames(); + } + + service::ResolverMap getResolvers() const noexcept final + { + return _pimpl->getResolvers(); + } + + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + _pimpl->beginSelectionSet(params); + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + _pimpl->endSelectionSet(params); + } + + private: + const std::shared_ptr _pimpl; + }; + + HumanOrAlien(std::unique_ptr&& pimpl) noexcept; + + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; + + const std::unique_ptr _pimpl; + +public: + template + HumanOrAlien(std::shared_ptr pimpl) noexcept + : HumanOrAlien { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } + { + static_assert(T::template implements(), "HumanOrAlien is not implemented"); + } +}; + +} // namespace graphql::validation::object + +#endif // HUMANORALIENOBJECT_H diff --git a/samples/validation/schema/MessageObject.cpp b/samples/validation/schema/MessageObject.cpp new file mode 100644 index 00000000..d32bff5b --- /dev/null +++ b/samples/validation/schema/MessageObject.cpp @@ -0,0 +1,88 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// WARNING! Do not edit this file manually, your changes will be overwritten. + +#include "MessageObject.h" + +#include "graphqlservice/introspection/Introspection.h" + +#include +#include +#include +#include +#include + +using namespace std::literals; + +namespace graphql::validation { +namespace object { + +Message::Message(std::unique_ptr&& pimpl) noexcept + : service::Object{ getTypeNames(), getResolvers() } + , _pimpl { std::move(pimpl) } +{ +} + +service::TypeNames Message::getTypeNames() const noexcept +{ + return { + R"gql(Message)gql"sv + }; +} + +service::ResolverMap Message::getResolvers() const noexcept +{ + return { + { R"gql(body)gql"sv, [this](service::ResolverParams&& params) { return resolveBody(std::move(params)); } }, + { R"gql(sender)gql"sv, [this](service::ResolverParams&& params) { return resolveSender(std::move(params)); } }, + { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } } + }; +} + +void Message::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void Message::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} + +service::AwaitableResolver Message::resolveBody(service::ResolverParams&& params) const +{ + std::unique_lock resolverLock(_resolverMutex); + auto directives = std::move(params.fieldDirectives); + auto result = _pimpl->getBody(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + resolverLock.unlock(); + + return service::ModifiedResult::convert(std::move(result), std::move(params)); +} + +service::AwaitableResolver Message::resolveSender(service::ResolverParams&& params) const +{ + std::unique_lock resolverLock(_resolverMutex); + auto directives = std::move(params.fieldDirectives); + auto result = _pimpl->getSender(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + resolverLock.unlock(); + + return service::ModifiedResult::convert(std::move(result), std::move(params)); +} + +service::AwaitableResolver Message::resolve_typename(service::ResolverParams&& params) const +{ + return service::ModifiedResult::convert(std::string{ R"gql(Message)gql" }, std::move(params)); +} + +} // namespace object + +void AddMessageDetails(const std::shared_ptr& typeMessage, const std::shared_ptr& schema) +{ + typeMessage->AddFields({ + schema::Field::Make(R"gql(body)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(String)gql"sv)), + schema::Field::Make(R"gql(sender)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ID)gql"sv))) + }); +} + +} // namespace graphql::validation diff --git a/samples/validation/schema/MessageObject.h b/samples/validation/schema/MessageObject.h new file mode 100644 index 00000000..c0e6dc03 --- /dev/null +++ b/samples/validation/schema/MessageObject.h @@ -0,0 +1,155 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// WARNING! Do not edit this file manually, your changes will be overwritten. + +#pragma once + +#ifndef MESSAGEOBJECT_H +#define MESSAGEOBJECT_H + +#include "ValidationSchema.h" + +namespace graphql::validation::object { +namespace methods::MessageHas { + +template +concept getBodyWithParams = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult> { impl.getBody(std::move(params)) } }; +}; + +template +concept getBody = requires (TImpl impl) +{ + { service::FieldResult> { impl.getBody() } }; +}; + +template +concept getSenderWithParams = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult { impl.getSender(std::move(params)) } }; +}; + +template +concept getSender = requires (TImpl impl) +{ + { service::FieldResult { impl.getSender() } }; +}; + +template +concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.beginSelectionSet(params) }; +}; + +template +concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.endSelectionSet(params) }; +}; + +} // namespace methods::MessageHas + +class Message + : public service::Object +{ +private: + service::AwaitableResolver resolveBody(service::ResolverParams&& params) const; + service::AwaitableResolver resolveSender(service::ResolverParams&& params) const; + + service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; + + struct Concept + { + virtual ~Concept() = default; + + virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + + virtual service::FieldResult> getBody(service::FieldParams&& params) const = 0; + virtual service::FieldResult getSender(service::FieldParams&& params) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::FieldResult> getBody(service::FieldParams&& params) const final + { + if constexpr (methods::MessageHas::getBodyWithParams) + { + return { _pimpl->getBody(std::move(params)) }; + } + else if constexpr (methods::MessageHas::getBody) + { + return { _pimpl->getBody() }; + } + else + { + throw std::runtime_error(R"ex(Message::getBody is not implemented)ex"); + } + } + + service::FieldResult getSender(service::FieldParams&& params) const final + { + if constexpr (methods::MessageHas::getSenderWithParams) + { + return { _pimpl->getSender(std::move(params)) }; + } + else if constexpr (methods::MessageHas::getSender) + { + return { _pimpl->getSender() }; + } + else + { + throw std::runtime_error(R"ex(Message::getSender is not implemented)ex"); + } + } + + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::MessageHas::beginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::MessageHas::endSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + + private: + const std::shared_ptr _pimpl; + }; + + Message(std::unique_ptr&& pimpl) noexcept; + + service::TypeNames getTypeNames() const noexcept; + service::ResolverMap getResolvers() const noexcept; + + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; + + const std::unique_ptr _pimpl; + +public: + template + Message(std::shared_ptr pimpl) noexcept + : Message { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } + { + } +}; + +} // namespace graphql::validation::object + +#endif // MESSAGEOBJECT_H diff --git a/samples/validation/schema/MutateDogResultObject.cpp b/samples/validation/schema/MutateDogResultObject.cpp new file mode 100644 index 00000000..3b6672ed --- /dev/null +++ b/samples/validation/schema/MutateDogResultObject.cpp @@ -0,0 +1,76 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// WARNING! Do not edit this file manually, your changes will be overwritten. + +#include "MutateDogResultObject.h" + +#include "graphqlservice/introspection/Introspection.h" + +#include +#include +#include +#include +#include + +using namespace std::literals; + +namespace graphql::validation { +namespace object { + +MutateDogResult::MutateDogResult(std::unique_ptr&& pimpl) noexcept + : service::Object{ getTypeNames(), getResolvers() } + , _pimpl { std::move(pimpl) } +{ +} + +service::TypeNames MutateDogResult::getTypeNames() const noexcept +{ + return { + R"gql(MutateDogResult)gql"sv + }; +} + +service::ResolverMap MutateDogResult::getResolvers() const noexcept +{ + return { + { R"gql(id)gql"sv, [this](service::ResolverParams&& params) { return resolveId(std::move(params)); } }, + { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } } + }; +} + +void MutateDogResult::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void MutateDogResult::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} + +service::AwaitableResolver MutateDogResult::resolveId(service::ResolverParams&& params) const +{ + std::unique_lock resolverLock(_resolverMutex); + auto directives = std::move(params.fieldDirectives); + auto result = _pimpl->getId(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + resolverLock.unlock(); + + return service::ModifiedResult::convert(std::move(result), std::move(params)); +} + +service::AwaitableResolver MutateDogResult::resolve_typename(service::ResolverParams&& params) const +{ + return service::ModifiedResult::convert(std::string{ R"gql(MutateDogResult)gql" }, std::move(params)); +} + +} // namespace object + +void AddMutateDogResultDetails(const std::shared_ptr& typeMutateDogResult, const std::shared_ptr& schema) +{ + typeMutateDogResult->AddFields({ + schema::Field::Make(R"gql(id)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ID)gql"sv))) + }); +} + +} // namespace graphql::validation diff --git a/samples/validation/schema/MutateDogResultObject.h b/samples/validation/schema/MutateDogResultObject.h new file mode 100644 index 00000000..ff6a27ac --- /dev/null +++ b/samples/validation/schema/MutateDogResultObject.h @@ -0,0 +1,125 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// WARNING! Do not edit this file manually, your changes will be overwritten. + +#pragma once + +#ifndef MUTATEDOGRESULTOBJECT_H +#define MUTATEDOGRESULTOBJECT_H + +#include "ValidationSchema.h" + +namespace graphql::validation::object { +namespace methods::MutateDogResultHas { + +template +concept getIdWithParams = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult { impl.getId(std::move(params)) } }; +}; + +template +concept getId = requires (TImpl impl) +{ + { service::FieldResult { impl.getId() } }; +}; + +template +concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.beginSelectionSet(params) }; +}; + +template +concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.endSelectionSet(params) }; +}; + +} // namespace methods::MutateDogResultHas + +class MutateDogResult + : public service::Object +{ +private: + service::AwaitableResolver resolveId(service::ResolverParams&& params) const; + + service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; + + struct Concept + { + virtual ~Concept() = default; + + virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + + virtual service::FieldResult getId(service::FieldParams&& params) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::FieldResult getId(service::FieldParams&& params) const final + { + if constexpr (methods::MutateDogResultHas::getIdWithParams) + { + return { _pimpl->getId(std::move(params)) }; + } + else if constexpr (methods::MutateDogResultHas::getId) + { + return { _pimpl->getId() }; + } + else + { + throw std::runtime_error(R"ex(MutateDogResult::getId is not implemented)ex"); + } + } + + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::MutateDogResultHas::beginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::MutateDogResultHas::endSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + + private: + const std::shared_ptr _pimpl; + }; + + MutateDogResult(std::unique_ptr&& pimpl) noexcept; + + service::TypeNames getTypeNames() const noexcept; + service::ResolverMap getResolvers() const noexcept; + + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; + + const std::unique_ptr _pimpl; + +public: + template + MutateDogResult(std::shared_ptr pimpl) noexcept + : MutateDogResult { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } + { + } +}; + +} // namespace graphql::validation::object + +#endif // MUTATEDOGRESULTOBJECT_H diff --git a/samples/validation/schema/MutationObject.cpp b/samples/validation/schema/MutationObject.cpp new file mode 100644 index 00000000..e7072a7b --- /dev/null +++ b/samples/validation/schema/MutationObject.cpp @@ -0,0 +1,77 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// WARNING! Do not edit this file manually, your changes will be overwritten. + +#include "MutationObject.h" +#include "MutateDogResultObject.h" + +#include "graphqlservice/introspection/Introspection.h" + +#include +#include +#include +#include +#include + +using namespace std::literals; + +namespace graphql::validation { +namespace object { + +Mutation::Mutation(std::unique_ptr&& pimpl) noexcept + : service::Object{ getTypeNames(), getResolvers() } + , _pimpl { std::move(pimpl) } +{ +} + +service::TypeNames Mutation::getTypeNames() const noexcept +{ + return { + R"gql(Mutation)gql"sv + }; +} + +service::ResolverMap Mutation::getResolvers() const noexcept +{ + return { + { R"gql(mutateDog)gql"sv, [this](service::ResolverParams&& params) { return resolveMutateDog(std::move(params)); } }, + { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } } + }; +} + +void Mutation::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void Mutation::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} + +service::AwaitableResolver Mutation::resolveMutateDog(service::ResolverParams&& params) const +{ + std::unique_lock resolverLock(_resolverMutex); + auto directives = std::move(params.fieldDirectives); + auto result = _pimpl->applyMutateDog(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + resolverLock.unlock(); + + return service::ModifiedResult::convert(std::move(result), std::move(params)); +} + +service::AwaitableResolver Mutation::resolve_typename(service::ResolverParams&& params) const +{ + return service::ModifiedResult::convert(std::string{ R"gql(Mutation)gql" }, std::move(params)); +} + +} // namespace object + +void AddMutationDetails(const std::shared_ptr& typeMutation, const std::shared_ptr& schema) +{ + typeMutation->AddFields({ + schema::Field::Make(R"gql(mutateDog)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(MutateDogResult)gql"sv)) + }); +} + +} // namespace graphql::validation diff --git a/samples/validation/schema/MutationObject.h b/samples/validation/schema/MutationObject.h new file mode 100644 index 00000000..1980eebc --- /dev/null +++ b/samples/validation/schema/MutationObject.h @@ -0,0 +1,125 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// WARNING! Do not edit this file manually, your changes will be overwritten. + +#pragma once + +#ifndef MUTATIONOBJECT_H +#define MUTATIONOBJECT_H + +#include "ValidationSchema.h" + +namespace graphql::validation::object { +namespace methods::MutationHas { + +template +concept applyMutateDogWithParams = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult> { impl.applyMutateDog(std::move(params)) } }; +}; + +template +concept applyMutateDog = requires (TImpl impl) +{ + { service::FieldResult> { impl.applyMutateDog() } }; +}; + +template +concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.beginSelectionSet(params) }; +}; + +template +concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.endSelectionSet(params) }; +}; + +} // namespace methods::MutationHas + +class Mutation + : public service::Object +{ +private: + service::AwaitableResolver resolveMutateDog(service::ResolverParams&& params) const; + + service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; + + struct Concept + { + virtual ~Concept() = default; + + virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + + virtual service::FieldResult> applyMutateDog(service::FieldParams&& params) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::FieldResult> applyMutateDog(service::FieldParams&& params) const final + { + if constexpr (methods::MutationHas::applyMutateDogWithParams) + { + return { _pimpl->applyMutateDog(std::move(params)) }; + } + else if constexpr (methods::MutationHas::applyMutateDog) + { + return { _pimpl->applyMutateDog() }; + } + else + { + throw std::runtime_error(R"ex(Mutation::applyMutateDog is not implemented)ex"); + } + } + + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::MutationHas::beginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::MutationHas::endSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + + private: + const std::shared_ptr _pimpl; + }; + + Mutation(std::unique_ptr&& pimpl) noexcept; + + service::TypeNames getTypeNames() const noexcept; + service::ResolverMap getResolvers() const noexcept; + + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; + + const std::unique_ptr _pimpl; + +public: + template + Mutation(std::shared_ptr pimpl) noexcept + : Mutation { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } + { + } +}; + +} // namespace graphql::validation::object + +#endif // MUTATIONOBJECT_H diff --git a/samples/validation/schema/PetObject.cpp b/samples/validation/schema/PetObject.cpp new file mode 100644 index 00000000..4510dfdb --- /dev/null +++ b/samples/validation/schema/PetObject.cpp @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// WARNING! Do not edit this file manually, your changes will be overwritten. + +#include "PetObject.h" + +#include "graphqlservice/introspection/Introspection.h" + +using namespace std::literals; + +namespace graphql::validation { +namespace object { + +Pet::Pet(std::unique_ptr&& pimpl) noexcept + : service::Object { pimpl->getTypeNames(), pimpl->getResolvers() } + , _pimpl { std::move(pimpl) } +{ +} + +void Pet::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void Pet::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} + +} // namespace object + +void AddPetDetails(const std::shared_ptr& typePet, const std::shared_ptr& schema) +{ + typePet->AddFields({ + schema::Field::Make(R"gql(name)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(String)gql"sv))) + }); +} + +} // namespace graphql::validation diff --git a/samples/validation/schema/PetObject.h b/samples/validation/schema/PetObject.h new file mode 100644 index 00000000..bf30ed00 --- /dev/null +++ b/samples/validation/schema/PetObject.h @@ -0,0 +1,81 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// WARNING! Do not edit this file manually, your changes will be overwritten. + +#pragma once + +#ifndef PETOBJECT_H +#define PETOBJECT_H + +#include "ValidationSchema.h" + +namespace graphql::validation::object { + +class Pet + : public service::Object +{ +private: + struct Concept + { + virtual ~Concept() = default; + + virtual service::TypeNames getTypeNames() const noexcept = 0; + virtual service::ResolverMap getResolvers() const noexcept = 0; + + virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::TypeNames getTypeNames() const noexcept final + { + return _pimpl->getTypeNames(); + } + + service::ResolverMap getResolvers() const noexcept final + { + return _pimpl->getResolvers(); + } + + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + _pimpl->beginSelectionSet(params); + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + _pimpl->endSelectionSet(params); + } + + private: + const std::shared_ptr _pimpl; + }; + + Pet(std::unique_ptr&& pimpl) noexcept; + + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; + + const std::unique_ptr _pimpl; + +public: + template + Pet(std::shared_ptr pimpl) noexcept + : Pet { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } + { + static_assert(T::template implements(), "Pet is not implemented"); + } +}; + +} // namespace graphql::validation::object + +#endif // PETOBJECT_H diff --git a/samples/validation/schema/QueryObject.cpp b/samples/validation/schema/QueryObject.cpp new file mode 100644 index 00000000..cc59f797 --- /dev/null +++ b/samples/validation/schema/QueryObject.cpp @@ -0,0 +1,159 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// WARNING! Do not edit this file manually, your changes will be overwritten. + +#include "QueryObject.h" +#include "DogObject.h" +#include "HumanObject.h" +#include "PetObject.h" +#include "CatOrDogObject.h" +#include "ArgumentsObject.h" + +#include "graphqlservice/introspection/Introspection.h" + +#include +#include +#include +#include +#include + +using namespace std::literals; + +namespace graphql::validation { +namespace object { + +Query::Query(std::unique_ptr&& pimpl) noexcept + : service::Object{ getTypeNames(), getResolvers() } + , _pimpl { std::move(pimpl) } +{ +} + +service::TypeNames Query::getTypeNames() const noexcept +{ + return { + R"gql(Query)gql"sv + }; +} + +service::ResolverMap Query::getResolvers() const noexcept +{ + return { + { R"gql(dog)gql"sv, [this](service::ResolverParams&& params) { return resolveDog(std::move(params)); } }, + { R"gql(pet)gql"sv, [this](service::ResolverParams&& params) { return resolvePet(std::move(params)); } }, + { R"gql(human)gql"sv, [this](service::ResolverParams&& params) { return resolveHuman(std::move(params)); } }, + { R"gql(findDog)gql"sv, [this](service::ResolverParams&& params) { return resolveFindDog(std::move(params)); } }, + { R"gql(catOrDog)gql"sv, [this](service::ResolverParams&& params) { return resolveCatOrDog(std::move(params)); } }, + { R"gql(arguments)gql"sv, [this](service::ResolverParams&& params) { return resolveArguments(std::move(params)); } }, + { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, + { R"gql(booleanList)gql"sv, [this](service::ResolverParams&& params) { return resolveBooleanList(std::move(params)); } } + }; +} + +void Query::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void Query::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} + +service::AwaitableResolver Query::resolveDog(service::ResolverParams&& params) const +{ + std::unique_lock resolverLock(_resolverMutex); + auto directives = std::move(params.fieldDirectives); + auto result = _pimpl->getDog(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + resolverLock.unlock(); + + return service::ModifiedResult::convert(std::move(result), std::move(params)); +} + +service::AwaitableResolver Query::resolveHuman(service::ResolverParams&& params) const +{ + std::unique_lock resolverLock(_resolverMutex); + auto directives = std::move(params.fieldDirectives); + auto result = _pimpl->getHuman(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + resolverLock.unlock(); + + return service::ModifiedResult::convert(std::move(result), std::move(params)); +} + +service::AwaitableResolver Query::resolvePet(service::ResolverParams&& params) const +{ + std::unique_lock resolverLock(_resolverMutex); + auto directives = std::move(params.fieldDirectives); + auto result = _pimpl->getPet(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + resolverLock.unlock(); + + return service::ModifiedResult::convert(std::move(result), std::move(params)); +} + +service::AwaitableResolver Query::resolveCatOrDog(service::ResolverParams&& params) const +{ + std::unique_lock resolverLock(_resolverMutex); + auto directives = std::move(params.fieldDirectives); + auto result = _pimpl->getCatOrDog(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + resolverLock.unlock(); + + return service::ModifiedResult::convert(std::move(result), std::move(params)); +} + +service::AwaitableResolver Query::resolveArguments(service::ResolverParams&& params) const +{ + std::unique_lock resolverLock(_resolverMutex); + auto directives = std::move(params.fieldDirectives); + auto result = _pimpl->getArguments(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + resolverLock.unlock(); + + return service::ModifiedResult::convert(std::move(result), std::move(params)); +} + +service::AwaitableResolver Query::resolveFindDog(service::ResolverParams&& params) const +{ + auto argComplex = service::ModifiedArgument::require("complex", params.arguments); + std::unique_lock resolverLock(_resolverMutex); + auto directives = std::move(params.fieldDirectives); + auto result = _pimpl->getFindDog(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argComplex)); + resolverLock.unlock(); + + return service::ModifiedResult::convert(std::move(result), std::move(params)); +} + +service::AwaitableResolver Query::resolveBooleanList(service::ResolverParams&& params) const +{ + auto argBooleanListArg = service::ModifiedArgument::require("booleanListArg", params.arguments); + std::unique_lock resolverLock(_resolverMutex); + auto directives = std::move(params.fieldDirectives); + auto result = _pimpl->getBooleanList(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argBooleanListArg)); + resolverLock.unlock(); + + return service::ModifiedResult::convert(std::move(result), std::move(params)); +} + +service::AwaitableResolver Query::resolve_typename(service::ResolverParams&& params) const +{ + return service::ModifiedResult::convert(std::string{ R"gql(Query)gql" }, std::move(params)); +} + +} // namespace object + +void AddQueryDetails(const std::shared_ptr& typeQuery, const std::shared_ptr& schema) +{ + typeQuery->AddFields({ + schema::Field::Make(R"gql(dog)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(Dog)gql"sv)), + schema::Field::Make(R"gql(human)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(Human)gql"sv)), + schema::Field::Make(R"gql(pet)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(Pet)gql"sv)), + schema::Field::Make(R"gql(catOrDog)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(CatOrDog)gql"sv)), + schema::Field::Make(R"gql(arguments)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(Arguments)gql"sv)), + schema::Field::Make(R"gql(findDog)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(Dog)gql"sv), { + schema::InputValue::Make(R"gql(complex)gql"sv, R"md()md"sv, schema->LookupType(R"gql(ComplexInput)gql"sv), R"gql()gql"sv) + }), + schema::Field::Make(R"gql(booleanList)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(Boolean)gql"sv), { + schema::InputValue::Make(R"gql(booleanListArg)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Boolean)gql"sv))), R"gql()gql"sv) + }) + }); +} + +} // namespace graphql::validation diff --git a/samples/validation/schema/QueryObject.h b/samples/validation/schema/QueryObject.h new file mode 100644 index 00000000..d405aff7 --- /dev/null +++ b/samples/validation/schema/QueryObject.h @@ -0,0 +1,305 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// WARNING! Do not edit this file manually, your changes will be overwritten. + +#pragma once + +#ifndef QUERYOBJECT_H +#define QUERYOBJECT_H + +#include "ValidationSchema.h" + +namespace graphql::validation::object { +namespace methods::QueryHas { + +template +concept getDogWithParams = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult> { impl.getDog(std::move(params)) } }; +}; + +template +concept getDog = requires (TImpl impl) +{ + { service::FieldResult> { impl.getDog() } }; +}; + +template +concept getHumanWithParams = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult> { impl.getHuman(std::move(params)) } }; +}; + +template +concept getHuman = requires (TImpl impl) +{ + { service::FieldResult> { impl.getHuman() } }; +}; + +template +concept getPetWithParams = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult> { impl.getPet(std::move(params)) } }; +}; + +template +concept getPet = requires (TImpl impl) +{ + { service::FieldResult> { impl.getPet() } }; +}; + +template +concept getCatOrDogWithParams = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult> { impl.getCatOrDog(std::move(params)) } }; +}; + +template +concept getCatOrDog = requires (TImpl impl) +{ + { service::FieldResult> { impl.getCatOrDog() } }; +}; + +template +concept getArgumentsWithParams = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult> { impl.getArguments(std::move(params)) } }; +}; + +template +concept getArguments = requires (TImpl impl) +{ + { service::FieldResult> { impl.getArguments() } }; +}; + +template +concept getFindDogWithParams = requires (TImpl impl, service::FieldParams params, std::optional complexArg) +{ + { service::FieldResult> { impl.getFindDog(std::move(params), std::move(complexArg)) } }; +}; + +template +concept getFindDog = requires (TImpl impl, std::optional complexArg) +{ + { service::FieldResult> { impl.getFindDog(std::move(complexArg)) } }; +}; + +template +concept getBooleanListWithParams = requires (TImpl impl, service::FieldParams params, std::optional> booleanListArgArg) +{ + { service::FieldResult> { impl.getBooleanList(std::move(params), std::move(booleanListArgArg)) } }; +}; + +template +concept getBooleanList = requires (TImpl impl, std::optional> booleanListArgArg) +{ + { service::FieldResult> { impl.getBooleanList(std::move(booleanListArgArg)) } }; +}; + +template +concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.beginSelectionSet(params) }; +}; + +template +concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.endSelectionSet(params) }; +}; + +} // namespace methods::QueryHas + +class Query + : public service::Object +{ +private: + service::AwaitableResolver resolveDog(service::ResolverParams&& params) const; + service::AwaitableResolver resolveHuman(service::ResolverParams&& params) const; + service::AwaitableResolver resolvePet(service::ResolverParams&& params) const; + service::AwaitableResolver resolveCatOrDog(service::ResolverParams&& params) const; + service::AwaitableResolver resolveArguments(service::ResolverParams&& params) const; + service::AwaitableResolver resolveFindDog(service::ResolverParams&& params) const; + service::AwaitableResolver resolveBooleanList(service::ResolverParams&& params) const; + + service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; + + struct Concept + { + virtual ~Concept() = default; + + virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + + virtual service::FieldResult> getDog(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getHuman(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getPet(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getCatOrDog(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getArguments(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getFindDog(service::FieldParams&& params, std::optional&& complexArg) const = 0; + virtual service::FieldResult> getBooleanList(service::FieldParams&& params, std::optional>&& booleanListArgArg) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::FieldResult> getDog(service::FieldParams&& params) const final + { + if constexpr (methods::QueryHas::getDogWithParams) + { + return { _pimpl->getDog(std::move(params)) }; + } + else if constexpr (methods::QueryHas::getDog) + { + return { _pimpl->getDog() }; + } + else + { + throw std::runtime_error(R"ex(Query::getDog is not implemented)ex"); + } + } + + service::FieldResult> getHuman(service::FieldParams&& params) const final + { + if constexpr (methods::QueryHas::getHumanWithParams) + { + return { _pimpl->getHuman(std::move(params)) }; + } + else if constexpr (methods::QueryHas::getHuman) + { + return { _pimpl->getHuman() }; + } + else + { + throw std::runtime_error(R"ex(Query::getHuman is not implemented)ex"); + } + } + + service::FieldResult> getPet(service::FieldParams&& params) const final + { + if constexpr (methods::QueryHas::getPetWithParams) + { + return { _pimpl->getPet(std::move(params)) }; + } + else if constexpr (methods::QueryHas::getPet) + { + return { _pimpl->getPet() }; + } + else + { + throw std::runtime_error(R"ex(Query::getPet is not implemented)ex"); + } + } + + service::FieldResult> getCatOrDog(service::FieldParams&& params) const final + { + if constexpr (methods::QueryHas::getCatOrDogWithParams) + { + return { _pimpl->getCatOrDog(std::move(params)) }; + } + else if constexpr (methods::QueryHas::getCatOrDog) + { + return { _pimpl->getCatOrDog() }; + } + else + { + throw std::runtime_error(R"ex(Query::getCatOrDog is not implemented)ex"); + } + } + + service::FieldResult> getArguments(service::FieldParams&& params) const final + { + if constexpr (methods::QueryHas::getArgumentsWithParams) + { + return { _pimpl->getArguments(std::move(params)) }; + } + else if constexpr (methods::QueryHas::getArguments) + { + return { _pimpl->getArguments() }; + } + else + { + throw std::runtime_error(R"ex(Query::getArguments is not implemented)ex"); + } + } + + service::FieldResult> getFindDog(service::FieldParams&& params, std::optional&& complexArg) const final + { + if constexpr (methods::QueryHas::getFindDogWithParams) + { + return { _pimpl->getFindDog(std::move(params), std::move(complexArg)) }; + } + else if constexpr (methods::QueryHas::getFindDog) + { + return { _pimpl->getFindDog(std::move(complexArg)) }; + } + else + { + throw std::runtime_error(R"ex(Query::getFindDog is not implemented)ex"); + } + } + + service::FieldResult> getBooleanList(service::FieldParams&& params, std::optional>&& booleanListArgArg) const final + { + if constexpr (methods::QueryHas::getBooleanListWithParams) + { + return { _pimpl->getBooleanList(std::move(params), std::move(booleanListArgArg)) }; + } + else if constexpr (methods::QueryHas::getBooleanList) + { + return { _pimpl->getBooleanList(std::move(booleanListArgArg)) }; + } + else + { + throw std::runtime_error(R"ex(Query::getBooleanList is not implemented)ex"); + } + } + + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::QueryHas::beginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::QueryHas::endSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + + private: + const std::shared_ptr _pimpl; + }; + + Query(std::unique_ptr&& pimpl) noexcept; + + service::TypeNames getTypeNames() const noexcept; + service::ResolverMap getResolvers() const noexcept; + + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; + + const std::unique_ptr _pimpl; + +public: + template + Query(std::shared_ptr pimpl) noexcept + : Query { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } + { + } +}; + +} // namespace graphql::validation::object + +#endif // QUERYOBJECT_H diff --git a/samples/validation/schema/SentientObject.cpp b/samples/validation/schema/SentientObject.cpp new file mode 100644 index 00000000..ac94bb87 --- /dev/null +++ b/samples/validation/schema/SentientObject.cpp @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// WARNING! Do not edit this file manually, your changes will be overwritten. + +#include "SentientObject.h" + +#include "graphqlservice/introspection/Introspection.h" + +using namespace std::literals; + +namespace graphql::validation { +namespace object { + +Sentient::Sentient(std::unique_ptr&& pimpl) noexcept + : service::Object { pimpl->getTypeNames(), pimpl->getResolvers() } + , _pimpl { std::move(pimpl) } +{ +} + +void Sentient::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void Sentient::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} + +} // namespace object + +void AddSentientDetails(const std::shared_ptr& typeSentient, const std::shared_ptr& schema) +{ + typeSentient->AddFields({ + schema::Field::Make(R"gql(name)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(String)gql"sv))) + }); +} + +} // namespace graphql::validation diff --git a/samples/validation/schema/SentientObject.h b/samples/validation/schema/SentientObject.h new file mode 100644 index 00000000..8569fc20 --- /dev/null +++ b/samples/validation/schema/SentientObject.h @@ -0,0 +1,81 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// WARNING! Do not edit this file manually, your changes will be overwritten. + +#pragma once + +#ifndef SENTIENTOBJECT_H +#define SENTIENTOBJECT_H + +#include "ValidationSchema.h" + +namespace graphql::validation::object { + +class Sentient + : public service::Object +{ +private: + struct Concept + { + virtual ~Concept() = default; + + virtual service::TypeNames getTypeNames() const noexcept = 0; + virtual service::ResolverMap getResolvers() const noexcept = 0; + + virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::TypeNames getTypeNames() const noexcept final + { + return _pimpl->getTypeNames(); + } + + service::ResolverMap getResolvers() const noexcept final + { + return _pimpl->getResolvers(); + } + + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + _pimpl->beginSelectionSet(params); + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + _pimpl->endSelectionSet(params); + } + + private: + const std::shared_ptr _pimpl; + }; + + Sentient(std::unique_ptr&& pimpl) noexcept; + + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; + + const std::unique_ptr _pimpl; + +public: + template + Sentient(std::shared_ptr pimpl) noexcept + : Sentient { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } + { + static_assert(T::template implements(), "Sentient is not implemented"); + } +}; + +} // namespace graphql::validation::object + +#endif // SENTIENTOBJECT_H diff --git a/samples/validation/schema/SubscriptionObject.cpp b/samples/validation/schema/SubscriptionObject.cpp new file mode 100644 index 00000000..56693285 --- /dev/null +++ b/samples/validation/schema/SubscriptionObject.cpp @@ -0,0 +1,89 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// WARNING! Do not edit this file manually, your changes will be overwritten. + +#include "SubscriptionObject.h" +#include "MessageObject.h" + +#include "graphqlservice/introspection/Introspection.h" + +#include +#include +#include +#include +#include + +using namespace std::literals; + +namespace graphql::validation { +namespace object { + +Subscription::Subscription(std::unique_ptr&& pimpl) noexcept + : service::Object{ getTypeNames(), getResolvers() } + , _pimpl { std::move(pimpl) } +{ +} + +service::TypeNames Subscription::getTypeNames() const noexcept +{ + return { + R"gql(Subscription)gql"sv + }; +} + +service::ResolverMap Subscription::getResolvers() const noexcept +{ + return { + { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, + { R"gql(newMessage)gql"sv, [this](service::ResolverParams&& params) { return resolveNewMessage(std::move(params)); } }, + { R"gql(disallowedSecondRootField)gql"sv, [this](service::ResolverParams&& params) { return resolveDisallowedSecondRootField(std::move(params)); } } + }; +} + +void Subscription::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void Subscription::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} + +service::AwaitableResolver Subscription::resolveNewMessage(service::ResolverParams&& params) const +{ + std::unique_lock resolverLock(_resolverMutex); + auto directives = std::move(params.fieldDirectives); + auto result = _pimpl->getNewMessage(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + resolverLock.unlock(); + + return service::ModifiedResult::convert(std::move(result), std::move(params)); +} + +service::AwaitableResolver Subscription::resolveDisallowedSecondRootField(service::ResolverParams&& params) const +{ + std::unique_lock resolverLock(_resolverMutex); + auto directives = std::move(params.fieldDirectives); + auto result = _pimpl->getDisallowedSecondRootField(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + resolverLock.unlock(); + + return service::ModifiedResult::convert(std::move(result), std::move(params)); +} + +service::AwaitableResolver Subscription::resolve_typename(service::ResolverParams&& params) const +{ + return service::ModifiedResult::convert(std::string{ R"gql(Subscription)gql" }, std::move(params)); +} + +} // namespace object + +void AddSubscriptionDetails(const std::shared_ptr& typeSubscription, const std::shared_ptr& schema) +{ + typeSubscription->AddFields({ + schema::Field::Make(R"gql(newMessage)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Message)gql"sv))), + schema::Field::Make(R"gql(disallowedSecondRootField)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Boolean)gql"sv))) + }); +} + +} // namespace graphql::validation diff --git a/samples/validation/schema/SubscriptionObject.h b/samples/validation/schema/SubscriptionObject.h new file mode 100644 index 00000000..e1eac1e3 --- /dev/null +++ b/samples/validation/schema/SubscriptionObject.h @@ -0,0 +1,155 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// WARNING! Do not edit this file manually, your changes will be overwritten. + +#pragma once + +#ifndef SUBSCRIPTIONOBJECT_H +#define SUBSCRIPTIONOBJECT_H + +#include "ValidationSchema.h" + +namespace graphql::validation::object { +namespace methods::SubscriptionHas { + +template +concept getNewMessageWithParams = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult> { impl.getNewMessage(std::move(params)) } }; +}; + +template +concept getNewMessage = requires (TImpl impl) +{ + { service::FieldResult> { impl.getNewMessage() } }; +}; + +template +concept getDisallowedSecondRootFieldWithParams = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult { impl.getDisallowedSecondRootField(std::move(params)) } }; +}; + +template +concept getDisallowedSecondRootField = requires (TImpl impl) +{ + { service::FieldResult { impl.getDisallowedSecondRootField() } }; +}; + +template +concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.beginSelectionSet(params) }; +}; + +template +concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.endSelectionSet(params) }; +}; + +} // namespace methods::SubscriptionHas + +class Subscription + : public service::Object +{ +private: + service::AwaitableResolver resolveNewMessage(service::ResolverParams&& params) const; + service::AwaitableResolver resolveDisallowedSecondRootField(service::ResolverParams&& params) const; + + service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; + + struct Concept + { + virtual ~Concept() = default; + + virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + + virtual service::FieldResult> getNewMessage(service::FieldParams&& params) const = 0; + virtual service::FieldResult getDisallowedSecondRootField(service::FieldParams&& params) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::FieldResult> getNewMessage(service::FieldParams&& params) const final + { + if constexpr (methods::SubscriptionHas::getNewMessageWithParams) + { + return { _pimpl->getNewMessage(std::move(params)) }; + } + else if constexpr (methods::SubscriptionHas::getNewMessage) + { + return { _pimpl->getNewMessage() }; + } + else + { + throw std::runtime_error(R"ex(Subscription::getNewMessage is not implemented)ex"); + } + } + + service::FieldResult getDisallowedSecondRootField(service::FieldParams&& params) const final + { + if constexpr (methods::SubscriptionHas::getDisallowedSecondRootFieldWithParams) + { + return { _pimpl->getDisallowedSecondRootField(std::move(params)) }; + } + else if constexpr (methods::SubscriptionHas::getDisallowedSecondRootField) + { + return { _pimpl->getDisallowedSecondRootField() }; + } + else + { + throw std::runtime_error(R"ex(Subscription::getDisallowedSecondRootField is not implemented)ex"); + } + } + + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::SubscriptionHas::beginSelectionSet) + { + _pimpl->beginSelectionSet(params); + } + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + if constexpr (methods::SubscriptionHas::endSelectionSet) + { + _pimpl->endSelectionSet(params); + } + } + + private: + const std::shared_ptr _pimpl; + }; + + Subscription(std::unique_ptr&& pimpl) noexcept; + + service::TypeNames getTypeNames() const noexcept; + service::ResolverMap getResolvers() const noexcept; + + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; + + const std::unique_ptr _pimpl; + +public: + template + Subscription(std::shared_ptr pimpl) noexcept + : Subscription { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } + { + } +}; + +} // namespace graphql::validation::object + +#endif // SUBSCRIPTIONOBJECT_H diff --git a/samples/validation/schema/ValidationObjects.h b/samples/validation/schema/ValidationObjects.h new file mode 100644 index 00000000..903ea138 --- /dev/null +++ b/samples/validation/schema/ValidationObjects.h @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// WARNING! Do not edit this file manually, your changes will be overwritten. + +#pragma once + +#ifndef VALIDATIONOBJECTS_H +#define VALIDATIONOBJECTS_H + +#include "ValidationSchema.h" + +#include "SentientObject.h" +#include "PetObject.h" +#include "CatOrDogObject.h" +#include "DogOrHumanObject.h" +#include "HumanOrAlienObject.h" +#include "QueryObject.h" +#include "DogObject.h" +#include "AlienObject.h" +#include "HumanObject.h" +#include "CatObject.h" +#include "MutationObject.h" +#include "MutateDogResultObject.h" +#include "SubscriptionObject.h" +#include "MessageObject.h" +#include "ArgumentsObject.h" + +#endif // VALIDATIONOBJECTS_H diff --git a/samples/validation/schema/ValidationSchema.cpp b/samples/validation/schema/ValidationSchema.cpp index b6ec2dc7..6fbe8498 100644 --- a/samples/validation/schema/ValidationSchema.cpp +++ b/samples/validation/schema/ValidationSchema.cpp @@ -3,7 +3,9 @@ // WARNING! Do not edit this file manually, your changes will be overwritten. -#include "ValidationSchema.h" +#include "QueryObject.h" +#include "MutationObject.h" +#include "SubscriptionObject.h" #include "graphqlservice/introspection/Introspection.h" @@ -110,862 +112,6 @@ validation::ComplexInput ModifiedArgument::convert(con } // namespace service namespace validation { -namespace object { - -Sentient::Sentient(std::unique_ptr&& pimpl) noexcept - : service::Object { pimpl->getTypeNames(), pimpl->getResolvers() } - , _pimpl { std::move(pimpl) } -{ -} - -void Sentient::beginSelectionSet(const service::SelectionSetParams& params) const -{ - _pimpl->beginSelectionSet(params); -} - -void Sentient::endSelectionSet(const service::SelectionSetParams& params) const -{ - _pimpl->endSelectionSet(params); -} - -Pet::Pet(std::unique_ptr&& pimpl) noexcept - : service::Object { pimpl->getTypeNames(), pimpl->getResolvers() } - , _pimpl { std::move(pimpl) } -{ -} - -void Pet::beginSelectionSet(const service::SelectionSetParams& params) const -{ - _pimpl->beginSelectionSet(params); -} - -void Pet::endSelectionSet(const service::SelectionSetParams& params) const -{ - _pimpl->endSelectionSet(params); -} - -CatOrDog::CatOrDog(std::unique_ptr&& pimpl) noexcept - : service::Object { pimpl->getTypeNames(), pimpl->getResolvers() } - , _pimpl { std::move(pimpl) } -{ -} - -void CatOrDog::beginSelectionSet(const service::SelectionSetParams& params) const -{ - _pimpl->beginSelectionSet(params); -} - -void CatOrDog::endSelectionSet(const service::SelectionSetParams& params) const -{ - _pimpl->endSelectionSet(params); -} - -DogOrHuman::DogOrHuman(std::unique_ptr&& pimpl) noexcept - : service::Object { pimpl->getTypeNames(), pimpl->getResolvers() } - , _pimpl { std::move(pimpl) } -{ -} - -void DogOrHuman::beginSelectionSet(const service::SelectionSetParams& params) const -{ - _pimpl->beginSelectionSet(params); -} - -void DogOrHuman::endSelectionSet(const service::SelectionSetParams& params) const -{ - _pimpl->endSelectionSet(params); -} - -HumanOrAlien::HumanOrAlien(std::unique_ptr&& pimpl) noexcept - : service::Object { pimpl->getTypeNames(), pimpl->getResolvers() } - , _pimpl { std::move(pimpl) } -{ -} - -void HumanOrAlien::beginSelectionSet(const service::SelectionSetParams& params) const -{ - _pimpl->beginSelectionSet(params); -} - -void HumanOrAlien::endSelectionSet(const service::SelectionSetParams& params) const -{ - _pimpl->endSelectionSet(params); -} - -Query::Query(std::unique_ptr&& pimpl) noexcept - : service::Object{ getTypeNames(), getResolvers() } - , _pimpl { std::move(pimpl) } -{ -} - -service::TypeNames Query::getTypeNames() const noexcept -{ - return { - R"gql(Query)gql"sv - }; -} - -service::ResolverMap Query::getResolvers() const noexcept -{ - return { - { R"gql(dog)gql"sv, [this](service::ResolverParams&& params) { return resolveDog(std::move(params)); } }, - { R"gql(pet)gql"sv, [this](service::ResolverParams&& params) { return resolvePet(std::move(params)); } }, - { R"gql(human)gql"sv, [this](service::ResolverParams&& params) { return resolveHuman(std::move(params)); } }, - { R"gql(findDog)gql"sv, [this](service::ResolverParams&& params) { return resolveFindDog(std::move(params)); } }, - { R"gql(catOrDog)gql"sv, [this](service::ResolverParams&& params) { return resolveCatOrDog(std::move(params)); } }, - { R"gql(arguments)gql"sv, [this](service::ResolverParams&& params) { return resolveArguments(std::move(params)); } }, - { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, - { R"gql(booleanList)gql"sv, [this](service::ResolverParams&& params) { return resolveBooleanList(std::move(params)); } } - }; -} - -void Query::beginSelectionSet(const service::SelectionSetParams& params) const -{ - _pimpl->beginSelectionSet(params); -} - -void Query::endSelectionSet(const service::SelectionSetParams& params) const -{ - _pimpl->endSelectionSet(params); -} - -service::AwaitableResolver Query::resolveDog(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getDog(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Query::resolveHuman(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getHuman(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Query::resolvePet(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getPet(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Query::resolveCatOrDog(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getCatOrDog(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Query::resolveArguments(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getArguments(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Query::resolveFindDog(service::ResolverParams&& params) const -{ - auto argComplex = service::ModifiedArgument::require("complex", params.arguments); - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getFindDog(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argComplex)); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Query::resolveBooleanList(service::ResolverParams&& params) const -{ - auto argBooleanListArg = service::ModifiedArgument::require("booleanListArg", params.arguments); - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getBooleanList(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argBooleanListArg)); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Query::resolve_typename(service::ResolverParams&& params) const -{ - return service::ModifiedResult::convert(std::string{ R"gql(Query)gql" }, std::move(params)); -} - -Dog::Dog(std::unique_ptr&& pimpl) noexcept - : service::Object{ getTypeNames(), getResolvers() } - , _pimpl { std::move(pimpl) } -{ -} - -service::TypeNames Dog::getTypeNames() const noexcept -{ - return { - R"gql(Pet)gql"sv, - R"gql(CatOrDog)gql"sv, - R"gql(DogOrHuman)gql"sv, - R"gql(Dog)gql"sv - }; -} - -service::ResolverMap Dog::getResolvers() const noexcept -{ - return { - { R"gql(name)gql"sv, [this](service::ResolverParams&& params) { return resolveName(std::move(params)); } }, - { R"gql(owner)gql"sv, [this](service::ResolverParams&& params) { return resolveOwner(std::move(params)); } }, - { R"gql(nickname)gql"sv, [this](service::ResolverParams&& params) { return resolveNickname(std::move(params)); } }, - { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, - { R"gql(barkVolume)gql"sv, [this](service::ResolverParams&& params) { return resolveBarkVolume(std::move(params)); } }, - { R"gql(isHousetrained)gql"sv, [this](service::ResolverParams&& params) { return resolveIsHousetrained(std::move(params)); } }, - { R"gql(doesKnowCommand)gql"sv, [this](service::ResolverParams&& params) { return resolveDoesKnowCommand(std::move(params)); } } - }; -} - -void Dog::beginSelectionSet(const service::SelectionSetParams& params) const -{ - _pimpl->beginSelectionSet(params); -} - -void Dog::endSelectionSet(const service::SelectionSetParams& params) const -{ - _pimpl->endSelectionSet(params); -} - -service::AwaitableResolver Dog::resolveName(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getName(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Dog::resolveNickname(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getNickname(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Dog::resolveBarkVolume(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getBarkVolume(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Dog::resolveDoesKnowCommand(service::ResolverParams&& params) const -{ - auto argDogCommand = service::ModifiedArgument::require("dogCommand", params.arguments); - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getDoesKnowCommand(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argDogCommand)); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Dog::resolveIsHousetrained(service::ResolverParams&& params) const -{ - auto argAtOtherHomes = service::ModifiedArgument::require("atOtherHomes", params.arguments); - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getIsHousetrained(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argAtOtherHomes)); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Dog::resolveOwner(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getOwner(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Dog::resolve_typename(service::ResolverParams&& params) const -{ - return service::ModifiedResult::convert(std::string{ R"gql(Dog)gql" }, std::move(params)); -} - -Alien::Alien(std::unique_ptr&& pimpl) noexcept - : service::Object{ getTypeNames(), getResolvers() } - , _pimpl { std::move(pimpl) } -{ -} - -service::TypeNames Alien::getTypeNames() const noexcept -{ - return { - R"gql(Sentient)gql"sv, - R"gql(HumanOrAlien)gql"sv, - R"gql(Alien)gql"sv - }; -} - -service::ResolverMap Alien::getResolvers() const noexcept -{ - return { - { R"gql(name)gql"sv, [this](service::ResolverParams&& params) { return resolveName(std::move(params)); } }, - { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, - { R"gql(homePlanet)gql"sv, [this](service::ResolverParams&& params) { return resolveHomePlanet(std::move(params)); } } - }; -} - -void Alien::beginSelectionSet(const service::SelectionSetParams& params) const -{ - _pimpl->beginSelectionSet(params); -} - -void Alien::endSelectionSet(const service::SelectionSetParams& params) const -{ - _pimpl->endSelectionSet(params); -} - -service::AwaitableResolver Alien::resolveName(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getName(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Alien::resolveHomePlanet(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getHomePlanet(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Alien::resolve_typename(service::ResolverParams&& params) const -{ - return service::ModifiedResult::convert(std::string{ R"gql(Alien)gql" }, std::move(params)); -} - -Human::Human(std::unique_ptr&& pimpl) noexcept - : service::Object{ getTypeNames(), getResolvers() } - , _pimpl { std::move(pimpl) } -{ -} - -service::TypeNames Human::getTypeNames() const noexcept -{ - return { - R"gql(Sentient)gql"sv, - R"gql(DogOrHuman)gql"sv, - R"gql(HumanOrAlien)gql"sv, - R"gql(Human)gql"sv - }; -} - -service::ResolverMap Human::getResolvers() const noexcept -{ - return { - { R"gql(name)gql"sv, [this](service::ResolverParams&& params) { return resolveName(std::move(params)); } }, - { R"gql(pets)gql"sv, [this](service::ResolverParams&& params) { return resolvePets(std::move(params)); } }, - { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } } - }; -} - -void Human::beginSelectionSet(const service::SelectionSetParams& params) const -{ - _pimpl->beginSelectionSet(params); -} - -void Human::endSelectionSet(const service::SelectionSetParams& params) const -{ - _pimpl->endSelectionSet(params); -} - -service::AwaitableResolver Human::resolveName(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getName(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Human::resolvePets(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getPets(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Human::resolve_typename(service::ResolverParams&& params) const -{ - return service::ModifiedResult::convert(std::string{ R"gql(Human)gql" }, std::move(params)); -} - -Cat::Cat(std::unique_ptr&& pimpl) noexcept - : service::Object{ getTypeNames(), getResolvers() } - , _pimpl { std::move(pimpl) } -{ -} - -service::TypeNames Cat::getTypeNames() const noexcept -{ - return { - R"gql(Pet)gql"sv, - R"gql(CatOrDog)gql"sv, - R"gql(Cat)gql"sv - }; -} - -service::ResolverMap Cat::getResolvers() const noexcept -{ - return { - { R"gql(name)gql"sv, [this](service::ResolverParams&& params) { return resolveName(std::move(params)); } }, - { R"gql(nickname)gql"sv, [this](service::ResolverParams&& params) { return resolveNickname(std::move(params)); } }, - { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, - { R"gql(meowVolume)gql"sv, [this](service::ResolverParams&& params) { return resolveMeowVolume(std::move(params)); } }, - { R"gql(doesKnowCommand)gql"sv, [this](service::ResolverParams&& params) { return resolveDoesKnowCommand(std::move(params)); } } - }; -} - -void Cat::beginSelectionSet(const service::SelectionSetParams& params) const -{ - _pimpl->beginSelectionSet(params); -} - -void Cat::endSelectionSet(const service::SelectionSetParams& params) const -{ - _pimpl->endSelectionSet(params); -} - -service::AwaitableResolver Cat::resolveName(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getName(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Cat::resolveNickname(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getNickname(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Cat::resolveDoesKnowCommand(service::ResolverParams&& params) const -{ - auto argCatCommand = service::ModifiedArgument::require("catCommand", params.arguments); - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getDoesKnowCommand(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argCatCommand)); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Cat::resolveMeowVolume(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getMeowVolume(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Cat::resolve_typename(service::ResolverParams&& params) const -{ - return service::ModifiedResult::convert(std::string{ R"gql(Cat)gql" }, std::move(params)); -} - -Mutation::Mutation(std::unique_ptr&& pimpl) noexcept - : service::Object{ getTypeNames(), getResolvers() } - , _pimpl { std::move(pimpl) } -{ -} - -service::TypeNames Mutation::getTypeNames() const noexcept -{ - return { - R"gql(Mutation)gql"sv - }; -} - -service::ResolverMap Mutation::getResolvers() const noexcept -{ - return { - { R"gql(mutateDog)gql"sv, [this](service::ResolverParams&& params) { return resolveMutateDog(std::move(params)); } }, - { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } } - }; -} - -void Mutation::beginSelectionSet(const service::SelectionSetParams& params) const -{ - _pimpl->beginSelectionSet(params); -} - -void Mutation::endSelectionSet(const service::SelectionSetParams& params) const -{ - _pimpl->endSelectionSet(params); -} - -service::AwaitableResolver Mutation::resolveMutateDog(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->applyMutateDog(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Mutation::resolve_typename(service::ResolverParams&& params) const -{ - return service::ModifiedResult::convert(std::string{ R"gql(Mutation)gql" }, std::move(params)); -} - -MutateDogResult::MutateDogResult(std::unique_ptr&& pimpl) noexcept - : service::Object{ getTypeNames(), getResolvers() } - , _pimpl { std::move(pimpl) } -{ -} - -service::TypeNames MutateDogResult::getTypeNames() const noexcept -{ - return { - R"gql(MutateDogResult)gql"sv - }; -} - -service::ResolverMap MutateDogResult::getResolvers() const noexcept -{ - return { - { R"gql(id)gql"sv, [this](service::ResolverParams&& params) { return resolveId(std::move(params)); } }, - { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } } - }; -} - -void MutateDogResult::beginSelectionSet(const service::SelectionSetParams& params) const -{ - _pimpl->beginSelectionSet(params); -} - -void MutateDogResult::endSelectionSet(const service::SelectionSetParams& params) const -{ - _pimpl->endSelectionSet(params); -} - -service::AwaitableResolver MutateDogResult::resolveId(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getId(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver MutateDogResult::resolve_typename(service::ResolverParams&& params) const -{ - return service::ModifiedResult::convert(std::string{ R"gql(MutateDogResult)gql" }, std::move(params)); -} - -Subscription::Subscription(std::unique_ptr&& pimpl) noexcept - : service::Object{ getTypeNames(), getResolvers() } - , _pimpl { std::move(pimpl) } -{ -} - -service::TypeNames Subscription::getTypeNames() const noexcept -{ - return { - R"gql(Subscription)gql"sv - }; -} - -service::ResolverMap Subscription::getResolvers() const noexcept -{ - return { - { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, - { R"gql(newMessage)gql"sv, [this](service::ResolverParams&& params) { return resolveNewMessage(std::move(params)); } }, - { R"gql(disallowedSecondRootField)gql"sv, [this](service::ResolverParams&& params) { return resolveDisallowedSecondRootField(std::move(params)); } } - }; -} - -void Subscription::beginSelectionSet(const service::SelectionSetParams& params) const -{ - _pimpl->beginSelectionSet(params); -} - -void Subscription::endSelectionSet(const service::SelectionSetParams& params) const -{ - _pimpl->endSelectionSet(params); -} - -service::AwaitableResolver Subscription::resolveNewMessage(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getNewMessage(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Subscription::resolveDisallowedSecondRootField(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getDisallowedSecondRootField(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Subscription::resolve_typename(service::ResolverParams&& params) const -{ - return service::ModifiedResult::convert(std::string{ R"gql(Subscription)gql" }, std::move(params)); -} - -Message::Message(std::unique_ptr&& pimpl) noexcept - : service::Object{ getTypeNames(), getResolvers() } - , _pimpl { std::move(pimpl) } -{ -} - -service::TypeNames Message::getTypeNames() const noexcept -{ - return { - R"gql(Message)gql"sv - }; -} - -service::ResolverMap Message::getResolvers() const noexcept -{ - return { - { R"gql(body)gql"sv, [this](service::ResolverParams&& params) { return resolveBody(std::move(params)); } }, - { R"gql(sender)gql"sv, [this](service::ResolverParams&& params) { return resolveSender(std::move(params)); } }, - { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } } - }; -} - -void Message::beginSelectionSet(const service::SelectionSetParams& params) const -{ - _pimpl->beginSelectionSet(params); -} - -void Message::endSelectionSet(const service::SelectionSetParams& params) const -{ - _pimpl->endSelectionSet(params); -} - -service::AwaitableResolver Message::resolveBody(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getBody(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Message::resolveSender(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getSender(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Message::resolve_typename(service::ResolverParams&& params) const -{ - return service::ModifiedResult::convert(std::string{ R"gql(Message)gql" }, std::move(params)); -} - -Arguments::Arguments(std::unique_ptr&& pimpl) noexcept - : service::Object{ getTypeNames(), getResolvers() } - , _pimpl { std::move(pimpl) } -{ -} - -service::TypeNames Arguments::getTypeNames() const noexcept -{ - return { - R"gql(Arguments)gql"sv - }; -} - -service::ResolverMap Arguments::getResolvers() const noexcept -{ - return { - { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, - { R"gql(intArgField)gql"sv, [this](service::ResolverParams&& params) { return resolveIntArgField(std::move(params)); } }, - { R"gql(multipleReqs)gql"sv, [this](service::ResolverParams&& params) { return resolveMultipleReqs(std::move(params)); } }, - { R"gql(floatArgField)gql"sv, [this](service::ResolverParams&& params) { return resolveFloatArgField(std::move(params)); } }, - { R"gql(booleanArgField)gql"sv, [this](service::ResolverParams&& params) { return resolveBooleanArgField(std::move(params)); } }, - { R"gql(booleanListArgField)gql"sv, [this](service::ResolverParams&& params) { return resolveBooleanListArgField(std::move(params)); } }, - { R"gql(nonNullBooleanArgField)gql"sv, [this](service::ResolverParams&& params) { return resolveNonNullBooleanArgField(std::move(params)); } }, - { R"gql(nonNullBooleanListField)gql"sv, [this](service::ResolverParams&& params) { return resolveNonNullBooleanListField(std::move(params)); } }, - { R"gql(optionalNonNullBooleanArgField)gql"sv, [this](service::ResolverParams&& params) { return resolveOptionalNonNullBooleanArgField(std::move(params)); } } - }; -} - -void Arguments::beginSelectionSet(const service::SelectionSetParams& params) const -{ - _pimpl->beginSelectionSet(params); -} - -void Arguments::endSelectionSet(const service::SelectionSetParams& params) const -{ - _pimpl->endSelectionSet(params); -} - -service::AwaitableResolver Arguments::resolveMultipleReqs(service::ResolverParams&& params) const -{ - auto argX = service::ModifiedArgument::require("x", params.arguments); - auto argY = service::ModifiedArgument::require("y", params.arguments); - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getMultipleReqs(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argX), std::move(argY)); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Arguments::resolveBooleanArgField(service::ResolverParams&& params) const -{ - auto argBooleanArg = service::ModifiedArgument::require("booleanArg", params.arguments); - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getBooleanArgField(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argBooleanArg)); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Arguments::resolveFloatArgField(service::ResolverParams&& params) const -{ - auto argFloatArg = service::ModifiedArgument::require("floatArg", params.arguments); - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getFloatArgField(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argFloatArg)); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Arguments::resolveIntArgField(service::ResolverParams&& params) const -{ - auto argIntArg = service::ModifiedArgument::require("intArg", params.arguments); - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getIntArgField(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argIntArg)); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Arguments::resolveNonNullBooleanArgField(service::ResolverParams&& params) const -{ - auto argNonNullBooleanArg = service::ModifiedArgument::require("nonNullBooleanArg", params.arguments); - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getNonNullBooleanArgField(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argNonNullBooleanArg)); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Arguments::resolveNonNullBooleanListField(service::ResolverParams&& params) const -{ - auto argNonNullBooleanListArg = service::ModifiedArgument::require("nonNullBooleanListArg", params.arguments); - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getNonNullBooleanListField(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argNonNullBooleanListArg)); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Arguments::resolveBooleanListArgField(service::ResolverParams&& params) const -{ - auto argBooleanListArg = service::ModifiedArgument::require("booleanListArg", params.arguments); - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getBooleanListArgField(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argBooleanListArg)); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Arguments::resolveOptionalNonNullBooleanArgField(service::ResolverParams&& params) const -{ - const auto defaultArguments = []() - { - response::Value values(response::Type::Map); - response::Value entry; - - entry = response::Value(false); - values.emplace_back("optionalBooleanArg", std::move(entry)); - - return values; - }(); - - auto pairOptionalBooleanArg = service::ModifiedArgument::find("optionalBooleanArg", params.arguments); - auto argOptionalBooleanArg = (pairOptionalBooleanArg.second - ? std::move(pairOptionalBooleanArg.first) - : service::ModifiedArgument::require("optionalBooleanArg", defaultArguments)); - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getOptionalNonNullBooleanArgField(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argOptionalBooleanArg)); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Arguments::resolve_typename(service::ResolverParams&& params) const -{ - return service::ModifiedResult::convert(std::string{ R"gql(Arguments)gql" }, std::move(params)); -} - -} // namespace object Operations::Operations(std::shared_ptr query, std::shared_ptr mutation, std::shared_ptr subscription) : service::Request({ @@ -1032,120 +178,23 @@ void AddTypesToSchema(const std::shared_ptr& schema) schema::InputValue::Make(R"gql(owner)gql"sv, R"md()md"sv, schema->LookupType(R"gql(String)gql"sv), R"gql()gql"sv) }); - typeSentient->AddFields({ - schema::Field::Make(R"gql(name)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(String)gql"sv))) - }); - typePet->AddFields({ - schema::Field::Make(R"gql(name)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(String)gql"sv))) - }); + AddSentientDetails(typeSentient, schema); + AddPetDetails(typePet, schema); - typeCatOrDog->AddPossibleTypes({ - schema->LookupType(R"gql(Cat)gql"sv), - schema->LookupType(R"gql(Dog)gql"sv) - }); - typeDogOrHuman->AddPossibleTypes({ - schema->LookupType(R"gql(Dog)gql"sv), - schema->LookupType(R"gql(Human)gql"sv) - }); - typeHumanOrAlien->AddPossibleTypes({ - schema->LookupType(R"gql(Human)gql"sv), - schema->LookupType(R"gql(Alien)gql"sv) - }); + AddCatOrDogDetails(typeCatOrDog, schema); + AddDogOrHumanDetails(typeDogOrHuman, schema); + AddHumanOrAlienDetails(typeHumanOrAlien, schema); - typeQuery->AddFields({ - schema::Field::Make(R"gql(dog)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(Dog)gql"sv)), - schema::Field::Make(R"gql(human)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(Human)gql"sv)), - schema::Field::Make(R"gql(pet)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(Pet)gql"sv)), - schema::Field::Make(R"gql(catOrDog)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(CatOrDog)gql"sv)), - schema::Field::Make(R"gql(arguments)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(Arguments)gql"sv)), - schema::Field::Make(R"gql(findDog)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(Dog)gql"sv), { - schema::InputValue::Make(R"gql(complex)gql"sv, R"md()md"sv, schema->LookupType(R"gql(ComplexInput)gql"sv), R"gql()gql"sv) - }), - schema::Field::Make(R"gql(booleanList)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(Boolean)gql"sv), { - schema::InputValue::Make(R"gql(booleanListArg)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Boolean)gql"sv))), R"gql()gql"sv) - }) - }); - typeDog->AddInterfaces({ - typePet - }); - typeDog->AddFields({ - schema::Field::Make(R"gql(name)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(String)gql"sv))), - schema::Field::Make(R"gql(nickname)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(String)gql"sv)), - schema::Field::Make(R"gql(barkVolume)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(Int)gql"sv)), - schema::Field::Make(R"gql(doesKnowCommand)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Boolean)gql"sv)), { - schema::InputValue::Make(R"gql(dogCommand)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(DogCommand)gql"sv)), R"gql()gql"sv) - }), - schema::Field::Make(R"gql(isHousetrained)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Boolean)gql"sv)), { - schema::InputValue::Make(R"gql(atOtherHomes)gql"sv, R"md()md"sv, schema->LookupType(R"gql(Boolean)gql"sv), R"gql()gql"sv) - }), - schema::Field::Make(R"gql(owner)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(Human)gql"sv)) - }); - typeAlien->AddInterfaces({ - typeSentient - }); - typeAlien->AddFields({ - schema::Field::Make(R"gql(name)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(String)gql"sv))), - schema::Field::Make(R"gql(homePlanet)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(String)gql"sv)) - }); - typeHuman->AddInterfaces({ - typeSentient - }); - typeHuman->AddFields({ - schema::Field::Make(R"gql(name)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(String)gql"sv))), - schema::Field::Make(R"gql(pets)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Pet)gql"sv))))) - }); - typeCat->AddInterfaces({ - typePet - }); - typeCat->AddFields({ - schema::Field::Make(R"gql(name)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(String)gql"sv))), - schema::Field::Make(R"gql(nickname)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(String)gql"sv)), - schema::Field::Make(R"gql(doesKnowCommand)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Boolean)gql"sv)), { - schema::InputValue::Make(R"gql(catCommand)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(CatCommand)gql"sv)), R"gql()gql"sv) - }), - schema::Field::Make(R"gql(meowVolume)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(Int)gql"sv)) - }); - typeMutation->AddFields({ - schema::Field::Make(R"gql(mutateDog)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(MutateDogResult)gql"sv)) - }); - typeMutateDogResult->AddFields({ - schema::Field::Make(R"gql(id)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ID)gql"sv))) - }); - typeSubscription->AddFields({ - schema::Field::Make(R"gql(newMessage)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Message)gql"sv))), - schema::Field::Make(R"gql(disallowedSecondRootField)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Boolean)gql"sv))) - }); - typeMessage->AddFields({ - schema::Field::Make(R"gql(body)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(String)gql"sv)), - schema::Field::Make(R"gql(sender)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ID)gql"sv))) - }); - typeArguments->AddFields({ - schema::Field::Make(R"gql(multipleReqs)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Int)gql"sv)), { - schema::InputValue::Make(R"gql(x)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Int)gql"sv)), R"gql()gql"sv), - schema::InputValue::Make(R"gql(y)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Int)gql"sv)), R"gql()gql"sv) - }), - schema::Field::Make(R"gql(booleanArgField)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(Boolean)gql"sv), { - schema::InputValue::Make(R"gql(booleanArg)gql"sv, R"md()md"sv, schema->LookupType(R"gql(Boolean)gql"sv), R"gql()gql"sv) - }), - schema::Field::Make(R"gql(floatArgField)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(Float)gql"sv), { - schema::InputValue::Make(R"gql(floatArg)gql"sv, R"md()md"sv, schema->LookupType(R"gql(Float)gql"sv), R"gql()gql"sv) - }), - schema::Field::Make(R"gql(intArgField)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(Int)gql"sv), { - schema::InputValue::Make(R"gql(intArg)gql"sv, R"md()md"sv, schema->LookupType(R"gql(Int)gql"sv), R"gql()gql"sv) - }), - schema::Field::Make(R"gql(nonNullBooleanArgField)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Boolean)gql"sv)), { - schema::InputValue::Make(R"gql(nonNullBooleanArg)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Boolean)gql"sv)), R"gql()gql"sv) - }), - schema::Field::Make(R"gql(nonNullBooleanListField)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Boolean)gql"sv))), { - schema::InputValue::Make(R"gql(nonNullBooleanListArg)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Boolean)gql"sv))), R"gql()gql"sv) - }), - schema::Field::Make(R"gql(booleanListArgField)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::LIST, schema->LookupType(R"gql(Boolean)gql"sv)), { - schema::InputValue::Make(R"gql(booleanListArg)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->LookupType(R"gql(Boolean)gql"sv))), R"gql()gql"sv) - }), - schema::Field::Make(R"gql(optionalNonNullBooleanArgField)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Boolean)gql"sv)), { - schema::InputValue::Make(R"gql(optionalBooleanArg)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Boolean)gql"sv)), R"gql(false)gql"sv) - }) - }); + AddQueryDetails(typeQuery, schema); + AddDogDetails(typeDog, schema); + AddAlienDetails(typeAlien, schema); + AddHumanDetails(typeHuman, schema); + AddCatDetails(typeCat, schema); + AddMutationDetails(typeMutation, schema); + AddMutateDogResultDetails(typeMutateDogResult, schema); + AddSubscriptionDetails(typeSubscription, schema); + AddMessageDetails(typeMessage, schema); + AddArgumentsDetails(typeArguments, schema); schema->AddQueryType(typeQuery); schema->AddMutationType(typeMutation); diff --git a/samples/validation/schema/ValidationSchema.h b/samples/validation/schema/ValidationSchema.h index f8b632a8..13375dc6 100644 --- a/samples/validation/schema/ValidationSchema.h +++ b/samples/validation/schema/ValidationSchema.h @@ -59,2234 +59,6 @@ class Subscription; class Message; class Arguments; -class Sentient - : public service::Object -{ -private: - struct Concept - { - virtual ~Concept() = default; - - virtual service::TypeNames getTypeNames() const noexcept = 0; - virtual service::ResolverMap getResolvers() const noexcept = 0; - - virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - }; - - template - struct Model - : Concept - { - Model(std::shared_ptr&& pimpl) noexcept - : _pimpl { std::move(pimpl) } - { - } - - service::TypeNames getTypeNames() const noexcept final - { - return _pimpl->getTypeNames(); - } - - service::ResolverMap getResolvers() const noexcept final - { - return _pimpl->getResolvers(); - } - - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - _pimpl->beginSelectionSet(params); - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - _pimpl->endSelectionSet(params); - } - - private: - const std::shared_ptr _pimpl; - }; - - Sentient(std::unique_ptr&& pimpl) noexcept; - - void beginSelectionSet(const service::SelectionSetParams& params) const final; - void endSelectionSet(const service::SelectionSetParams& params) const final; - - const std::unique_ptr _pimpl; - -public: - template - Sentient(std::shared_ptr pimpl) noexcept - : Sentient { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } - { - static_assert(T::template implements(), "Sentient is not implemented"); - } -}; - -class Pet - : public service::Object -{ -private: - struct Concept - { - virtual ~Concept() = default; - - virtual service::TypeNames getTypeNames() const noexcept = 0; - virtual service::ResolverMap getResolvers() const noexcept = 0; - - virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - }; - - template - struct Model - : Concept - { - Model(std::shared_ptr&& pimpl) noexcept - : _pimpl { std::move(pimpl) } - { - } - - service::TypeNames getTypeNames() const noexcept final - { - return _pimpl->getTypeNames(); - } - - service::ResolverMap getResolvers() const noexcept final - { - return _pimpl->getResolvers(); - } - - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - _pimpl->beginSelectionSet(params); - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - _pimpl->endSelectionSet(params); - } - - private: - const std::shared_ptr _pimpl; - }; - - Pet(std::unique_ptr&& pimpl) noexcept; - - void beginSelectionSet(const service::SelectionSetParams& params) const final; - void endSelectionSet(const service::SelectionSetParams& params) const final; - - const std::unique_ptr _pimpl; - -public: - template - Pet(std::shared_ptr pimpl) noexcept - : Pet { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } - { - static_assert(T::template implements(), "Pet is not implemented"); - } -}; - -class CatOrDog - : public service::Object -{ -private: - struct Concept - { - virtual ~Concept() = default; - - virtual service::TypeNames getTypeNames() const noexcept = 0; - virtual service::ResolverMap getResolvers() const noexcept = 0; - - virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - }; - - template - struct Model - : Concept - { - Model(std::shared_ptr&& pimpl) noexcept - : _pimpl { std::move(pimpl) } - { - } - - service::TypeNames getTypeNames() const noexcept final - { - return _pimpl->getTypeNames(); - } - - service::ResolverMap getResolvers() const noexcept final - { - return _pimpl->getResolvers(); - } - - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - _pimpl->beginSelectionSet(params); - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - _pimpl->endSelectionSet(params); - } - - private: - const std::shared_ptr _pimpl; - }; - - CatOrDog(std::unique_ptr&& pimpl) noexcept; - - void beginSelectionSet(const service::SelectionSetParams& params) const final; - void endSelectionSet(const service::SelectionSetParams& params) const final; - - const std::unique_ptr _pimpl; - -public: - template - CatOrDog(std::shared_ptr pimpl) noexcept - : CatOrDog { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } - { - static_assert(T::template implements(), "CatOrDog is not implemented"); - } -}; - -class DogOrHuman - : public service::Object -{ -private: - struct Concept - { - virtual ~Concept() = default; - - virtual service::TypeNames getTypeNames() const noexcept = 0; - virtual service::ResolverMap getResolvers() const noexcept = 0; - - virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - }; - - template - struct Model - : Concept - { - Model(std::shared_ptr&& pimpl) noexcept - : _pimpl { std::move(pimpl) } - { - } - - service::TypeNames getTypeNames() const noexcept final - { - return _pimpl->getTypeNames(); - } - - service::ResolverMap getResolvers() const noexcept final - { - return _pimpl->getResolvers(); - } - - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - _pimpl->beginSelectionSet(params); - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - _pimpl->endSelectionSet(params); - } - - private: - const std::shared_ptr _pimpl; - }; - - DogOrHuman(std::unique_ptr&& pimpl) noexcept; - - void beginSelectionSet(const service::SelectionSetParams& params) const final; - void endSelectionSet(const service::SelectionSetParams& params) const final; - - const std::unique_ptr _pimpl; - -public: - template - DogOrHuman(std::shared_ptr pimpl) noexcept - : DogOrHuman { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } - { - static_assert(T::template implements(), "DogOrHuman is not implemented"); - } -}; - -class HumanOrAlien - : public service::Object -{ -private: - struct Concept - { - virtual ~Concept() = default; - - virtual service::TypeNames getTypeNames() const noexcept = 0; - virtual service::ResolverMap getResolvers() const noexcept = 0; - - virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - }; - - template - struct Model - : Concept - { - Model(std::shared_ptr&& pimpl) noexcept - : _pimpl { std::move(pimpl) } - { - } - - service::TypeNames getTypeNames() const noexcept final - { - return _pimpl->getTypeNames(); - } - - service::ResolverMap getResolvers() const noexcept final - { - return _pimpl->getResolvers(); - } - - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - _pimpl->beginSelectionSet(params); - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - _pimpl->endSelectionSet(params); - } - - private: - const std::shared_ptr _pimpl; - }; - - HumanOrAlien(std::unique_ptr&& pimpl) noexcept; - - void beginSelectionSet(const service::SelectionSetParams& params) const final; - void endSelectionSet(const service::SelectionSetParams& params) const final; - - const std::unique_ptr _pimpl; - -public: - template - HumanOrAlien(std::shared_ptr pimpl) noexcept - : HumanOrAlien { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } - { - static_assert(T::template implements(), "HumanOrAlien is not implemented"); - } -}; - -namespace implements { - -template -concept DogIs = std::is_same_v || std::is_same_v || std::is_same_v; - -template -concept AlienIs = std::is_same_v || std::is_same_v; - -template -concept HumanIs = std::is_same_v || std::is_same_v || std::is_same_v; - -template -concept CatIs = std::is_same_v || std::is_same_v; - -} // namespace implements - -namespace methods { -namespace QueryHas { - -template -concept getDogWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getDog(std::move(params)) } }; -}; - -template -concept getDog = requires (TImpl impl) -{ - { service::FieldResult> { impl.getDog() } }; -}; - -template -concept getHumanWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getHuman(std::move(params)) } }; -}; - -template -concept getHuman = requires (TImpl impl) -{ - { service::FieldResult> { impl.getHuman() } }; -}; - -template -concept getPetWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getPet(std::move(params)) } }; -}; - -template -concept getPet = requires (TImpl impl) -{ - { service::FieldResult> { impl.getPet() } }; -}; - -template -concept getCatOrDogWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getCatOrDog(std::move(params)) } }; -}; - -template -concept getCatOrDog = requires (TImpl impl) -{ - { service::FieldResult> { impl.getCatOrDog() } }; -}; - -template -concept getArgumentsWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getArguments(std::move(params)) } }; -}; - -template -concept getArguments = requires (TImpl impl) -{ - { service::FieldResult> { impl.getArguments() } }; -}; - -template -concept getFindDogWithParams = requires (TImpl impl, service::FieldParams params, std::optional complexArg) -{ - { service::FieldResult> { impl.getFindDog(std::move(params), std::move(complexArg)) } }; -}; - -template -concept getFindDog = requires (TImpl impl, std::optional complexArg) -{ - { service::FieldResult> { impl.getFindDog(std::move(complexArg)) } }; -}; - -template -concept getBooleanListWithParams = requires (TImpl impl, service::FieldParams params, std::optional> booleanListArgArg) -{ - { service::FieldResult> { impl.getBooleanList(std::move(params), std::move(booleanListArgArg)) } }; -}; - -template -concept getBooleanList = requires (TImpl impl, std::optional> booleanListArgArg) -{ - { service::FieldResult> { impl.getBooleanList(std::move(booleanListArgArg)) } }; -}; - -template -concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) -{ - { impl.beginSelectionSet(params) }; -}; - -template -concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) -{ - { impl.endSelectionSet(params) }; -}; - -} // namespace QueryHas - -namespace DogHas { - -template -concept getNameWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult { impl.getName(std::move(params)) } }; -}; - -template -concept getName = requires (TImpl impl) -{ - { service::FieldResult { impl.getName() } }; -}; - -template -concept getNicknameWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getNickname(std::move(params)) } }; -}; - -template -concept getNickname = requires (TImpl impl) -{ - { service::FieldResult> { impl.getNickname() } }; -}; - -template -concept getBarkVolumeWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getBarkVolume(std::move(params)) } }; -}; - -template -concept getBarkVolume = requires (TImpl impl) -{ - { service::FieldResult> { impl.getBarkVolume() } }; -}; - -template -concept getDoesKnowCommandWithParams = requires (TImpl impl, service::FieldParams params, DogCommand dogCommandArg) -{ - { service::FieldResult { impl.getDoesKnowCommand(std::move(params), std::move(dogCommandArg)) } }; -}; - -template -concept getDoesKnowCommand = requires (TImpl impl, DogCommand dogCommandArg) -{ - { service::FieldResult { impl.getDoesKnowCommand(std::move(dogCommandArg)) } }; -}; - -template -concept getIsHousetrainedWithParams = requires (TImpl impl, service::FieldParams params, std::optional atOtherHomesArg) -{ - { service::FieldResult { impl.getIsHousetrained(std::move(params), std::move(atOtherHomesArg)) } }; -}; - -template -concept getIsHousetrained = requires (TImpl impl, std::optional atOtherHomesArg) -{ - { service::FieldResult { impl.getIsHousetrained(std::move(atOtherHomesArg)) } }; -}; - -template -concept getOwnerWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getOwner(std::move(params)) } }; -}; - -template -concept getOwner = requires (TImpl impl) -{ - { service::FieldResult> { impl.getOwner() } }; -}; - -template -concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) -{ - { impl.beginSelectionSet(params) }; -}; - -template -concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) -{ - { impl.endSelectionSet(params) }; -}; - -} // namespace DogHas - -namespace AlienHas { - -template -concept getNameWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult { impl.getName(std::move(params)) } }; -}; - -template -concept getName = requires (TImpl impl) -{ - { service::FieldResult { impl.getName() } }; -}; - -template -concept getHomePlanetWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getHomePlanet(std::move(params)) } }; -}; - -template -concept getHomePlanet = requires (TImpl impl) -{ - { service::FieldResult> { impl.getHomePlanet() } }; -}; - -template -concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) -{ - { impl.beginSelectionSet(params) }; -}; - -template -concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) -{ - { impl.endSelectionSet(params) }; -}; - -} // namespace AlienHas - -namespace HumanHas { - -template -concept getNameWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult { impl.getName(std::move(params)) } }; -}; - -template -concept getName = requires (TImpl impl) -{ - { service::FieldResult { impl.getName() } }; -}; - -template -concept getPetsWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult>> { impl.getPets(std::move(params)) } }; -}; - -template -concept getPets = requires (TImpl impl) -{ - { service::FieldResult>> { impl.getPets() } }; -}; - -template -concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) -{ - { impl.beginSelectionSet(params) }; -}; - -template -concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) -{ - { impl.endSelectionSet(params) }; -}; - -} // namespace HumanHas - -namespace CatHas { - -template -concept getNameWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult { impl.getName(std::move(params)) } }; -}; - -template -concept getName = requires (TImpl impl) -{ - { service::FieldResult { impl.getName() } }; -}; - -template -concept getNicknameWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getNickname(std::move(params)) } }; -}; - -template -concept getNickname = requires (TImpl impl) -{ - { service::FieldResult> { impl.getNickname() } }; -}; - -template -concept getDoesKnowCommandWithParams = requires (TImpl impl, service::FieldParams params, CatCommand catCommandArg) -{ - { service::FieldResult { impl.getDoesKnowCommand(std::move(params), std::move(catCommandArg)) } }; -}; - -template -concept getDoesKnowCommand = requires (TImpl impl, CatCommand catCommandArg) -{ - { service::FieldResult { impl.getDoesKnowCommand(std::move(catCommandArg)) } }; -}; - -template -concept getMeowVolumeWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getMeowVolume(std::move(params)) } }; -}; - -template -concept getMeowVolume = requires (TImpl impl) -{ - { service::FieldResult> { impl.getMeowVolume() } }; -}; - -template -concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) -{ - { impl.beginSelectionSet(params) }; -}; - -template -concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) -{ - { impl.endSelectionSet(params) }; -}; - -} // namespace CatHas - -namespace MutationHas { - -template -concept applyMutateDogWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.applyMutateDog(std::move(params)) } }; -}; - -template -concept applyMutateDog = requires (TImpl impl) -{ - { service::FieldResult> { impl.applyMutateDog() } }; -}; - -template -concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) -{ - { impl.beginSelectionSet(params) }; -}; - -template -concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) -{ - { impl.endSelectionSet(params) }; -}; - -} // namespace MutationHas - -namespace MutateDogResultHas { - -template -concept getIdWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult { impl.getId(std::move(params)) } }; -}; - -template -concept getId = requires (TImpl impl) -{ - { service::FieldResult { impl.getId() } }; -}; - -template -concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) -{ - { impl.beginSelectionSet(params) }; -}; - -template -concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) -{ - { impl.endSelectionSet(params) }; -}; - -} // namespace MutateDogResultHas - -namespace SubscriptionHas { - -template -concept getNewMessageWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getNewMessage(std::move(params)) } }; -}; - -template -concept getNewMessage = requires (TImpl impl) -{ - { service::FieldResult> { impl.getNewMessage() } }; -}; - -template -concept getDisallowedSecondRootFieldWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult { impl.getDisallowedSecondRootField(std::move(params)) } }; -}; - -template -concept getDisallowedSecondRootField = requires (TImpl impl) -{ - { service::FieldResult { impl.getDisallowedSecondRootField() } }; -}; - -template -concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) -{ - { impl.beginSelectionSet(params) }; -}; - -template -concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) -{ - { impl.endSelectionSet(params) }; -}; - -} // namespace SubscriptionHas - -namespace MessageHas { - -template -concept getBodyWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getBody(std::move(params)) } }; -}; - -template -concept getBody = requires (TImpl impl) -{ - { service::FieldResult> { impl.getBody() } }; -}; - -template -concept getSenderWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult { impl.getSender(std::move(params)) } }; -}; - -template -concept getSender = requires (TImpl impl) -{ - { service::FieldResult { impl.getSender() } }; -}; - -template -concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) -{ - { impl.beginSelectionSet(params) }; -}; - -template -concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) -{ - { impl.endSelectionSet(params) }; -}; - -} // namespace MessageHas - -namespace ArgumentsHas { - -template -concept getMultipleReqsWithParams = requires (TImpl impl, service::FieldParams params, int xArg, int yArg) -{ - { service::FieldResult { impl.getMultipleReqs(std::move(params), std::move(xArg), std::move(yArg)) } }; -}; - -template -concept getMultipleReqs = requires (TImpl impl, int xArg, int yArg) -{ - { service::FieldResult { impl.getMultipleReqs(std::move(xArg), std::move(yArg)) } }; -}; - -template -concept getBooleanArgFieldWithParams = requires (TImpl impl, service::FieldParams params, std::optional booleanArgArg) -{ - { service::FieldResult> { impl.getBooleanArgField(std::move(params), std::move(booleanArgArg)) } }; -}; - -template -concept getBooleanArgField = requires (TImpl impl, std::optional booleanArgArg) -{ - { service::FieldResult> { impl.getBooleanArgField(std::move(booleanArgArg)) } }; -}; - -template -concept getFloatArgFieldWithParams = requires (TImpl impl, service::FieldParams params, std::optional floatArgArg) -{ - { service::FieldResult> { impl.getFloatArgField(std::move(params), std::move(floatArgArg)) } }; -}; - -template -concept getFloatArgField = requires (TImpl impl, std::optional floatArgArg) -{ - { service::FieldResult> { impl.getFloatArgField(std::move(floatArgArg)) } }; -}; - -template -concept getIntArgFieldWithParams = requires (TImpl impl, service::FieldParams params, std::optional intArgArg) -{ - { service::FieldResult> { impl.getIntArgField(std::move(params), std::move(intArgArg)) } }; -}; - -template -concept getIntArgField = requires (TImpl impl, std::optional intArgArg) -{ - { service::FieldResult> { impl.getIntArgField(std::move(intArgArg)) } }; -}; - -template -concept getNonNullBooleanArgFieldWithParams = requires (TImpl impl, service::FieldParams params, bool nonNullBooleanArgArg) -{ - { service::FieldResult { impl.getNonNullBooleanArgField(std::move(params), std::move(nonNullBooleanArgArg)) } }; -}; - -template -concept getNonNullBooleanArgField = requires (TImpl impl, bool nonNullBooleanArgArg) -{ - { service::FieldResult { impl.getNonNullBooleanArgField(std::move(nonNullBooleanArgArg)) } }; -}; - -template -concept getNonNullBooleanListFieldWithParams = requires (TImpl impl, service::FieldParams params, std::optional> nonNullBooleanListArgArg) -{ - { service::FieldResult>> { impl.getNonNullBooleanListField(std::move(params), std::move(nonNullBooleanListArgArg)) } }; -}; - -template -concept getNonNullBooleanListField = requires (TImpl impl, std::optional> nonNullBooleanListArgArg) -{ - { service::FieldResult>> { impl.getNonNullBooleanListField(std::move(nonNullBooleanListArgArg)) } }; -}; - -template -concept getBooleanListArgFieldWithParams = requires (TImpl impl, service::FieldParams params, std::vector> booleanListArgArg) -{ - { service::FieldResult>>> { impl.getBooleanListArgField(std::move(params), std::move(booleanListArgArg)) } }; -}; - -template -concept getBooleanListArgField = requires (TImpl impl, std::vector> booleanListArgArg) -{ - { service::FieldResult>>> { impl.getBooleanListArgField(std::move(booleanListArgArg)) } }; -}; - -template -concept getOptionalNonNullBooleanArgFieldWithParams = requires (TImpl impl, service::FieldParams params, bool optionalBooleanArgArg) -{ - { service::FieldResult { impl.getOptionalNonNullBooleanArgField(std::move(params), std::move(optionalBooleanArgArg)) } }; -}; - -template -concept getOptionalNonNullBooleanArgField = requires (TImpl impl, bool optionalBooleanArgArg) -{ - { service::FieldResult { impl.getOptionalNonNullBooleanArgField(std::move(optionalBooleanArgArg)) } }; -}; - -template -concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) -{ - { impl.beginSelectionSet(params) }; -}; - -template -concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) -{ - { impl.endSelectionSet(params) }; -}; - -} // namespace ArgumentsHas -} // namespace methods - -class Query - : public service::Object -{ -private: - service::AwaitableResolver resolveDog(service::ResolverParams&& params) const; - service::AwaitableResolver resolveHuman(service::ResolverParams&& params) const; - service::AwaitableResolver resolvePet(service::ResolverParams&& params) const; - service::AwaitableResolver resolveCatOrDog(service::ResolverParams&& params) const; - service::AwaitableResolver resolveArguments(service::ResolverParams&& params) const; - service::AwaitableResolver resolveFindDog(service::ResolverParams&& params) const; - service::AwaitableResolver resolveBooleanList(service::ResolverParams&& params) const; - - service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; - - struct Concept - { - virtual ~Concept() = default; - - virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - - virtual service::FieldResult> getDog(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getHuman(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getPet(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getCatOrDog(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getArguments(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getFindDog(service::FieldParams&& params, std::optional&& complexArg) const = 0; - virtual service::FieldResult> getBooleanList(service::FieldParams&& params, std::optional>&& booleanListArgArg) const = 0; - }; - - template - struct Model - : Concept - { - Model(std::shared_ptr&& pimpl) noexcept - : _pimpl { std::move(pimpl) } - { - } - - service::FieldResult> getDog(service::FieldParams&& params) const final - { - if constexpr (methods::QueryHas::getDogWithParams) - { - return { _pimpl->getDog(std::move(params)) }; - } - else if constexpr (methods::QueryHas::getDog) - { - return { _pimpl->getDog() }; - } - else - { - throw std::runtime_error(R"ex(Query::getDog is not implemented)ex"); - } - } - - service::FieldResult> getHuman(service::FieldParams&& params) const final - { - if constexpr (methods::QueryHas::getHumanWithParams) - { - return { _pimpl->getHuman(std::move(params)) }; - } - else if constexpr (methods::QueryHas::getHuman) - { - return { _pimpl->getHuman() }; - } - else - { - throw std::runtime_error(R"ex(Query::getHuman is not implemented)ex"); - } - } - - service::FieldResult> getPet(service::FieldParams&& params) const final - { - if constexpr (methods::QueryHas::getPetWithParams) - { - return { _pimpl->getPet(std::move(params)) }; - } - else if constexpr (methods::QueryHas::getPet) - { - return { _pimpl->getPet() }; - } - else - { - throw std::runtime_error(R"ex(Query::getPet is not implemented)ex"); - } - } - - service::FieldResult> getCatOrDog(service::FieldParams&& params) const final - { - if constexpr (methods::QueryHas::getCatOrDogWithParams) - { - return { _pimpl->getCatOrDog(std::move(params)) }; - } - else if constexpr (methods::QueryHas::getCatOrDog) - { - return { _pimpl->getCatOrDog() }; - } - else - { - throw std::runtime_error(R"ex(Query::getCatOrDog is not implemented)ex"); - } - } - - service::FieldResult> getArguments(service::FieldParams&& params) const final - { - if constexpr (methods::QueryHas::getArgumentsWithParams) - { - return { _pimpl->getArguments(std::move(params)) }; - } - else if constexpr (methods::QueryHas::getArguments) - { - return { _pimpl->getArguments() }; - } - else - { - throw std::runtime_error(R"ex(Query::getArguments is not implemented)ex"); - } - } - - service::FieldResult> getFindDog(service::FieldParams&& params, std::optional&& complexArg) const final - { - if constexpr (methods::QueryHas::getFindDogWithParams) - { - return { _pimpl->getFindDog(std::move(params), std::move(complexArg)) }; - } - else if constexpr (methods::QueryHas::getFindDog) - { - return { _pimpl->getFindDog(std::move(complexArg)) }; - } - else - { - throw std::runtime_error(R"ex(Query::getFindDog is not implemented)ex"); - } - } - - service::FieldResult> getBooleanList(service::FieldParams&& params, std::optional>&& booleanListArgArg) const final - { - if constexpr (methods::QueryHas::getBooleanListWithParams) - { - return { _pimpl->getBooleanList(std::move(params), std::move(booleanListArgArg)) }; - } - else if constexpr (methods::QueryHas::getBooleanList) - { - return { _pimpl->getBooleanList(std::move(booleanListArgArg)) }; - } - else - { - throw std::runtime_error(R"ex(Query::getBooleanList is not implemented)ex"); - } - } - - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (methods::QueryHas::beginSelectionSet) - { - _pimpl->beginSelectionSet(params); - } - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (methods::QueryHas::endSelectionSet) - { - _pimpl->endSelectionSet(params); - } - } - - private: - const std::shared_ptr _pimpl; - }; - - Query(std::unique_ptr&& pimpl) noexcept; - - service::TypeNames getTypeNames() const noexcept; - service::ResolverMap getResolvers() const noexcept; - - void beginSelectionSet(const service::SelectionSetParams& params) const final; - void endSelectionSet(const service::SelectionSetParams& params) const final; - - const std::unique_ptr _pimpl; - -public: - template - Query(std::shared_ptr pimpl) noexcept - : Query { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } - { - } -}; - -class Dog - : public service::Object -{ -private: - service::AwaitableResolver resolveName(service::ResolverParams&& params) const; - service::AwaitableResolver resolveNickname(service::ResolverParams&& params) const; - service::AwaitableResolver resolveBarkVolume(service::ResolverParams&& params) const; - service::AwaitableResolver resolveDoesKnowCommand(service::ResolverParams&& params) const; - service::AwaitableResolver resolveIsHousetrained(service::ResolverParams&& params) const; - service::AwaitableResolver resolveOwner(service::ResolverParams&& params) const; - - service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; - - struct Concept - { - virtual ~Concept() = default; - - virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - - virtual service::FieldResult getName(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getNickname(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getBarkVolume(service::FieldParams&& params) const = 0; - virtual service::FieldResult getDoesKnowCommand(service::FieldParams&& params, DogCommand&& dogCommandArg) const = 0; - virtual service::FieldResult getIsHousetrained(service::FieldParams&& params, std::optional&& atOtherHomesArg) const = 0; - virtual service::FieldResult> getOwner(service::FieldParams&& params) const = 0; - }; - - template - struct Model - : Concept - { - Model(std::shared_ptr&& pimpl) noexcept - : _pimpl { std::move(pimpl) } - { - } - - service::FieldResult getName(service::FieldParams&& params) const final - { - if constexpr (methods::DogHas::getNameWithParams) - { - return { _pimpl->getName(std::move(params)) }; - } - else if constexpr (methods::DogHas::getName) - { - return { _pimpl->getName() }; - } - else - { - throw std::runtime_error(R"ex(Dog::getName is not implemented)ex"); - } - } - - service::FieldResult> getNickname(service::FieldParams&& params) const final - { - if constexpr (methods::DogHas::getNicknameWithParams) - { - return { _pimpl->getNickname(std::move(params)) }; - } - else if constexpr (methods::DogHas::getNickname) - { - return { _pimpl->getNickname() }; - } - else - { - throw std::runtime_error(R"ex(Dog::getNickname is not implemented)ex"); - } - } - - service::FieldResult> getBarkVolume(service::FieldParams&& params) const final - { - if constexpr (methods::DogHas::getBarkVolumeWithParams) - { - return { _pimpl->getBarkVolume(std::move(params)) }; - } - else if constexpr (methods::DogHas::getBarkVolume) - { - return { _pimpl->getBarkVolume() }; - } - else - { - throw std::runtime_error(R"ex(Dog::getBarkVolume is not implemented)ex"); - } - } - - service::FieldResult getDoesKnowCommand(service::FieldParams&& params, DogCommand&& dogCommandArg) const final - { - if constexpr (methods::DogHas::getDoesKnowCommandWithParams) - { - return { _pimpl->getDoesKnowCommand(std::move(params), std::move(dogCommandArg)) }; - } - else if constexpr (methods::DogHas::getDoesKnowCommand) - { - return { _pimpl->getDoesKnowCommand(std::move(dogCommandArg)) }; - } - else - { - throw std::runtime_error(R"ex(Dog::getDoesKnowCommand is not implemented)ex"); - } - } - - service::FieldResult getIsHousetrained(service::FieldParams&& params, std::optional&& atOtherHomesArg) const final - { - if constexpr (methods::DogHas::getIsHousetrainedWithParams) - { - return { _pimpl->getIsHousetrained(std::move(params), std::move(atOtherHomesArg)) }; - } - else if constexpr (methods::DogHas::getIsHousetrained) - { - return { _pimpl->getIsHousetrained(std::move(atOtherHomesArg)) }; - } - else - { - throw std::runtime_error(R"ex(Dog::getIsHousetrained is not implemented)ex"); - } - } - - service::FieldResult> getOwner(service::FieldParams&& params) const final - { - if constexpr (methods::DogHas::getOwnerWithParams) - { - return { _pimpl->getOwner(std::move(params)) }; - } - else if constexpr (methods::DogHas::getOwner) - { - return { _pimpl->getOwner() }; - } - else - { - throw std::runtime_error(R"ex(Dog::getOwner is not implemented)ex"); - } - } - - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (methods::DogHas::beginSelectionSet) - { - _pimpl->beginSelectionSet(params); - } - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (methods::DogHas::endSelectionSet) - { - _pimpl->endSelectionSet(params); - } - } - - private: - const std::shared_ptr _pimpl; - }; - - Dog(std::unique_ptr&& pimpl) noexcept; - - // Interfaces which this type implements - friend Pet; - - // Unions which include this type - friend CatOrDog; - friend DogOrHuman; - - template - static constexpr bool implements() noexcept - { - return implements::DogIs; - } - - service::TypeNames getTypeNames() const noexcept; - service::ResolverMap getResolvers() const noexcept; - - void beginSelectionSet(const service::SelectionSetParams& params) const final; - void endSelectionSet(const service::SelectionSetParams& params) const final; - - const std::unique_ptr _pimpl; - -public: - template - Dog(std::shared_ptr pimpl) noexcept - : Dog { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } - { - } -}; - -class Alien - : public service::Object -{ -private: - service::AwaitableResolver resolveName(service::ResolverParams&& params) const; - service::AwaitableResolver resolveHomePlanet(service::ResolverParams&& params) const; - - service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; - - struct Concept - { - virtual ~Concept() = default; - - virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - - virtual service::FieldResult getName(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getHomePlanet(service::FieldParams&& params) const = 0; - }; - - template - struct Model - : Concept - { - Model(std::shared_ptr&& pimpl) noexcept - : _pimpl { std::move(pimpl) } - { - } - - service::FieldResult getName(service::FieldParams&& params) const final - { - if constexpr (methods::AlienHas::getNameWithParams) - { - return { _pimpl->getName(std::move(params)) }; - } - else if constexpr (methods::AlienHas::getName) - { - return { _pimpl->getName() }; - } - else - { - throw std::runtime_error(R"ex(Alien::getName is not implemented)ex"); - } - } - - service::FieldResult> getHomePlanet(service::FieldParams&& params) const final - { - if constexpr (methods::AlienHas::getHomePlanetWithParams) - { - return { _pimpl->getHomePlanet(std::move(params)) }; - } - else if constexpr (methods::AlienHas::getHomePlanet) - { - return { _pimpl->getHomePlanet() }; - } - else - { - throw std::runtime_error(R"ex(Alien::getHomePlanet is not implemented)ex"); - } - } - - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (methods::AlienHas::beginSelectionSet) - { - _pimpl->beginSelectionSet(params); - } - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (methods::AlienHas::endSelectionSet) - { - _pimpl->endSelectionSet(params); - } - } - - private: - const std::shared_ptr _pimpl; - }; - - Alien(std::unique_ptr&& pimpl) noexcept; - - // Interfaces which this type implements - friend Sentient; - - // Unions which include this type - friend HumanOrAlien; - - template - static constexpr bool implements() noexcept - { - return implements::AlienIs; - } - - service::TypeNames getTypeNames() const noexcept; - service::ResolverMap getResolvers() const noexcept; - - void beginSelectionSet(const service::SelectionSetParams& params) const final; - void endSelectionSet(const service::SelectionSetParams& params) const final; - - const std::unique_ptr _pimpl; - -public: - template - Alien(std::shared_ptr pimpl) noexcept - : Alien { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } - { - } -}; - -class Human - : public service::Object -{ -private: - service::AwaitableResolver resolveName(service::ResolverParams&& params) const; - service::AwaitableResolver resolvePets(service::ResolverParams&& params) const; - - service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; - - struct Concept - { - virtual ~Concept() = default; - - virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - - virtual service::FieldResult getName(service::FieldParams&& params) const = 0; - virtual service::FieldResult>> getPets(service::FieldParams&& params) const = 0; - }; - - template - struct Model - : Concept - { - Model(std::shared_ptr&& pimpl) noexcept - : _pimpl { std::move(pimpl) } - { - } - - service::FieldResult getName(service::FieldParams&& params) const final - { - if constexpr (methods::HumanHas::getNameWithParams) - { - return { _pimpl->getName(std::move(params)) }; - } - else if constexpr (methods::HumanHas::getName) - { - return { _pimpl->getName() }; - } - else - { - throw std::runtime_error(R"ex(Human::getName is not implemented)ex"); - } - } - - service::FieldResult>> getPets(service::FieldParams&& params) const final - { - if constexpr (methods::HumanHas::getPetsWithParams) - { - return { _pimpl->getPets(std::move(params)) }; - } - else if constexpr (methods::HumanHas::getPets) - { - return { _pimpl->getPets() }; - } - else - { - throw std::runtime_error(R"ex(Human::getPets is not implemented)ex"); - } - } - - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (methods::HumanHas::beginSelectionSet) - { - _pimpl->beginSelectionSet(params); - } - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (methods::HumanHas::endSelectionSet) - { - _pimpl->endSelectionSet(params); - } - } - - private: - const std::shared_ptr _pimpl; - }; - - Human(std::unique_ptr&& pimpl) noexcept; - - // Interfaces which this type implements - friend Sentient; - - // Unions which include this type - friend DogOrHuman; - friend HumanOrAlien; - - template - static constexpr bool implements() noexcept - { - return implements::HumanIs; - } - - service::TypeNames getTypeNames() const noexcept; - service::ResolverMap getResolvers() const noexcept; - - void beginSelectionSet(const service::SelectionSetParams& params) const final; - void endSelectionSet(const service::SelectionSetParams& params) const final; - - const std::unique_ptr _pimpl; - -public: - template - Human(std::shared_ptr pimpl) noexcept - : Human { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } - { - } -}; - -class Cat - : public service::Object -{ -private: - service::AwaitableResolver resolveName(service::ResolverParams&& params) const; - service::AwaitableResolver resolveNickname(service::ResolverParams&& params) const; - service::AwaitableResolver resolveDoesKnowCommand(service::ResolverParams&& params) const; - service::AwaitableResolver resolveMeowVolume(service::ResolverParams&& params) const; - - service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; - - struct Concept - { - virtual ~Concept() = default; - - virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - - virtual service::FieldResult getName(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getNickname(service::FieldParams&& params) const = 0; - virtual service::FieldResult getDoesKnowCommand(service::FieldParams&& params, CatCommand&& catCommandArg) const = 0; - virtual service::FieldResult> getMeowVolume(service::FieldParams&& params) const = 0; - }; - - template - struct Model - : Concept - { - Model(std::shared_ptr&& pimpl) noexcept - : _pimpl { std::move(pimpl) } - { - } - - service::FieldResult getName(service::FieldParams&& params) const final - { - if constexpr (methods::CatHas::getNameWithParams) - { - return { _pimpl->getName(std::move(params)) }; - } - else if constexpr (methods::CatHas::getName) - { - return { _pimpl->getName() }; - } - else - { - throw std::runtime_error(R"ex(Cat::getName is not implemented)ex"); - } - } - - service::FieldResult> getNickname(service::FieldParams&& params) const final - { - if constexpr (methods::CatHas::getNicknameWithParams) - { - return { _pimpl->getNickname(std::move(params)) }; - } - else if constexpr (methods::CatHas::getNickname) - { - return { _pimpl->getNickname() }; - } - else - { - throw std::runtime_error(R"ex(Cat::getNickname is not implemented)ex"); - } - } - - service::FieldResult getDoesKnowCommand(service::FieldParams&& params, CatCommand&& catCommandArg) const final - { - if constexpr (methods::CatHas::getDoesKnowCommandWithParams) - { - return { _pimpl->getDoesKnowCommand(std::move(params), std::move(catCommandArg)) }; - } - else if constexpr (methods::CatHas::getDoesKnowCommand) - { - return { _pimpl->getDoesKnowCommand(std::move(catCommandArg)) }; - } - else - { - throw std::runtime_error(R"ex(Cat::getDoesKnowCommand is not implemented)ex"); - } - } - - service::FieldResult> getMeowVolume(service::FieldParams&& params) const final - { - if constexpr (methods::CatHas::getMeowVolumeWithParams) - { - return { _pimpl->getMeowVolume(std::move(params)) }; - } - else if constexpr (methods::CatHas::getMeowVolume) - { - return { _pimpl->getMeowVolume() }; - } - else - { - throw std::runtime_error(R"ex(Cat::getMeowVolume is not implemented)ex"); - } - } - - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (methods::CatHas::beginSelectionSet) - { - _pimpl->beginSelectionSet(params); - } - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (methods::CatHas::endSelectionSet) - { - _pimpl->endSelectionSet(params); - } - } - - private: - const std::shared_ptr _pimpl; - }; - - Cat(std::unique_ptr&& pimpl) noexcept; - - // Interfaces which this type implements - friend Pet; - - // Unions which include this type - friend CatOrDog; - - template - static constexpr bool implements() noexcept - { - return implements::CatIs; - } - - service::TypeNames getTypeNames() const noexcept; - service::ResolverMap getResolvers() const noexcept; - - void beginSelectionSet(const service::SelectionSetParams& params) const final; - void endSelectionSet(const service::SelectionSetParams& params) const final; - - const std::unique_ptr _pimpl; - -public: - template - Cat(std::shared_ptr pimpl) noexcept - : Cat { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } - { - } -}; - -class Mutation - : public service::Object -{ -private: - service::AwaitableResolver resolveMutateDog(service::ResolverParams&& params) const; - - service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; - - struct Concept - { - virtual ~Concept() = default; - - virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - - virtual service::FieldResult> applyMutateDog(service::FieldParams&& params) const = 0; - }; - - template - struct Model - : Concept - { - Model(std::shared_ptr&& pimpl) noexcept - : _pimpl { std::move(pimpl) } - { - } - - service::FieldResult> applyMutateDog(service::FieldParams&& params) const final - { - if constexpr (methods::MutationHas::applyMutateDogWithParams) - { - return { _pimpl->applyMutateDog(std::move(params)) }; - } - else if constexpr (methods::MutationHas::applyMutateDog) - { - return { _pimpl->applyMutateDog() }; - } - else - { - throw std::runtime_error(R"ex(Mutation::applyMutateDog is not implemented)ex"); - } - } - - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (methods::MutationHas::beginSelectionSet) - { - _pimpl->beginSelectionSet(params); - } - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (methods::MutationHas::endSelectionSet) - { - _pimpl->endSelectionSet(params); - } - } - - private: - const std::shared_ptr _pimpl; - }; - - Mutation(std::unique_ptr&& pimpl) noexcept; - - service::TypeNames getTypeNames() const noexcept; - service::ResolverMap getResolvers() const noexcept; - - void beginSelectionSet(const service::SelectionSetParams& params) const final; - void endSelectionSet(const service::SelectionSetParams& params) const final; - - const std::unique_ptr _pimpl; - -public: - template - Mutation(std::shared_ptr pimpl) noexcept - : Mutation { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } - { - } -}; - -class MutateDogResult - : public service::Object -{ -private: - service::AwaitableResolver resolveId(service::ResolverParams&& params) const; - - service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; - - struct Concept - { - virtual ~Concept() = default; - - virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - - virtual service::FieldResult getId(service::FieldParams&& params) const = 0; - }; - - template - struct Model - : Concept - { - Model(std::shared_ptr&& pimpl) noexcept - : _pimpl { std::move(pimpl) } - { - } - - service::FieldResult getId(service::FieldParams&& params) const final - { - if constexpr (methods::MutateDogResultHas::getIdWithParams) - { - return { _pimpl->getId(std::move(params)) }; - } - else if constexpr (methods::MutateDogResultHas::getId) - { - return { _pimpl->getId() }; - } - else - { - throw std::runtime_error(R"ex(MutateDogResult::getId is not implemented)ex"); - } - } - - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (methods::MutateDogResultHas::beginSelectionSet) - { - _pimpl->beginSelectionSet(params); - } - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (methods::MutateDogResultHas::endSelectionSet) - { - _pimpl->endSelectionSet(params); - } - } - - private: - const std::shared_ptr _pimpl; - }; - - MutateDogResult(std::unique_ptr&& pimpl) noexcept; - - service::TypeNames getTypeNames() const noexcept; - service::ResolverMap getResolvers() const noexcept; - - void beginSelectionSet(const service::SelectionSetParams& params) const final; - void endSelectionSet(const service::SelectionSetParams& params) const final; - - const std::unique_ptr _pimpl; - -public: - template - MutateDogResult(std::shared_ptr pimpl) noexcept - : MutateDogResult { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } - { - } -}; - -class Subscription - : public service::Object -{ -private: - service::AwaitableResolver resolveNewMessage(service::ResolverParams&& params) const; - service::AwaitableResolver resolveDisallowedSecondRootField(service::ResolverParams&& params) const; - - service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; - - struct Concept - { - virtual ~Concept() = default; - - virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - - virtual service::FieldResult> getNewMessage(service::FieldParams&& params) const = 0; - virtual service::FieldResult getDisallowedSecondRootField(service::FieldParams&& params) const = 0; - }; - - template - struct Model - : Concept - { - Model(std::shared_ptr&& pimpl) noexcept - : _pimpl { std::move(pimpl) } - { - } - - service::FieldResult> getNewMessage(service::FieldParams&& params) const final - { - if constexpr (methods::SubscriptionHas::getNewMessageWithParams) - { - return { _pimpl->getNewMessage(std::move(params)) }; - } - else if constexpr (methods::SubscriptionHas::getNewMessage) - { - return { _pimpl->getNewMessage() }; - } - else - { - throw std::runtime_error(R"ex(Subscription::getNewMessage is not implemented)ex"); - } - } - - service::FieldResult getDisallowedSecondRootField(service::FieldParams&& params) const final - { - if constexpr (methods::SubscriptionHas::getDisallowedSecondRootFieldWithParams) - { - return { _pimpl->getDisallowedSecondRootField(std::move(params)) }; - } - else if constexpr (methods::SubscriptionHas::getDisallowedSecondRootField) - { - return { _pimpl->getDisallowedSecondRootField() }; - } - else - { - throw std::runtime_error(R"ex(Subscription::getDisallowedSecondRootField is not implemented)ex"); - } - } - - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (methods::SubscriptionHas::beginSelectionSet) - { - _pimpl->beginSelectionSet(params); - } - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (methods::SubscriptionHas::endSelectionSet) - { - _pimpl->endSelectionSet(params); - } - } - - private: - const std::shared_ptr _pimpl; - }; - - Subscription(std::unique_ptr&& pimpl) noexcept; - - service::TypeNames getTypeNames() const noexcept; - service::ResolverMap getResolvers() const noexcept; - - void beginSelectionSet(const service::SelectionSetParams& params) const final; - void endSelectionSet(const service::SelectionSetParams& params) const final; - - const std::unique_ptr _pimpl; - -public: - template - Subscription(std::shared_ptr pimpl) noexcept - : Subscription { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } - { - } -}; - -class Message - : public service::Object -{ -private: - service::AwaitableResolver resolveBody(service::ResolverParams&& params) const; - service::AwaitableResolver resolveSender(service::ResolverParams&& params) const; - - service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; - - struct Concept - { - virtual ~Concept() = default; - - virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - - virtual service::FieldResult> getBody(service::FieldParams&& params) const = 0; - virtual service::FieldResult getSender(service::FieldParams&& params) const = 0; - }; - - template - struct Model - : Concept - { - Model(std::shared_ptr&& pimpl) noexcept - : _pimpl { std::move(pimpl) } - { - } - - service::FieldResult> getBody(service::FieldParams&& params) const final - { - if constexpr (methods::MessageHas::getBodyWithParams) - { - return { _pimpl->getBody(std::move(params)) }; - } - else if constexpr (methods::MessageHas::getBody) - { - return { _pimpl->getBody() }; - } - else - { - throw std::runtime_error(R"ex(Message::getBody is not implemented)ex"); - } - } - - service::FieldResult getSender(service::FieldParams&& params) const final - { - if constexpr (methods::MessageHas::getSenderWithParams) - { - return { _pimpl->getSender(std::move(params)) }; - } - else if constexpr (methods::MessageHas::getSender) - { - return { _pimpl->getSender() }; - } - else - { - throw std::runtime_error(R"ex(Message::getSender is not implemented)ex"); - } - } - - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (methods::MessageHas::beginSelectionSet) - { - _pimpl->beginSelectionSet(params); - } - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (methods::MessageHas::endSelectionSet) - { - _pimpl->endSelectionSet(params); - } - } - - private: - const std::shared_ptr _pimpl; - }; - - Message(std::unique_ptr&& pimpl) noexcept; - - service::TypeNames getTypeNames() const noexcept; - service::ResolverMap getResolvers() const noexcept; - - void beginSelectionSet(const service::SelectionSetParams& params) const final; - void endSelectionSet(const service::SelectionSetParams& params) const final; - - const std::unique_ptr _pimpl; - -public: - template - Message(std::shared_ptr pimpl) noexcept - : Message { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } - { - } -}; - -class Arguments - : public service::Object -{ -private: - service::AwaitableResolver resolveMultipleReqs(service::ResolverParams&& params) const; - service::AwaitableResolver resolveBooleanArgField(service::ResolverParams&& params) const; - service::AwaitableResolver resolveFloatArgField(service::ResolverParams&& params) const; - service::AwaitableResolver resolveIntArgField(service::ResolverParams&& params) const; - service::AwaitableResolver resolveNonNullBooleanArgField(service::ResolverParams&& params) const; - service::AwaitableResolver resolveNonNullBooleanListField(service::ResolverParams&& params) const; - service::AwaitableResolver resolveBooleanListArgField(service::ResolverParams&& params) const; - service::AwaitableResolver resolveOptionalNonNullBooleanArgField(service::ResolverParams&& params) const; - - service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; - - struct Concept - { - virtual ~Concept() = default; - - virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - - virtual service::FieldResult getMultipleReqs(service::FieldParams&& params, int&& xArg, int&& yArg) const = 0; - virtual service::FieldResult> getBooleanArgField(service::FieldParams&& params, std::optional&& booleanArgArg) const = 0; - virtual service::FieldResult> getFloatArgField(service::FieldParams&& params, std::optional&& floatArgArg) const = 0; - virtual service::FieldResult> getIntArgField(service::FieldParams&& params, std::optional&& intArgArg) const = 0; - virtual service::FieldResult getNonNullBooleanArgField(service::FieldParams&& params, bool&& nonNullBooleanArgArg) const = 0; - virtual service::FieldResult>> getNonNullBooleanListField(service::FieldParams&& params, std::optional>&& nonNullBooleanListArgArg) const = 0; - virtual service::FieldResult>>> getBooleanListArgField(service::FieldParams&& params, std::vector>&& booleanListArgArg) const = 0; - virtual service::FieldResult getOptionalNonNullBooleanArgField(service::FieldParams&& params, bool&& optionalBooleanArgArg) const = 0; - }; - - template - struct Model - : Concept - { - Model(std::shared_ptr&& pimpl) noexcept - : _pimpl { std::move(pimpl) } - { - } - - service::FieldResult getMultipleReqs(service::FieldParams&& params, int&& xArg, int&& yArg) const final - { - if constexpr (methods::ArgumentsHas::getMultipleReqsWithParams) - { - return { _pimpl->getMultipleReqs(std::move(params), std::move(xArg), std::move(yArg)) }; - } - else if constexpr (methods::ArgumentsHas::getMultipleReqs) - { - return { _pimpl->getMultipleReqs(std::move(xArg), std::move(yArg)) }; - } - else - { - throw std::runtime_error(R"ex(Arguments::getMultipleReqs is not implemented)ex"); - } - } - - service::FieldResult> getBooleanArgField(service::FieldParams&& params, std::optional&& booleanArgArg) const final - { - if constexpr (methods::ArgumentsHas::getBooleanArgFieldWithParams) - { - return { _pimpl->getBooleanArgField(std::move(params), std::move(booleanArgArg)) }; - } - else if constexpr (methods::ArgumentsHas::getBooleanArgField) - { - return { _pimpl->getBooleanArgField(std::move(booleanArgArg)) }; - } - else - { - throw std::runtime_error(R"ex(Arguments::getBooleanArgField is not implemented)ex"); - } - } - - service::FieldResult> getFloatArgField(service::FieldParams&& params, std::optional&& floatArgArg) const final - { - if constexpr (methods::ArgumentsHas::getFloatArgFieldWithParams) - { - return { _pimpl->getFloatArgField(std::move(params), std::move(floatArgArg)) }; - } - else if constexpr (methods::ArgumentsHas::getFloatArgField) - { - return { _pimpl->getFloatArgField(std::move(floatArgArg)) }; - } - else - { - throw std::runtime_error(R"ex(Arguments::getFloatArgField is not implemented)ex"); - } - } - - service::FieldResult> getIntArgField(service::FieldParams&& params, std::optional&& intArgArg) const final - { - if constexpr (methods::ArgumentsHas::getIntArgFieldWithParams) - { - return { _pimpl->getIntArgField(std::move(params), std::move(intArgArg)) }; - } - else if constexpr (methods::ArgumentsHas::getIntArgField) - { - return { _pimpl->getIntArgField(std::move(intArgArg)) }; - } - else - { - throw std::runtime_error(R"ex(Arguments::getIntArgField is not implemented)ex"); - } - } - - service::FieldResult getNonNullBooleanArgField(service::FieldParams&& params, bool&& nonNullBooleanArgArg) const final - { - if constexpr (methods::ArgumentsHas::getNonNullBooleanArgFieldWithParams) - { - return { _pimpl->getNonNullBooleanArgField(std::move(params), std::move(nonNullBooleanArgArg)) }; - } - else if constexpr (methods::ArgumentsHas::getNonNullBooleanArgField) - { - return { _pimpl->getNonNullBooleanArgField(std::move(nonNullBooleanArgArg)) }; - } - else - { - throw std::runtime_error(R"ex(Arguments::getNonNullBooleanArgField is not implemented)ex"); - } - } - - service::FieldResult>> getNonNullBooleanListField(service::FieldParams&& params, std::optional>&& nonNullBooleanListArgArg) const final - { - if constexpr (methods::ArgumentsHas::getNonNullBooleanListFieldWithParams) - { - return { _pimpl->getNonNullBooleanListField(std::move(params), std::move(nonNullBooleanListArgArg)) }; - } - else if constexpr (methods::ArgumentsHas::getNonNullBooleanListField) - { - return { _pimpl->getNonNullBooleanListField(std::move(nonNullBooleanListArgArg)) }; - } - else - { - throw std::runtime_error(R"ex(Arguments::getNonNullBooleanListField is not implemented)ex"); - } - } - - service::FieldResult>>> getBooleanListArgField(service::FieldParams&& params, std::vector>&& booleanListArgArg) const final - { - if constexpr (methods::ArgumentsHas::getBooleanListArgFieldWithParams) - { - return { _pimpl->getBooleanListArgField(std::move(params), std::move(booleanListArgArg)) }; - } - else if constexpr (methods::ArgumentsHas::getBooleanListArgField) - { - return { _pimpl->getBooleanListArgField(std::move(booleanListArgArg)) }; - } - else - { - throw std::runtime_error(R"ex(Arguments::getBooleanListArgField is not implemented)ex"); - } - } - - service::FieldResult getOptionalNonNullBooleanArgField(service::FieldParams&& params, bool&& optionalBooleanArgArg) const final - { - if constexpr (methods::ArgumentsHas::getOptionalNonNullBooleanArgFieldWithParams) - { - return { _pimpl->getOptionalNonNullBooleanArgField(std::move(params), std::move(optionalBooleanArgArg)) }; - } - else if constexpr (methods::ArgumentsHas::getOptionalNonNullBooleanArgField) - { - return { _pimpl->getOptionalNonNullBooleanArgField(std::move(optionalBooleanArgArg)) }; - } - else - { - throw std::runtime_error(R"ex(Arguments::getOptionalNonNullBooleanArgField is not implemented)ex"); - } - } - - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (methods::ArgumentsHas::beginSelectionSet) - { - _pimpl->beginSelectionSet(params); - } - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (methods::ArgumentsHas::endSelectionSet) - { - _pimpl->endSelectionSet(params); - } - } - - private: - const std::shared_ptr _pimpl; - }; - - Arguments(std::unique_ptr&& pimpl) noexcept; - - service::TypeNames getTypeNames() const noexcept; - service::ResolverMap getResolvers() const noexcept; - - void beginSelectionSet(const service::SelectionSetParams& params) const final; - void endSelectionSet(const service::SelectionSetParams& params) const final; - - const std::unique_ptr _pimpl; - -public: - template - Arguments(std::shared_ptr pimpl) noexcept - : Arguments { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } - { - } -}; - } // namespace object class Operations @@ -2307,6 +79,24 @@ class Operations std::shared_ptr _subscription; }; +void AddSentientDetails(const std::shared_ptr& typeSentient, const std::shared_ptr& schema); +void AddPetDetails(const std::shared_ptr& typePet, const std::shared_ptr& schema); + +void AddCatOrDogDetails(const std::shared_ptr& typeCatOrDog, const std::shared_ptr& schema); +void AddDogOrHumanDetails(const std::shared_ptr& typeDogOrHuman, const std::shared_ptr& schema); +void AddHumanOrAlienDetails(const std::shared_ptr& typeHumanOrAlien, const std::shared_ptr& schema); + +void AddQueryDetails(const std::shared_ptr& typeQuery, const std::shared_ptr& schema); +void AddDogDetails(const std::shared_ptr& typeDog, const std::shared_ptr& schema); +void AddAlienDetails(const std::shared_ptr& typeAlien, const std::shared_ptr& schema); +void AddHumanDetails(const std::shared_ptr& typeHuman, const std::shared_ptr& schema); +void AddCatDetails(const std::shared_ptr& typeCat, const std::shared_ptr& schema); +void AddMutationDetails(const std::shared_ptr& typeMutation, const std::shared_ptr& schema); +void AddMutateDogResultDetails(const std::shared_ptr& typeMutateDogResult, const std::shared_ptr& schema); +void AddSubscriptionDetails(const std::shared_ptr& typeSubscription, const std::shared_ptr& schema); +void AddMessageDetails(const std::shared_ptr& typeMessage, const std::shared_ptr& schema); +void AddArgumentsDetails(const std::shared_ptr& typeArguments, const std::shared_ptr& schema); + std::shared_ptr GetSchema(); } // namespace validation diff --git a/samples/validation/schema/validation_schema_files b/samples/validation/schema/validation_schema_files index 0e298f8f..fe72dfb8 100644 --- a/samples/validation/schema/validation_schema_files +++ b/samples/validation/schema/validation_schema_files @@ -1 +1,16 @@ ValidationSchema.cpp +SentientObject.cpp +PetObject.cpp +CatOrDogObject.cpp +DogOrHumanObject.cpp +HumanOrAlienObject.cpp +QueryObject.cpp +DogObject.cpp +AlienObject.cpp +HumanObject.cpp +CatObject.cpp +MutationObject.cpp +MutateDogResultObject.cpp +SubscriptionObject.cpp +MessageObject.cpp +ArgumentsObject.cpp From 4773439fe63167674e2477d87a79b7b37a16f149 Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Wed, 8 Dec 2021 18:57:52 -0800 Subject: [PATCH 069/119] Remove separate unified sample schemas --- samples/today/CMakeLists.txt | 17 - samples/today/TodayMock.h | 4 - samples/today/unified/CMakeLists.txt | 13 - samples/today/unified/TodaySchema.cpp | 1588 --------- samples/today/unified/TodaySchema.h | 2938 ----------------- samples/today/unified/unified_schema_files | 1 - .../unified_nointrospection/CMakeLists.txt | 13 - .../unified_nointrospection/TodaySchema.cpp | 1571 --------- .../unified_nointrospection/TodaySchema.h | 2934 ---------------- .../unified_nointrospection_schema_files | 1 - test/CMakeLists.txt | 8 +- 11 files changed, 4 insertions(+), 9084 deletions(-) delete mode 100644 samples/today/unified/CMakeLists.txt delete mode 100644 samples/today/unified/TodaySchema.cpp delete mode 100644 samples/today/unified/TodaySchema.h delete mode 100644 samples/today/unified/unified_schema_files delete mode 100644 samples/today/unified_nointrospection/CMakeLists.txt delete mode 100644 samples/today/unified_nointrospection/TodaySchema.cpp delete mode 100644 samples/today/unified_nointrospection/TodaySchema.h delete mode 100644 samples/today/unified_nointrospection/unified_nointrospection_schema_files diff --git a/samples/today/CMakeLists.txt b/samples/today/CMakeLists.txt index 56415c3f..5e392e28 100644 --- a/samples/today/CMakeLists.txt +++ b/samples/today/CMakeLists.txt @@ -8,14 +8,12 @@ add_subdirectory(separate) add_library(separategraphql STATIC TodayMock.cpp) target_link_libraries(separategraphql PUBLIC separate_schema) target_include_directories(separategraphql PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) -target_compile_definitions(separategraphql PUBLIC IMPL_SEPARATE_TODAY) # separategraphql_nointrospection add_subdirectory(separate_nointrospection) add_library(separategraphql_nointrospection STATIC TodayMock.cpp) target_link_libraries(separategraphql_nointrospection PUBLIC separate_nointrospection_schema) target_include_directories(separategraphql_nointrospection PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) -target_compile_definitions(separategraphql_nointrospection PUBLIC IMPL_SEPARATE_TODAY) # sample add_executable(sample sample.cpp) @@ -65,18 +63,3 @@ if(WIN32 AND BUILD_SHARED_LIBS) add_dependencies(benchmark copy_today_sample_dlls) add_dependencies(benchmark_nointrospection copy_today_sample_dlls) endif() - -if(GRAPHQL_BUILD_TESTS) - # tests - add_subdirectory(unified) - add_library(unifiedgraphql STATIC TodayMock.cpp) - target_link_libraries(unifiedgraphql PUBLIC unified_schema) - target_include_directories(unifiedgraphql PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) - add_bigobj_flag(unifiedgraphql) - - add_subdirectory(unified_nointrospection) - add_library(unifiedgraphql_nointrospection STATIC TodayMock.cpp) - target_link_libraries(unifiedgraphql_nointrospection PUBLIC unified_nointrospection_schema) - target_include_directories(unifiedgraphql_nointrospection PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) - add_bigobj_flag(unifiedgraphql_nointrospection) -endif() diff --git a/samples/today/TodayMock.h b/samples/today/TodayMock.h index e86a972a..5d6883eb 100644 --- a/samples/today/TodayMock.h +++ b/samples/today/TodayMock.h @@ -6,11 +6,7 @@ #ifndef TODAYMOCK_H #define TODAYMOCK_H -#ifdef IMPL_SEPARATE_TODAY #include "TodayObjects.h" -#else -#include "TodaySchema.h" -#endif #include #include diff --git a/samples/today/unified/CMakeLists.txt b/samples/today/unified/CMakeLists.txt deleted file mode 100644 index b221706d..00000000 --- a/samples/today/unified/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. - -cmake_minimum_required(VERSION 3.15) - -# Normally this would be handled by find_package(cppgraphqlgen CONFIG). -include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/cppgraphqlgen-functions.cmake) - -if(GRAPHQL_UPDATE_SAMPLES) - update_graphql_schema_files(unified ../schema.today.graphql Today today --stubs --merge-files) -endif() - -add_graphql_schema_target(unified) diff --git a/samples/today/unified/TodaySchema.cpp b/samples/today/unified/TodaySchema.cpp deleted file mode 100644 index c1a0a02c..00000000 --- a/samples/today/unified/TodaySchema.cpp +++ /dev/null @@ -1,1588 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// WARNING! Do not edit this file manually, your changes will be overwritten. - -#include "TodaySchema.h" - -#include "graphqlservice/introspection/Introspection.h" - -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace std::literals; - -namespace graphql { -namespace service { - -static const std::array s_namesTaskState = { - R"gql(New)gql"sv, - R"gql(Started)gql"sv, - R"gql(Complete)gql"sv, - R"gql(Unassigned)gql"sv -}; - -template <> -today::TaskState ModifiedArgument::convert(const response::Value& value) -{ - if (!value.maybe_enum()) - { - throw service::schema_exception { { R"ex(not a valid TaskState value)ex" } }; - } - - const auto itr = std::find(s_namesTaskState.cbegin(), s_namesTaskState.cend(), value.get()); - - if (itr == s_namesTaskState.cend()) - { - throw service::schema_exception { { R"ex(not a valid TaskState value)ex" } }; - } - - return static_cast(itr - s_namesTaskState.cbegin()); -} - -template <> -service::AwaitableResolver ModifiedResult::convert(service::FieldResult result, ResolverParams params) -{ - return resolve(std::move(result), std::move(params), - [](today::TaskState value, const ResolverParams&) - { - response::Value result(response::Type::EnumValue); - - result.set(std::string { s_namesTaskState[static_cast(value)] }); - - return result; - }); -} - -template <> -today::CompleteTaskInput ModifiedArgument::convert(const response::Value& value) -{ - const auto defaultValue = []() - { - response::Value values(response::Type::Map); - response::Value entry; - - entry = response::Value(true); - values.emplace_back("isComplete", std::move(entry)); - - return values; - }(); - - auto valueId = service::ModifiedArgument::require("id", value); - auto valueTestTaskState = service::ModifiedArgument::require("testTaskState", value); - auto pairIsComplete = service::ModifiedArgument::find("isComplete", value); - auto valueIsComplete = (pairIsComplete.second - ? std::move(pairIsComplete.first) - : service::ModifiedArgument::require("isComplete", defaultValue)); - auto valueClientMutationId = service::ModifiedArgument::require("clientMutationId", value); - - return { - std::move(valueId), - std::move(valueTestTaskState), - std::move(valueIsComplete), - std::move(valueClientMutationId) - }; -} - -template <> -today::ThirdNestedInput ModifiedArgument::convert(const response::Value& value) -{ - auto valueId = service::ModifiedArgument::require("id", value); - - return { - std::move(valueId) - }; -} - -template <> -today::FourthNestedInput ModifiedArgument::convert(const response::Value& value) -{ - auto valueId = service::ModifiedArgument::require("id", value); - - return { - std::move(valueId) - }; -} - -template <> -today::SecondNestedInput ModifiedArgument::convert(const response::Value& value) -{ - auto valueId = service::ModifiedArgument::require("id", value); - auto valueThird = service::ModifiedArgument::require("third", value); - - return { - std::move(valueId), - std::move(valueThird) - }; -} - -template <> -today::FirstNestedInput ModifiedArgument::convert(const response::Value& value) -{ - auto valueId = service::ModifiedArgument::require("id", value); - auto valueSecond = service::ModifiedArgument::require("second", value); - auto valueThird = service::ModifiedArgument::require("third", value); - - return { - std::move(valueId), - std::move(valueSecond), - std::move(valueThird) - }; -} - -} // namespace service - -namespace today { -namespace object { - -Node::Node(std::unique_ptr&& pimpl) noexcept - : service::Object { pimpl->getTypeNames(), pimpl->getResolvers() } - , _pimpl { std::move(pimpl) } -{ -} - -void Node::beginSelectionSet(const service::SelectionSetParams& params) const -{ - _pimpl->beginSelectionSet(params); -} - -void Node::endSelectionSet(const service::SelectionSetParams& params) const -{ - _pimpl->endSelectionSet(params); -} - -UnionType::UnionType(std::unique_ptr&& pimpl) noexcept - : service::Object { pimpl->getTypeNames(), pimpl->getResolvers() } - , _pimpl { std::move(pimpl) } -{ -} - -void UnionType::beginSelectionSet(const service::SelectionSetParams& params) const -{ - _pimpl->beginSelectionSet(params); -} - -void UnionType::endSelectionSet(const service::SelectionSetParams& params) const -{ - _pimpl->endSelectionSet(params); -} - -Query::Query(std::unique_ptr&& pimpl) noexcept - : service::Object{ getTypeNames(), getResolvers() } - , _schema { GetSchema() } - , _pimpl { std::move(pimpl) } -{ -} - -service::TypeNames Query::getTypeNames() const noexcept -{ - return { - R"gql(Query)gql"sv - }; -} - -service::ResolverMap Query::getResolvers() const noexcept -{ - return { - { R"gql(node)gql"sv, [this](service::ResolverParams&& params) { return resolveNode(std::move(params)); } }, - { R"gql(tasks)gql"sv, [this](service::ResolverParams&& params) { return resolveTasks(std::move(params)); } }, - { R"gql(__type)gql"sv, [this](service::ResolverParams&& params) { return resolve_type(std::move(params)); } }, - { R"gql(nested)gql"sv, [this](service::ResolverParams&& params) { return resolveNested(std::move(params)); } }, - { R"gql(anyType)gql"sv, [this](service::ResolverParams&& params) { return resolveAnyType(std::move(params)); } }, - { R"gql(__schema)gql"sv, [this](service::ResolverParams&& params) { return resolve_schema(std::move(params)); } }, - { R"gql(expensive)gql"sv, [this](service::ResolverParams&& params) { return resolveExpensive(std::move(params)); } }, - { R"gql(tasksById)gql"sv, [this](service::ResolverParams&& params) { return resolveTasksById(std::move(params)); } }, - { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, - { R"gql(appointments)gql"sv, [this](service::ResolverParams&& params) { return resolveAppointments(std::move(params)); } }, - { R"gql(unreadCounts)gql"sv, [this](service::ResolverParams&& params) { return resolveUnreadCounts(std::move(params)); } }, - { R"gql(testTaskState)gql"sv, [this](service::ResolverParams&& params) { return resolveTestTaskState(std::move(params)); } }, - { R"gql(unimplemented)gql"sv, [this](service::ResolverParams&& params) { return resolveUnimplemented(std::move(params)); } }, - { R"gql(appointmentsById)gql"sv, [this](service::ResolverParams&& params) { return resolveAppointmentsById(std::move(params)); } }, - { R"gql(unreadCountsById)gql"sv, [this](service::ResolverParams&& params) { return resolveUnreadCountsById(std::move(params)); } } - }; -} - -void Query::beginSelectionSet(const service::SelectionSetParams& params) const -{ - _pimpl->beginSelectionSet(params); -} - -void Query::endSelectionSet(const service::SelectionSetParams& params) const -{ - _pimpl->endSelectionSet(params); -} - -service::AwaitableResolver Query::resolveNode(service::ResolverParams&& params) const -{ - auto argId = service::ModifiedArgument::require("id", params.arguments); - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getNode(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argId)); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Query::resolveAppointments(service::ResolverParams&& params) const -{ - auto argFirst = service::ModifiedArgument::require("first", params.arguments); - auto argAfter = service::ModifiedArgument::require("after", params.arguments); - auto argLast = service::ModifiedArgument::require("last", params.arguments); - auto argBefore = service::ModifiedArgument::require("before", params.arguments); - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getAppointments(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argFirst), std::move(argAfter), std::move(argLast), std::move(argBefore)); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Query::resolveTasks(service::ResolverParams&& params) const -{ - auto argFirst = service::ModifiedArgument::require("first", params.arguments); - auto argAfter = service::ModifiedArgument::require("after", params.arguments); - auto argLast = service::ModifiedArgument::require("last", params.arguments); - auto argBefore = service::ModifiedArgument::require("before", params.arguments); - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getTasks(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argFirst), std::move(argAfter), std::move(argLast), std::move(argBefore)); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Query::resolveUnreadCounts(service::ResolverParams&& params) const -{ - auto argFirst = service::ModifiedArgument::require("first", params.arguments); - auto argAfter = service::ModifiedArgument::require("after", params.arguments); - auto argLast = service::ModifiedArgument::require("last", params.arguments); - auto argBefore = service::ModifiedArgument::require("before", params.arguments); - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getUnreadCounts(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argFirst), std::move(argAfter), std::move(argLast), std::move(argBefore)); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Query::resolveAppointmentsById(service::ResolverParams&& params) const -{ - const auto defaultArguments = []() - { - response::Value values(response::Type::Map); - response::Value entry; - - entry = []() - { - response::Value elements(response::Type::List); - response::Value entry; - - entry = response::Value(std::string(R"gql(ZmFrZUFwcG9pbnRtZW50SWQ=)gql")); - elements.emplace_back(std::move(entry)); - return elements; - }(); - values.emplace_back("ids", std::move(entry)); - - return values; - }(); - - auto pairIds = service::ModifiedArgument::find("ids", params.arguments); - auto argIds = (pairIds.second - ? std::move(pairIds.first) - : service::ModifiedArgument::require("ids", defaultArguments)); - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getAppointmentsById(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argIds)); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Query::resolveTasksById(service::ResolverParams&& params) const -{ - auto argIds = service::ModifiedArgument::require("ids", params.arguments); - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getTasksById(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argIds)); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Query::resolveUnreadCountsById(service::ResolverParams&& params) const -{ - auto argIds = service::ModifiedArgument::require("ids", params.arguments); - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getUnreadCountsById(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argIds)); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Query::resolveNested(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getNested(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Query::resolveUnimplemented(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getUnimplemented(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Query::resolveExpensive(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getExpensive(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Query::resolveTestTaskState(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getTestTaskState(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Query::resolveAnyType(service::ResolverParams&& params) const -{ - auto argIds = service::ModifiedArgument::require("ids", params.arguments); - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getAnyType(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argIds)); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Query::resolve_typename(service::ResolverParams&& params) const -{ - return service::ModifiedResult::convert(std::string{ R"gql(Query)gql" }, std::move(params)); -} - -service::AwaitableResolver Query::resolve_schema(service::ResolverParams&& params) const -{ - return service::ModifiedResult::convert(std::static_pointer_cast(std::make_shared(std::make_shared(_schema))), std::move(params)); -} - -service::AwaitableResolver Query::resolve_type(service::ResolverParams&& params) const -{ - auto argName = service::ModifiedArgument::require("name", params.arguments); - const auto& baseType = _schema->LookupType(argName); - std::shared_ptr result { baseType ? std::make_shared(std::make_shared(baseType)) : nullptr }; - - return service::ModifiedResult::convert(result, std::move(params)); -} - -PageInfo::PageInfo(std::unique_ptr&& pimpl) noexcept - : service::Object{ getTypeNames(), getResolvers() } - , _pimpl { std::move(pimpl) } -{ -} - -service::TypeNames PageInfo::getTypeNames() const noexcept -{ - return { - R"gql(PageInfo)gql"sv - }; -} - -service::ResolverMap PageInfo::getResolvers() const noexcept -{ - return { - { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, - { R"gql(hasNextPage)gql"sv, [this](service::ResolverParams&& params) { return resolveHasNextPage(std::move(params)); } }, - { R"gql(hasPreviousPage)gql"sv, [this](service::ResolverParams&& params) { return resolveHasPreviousPage(std::move(params)); } } - }; -} - -void PageInfo::beginSelectionSet(const service::SelectionSetParams& params) const -{ - _pimpl->beginSelectionSet(params); -} - -void PageInfo::endSelectionSet(const service::SelectionSetParams& params) const -{ - _pimpl->endSelectionSet(params); -} - -service::AwaitableResolver PageInfo::resolveHasNextPage(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getHasNextPage(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver PageInfo::resolveHasPreviousPage(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getHasPreviousPage(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver PageInfo::resolve_typename(service::ResolverParams&& params) const -{ - return service::ModifiedResult::convert(std::string{ R"gql(PageInfo)gql" }, std::move(params)); -} - -AppointmentEdge::AppointmentEdge(std::unique_ptr&& pimpl) noexcept - : service::Object{ getTypeNames(), getResolvers() } - , _pimpl { std::move(pimpl) } -{ -} - -service::TypeNames AppointmentEdge::getTypeNames() const noexcept -{ - return { - R"gql(AppointmentEdge)gql"sv - }; -} - -service::ResolverMap AppointmentEdge::getResolvers() const noexcept -{ - return { - { R"gql(node)gql"sv, [this](service::ResolverParams&& params) { return resolveNode(std::move(params)); } }, - { R"gql(cursor)gql"sv, [this](service::ResolverParams&& params) { return resolveCursor(std::move(params)); } }, - { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } } - }; -} - -void AppointmentEdge::beginSelectionSet(const service::SelectionSetParams& params) const -{ - _pimpl->beginSelectionSet(params); -} - -void AppointmentEdge::endSelectionSet(const service::SelectionSetParams& params) const -{ - _pimpl->endSelectionSet(params); -} - -service::AwaitableResolver AppointmentEdge::resolveNode(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getNode(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver AppointmentEdge::resolveCursor(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getCursor(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver AppointmentEdge::resolve_typename(service::ResolverParams&& params) const -{ - return service::ModifiedResult::convert(std::string{ R"gql(AppointmentEdge)gql" }, std::move(params)); -} - -AppointmentConnection::AppointmentConnection(std::unique_ptr&& pimpl) noexcept - : service::Object{ getTypeNames(), getResolvers() } - , _pimpl { std::move(pimpl) } -{ -} - -service::TypeNames AppointmentConnection::getTypeNames() const noexcept -{ - return { - R"gql(AppointmentConnection)gql"sv - }; -} - -service::ResolverMap AppointmentConnection::getResolvers() const noexcept -{ - return { - { R"gql(edges)gql"sv, [this](service::ResolverParams&& params) { return resolveEdges(std::move(params)); } }, - { R"gql(pageInfo)gql"sv, [this](service::ResolverParams&& params) { return resolvePageInfo(std::move(params)); } }, - { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } } - }; -} - -void AppointmentConnection::beginSelectionSet(const service::SelectionSetParams& params) const -{ - _pimpl->beginSelectionSet(params); -} - -void AppointmentConnection::endSelectionSet(const service::SelectionSetParams& params) const -{ - _pimpl->endSelectionSet(params); -} - -service::AwaitableResolver AppointmentConnection::resolvePageInfo(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getPageInfo(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver AppointmentConnection::resolveEdges(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getEdges(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver AppointmentConnection::resolve_typename(service::ResolverParams&& params) const -{ - return service::ModifiedResult::convert(std::string{ R"gql(AppointmentConnection)gql" }, std::move(params)); -} - -TaskEdge::TaskEdge(std::unique_ptr&& pimpl) noexcept - : service::Object{ getTypeNames(), getResolvers() } - , _pimpl { std::move(pimpl) } -{ -} - -service::TypeNames TaskEdge::getTypeNames() const noexcept -{ - return { - R"gql(TaskEdge)gql"sv - }; -} - -service::ResolverMap TaskEdge::getResolvers() const noexcept -{ - return { - { R"gql(node)gql"sv, [this](service::ResolverParams&& params) { return resolveNode(std::move(params)); } }, - { R"gql(cursor)gql"sv, [this](service::ResolverParams&& params) { return resolveCursor(std::move(params)); } }, - { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } } - }; -} - -void TaskEdge::beginSelectionSet(const service::SelectionSetParams& params) const -{ - _pimpl->beginSelectionSet(params); -} - -void TaskEdge::endSelectionSet(const service::SelectionSetParams& params) const -{ - _pimpl->endSelectionSet(params); -} - -service::AwaitableResolver TaskEdge::resolveNode(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getNode(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver TaskEdge::resolveCursor(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getCursor(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver TaskEdge::resolve_typename(service::ResolverParams&& params) const -{ - return service::ModifiedResult::convert(std::string{ R"gql(TaskEdge)gql" }, std::move(params)); -} - -TaskConnection::TaskConnection(std::unique_ptr&& pimpl) noexcept - : service::Object{ getTypeNames(), getResolvers() } - , _pimpl { std::move(pimpl) } -{ -} - -service::TypeNames TaskConnection::getTypeNames() const noexcept -{ - return { - R"gql(TaskConnection)gql"sv - }; -} - -service::ResolverMap TaskConnection::getResolvers() const noexcept -{ - return { - { R"gql(edges)gql"sv, [this](service::ResolverParams&& params) { return resolveEdges(std::move(params)); } }, - { R"gql(pageInfo)gql"sv, [this](service::ResolverParams&& params) { return resolvePageInfo(std::move(params)); } }, - { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } } - }; -} - -void TaskConnection::beginSelectionSet(const service::SelectionSetParams& params) const -{ - _pimpl->beginSelectionSet(params); -} - -void TaskConnection::endSelectionSet(const service::SelectionSetParams& params) const -{ - _pimpl->endSelectionSet(params); -} - -service::AwaitableResolver TaskConnection::resolvePageInfo(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getPageInfo(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver TaskConnection::resolveEdges(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getEdges(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver TaskConnection::resolve_typename(service::ResolverParams&& params) const -{ - return service::ModifiedResult::convert(std::string{ R"gql(TaskConnection)gql" }, std::move(params)); -} - -FolderEdge::FolderEdge(std::unique_ptr&& pimpl) noexcept - : service::Object{ getTypeNames(), getResolvers() } - , _pimpl { std::move(pimpl) } -{ -} - -service::TypeNames FolderEdge::getTypeNames() const noexcept -{ - return { - R"gql(FolderEdge)gql"sv - }; -} - -service::ResolverMap FolderEdge::getResolvers() const noexcept -{ - return { - { R"gql(node)gql"sv, [this](service::ResolverParams&& params) { return resolveNode(std::move(params)); } }, - { R"gql(cursor)gql"sv, [this](service::ResolverParams&& params) { return resolveCursor(std::move(params)); } }, - { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } } - }; -} - -void FolderEdge::beginSelectionSet(const service::SelectionSetParams& params) const -{ - _pimpl->beginSelectionSet(params); -} - -void FolderEdge::endSelectionSet(const service::SelectionSetParams& params) const -{ - _pimpl->endSelectionSet(params); -} - -service::AwaitableResolver FolderEdge::resolveNode(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getNode(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver FolderEdge::resolveCursor(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getCursor(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver FolderEdge::resolve_typename(service::ResolverParams&& params) const -{ - return service::ModifiedResult::convert(std::string{ R"gql(FolderEdge)gql" }, std::move(params)); -} - -FolderConnection::FolderConnection(std::unique_ptr&& pimpl) noexcept - : service::Object{ getTypeNames(), getResolvers() } - , _pimpl { std::move(pimpl) } -{ -} - -service::TypeNames FolderConnection::getTypeNames() const noexcept -{ - return { - R"gql(FolderConnection)gql"sv - }; -} - -service::ResolverMap FolderConnection::getResolvers() const noexcept -{ - return { - { R"gql(edges)gql"sv, [this](service::ResolverParams&& params) { return resolveEdges(std::move(params)); } }, - { R"gql(pageInfo)gql"sv, [this](service::ResolverParams&& params) { return resolvePageInfo(std::move(params)); } }, - { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } } - }; -} - -void FolderConnection::beginSelectionSet(const service::SelectionSetParams& params) const -{ - _pimpl->beginSelectionSet(params); -} - -void FolderConnection::endSelectionSet(const service::SelectionSetParams& params) const -{ - _pimpl->endSelectionSet(params); -} - -service::AwaitableResolver FolderConnection::resolvePageInfo(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getPageInfo(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver FolderConnection::resolveEdges(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getEdges(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver FolderConnection::resolve_typename(service::ResolverParams&& params) const -{ - return service::ModifiedResult::convert(std::string{ R"gql(FolderConnection)gql" }, std::move(params)); -} - -CompleteTaskPayload::CompleteTaskPayload(std::unique_ptr&& pimpl) noexcept - : service::Object{ getTypeNames(), getResolvers() } - , _pimpl { std::move(pimpl) } -{ -} - -service::TypeNames CompleteTaskPayload::getTypeNames() const noexcept -{ - return { - R"gql(CompleteTaskPayload)gql"sv - }; -} - -service::ResolverMap CompleteTaskPayload::getResolvers() const noexcept -{ - return { - { R"gql(task)gql"sv, [this](service::ResolverParams&& params) { return resolveTask(std::move(params)); } }, - { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, - { R"gql(clientMutationId)gql"sv, [this](service::ResolverParams&& params) { return resolveClientMutationId(std::move(params)); } } - }; -} - -void CompleteTaskPayload::beginSelectionSet(const service::SelectionSetParams& params) const -{ - _pimpl->beginSelectionSet(params); -} - -void CompleteTaskPayload::endSelectionSet(const service::SelectionSetParams& params) const -{ - _pimpl->endSelectionSet(params); -} - -service::AwaitableResolver CompleteTaskPayload::resolveTask(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getTask(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver CompleteTaskPayload::resolveClientMutationId(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getClientMutationId(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver CompleteTaskPayload::resolve_typename(service::ResolverParams&& params) const -{ - return service::ModifiedResult::convert(std::string{ R"gql(CompleteTaskPayload)gql" }, std::move(params)); -} - -Mutation::Mutation(std::unique_ptr&& pimpl) noexcept - : service::Object{ getTypeNames(), getResolvers() } - , _pimpl { std::move(pimpl) } -{ -} - -service::TypeNames Mutation::getTypeNames() const noexcept -{ - return { - R"gql(Mutation)gql"sv - }; -} - -service::ResolverMap Mutation::getResolvers() const noexcept -{ - return { - { R"gql(setFloat)gql"sv, [this](service::ResolverParams&& params) { return resolveSetFloat(std::move(params)); } }, - { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, - { R"gql(completeTask)gql"sv, [this](service::ResolverParams&& params) { return resolveCompleteTask(std::move(params)); } } - }; -} - -void Mutation::beginSelectionSet(const service::SelectionSetParams& params) const -{ - _pimpl->beginSelectionSet(params); -} - -void Mutation::endSelectionSet(const service::SelectionSetParams& params) const -{ - _pimpl->endSelectionSet(params); -} - -service::AwaitableResolver Mutation::resolveCompleteTask(service::ResolverParams&& params) const -{ - auto argInput = service::ModifiedArgument::require("input", params.arguments); - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->applyCompleteTask(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argInput)); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Mutation::resolveSetFloat(service::ResolverParams&& params) const -{ - auto argValue = service::ModifiedArgument::require("value", params.arguments); - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->applySetFloat(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argValue)); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Mutation::resolve_typename(service::ResolverParams&& params) const -{ - return service::ModifiedResult::convert(std::string{ R"gql(Mutation)gql" }, std::move(params)); -} - -Subscription::Subscription(std::unique_ptr&& pimpl) noexcept - : service::Object{ getTypeNames(), getResolvers() } - , _pimpl { std::move(pimpl) } -{ -} - -service::TypeNames Subscription::getTypeNames() const noexcept -{ - return { - R"gql(Subscription)gql"sv - }; -} - -service::ResolverMap Subscription::getResolvers() const noexcept -{ - return { - { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, - { R"gql(nodeChange)gql"sv, [this](service::ResolverParams&& params) { return resolveNodeChange(std::move(params)); } }, - { R"gql(nextAppointmentChange)gql"sv, [this](service::ResolverParams&& params) { return resolveNextAppointmentChange(std::move(params)); } } - }; -} - -void Subscription::beginSelectionSet(const service::SelectionSetParams& params) const -{ - _pimpl->beginSelectionSet(params); -} - -void Subscription::endSelectionSet(const service::SelectionSetParams& params) const -{ - _pimpl->endSelectionSet(params); -} - -service::AwaitableResolver Subscription::resolveNextAppointmentChange(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getNextAppointmentChange(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Subscription::resolveNodeChange(service::ResolverParams&& params) const -{ - auto argId = service::ModifiedArgument::require("id", params.arguments); - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getNodeChange(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argId)); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Subscription::resolve_typename(service::ResolverParams&& params) const -{ - return service::ModifiedResult::convert(std::string{ R"gql(Subscription)gql" }, std::move(params)); -} - -Appointment::Appointment(std::unique_ptr&& pimpl) noexcept - : service::Object{ getTypeNames(), getResolvers() } - , _pimpl { std::move(pimpl) } -{ -} - -service::TypeNames Appointment::getTypeNames() const noexcept -{ - return { - R"gql(Node)gql"sv, - R"gql(UnionType)gql"sv, - R"gql(Appointment)gql"sv - }; -} - -service::ResolverMap Appointment::getResolvers() const noexcept -{ - return { - { R"gql(id)gql"sv, [this](service::ResolverParams&& params) { return resolveId(std::move(params)); } }, - { R"gql(when)gql"sv, [this](service::ResolverParams&& params) { return resolveWhen(std::move(params)); } }, - { R"gql(isNow)gql"sv, [this](service::ResolverParams&& params) { return resolveIsNow(std::move(params)); } }, - { R"gql(subject)gql"sv, [this](service::ResolverParams&& params) { return resolveSubject(std::move(params)); } }, - { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, - { R"gql(forceError)gql"sv, [this](service::ResolverParams&& params) { return resolveForceError(std::move(params)); } } - }; -} - -void Appointment::beginSelectionSet(const service::SelectionSetParams& params) const -{ - _pimpl->beginSelectionSet(params); -} - -void Appointment::endSelectionSet(const service::SelectionSetParams& params) const -{ - _pimpl->endSelectionSet(params); -} - -service::AwaitableResolver Appointment::resolveId(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getId(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Appointment::resolveWhen(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getWhen(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Appointment::resolveSubject(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getSubject(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Appointment::resolveIsNow(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getIsNow(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Appointment::resolveForceError(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getForceError(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Appointment::resolve_typename(service::ResolverParams&& params) const -{ - return service::ModifiedResult::convert(std::string{ R"gql(Appointment)gql" }, std::move(params)); -} - -Task::Task(std::unique_ptr&& pimpl) noexcept - : service::Object{ getTypeNames(), getResolvers() } - , _pimpl { std::move(pimpl) } -{ -} - -service::TypeNames Task::getTypeNames() const noexcept -{ - return { - R"gql(Node)gql"sv, - R"gql(UnionType)gql"sv, - R"gql(Task)gql"sv - }; -} - -service::ResolverMap Task::getResolvers() const noexcept -{ - return { - { R"gql(id)gql"sv, [this](service::ResolverParams&& params) { return resolveId(std::move(params)); } }, - { R"gql(title)gql"sv, [this](service::ResolverParams&& params) { return resolveTitle(std::move(params)); } }, - { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, - { R"gql(isComplete)gql"sv, [this](service::ResolverParams&& params) { return resolveIsComplete(std::move(params)); } } - }; -} - -void Task::beginSelectionSet(const service::SelectionSetParams& params) const -{ - _pimpl->beginSelectionSet(params); -} - -void Task::endSelectionSet(const service::SelectionSetParams& params) const -{ - _pimpl->endSelectionSet(params); -} - -service::AwaitableResolver Task::resolveId(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getId(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Task::resolveTitle(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getTitle(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Task::resolveIsComplete(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getIsComplete(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Task::resolve_typename(service::ResolverParams&& params) const -{ - return service::ModifiedResult::convert(std::string{ R"gql(Task)gql" }, std::move(params)); -} - -Folder::Folder(std::unique_ptr&& pimpl) noexcept - : service::Object{ getTypeNames(), getResolvers() } - , _pimpl { std::move(pimpl) } -{ -} - -service::TypeNames Folder::getTypeNames() const noexcept -{ - return { - R"gql(Node)gql"sv, - R"gql(UnionType)gql"sv, - R"gql(Folder)gql"sv - }; -} - -service::ResolverMap Folder::getResolvers() const noexcept -{ - return { - { R"gql(id)gql"sv, [this](service::ResolverParams&& params) { return resolveId(std::move(params)); } }, - { R"gql(name)gql"sv, [this](service::ResolverParams&& params) { return resolveName(std::move(params)); } }, - { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, - { R"gql(unreadCount)gql"sv, [this](service::ResolverParams&& params) { return resolveUnreadCount(std::move(params)); } } - }; -} - -void Folder::beginSelectionSet(const service::SelectionSetParams& params) const -{ - _pimpl->beginSelectionSet(params); -} - -void Folder::endSelectionSet(const service::SelectionSetParams& params) const -{ - _pimpl->endSelectionSet(params); -} - -service::AwaitableResolver Folder::resolveId(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getId(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Folder::resolveName(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getName(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Folder::resolveUnreadCount(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getUnreadCount(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Folder::resolve_typename(service::ResolverParams&& params) const -{ - return service::ModifiedResult::convert(std::string{ R"gql(Folder)gql" }, std::move(params)); -} - -NestedType::NestedType(std::unique_ptr&& pimpl) noexcept - : service::Object{ getTypeNames(), getResolvers() } - , _pimpl { std::move(pimpl) } -{ -} - -service::TypeNames NestedType::getTypeNames() const noexcept -{ - return { - R"gql(NestedType)gql"sv - }; -} - -service::ResolverMap NestedType::getResolvers() const noexcept -{ - return { - { R"gql(depth)gql"sv, [this](service::ResolverParams&& params) { return resolveDepth(std::move(params)); } }, - { R"gql(nested)gql"sv, [this](service::ResolverParams&& params) { return resolveNested(std::move(params)); } }, - { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } } - }; -} - -void NestedType::beginSelectionSet(const service::SelectionSetParams& params) const -{ - _pimpl->beginSelectionSet(params); -} - -void NestedType::endSelectionSet(const service::SelectionSetParams& params) const -{ - _pimpl->endSelectionSet(params); -} - -service::AwaitableResolver NestedType::resolveDepth(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getDepth(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver NestedType::resolveNested(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getNested(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver NestedType::resolve_typename(service::ResolverParams&& params) const -{ - return service::ModifiedResult::convert(std::string{ R"gql(NestedType)gql" }, std::move(params)); -} - -Expensive::Expensive(std::unique_ptr&& pimpl) noexcept - : service::Object{ getTypeNames(), getResolvers() } - , _pimpl { std::move(pimpl) } -{ -} - -service::TypeNames Expensive::getTypeNames() const noexcept -{ - return { - R"gql(Expensive)gql"sv - }; -} - -service::ResolverMap Expensive::getResolvers() const noexcept -{ - return { - { R"gql(order)gql"sv, [this](service::ResolverParams&& params) { return resolveOrder(std::move(params)); } }, - { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } } - }; -} - -void Expensive::beginSelectionSet(const service::SelectionSetParams& params) const -{ - _pimpl->beginSelectionSet(params); -} - -void Expensive::endSelectionSet(const service::SelectionSetParams& params) const -{ - _pimpl->endSelectionSet(params); -} - -service::AwaitableResolver Expensive::resolveOrder(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getOrder(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Expensive::resolve_typename(service::ResolverParams&& params) const -{ - return service::ModifiedResult::convert(std::string{ R"gql(Expensive)gql" }, std::move(params)); -} - -} // namespace object - -Operations::Operations(std::shared_ptr query, std::shared_ptr mutation, std::shared_ptr subscription) - : service::Request({ - { "query", query }, - { "mutation", mutation }, - { "subscription", subscription } - }, GetSchema()) - , _query(std::move(query)) - , _mutation(std::move(mutation)) - , _subscription(std::move(subscription)) -{ -} - -void AddTypesToSchema(const std::shared_ptr& schema) -{ - schema->AddType(R"gql(ItemCursor)gql"sv, schema::ScalarType::Make(R"gql(ItemCursor)gql"sv, R"md()md")); - schema->AddType(R"gql(DateTime)gql"sv, schema::ScalarType::Make(R"gql(DateTime)gql"sv, R"md()md")); - auto typeTaskState = schema::EnumType::Make(R"gql(TaskState)gql"sv, R"md()md"sv); - schema->AddType(R"gql(TaskState)gql"sv, typeTaskState); - auto typeCompleteTaskInput = schema::InputObjectType::Make(R"gql(CompleteTaskInput)gql"sv, R"md()md"sv); - schema->AddType(R"gql(CompleteTaskInput)gql"sv, typeCompleteTaskInput); - auto typeThirdNestedInput = schema::InputObjectType::Make(R"gql(ThirdNestedInput)gql"sv, R"md()md"sv); - schema->AddType(R"gql(ThirdNestedInput)gql"sv, typeThirdNestedInput); - auto typeFourthNestedInput = schema::InputObjectType::Make(R"gql(FourthNestedInput)gql"sv, R"md()md"sv); - schema->AddType(R"gql(FourthNestedInput)gql"sv, typeFourthNestedInput); - auto typeSecondNestedInput = schema::InputObjectType::Make(R"gql(SecondNestedInput)gql"sv, R"md()md"sv); - schema->AddType(R"gql(SecondNestedInput)gql"sv, typeSecondNestedInput); - auto typeFirstNestedInput = schema::InputObjectType::Make(R"gql(FirstNestedInput)gql"sv, R"md()md"sv); - schema->AddType(R"gql(FirstNestedInput)gql"sv, typeFirstNestedInput); - auto typeNode = schema::InterfaceType::Make(R"gql(Node)gql"sv, R"md(Node interface for Relay support)md"sv); - schema->AddType(R"gql(Node)gql"sv, typeNode); - auto typeUnionType = schema::UnionType::Make(R"gql(UnionType)gql"sv, R"md()md"sv); - schema->AddType(R"gql(UnionType)gql"sv, typeUnionType); - auto typeQuery = schema::ObjectType::Make(R"gql(Query)gql"sv, R"md(Root Query type)md"); - schema->AddType(R"gql(Query)gql"sv, typeQuery); - auto typePageInfo = schema::ObjectType::Make(R"gql(PageInfo)gql"sv, R"md()md"); - schema->AddType(R"gql(PageInfo)gql"sv, typePageInfo); - auto typeAppointmentEdge = schema::ObjectType::Make(R"gql(AppointmentEdge)gql"sv, R"md()md"); - schema->AddType(R"gql(AppointmentEdge)gql"sv, typeAppointmentEdge); - auto typeAppointmentConnection = schema::ObjectType::Make(R"gql(AppointmentConnection)gql"sv, R"md()md"); - schema->AddType(R"gql(AppointmentConnection)gql"sv, typeAppointmentConnection); - auto typeTaskEdge = schema::ObjectType::Make(R"gql(TaskEdge)gql"sv, R"md()md"); - schema->AddType(R"gql(TaskEdge)gql"sv, typeTaskEdge); - auto typeTaskConnection = schema::ObjectType::Make(R"gql(TaskConnection)gql"sv, R"md()md"); - schema->AddType(R"gql(TaskConnection)gql"sv, typeTaskConnection); - auto typeFolderEdge = schema::ObjectType::Make(R"gql(FolderEdge)gql"sv, R"md()md"); - schema->AddType(R"gql(FolderEdge)gql"sv, typeFolderEdge); - auto typeFolderConnection = schema::ObjectType::Make(R"gql(FolderConnection)gql"sv, R"md()md"); - schema->AddType(R"gql(FolderConnection)gql"sv, typeFolderConnection); - auto typeCompleteTaskPayload = schema::ObjectType::Make(R"gql(CompleteTaskPayload)gql"sv, R"md()md"); - schema->AddType(R"gql(CompleteTaskPayload)gql"sv, typeCompleteTaskPayload); - auto typeMutation = schema::ObjectType::Make(R"gql(Mutation)gql"sv, R"md()md"); - schema->AddType(R"gql(Mutation)gql"sv, typeMutation); - auto typeSubscription = schema::ObjectType::Make(R"gql(Subscription)gql"sv, R"md()md"); - schema->AddType(R"gql(Subscription)gql"sv, typeSubscription); - auto typeAppointment = schema::ObjectType::Make(R"gql(Appointment)gql"sv, R"md()md"); - schema->AddType(R"gql(Appointment)gql"sv, typeAppointment); - auto typeTask = schema::ObjectType::Make(R"gql(Task)gql"sv, R"md()md"); - schema->AddType(R"gql(Task)gql"sv, typeTask); - auto typeFolder = schema::ObjectType::Make(R"gql(Folder)gql"sv, R"md()md"); - schema->AddType(R"gql(Folder)gql"sv, typeFolder); - auto typeNestedType = schema::ObjectType::Make(R"gql(NestedType)gql"sv, R"md(Infinitely nestable type which can be used with nested fragments to test directive handling)md"); - schema->AddType(R"gql(NestedType)gql"sv, typeNestedType); - auto typeExpensive = schema::ObjectType::Make(R"gql(Expensive)gql"sv, R"md()md"); - schema->AddType(R"gql(Expensive)gql"sv, typeExpensive); - - typeTaskState->AddEnumValues({ - { service::s_namesTaskState[static_cast(today::TaskState::New)], R"md()md"sv, std::nullopt }, - { service::s_namesTaskState[static_cast(today::TaskState::Started)], R"md()md"sv, std::nullopt }, - { service::s_namesTaskState[static_cast(today::TaskState::Complete)], R"md()md"sv, std::nullopt }, - { service::s_namesTaskState[static_cast(today::TaskState::Unassigned)], R"md()md"sv, std::make_optional(R"md(Need to deprecate an [enum value](http://spec.graphql.org/June2018/#sec-Deprecation))md"sv) } - }); - - typeCompleteTaskInput->AddInputValues({ - schema::InputValue::Make(R"gql(id)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ID)gql"sv)), R"gql()gql"sv), - schema::InputValue::Make(R"gql(testTaskState)gql"sv, R"md()md"sv, schema->LookupType(R"gql(TaskState)gql"sv), R"gql()gql"sv), - schema::InputValue::Make(R"gql(isComplete)gql"sv, R"md()md"sv, schema->LookupType(R"gql(Boolean)gql"sv), R"gql(true)gql"sv), - schema::InputValue::Make(R"gql(clientMutationId)gql"sv, R"md()md"sv, schema->LookupType(R"gql(String)gql"sv), R"gql()gql"sv) - }); - typeThirdNestedInput->AddInputValues({ - schema::InputValue::Make(R"gql(id)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ID)gql"sv)), R"gql()gql"sv) - }); - typeFourthNestedInput->AddInputValues({ - schema::InputValue::Make(R"gql(id)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ID)gql"sv)), R"gql()gql"sv) - }); - typeSecondNestedInput->AddInputValues({ - schema::InputValue::Make(R"gql(id)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ID)gql"sv)), R"gql()gql"sv), - schema::InputValue::Make(R"gql(third)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ThirdNestedInput)gql"sv)), R"gql()gql"sv) - }); - typeFirstNestedInput->AddInputValues({ - schema::InputValue::Make(R"gql(id)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ID)gql"sv)), R"gql()gql"sv), - schema::InputValue::Make(R"gql(second)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(SecondNestedInput)gql"sv)), R"gql()gql"sv), - schema::InputValue::Make(R"gql(third)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ThirdNestedInput)gql"sv)), R"gql()gql"sv) - }); - - typeNode->AddFields({ - schema::Field::Make(R"gql(id)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ID)gql"sv))) - }); - - typeUnionType->AddPossibleTypes({ - schema->LookupType(R"gql(Appointment)gql"sv), - schema->LookupType(R"gql(Task)gql"sv), - schema->LookupType(R"gql(Folder)gql"sv) - }); - - typeQuery->AddFields({ - schema::Field::Make(R"gql(node)gql"sv, R"md([Object Identification](https://facebook.github.io/relay/docs/en/graphql-server-specification.html#object-identification))md"sv, std::nullopt, schema->LookupType(R"gql(Node)gql"sv), { - schema::InputValue::Make(R"gql(id)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ID)gql"sv)), R"gql()gql"sv) - }), - schema::Field::Make(R"gql(appointments)gql"sv, R"md(Appointments [Connection](https://facebook.github.io/relay/docs/en/graphql-server-specification.html#connections))md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(AppointmentConnection)gql"sv)), { - schema::InputValue::Make(R"gql(first)gql"sv, R"md()md"sv, schema->LookupType(R"gql(Int)gql"sv), R"gql()gql"sv), - schema::InputValue::Make(R"gql(after)gql"sv, R"md()md"sv, schema->LookupType(R"gql(ItemCursor)gql"sv), R"gql()gql"sv), - schema::InputValue::Make(R"gql(last)gql"sv, R"md()md"sv, schema->LookupType(R"gql(Int)gql"sv), R"gql()gql"sv), - schema::InputValue::Make(R"gql(before)gql"sv, R"md()md"sv, schema->LookupType(R"gql(ItemCursor)gql"sv), R"gql()gql"sv) - }), - schema::Field::Make(R"gql(tasks)gql"sv, R"md(Tasks [Connection](https://facebook.github.io/relay/docs/en/graphql-server-specification.html#connections))md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(TaskConnection)gql"sv)), { - schema::InputValue::Make(R"gql(first)gql"sv, R"md()md"sv, schema->LookupType(R"gql(Int)gql"sv), R"gql()gql"sv), - schema::InputValue::Make(R"gql(after)gql"sv, R"md()md"sv, schema->LookupType(R"gql(ItemCursor)gql"sv), R"gql()gql"sv), - schema::InputValue::Make(R"gql(last)gql"sv, R"md()md"sv, schema->LookupType(R"gql(Int)gql"sv), R"gql()gql"sv), - schema::InputValue::Make(R"gql(before)gql"sv, R"md()md"sv, schema->LookupType(R"gql(ItemCursor)gql"sv), R"gql()gql"sv) - }), - schema::Field::Make(R"gql(unreadCounts)gql"sv, R"md(Folder unread counts [Connection](https://facebook.github.io/relay/docs/en/graphql-server-specification.html#connections))md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(FolderConnection)gql"sv)), { - schema::InputValue::Make(R"gql(first)gql"sv, R"md()md"sv, schema->LookupType(R"gql(Int)gql"sv), R"gql()gql"sv), - schema::InputValue::Make(R"gql(after)gql"sv, R"md()md"sv, schema->LookupType(R"gql(ItemCursor)gql"sv), R"gql()gql"sv), - schema::InputValue::Make(R"gql(last)gql"sv, R"md()md"sv, schema->LookupType(R"gql(Int)gql"sv), R"gql()gql"sv), - schema::InputValue::Make(R"gql(before)gql"sv, R"md()md"sv, schema->LookupType(R"gql(ItemCursor)gql"sv), R"gql()gql"sv) - }), - schema::Field::Make(R"gql(appointmentsById)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->LookupType(R"gql(Appointment)gql"sv))), { - schema::InputValue::Make(R"gql(ids)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ID)gql"sv)))), R"gql(["ZmFrZUFwcG9pbnRtZW50SWQ="])gql"sv) - }), - schema::Field::Make(R"gql(tasksById)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->LookupType(R"gql(Task)gql"sv))), { - schema::InputValue::Make(R"gql(ids)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ID)gql"sv)))), R"gql()gql"sv) - }), - schema::Field::Make(R"gql(unreadCountsById)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->LookupType(R"gql(Folder)gql"sv))), { - schema::InputValue::Make(R"gql(ids)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ID)gql"sv)))), R"gql()gql"sv) - }), - schema::Field::Make(R"gql(nested)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(NestedType)gql"sv))), - schema::Field::Make(R"gql(unimplemented)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(String)gql"sv))), - schema::Field::Make(R"gql(expensive)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Expensive)gql"sv))))), - schema::Field::Make(R"gql(testTaskState)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(TaskState)gql"sv))), - schema::Field::Make(R"gql(anyType)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->LookupType(R"gql(UnionType)gql"sv))), { - schema::InputValue::Make(R"gql(ids)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ID)gql"sv)))), R"gql()gql"sv) - }) - }); - typePageInfo->AddFields({ - schema::Field::Make(R"gql(hasNextPage)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Boolean)gql"sv))), - schema::Field::Make(R"gql(hasPreviousPage)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Boolean)gql"sv))) - }); - typeAppointmentEdge->AddFields({ - schema::Field::Make(R"gql(node)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(Appointment)gql"sv)), - schema::Field::Make(R"gql(cursor)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ItemCursor)gql"sv))) - }); - typeAppointmentConnection->AddFields({ - schema::Field::Make(R"gql(pageInfo)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(PageInfo)gql"sv))), - schema::Field::Make(R"gql(edges)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::LIST, schema->LookupType(R"gql(AppointmentEdge)gql"sv))) - }); - typeTaskEdge->AddFields({ - schema::Field::Make(R"gql(node)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(Task)gql"sv)), - schema::Field::Make(R"gql(cursor)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ItemCursor)gql"sv))) - }); - typeTaskConnection->AddFields({ - schema::Field::Make(R"gql(pageInfo)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(PageInfo)gql"sv))), - schema::Field::Make(R"gql(edges)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::LIST, schema->LookupType(R"gql(TaskEdge)gql"sv))) - }); - typeFolderEdge->AddFields({ - schema::Field::Make(R"gql(node)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(Folder)gql"sv)), - schema::Field::Make(R"gql(cursor)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ItemCursor)gql"sv))) - }); - typeFolderConnection->AddFields({ - schema::Field::Make(R"gql(pageInfo)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(PageInfo)gql"sv))), - schema::Field::Make(R"gql(edges)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::LIST, schema->LookupType(R"gql(FolderEdge)gql"sv))) - }); - typeCompleteTaskPayload->AddFields({ - schema::Field::Make(R"gql(task)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(Task)gql"sv)), - schema::Field::Make(R"gql(clientMutationId)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(String)gql"sv)) - }); - typeMutation->AddFields({ - schema::Field::Make(R"gql(completeTask)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(CompleteTaskPayload)gql"sv)), { - schema::InputValue::Make(R"gql(input)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(CompleteTaskInput)gql"sv)), R"gql()gql"sv) - }), - schema::Field::Make(R"gql(setFloat)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Float)gql"sv)), { - schema::InputValue::Make(R"gql(value)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Float)gql"sv)), R"gql()gql"sv) - }) - }); - typeSubscription->AddFields({ - schema::Field::Make(R"gql(nextAppointmentChange)gql"sv, R"md()md"sv, std::make_optional(R"md(Need to deprecate a [field](http://spec.graphql.org/June2018/#sec-Deprecation))md"sv), schema->LookupType(R"gql(Appointment)gql"sv)), - schema::Field::Make(R"gql(nodeChange)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Node)gql"sv)), { - schema::InputValue::Make(R"gql(id)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ID)gql"sv)), R"gql()gql"sv) - }) - }); - typeAppointment->AddInterfaces({ - typeNode - }); - typeAppointment->AddFields({ - schema::Field::Make(R"gql(id)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ID)gql"sv))), - schema::Field::Make(R"gql(when)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(DateTime)gql"sv)), - schema::Field::Make(R"gql(subject)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(String)gql"sv)), - schema::Field::Make(R"gql(isNow)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Boolean)gql"sv))), - schema::Field::Make(R"gql(forceError)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(String)gql"sv)) - }); - typeTask->AddInterfaces({ - typeNode - }); - typeTask->AddFields({ - schema::Field::Make(R"gql(id)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ID)gql"sv))), - schema::Field::Make(R"gql(title)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(String)gql"sv)), - schema::Field::Make(R"gql(isComplete)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Boolean)gql"sv))) - }); - typeFolder->AddInterfaces({ - typeNode - }); - typeFolder->AddFields({ - schema::Field::Make(R"gql(id)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ID)gql"sv))), - schema::Field::Make(R"gql(name)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(String)gql"sv)), - schema::Field::Make(R"gql(unreadCount)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Int)gql"sv))) - }); - typeNestedType->AddFields({ - schema::Field::Make(R"gql(depth)gql"sv, R"md(Depth of the nested element)md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Int)gql"sv))), - schema::Field::Make(R"gql(nested)gql"sv, R"md(Link to the next level)md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(NestedType)gql"sv))) - }); - typeExpensive->AddFields({ - schema::Field::Make(R"gql(order)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Int)gql"sv))) - }); - - schema->AddDirective(schema::Directive::Make(R"gql(id)gql"sv, R"md()md"sv, { - introspection::DirectiveLocation::FIELD_DEFINITION - })); - schema->AddDirective(schema::Directive::Make(R"gql(subscriptionTag)gql"sv, R"md()md"sv, { - introspection::DirectiveLocation::SUBSCRIPTION - }, { - schema::InputValue::Make(R"gql(field)gql"sv, R"md()md"sv, schema->LookupType(R"gql(String)gql"sv), R"gql()gql"sv) - })); - schema->AddDirective(schema::Directive::Make(R"gql(queryTag)gql"sv, R"md()md"sv, { - introspection::DirectiveLocation::QUERY - }, { - schema::InputValue::Make(R"gql(query)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(String)gql"sv)), R"gql()gql"sv) - })); - schema->AddDirective(schema::Directive::Make(R"gql(fieldTag)gql"sv, R"md()md"sv, { - introspection::DirectiveLocation::FIELD - }, { - schema::InputValue::Make(R"gql(field)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(String)gql"sv)), R"gql()gql"sv) - })); - schema->AddDirective(schema::Directive::Make(R"gql(fragmentDefinitionTag)gql"sv, R"md()md"sv, { - introspection::DirectiveLocation::FRAGMENT_DEFINITION - }, { - schema::InputValue::Make(R"gql(fragmentDefinition)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(String)gql"sv)), R"gql()gql"sv) - })); - schema->AddDirective(schema::Directive::Make(R"gql(fragmentSpreadTag)gql"sv, R"md()md"sv, { - introspection::DirectiveLocation::FRAGMENT_SPREAD - }, { - schema::InputValue::Make(R"gql(fragmentSpread)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(String)gql"sv)), R"gql()gql"sv) - })); - schema->AddDirective(schema::Directive::Make(R"gql(inlineFragmentTag)gql"sv, R"md()md"sv, { - introspection::DirectiveLocation::INLINE_FRAGMENT - }, { - schema::InputValue::Make(R"gql(inlineFragment)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(String)gql"sv)), R"gql()gql"sv) - })); - - schema->AddQueryType(typeQuery); - schema->AddMutationType(typeMutation); - schema->AddSubscriptionType(typeSubscription); -} - -std::shared_ptr GetSchema() -{ - static std::weak_ptr s_wpSchema; - auto schema = s_wpSchema.lock(); - - if (!schema) - { - schema = std::make_shared(false); - introspection::AddTypesToSchema(schema); - AddTypesToSchema(schema); - s_wpSchema = schema; - } - - return schema; -} - -} // namespace today -} // namespace graphql diff --git a/samples/today/unified/TodaySchema.h b/samples/today/unified/TodaySchema.h deleted file mode 100644 index 0ee8ed5a..00000000 --- a/samples/today/unified/TodaySchema.h +++ /dev/null @@ -1,2938 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// WARNING! Do not edit this file manually, your changes will be overwritten. - -#pragma once - -#ifndef TODAYSCHEMA_H -#define TODAYSCHEMA_H - -#include "graphqlservice/internal/Schema.h" - -// Check if the library version is compatible with schemagen 4.0.0 -static_assert(graphql::internal::MajorVersion == 4, "regenerate with schemagen: major version mismatch"); -static_assert(graphql::internal::MinorVersion == 0, "regenerate with schemagen: minor version mismatch"); - -#include -#include -#include - -namespace graphql { -namespace today { - -enum class TaskState -{ - New, - Started, - Complete, - Unassigned -}; - -struct CompleteTaskInput -{ - response::IdType id; - std::optional testTaskState; - std::optional isComplete; - std::optional clientMutationId; -}; - -struct ThirdNestedInput -{ - response::IdType id; -}; - -struct FourthNestedInput -{ - response::IdType id; -}; - -struct SecondNestedInput -{ - response::IdType id; - ThirdNestedInput third; -}; - -struct FirstNestedInput -{ - response::IdType id; - SecondNestedInput second; - ThirdNestedInput third; -}; - -namespace object { - -class Node; - -class UnionType; - -class Query; -class PageInfo; -class AppointmentEdge; -class AppointmentConnection; -class TaskEdge; -class TaskConnection; -class FolderEdge; -class FolderConnection; -class CompleteTaskPayload; -class Mutation; -class Subscription; -class Appointment; -class Task; -class Folder; -class NestedType; -class Expensive; - -class Node - : public service::Object -{ -private: - struct Concept - { - virtual ~Concept() = default; - - virtual service::TypeNames getTypeNames() const noexcept = 0; - virtual service::ResolverMap getResolvers() const noexcept = 0; - - virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - }; - - template - struct Model - : Concept - { - Model(std::shared_ptr&& pimpl) noexcept - : _pimpl { std::move(pimpl) } - { - } - - service::TypeNames getTypeNames() const noexcept final - { - return _pimpl->getTypeNames(); - } - - service::ResolverMap getResolvers() const noexcept final - { - return _pimpl->getResolvers(); - } - - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - _pimpl->beginSelectionSet(params); - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - _pimpl->endSelectionSet(params); - } - - private: - const std::shared_ptr _pimpl; - }; - - Node(std::unique_ptr&& pimpl) noexcept; - - void beginSelectionSet(const service::SelectionSetParams& params) const final; - void endSelectionSet(const service::SelectionSetParams& params) const final; - - const std::unique_ptr _pimpl; - -public: - template - Node(std::shared_ptr pimpl) noexcept - : Node { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } - { - static_assert(T::template implements(), "Node is not implemented"); - } -}; - -class UnionType - : public service::Object -{ -private: - struct Concept - { - virtual ~Concept() = default; - - virtual service::TypeNames getTypeNames() const noexcept = 0; - virtual service::ResolverMap getResolvers() const noexcept = 0; - - virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - }; - - template - struct Model - : Concept - { - Model(std::shared_ptr&& pimpl) noexcept - : _pimpl { std::move(pimpl) } - { - } - - service::TypeNames getTypeNames() const noexcept final - { - return _pimpl->getTypeNames(); - } - - service::ResolverMap getResolvers() const noexcept final - { - return _pimpl->getResolvers(); - } - - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - _pimpl->beginSelectionSet(params); - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - _pimpl->endSelectionSet(params); - } - - private: - const std::shared_ptr _pimpl; - }; - - UnionType(std::unique_ptr&& pimpl) noexcept; - - void beginSelectionSet(const service::SelectionSetParams& params) const final; - void endSelectionSet(const service::SelectionSetParams& params) const final; - - const std::unique_ptr _pimpl; - -public: - template - UnionType(std::shared_ptr pimpl) noexcept - : UnionType { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } - { - static_assert(T::template implements(), "UnionType is not implemented"); - } -}; - -namespace implements { - -template -concept AppointmentIs = std::is_same_v || std::is_same_v; - -template -concept TaskIs = std::is_same_v || std::is_same_v; - -template -concept FolderIs = std::is_same_v || std::is_same_v; - -} // namespace implements - -namespace methods { -namespace QueryHas { - -template -concept getNodeWithParams = requires (TImpl impl, service::FieldParams params, response::IdType idArg) -{ - { service::FieldResult> { impl.getNode(std::move(params), std::move(idArg)) } }; -}; - -template -concept getNode = requires (TImpl impl, response::IdType idArg) -{ - { service::FieldResult> { impl.getNode(std::move(idArg)) } }; -}; - -template -concept getAppointmentsWithParams = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) -{ - { service::FieldResult> { impl.getAppointments(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; -}; - -template -concept getAppointments = requires (TImpl impl, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) -{ - { service::FieldResult> { impl.getAppointments(std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; -}; - -template -concept getTasksWithParams = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) -{ - { service::FieldResult> { impl.getTasks(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; -}; - -template -concept getTasks = requires (TImpl impl, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) -{ - { service::FieldResult> { impl.getTasks(std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; -}; - -template -concept getUnreadCountsWithParams = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) -{ - { service::FieldResult> { impl.getUnreadCounts(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; -}; - -template -concept getUnreadCounts = requires (TImpl impl, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) -{ - { service::FieldResult> { impl.getUnreadCounts(std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; -}; - -template -concept getAppointmentsByIdWithParams = requires (TImpl impl, service::FieldParams params, std::vector idsArg) -{ - { service::FieldResult>> { impl.getAppointmentsById(std::move(params), std::move(idsArg)) } }; -}; - -template -concept getAppointmentsById = requires (TImpl impl, std::vector idsArg) -{ - { service::FieldResult>> { impl.getAppointmentsById(std::move(idsArg)) } }; -}; - -template -concept getTasksByIdWithParams = requires (TImpl impl, service::FieldParams params, std::vector idsArg) -{ - { service::FieldResult>> { impl.getTasksById(std::move(params), std::move(idsArg)) } }; -}; - -template -concept getTasksById = requires (TImpl impl, std::vector idsArg) -{ - { service::FieldResult>> { impl.getTasksById(std::move(idsArg)) } }; -}; - -template -concept getUnreadCountsByIdWithParams = requires (TImpl impl, service::FieldParams params, std::vector idsArg) -{ - { service::FieldResult>> { impl.getUnreadCountsById(std::move(params), std::move(idsArg)) } }; -}; - -template -concept getUnreadCountsById = requires (TImpl impl, std::vector idsArg) -{ - { service::FieldResult>> { impl.getUnreadCountsById(std::move(idsArg)) } }; -}; - -template -concept getNestedWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getNested(std::move(params)) } }; -}; - -template -concept getNested = requires (TImpl impl) -{ - { service::FieldResult> { impl.getNested() } }; -}; - -template -concept getUnimplementedWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult { impl.getUnimplemented(std::move(params)) } }; -}; - -template -concept getUnimplemented = requires (TImpl impl) -{ - { service::FieldResult { impl.getUnimplemented() } }; -}; - -template -concept getExpensiveWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult>> { impl.getExpensive(std::move(params)) } }; -}; - -template -concept getExpensive = requires (TImpl impl) -{ - { service::FieldResult>> { impl.getExpensive() } }; -}; - -template -concept getTestTaskStateWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult { impl.getTestTaskState(std::move(params)) } }; -}; - -template -concept getTestTaskState = requires (TImpl impl) -{ - { service::FieldResult { impl.getTestTaskState() } }; -}; - -template -concept getAnyTypeWithParams = requires (TImpl impl, service::FieldParams params, std::vector idsArg) -{ - { service::FieldResult>> { impl.getAnyType(std::move(params), std::move(idsArg)) } }; -}; - -template -concept getAnyType = requires (TImpl impl, std::vector idsArg) -{ - { service::FieldResult>> { impl.getAnyType(std::move(idsArg)) } }; -}; - -template -concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) -{ - { impl.beginSelectionSet(params) }; -}; - -template -concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) -{ - { impl.endSelectionSet(params) }; -}; - -} // namespace QueryHas - -namespace PageInfoHas { - -template -concept getHasNextPageWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult { impl.getHasNextPage(std::move(params)) } }; -}; - -template -concept getHasNextPage = requires (TImpl impl) -{ - { service::FieldResult { impl.getHasNextPage() } }; -}; - -template -concept getHasPreviousPageWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult { impl.getHasPreviousPage(std::move(params)) } }; -}; - -template -concept getHasPreviousPage = requires (TImpl impl) -{ - { service::FieldResult { impl.getHasPreviousPage() } }; -}; - -template -concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) -{ - { impl.beginSelectionSet(params) }; -}; - -template -concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) -{ - { impl.endSelectionSet(params) }; -}; - -} // namespace PageInfoHas - -namespace AppointmentEdgeHas { - -template -concept getNodeWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getNode(std::move(params)) } }; -}; - -template -concept getNode = requires (TImpl impl) -{ - { service::FieldResult> { impl.getNode() } }; -}; - -template -concept getCursorWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult { impl.getCursor(std::move(params)) } }; -}; - -template -concept getCursor = requires (TImpl impl) -{ - { service::FieldResult { impl.getCursor() } }; -}; - -template -concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) -{ - { impl.beginSelectionSet(params) }; -}; - -template -concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) -{ - { impl.endSelectionSet(params) }; -}; - -} // namespace AppointmentEdgeHas - -namespace AppointmentConnectionHas { - -template -concept getPageInfoWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getPageInfo(std::move(params)) } }; -}; - -template -concept getPageInfo = requires (TImpl impl) -{ - { service::FieldResult> { impl.getPageInfo() } }; -}; - -template -concept getEdgesWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult>>> { impl.getEdges(std::move(params)) } }; -}; - -template -concept getEdges = requires (TImpl impl) -{ - { service::FieldResult>>> { impl.getEdges() } }; -}; - -template -concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) -{ - { impl.beginSelectionSet(params) }; -}; - -template -concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) -{ - { impl.endSelectionSet(params) }; -}; - -} // namespace AppointmentConnectionHas - -namespace TaskEdgeHas { - -template -concept getNodeWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getNode(std::move(params)) } }; -}; - -template -concept getNode = requires (TImpl impl) -{ - { service::FieldResult> { impl.getNode() } }; -}; - -template -concept getCursorWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult { impl.getCursor(std::move(params)) } }; -}; - -template -concept getCursor = requires (TImpl impl) -{ - { service::FieldResult { impl.getCursor() } }; -}; - -template -concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) -{ - { impl.beginSelectionSet(params) }; -}; - -template -concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) -{ - { impl.endSelectionSet(params) }; -}; - -} // namespace TaskEdgeHas - -namespace TaskConnectionHas { - -template -concept getPageInfoWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getPageInfo(std::move(params)) } }; -}; - -template -concept getPageInfo = requires (TImpl impl) -{ - { service::FieldResult> { impl.getPageInfo() } }; -}; - -template -concept getEdgesWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult>>> { impl.getEdges(std::move(params)) } }; -}; - -template -concept getEdges = requires (TImpl impl) -{ - { service::FieldResult>>> { impl.getEdges() } }; -}; - -template -concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) -{ - { impl.beginSelectionSet(params) }; -}; - -template -concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) -{ - { impl.endSelectionSet(params) }; -}; - -} // namespace TaskConnectionHas - -namespace FolderEdgeHas { - -template -concept getNodeWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getNode(std::move(params)) } }; -}; - -template -concept getNode = requires (TImpl impl) -{ - { service::FieldResult> { impl.getNode() } }; -}; - -template -concept getCursorWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult { impl.getCursor(std::move(params)) } }; -}; - -template -concept getCursor = requires (TImpl impl) -{ - { service::FieldResult { impl.getCursor() } }; -}; - -template -concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) -{ - { impl.beginSelectionSet(params) }; -}; - -template -concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) -{ - { impl.endSelectionSet(params) }; -}; - -} // namespace FolderEdgeHas - -namespace FolderConnectionHas { - -template -concept getPageInfoWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getPageInfo(std::move(params)) } }; -}; - -template -concept getPageInfo = requires (TImpl impl) -{ - { service::FieldResult> { impl.getPageInfo() } }; -}; - -template -concept getEdgesWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult>>> { impl.getEdges(std::move(params)) } }; -}; - -template -concept getEdges = requires (TImpl impl) -{ - { service::FieldResult>>> { impl.getEdges() } }; -}; - -template -concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) -{ - { impl.beginSelectionSet(params) }; -}; - -template -concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) -{ - { impl.endSelectionSet(params) }; -}; - -} // namespace FolderConnectionHas - -namespace CompleteTaskPayloadHas { - -template -concept getTaskWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getTask(std::move(params)) } }; -}; - -template -concept getTask = requires (TImpl impl) -{ - { service::FieldResult> { impl.getTask() } }; -}; - -template -concept getClientMutationIdWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getClientMutationId(std::move(params)) } }; -}; - -template -concept getClientMutationId = requires (TImpl impl) -{ - { service::FieldResult> { impl.getClientMutationId() } }; -}; - -template -concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) -{ - { impl.beginSelectionSet(params) }; -}; - -template -concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) -{ - { impl.endSelectionSet(params) }; -}; - -} // namespace CompleteTaskPayloadHas - -namespace MutationHas { - -template -concept applyCompleteTaskWithParams = requires (TImpl impl, service::FieldParams params, CompleteTaskInput inputArg) -{ - { service::FieldResult> { impl.applyCompleteTask(std::move(params), std::move(inputArg)) } }; -}; - -template -concept applyCompleteTask = requires (TImpl impl, CompleteTaskInput inputArg) -{ - { service::FieldResult> { impl.applyCompleteTask(std::move(inputArg)) } }; -}; - -template -concept applySetFloatWithParams = requires (TImpl impl, service::FieldParams params, double valueArg) -{ - { service::FieldResult { impl.applySetFloat(std::move(params), std::move(valueArg)) } }; -}; - -template -concept applySetFloat = requires (TImpl impl, double valueArg) -{ - { service::FieldResult { impl.applySetFloat(std::move(valueArg)) } }; -}; - -template -concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) -{ - { impl.beginSelectionSet(params) }; -}; - -template -concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) -{ - { impl.endSelectionSet(params) }; -}; - -} // namespace MutationHas - -namespace SubscriptionHas { - -template -concept getNextAppointmentChangeWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getNextAppointmentChange(std::move(params)) } }; -}; - -template -concept getNextAppointmentChange = requires (TImpl impl) -{ - { service::FieldResult> { impl.getNextAppointmentChange() } }; -}; - -template -concept getNodeChangeWithParams = requires (TImpl impl, service::FieldParams params, response::IdType idArg) -{ - { service::FieldResult> { impl.getNodeChange(std::move(params), std::move(idArg)) } }; -}; - -template -concept getNodeChange = requires (TImpl impl, response::IdType idArg) -{ - { service::FieldResult> { impl.getNodeChange(std::move(idArg)) } }; -}; - -template -concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) -{ - { impl.beginSelectionSet(params) }; -}; - -template -concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) -{ - { impl.endSelectionSet(params) }; -}; - -} // namespace SubscriptionHas - -namespace AppointmentHas { - -template -concept getIdWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult { impl.getId(std::move(params)) } }; -}; - -template -concept getId = requires (TImpl impl) -{ - { service::FieldResult { impl.getId() } }; -}; - -template -concept getWhenWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getWhen(std::move(params)) } }; -}; - -template -concept getWhen = requires (TImpl impl) -{ - { service::FieldResult> { impl.getWhen() } }; -}; - -template -concept getSubjectWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getSubject(std::move(params)) } }; -}; - -template -concept getSubject = requires (TImpl impl) -{ - { service::FieldResult> { impl.getSubject() } }; -}; - -template -concept getIsNowWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult { impl.getIsNow(std::move(params)) } }; -}; - -template -concept getIsNow = requires (TImpl impl) -{ - { service::FieldResult { impl.getIsNow() } }; -}; - -template -concept getForceErrorWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getForceError(std::move(params)) } }; -}; - -template -concept getForceError = requires (TImpl impl) -{ - { service::FieldResult> { impl.getForceError() } }; -}; - -template -concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) -{ - { impl.beginSelectionSet(params) }; -}; - -template -concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) -{ - { impl.endSelectionSet(params) }; -}; - -} // namespace AppointmentHas - -namespace TaskHas { - -template -concept getIdWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult { impl.getId(std::move(params)) } }; -}; - -template -concept getId = requires (TImpl impl) -{ - { service::FieldResult { impl.getId() } }; -}; - -template -concept getTitleWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getTitle(std::move(params)) } }; -}; - -template -concept getTitle = requires (TImpl impl) -{ - { service::FieldResult> { impl.getTitle() } }; -}; - -template -concept getIsCompleteWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult { impl.getIsComplete(std::move(params)) } }; -}; - -template -concept getIsComplete = requires (TImpl impl) -{ - { service::FieldResult { impl.getIsComplete() } }; -}; - -template -concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) -{ - { impl.beginSelectionSet(params) }; -}; - -template -concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) -{ - { impl.endSelectionSet(params) }; -}; - -} // namespace TaskHas - -namespace FolderHas { - -template -concept getIdWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult { impl.getId(std::move(params)) } }; -}; - -template -concept getId = requires (TImpl impl) -{ - { service::FieldResult { impl.getId() } }; -}; - -template -concept getNameWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getName(std::move(params)) } }; -}; - -template -concept getName = requires (TImpl impl) -{ - { service::FieldResult> { impl.getName() } }; -}; - -template -concept getUnreadCountWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult { impl.getUnreadCount(std::move(params)) } }; -}; - -template -concept getUnreadCount = requires (TImpl impl) -{ - { service::FieldResult { impl.getUnreadCount() } }; -}; - -template -concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) -{ - { impl.beginSelectionSet(params) }; -}; - -template -concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) -{ - { impl.endSelectionSet(params) }; -}; - -} // namespace FolderHas - -namespace NestedTypeHas { - -template -concept getDepthWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult { impl.getDepth(std::move(params)) } }; -}; - -template -concept getDepth = requires (TImpl impl) -{ - { service::FieldResult { impl.getDepth() } }; -}; - -template -concept getNestedWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getNested(std::move(params)) } }; -}; - -template -concept getNested = requires (TImpl impl) -{ - { service::FieldResult> { impl.getNested() } }; -}; - -template -concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) -{ - { impl.beginSelectionSet(params) }; -}; - -template -concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) -{ - { impl.endSelectionSet(params) }; -}; - -} // namespace NestedTypeHas - -namespace ExpensiveHas { - -template -concept getOrderWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult { impl.getOrder(std::move(params)) } }; -}; - -template -concept getOrder = requires (TImpl impl) -{ - { service::FieldResult { impl.getOrder() } }; -}; - -template -concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) -{ - { impl.beginSelectionSet(params) }; -}; - -template -concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) -{ - { impl.endSelectionSet(params) }; -}; - -} // namespace ExpensiveHas -} // namespace methods - -class Query - : public service::Object -{ -private: - service::AwaitableResolver resolveNode(service::ResolverParams&& params) const; - service::AwaitableResolver resolveAppointments(service::ResolverParams&& params) const; - service::AwaitableResolver resolveTasks(service::ResolverParams&& params) const; - service::AwaitableResolver resolveUnreadCounts(service::ResolverParams&& params) const; - service::AwaitableResolver resolveAppointmentsById(service::ResolverParams&& params) const; - service::AwaitableResolver resolveTasksById(service::ResolverParams&& params) const; - service::AwaitableResolver resolveUnreadCountsById(service::ResolverParams&& params) const; - service::AwaitableResolver resolveNested(service::ResolverParams&& params) const; - service::AwaitableResolver resolveUnimplemented(service::ResolverParams&& params) const; - service::AwaitableResolver resolveExpensive(service::ResolverParams&& params) const; - service::AwaitableResolver resolveTestTaskState(service::ResolverParams&& params) const; - service::AwaitableResolver resolveAnyType(service::ResolverParams&& params) const; - - service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; - service::AwaitableResolver resolve_schema(service::ResolverParams&& params) const; - service::AwaitableResolver resolve_type(service::ResolverParams&& params) const; - - std::shared_ptr _schema; - - struct Concept - { - virtual ~Concept() = default; - - virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - - virtual service::FieldResult> getNode(service::FieldParams&& params, response::IdType&& idArg) const = 0; - virtual service::FieldResult> getAppointments(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const = 0; - virtual service::FieldResult> getTasks(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const = 0; - virtual service::FieldResult> getUnreadCounts(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const = 0; - virtual service::FieldResult>> getAppointmentsById(service::FieldParams&& params, std::vector&& idsArg) const = 0; - virtual service::FieldResult>> getTasksById(service::FieldParams&& params, std::vector&& idsArg) const = 0; - virtual service::FieldResult>> getUnreadCountsById(service::FieldParams&& params, std::vector&& idsArg) const = 0; - virtual service::FieldResult> getNested(service::FieldParams&& params) const = 0; - virtual service::FieldResult getUnimplemented(service::FieldParams&& params) const = 0; - virtual service::FieldResult>> getExpensive(service::FieldParams&& params) const = 0; - virtual service::FieldResult getTestTaskState(service::FieldParams&& params) const = 0; - virtual service::FieldResult>> getAnyType(service::FieldParams&& params, std::vector&& idsArg) const = 0; - }; - - template - struct Model - : Concept - { - Model(std::shared_ptr&& pimpl) noexcept - : _pimpl { std::move(pimpl) } - { - } - - service::FieldResult> getNode(service::FieldParams&& params, response::IdType&& idArg) const final - { - if constexpr (methods::QueryHas::getNodeWithParams) - { - return { _pimpl->getNode(std::move(params), std::move(idArg)) }; - } - else if constexpr (methods::QueryHas::getNode) - { - return { _pimpl->getNode(std::move(idArg)) }; - } - else - { - throw std::runtime_error(R"ex(Query::getNode is not implemented)ex"); - } - } - - service::FieldResult> getAppointments(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const final - { - if constexpr (methods::QueryHas::getAppointmentsWithParams) - { - return { _pimpl->getAppointments(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) }; - } - else if constexpr (methods::QueryHas::getAppointments) - { - return { _pimpl->getAppointments(std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) }; - } - else - { - throw std::runtime_error(R"ex(Query::getAppointments is not implemented)ex"); - } - } - - service::FieldResult> getTasks(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const final - { - if constexpr (methods::QueryHas::getTasksWithParams) - { - return { _pimpl->getTasks(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) }; - } - else if constexpr (methods::QueryHas::getTasks) - { - return { _pimpl->getTasks(std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) }; - } - else - { - throw std::runtime_error(R"ex(Query::getTasks is not implemented)ex"); - } - } - - service::FieldResult> getUnreadCounts(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const final - { - if constexpr (methods::QueryHas::getUnreadCountsWithParams) - { - return { _pimpl->getUnreadCounts(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) }; - } - else if constexpr (methods::QueryHas::getUnreadCounts) - { - return { _pimpl->getUnreadCounts(std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) }; - } - else - { - throw std::runtime_error(R"ex(Query::getUnreadCounts is not implemented)ex"); - } - } - - service::FieldResult>> getAppointmentsById(service::FieldParams&& params, std::vector&& idsArg) const final - { - if constexpr (methods::QueryHas::getAppointmentsByIdWithParams) - { - return { _pimpl->getAppointmentsById(std::move(params), std::move(idsArg)) }; - } - else if constexpr (methods::QueryHas::getAppointmentsById) - { - return { _pimpl->getAppointmentsById(std::move(idsArg)) }; - } - else - { - throw std::runtime_error(R"ex(Query::getAppointmentsById is not implemented)ex"); - } - } - - service::FieldResult>> getTasksById(service::FieldParams&& params, std::vector&& idsArg) const final - { - if constexpr (methods::QueryHas::getTasksByIdWithParams) - { - return { _pimpl->getTasksById(std::move(params), std::move(idsArg)) }; - } - else if constexpr (methods::QueryHas::getTasksById) - { - return { _pimpl->getTasksById(std::move(idsArg)) }; - } - else - { - throw std::runtime_error(R"ex(Query::getTasksById is not implemented)ex"); - } - } - - service::FieldResult>> getUnreadCountsById(service::FieldParams&& params, std::vector&& idsArg) const final - { - if constexpr (methods::QueryHas::getUnreadCountsByIdWithParams) - { - return { _pimpl->getUnreadCountsById(std::move(params), std::move(idsArg)) }; - } - else if constexpr (methods::QueryHas::getUnreadCountsById) - { - return { _pimpl->getUnreadCountsById(std::move(idsArg)) }; - } - else - { - throw std::runtime_error(R"ex(Query::getUnreadCountsById is not implemented)ex"); - } - } - - service::FieldResult> getNested(service::FieldParams&& params) const final - { - if constexpr (methods::QueryHas::getNestedWithParams) - { - return { _pimpl->getNested(std::move(params)) }; - } - else if constexpr (methods::QueryHas::getNested) - { - return { _pimpl->getNested() }; - } - else - { - throw std::runtime_error(R"ex(Query::getNested is not implemented)ex"); - } - } - - service::FieldResult getUnimplemented(service::FieldParams&& params) const final - { - if constexpr (methods::QueryHas::getUnimplementedWithParams) - { - return { _pimpl->getUnimplemented(std::move(params)) }; - } - else if constexpr (methods::QueryHas::getUnimplemented) - { - return { _pimpl->getUnimplemented() }; - } - else - { - throw std::runtime_error(R"ex(Query::getUnimplemented is not implemented)ex"); - } - } - - service::FieldResult>> getExpensive(service::FieldParams&& params) const final - { - if constexpr (methods::QueryHas::getExpensiveWithParams) - { - return { _pimpl->getExpensive(std::move(params)) }; - } - else if constexpr (methods::QueryHas::getExpensive) - { - return { _pimpl->getExpensive() }; - } - else - { - throw std::runtime_error(R"ex(Query::getExpensive is not implemented)ex"); - } - } - - service::FieldResult getTestTaskState(service::FieldParams&& params) const final - { - if constexpr (methods::QueryHas::getTestTaskStateWithParams) - { - return { _pimpl->getTestTaskState(std::move(params)) }; - } - else if constexpr (methods::QueryHas::getTestTaskState) - { - return { _pimpl->getTestTaskState() }; - } - else - { - throw std::runtime_error(R"ex(Query::getTestTaskState is not implemented)ex"); - } - } - - service::FieldResult>> getAnyType(service::FieldParams&& params, std::vector&& idsArg) const final - { - if constexpr (methods::QueryHas::getAnyTypeWithParams) - { - return { _pimpl->getAnyType(std::move(params), std::move(idsArg)) }; - } - else if constexpr (methods::QueryHas::getAnyType) - { - return { _pimpl->getAnyType(std::move(idsArg)) }; - } - else - { - throw std::runtime_error(R"ex(Query::getAnyType is not implemented)ex"); - } - } - - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (methods::QueryHas::beginSelectionSet) - { - _pimpl->beginSelectionSet(params); - } - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (methods::QueryHas::endSelectionSet) - { - _pimpl->endSelectionSet(params); - } - } - - private: - const std::shared_ptr _pimpl; - }; - - Query(std::unique_ptr&& pimpl) noexcept; - - service::TypeNames getTypeNames() const noexcept; - service::ResolverMap getResolvers() const noexcept; - - void beginSelectionSet(const service::SelectionSetParams& params) const final; - void endSelectionSet(const service::SelectionSetParams& params) const final; - - const std::unique_ptr _pimpl; - -public: - template - Query(std::shared_ptr pimpl) noexcept - : Query { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } - { - } -}; - -class PageInfo - : public service::Object -{ -private: - service::AwaitableResolver resolveHasNextPage(service::ResolverParams&& params) const; - service::AwaitableResolver resolveHasPreviousPage(service::ResolverParams&& params) const; - - service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; - - struct Concept - { - virtual ~Concept() = default; - - virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - - virtual service::FieldResult getHasNextPage(service::FieldParams&& params) const = 0; - virtual service::FieldResult getHasPreviousPage(service::FieldParams&& params) const = 0; - }; - - template - struct Model - : Concept - { - Model(std::shared_ptr&& pimpl) noexcept - : _pimpl { std::move(pimpl) } - { - } - - service::FieldResult getHasNextPage(service::FieldParams&& params) const final - { - if constexpr (methods::PageInfoHas::getHasNextPageWithParams) - { - return { _pimpl->getHasNextPage(std::move(params)) }; - } - else if constexpr (methods::PageInfoHas::getHasNextPage) - { - return { _pimpl->getHasNextPage() }; - } - else - { - throw std::runtime_error(R"ex(PageInfo::getHasNextPage is not implemented)ex"); - } - } - - service::FieldResult getHasPreviousPage(service::FieldParams&& params) const final - { - if constexpr (methods::PageInfoHas::getHasPreviousPageWithParams) - { - return { _pimpl->getHasPreviousPage(std::move(params)) }; - } - else if constexpr (methods::PageInfoHas::getHasPreviousPage) - { - return { _pimpl->getHasPreviousPage() }; - } - else - { - throw std::runtime_error(R"ex(PageInfo::getHasPreviousPage is not implemented)ex"); - } - } - - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (methods::PageInfoHas::beginSelectionSet) - { - _pimpl->beginSelectionSet(params); - } - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (methods::PageInfoHas::endSelectionSet) - { - _pimpl->endSelectionSet(params); - } - } - - private: - const std::shared_ptr _pimpl; - }; - - PageInfo(std::unique_ptr&& pimpl) noexcept; - - service::TypeNames getTypeNames() const noexcept; - service::ResolverMap getResolvers() const noexcept; - - void beginSelectionSet(const service::SelectionSetParams& params) const final; - void endSelectionSet(const service::SelectionSetParams& params) const final; - - const std::unique_ptr _pimpl; - -public: - template - PageInfo(std::shared_ptr pimpl) noexcept - : PageInfo { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } - { - } -}; - -class AppointmentEdge - : public service::Object -{ -private: - service::AwaitableResolver resolveNode(service::ResolverParams&& params) const; - service::AwaitableResolver resolveCursor(service::ResolverParams&& params) const; - - service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; - - struct Concept - { - virtual ~Concept() = default; - - virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - - virtual service::FieldResult> getNode(service::FieldParams&& params) const = 0; - virtual service::FieldResult getCursor(service::FieldParams&& params) const = 0; - }; - - template - struct Model - : Concept - { - Model(std::shared_ptr&& pimpl) noexcept - : _pimpl { std::move(pimpl) } - { - } - - service::FieldResult> getNode(service::FieldParams&& params) const final - { - if constexpr (methods::AppointmentEdgeHas::getNodeWithParams) - { - return { _pimpl->getNode(std::move(params)) }; - } - else if constexpr (methods::AppointmentEdgeHas::getNode) - { - return { _pimpl->getNode() }; - } - else - { - throw std::runtime_error(R"ex(AppointmentEdge::getNode is not implemented)ex"); - } - } - - service::FieldResult getCursor(service::FieldParams&& params) const final - { - if constexpr (methods::AppointmentEdgeHas::getCursorWithParams) - { - return { _pimpl->getCursor(std::move(params)) }; - } - else if constexpr (methods::AppointmentEdgeHas::getCursor) - { - return { _pimpl->getCursor() }; - } - else - { - throw std::runtime_error(R"ex(AppointmentEdge::getCursor is not implemented)ex"); - } - } - - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (methods::AppointmentEdgeHas::beginSelectionSet) - { - _pimpl->beginSelectionSet(params); - } - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (methods::AppointmentEdgeHas::endSelectionSet) - { - _pimpl->endSelectionSet(params); - } - } - - private: - const std::shared_ptr _pimpl; - }; - - AppointmentEdge(std::unique_ptr&& pimpl) noexcept; - - service::TypeNames getTypeNames() const noexcept; - service::ResolverMap getResolvers() const noexcept; - - void beginSelectionSet(const service::SelectionSetParams& params) const final; - void endSelectionSet(const service::SelectionSetParams& params) const final; - - const std::unique_ptr _pimpl; - -public: - template - AppointmentEdge(std::shared_ptr pimpl) noexcept - : AppointmentEdge { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } - { - } -}; - -class AppointmentConnection - : public service::Object -{ -private: - service::AwaitableResolver resolvePageInfo(service::ResolverParams&& params) const; - service::AwaitableResolver resolveEdges(service::ResolverParams&& params) const; - - service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; - - struct Concept - { - virtual ~Concept() = default; - - virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - - virtual service::FieldResult> getPageInfo(service::FieldParams&& params) const = 0; - virtual service::FieldResult>>> getEdges(service::FieldParams&& params) const = 0; - }; - - template - struct Model - : Concept - { - Model(std::shared_ptr&& pimpl) noexcept - : _pimpl { std::move(pimpl) } - { - } - - service::FieldResult> getPageInfo(service::FieldParams&& params) const final - { - if constexpr (methods::AppointmentConnectionHas::getPageInfoWithParams) - { - return { _pimpl->getPageInfo(std::move(params)) }; - } - else if constexpr (methods::AppointmentConnectionHas::getPageInfo) - { - return { _pimpl->getPageInfo() }; - } - else - { - throw std::runtime_error(R"ex(AppointmentConnection::getPageInfo is not implemented)ex"); - } - } - - service::FieldResult>>> getEdges(service::FieldParams&& params) const final - { - if constexpr (methods::AppointmentConnectionHas::getEdgesWithParams) - { - return { _pimpl->getEdges(std::move(params)) }; - } - else if constexpr (methods::AppointmentConnectionHas::getEdges) - { - return { _pimpl->getEdges() }; - } - else - { - throw std::runtime_error(R"ex(AppointmentConnection::getEdges is not implemented)ex"); - } - } - - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (methods::AppointmentConnectionHas::beginSelectionSet) - { - _pimpl->beginSelectionSet(params); - } - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (methods::AppointmentConnectionHas::endSelectionSet) - { - _pimpl->endSelectionSet(params); - } - } - - private: - const std::shared_ptr _pimpl; - }; - - AppointmentConnection(std::unique_ptr&& pimpl) noexcept; - - service::TypeNames getTypeNames() const noexcept; - service::ResolverMap getResolvers() const noexcept; - - void beginSelectionSet(const service::SelectionSetParams& params) const final; - void endSelectionSet(const service::SelectionSetParams& params) const final; - - const std::unique_ptr _pimpl; - -public: - template - AppointmentConnection(std::shared_ptr pimpl) noexcept - : AppointmentConnection { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } - { - } -}; - -class TaskEdge - : public service::Object -{ -private: - service::AwaitableResolver resolveNode(service::ResolverParams&& params) const; - service::AwaitableResolver resolveCursor(service::ResolverParams&& params) const; - - service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; - - struct Concept - { - virtual ~Concept() = default; - - virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - - virtual service::FieldResult> getNode(service::FieldParams&& params) const = 0; - virtual service::FieldResult getCursor(service::FieldParams&& params) const = 0; - }; - - template - struct Model - : Concept - { - Model(std::shared_ptr&& pimpl) noexcept - : _pimpl { std::move(pimpl) } - { - } - - service::FieldResult> getNode(service::FieldParams&& params) const final - { - if constexpr (methods::TaskEdgeHas::getNodeWithParams) - { - return { _pimpl->getNode(std::move(params)) }; - } - else if constexpr (methods::TaskEdgeHas::getNode) - { - return { _pimpl->getNode() }; - } - else - { - throw std::runtime_error(R"ex(TaskEdge::getNode is not implemented)ex"); - } - } - - service::FieldResult getCursor(service::FieldParams&& params) const final - { - if constexpr (methods::TaskEdgeHas::getCursorWithParams) - { - return { _pimpl->getCursor(std::move(params)) }; - } - else if constexpr (methods::TaskEdgeHas::getCursor) - { - return { _pimpl->getCursor() }; - } - else - { - throw std::runtime_error(R"ex(TaskEdge::getCursor is not implemented)ex"); - } - } - - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (methods::TaskEdgeHas::beginSelectionSet) - { - _pimpl->beginSelectionSet(params); - } - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (methods::TaskEdgeHas::endSelectionSet) - { - _pimpl->endSelectionSet(params); - } - } - - private: - const std::shared_ptr _pimpl; - }; - - TaskEdge(std::unique_ptr&& pimpl) noexcept; - - service::TypeNames getTypeNames() const noexcept; - service::ResolverMap getResolvers() const noexcept; - - void beginSelectionSet(const service::SelectionSetParams& params) const final; - void endSelectionSet(const service::SelectionSetParams& params) const final; - - const std::unique_ptr _pimpl; - -public: - template - TaskEdge(std::shared_ptr pimpl) noexcept - : TaskEdge { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } - { - } -}; - -class TaskConnection - : public service::Object -{ -private: - service::AwaitableResolver resolvePageInfo(service::ResolverParams&& params) const; - service::AwaitableResolver resolveEdges(service::ResolverParams&& params) const; - - service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; - - struct Concept - { - virtual ~Concept() = default; - - virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - - virtual service::FieldResult> getPageInfo(service::FieldParams&& params) const = 0; - virtual service::FieldResult>>> getEdges(service::FieldParams&& params) const = 0; - }; - - template - struct Model - : Concept - { - Model(std::shared_ptr&& pimpl) noexcept - : _pimpl { std::move(pimpl) } - { - } - - service::FieldResult> getPageInfo(service::FieldParams&& params) const final - { - if constexpr (methods::TaskConnectionHas::getPageInfoWithParams) - { - return { _pimpl->getPageInfo(std::move(params)) }; - } - else if constexpr (methods::TaskConnectionHas::getPageInfo) - { - return { _pimpl->getPageInfo() }; - } - else - { - throw std::runtime_error(R"ex(TaskConnection::getPageInfo is not implemented)ex"); - } - } - - service::FieldResult>>> getEdges(service::FieldParams&& params) const final - { - if constexpr (methods::TaskConnectionHas::getEdgesWithParams) - { - return { _pimpl->getEdges(std::move(params)) }; - } - else if constexpr (methods::TaskConnectionHas::getEdges) - { - return { _pimpl->getEdges() }; - } - else - { - throw std::runtime_error(R"ex(TaskConnection::getEdges is not implemented)ex"); - } - } - - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (methods::TaskConnectionHas::beginSelectionSet) - { - _pimpl->beginSelectionSet(params); - } - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (methods::TaskConnectionHas::endSelectionSet) - { - _pimpl->endSelectionSet(params); - } - } - - private: - const std::shared_ptr _pimpl; - }; - - TaskConnection(std::unique_ptr&& pimpl) noexcept; - - service::TypeNames getTypeNames() const noexcept; - service::ResolverMap getResolvers() const noexcept; - - void beginSelectionSet(const service::SelectionSetParams& params) const final; - void endSelectionSet(const service::SelectionSetParams& params) const final; - - const std::unique_ptr _pimpl; - -public: - template - TaskConnection(std::shared_ptr pimpl) noexcept - : TaskConnection { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } - { - } -}; - -class FolderEdge - : public service::Object -{ -private: - service::AwaitableResolver resolveNode(service::ResolverParams&& params) const; - service::AwaitableResolver resolveCursor(service::ResolverParams&& params) const; - - service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; - - struct Concept - { - virtual ~Concept() = default; - - virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - - virtual service::FieldResult> getNode(service::FieldParams&& params) const = 0; - virtual service::FieldResult getCursor(service::FieldParams&& params) const = 0; - }; - - template - struct Model - : Concept - { - Model(std::shared_ptr&& pimpl) noexcept - : _pimpl { std::move(pimpl) } - { - } - - service::FieldResult> getNode(service::FieldParams&& params) const final - { - if constexpr (methods::FolderEdgeHas::getNodeWithParams) - { - return { _pimpl->getNode(std::move(params)) }; - } - else if constexpr (methods::FolderEdgeHas::getNode) - { - return { _pimpl->getNode() }; - } - else - { - throw std::runtime_error(R"ex(FolderEdge::getNode is not implemented)ex"); - } - } - - service::FieldResult getCursor(service::FieldParams&& params) const final - { - if constexpr (methods::FolderEdgeHas::getCursorWithParams) - { - return { _pimpl->getCursor(std::move(params)) }; - } - else if constexpr (methods::FolderEdgeHas::getCursor) - { - return { _pimpl->getCursor() }; - } - else - { - throw std::runtime_error(R"ex(FolderEdge::getCursor is not implemented)ex"); - } - } - - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (methods::FolderEdgeHas::beginSelectionSet) - { - _pimpl->beginSelectionSet(params); - } - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (methods::FolderEdgeHas::endSelectionSet) - { - _pimpl->endSelectionSet(params); - } - } - - private: - const std::shared_ptr _pimpl; - }; - - FolderEdge(std::unique_ptr&& pimpl) noexcept; - - service::TypeNames getTypeNames() const noexcept; - service::ResolverMap getResolvers() const noexcept; - - void beginSelectionSet(const service::SelectionSetParams& params) const final; - void endSelectionSet(const service::SelectionSetParams& params) const final; - - const std::unique_ptr _pimpl; - -public: - template - FolderEdge(std::shared_ptr pimpl) noexcept - : FolderEdge { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } - { - } -}; - -class FolderConnection - : public service::Object -{ -private: - service::AwaitableResolver resolvePageInfo(service::ResolverParams&& params) const; - service::AwaitableResolver resolveEdges(service::ResolverParams&& params) const; - - service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; - - struct Concept - { - virtual ~Concept() = default; - - virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - - virtual service::FieldResult> getPageInfo(service::FieldParams&& params) const = 0; - virtual service::FieldResult>>> getEdges(service::FieldParams&& params) const = 0; - }; - - template - struct Model - : Concept - { - Model(std::shared_ptr&& pimpl) noexcept - : _pimpl { std::move(pimpl) } - { - } - - service::FieldResult> getPageInfo(service::FieldParams&& params) const final - { - if constexpr (methods::FolderConnectionHas::getPageInfoWithParams) - { - return { _pimpl->getPageInfo(std::move(params)) }; - } - else if constexpr (methods::FolderConnectionHas::getPageInfo) - { - return { _pimpl->getPageInfo() }; - } - else - { - throw std::runtime_error(R"ex(FolderConnection::getPageInfo is not implemented)ex"); - } - } - - service::FieldResult>>> getEdges(service::FieldParams&& params) const final - { - if constexpr (methods::FolderConnectionHas::getEdgesWithParams) - { - return { _pimpl->getEdges(std::move(params)) }; - } - else if constexpr (methods::FolderConnectionHas::getEdges) - { - return { _pimpl->getEdges() }; - } - else - { - throw std::runtime_error(R"ex(FolderConnection::getEdges is not implemented)ex"); - } - } - - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (methods::FolderConnectionHas::beginSelectionSet) - { - _pimpl->beginSelectionSet(params); - } - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (methods::FolderConnectionHas::endSelectionSet) - { - _pimpl->endSelectionSet(params); - } - } - - private: - const std::shared_ptr _pimpl; - }; - - FolderConnection(std::unique_ptr&& pimpl) noexcept; - - service::TypeNames getTypeNames() const noexcept; - service::ResolverMap getResolvers() const noexcept; - - void beginSelectionSet(const service::SelectionSetParams& params) const final; - void endSelectionSet(const service::SelectionSetParams& params) const final; - - const std::unique_ptr _pimpl; - -public: - template - FolderConnection(std::shared_ptr pimpl) noexcept - : FolderConnection { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } - { - } -}; - -class CompleteTaskPayload - : public service::Object -{ -private: - service::AwaitableResolver resolveTask(service::ResolverParams&& params) const; - service::AwaitableResolver resolveClientMutationId(service::ResolverParams&& params) const; - - service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; - - struct Concept - { - virtual ~Concept() = default; - - virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - - virtual service::FieldResult> getTask(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getClientMutationId(service::FieldParams&& params) const = 0; - }; - - template - struct Model - : Concept - { - Model(std::shared_ptr&& pimpl) noexcept - : _pimpl { std::move(pimpl) } - { - } - - service::FieldResult> getTask(service::FieldParams&& params) const final - { - if constexpr (methods::CompleteTaskPayloadHas::getTaskWithParams) - { - return { _pimpl->getTask(std::move(params)) }; - } - else if constexpr (methods::CompleteTaskPayloadHas::getTask) - { - return { _pimpl->getTask() }; - } - else - { - throw std::runtime_error(R"ex(CompleteTaskPayload::getTask is not implemented)ex"); - } - } - - service::FieldResult> getClientMutationId(service::FieldParams&& params) const final - { - if constexpr (methods::CompleteTaskPayloadHas::getClientMutationIdWithParams) - { - return { _pimpl->getClientMutationId(std::move(params)) }; - } - else if constexpr (methods::CompleteTaskPayloadHas::getClientMutationId) - { - return { _pimpl->getClientMutationId() }; - } - else - { - throw std::runtime_error(R"ex(CompleteTaskPayload::getClientMutationId is not implemented)ex"); - } - } - - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (methods::CompleteTaskPayloadHas::beginSelectionSet) - { - _pimpl->beginSelectionSet(params); - } - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (methods::CompleteTaskPayloadHas::endSelectionSet) - { - _pimpl->endSelectionSet(params); - } - } - - private: - const std::shared_ptr _pimpl; - }; - - CompleteTaskPayload(std::unique_ptr&& pimpl) noexcept; - - service::TypeNames getTypeNames() const noexcept; - service::ResolverMap getResolvers() const noexcept; - - void beginSelectionSet(const service::SelectionSetParams& params) const final; - void endSelectionSet(const service::SelectionSetParams& params) const final; - - const std::unique_ptr _pimpl; - -public: - template - CompleteTaskPayload(std::shared_ptr pimpl) noexcept - : CompleteTaskPayload { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } - { - } -}; - -class Mutation - : public service::Object -{ -private: - service::AwaitableResolver resolveCompleteTask(service::ResolverParams&& params) const; - service::AwaitableResolver resolveSetFloat(service::ResolverParams&& params) const; - - service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; - - struct Concept - { - virtual ~Concept() = default; - - virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - - virtual service::FieldResult> applyCompleteTask(service::FieldParams&& params, CompleteTaskInput&& inputArg) const = 0; - virtual service::FieldResult applySetFloat(service::FieldParams&& params, double&& valueArg) const = 0; - }; - - template - struct Model - : Concept - { - Model(std::shared_ptr&& pimpl) noexcept - : _pimpl { std::move(pimpl) } - { - } - - service::FieldResult> applyCompleteTask(service::FieldParams&& params, CompleteTaskInput&& inputArg) const final - { - if constexpr (methods::MutationHas::applyCompleteTaskWithParams) - { - return { _pimpl->applyCompleteTask(std::move(params), std::move(inputArg)) }; - } - else if constexpr (methods::MutationHas::applyCompleteTask) - { - return { _pimpl->applyCompleteTask(std::move(inputArg)) }; - } - else - { - throw std::runtime_error(R"ex(Mutation::applyCompleteTask is not implemented)ex"); - } - } - - service::FieldResult applySetFloat(service::FieldParams&& params, double&& valueArg) const final - { - if constexpr (methods::MutationHas::applySetFloatWithParams) - { - return { _pimpl->applySetFloat(std::move(params), std::move(valueArg)) }; - } - else if constexpr (methods::MutationHas::applySetFloat) - { - return { _pimpl->applySetFloat(std::move(valueArg)) }; - } - else - { - throw std::runtime_error(R"ex(Mutation::applySetFloat is not implemented)ex"); - } - } - - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (methods::MutationHas::beginSelectionSet) - { - _pimpl->beginSelectionSet(params); - } - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (methods::MutationHas::endSelectionSet) - { - _pimpl->endSelectionSet(params); - } - } - - private: - const std::shared_ptr _pimpl; - }; - - Mutation(std::unique_ptr&& pimpl) noexcept; - - service::TypeNames getTypeNames() const noexcept; - service::ResolverMap getResolvers() const noexcept; - - void beginSelectionSet(const service::SelectionSetParams& params) const final; - void endSelectionSet(const service::SelectionSetParams& params) const final; - - const std::unique_ptr _pimpl; - -public: - template - Mutation(std::shared_ptr pimpl) noexcept - : Mutation { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } - { - } -}; - -class Subscription - : public service::Object -{ -private: - service::AwaitableResolver resolveNextAppointmentChange(service::ResolverParams&& params) const; - service::AwaitableResolver resolveNodeChange(service::ResolverParams&& params) const; - - service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; - - struct Concept - { - virtual ~Concept() = default; - - virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - - virtual service::FieldResult> getNextAppointmentChange(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getNodeChange(service::FieldParams&& params, response::IdType&& idArg) const = 0; - }; - - template - struct Model - : Concept - { - Model(std::shared_ptr&& pimpl) noexcept - : _pimpl { std::move(pimpl) } - { - } - - service::FieldResult> getNextAppointmentChange(service::FieldParams&& params) const final - { - if constexpr (methods::SubscriptionHas::getNextAppointmentChangeWithParams) - { - return { _pimpl->getNextAppointmentChange(std::move(params)) }; - } - else if constexpr (methods::SubscriptionHas::getNextAppointmentChange) - { - return { _pimpl->getNextAppointmentChange() }; - } - else - { - throw std::runtime_error(R"ex(Subscription::getNextAppointmentChange is not implemented)ex"); - } - } - - service::FieldResult> getNodeChange(service::FieldParams&& params, response::IdType&& idArg) const final - { - if constexpr (methods::SubscriptionHas::getNodeChangeWithParams) - { - return { _pimpl->getNodeChange(std::move(params), std::move(idArg)) }; - } - else if constexpr (methods::SubscriptionHas::getNodeChange) - { - return { _pimpl->getNodeChange(std::move(idArg)) }; - } - else - { - throw std::runtime_error(R"ex(Subscription::getNodeChange is not implemented)ex"); - } - } - - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (methods::SubscriptionHas::beginSelectionSet) - { - _pimpl->beginSelectionSet(params); - } - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (methods::SubscriptionHas::endSelectionSet) - { - _pimpl->endSelectionSet(params); - } - } - - private: - const std::shared_ptr _pimpl; - }; - - Subscription(std::unique_ptr&& pimpl) noexcept; - - service::TypeNames getTypeNames() const noexcept; - service::ResolverMap getResolvers() const noexcept; - - void beginSelectionSet(const service::SelectionSetParams& params) const final; - void endSelectionSet(const service::SelectionSetParams& params) const final; - - const std::unique_ptr _pimpl; - -public: - template - Subscription(std::shared_ptr pimpl) noexcept - : Subscription { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } - { - } -}; - -class Appointment - : public service::Object -{ -private: - service::AwaitableResolver resolveId(service::ResolverParams&& params) const; - service::AwaitableResolver resolveWhen(service::ResolverParams&& params) const; - service::AwaitableResolver resolveSubject(service::ResolverParams&& params) const; - service::AwaitableResolver resolveIsNow(service::ResolverParams&& params) const; - service::AwaitableResolver resolveForceError(service::ResolverParams&& params) const; - - service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; - - struct Concept - { - virtual ~Concept() = default; - - virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - - virtual service::FieldResult getId(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getWhen(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getSubject(service::FieldParams&& params) const = 0; - virtual service::FieldResult getIsNow(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getForceError(service::FieldParams&& params) const = 0; - }; - - template - struct Model - : Concept - { - Model(std::shared_ptr&& pimpl) noexcept - : _pimpl { std::move(pimpl) } - { - } - - service::FieldResult getId(service::FieldParams&& params) const final - { - if constexpr (methods::AppointmentHas::getIdWithParams) - { - return { _pimpl->getId(std::move(params)) }; - } - else if constexpr (methods::AppointmentHas::getId) - { - return { _pimpl->getId() }; - } - else - { - throw std::runtime_error(R"ex(Appointment::getId is not implemented)ex"); - } - } - - service::FieldResult> getWhen(service::FieldParams&& params) const final - { - if constexpr (methods::AppointmentHas::getWhenWithParams) - { - return { _pimpl->getWhen(std::move(params)) }; - } - else if constexpr (methods::AppointmentHas::getWhen) - { - return { _pimpl->getWhen() }; - } - else - { - throw std::runtime_error(R"ex(Appointment::getWhen is not implemented)ex"); - } - } - - service::FieldResult> getSubject(service::FieldParams&& params) const final - { - if constexpr (methods::AppointmentHas::getSubjectWithParams) - { - return { _pimpl->getSubject(std::move(params)) }; - } - else if constexpr (methods::AppointmentHas::getSubject) - { - return { _pimpl->getSubject() }; - } - else - { - throw std::runtime_error(R"ex(Appointment::getSubject is not implemented)ex"); - } - } - - service::FieldResult getIsNow(service::FieldParams&& params) const final - { - if constexpr (methods::AppointmentHas::getIsNowWithParams) - { - return { _pimpl->getIsNow(std::move(params)) }; - } - else if constexpr (methods::AppointmentHas::getIsNow) - { - return { _pimpl->getIsNow() }; - } - else - { - throw std::runtime_error(R"ex(Appointment::getIsNow is not implemented)ex"); - } - } - - service::FieldResult> getForceError(service::FieldParams&& params) const final - { - if constexpr (methods::AppointmentHas::getForceErrorWithParams) - { - return { _pimpl->getForceError(std::move(params)) }; - } - else if constexpr (methods::AppointmentHas::getForceError) - { - return { _pimpl->getForceError() }; - } - else - { - throw std::runtime_error(R"ex(Appointment::getForceError is not implemented)ex"); - } - } - - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (methods::AppointmentHas::beginSelectionSet) - { - _pimpl->beginSelectionSet(params); - } - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (methods::AppointmentHas::endSelectionSet) - { - _pimpl->endSelectionSet(params); - } - } - - private: - const std::shared_ptr _pimpl; - }; - - Appointment(std::unique_ptr&& pimpl) noexcept; - - // Interfaces which this type implements - friend Node; - - // Unions which include this type - friend UnionType; - - template - static constexpr bool implements() noexcept - { - return implements::AppointmentIs; - } - - service::TypeNames getTypeNames() const noexcept; - service::ResolverMap getResolvers() const noexcept; - - void beginSelectionSet(const service::SelectionSetParams& params) const final; - void endSelectionSet(const service::SelectionSetParams& params) const final; - - const std::unique_ptr _pimpl; - -public: - template - Appointment(std::shared_ptr pimpl) noexcept - : Appointment { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } - { - } -}; - -class Task - : public service::Object -{ -private: - service::AwaitableResolver resolveId(service::ResolverParams&& params) const; - service::AwaitableResolver resolveTitle(service::ResolverParams&& params) const; - service::AwaitableResolver resolveIsComplete(service::ResolverParams&& params) const; - - service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; - - struct Concept - { - virtual ~Concept() = default; - - virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - - virtual service::FieldResult getId(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getTitle(service::FieldParams&& params) const = 0; - virtual service::FieldResult getIsComplete(service::FieldParams&& params) const = 0; - }; - - template - struct Model - : Concept - { - Model(std::shared_ptr&& pimpl) noexcept - : _pimpl { std::move(pimpl) } - { - } - - service::FieldResult getId(service::FieldParams&& params) const final - { - if constexpr (methods::TaskHas::getIdWithParams) - { - return { _pimpl->getId(std::move(params)) }; - } - else if constexpr (methods::TaskHas::getId) - { - return { _pimpl->getId() }; - } - else - { - throw std::runtime_error(R"ex(Task::getId is not implemented)ex"); - } - } - - service::FieldResult> getTitle(service::FieldParams&& params) const final - { - if constexpr (methods::TaskHas::getTitleWithParams) - { - return { _pimpl->getTitle(std::move(params)) }; - } - else if constexpr (methods::TaskHas::getTitle) - { - return { _pimpl->getTitle() }; - } - else - { - throw std::runtime_error(R"ex(Task::getTitle is not implemented)ex"); - } - } - - service::FieldResult getIsComplete(service::FieldParams&& params) const final - { - if constexpr (methods::TaskHas::getIsCompleteWithParams) - { - return { _pimpl->getIsComplete(std::move(params)) }; - } - else if constexpr (methods::TaskHas::getIsComplete) - { - return { _pimpl->getIsComplete() }; - } - else - { - throw std::runtime_error(R"ex(Task::getIsComplete is not implemented)ex"); - } - } - - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (methods::TaskHas::beginSelectionSet) - { - _pimpl->beginSelectionSet(params); - } - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (methods::TaskHas::endSelectionSet) - { - _pimpl->endSelectionSet(params); - } - } - - private: - const std::shared_ptr _pimpl; - }; - - Task(std::unique_ptr&& pimpl) noexcept; - - // Interfaces which this type implements - friend Node; - - // Unions which include this type - friend UnionType; - - template - static constexpr bool implements() noexcept - { - return implements::TaskIs; - } - - service::TypeNames getTypeNames() const noexcept; - service::ResolverMap getResolvers() const noexcept; - - void beginSelectionSet(const service::SelectionSetParams& params) const final; - void endSelectionSet(const service::SelectionSetParams& params) const final; - - const std::unique_ptr _pimpl; - -public: - template - Task(std::shared_ptr pimpl) noexcept - : Task { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } - { - } -}; - -class Folder - : public service::Object -{ -private: - service::AwaitableResolver resolveId(service::ResolverParams&& params) const; - service::AwaitableResolver resolveName(service::ResolverParams&& params) const; - service::AwaitableResolver resolveUnreadCount(service::ResolverParams&& params) const; - - service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; - - struct Concept - { - virtual ~Concept() = default; - - virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - - virtual service::FieldResult getId(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getName(service::FieldParams&& params) const = 0; - virtual service::FieldResult getUnreadCount(service::FieldParams&& params) const = 0; - }; - - template - struct Model - : Concept - { - Model(std::shared_ptr&& pimpl) noexcept - : _pimpl { std::move(pimpl) } - { - } - - service::FieldResult getId(service::FieldParams&& params) const final - { - if constexpr (methods::FolderHas::getIdWithParams) - { - return { _pimpl->getId(std::move(params)) }; - } - else if constexpr (methods::FolderHas::getId) - { - return { _pimpl->getId() }; - } - else - { - throw std::runtime_error(R"ex(Folder::getId is not implemented)ex"); - } - } - - service::FieldResult> getName(service::FieldParams&& params) const final - { - if constexpr (methods::FolderHas::getNameWithParams) - { - return { _pimpl->getName(std::move(params)) }; - } - else if constexpr (methods::FolderHas::getName) - { - return { _pimpl->getName() }; - } - else - { - throw std::runtime_error(R"ex(Folder::getName is not implemented)ex"); - } - } - - service::FieldResult getUnreadCount(service::FieldParams&& params) const final - { - if constexpr (methods::FolderHas::getUnreadCountWithParams) - { - return { _pimpl->getUnreadCount(std::move(params)) }; - } - else if constexpr (methods::FolderHas::getUnreadCount) - { - return { _pimpl->getUnreadCount() }; - } - else - { - throw std::runtime_error(R"ex(Folder::getUnreadCount is not implemented)ex"); - } - } - - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (methods::FolderHas::beginSelectionSet) - { - _pimpl->beginSelectionSet(params); - } - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (methods::FolderHas::endSelectionSet) - { - _pimpl->endSelectionSet(params); - } - } - - private: - const std::shared_ptr _pimpl; - }; - - Folder(std::unique_ptr&& pimpl) noexcept; - - // Interfaces which this type implements - friend Node; - - // Unions which include this type - friend UnionType; - - template - static constexpr bool implements() noexcept - { - return implements::FolderIs; - } - - service::TypeNames getTypeNames() const noexcept; - service::ResolverMap getResolvers() const noexcept; - - void beginSelectionSet(const service::SelectionSetParams& params) const final; - void endSelectionSet(const service::SelectionSetParams& params) const final; - - const std::unique_ptr _pimpl; - -public: - template - Folder(std::shared_ptr pimpl) noexcept - : Folder { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } - { - } -}; - -class NestedType - : public service::Object -{ -private: - service::AwaitableResolver resolveDepth(service::ResolverParams&& params) const; - service::AwaitableResolver resolveNested(service::ResolverParams&& params) const; - - service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; - - struct Concept - { - virtual ~Concept() = default; - - virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - - virtual service::FieldResult getDepth(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getNested(service::FieldParams&& params) const = 0; - }; - - template - struct Model - : Concept - { - Model(std::shared_ptr&& pimpl) noexcept - : _pimpl { std::move(pimpl) } - { - } - - service::FieldResult getDepth(service::FieldParams&& params) const final - { - if constexpr (methods::NestedTypeHas::getDepthWithParams) - { - return { _pimpl->getDepth(std::move(params)) }; - } - else if constexpr (methods::NestedTypeHas::getDepth) - { - return { _pimpl->getDepth() }; - } - else - { - throw std::runtime_error(R"ex(NestedType::getDepth is not implemented)ex"); - } - } - - service::FieldResult> getNested(service::FieldParams&& params) const final - { - if constexpr (methods::NestedTypeHas::getNestedWithParams) - { - return { _pimpl->getNested(std::move(params)) }; - } - else if constexpr (methods::NestedTypeHas::getNested) - { - return { _pimpl->getNested() }; - } - else - { - throw std::runtime_error(R"ex(NestedType::getNested is not implemented)ex"); - } - } - - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (methods::NestedTypeHas::beginSelectionSet) - { - _pimpl->beginSelectionSet(params); - } - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (methods::NestedTypeHas::endSelectionSet) - { - _pimpl->endSelectionSet(params); - } - } - - private: - const std::shared_ptr _pimpl; - }; - - NestedType(std::unique_ptr&& pimpl) noexcept; - - service::TypeNames getTypeNames() const noexcept; - service::ResolverMap getResolvers() const noexcept; - - void beginSelectionSet(const service::SelectionSetParams& params) const final; - void endSelectionSet(const service::SelectionSetParams& params) const final; - - const std::unique_ptr _pimpl; - -public: - template - NestedType(std::shared_ptr pimpl) noexcept - : NestedType { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } - { - } -}; - -class Expensive - : public service::Object -{ -private: - service::AwaitableResolver resolveOrder(service::ResolverParams&& params) const; - - service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; - - struct Concept - { - virtual ~Concept() = default; - - virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - - virtual service::FieldResult getOrder(service::FieldParams&& params) const = 0; - }; - - template - struct Model - : Concept - { - Model(std::shared_ptr&& pimpl) noexcept - : _pimpl { std::move(pimpl) } - { - } - - service::FieldResult getOrder(service::FieldParams&& params) const final - { - if constexpr (methods::ExpensiveHas::getOrderWithParams) - { - return { _pimpl->getOrder(std::move(params)) }; - } - else if constexpr (methods::ExpensiveHas::getOrder) - { - return { _pimpl->getOrder() }; - } - else - { - throw std::runtime_error(R"ex(Expensive::getOrder is not implemented)ex"); - } - } - - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (methods::ExpensiveHas::beginSelectionSet) - { - _pimpl->beginSelectionSet(params); - } - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (methods::ExpensiveHas::endSelectionSet) - { - _pimpl->endSelectionSet(params); - } - } - - private: - const std::shared_ptr _pimpl; - }; - - Expensive(std::unique_ptr&& pimpl) noexcept; - - service::TypeNames getTypeNames() const noexcept; - service::ResolverMap getResolvers() const noexcept; - - void beginSelectionSet(const service::SelectionSetParams& params) const final; - void endSelectionSet(const service::SelectionSetParams& params) const final; - - const std::unique_ptr _pimpl; - -public: - template - Expensive(std::shared_ptr pimpl) noexcept - : Expensive { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } - { - } -}; - -} // namespace object - -class Operations - : public service::Request -{ -public: - explicit Operations(std::shared_ptr query, std::shared_ptr mutation, std::shared_ptr subscription); - - template - explicit Operations(std::shared_ptr query, std::shared_ptr mutation, std::shared_ptr subscription) - : Operations { std::make_shared(std::move(query)), std::make_shared(std::move(mutation)), std::make_shared(std::move(subscription)) } - { - } - -private: - std::shared_ptr _query; - std::shared_ptr _mutation; - std::shared_ptr _subscription; -}; - -std::shared_ptr GetSchema(); - -} // namespace today -} // namespace graphql - -#endif // TODAYSCHEMA_H diff --git a/samples/today/unified/unified_schema_files b/samples/today/unified/unified_schema_files deleted file mode 100644 index 1647a93d..00000000 --- a/samples/today/unified/unified_schema_files +++ /dev/null @@ -1 +0,0 @@ -TodaySchema.cpp diff --git a/samples/today/unified_nointrospection/CMakeLists.txt b/samples/today/unified_nointrospection/CMakeLists.txt deleted file mode 100644 index 405f5ecd..00000000 --- a/samples/today/unified_nointrospection/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. - -cmake_minimum_required(VERSION 3.15) - -# Normally this would be handled by find_package(cppgraphqlgen CONFIG). -include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/cppgraphqlgen-functions.cmake) - -if(GRAPHQL_UPDATE_SAMPLES) - update_graphql_schema_files(unified_nointrospection ../schema.today.graphql Today today --stubs --merge-files --no-introspection) -endif() - -add_graphql_schema_no_introspection_target(unified_nointrospection) diff --git a/samples/today/unified_nointrospection/TodaySchema.cpp b/samples/today/unified_nointrospection/TodaySchema.cpp deleted file mode 100644 index 5fe82b26..00000000 --- a/samples/today/unified_nointrospection/TodaySchema.cpp +++ /dev/null @@ -1,1571 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// WARNING! Do not edit this file manually, your changes will be overwritten. - -#include "TodaySchema.h" - -#include "graphqlservice/introspection/Introspection.h" - -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace std::literals; - -namespace graphql { -namespace service { - -static const std::array s_namesTaskState = { - R"gql(New)gql"sv, - R"gql(Started)gql"sv, - R"gql(Complete)gql"sv, - R"gql(Unassigned)gql"sv -}; - -template <> -today::TaskState ModifiedArgument::convert(const response::Value& value) -{ - if (!value.maybe_enum()) - { - throw service::schema_exception { { R"ex(not a valid TaskState value)ex" } }; - } - - const auto itr = std::find(s_namesTaskState.cbegin(), s_namesTaskState.cend(), value.get()); - - if (itr == s_namesTaskState.cend()) - { - throw service::schema_exception { { R"ex(not a valid TaskState value)ex" } }; - } - - return static_cast(itr - s_namesTaskState.cbegin()); -} - -template <> -service::AwaitableResolver ModifiedResult::convert(service::FieldResult result, ResolverParams params) -{ - return resolve(std::move(result), std::move(params), - [](today::TaskState value, const ResolverParams&) - { - response::Value result(response::Type::EnumValue); - - result.set(std::string { s_namesTaskState[static_cast(value)] }); - - return result; - }); -} - -template <> -today::CompleteTaskInput ModifiedArgument::convert(const response::Value& value) -{ - const auto defaultValue = []() - { - response::Value values(response::Type::Map); - response::Value entry; - - entry = response::Value(true); - values.emplace_back("isComplete", std::move(entry)); - - return values; - }(); - - auto valueId = service::ModifiedArgument::require("id", value); - auto valueTestTaskState = service::ModifiedArgument::require("testTaskState", value); - auto pairIsComplete = service::ModifiedArgument::find("isComplete", value); - auto valueIsComplete = (pairIsComplete.second - ? std::move(pairIsComplete.first) - : service::ModifiedArgument::require("isComplete", defaultValue)); - auto valueClientMutationId = service::ModifiedArgument::require("clientMutationId", value); - - return { - std::move(valueId), - std::move(valueTestTaskState), - std::move(valueIsComplete), - std::move(valueClientMutationId) - }; -} - -template <> -today::ThirdNestedInput ModifiedArgument::convert(const response::Value& value) -{ - auto valueId = service::ModifiedArgument::require("id", value); - - return { - std::move(valueId) - }; -} - -template <> -today::FourthNestedInput ModifiedArgument::convert(const response::Value& value) -{ - auto valueId = service::ModifiedArgument::require("id", value); - - return { - std::move(valueId) - }; -} - -template <> -today::SecondNestedInput ModifiedArgument::convert(const response::Value& value) -{ - auto valueId = service::ModifiedArgument::require("id", value); - auto valueThird = service::ModifiedArgument::require("third", value); - - return { - std::move(valueId), - std::move(valueThird) - }; -} - -template <> -today::FirstNestedInput ModifiedArgument::convert(const response::Value& value) -{ - auto valueId = service::ModifiedArgument::require("id", value); - auto valueSecond = service::ModifiedArgument::require("second", value); - auto valueThird = service::ModifiedArgument::require("third", value); - - return { - std::move(valueId), - std::move(valueSecond), - std::move(valueThird) - }; -} - -} // namespace service - -namespace today { -namespace object { - -Node::Node(std::unique_ptr&& pimpl) noexcept - : service::Object { pimpl->getTypeNames(), pimpl->getResolvers() } - , _pimpl { std::move(pimpl) } -{ -} - -void Node::beginSelectionSet(const service::SelectionSetParams& params) const -{ - _pimpl->beginSelectionSet(params); -} - -void Node::endSelectionSet(const service::SelectionSetParams& params) const -{ - _pimpl->endSelectionSet(params); -} - -UnionType::UnionType(std::unique_ptr&& pimpl) noexcept - : service::Object { pimpl->getTypeNames(), pimpl->getResolvers() } - , _pimpl { std::move(pimpl) } -{ -} - -void UnionType::beginSelectionSet(const service::SelectionSetParams& params) const -{ - _pimpl->beginSelectionSet(params); -} - -void UnionType::endSelectionSet(const service::SelectionSetParams& params) const -{ - _pimpl->endSelectionSet(params); -} - -Query::Query(std::unique_ptr&& pimpl) noexcept - : service::Object{ getTypeNames(), getResolvers() } - , _pimpl { std::move(pimpl) } -{ -} - -service::TypeNames Query::getTypeNames() const noexcept -{ - return { - R"gql(Query)gql"sv - }; -} - -service::ResolverMap Query::getResolvers() const noexcept -{ - return { - { R"gql(node)gql"sv, [this](service::ResolverParams&& params) { return resolveNode(std::move(params)); } }, - { R"gql(tasks)gql"sv, [this](service::ResolverParams&& params) { return resolveTasks(std::move(params)); } }, - { R"gql(nested)gql"sv, [this](service::ResolverParams&& params) { return resolveNested(std::move(params)); } }, - { R"gql(anyType)gql"sv, [this](service::ResolverParams&& params) { return resolveAnyType(std::move(params)); } }, - { R"gql(expensive)gql"sv, [this](service::ResolverParams&& params) { return resolveExpensive(std::move(params)); } }, - { R"gql(tasksById)gql"sv, [this](service::ResolverParams&& params) { return resolveTasksById(std::move(params)); } }, - { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, - { R"gql(appointments)gql"sv, [this](service::ResolverParams&& params) { return resolveAppointments(std::move(params)); } }, - { R"gql(unreadCounts)gql"sv, [this](service::ResolverParams&& params) { return resolveUnreadCounts(std::move(params)); } }, - { R"gql(testTaskState)gql"sv, [this](service::ResolverParams&& params) { return resolveTestTaskState(std::move(params)); } }, - { R"gql(unimplemented)gql"sv, [this](service::ResolverParams&& params) { return resolveUnimplemented(std::move(params)); } }, - { R"gql(appointmentsById)gql"sv, [this](service::ResolverParams&& params) { return resolveAppointmentsById(std::move(params)); } }, - { R"gql(unreadCountsById)gql"sv, [this](service::ResolverParams&& params) { return resolveUnreadCountsById(std::move(params)); } } - }; -} - -void Query::beginSelectionSet(const service::SelectionSetParams& params) const -{ - _pimpl->beginSelectionSet(params); -} - -void Query::endSelectionSet(const service::SelectionSetParams& params) const -{ - _pimpl->endSelectionSet(params); -} - -service::AwaitableResolver Query::resolveNode(service::ResolverParams&& params) const -{ - auto argId = service::ModifiedArgument::require("id", params.arguments); - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getNode(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argId)); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Query::resolveAppointments(service::ResolverParams&& params) const -{ - auto argFirst = service::ModifiedArgument::require("first", params.arguments); - auto argAfter = service::ModifiedArgument::require("after", params.arguments); - auto argLast = service::ModifiedArgument::require("last", params.arguments); - auto argBefore = service::ModifiedArgument::require("before", params.arguments); - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getAppointments(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argFirst), std::move(argAfter), std::move(argLast), std::move(argBefore)); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Query::resolveTasks(service::ResolverParams&& params) const -{ - auto argFirst = service::ModifiedArgument::require("first", params.arguments); - auto argAfter = service::ModifiedArgument::require("after", params.arguments); - auto argLast = service::ModifiedArgument::require("last", params.arguments); - auto argBefore = service::ModifiedArgument::require("before", params.arguments); - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getTasks(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argFirst), std::move(argAfter), std::move(argLast), std::move(argBefore)); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Query::resolveUnreadCounts(service::ResolverParams&& params) const -{ - auto argFirst = service::ModifiedArgument::require("first", params.arguments); - auto argAfter = service::ModifiedArgument::require("after", params.arguments); - auto argLast = service::ModifiedArgument::require("last", params.arguments); - auto argBefore = service::ModifiedArgument::require("before", params.arguments); - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getUnreadCounts(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argFirst), std::move(argAfter), std::move(argLast), std::move(argBefore)); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Query::resolveAppointmentsById(service::ResolverParams&& params) const -{ - const auto defaultArguments = []() - { - response::Value values(response::Type::Map); - response::Value entry; - - entry = []() - { - response::Value elements(response::Type::List); - response::Value entry; - - entry = response::Value(std::string(R"gql(ZmFrZUFwcG9pbnRtZW50SWQ=)gql")); - elements.emplace_back(std::move(entry)); - return elements; - }(); - values.emplace_back("ids", std::move(entry)); - - return values; - }(); - - auto pairIds = service::ModifiedArgument::find("ids", params.arguments); - auto argIds = (pairIds.second - ? std::move(pairIds.first) - : service::ModifiedArgument::require("ids", defaultArguments)); - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getAppointmentsById(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argIds)); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Query::resolveTasksById(service::ResolverParams&& params) const -{ - auto argIds = service::ModifiedArgument::require("ids", params.arguments); - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getTasksById(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argIds)); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Query::resolveUnreadCountsById(service::ResolverParams&& params) const -{ - auto argIds = service::ModifiedArgument::require("ids", params.arguments); - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getUnreadCountsById(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argIds)); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Query::resolveNested(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getNested(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Query::resolveUnimplemented(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getUnimplemented(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Query::resolveExpensive(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getExpensive(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Query::resolveTestTaskState(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getTestTaskState(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Query::resolveAnyType(service::ResolverParams&& params) const -{ - auto argIds = service::ModifiedArgument::require("ids", params.arguments); - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getAnyType(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argIds)); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Query::resolve_typename(service::ResolverParams&& params) const -{ - return service::ModifiedResult::convert(std::string{ R"gql(Query)gql" }, std::move(params)); -} - -PageInfo::PageInfo(std::unique_ptr&& pimpl) noexcept - : service::Object{ getTypeNames(), getResolvers() } - , _pimpl { std::move(pimpl) } -{ -} - -service::TypeNames PageInfo::getTypeNames() const noexcept -{ - return { - R"gql(PageInfo)gql"sv - }; -} - -service::ResolverMap PageInfo::getResolvers() const noexcept -{ - return { - { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, - { R"gql(hasNextPage)gql"sv, [this](service::ResolverParams&& params) { return resolveHasNextPage(std::move(params)); } }, - { R"gql(hasPreviousPage)gql"sv, [this](service::ResolverParams&& params) { return resolveHasPreviousPage(std::move(params)); } } - }; -} - -void PageInfo::beginSelectionSet(const service::SelectionSetParams& params) const -{ - _pimpl->beginSelectionSet(params); -} - -void PageInfo::endSelectionSet(const service::SelectionSetParams& params) const -{ - _pimpl->endSelectionSet(params); -} - -service::AwaitableResolver PageInfo::resolveHasNextPage(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getHasNextPage(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver PageInfo::resolveHasPreviousPage(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getHasPreviousPage(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver PageInfo::resolve_typename(service::ResolverParams&& params) const -{ - return service::ModifiedResult::convert(std::string{ R"gql(PageInfo)gql" }, std::move(params)); -} - -AppointmentEdge::AppointmentEdge(std::unique_ptr&& pimpl) noexcept - : service::Object{ getTypeNames(), getResolvers() } - , _pimpl { std::move(pimpl) } -{ -} - -service::TypeNames AppointmentEdge::getTypeNames() const noexcept -{ - return { - R"gql(AppointmentEdge)gql"sv - }; -} - -service::ResolverMap AppointmentEdge::getResolvers() const noexcept -{ - return { - { R"gql(node)gql"sv, [this](service::ResolverParams&& params) { return resolveNode(std::move(params)); } }, - { R"gql(cursor)gql"sv, [this](service::ResolverParams&& params) { return resolveCursor(std::move(params)); } }, - { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } } - }; -} - -void AppointmentEdge::beginSelectionSet(const service::SelectionSetParams& params) const -{ - _pimpl->beginSelectionSet(params); -} - -void AppointmentEdge::endSelectionSet(const service::SelectionSetParams& params) const -{ - _pimpl->endSelectionSet(params); -} - -service::AwaitableResolver AppointmentEdge::resolveNode(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getNode(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver AppointmentEdge::resolveCursor(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getCursor(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver AppointmentEdge::resolve_typename(service::ResolverParams&& params) const -{ - return service::ModifiedResult::convert(std::string{ R"gql(AppointmentEdge)gql" }, std::move(params)); -} - -AppointmentConnection::AppointmentConnection(std::unique_ptr&& pimpl) noexcept - : service::Object{ getTypeNames(), getResolvers() } - , _pimpl { std::move(pimpl) } -{ -} - -service::TypeNames AppointmentConnection::getTypeNames() const noexcept -{ - return { - R"gql(AppointmentConnection)gql"sv - }; -} - -service::ResolverMap AppointmentConnection::getResolvers() const noexcept -{ - return { - { R"gql(edges)gql"sv, [this](service::ResolverParams&& params) { return resolveEdges(std::move(params)); } }, - { R"gql(pageInfo)gql"sv, [this](service::ResolverParams&& params) { return resolvePageInfo(std::move(params)); } }, - { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } } - }; -} - -void AppointmentConnection::beginSelectionSet(const service::SelectionSetParams& params) const -{ - _pimpl->beginSelectionSet(params); -} - -void AppointmentConnection::endSelectionSet(const service::SelectionSetParams& params) const -{ - _pimpl->endSelectionSet(params); -} - -service::AwaitableResolver AppointmentConnection::resolvePageInfo(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getPageInfo(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver AppointmentConnection::resolveEdges(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getEdges(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver AppointmentConnection::resolve_typename(service::ResolverParams&& params) const -{ - return service::ModifiedResult::convert(std::string{ R"gql(AppointmentConnection)gql" }, std::move(params)); -} - -TaskEdge::TaskEdge(std::unique_ptr&& pimpl) noexcept - : service::Object{ getTypeNames(), getResolvers() } - , _pimpl { std::move(pimpl) } -{ -} - -service::TypeNames TaskEdge::getTypeNames() const noexcept -{ - return { - R"gql(TaskEdge)gql"sv - }; -} - -service::ResolverMap TaskEdge::getResolvers() const noexcept -{ - return { - { R"gql(node)gql"sv, [this](service::ResolverParams&& params) { return resolveNode(std::move(params)); } }, - { R"gql(cursor)gql"sv, [this](service::ResolverParams&& params) { return resolveCursor(std::move(params)); } }, - { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } } - }; -} - -void TaskEdge::beginSelectionSet(const service::SelectionSetParams& params) const -{ - _pimpl->beginSelectionSet(params); -} - -void TaskEdge::endSelectionSet(const service::SelectionSetParams& params) const -{ - _pimpl->endSelectionSet(params); -} - -service::AwaitableResolver TaskEdge::resolveNode(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getNode(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver TaskEdge::resolveCursor(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getCursor(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver TaskEdge::resolve_typename(service::ResolverParams&& params) const -{ - return service::ModifiedResult::convert(std::string{ R"gql(TaskEdge)gql" }, std::move(params)); -} - -TaskConnection::TaskConnection(std::unique_ptr&& pimpl) noexcept - : service::Object{ getTypeNames(), getResolvers() } - , _pimpl { std::move(pimpl) } -{ -} - -service::TypeNames TaskConnection::getTypeNames() const noexcept -{ - return { - R"gql(TaskConnection)gql"sv - }; -} - -service::ResolverMap TaskConnection::getResolvers() const noexcept -{ - return { - { R"gql(edges)gql"sv, [this](service::ResolverParams&& params) { return resolveEdges(std::move(params)); } }, - { R"gql(pageInfo)gql"sv, [this](service::ResolverParams&& params) { return resolvePageInfo(std::move(params)); } }, - { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } } - }; -} - -void TaskConnection::beginSelectionSet(const service::SelectionSetParams& params) const -{ - _pimpl->beginSelectionSet(params); -} - -void TaskConnection::endSelectionSet(const service::SelectionSetParams& params) const -{ - _pimpl->endSelectionSet(params); -} - -service::AwaitableResolver TaskConnection::resolvePageInfo(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getPageInfo(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver TaskConnection::resolveEdges(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getEdges(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver TaskConnection::resolve_typename(service::ResolverParams&& params) const -{ - return service::ModifiedResult::convert(std::string{ R"gql(TaskConnection)gql" }, std::move(params)); -} - -FolderEdge::FolderEdge(std::unique_ptr&& pimpl) noexcept - : service::Object{ getTypeNames(), getResolvers() } - , _pimpl { std::move(pimpl) } -{ -} - -service::TypeNames FolderEdge::getTypeNames() const noexcept -{ - return { - R"gql(FolderEdge)gql"sv - }; -} - -service::ResolverMap FolderEdge::getResolvers() const noexcept -{ - return { - { R"gql(node)gql"sv, [this](service::ResolverParams&& params) { return resolveNode(std::move(params)); } }, - { R"gql(cursor)gql"sv, [this](service::ResolverParams&& params) { return resolveCursor(std::move(params)); } }, - { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } } - }; -} - -void FolderEdge::beginSelectionSet(const service::SelectionSetParams& params) const -{ - _pimpl->beginSelectionSet(params); -} - -void FolderEdge::endSelectionSet(const service::SelectionSetParams& params) const -{ - _pimpl->endSelectionSet(params); -} - -service::AwaitableResolver FolderEdge::resolveNode(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getNode(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver FolderEdge::resolveCursor(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getCursor(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver FolderEdge::resolve_typename(service::ResolverParams&& params) const -{ - return service::ModifiedResult::convert(std::string{ R"gql(FolderEdge)gql" }, std::move(params)); -} - -FolderConnection::FolderConnection(std::unique_ptr&& pimpl) noexcept - : service::Object{ getTypeNames(), getResolvers() } - , _pimpl { std::move(pimpl) } -{ -} - -service::TypeNames FolderConnection::getTypeNames() const noexcept -{ - return { - R"gql(FolderConnection)gql"sv - }; -} - -service::ResolverMap FolderConnection::getResolvers() const noexcept -{ - return { - { R"gql(edges)gql"sv, [this](service::ResolverParams&& params) { return resolveEdges(std::move(params)); } }, - { R"gql(pageInfo)gql"sv, [this](service::ResolverParams&& params) { return resolvePageInfo(std::move(params)); } }, - { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } } - }; -} - -void FolderConnection::beginSelectionSet(const service::SelectionSetParams& params) const -{ - _pimpl->beginSelectionSet(params); -} - -void FolderConnection::endSelectionSet(const service::SelectionSetParams& params) const -{ - _pimpl->endSelectionSet(params); -} - -service::AwaitableResolver FolderConnection::resolvePageInfo(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getPageInfo(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver FolderConnection::resolveEdges(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getEdges(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver FolderConnection::resolve_typename(service::ResolverParams&& params) const -{ - return service::ModifiedResult::convert(std::string{ R"gql(FolderConnection)gql" }, std::move(params)); -} - -CompleteTaskPayload::CompleteTaskPayload(std::unique_ptr&& pimpl) noexcept - : service::Object{ getTypeNames(), getResolvers() } - , _pimpl { std::move(pimpl) } -{ -} - -service::TypeNames CompleteTaskPayload::getTypeNames() const noexcept -{ - return { - R"gql(CompleteTaskPayload)gql"sv - }; -} - -service::ResolverMap CompleteTaskPayload::getResolvers() const noexcept -{ - return { - { R"gql(task)gql"sv, [this](service::ResolverParams&& params) { return resolveTask(std::move(params)); } }, - { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, - { R"gql(clientMutationId)gql"sv, [this](service::ResolverParams&& params) { return resolveClientMutationId(std::move(params)); } } - }; -} - -void CompleteTaskPayload::beginSelectionSet(const service::SelectionSetParams& params) const -{ - _pimpl->beginSelectionSet(params); -} - -void CompleteTaskPayload::endSelectionSet(const service::SelectionSetParams& params) const -{ - _pimpl->endSelectionSet(params); -} - -service::AwaitableResolver CompleteTaskPayload::resolveTask(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getTask(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver CompleteTaskPayload::resolveClientMutationId(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getClientMutationId(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver CompleteTaskPayload::resolve_typename(service::ResolverParams&& params) const -{ - return service::ModifiedResult::convert(std::string{ R"gql(CompleteTaskPayload)gql" }, std::move(params)); -} - -Mutation::Mutation(std::unique_ptr&& pimpl) noexcept - : service::Object{ getTypeNames(), getResolvers() } - , _pimpl { std::move(pimpl) } -{ -} - -service::TypeNames Mutation::getTypeNames() const noexcept -{ - return { - R"gql(Mutation)gql"sv - }; -} - -service::ResolverMap Mutation::getResolvers() const noexcept -{ - return { - { R"gql(setFloat)gql"sv, [this](service::ResolverParams&& params) { return resolveSetFloat(std::move(params)); } }, - { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, - { R"gql(completeTask)gql"sv, [this](service::ResolverParams&& params) { return resolveCompleteTask(std::move(params)); } } - }; -} - -void Mutation::beginSelectionSet(const service::SelectionSetParams& params) const -{ - _pimpl->beginSelectionSet(params); -} - -void Mutation::endSelectionSet(const service::SelectionSetParams& params) const -{ - _pimpl->endSelectionSet(params); -} - -service::AwaitableResolver Mutation::resolveCompleteTask(service::ResolverParams&& params) const -{ - auto argInput = service::ModifiedArgument::require("input", params.arguments); - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->applyCompleteTask(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argInput)); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Mutation::resolveSetFloat(service::ResolverParams&& params) const -{ - auto argValue = service::ModifiedArgument::require("value", params.arguments); - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->applySetFloat(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argValue)); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Mutation::resolve_typename(service::ResolverParams&& params) const -{ - return service::ModifiedResult::convert(std::string{ R"gql(Mutation)gql" }, std::move(params)); -} - -Subscription::Subscription(std::unique_ptr&& pimpl) noexcept - : service::Object{ getTypeNames(), getResolvers() } - , _pimpl { std::move(pimpl) } -{ -} - -service::TypeNames Subscription::getTypeNames() const noexcept -{ - return { - R"gql(Subscription)gql"sv - }; -} - -service::ResolverMap Subscription::getResolvers() const noexcept -{ - return { - { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, - { R"gql(nodeChange)gql"sv, [this](service::ResolverParams&& params) { return resolveNodeChange(std::move(params)); } }, - { R"gql(nextAppointmentChange)gql"sv, [this](service::ResolverParams&& params) { return resolveNextAppointmentChange(std::move(params)); } } - }; -} - -void Subscription::beginSelectionSet(const service::SelectionSetParams& params) const -{ - _pimpl->beginSelectionSet(params); -} - -void Subscription::endSelectionSet(const service::SelectionSetParams& params) const -{ - _pimpl->endSelectionSet(params); -} - -service::AwaitableResolver Subscription::resolveNextAppointmentChange(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getNextAppointmentChange(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Subscription::resolveNodeChange(service::ResolverParams&& params) const -{ - auto argId = service::ModifiedArgument::require("id", params.arguments); - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getNodeChange(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argId)); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Subscription::resolve_typename(service::ResolverParams&& params) const -{ - return service::ModifiedResult::convert(std::string{ R"gql(Subscription)gql" }, std::move(params)); -} - -Appointment::Appointment(std::unique_ptr&& pimpl) noexcept - : service::Object{ getTypeNames(), getResolvers() } - , _pimpl { std::move(pimpl) } -{ -} - -service::TypeNames Appointment::getTypeNames() const noexcept -{ - return { - R"gql(Node)gql"sv, - R"gql(UnionType)gql"sv, - R"gql(Appointment)gql"sv - }; -} - -service::ResolverMap Appointment::getResolvers() const noexcept -{ - return { - { R"gql(id)gql"sv, [this](service::ResolverParams&& params) { return resolveId(std::move(params)); } }, - { R"gql(when)gql"sv, [this](service::ResolverParams&& params) { return resolveWhen(std::move(params)); } }, - { R"gql(isNow)gql"sv, [this](service::ResolverParams&& params) { return resolveIsNow(std::move(params)); } }, - { R"gql(subject)gql"sv, [this](service::ResolverParams&& params) { return resolveSubject(std::move(params)); } }, - { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, - { R"gql(forceError)gql"sv, [this](service::ResolverParams&& params) { return resolveForceError(std::move(params)); } } - }; -} - -void Appointment::beginSelectionSet(const service::SelectionSetParams& params) const -{ - _pimpl->beginSelectionSet(params); -} - -void Appointment::endSelectionSet(const service::SelectionSetParams& params) const -{ - _pimpl->endSelectionSet(params); -} - -service::AwaitableResolver Appointment::resolveId(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getId(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Appointment::resolveWhen(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getWhen(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Appointment::resolveSubject(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getSubject(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Appointment::resolveIsNow(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getIsNow(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Appointment::resolveForceError(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getForceError(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Appointment::resolve_typename(service::ResolverParams&& params) const -{ - return service::ModifiedResult::convert(std::string{ R"gql(Appointment)gql" }, std::move(params)); -} - -Task::Task(std::unique_ptr&& pimpl) noexcept - : service::Object{ getTypeNames(), getResolvers() } - , _pimpl { std::move(pimpl) } -{ -} - -service::TypeNames Task::getTypeNames() const noexcept -{ - return { - R"gql(Node)gql"sv, - R"gql(UnionType)gql"sv, - R"gql(Task)gql"sv - }; -} - -service::ResolverMap Task::getResolvers() const noexcept -{ - return { - { R"gql(id)gql"sv, [this](service::ResolverParams&& params) { return resolveId(std::move(params)); } }, - { R"gql(title)gql"sv, [this](service::ResolverParams&& params) { return resolveTitle(std::move(params)); } }, - { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, - { R"gql(isComplete)gql"sv, [this](service::ResolverParams&& params) { return resolveIsComplete(std::move(params)); } } - }; -} - -void Task::beginSelectionSet(const service::SelectionSetParams& params) const -{ - _pimpl->beginSelectionSet(params); -} - -void Task::endSelectionSet(const service::SelectionSetParams& params) const -{ - _pimpl->endSelectionSet(params); -} - -service::AwaitableResolver Task::resolveId(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getId(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Task::resolveTitle(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getTitle(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Task::resolveIsComplete(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getIsComplete(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Task::resolve_typename(service::ResolverParams&& params) const -{ - return service::ModifiedResult::convert(std::string{ R"gql(Task)gql" }, std::move(params)); -} - -Folder::Folder(std::unique_ptr&& pimpl) noexcept - : service::Object{ getTypeNames(), getResolvers() } - , _pimpl { std::move(pimpl) } -{ -} - -service::TypeNames Folder::getTypeNames() const noexcept -{ - return { - R"gql(Node)gql"sv, - R"gql(UnionType)gql"sv, - R"gql(Folder)gql"sv - }; -} - -service::ResolverMap Folder::getResolvers() const noexcept -{ - return { - { R"gql(id)gql"sv, [this](service::ResolverParams&& params) { return resolveId(std::move(params)); } }, - { R"gql(name)gql"sv, [this](service::ResolverParams&& params) { return resolveName(std::move(params)); } }, - { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, - { R"gql(unreadCount)gql"sv, [this](service::ResolverParams&& params) { return resolveUnreadCount(std::move(params)); } } - }; -} - -void Folder::beginSelectionSet(const service::SelectionSetParams& params) const -{ - _pimpl->beginSelectionSet(params); -} - -void Folder::endSelectionSet(const service::SelectionSetParams& params) const -{ - _pimpl->endSelectionSet(params); -} - -service::AwaitableResolver Folder::resolveId(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getId(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Folder::resolveName(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getName(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Folder::resolveUnreadCount(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getUnreadCount(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Folder::resolve_typename(service::ResolverParams&& params) const -{ - return service::ModifiedResult::convert(std::string{ R"gql(Folder)gql" }, std::move(params)); -} - -NestedType::NestedType(std::unique_ptr&& pimpl) noexcept - : service::Object{ getTypeNames(), getResolvers() } - , _pimpl { std::move(pimpl) } -{ -} - -service::TypeNames NestedType::getTypeNames() const noexcept -{ - return { - R"gql(NestedType)gql"sv - }; -} - -service::ResolverMap NestedType::getResolvers() const noexcept -{ - return { - { R"gql(depth)gql"sv, [this](service::ResolverParams&& params) { return resolveDepth(std::move(params)); } }, - { R"gql(nested)gql"sv, [this](service::ResolverParams&& params) { return resolveNested(std::move(params)); } }, - { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } } - }; -} - -void NestedType::beginSelectionSet(const service::SelectionSetParams& params) const -{ - _pimpl->beginSelectionSet(params); -} - -void NestedType::endSelectionSet(const service::SelectionSetParams& params) const -{ - _pimpl->endSelectionSet(params); -} - -service::AwaitableResolver NestedType::resolveDepth(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getDepth(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver NestedType::resolveNested(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getNested(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver NestedType::resolve_typename(service::ResolverParams&& params) const -{ - return service::ModifiedResult::convert(std::string{ R"gql(NestedType)gql" }, std::move(params)); -} - -Expensive::Expensive(std::unique_ptr&& pimpl) noexcept - : service::Object{ getTypeNames(), getResolvers() } - , _pimpl { std::move(pimpl) } -{ -} - -service::TypeNames Expensive::getTypeNames() const noexcept -{ - return { - R"gql(Expensive)gql"sv - }; -} - -service::ResolverMap Expensive::getResolvers() const noexcept -{ - return { - { R"gql(order)gql"sv, [this](service::ResolverParams&& params) { return resolveOrder(std::move(params)); } }, - { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } } - }; -} - -void Expensive::beginSelectionSet(const service::SelectionSetParams& params) const -{ - _pimpl->beginSelectionSet(params); -} - -void Expensive::endSelectionSet(const service::SelectionSetParams& params) const -{ - _pimpl->endSelectionSet(params); -} - -service::AwaitableResolver Expensive::resolveOrder(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getOrder(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Expensive::resolve_typename(service::ResolverParams&& params) const -{ - return service::ModifiedResult::convert(std::string{ R"gql(Expensive)gql" }, std::move(params)); -} - -} // namespace object - -Operations::Operations(std::shared_ptr query, std::shared_ptr mutation, std::shared_ptr subscription) - : service::Request({ - { "query", query }, - { "mutation", mutation }, - { "subscription", subscription } - }, GetSchema()) - , _query(std::move(query)) - , _mutation(std::move(mutation)) - , _subscription(std::move(subscription)) -{ -} - -void AddTypesToSchema(const std::shared_ptr& schema) -{ - schema->AddType(R"gql(ItemCursor)gql"sv, schema::ScalarType::Make(R"gql(ItemCursor)gql"sv, R"md()md")); - schema->AddType(R"gql(DateTime)gql"sv, schema::ScalarType::Make(R"gql(DateTime)gql"sv, R"md()md")); - auto typeTaskState = schema::EnumType::Make(R"gql(TaskState)gql"sv, R"md()md"sv); - schema->AddType(R"gql(TaskState)gql"sv, typeTaskState); - auto typeCompleteTaskInput = schema::InputObjectType::Make(R"gql(CompleteTaskInput)gql"sv, R"md()md"sv); - schema->AddType(R"gql(CompleteTaskInput)gql"sv, typeCompleteTaskInput); - auto typeThirdNestedInput = schema::InputObjectType::Make(R"gql(ThirdNestedInput)gql"sv, R"md()md"sv); - schema->AddType(R"gql(ThirdNestedInput)gql"sv, typeThirdNestedInput); - auto typeFourthNestedInput = schema::InputObjectType::Make(R"gql(FourthNestedInput)gql"sv, R"md()md"sv); - schema->AddType(R"gql(FourthNestedInput)gql"sv, typeFourthNestedInput); - auto typeSecondNestedInput = schema::InputObjectType::Make(R"gql(SecondNestedInput)gql"sv, R"md()md"sv); - schema->AddType(R"gql(SecondNestedInput)gql"sv, typeSecondNestedInput); - auto typeFirstNestedInput = schema::InputObjectType::Make(R"gql(FirstNestedInput)gql"sv, R"md()md"sv); - schema->AddType(R"gql(FirstNestedInput)gql"sv, typeFirstNestedInput); - auto typeNode = schema::InterfaceType::Make(R"gql(Node)gql"sv, R"md()md"sv); - schema->AddType(R"gql(Node)gql"sv, typeNode); - auto typeUnionType = schema::UnionType::Make(R"gql(UnionType)gql"sv, R"md()md"sv); - schema->AddType(R"gql(UnionType)gql"sv, typeUnionType); - auto typeQuery = schema::ObjectType::Make(R"gql(Query)gql"sv, R"md()md"); - schema->AddType(R"gql(Query)gql"sv, typeQuery); - auto typePageInfo = schema::ObjectType::Make(R"gql(PageInfo)gql"sv, R"md()md"); - schema->AddType(R"gql(PageInfo)gql"sv, typePageInfo); - auto typeAppointmentEdge = schema::ObjectType::Make(R"gql(AppointmentEdge)gql"sv, R"md()md"); - schema->AddType(R"gql(AppointmentEdge)gql"sv, typeAppointmentEdge); - auto typeAppointmentConnection = schema::ObjectType::Make(R"gql(AppointmentConnection)gql"sv, R"md()md"); - schema->AddType(R"gql(AppointmentConnection)gql"sv, typeAppointmentConnection); - auto typeTaskEdge = schema::ObjectType::Make(R"gql(TaskEdge)gql"sv, R"md()md"); - schema->AddType(R"gql(TaskEdge)gql"sv, typeTaskEdge); - auto typeTaskConnection = schema::ObjectType::Make(R"gql(TaskConnection)gql"sv, R"md()md"); - schema->AddType(R"gql(TaskConnection)gql"sv, typeTaskConnection); - auto typeFolderEdge = schema::ObjectType::Make(R"gql(FolderEdge)gql"sv, R"md()md"); - schema->AddType(R"gql(FolderEdge)gql"sv, typeFolderEdge); - auto typeFolderConnection = schema::ObjectType::Make(R"gql(FolderConnection)gql"sv, R"md()md"); - schema->AddType(R"gql(FolderConnection)gql"sv, typeFolderConnection); - auto typeCompleteTaskPayload = schema::ObjectType::Make(R"gql(CompleteTaskPayload)gql"sv, R"md()md"); - schema->AddType(R"gql(CompleteTaskPayload)gql"sv, typeCompleteTaskPayload); - auto typeMutation = schema::ObjectType::Make(R"gql(Mutation)gql"sv, R"md()md"); - schema->AddType(R"gql(Mutation)gql"sv, typeMutation); - auto typeSubscription = schema::ObjectType::Make(R"gql(Subscription)gql"sv, R"md()md"); - schema->AddType(R"gql(Subscription)gql"sv, typeSubscription); - auto typeAppointment = schema::ObjectType::Make(R"gql(Appointment)gql"sv, R"md()md"); - schema->AddType(R"gql(Appointment)gql"sv, typeAppointment); - auto typeTask = schema::ObjectType::Make(R"gql(Task)gql"sv, R"md()md"); - schema->AddType(R"gql(Task)gql"sv, typeTask); - auto typeFolder = schema::ObjectType::Make(R"gql(Folder)gql"sv, R"md()md"); - schema->AddType(R"gql(Folder)gql"sv, typeFolder); - auto typeNestedType = schema::ObjectType::Make(R"gql(NestedType)gql"sv, R"md()md"); - schema->AddType(R"gql(NestedType)gql"sv, typeNestedType); - auto typeExpensive = schema::ObjectType::Make(R"gql(Expensive)gql"sv, R"md()md"); - schema->AddType(R"gql(Expensive)gql"sv, typeExpensive); - - typeTaskState->AddEnumValues({ - { service::s_namesTaskState[static_cast(today::TaskState::New)], R"md()md"sv, std::nullopt }, - { service::s_namesTaskState[static_cast(today::TaskState::Started)], R"md()md"sv, std::nullopt }, - { service::s_namesTaskState[static_cast(today::TaskState::Complete)], R"md()md"sv, std::nullopt }, - { service::s_namesTaskState[static_cast(today::TaskState::Unassigned)], R"md()md"sv, std::make_optional(R"md(Need to deprecate an [enum value](http://spec.graphql.org/June2018/#sec-Deprecation))md"sv) } - }); - - typeCompleteTaskInput->AddInputValues({ - schema::InputValue::Make(R"gql(id)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ID)gql"sv)), R"gql()gql"sv), - schema::InputValue::Make(R"gql(testTaskState)gql"sv, R"md()md"sv, schema->LookupType(R"gql(TaskState)gql"sv), R"gql()gql"sv), - schema::InputValue::Make(R"gql(isComplete)gql"sv, R"md()md"sv, schema->LookupType(R"gql(Boolean)gql"sv), R"gql(true)gql"sv), - schema::InputValue::Make(R"gql(clientMutationId)gql"sv, R"md()md"sv, schema->LookupType(R"gql(String)gql"sv), R"gql()gql"sv) - }); - typeThirdNestedInput->AddInputValues({ - schema::InputValue::Make(R"gql(id)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ID)gql"sv)), R"gql()gql"sv) - }); - typeFourthNestedInput->AddInputValues({ - schema::InputValue::Make(R"gql(id)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ID)gql"sv)), R"gql()gql"sv) - }); - typeSecondNestedInput->AddInputValues({ - schema::InputValue::Make(R"gql(id)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ID)gql"sv)), R"gql()gql"sv), - schema::InputValue::Make(R"gql(third)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ThirdNestedInput)gql"sv)), R"gql()gql"sv) - }); - typeFirstNestedInput->AddInputValues({ - schema::InputValue::Make(R"gql(id)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ID)gql"sv)), R"gql()gql"sv), - schema::InputValue::Make(R"gql(second)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(SecondNestedInput)gql"sv)), R"gql()gql"sv), - schema::InputValue::Make(R"gql(third)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ThirdNestedInput)gql"sv)), R"gql()gql"sv) - }); - - typeNode->AddFields({ - schema::Field::Make(R"gql(id)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ID)gql"sv))) - }); - - typeUnionType->AddPossibleTypes({ - schema->LookupType(R"gql(Appointment)gql"sv), - schema->LookupType(R"gql(Task)gql"sv), - schema->LookupType(R"gql(Folder)gql"sv) - }); - - typeQuery->AddFields({ - schema::Field::Make(R"gql(node)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(Node)gql"sv), { - schema::InputValue::Make(R"gql(id)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ID)gql"sv)), R"gql()gql"sv) - }), - schema::Field::Make(R"gql(appointments)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(AppointmentConnection)gql"sv)), { - schema::InputValue::Make(R"gql(first)gql"sv, R"md()md"sv, schema->LookupType(R"gql(Int)gql"sv), R"gql()gql"sv), - schema::InputValue::Make(R"gql(after)gql"sv, R"md()md"sv, schema->LookupType(R"gql(ItemCursor)gql"sv), R"gql()gql"sv), - schema::InputValue::Make(R"gql(last)gql"sv, R"md()md"sv, schema->LookupType(R"gql(Int)gql"sv), R"gql()gql"sv), - schema::InputValue::Make(R"gql(before)gql"sv, R"md()md"sv, schema->LookupType(R"gql(ItemCursor)gql"sv), R"gql()gql"sv) - }), - schema::Field::Make(R"gql(tasks)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(TaskConnection)gql"sv)), { - schema::InputValue::Make(R"gql(first)gql"sv, R"md()md"sv, schema->LookupType(R"gql(Int)gql"sv), R"gql()gql"sv), - schema::InputValue::Make(R"gql(after)gql"sv, R"md()md"sv, schema->LookupType(R"gql(ItemCursor)gql"sv), R"gql()gql"sv), - schema::InputValue::Make(R"gql(last)gql"sv, R"md()md"sv, schema->LookupType(R"gql(Int)gql"sv), R"gql()gql"sv), - schema::InputValue::Make(R"gql(before)gql"sv, R"md()md"sv, schema->LookupType(R"gql(ItemCursor)gql"sv), R"gql()gql"sv) - }), - schema::Field::Make(R"gql(unreadCounts)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(FolderConnection)gql"sv)), { - schema::InputValue::Make(R"gql(first)gql"sv, R"md()md"sv, schema->LookupType(R"gql(Int)gql"sv), R"gql()gql"sv), - schema::InputValue::Make(R"gql(after)gql"sv, R"md()md"sv, schema->LookupType(R"gql(ItemCursor)gql"sv), R"gql()gql"sv), - schema::InputValue::Make(R"gql(last)gql"sv, R"md()md"sv, schema->LookupType(R"gql(Int)gql"sv), R"gql()gql"sv), - schema::InputValue::Make(R"gql(before)gql"sv, R"md()md"sv, schema->LookupType(R"gql(ItemCursor)gql"sv), R"gql()gql"sv) - }), - schema::Field::Make(R"gql(appointmentsById)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->LookupType(R"gql(Appointment)gql"sv))), { - schema::InputValue::Make(R"gql(ids)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ID)gql"sv)))), R"gql(["ZmFrZUFwcG9pbnRtZW50SWQ="])gql"sv) - }), - schema::Field::Make(R"gql(tasksById)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->LookupType(R"gql(Task)gql"sv))), { - schema::InputValue::Make(R"gql(ids)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ID)gql"sv)))), R"gql()gql"sv) - }), - schema::Field::Make(R"gql(unreadCountsById)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->LookupType(R"gql(Folder)gql"sv))), { - schema::InputValue::Make(R"gql(ids)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ID)gql"sv)))), R"gql()gql"sv) - }), - schema::Field::Make(R"gql(nested)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(NestedType)gql"sv))), - schema::Field::Make(R"gql(unimplemented)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(String)gql"sv))), - schema::Field::Make(R"gql(expensive)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Expensive)gql"sv))))), - schema::Field::Make(R"gql(testTaskState)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(TaskState)gql"sv))), - schema::Field::Make(R"gql(anyType)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->LookupType(R"gql(UnionType)gql"sv))), { - schema::InputValue::Make(R"gql(ids)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ID)gql"sv)))), R"gql()gql"sv) - }) - }); - typePageInfo->AddFields({ - schema::Field::Make(R"gql(hasNextPage)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Boolean)gql"sv))), - schema::Field::Make(R"gql(hasPreviousPage)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Boolean)gql"sv))) - }); - typeAppointmentEdge->AddFields({ - schema::Field::Make(R"gql(node)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(Appointment)gql"sv)), - schema::Field::Make(R"gql(cursor)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ItemCursor)gql"sv))) - }); - typeAppointmentConnection->AddFields({ - schema::Field::Make(R"gql(pageInfo)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(PageInfo)gql"sv))), - schema::Field::Make(R"gql(edges)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::LIST, schema->LookupType(R"gql(AppointmentEdge)gql"sv))) - }); - typeTaskEdge->AddFields({ - schema::Field::Make(R"gql(node)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(Task)gql"sv)), - schema::Field::Make(R"gql(cursor)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ItemCursor)gql"sv))) - }); - typeTaskConnection->AddFields({ - schema::Field::Make(R"gql(pageInfo)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(PageInfo)gql"sv))), - schema::Field::Make(R"gql(edges)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::LIST, schema->LookupType(R"gql(TaskEdge)gql"sv))) - }); - typeFolderEdge->AddFields({ - schema::Field::Make(R"gql(node)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(Folder)gql"sv)), - schema::Field::Make(R"gql(cursor)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ItemCursor)gql"sv))) - }); - typeFolderConnection->AddFields({ - schema::Field::Make(R"gql(pageInfo)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(PageInfo)gql"sv))), - schema::Field::Make(R"gql(edges)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::LIST, schema->LookupType(R"gql(FolderEdge)gql"sv))) - }); - typeCompleteTaskPayload->AddFields({ - schema::Field::Make(R"gql(task)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(Task)gql"sv)), - schema::Field::Make(R"gql(clientMutationId)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(String)gql"sv)) - }); - typeMutation->AddFields({ - schema::Field::Make(R"gql(completeTask)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(CompleteTaskPayload)gql"sv)), { - schema::InputValue::Make(R"gql(input)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(CompleteTaskInput)gql"sv)), R"gql()gql"sv) - }), - schema::Field::Make(R"gql(setFloat)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Float)gql"sv)), { - schema::InputValue::Make(R"gql(value)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Float)gql"sv)), R"gql()gql"sv) - }) - }); - typeSubscription->AddFields({ - schema::Field::Make(R"gql(nextAppointmentChange)gql"sv, R"md()md"sv, std::make_optional(R"md(Need to deprecate a [field](http://spec.graphql.org/June2018/#sec-Deprecation))md"sv), schema->LookupType(R"gql(Appointment)gql"sv)), - schema::Field::Make(R"gql(nodeChange)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Node)gql"sv)), { - schema::InputValue::Make(R"gql(id)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ID)gql"sv)), R"gql()gql"sv) - }) - }); - typeAppointment->AddInterfaces({ - typeNode - }); - typeAppointment->AddFields({ - schema::Field::Make(R"gql(id)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ID)gql"sv))), - schema::Field::Make(R"gql(when)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(DateTime)gql"sv)), - schema::Field::Make(R"gql(subject)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(String)gql"sv)), - schema::Field::Make(R"gql(isNow)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Boolean)gql"sv))), - schema::Field::Make(R"gql(forceError)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(String)gql"sv)) - }); - typeTask->AddInterfaces({ - typeNode - }); - typeTask->AddFields({ - schema::Field::Make(R"gql(id)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ID)gql"sv))), - schema::Field::Make(R"gql(title)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(String)gql"sv)), - schema::Field::Make(R"gql(isComplete)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Boolean)gql"sv))) - }); - typeFolder->AddInterfaces({ - typeNode - }); - typeFolder->AddFields({ - schema::Field::Make(R"gql(id)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ID)gql"sv))), - schema::Field::Make(R"gql(name)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(String)gql"sv)), - schema::Field::Make(R"gql(unreadCount)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Int)gql"sv))) - }); - typeNestedType->AddFields({ - schema::Field::Make(R"gql(depth)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Int)gql"sv))), - schema::Field::Make(R"gql(nested)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(NestedType)gql"sv))) - }); - typeExpensive->AddFields({ - schema::Field::Make(R"gql(order)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Int)gql"sv))) - }); - - schema->AddDirective(schema::Directive::Make(R"gql(id)gql"sv, R"md()md"sv, { - introspection::DirectiveLocation::FIELD_DEFINITION - })); - schema->AddDirective(schema::Directive::Make(R"gql(subscriptionTag)gql"sv, R"md()md"sv, { - introspection::DirectiveLocation::SUBSCRIPTION - }, { - schema::InputValue::Make(R"gql(field)gql"sv, R"md()md"sv, schema->LookupType(R"gql(String)gql"sv), R"gql()gql"sv) - })); - schema->AddDirective(schema::Directive::Make(R"gql(queryTag)gql"sv, R"md()md"sv, { - introspection::DirectiveLocation::QUERY - }, { - schema::InputValue::Make(R"gql(query)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(String)gql"sv)), R"gql()gql"sv) - })); - schema->AddDirective(schema::Directive::Make(R"gql(fieldTag)gql"sv, R"md()md"sv, { - introspection::DirectiveLocation::FIELD - }, { - schema::InputValue::Make(R"gql(field)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(String)gql"sv)), R"gql()gql"sv) - })); - schema->AddDirective(schema::Directive::Make(R"gql(fragmentDefinitionTag)gql"sv, R"md()md"sv, { - introspection::DirectiveLocation::FRAGMENT_DEFINITION - }, { - schema::InputValue::Make(R"gql(fragmentDefinition)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(String)gql"sv)), R"gql()gql"sv) - })); - schema->AddDirective(schema::Directive::Make(R"gql(fragmentSpreadTag)gql"sv, R"md()md"sv, { - introspection::DirectiveLocation::FRAGMENT_SPREAD - }, { - schema::InputValue::Make(R"gql(fragmentSpread)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(String)gql"sv)), R"gql()gql"sv) - })); - schema->AddDirective(schema::Directive::Make(R"gql(inlineFragmentTag)gql"sv, R"md()md"sv, { - introspection::DirectiveLocation::INLINE_FRAGMENT - }, { - schema::InputValue::Make(R"gql(inlineFragment)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(String)gql"sv)), R"gql()gql"sv) - })); - - schema->AddQueryType(typeQuery); - schema->AddMutationType(typeMutation); - schema->AddSubscriptionType(typeSubscription); -} - -std::shared_ptr GetSchema() -{ - static std::weak_ptr s_wpSchema; - auto schema = s_wpSchema.lock(); - - if (!schema) - { - schema = std::make_shared(true); - introspection::AddTypesToSchema(schema); - AddTypesToSchema(schema); - s_wpSchema = schema; - } - - return schema; -} - -} // namespace today -} // namespace graphql diff --git a/samples/today/unified_nointrospection/TodaySchema.h b/samples/today/unified_nointrospection/TodaySchema.h deleted file mode 100644 index 2b45e036..00000000 --- a/samples/today/unified_nointrospection/TodaySchema.h +++ /dev/null @@ -1,2934 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// WARNING! Do not edit this file manually, your changes will be overwritten. - -#pragma once - -#ifndef TODAYSCHEMA_H -#define TODAYSCHEMA_H - -#include "graphqlservice/internal/Schema.h" - -// Check if the library version is compatible with schemagen 4.0.0 -static_assert(graphql::internal::MajorVersion == 4, "regenerate with schemagen: major version mismatch"); -static_assert(graphql::internal::MinorVersion == 0, "regenerate with schemagen: minor version mismatch"); - -#include -#include -#include - -namespace graphql { -namespace today { - -enum class TaskState -{ - New, - Started, - Complete, - Unassigned -}; - -struct CompleteTaskInput -{ - response::IdType id; - std::optional testTaskState; - std::optional isComplete; - std::optional clientMutationId; -}; - -struct ThirdNestedInput -{ - response::IdType id; -}; - -struct FourthNestedInput -{ - response::IdType id; -}; - -struct SecondNestedInput -{ - response::IdType id; - ThirdNestedInput third; -}; - -struct FirstNestedInput -{ - response::IdType id; - SecondNestedInput second; - ThirdNestedInput third; -}; - -namespace object { - -class Node; - -class UnionType; - -class Query; -class PageInfo; -class AppointmentEdge; -class AppointmentConnection; -class TaskEdge; -class TaskConnection; -class FolderEdge; -class FolderConnection; -class CompleteTaskPayload; -class Mutation; -class Subscription; -class Appointment; -class Task; -class Folder; -class NestedType; -class Expensive; - -class Node - : public service::Object -{ -private: - struct Concept - { - virtual ~Concept() = default; - - virtual service::TypeNames getTypeNames() const noexcept = 0; - virtual service::ResolverMap getResolvers() const noexcept = 0; - - virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - }; - - template - struct Model - : Concept - { - Model(std::shared_ptr&& pimpl) noexcept - : _pimpl { std::move(pimpl) } - { - } - - service::TypeNames getTypeNames() const noexcept final - { - return _pimpl->getTypeNames(); - } - - service::ResolverMap getResolvers() const noexcept final - { - return _pimpl->getResolvers(); - } - - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - _pimpl->beginSelectionSet(params); - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - _pimpl->endSelectionSet(params); - } - - private: - const std::shared_ptr _pimpl; - }; - - Node(std::unique_ptr&& pimpl) noexcept; - - void beginSelectionSet(const service::SelectionSetParams& params) const final; - void endSelectionSet(const service::SelectionSetParams& params) const final; - - const std::unique_ptr _pimpl; - -public: - template - Node(std::shared_ptr pimpl) noexcept - : Node { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } - { - static_assert(T::template implements(), "Node is not implemented"); - } -}; - -class UnionType - : public service::Object -{ -private: - struct Concept - { - virtual ~Concept() = default; - - virtual service::TypeNames getTypeNames() const noexcept = 0; - virtual service::ResolverMap getResolvers() const noexcept = 0; - - virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - }; - - template - struct Model - : Concept - { - Model(std::shared_ptr&& pimpl) noexcept - : _pimpl { std::move(pimpl) } - { - } - - service::TypeNames getTypeNames() const noexcept final - { - return _pimpl->getTypeNames(); - } - - service::ResolverMap getResolvers() const noexcept final - { - return _pimpl->getResolvers(); - } - - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - _pimpl->beginSelectionSet(params); - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - _pimpl->endSelectionSet(params); - } - - private: - const std::shared_ptr _pimpl; - }; - - UnionType(std::unique_ptr&& pimpl) noexcept; - - void beginSelectionSet(const service::SelectionSetParams& params) const final; - void endSelectionSet(const service::SelectionSetParams& params) const final; - - const std::unique_ptr _pimpl; - -public: - template - UnionType(std::shared_ptr pimpl) noexcept - : UnionType { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } - { - static_assert(T::template implements(), "UnionType is not implemented"); - } -}; - -namespace implements { - -template -concept AppointmentIs = std::is_same_v || std::is_same_v; - -template -concept TaskIs = std::is_same_v || std::is_same_v; - -template -concept FolderIs = std::is_same_v || std::is_same_v; - -} // namespace implements - -namespace methods { -namespace QueryHas { - -template -concept getNodeWithParams = requires (TImpl impl, service::FieldParams params, response::IdType idArg) -{ - { service::FieldResult> { impl.getNode(std::move(params), std::move(idArg)) } }; -}; - -template -concept getNode = requires (TImpl impl, response::IdType idArg) -{ - { service::FieldResult> { impl.getNode(std::move(idArg)) } }; -}; - -template -concept getAppointmentsWithParams = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) -{ - { service::FieldResult> { impl.getAppointments(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; -}; - -template -concept getAppointments = requires (TImpl impl, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) -{ - { service::FieldResult> { impl.getAppointments(std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; -}; - -template -concept getTasksWithParams = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) -{ - { service::FieldResult> { impl.getTasks(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; -}; - -template -concept getTasks = requires (TImpl impl, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) -{ - { service::FieldResult> { impl.getTasks(std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; -}; - -template -concept getUnreadCountsWithParams = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) -{ - { service::FieldResult> { impl.getUnreadCounts(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; -}; - -template -concept getUnreadCounts = requires (TImpl impl, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) -{ - { service::FieldResult> { impl.getUnreadCounts(std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; -}; - -template -concept getAppointmentsByIdWithParams = requires (TImpl impl, service::FieldParams params, std::vector idsArg) -{ - { service::FieldResult>> { impl.getAppointmentsById(std::move(params), std::move(idsArg)) } }; -}; - -template -concept getAppointmentsById = requires (TImpl impl, std::vector idsArg) -{ - { service::FieldResult>> { impl.getAppointmentsById(std::move(idsArg)) } }; -}; - -template -concept getTasksByIdWithParams = requires (TImpl impl, service::FieldParams params, std::vector idsArg) -{ - { service::FieldResult>> { impl.getTasksById(std::move(params), std::move(idsArg)) } }; -}; - -template -concept getTasksById = requires (TImpl impl, std::vector idsArg) -{ - { service::FieldResult>> { impl.getTasksById(std::move(idsArg)) } }; -}; - -template -concept getUnreadCountsByIdWithParams = requires (TImpl impl, service::FieldParams params, std::vector idsArg) -{ - { service::FieldResult>> { impl.getUnreadCountsById(std::move(params), std::move(idsArg)) } }; -}; - -template -concept getUnreadCountsById = requires (TImpl impl, std::vector idsArg) -{ - { service::FieldResult>> { impl.getUnreadCountsById(std::move(idsArg)) } }; -}; - -template -concept getNestedWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getNested(std::move(params)) } }; -}; - -template -concept getNested = requires (TImpl impl) -{ - { service::FieldResult> { impl.getNested() } }; -}; - -template -concept getUnimplementedWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult { impl.getUnimplemented(std::move(params)) } }; -}; - -template -concept getUnimplemented = requires (TImpl impl) -{ - { service::FieldResult { impl.getUnimplemented() } }; -}; - -template -concept getExpensiveWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult>> { impl.getExpensive(std::move(params)) } }; -}; - -template -concept getExpensive = requires (TImpl impl) -{ - { service::FieldResult>> { impl.getExpensive() } }; -}; - -template -concept getTestTaskStateWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult { impl.getTestTaskState(std::move(params)) } }; -}; - -template -concept getTestTaskState = requires (TImpl impl) -{ - { service::FieldResult { impl.getTestTaskState() } }; -}; - -template -concept getAnyTypeWithParams = requires (TImpl impl, service::FieldParams params, std::vector idsArg) -{ - { service::FieldResult>> { impl.getAnyType(std::move(params), std::move(idsArg)) } }; -}; - -template -concept getAnyType = requires (TImpl impl, std::vector idsArg) -{ - { service::FieldResult>> { impl.getAnyType(std::move(idsArg)) } }; -}; - -template -concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) -{ - { impl.beginSelectionSet(params) }; -}; - -template -concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) -{ - { impl.endSelectionSet(params) }; -}; - -} // namespace QueryHas - -namespace PageInfoHas { - -template -concept getHasNextPageWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult { impl.getHasNextPage(std::move(params)) } }; -}; - -template -concept getHasNextPage = requires (TImpl impl) -{ - { service::FieldResult { impl.getHasNextPage() } }; -}; - -template -concept getHasPreviousPageWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult { impl.getHasPreviousPage(std::move(params)) } }; -}; - -template -concept getHasPreviousPage = requires (TImpl impl) -{ - { service::FieldResult { impl.getHasPreviousPage() } }; -}; - -template -concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) -{ - { impl.beginSelectionSet(params) }; -}; - -template -concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) -{ - { impl.endSelectionSet(params) }; -}; - -} // namespace PageInfoHas - -namespace AppointmentEdgeHas { - -template -concept getNodeWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getNode(std::move(params)) } }; -}; - -template -concept getNode = requires (TImpl impl) -{ - { service::FieldResult> { impl.getNode() } }; -}; - -template -concept getCursorWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult { impl.getCursor(std::move(params)) } }; -}; - -template -concept getCursor = requires (TImpl impl) -{ - { service::FieldResult { impl.getCursor() } }; -}; - -template -concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) -{ - { impl.beginSelectionSet(params) }; -}; - -template -concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) -{ - { impl.endSelectionSet(params) }; -}; - -} // namespace AppointmentEdgeHas - -namespace AppointmentConnectionHas { - -template -concept getPageInfoWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getPageInfo(std::move(params)) } }; -}; - -template -concept getPageInfo = requires (TImpl impl) -{ - { service::FieldResult> { impl.getPageInfo() } }; -}; - -template -concept getEdgesWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult>>> { impl.getEdges(std::move(params)) } }; -}; - -template -concept getEdges = requires (TImpl impl) -{ - { service::FieldResult>>> { impl.getEdges() } }; -}; - -template -concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) -{ - { impl.beginSelectionSet(params) }; -}; - -template -concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) -{ - { impl.endSelectionSet(params) }; -}; - -} // namespace AppointmentConnectionHas - -namespace TaskEdgeHas { - -template -concept getNodeWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getNode(std::move(params)) } }; -}; - -template -concept getNode = requires (TImpl impl) -{ - { service::FieldResult> { impl.getNode() } }; -}; - -template -concept getCursorWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult { impl.getCursor(std::move(params)) } }; -}; - -template -concept getCursor = requires (TImpl impl) -{ - { service::FieldResult { impl.getCursor() } }; -}; - -template -concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) -{ - { impl.beginSelectionSet(params) }; -}; - -template -concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) -{ - { impl.endSelectionSet(params) }; -}; - -} // namespace TaskEdgeHas - -namespace TaskConnectionHas { - -template -concept getPageInfoWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getPageInfo(std::move(params)) } }; -}; - -template -concept getPageInfo = requires (TImpl impl) -{ - { service::FieldResult> { impl.getPageInfo() } }; -}; - -template -concept getEdgesWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult>>> { impl.getEdges(std::move(params)) } }; -}; - -template -concept getEdges = requires (TImpl impl) -{ - { service::FieldResult>>> { impl.getEdges() } }; -}; - -template -concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) -{ - { impl.beginSelectionSet(params) }; -}; - -template -concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) -{ - { impl.endSelectionSet(params) }; -}; - -} // namespace TaskConnectionHas - -namespace FolderEdgeHas { - -template -concept getNodeWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getNode(std::move(params)) } }; -}; - -template -concept getNode = requires (TImpl impl) -{ - { service::FieldResult> { impl.getNode() } }; -}; - -template -concept getCursorWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult { impl.getCursor(std::move(params)) } }; -}; - -template -concept getCursor = requires (TImpl impl) -{ - { service::FieldResult { impl.getCursor() } }; -}; - -template -concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) -{ - { impl.beginSelectionSet(params) }; -}; - -template -concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) -{ - { impl.endSelectionSet(params) }; -}; - -} // namespace FolderEdgeHas - -namespace FolderConnectionHas { - -template -concept getPageInfoWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getPageInfo(std::move(params)) } }; -}; - -template -concept getPageInfo = requires (TImpl impl) -{ - { service::FieldResult> { impl.getPageInfo() } }; -}; - -template -concept getEdgesWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult>>> { impl.getEdges(std::move(params)) } }; -}; - -template -concept getEdges = requires (TImpl impl) -{ - { service::FieldResult>>> { impl.getEdges() } }; -}; - -template -concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) -{ - { impl.beginSelectionSet(params) }; -}; - -template -concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) -{ - { impl.endSelectionSet(params) }; -}; - -} // namespace FolderConnectionHas - -namespace CompleteTaskPayloadHas { - -template -concept getTaskWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getTask(std::move(params)) } }; -}; - -template -concept getTask = requires (TImpl impl) -{ - { service::FieldResult> { impl.getTask() } }; -}; - -template -concept getClientMutationIdWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getClientMutationId(std::move(params)) } }; -}; - -template -concept getClientMutationId = requires (TImpl impl) -{ - { service::FieldResult> { impl.getClientMutationId() } }; -}; - -template -concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) -{ - { impl.beginSelectionSet(params) }; -}; - -template -concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) -{ - { impl.endSelectionSet(params) }; -}; - -} // namespace CompleteTaskPayloadHas - -namespace MutationHas { - -template -concept applyCompleteTaskWithParams = requires (TImpl impl, service::FieldParams params, CompleteTaskInput inputArg) -{ - { service::FieldResult> { impl.applyCompleteTask(std::move(params), std::move(inputArg)) } }; -}; - -template -concept applyCompleteTask = requires (TImpl impl, CompleteTaskInput inputArg) -{ - { service::FieldResult> { impl.applyCompleteTask(std::move(inputArg)) } }; -}; - -template -concept applySetFloatWithParams = requires (TImpl impl, service::FieldParams params, double valueArg) -{ - { service::FieldResult { impl.applySetFloat(std::move(params), std::move(valueArg)) } }; -}; - -template -concept applySetFloat = requires (TImpl impl, double valueArg) -{ - { service::FieldResult { impl.applySetFloat(std::move(valueArg)) } }; -}; - -template -concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) -{ - { impl.beginSelectionSet(params) }; -}; - -template -concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) -{ - { impl.endSelectionSet(params) }; -}; - -} // namespace MutationHas - -namespace SubscriptionHas { - -template -concept getNextAppointmentChangeWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getNextAppointmentChange(std::move(params)) } }; -}; - -template -concept getNextAppointmentChange = requires (TImpl impl) -{ - { service::FieldResult> { impl.getNextAppointmentChange() } }; -}; - -template -concept getNodeChangeWithParams = requires (TImpl impl, service::FieldParams params, response::IdType idArg) -{ - { service::FieldResult> { impl.getNodeChange(std::move(params), std::move(idArg)) } }; -}; - -template -concept getNodeChange = requires (TImpl impl, response::IdType idArg) -{ - { service::FieldResult> { impl.getNodeChange(std::move(idArg)) } }; -}; - -template -concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) -{ - { impl.beginSelectionSet(params) }; -}; - -template -concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) -{ - { impl.endSelectionSet(params) }; -}; - -} // namespace SubscriptionHas - -namespace AppointmentHas { - -template -concept getIdWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult { impl.getId(std::move(params)) } }; -}; - -template -concept getId = requires (TImpl impl) -{ - { service::FieldResult { impl.getId() } }; -}; - -template -concept getWhenWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getWhen(std::move(params)) } }; -}; - -template -concept getWhen = requires (TImpl impl) -{ - { service::FieldResult> { impl.getWhen() } }; -}; - -template -concept getSubjectWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getSubject(std::move(params)) } }; -}; - -template -concept getSubject = requires (TImpl impl) -{ - { service::FieldResult> { impl.getSubject() } }; -}; - -template -concept getIsNowWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult { impl.getIsNow(std::move(params)) } }; -}; - -template -concept getIsNow = requires (TImpl impl) -{ - { service::FieldResult { impl.getIsNow() } }; -}; - -template -concept getForceErrorWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getForceError(std::move(params)) } }; -}; - -template -concept getForceError = requires (TImpl impl) -{ - { service::FieldResult> { impl.getForceError() } }; -}; - -template -concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) -{ - { impl.beginSelectionSet(params) }; -}; - -template -concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) -{ - { impl.endSelectionSet(params) }; -}; - -} // namespace AppointmentHas - -namespace TaskHas { - -template -concept getIdWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult { impl.getId(std::move(params)) } }; -}; - -template -concept getId = requires (TImpl impl) -{ - { service::FieldResult { impl.getId() } }; -}; - -template -concept getTitleWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getTitle(std::move(params)) } }; -}; - -template -concept getTitle = requires (TImpl impl) -{ - { service::FieldResult> { impl.getTitle() } }; -}; - -template -concept getIsCompleteWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult { impl.getIsComplete(std::move(params)) } }; -}; - -template -concept getIsComplete = requires (TImpl impl) -{ - { service::FieldResult { impl.getIsComplete() } }; -}; - -template -concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) -{ - { impl.beginSelectionSet(params) }; -}; - -template -concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) -{ - { impl.endSelectionSet(params) }; -}; - -} // namespace TaskHas - -namespace FolderHas { - -template -concept getIdWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult { impl.getId(std::move(params)) } }; -}; - -template -concept getId = requires (TImpl impl) -{ - { service::FieldResult { impl.getId() } }; -}; - -template -concept getNameWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getName(std::move(params)) } }; -}; - -template -concept getName = requires (TImpl impl) -{ - { service::FieldResult> { impl.getName() } }; -}; - -template -concept getUnreadCountWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult { impl.getUnreadCount(std::move(params)) } }; -}; - -template -concept getUnreadCount = requires (TImpl impl) -{ - { service::FieldResult { impl.getUnreadCount() } }; -}; - -template -concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) -{ - { impl.beginSelectionSet(params) }; -}; - -template -concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) -{ - { impl.endSelectionSet(params) }; -}; - -} // namespace FolderHas - -namespace NestedTypeHas { - -template -concept getDepthWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult { impl.getDepth(std::move(params)) } }; -}; - -template -concept getDepth = requires (TImpl impl) -{ - { service::FieldResult { impl.getDepth() } }; -}; - -template -concept getNestedWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getNested(std::move(params)) } }; -}; - -template -concept getNested = requires (TImpl impl) -{ - { service::FieldResult> { impl.getNested() } }; -}; - -template -concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) -{ - { impl.beginSelectionSet(params) }; -}; - -template -concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) -{ - { impl.endSelectionSet(params) }; -}; - -} // namespace NestedTypeHas - -namespace ExpensiveHas { - -template -concept getOrderWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult { impl.getOrder(std::move(params)) } }; -}; - -template -concept getOrder = requires (TImpl impl) -{ - { service::FieldResult { impl.getOrder() } }; -}; - -template -concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) -{ - { impl.beginSelectionSet(params) }; -}; - -template -concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) -{ - { impl.endSelectionSet(params) }; -}; - -} // namespace ExpensiveHas -} // namespace methods - -class Query - : public service::Object -{ -private: - service::AwaitableResolver resolveNode(service::ResolverParams&& params) const; - service::AwaitableResolver resolveAppointments(service::ResolverParams&& params) const; - service::AwaitableResolver resolveTasks(service::ResolverParams&& params) const; - service::AwaitableResolver resolveUnreadCounts(service::ResolverParams&& params) const; - service::AwaitableResolver resolveAppointmentsById(service::ResolverParams&& params) const; - service::AwaitableResolver resolveTasksById(service::ResolverParams&& params) const; - service::AwaitableResolver resolveUnreadCountsById(service::ResolverParams&& params) const; - service::AwaitableResolver resolveNested(service::ResolverParams&& params) const; - service::AwaitableResolver resolveUnimplemented(service::ResolverParams&& params) const; - service::AwaitableResolver resolveExpensive(service::ResolverParams&& params) const; - service::AwaitableResolver resolveTestTaskState(service::ResolverParams&& params) const; - service::AwaitableResolver resolveAnyType(service::ResolverParams&& params) const; - - service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; - - struct Concept - { - virtual ~Concept() = default; - - virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - - virtual service::FieldResult> getNode(service::FieldParams&& params, response::IdType&& idArg) const = 0; - virtual service::FieldResult> getAppointments(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const = 0; - virtual service::FieldResult> getTasks(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const = 0; - virtual service::FieldResult> getUnreadCounts(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const = 0; - virtual service::FieldResult>> getAppointmentsById(service::FieldParams&& params, std::vector&& idsArg) const = 0; - virtual service::FieldResult>> getTasksById(service::FieldParams&& params, std::vector&& idsArg) const = 0; - virtual service::FieldResult>> getUnreadCountsById(service::FieldParams&& params, std::vector&& idsArg) const = 0; - virtual service::FieldResult> getNested(service::FieldParams&& params) const = 0; - virtual service::FieldResult getUnimplemented(service::FieldParams&& params) const = 0; - virtual service::FieldResult>> getExpensive(service::FieldParams&& params) const = 0; - virtual service::FieldResult getTestTaskState(service::FieldParams&& params) const = 0; - virtual service::FieldResult>> getAnyType(service::FieldParams&& params, std::vector&& idsArg) const = 0; - }; - - template - struct Model - : Concept - { - Model(std::shared_ptr&& pimpl) noexcept - : _pimpl { std::move(pimpl) } - { - } - - service::FieldResult> getNode(service::FieldParams&& params, response::IdType&& idArg) const final - { - if constexpr (methods::QueryHas::getNodeWithParams) - { - return { _pimpl->getNode(std::move(params), std::move(idArg)) }; - } - else if constexpr (methods::QueryHas::getNode) - { - return { _pimpl->getNode(std::move(idArg)) }; - } - else - { - throw std::runtime_error(R"ex(Query::getNode is not implemented)ex"); - } - } - - service::FieldResult> getAppointments(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const final - { - if constexpr (methods::QueryHas::getAppointmentsWithParams) - { - return { _pimpl->getAppointments(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) }; - } - else if constexpr (methods::QueryHas::getAppointments) - { - return { _pimpl->getAppointments(std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) }; - } - else - { - throw std::runtime_error(R"ex(Query::getAppointments is not implemented)ex"); - } - } - - service::FieldResult> getTasks(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const final - { - if constexpr (methods::QueryHas::getTasksWithParams) - { - return { _pimpl->getTasks(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) }; - } - else if constexpr (methods::QueryHas::getTasks) - { - return { _pimpl->getTasks(std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) }; - } - else - { - throw std::runtime_error(R"ex(Query::getTasks is not implemented)ex"); - } - } - - service::FieldResult> getUnreadCounts(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const final - { - if constexpr (methods::QueryHas::getUnreadCountsWithParams) - { - return { _pimpl->getUnreadCounts(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) }; - } - else if constexpr (methods::QueryHas::getUnreadCounts) - { - return { _pimpl->getUnreadCounts(std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) }; - } - else - { - throw std::runtime_error(R"ex(Query::getUnreadCounts is not implemented)ex"); - } - } - - service::FieldResult>> getAppointmentsById(service::FieldParams&& params, std::vector&& idsArg) const final - { - if constexpr (methods::QueryHas::getAppointmentsByIdWithParams) - { - return { _pimpl->getAppointmentsById(std::move(params), std::move(idsArg)) }; - } - else if constexpr (methods::QueryHas::getAppointmentsById) - { - return { _pimpl->getAppointmentsById(std::move(idsArg)) }; - } - else - { - throw std::runtime_error(R"ex(Query::getAppointmentsById is not implemented)ex"); - } - } - - service::FieldResult>> getTasksById(service::FieldParams&& params, std::vector&& idsArg) const final - { - if constexpr (methods::QueryHas::getTasksByIdWithParams) - { - return { _pimpl->getTasksById(std::move(params), std::move(idsArg)) }; - } - else if constexpr (methods::QueryHas::getTasksById) - { - return { _pimpl->getTasksById(std::move(idsArg)) }; - } - else - { - throw std::runtime_error(R"ex(Query::getTasksById is not implemented)ex"); - } - } - - service::FieldResult>> getUnreadCountsById(service::FieldParams&& params, std::vector&& idsArg) const final - { - if constexpr (methods::QueryHas::getUnreadCountsByIdWithParams) - { - return { _pimpl->getUnreadCountsById(std::move(params), std::move(idsArg)) }; - } - else if constexpr (methods::QueryHas::getUnreadCountsById) - { - return { _pimpl->getUnreadCountsById(std::move(idsArg)) }; - } - else - { - throw std::runtime_error(R"ex(Query::getUnreadCountsById is not implemented)ex"); - } - } - - service::FieldResult> getNested(service::FieldParams&& params) const final - { - if constexpr (methods::QueryHas::getNestedWithParams) - { - return { _pimpl->getNested(std::move(params)) }; - } - else if constexpr (methods::QueryHas::getNested) - { - return { _pimpl->getNested() }; - } - else - { - throw std::runtime_error(R"ex(Query::getNested is not implemented)ex"); - } - } - - service::FieldResult getUnimplemented(service::FieldParams&& params) const final - { - if constexpr (methods::QueryHas::getUnimplementedWithParams) - { - return { _pimpl->getUnimplemented(std::move(params)) }; - } - else if constexpr (methods::QueryHas::getUnimplemented) - { - return { _pimpl->getUnimplemented() }; - } - else - { - throw std::runtime_error(R"ex(Query::getUnimplemented is not implemented)ex"); - } - } - - service::FieldResult>> getExpensive(service::FieldParams&& params) const final - { - if constexpr (methods::QueryHas::getExpensiveWithParams) - { - return { _pimpl->getExpensive(std::move(params)) }; - } - else if constexpr (methods::QueryHas::getExpensive) - { - return { _pimpl->getExpensive() }; - } - else - { - throw std::runtime_error(R"ex(Query::getExpensive is not implemented)ex"); - } - } - - service::FieldResult getTestTaskState(service::FieldParams&& params) const final - { - if constexpr (methods::QueryHas::getTestTaskStateWithParams) - { - return { _pimpl->getTestTaskState(std::move(params)) }; - } - else if constexpr (methods::QueryHas::getTestTaskState) - { - return { _pimpl->getTestTaskState() }; - } - else - { - throw std::runtime_error(R"ex(Query::getTestTaskState is not implemented)ex"); - } - } - - service::FieldResult>> getAnyType(service::FieldParams&& params, std::vector&& idsArg) const final - { - if constexpr (methods::QueryHas::getAnyTypeWithParams) - { - return { _pimpl->getAnyType(std::move(params), std::move(idsArg)) }; - } - else if constexpr (methods::QueryHas::getAnyType) - { - return { _pimpl->getAnyType(std::move(idsArg)) }; - } - else - { - throw std::runtime_error(R"ex(Query::getAnyType is not implemented)ex"); - } - } - - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (methods::QueryHas::beginSelectionSet) - { - _pimpl->beginSelectionSet(params); - } - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (methods::QueryHas::endSelectionSet) - { - _pimpl->endSelectionSet(params); - } - } - - private: - const std::shared_ptr _pimpl; - }; - - Query(std::unique_ptr&& pimpl) noexcept; - - service::TypeNames getTypeNames() const noexcept; - service::ResolverMap getResolvers() const noexcept; - - void beginSelectionSet(const service::SelectionSetParams& params) const final; - void endSelectionSet(const service::SelectionSetParams& params) const final; - - const std::unique_ptr _pimpl; - -public: - template - Query(std::shared_ptr pimpl) noexcept - : Query { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } - { - } -}; - -class PageInfo - : public service::Object -{ -private: - service::AwaitableResolver resolveHasNextPage(service::ResolverParams&& params) const; - service::AwaitableResolver resolveHasPreviousPage(service::ResolverParams&& params) const; - - service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; - - struct Concept - { - virtual ~Concept() = default; - - virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - - virtual service::FieldResult getHasNextPage(service::FieldParams&& params) const = 0; - virtual service::FieldResult getHasPreviousPage(service::FieldParams&& params) const = 0; - }; - - template - struct Model - : Concept - { - Model(std::shared_ptr&& pimpl) noexcept - : _pimpl { std::move(pimpl) } - { - } - - service::FieldResult getHasNextPage(service::FieldParams&& params) const final - { - if constexpr (methods::PageInfoHas::getHasNextPageWithParams) - { - return { _pimpl->getHasNextPage(std::move(params)) }; - } - else if constexpr (methods::PageInfoHas::getHasNextPage) - { - return { _pimpl->getHasNextPage() }; - } - else - { - throw std::runtime_error(R"ex(PageInfo::getHasNextPage is not implemented)ex"); - } - } - - service::FieldResult getHasPreviousPage(service::FieldParams&& params) const final - { - if constexpr (methods::PageInfoHas::getHasPreviousPageWithParams) - { - return { _pimpl->getHasPreviousPage(std::move(params)) }; - } - else if constexpr (methods::PageInfoHas::getHasPreviousPage) - { - return { _pimpl->getHasPreviousPage() }; - } - else - { - throw std::runtime_error(R"ex(PageInfo::getHasPreviousPage is not implemented)ex"); - } - } - - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (methods::PageInfoHas::beginSelectionSet) - { - _pimpl->beginSelectionSet(params); - } - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (methods::PageInfoHas::endSelectionSet) - { - _pimpl->endSelectionSet(params); - } - } - - private: - const std::shared_ptr _pimpl; - }; - - PageInfo(std::unique_ptr&& pimpl) noexcept; - - service::TypeNames getTypeNames() const noexcept; - service::ResolverMap getResolvers() const noexcept; - - void beginSelectionSet(const service::SelectionSetParams& params) const final; - void endSelectionSet(const service::SelectionSetParams& params) const final; - - const std::unique_ptr _pimpl; - -public: - template - PageInfo(std::shared_ptr pimpl) noexcept - : PageInfo { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } - { - } -}; - -class AppointmentEdge - : public service::Object -{ -private: - service::AwaitableResolver resolveNode(service::ResolverParams&& params) const; - service::AwaitableResolver resolveCursor(service::ResolverParams&& params) const; - - service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; - - struct Concept - { - virtual ~Concept() = default; - - virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - - virtual service::FieldResult> getNode(service::FieldParams&& params) const = 0; - virtual service::FieldResult getCursor(service::FieldParams&& params) const = 0; - }; - - template - struct Model - : Concept - { - Model(std::shared_ptr&& pimpl) noexcept - : _pimpl { std::move(pimpl) } - { - } - - service::FieldResult> getNode(service::FieldParams&& params) const final - { - if constexpr (methods::AppointmentEdgeHas::getNodeWithParams) - { - return { _pimpl->getNode(std::move(params)) }; - } - else if constexpr (methods::AppointmentEdgeHas::getNode) - { - return { _pimpl->getNode() }; - } - else - { - throw std::runtime_error(R"ex(AppointmentEdge::getNode is not implemented)ex"); - } - } - - service::FieldResult getCursor(service::FieldParams&& params) const final - { - if constexpr (methods::AppointmentEdgeHas::getCursorWithParams) - { - return { _pimpl->getCursor(std::move(params)) }; - } - else if constexpr (methods::AppointmentEdgeHas::getCursor) - { - return { _pimpl->getCursor() }; - } - else - { - throw std::runtime_error(R"ex(AppointmentEdge::getCursor is not implemented)ex"); - } - } - - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (methods::AppointmentEdgeHas::beginSelectionSet) - { - _pimpl->beginSelectionSet(params); - } - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (methods::AppointmentEdgeHas::endSelectionSet) - { - _pimpl->endSelectionSet(params); - } - } - - private: - const std::shared_ptr _pimpl; - }; - - AppointmentEdge(std::unique_ptr&& pimpl) noexcept; - - service::TypeNames getTypeNames() const noexcept; - service::ResolverMap getResolvers() const noexcept; - - void beginSelectionSet(const service::SelectionSetParams& params) const final; - void endSelectionSet(const service::SelectionSetParams& params) const final; - - const std::unique_ptr _pimpl; - -public: - template - AppointmentEdge(std::shared_ptr pimpl) noexcept - : AppointmentEdge { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } - { - } -}; - -class AppointmentConnection - : public service::Object -{ -private: - service::AwaitableResolver resolvePageInfo(service::ResolverParams&& params) const; - service::AwaitableResolver resolveEdges(service::ResolverParams&& params) const; - - service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; - - struct Concept - { - virtual ~Concept() = default; - - virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - - virtual service::FieldResult> getPageInfo(service::FieldParams&& params) const = 0; - virtual service::FieldResult>>> getEdges(service::FieldParams&& params) const = 0; - }; - - template - struct Model - : Concept - { - Model(std::shared_ptr&& pimpl) noexcept - : _pimpl { std::move(pimpl) } - { - } - - service::FieldResult> getPageInfo(service::FieldParams&& params) const final - { - if constexpr (methods::AppointmentConnectionHas::getPageInfoWithParams) - { - return { _pimpl->getPageInfo(std::move(params)) }; - } - else if constexpr (methods::AppointmentConnectionHas::getPageInfo) - { - return { _pimpl->getPageInfo() }; - } - else - { - throw std::runtime_error(R"ex(AppointmentConnection::getPageInfo is not implemented)ex"); - } - } - - service::FieldResult>>> getEdges(service::FieldParams&& params) const final - { - if constexpr (methods::AppointmentConnectionHas::getEdgesWithParams) - { - return { _pimpl->getEdges(std::move(params)) }; - } - else if constexpr (methods::AppointmentConnectionHas::getEdges) - { - return { _pimpl->getEdges() }; - } - else - { - throw std::runtime_error(R"ex(AppointmentConnection::getEdges is not implemented)ex"); - } - } - - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (methods::AppointmentConnectionHas::beginSelectionSet) - { - _pimpl->beginSelectionSet(params); - } - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (methods::AppointmentConnectionHas::endSelectionSet) - { - _pimpl->endSelectionSet(params); - } - } - - private: - const std::shared_ptr _pimpl; - }; - - AppointmentConnection(std::unique_ptr&& pimpl) noexcept; - - service::TypeNames getTypeNames() const noexcept; - service::ResolverMap getResolvers() const noexcept; - - void beginSelectionSet(const service::SelectionSetParams& params) const final; - void endSelectionSet(const service::SelectionSetParams& params) const final; - - const std::unique_ptr _pimpl; - -public: - template - AppointmentConnection(std::shared_ptr pimpl) noexcept - : AppointmentConnection { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } - { - } -}; - -class TaskEdge - : public service::Object -{ -private: - service::AwaitableResolver resolveNode(service::ResolverParams&& params) const; - service::AwaitableResolver resolveCursor(service::ResolverParams&& params) const; - - service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; - - struct Concept - { - virtual ~Concept() = default; - - virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - - virtual service::FieldResult> getNode(service::FieldParams&& params) const = 0; - virtual service::FieldResult getCursor(service::FieldParams&& params) const = 0; - }; - - template - struct Model - : Concept - { - Model(std::shared_ptr&& pimpl) noexcept - : _pimpl { std::move(pimpl) } - { - } - - service::FieldResult> getNode(service::FieldParams&& params) const final - { - if constexpr (methods::TaskEdgeHas::getNodeWithParams) - { - return { _pimpl->getNode(std::move(params)) }; - } - else if constexpr (methods::TaskEdgeHas::getNode) - { - return { _pimpl->getNode() }; - } - else - { - throw std::runtime_error(R"ex(TaskEdge::getNode is not implemented)ex"); - } - } - - service::FieldResult getCursor(service::FieldParams&& params) const final - { - if constexpr (methods::TaskEdgeHas::getCursorWithParams) - { - return { _pimpl->getCursor(std::move(params)) }; - } - else if constexpr (methods::TaskEdgeHas::getCursor) - { - return { _pimpl->getCursor() }; - } - else - { - throw std::runtime_error(R"ex(TaskEdge::getCursor is not implemented)ex"); - } - } - - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (methods::TaskEdgeHas::beginSelectionSet) - { - _pimpl->beginSelectionSet(params); - } - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (methods::TaskEdgeHas::endSelectionSet) - { - _pimpl->endSelectionSet(params); - } - } - - private: - const std::shared_ptr _pimpl; - }; - - TaskEdge(std::unique_ptr&& pimpl) noexcept; - - service::TypeNames getTypeNames() const noexcept; - service::ResolverMap getResolvers() const noexcept; - - void beginSelectionSet(const service::SelectionSetParams& params) const final; - void endSelectionSet(const service::SelectionSetParams& params) const final; - - const std::unique_ptr _pimpl; - -public: - template - TaskEdge(std::shared_ptr pimpl) noexcept - : TaskEdge { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } - { - } -}; - -class TaskConnection - : public service::Object -{ -private: - service::AwaitableResolver resolvePageInfo(service::ResolverParams&& params) const; - service::AwaitableResolver resolveEdges(service::ResolverParams&& params) const; - - service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; - - struct Concept - { - virtual ~Concept() = default; - - virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - - virtual service::FieldResult> getPageInfo(service::FieldParams&& params) const = 0; - virtual service::FieldResult>>> getEdges(service::FieldParams&& params) const = 0; - }; - - template - struct Model - : Concept - { - Model(std::shared_ptr&& pimpl) noexcept - : _pimpl { std::move(pimpl) } - { - } - - service::FieldResult> getPageInfo(service::FieldParams&& params) const final - { - if constexpr (methods::TaskConnectionHas::getPageInfoWithParams) - { - return { _pimpl->getPageInfo(std::move(params)) }; - } - else if constexpr (methods::TaskConnectionHas::getPageInfo) - { - return { _pimpl->getPageInfo() }; - } - else - { - throw std::runtime_error(R"ex(TaskConnection::getPageInfo is not implemented)ex"); - } - } - - service::FieldResult>>> getEdges(service::FieldParams&& params) const final - { - if constexpr (methods::TaskConnectionHas::getEdgesWithParams) - { - return { _pimpl->getEdges(std::move(params)) }; - } - else if constexpr (methods::TaskConnectionHas::getEdges) - { - return { _pimpl->getEdges() }; - } - else - { - throw std::runtime_error(R"ex(TaskConnection::getEdges is not implemented)ex"); - } - } - - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (methods::TaskConnectionHas::beginSelectionSet) - { - _pimpl->beginSelectionSet(params); - } - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (methods::TaskConnectionHas::endSelectionSet) - { - _pimpl->endSelectionSet(params); - } - } - - private: - const std::shared_ptr _pimpl; - }; - - TaskConnection(std::unique_ptr&& pimpl) noexcept; - - service::TypeNames getTypeNames() const noexcept; - service::ResolverMap getResolvers() const noexcept; - - void beginSelectionSet(const service::SelectionSetParams& params) const final; - void endSelectionSet(const service::SelectionSetParams& params) const final; - - const std::unique_ptr _pimpl; - -public: - template - TaskConnection(std::shared_ptr pimpl) noexcept - : TaskConnection { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } - { - } -}; - -class FolderEdge - : public service::Object -{ -private: - service::AwaitableResolver resolveNode(service::ResolverParams&& params) const; - service::AwaitableResolver resolveCursor(service::ResolverParams&& params) const; - - service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; - - struct Concept - { - virtual ~Concept() = default; - - virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - - virtual service::FieldResult> getNode(service::FieldParams&& params) const = 0; - virtual service::FieldResult getCursor(service::FieldParams&& params) const = 0; - }; - - template - struct Model - : Concept - { - Model(std::shared_ptr&& pimpl) noexcept - : _pimpl { std::move(pimpl) } - { - } - - service::FieldResult> getNode(service::FieldParams&& params) const final - { - if constexpr (methods::FolderEdgeHas::getNodeWithParams) - { - return { _pimpl->getNode(std::move(params)) }; - } - else if constexpr (methods::FolderEdgeHas::getNode) - { - return { _pimpl->getNode() }; - } - else - { - throw std::runtime_error(R"ex(FolderEdge::getNode is not implemented)ex"); - } - } - - service::FieldResult getCursor(service::FieldParams&& params) const final - { - if constexpr (methods::FolderEdgeHas::getCursorWithParams) - { - return { _pimpl->getCursor(std::move(params)) }; - } - else if constexpr (methods::FolderEdgeHas::getCursor) - { - return { _pimpl->getCursor() }; - } - else - { - throw std::runtime_error(R"ex(FolderEdge::getCursor is not implemented)ex"); - } - } - - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (methods::FolderEdgeHas::beginSelectionSet) - { - _pimpl->beginSelectionSet(params); - } - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (methods::FolderEdgeHas::endSelectionSet) - { - _pimpl->endSelectionSet(params); - } - } - - private: - const std::shared_ptr _pimpl; - }; - - FolderEdge(std::unique_ptr&& pimpl) noexcept; - - service::TypeNames getTypeNames() const noexcept; - service::ResolverMap getResolvers() const noexcept; - - void beginSelectionSet(const service::SelectionSetParams& params) const final; - void endSelectionSet(const service::SelectionSetParams& params) const final; - - const std::unique_ptr _pimpl; - -public: - template - FolderEdge(std::shared_ptr pimpl) noexcept - : FolderEdge { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } - { - } -}; - -class FolderConnection - : public service::Object -{ -private: - service::AwaitableResolver resolvePageInfo(service::ResolverParams&& params) const; - service::AwaitableResolver resolveEdges(service::ResolverParams&& params) const; - - service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; - - struct Concept - { - virtual ~Concept() = default; - - virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - - virtual service::FieldResult> getPageInfo(service::FieldParams&& params) const = 0; - virtual service::FieldResult>>> getEdges(service::FieldParams&& params) const = 0; - }; - - template - struct Model - : Concept - { - Model(std::shared_ptr&& pimpl) noexcept - : _pimpl { std::move(pimpl) } - { - } - - service::FieldResult> getPageInfo(service::FieldParams&& params) const final - { - if constexpr (methods::FolderConnectionHas::getPageInfoWithParams) - { - return { _pimpl->getPageInfo(std::move(params)) }; - } - else if constexpr (methods::FolderConnectionHas::getPageInfo) - { - return { _pimpl->getPageInfo() }; - } - else - { - throw std::runtime_error(R"ex(FolderConnection::getPageInfo is not implemented)ex"); - } - } - - service::FieldResult>>> getEdges(service::FieldParams&& params) const final - { - if constexpr (methods::FolderConnectionHas::getEdgesWithParams) - { - return { _pimpl->getEdges(std::move(params)) }; - } - else if constexpr (methods::FolderConnectionHas::getEdges) - { - return { _pimpl->getEdges() }; - } - else - { - throw std::runtime_error(R"ex(FolderConnection::getEdges is not implemented)ex"); - } - } - - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (methods::FolderConnectionHas::beginSelectionSet) - { - _pimpl->beginSelectionSet(params); - } - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (methods::FolderConnectionHas::endSelectionSet) - { - _pimpl->endSelectionSet(params); - } - } - - private: - const std::shared_ptr _pimpl; - }; - - FolderConnection(std::unique_ptr&& pimpl) noexcept; - - service::TypeNames getTypeNames() const noexcept; - service::ResolverMap getResolvers() const noexcept; - - void beginSelectionSet(const service::SelectionSetParams& params) const final; - void endSelectionSet(const service::SelectionSetParams& params) const final; - - const std::unique_ptr _pimpl; - -public: - template - FolderConnection(std::shared_ptr pimpl) noexcept - : FolderConnection { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } - { - } -}; - -class CompleteTaskPayload - : public service::Object -{ -private: - service::AwaitableResolver resolveTask(service::ResolverParams&& params) const; - service::AwaitableResolver resolveClientMutationId(service::ResolverParams&& params) const; - - service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; - - struct Concept - { - virtual ~Concept() = default; - - virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - - virtual service::FieldResult> getTask(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getClientMutationId(service::FieldParams&& params) const = 0; - }; - - template - struct Model - : Concept - { - Model(std::shared_ptr&& pimpl) noexcept - : _pimpl { std::move(pimpl) } - { - } - - service::FieldResult> getTask(service::FieldParams&& params) const final - { - if constexpr (methods::CompleteTaskPayloadHas::getTaskWithParams) - { - return { _pimpl->getTask(std::move(params)) }; - } - else if constexpr (methods::CompleteTaskPayloadHas::getTask) - { - return { _pimpl->getTask() }; - } - else - { - throw std::runtime_error(R"ex(CompleteTaskPayload::getTask is not implemented)ex"); - } - } - - service::FieldResult> getClientMutationId(service::FieldParams&& params) const final - { - if constexpr (methods::CompleteTaskPayloadHas::getClientMutationIdWithParams) - { - return { _pimpl->getClientMutationId(std::move(params)) }; - } - else if constexpr (methods::CompleteTaskPayloadHas::getClientMutationId) - { - return { _pimpl->getClientMutationId() }; - } - else - { - throw std::runtime_error(R"ex(CompleteTaskPayload::getClientMutationId is not implemented)ex"); - } - } - - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (methods::CompleteTaskPayloadHas::beginSelectionSet) - { - _pimpl->beginSelectionSet(params); - } - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (methods::CompleteTaskPayloadHas::endSelectionSet) - { - _pimpl->endSelectionSet(params); - } - } - - private: - const std::shared_ptr _pimpl; - }; - - CompleteTaskPayload(std::unique_ptr&& pimpl) noexcept; - - service::TypeNames getTypeNames() const noexcept; - service::ResolverMap getResolvers() const noexcept; - - void beginSelectionSet(const service::SelectionSetParams& params) const final; - void endSelectionSet(const service::SelectionSetParams& params) const final; - - const std::unique_ptr _pimpl; - -public: - template - CompleteTaskPayload(std::shared_ptr pimpl) noexcept - : CompleteTaskPayload { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } - { - } -}; - -class Mutation - : public service::Object -{ -private: - service::AwaitableResolver resolveCompleteTask(service::ResolverParams&& params) const; - service::AwaitableResolver resolveSetFloat(service::ResolverParams&& params) const; - - service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; - - struct Concept - { - virtual ~Concept() = default; - - virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - - virtual service::FieldResult> applyCompleteTask(service::FieldParams&& params, CompleteTaskInput&& inputArg) const = 0; - virtual service::FieldResult applySetFloat(service::FieldParams&& params, double&& valueArg) const = 0; - }; - - template - struct Model - : Concept - { - Model(std::shared_ptr&& pimpl) noexcept - : _pimpl { std::move(pimpl) } - { - } - - service::FieldResult> applyCompleteTask(service::FieldParams&& params, CompleteTaskInput&& inputArg) const final - { - if constexpr (methods::MutationHas::applyCompleteTaskWithParams) - { - return { _pimpl->applyCompleteTask(std::move(params), std::move(inputArg)) }; - } - else if constexpr (methods::MutationHas::applyCompleteTask) - { - return { _pimpl->applyCompleteTask(std::move(inputArg)) }; - } - else - { - throw std::runtime_error(R"ex(Mutation::applyCompleteTask is not implemented)ex"); - } - } - - service::FieldResult applySetFloat(service::FieldParams&& params, double&& valueArg) const final - { - if constexpr (methods::MutationHas::applySetFloatWithParams) - { - return { _pimpl->applySetFloat(std::move(params), std::move(valueArg)) }; - } - else if constexpr (methods::MutationHas::applySetFloat) - { - return { _pimpl->applySetFloat(std::move(valueArg)) }; - } - else - { - throw std::runtime_error(R"ex(Mutation::applySetFloat is not implemented)ex"); - } - } - - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (methods::MutationHas::beginSelectionSet) - { - _pimpl->beginSelectionSet(params); - } - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (methods::MutationHas::endSelectionSet) - { - _pimpl->endSelectionSet(params); - } - } - - private: - const std::shared_ptr _pimpl; - }; - - Mutation(std::unique_ptr&& pimpl) noexcept; - - service::TypeNames getTypeNames() const noexcept; - service::ResolverMap getResolvers() const noexcept; - - void beginSelectionSet(const service::SelectionSetParams& params) const final; - void endSelectionSet(const service::SelectionSetParams& params) const final; - - const std::unique_ptr _pimpl; - -public: - template - Mutation(std::shared_ptr pimpl) noexcept - : Mutation { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } - { - } -}; - -class Subscription - : public service::Object -{ -private: - service::AwaitableResolver resolveNextAppointmentChange(service::ResolverParams&& params) const; - service::AwaitableResolver resolveNodeChange(service::ResolverParams&& params) const; - - service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; - - struct Concept - { - virtual ~Concept() = default; - - virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - - virtual service::FieldResult> getNextAppointmentChange(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getNodeChange(service::FieldParams&& params, response::IdType&& idArg) const = 0; - }; - - template - struct Model - : Concept - { - Model(std::shared_ptr&& pimpl) noexcept - : _pimpl { std::move(pimpl) } - { - } - - service::FieldResult> getNextAppointmentChange(service::FieldParams&& params) const final - { - if constexpr (methods::SubscriptionHas::getNextAppointmentChangeWithParams) - { - return { _pimpl->getNextAppointmentChange(std::move(params)) }; - } - else if constexpr (methods::SubscriptionHas::getNextAppointmentChange) - { - return { _pimpl->getNextAppointmentChange() }; - } - else - { - throw std::runtime_error(R"ex(Subscription::getNextAppointmentChange is not implemented)ex"); - } - } - - service::FieldResult> getNodeChange(service::FieldParams&& params, response::IdType&& idArg) const final - { - if constexpr (methods::SubscriptionHas::getNodeChangeWithParams) - { - return { _pimpl->getNodeChange(std::move(params), std::move(idArg)) }; - } - else if constexpr (methods::SubscriptionHas::getNodeChange) - { - return { _pimpl->getNodeChange(std::move(idArg)) }; - } - else - { - throw std::runtime_error(R"ex(Subscription::getNodeChange is not implemented)ex"); - } - } - - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (methods::SubscriptionHas::beginSelectionSet) - { - _pimpl->beginSelectionSet(params); - } - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (methods::SubscriptionHas::endSelectionSet) - { - _pimpl->endSelectionSet(params); - } - } - - private: - const std::shared_ptr _pimpl; - }; - - Subscription(std::unique_ptr&& pimpl) noexcept; - - service::TypeNames getTypeNames() const noexcept; - service::ResolverMap getResolvers() const noexcept; - - void beginSelectionSet(const service::SelectionSetParams& params) const final; - void endSelectionSet(const service::SelectionSetParams& params) const final; - - const std::unique_ptr _pimpl; - -public: - template - Subscription(std::shared_ptr pimpl) noexcept - : Subscription { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } - { - } -}; - -class Appointment - : public service::Object -{ -private: - service::AwaitableResolver resolveId(service::ResolverParams&& params) const; - service::AwaitableResolver resolveWhen(service::ResolverParams&& params) const; - service::AwaitableResolver resolveSubject(service::ResolverParams&& params) const; - service::AwaitableResolver resolveIsNow(service::ResolverParams&& params) const; - service::AwaitableResolver resolveForceError(service::ResolverParams&& params) const; - - service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; - - struct Concept - { - virtual ~Concept() = default; - - virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - - virtual service::FieldResult getId(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getWhen(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getSubject(service::FieldParams&& params) const = 0; - virtual service::FieldResult getIsNow(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getForceError(service::FieldParams&& params) const = 0; - }; - - template - struct Model - : Concept - { - Model(std::shared_ptr&& pimpl) noexcept - : _pimpl { std::move(pimpl) } - { - } - - service::FieldResult getId(service::FieldParams&& params) const final - { - if constexpr (methods::AppointmentHas::getIdWithParams) - { - return { _pimpl->getId(std::move(params)) }; - } - else if constexpr (methods::AppointmentHas::getId) - { - return { _pimpl->getId() }; - } - else - { - throw std::runtime_error(R"ex(Appointment::getId is not implemented)ex"); - } - } - - service::FieldResult> getWhen(service::FieldParams&& params) const final - { - if constexpr (methods::AppointmentHas::getWhenWithParams) - { - return { _pimpl->getWhen(std::move(params)) }; - } - else if constexpr (methods::AppointmentHas::getWhen) - { - return { _pimpl->getWhen() }; - } - else - { - throw std::runtime_error(R"ex(Appointment::getWhen is not implemented)ex"); - } - } - - service::FieldResult> getSubject(service::FieldParams&& params) const final - { - if constexpr (methods::AppointmentHas::getSubjectWithParams) - { - return { _pimpl->getSubject(std::move(params)) }; - } - else if constexpr (methods::AppointmentHas::getSubject) - { - return { _pimpl->getSubject() }; - } - else - { - throw std::runtime_error(R"ex(Appointment::getSubject is not implemented)ex"); - } - } - - service::FieldResult getIsNow(service::FieldParams&& params) const final - { - if constexpr (methods::AppointmentHas::getIsNowWithParams) - { - return { _pimpl->getIsNow(std::move(params)) }; - } - else if constexpr (methods::AppointmentHas::getIsNow) - { - return { _pimpl->getIsNow() }; - } - else - { - throw std::runtime_error(R"ex(Appointment::getIsNow is not implemented)ex"); - } - } - - service::FieldResult> getForceError(service::FieldParams&& params) const final - { - if constexpr (methods::AppointmentHas::getForceErrorWithParams) - { - return { _pimpl->getForceError(std::move(params)) }; - } - else if constexpr (methods::AppointmentHas::getForceError) - { - return { _pimpl->getForceError() }; - } - else - { - throw std::runtime_error(R"ex(Appointment::getForceError is not implemented)ex"); - } - } - - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (methods::AppointmentHas::beginSelectionSet) - { - _pimpl->beginSelectionSet(params); - } - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (methods::AppointmentHas::endSelectionSet) - { - _pimpl->endSelectionSet(params); - } - } - - private: - const std::shared_ptr _pimpl; - }; - - Appointment(std::unique_ptr&& pimpl) noexcept; - - // Interfaces which this type implements - friend Node; - - // Unions which include this type - friend UnionType; - - template - static constexpr bool implements() noexcept - { - return implements::AppointmentIs; - } - - service::TypeNames getTypeNames() const noexcept; - service::ResolverMap getResolvers() const noexcept; - - void beginSelectionSet(const service::SelectionSetParams& params) const final; - void endSelectionSet(const service::SelectionSetParams& params) const final; - - const std::unique_ptr _pimpl; - -public: - template - Appointment(std::shared_ptr pimpl) noexcept - : Appointment { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } - { - } -}; - -class Task - : public service::Object -{ -private: - service::AwaitableResolver resolveId(service::ResolverParams&& params) const; - service::AwaitableResolver resolveTitle(service::ResolverParams&& params) const; - service::AwaitableResolver resolveIsComplete(service::ResolverParams&& params) const; - - service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; - - struct Concept - { - virtual ~Concept() = default; - - virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - - virtual service::FieldResult getId(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getTitle(service::FieldParams&& params) const = 0; - virtual service::FieldResult getIsComplete(service::FieldParams&& params) const = 0; - }; - - template - struct Model - : Concept - { - Model(std::shared_ptr&& pimpl) noexcept - : _pimpl { std::move(pimpl) } - { - } - - service::FieldResult getId(service::FieldParams&& params) const final - { - if constexpr (methods::TaskHas::getIdWithParams) - { - return { _pimpl->getId(std::move(params)) }; - } - else if constexpr (methods::TaskHas::getId) - { - return { _pimpl->getId() }; - } - else - { - throw std::runtime_error(R"ex(Task::getId is not implemented)ex"); - } - } - - service::FieldResult> getTitle(service::FieldParams&& params) const final - { - if constexpr (methods::TaskHas::getTitleWithParams) - { - return { _pimpl->getTitle(std::move(params)) }; - } - else if constexpr (methods::TaskHas::getTitle) - { - return { _pimpl->getTitle() }; - } - else - { - throw std::runtime_error(R"ex(Task::getTitle is not implemented)ex"); - } - } - - service::FieldResult getIsComplete(service::FieldParams&& params) const final - { - if constexpr (methods::TaskHas::getIsCompleteWithParams) - { - return { _pimpl->getIsComplete(std::move(params)) }; - } - else if constexpr (methods::TaskHas::getIsComplete) - { - return { _pimpl->getIsComplete() }; - } - else - { - throw std::runtime_error(R"ex(Task::getIsComplete is not implemented)ex"); - } - } - - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (methods::TaskHas::beginSelectionSet) - { - _pimpl->beginSelectionSet(params); - } - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (methods::TaskHas::endSelectionSet) - { - _pimpl->endSelectionSet(params); - } - } - - private: - const std::shared_ptr _pimpl; - }; - - Task(std::unique_ptr&& pimpl) noexcept; - - // Interfaces which this type implements - friend Node; - - // Unions which include this type - friend UnionType; - - template - static constexpr bool implements() noexcept - { - return implements::TaskIs; - } - - service::TypeNames getTypeNames() const noexcept; - service::ResolverMap getResolvers() const noexcept; - - void beginSelectionSet(const service::SelectionSetParams& params) const final; - void endSelectionSet(const service::SelectionSetParams& params) const final; - - const std::unique_ptr _pimpl; - -public: - template - Task(std::shared_ptr pimpl) noexcept - : Task { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } - { - } -}; - -class Folder - : public service::Object -{ -private: - service::AwaitableResolver resolveId(service::ResolverParams&& params) const; - service::AwaitableResolver resolveName(service::ResolverParams&& params) const; - service::AwaitableResolver resolveUnreadCount(service::ResolverParams&& params) const; - - service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; - - struct Concept - { - virtual ~Concept() = default; - - virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - - virtual service::FieldResult getId(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getName(service::FieldParams&& params) const = 0; - virtual service::FieldResult getUnreadCount(service::FieldParams&& params) const = 0; - }; - - template - struct Model - : Concept - { - Model(std::shared_ptr&& pimpl) noexcept - : _pimpl { std::move(pimpl) } - { - } - - service::FieldResult getId(service::FieldParams&& params) const final - { - if constexpr (methods::FolderHas::getIdWithParams) - { - return { _pimpl->getId(std::move(params)) }; - } - else if constexpr (methods::FolderHas::getId) - { - return { _pimpl->getId() }; - } - else - { - throw std::runtime_error(R"ex(Folder::getId is not implemented)ex"); - } - } - - service::FieldResult> getName(service::FieldParams&& params) const final - { - if constexpr (methods::FolderHas::getNameWithParams) - { - return { _pimpl->getName(std::move(params)) }; - } - else if constexpr (methods::FolderHas::getName) - { - return { _pimpl->getName() }; - } - else - { - throw std::runtime_error(R"ex(Folder::getName is not implemented)ex"); - } - } - - service::FieldResult getUnreadCount(service::FieldParams&& params) const final - { - if constexpr (methods::FolderHas::getUnreadCountWithParams) - { - return { _pimpl->getUnreadCount(std::move(params)) }; - } - else if constexpr (methods::FolderHas::getUnreadCount) - { - return { _pimpl->getUnreadCount() }; - } - else - { - throw std::runtime_error(R"ex(Folder::getUnreadCount is not implemented)ex"); - } - } - - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (methods::FolderHas::beginSelectionSet) - { - _pimpl->beginSelectionSet(params); - } - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (methods::FolderHas::endSelectionSet) - { - _pimpl->endSelectionSet(params); - } - } - - private: - const std::shared_ptr _pimpl; - }; - - Folder(std::unique_ptr&& pimpl) noexcept; - - // Interfaces which this type implements - friend Node; - - // Unions which include this type - friend UnionType; - - template - static constexpr bool implements() noexcept - { - return implements::FolderIs; - } - - service::TypeNames getTypeNames() const noexcept; - service::ResolverMap getResolvers() const noexcept; - - void beginSelectionSet(const service::SelectionSetParams& params) const final; - void endSelectionSet(const service::SelectionSetParams& params) const final; - - const std::unique_ptr _pimpl; - -public: - template - Folder(std::shared_ptr pimpl) noexcept - : Folder { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } - { - } -}; - -class NestedType - : public service::Object -{ -private: - service::AwaitableResolver resolveDepth(service::ResolverParams&& params) const; - service::AwaitableResolver resolveNested(service::ResolverParams&& params) const; - - service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; - - struct Concept - { - virtual ~Concept() = default; - - virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - - virtual service::FieldResult getDepth(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getNested(service::FieldParams&& params) const = 0; - }; - - template - struct Model - : Concept - { - Model(std::shared_ptr&& pimpl) noexcept - : _pimpl { std::move(pimpl) } - { - } - - service::FieldResult getDepth(service::FieldParams&& params) const final - { - if constexpr (methods::NestedTypeHas::getDepthWithParams) - { - return { _pimpl->getDepth(std::move(params)) }; - } - else if constexpr (methods::NestedTypeHas::getDepth) - { - return { _pimpl->getDepth() }; - } - else - { - throw std::runtime_error(R"ex(NestedType::getDepth is not implemented)ex"); - } - } - - service::FieldResult> getNested(service::FieldParams&& params) const final - { - if constexpr (methods::NestedTypeHas::getNestedWithParams) - { - return { _pimpl->getNested(std::move(params)) }; - } - else if constexpr (methods::NestedTypeHas::getNested) - { - return { _pimpl->getNested() }; - } - else - { - throw std::runtime_error(R"ex(NestedType::getNested is not implemented)ex"); - } - } - - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (methods::NestedTypeHas::beginSelectionSet) - { - _pimpl->beginSelectionSet(params); - } - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (methods::NestedTypeHas::endSelectionSet) - { - _pimpl->endSelectionSet(params); - } - } - - private: - const std::shared_ptr _pimpl; - }; - - NestedType(std::unique_ptr&& pimpl) noexcept; - - service::TypeNames getTypeNames() const noexcept; - service::ResolverMap getResolvers() const noexcept; - - void beginSelectionSet(const service::SelectionSetParams& params) const final; - void endSelectionSet(const service::SelectionSetParams& params) const final; - - const std::unique_ptr _pimpl; - -public: - template - NestedType(std::shared_ptr pimpl) noexcept - : NestedType { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } - { - } -}; - -class Expensive - : public service::Object -{ -private: - service::AwaitableResolver resolveOrder(service::ResolverParams&& params) const; - - service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; - - struct Concept - { - virtual ~Concept() = default; - - virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - - virtual service::FieldResult getOrder(service::FieldParams&& params) const = 0; - }; - - template - struct Model - : Concept - { - Model(std::shared_ptr&& pimpl) noexcept - : _pimpl { std::move(pimpl) } - { - } - - service::FieldResult getOrder(service::FieldParams&& params) const final - { - if constexpr (methods::ExpensiveHas::getOrderWithParams) - { - return { _pimpl->getOrder(std::move(params)) }; - } - else if constexpr (methods::ExpensiveHas::getOrder) - { - return { _pimpl->getOrder() }; - } - else - { - throw std::runtime_error(R"ex(Expensive::getOrder is not implemented)ex"); - } - } - - void beginSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (methods::ExpensiveHas::beginSelectionSet) - { - _pimpl->beginSelectionSet(params); - } - } - - void endSelectionSet(const service::SelectionSetParams& params) const final - { - if constexpr (methods::ExpensiveHas::endSelectionSet) - { - _pimpl->endSelectionSet(params); - } - } - - private: - const std::shared_ptr _pimpl; - }; - - Expensive(std::unique_ptr&& pimpl) noexcept; - - service::TypeNames getTypeNames() const noexcept; - service::ResolverMap getResolvers() const noexcept; - - void beginSelectionSet(const service::SelectionSetParams& params) const final; - void endSelectionSet(const service::SelectionSetParams& params) const final; - - const std::unique_ptr _pimpl; - -public: - template - Expensive(std::shared_ptr pimpl) noexcept - : Expensive { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } - { - } -}; - -} // namespace object - -class Operations - : public service::Request -{ -public: - explicit Operations(std::shared_ptr query, std::shared_ptr mutation, std::shared_ptr subscription); - - template - explicit Operations(std::shared_ptr query, std::shared_ptr mutation, std::shared_ptr subscription) - : Operations { std::make_shared(std::move(query)), std::make_shared(std::move(mutation)), std::make_shared(std::move(subscription)) } - { - } - -private: - std::shared_ptr _query; - std::shared_ptr _mutation; - std::shared_ptr _subscription; -}; - -std::shared_ptr GetSchema(); - -} // namespace today -} // namespace graphql - -#endif // TODAYSCHEMA_H diff --git a/samples/today/unified_nointrospection/unified_nointrospection_schema_files b/samples/today/unified_nointrospection/unified_nointrospection_schema_files deleted file mode 100644 index 1647a93d..00000000 --- a/samples/today/unified_nointrospection/unified_nointrospection_schema_files +++ /dev/null @@ -1 +0,0 @@ -TodaySchema.cpp diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 8d0df3f2..0b6bf1a2 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -16,7 +16,7 @@ gtest_add_tests(TARGET validation_tests) add_executable(today_tests TodayTests.cpp) target_link_libraries(today_tests PRIVATE - unifiedgraphql + separategraphql graphqljson GTest::GTest GTest::Main) @@ -25,7 +25,7 @@ gtest_add_tests(TARGET today_tests) add_executable(client_tests ClientTests.cpp) target_link_libraries(client_tests PRIVATE - unifiedgraphql + separategraphql query_client mutate_client subscribe_client @@ -36,7 +36,7 @@ gtest_add_tests(TARGET client_tests) add_executable(nointrospection_tests NoIntrospectionTests.cpp) target_link_libraries(nointrospection_tests PRIVATE - unifiedgraphql_nointrospection + separategraphql_nointrospection graphqljson GTest::GTest GTest::Main) @@ -45,7 +45,7 @@ gtest_add_tests(TARGET nointrospection_tests) add_executable(argument_tests ArgumentTests.cpp) target_link_libraries(argument_tests PRIVATE - unifiedgraphql + separategraphql graphqljson GTest::GTest GTest::Main) From 9a7bf58c3414788d4df1b6b1380e92b4a56b0167 Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Wed, 8 Dec 2021 19:05:05 -0800 Subject: [PATCH 070/119] Rename separate... schemas to today... --- samples/client/CMakeLists.txt | 2 +- samples/today/CMakeLists.txt | 28 +++++++++---------- .../AppointmentConnectionObject.cpp | 0 .../AppointmentConnectionObject.h | 0 .../AppointmentEdgeObject.cpp | 0 .../AppointmentEdgeObject.h | 0 .../AppointmentObject.cpp | 0 .../AppointmentObject.h | 0 .../CMakeLists.txt | 4 +-- .../CompleteTaskPayloadObject.cpp | 0 .../CompleteTaskPayloadObject.h | 0 .../ExpensiveObject.cpp | 0 .../ExpensiveObject.h | 0 .../FolderConnectionObject.cpp | 0 .../FolderConnectionObject.h | 0 .../FolderEdgeObject.cpp | 0 .../FolderEdgeObject.h | 0 .../FolderObject.cpp | 0 .../FolderObject.h | 0 .../MutationObject.cpp | 0 .../MutationObject.h | 0 .../NestedTypeObject.cpp | 0 .../NestedTypeObject.h | 0 .../NodeObject.cpp | 0 .../NodeObject.h | 0 .../PageInfoObject.cpp | 0 .../PageInfoObject.h | 0 .../QueryObject.cpp | 0 .../QueryObject.h | 0 .../SubscriptionObject.cpp | 0 .../SubscriptionObject.h | 0 .../TaskConnectionObject.cpp | 0 .../TaskConnectionObject.h | 0 .../TaskEdgeObject.cpp | 0 .../TaskEdgeObject.h | 0 .../TaskObject.cpp | 0 .../TaskObject.h | 0 .../TodayObjects.h | 0 .../TodaySchema.cpp | 0 .../TodaySchema.h | 0 .../UnionTypeObject.cpp | 0 .../UnionTypeObject.h | 0 .../today_nointrospection_schema_files} | 0 .../AppointmentConnectionObject.cpp | 0 .../AppointmentConnectionObject.h | 0 .../AppointmentEdgeObject.cpp | 0 .../AppointmentEdgeObject.h | 0 .../AppointmentObject.cpp | 0 .../AppointmentObject.h | 0 .../today/{separate => schema}/CMakeLists.txt | 4 +-- .../CompleteTaskPayloadObject.cpp | 0 .../CompleteTaskPayloadObject.h | 0 .../ExpensiveObject.cpp | 0 .../ExpensiveObject.h | 0 .../FolderConnectionObject.cpp | 0 .../FolderConnectionObject.h | 0 .../FolderEdgeObject.cpp | 0 .../FolderEdgeObject.h | 0 .../FolderObject.cpp | 0 .../FolderObject.h | 0 .../MutationObject.cpp | 0 .../MutationObject.h | 0 .../{separate => schema}/NestedTypeObject.cpp | 0 .../NestedTypeObject.h | 0 .../NodeObject.cpp | 0 .../NodeObject.h | 0 .../PageInfoObject.cpp | 0 .../PageInfoObject.h | 0 .../{separate => schema}/QueryObject.cpp | 0 .../today/{separate => schema}/QueryObject.h | 0 .../SubscriptionObject.cpp | 0 .../SubscriptionObject.h | 0 .../TaskConnectionObject.cpp | 0 .../TaskConnectionObject.h | 0 .../TaskEdgeObject.cpp | 0 .../TaskEdgeObject.h | 0 .../TaskObject.cpp | 0 .../TaskObject.h | 0 .../TodayObjects.h | 0 .../{separate => schema}/TodaySchema.cpp | 0 .../TodaySchema.h | 0 .../UnionTypeObject.cpp | 0 .../UnionTypeObject.h | 0 .../today_schema_files} | 0 test/CMakeLists.txt | 8 +++--- 85 files changed, 23 insertions(+), 23 deletions(-) rename samples/today/{separate => nointrospection}/AppointmentConnectionObject.cpp (100%) rename samples/today/{separate => nointrospection}/AppointmentConnectionObject.h (100%) rename samples/today/{separate => nointrospection}/AppointmentEdgeObject.cpp (100%) rename samples/today/{separate => nointrospection}/AppointmentEdgeObject.h (100%) rename samples/today/{separate => nointrospection}/AppointmentObject.cpp (100%) rename samples/today/{separate => nointrospection}/AppointmentObject.h (100%) rename samples/today/{separate_nointrospection => nointrospection}/CMakeLists.txt (63%) rename samples/today/{separate => nointrospection}/CompleteTaskPayloadObject.cpp (100%) rename samples/today/{separate => nointrospection}/CompleteTaskPayloadObject.h (100%) rename samples/today/{separate => nointrospection}/ExpensiveObject.cpp (100%) rename samples/today/{separate => nointrospection}/ExpensiveObject.h (100%) rename samples/today/{separate => nointrospection}/FolderConnectionObject.cpp (100%) rename samples/today/{separate => nointrospection}/FolderConnectionObject.h (100%) rename samples/today/{separate => nointrospection}/FolderEdgeObject.cpp (100%) rename samples/today/{separate => nointrospection}/FolderEdgeObject.h (100%) rename samples/today/{separate => nointrospection}/FolderObject.cpp (100%) rename samples/today/{separate => nointrospection}/FolderObject.h (100%) rename samples/today/{separate => nointrospection}/MutationObject.cpp (100%) rename samples/today/{separate => nointrospection}/MutationObject.h (100%) rename samples/today/{separate_nointrospection => nointrospection}/NestedTypeObject.cpp (100%) rename samples/today/{separate => nointrospection}/NestedTypeObject.h (100%) rename samples/today/{separate => nointrospection}/NodeObject.cpp (100%) rename samples/today/{separate => nointrospection}/NodeObject.h (100%) rename samples/today/{separate => nointrospection}/PageInfoObject.cpp (100%) rename samples/today/{separate => nointrospection}/PageInfoObject.h (100%) rename samples/today/{separate_nointrospection => nointrospection}/QueryObject.cpp (100%) rename samples/today/{separate_nointrospection => nointrospection}/QueryObject.h (100%) rename samples/today/{separate => nointrospection}/SubscriptionObject.cpp (100%) rename samples/today/{separate => nointrospection}/SubscriptionObject.h (100%) rename samples/today/{separate => nointrospection}/TaskConnectionObject.cpp (100%) rename samples/today/{separate => nointrospection}/TaskConnectionObject.h (100%) rename samples/today/{separate => nointrospection}/TaskEdgeObject.cpp (100%) rename samples/today/{separate => nointrospection}/TaskEdgeObject.h (100%) rename samples/today/{separate => nointrospection}/TaskObject.cpp (100%) rename samples/today/{separate => nointrospection}/TaskObject.h (100%) rename samples/today/{separate => nointrospection}/TodayObjects.h (100%) rename samples/today/{separate_nointrospection => nointrospection}/TodaySchema.cpp (100%) rename samples/today/{separate => nointrospection}/TodaySchema.h (100%) rename samples/today/{separate => nointrospection}/UnionTypeObject.cpp (100%) rename samples/today/{separate => nointrospection}/UnionTypeObject.h (100%) rename samples/today/{separate/separate_schema_files => nointrospection/today_nointrospection_schema_files} (100%) rename samples/today/{separate_nointrospection => schema}/AppointmentConnectionObject.cpp (100%) rename samples/today/{separate_nointrospection => schema}/AppointmentConnectionObject.h (100%) rename samples/today/{separate_nointrospection => schema}/AppointmentEdgeObject.cpp (100%) rename samples/today/{separate_nointrospection => schema}/AppointmentEdgeObject.h (100%) rename samples/today/{separate_nointrospection => schema}/AppointmentObject.cpp (100%) rename samples/today/{separate_nointrospection => schema}/AppointmentObject.h (100%) rename samples/today/{separate => schema}/CMakeLists.txt (72%) rename samples/today/{separate_nointrospection => schema}/CompleteTaskPayloadObject.cpp (100%) rename samples/today/{separate_nointrospection => schema}/CompleteTaskPayloadObject.h (100%) rename samples/today/{separate_nointrospection => schema}/ExpensiveObject.cpp (100%) rename samples/today/{separate_nointrospection => schema}/ExpensiveObject.h (100%) rename samples/today/{separate_nointrospection => schema}/FolderConnectionObject.cpp (100%) rename samples/today/{separate_nointrospection => schema}/FolderConnectionObject.h (100%) rename samples/today/{separate_nointrospection => schema}/FolderEdgeObject.cpp (100%) rename samples/today/{separate_nointrospection => schema}/FolderEdgeObject.h (100%) rename samples/today/{separate_nointrospection => schema}/FolderObject.cpp (100%) rename samples/today/{separate_nointrospection => schema}/FolderObject.h (100%) rename samples/today/{separate_nointrospection => schema}/MutationObject.cpp (100%) rename samples/today/{separate_nointrospection => schema}/MutationObject.h (100%) rename samples/today/{separate => schema}/NestedTypeObject.cpp (100%) rename samples/today/{separate_nointrospection => schema}/NestedTypeObject.h (100%) rename samples/today/{separate_nointrospection => schema}/NodeObject.cpp (100%) rename samples/today/{separate_nointrospection => schema}/NodeObject.h (100%) rename samples/today/{separate_nointrospection => schema}/PageInfoObject.cpp (100%) rename samples/today/{separate_nointrospection => schema}/PageInfoObject.h (100%) rename samples/today/{separate => schema}/QueryObject.cpp (100%) rename samples/today/{separate => schema}/QueryObject.h (100%) rename samples/today/{separate_nointrospection => schema}/SubscriptionObject.cpp (100%) rename samples/today/{separate_nointrospection => schema}/SubscriptionObject.h (100%) rename samples/today/{separate_nointrospection => schema}/TaskConnectionObject.cpp (100%) rename samples/today/{separate_nointrospection => schema}/TaskConnectionObject.h (100%) rename samples/today/{separate_nointrospection => schema}/TaskEdgeObject.cpp (100%) rename samples/today/{separate_nointrospection => schema}/TaskEdgeObject.h (100%) rename samples/today/{separate_nointrospection => schema}/TaskObject.cpp (100%) rename samples/today/{separate_nointrospection => schema}/TaskObject.h (100%) rename samples/today/{separate_nointrospection => schema}/TodayObjects.h (100%) rename samples/today/{separate => schema}/TodaySchema.cpp (100%) rename samples/today/{separate_nointrospection => schema}/TodaySchema.h (100%) rename samples/today/{separate_nointrospection => schema}/UnionTypeObject.cpp (100%) rename samples/today/{separate_nointrospection => schema}/UnionTypeObject.h (100%) rename samples/today/{separate_nointrospection/separate_nointrospection_schema_files => schema/today_schema_files} (100%) diff --git a/samples/client/CMakeLists.txt b/samples/client/CMakeLists.txt index bcee7f94..b220bdc8 100644 --- a/samples/client/CMakeLists.txt +++ b/samples/client/CMakeLists.txt @@ -12,7 +12,7 @@ add_subdirectory(benchmark) # client_benchmark add_executable(client_benchmark benchmark.cpp) target_link_libraries(client_benchmark PRIVATE - separategraphql + todaygraphql benchmark_client) if(WIN32 AND BUILD_SHARED_LIBS) diff --git a/samples/today/CMakeLists.txt b/samples/today/CMakeLists.txt index 5e392e28..d4afd83f 100644 --- a/samples/today/CMakeLists.txt +++ b/samples/today/CMakeLists.txt @@ -3,40 +3,40 @@ cmake_minimum_required(VERSION 3.15) -# separategraphql -add_subdirectory(separate) -add_library(separategraphql STATIC TodayMock.cpp) -target_link_libraries(separategraphql PUBLIC separate_schema) -target_include_directories(separategraphql PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) +# todaygraphql +add_subdirectory(schema) +add_library(todaygraphql STATIC TodayMock.cpp) +target_link_libraries(todaygraphql PUBLIC today_schema) +target_include_directories(todaygraphql PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) -# separategraphql_nointrospection -add_subdirectory(separate_nointrospection) -add_library(separategraphql_nointrospection STATIC TodayMock.cpp) -target_link_libraries(separategraphql_nointrospection PUBLIC separate_nointrospection_schema) -target_include_directories(separategraphql_nointrospection PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) +# todaygraphql_nointrospection +add_subdirectory(nointrospection) +add_library(todaygraphql_nointrospection STATIC TodayMock.cpp) +target_link_libraries(todaygraphql_nointrospection PUBLIC today_nointrospection_schema) +target_include_directories(todaygraphql_nointrospection PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) # sample add_executable(sample sample.cpp) target_link_libraries(sample PRIVATE - separategraphql + todaygraphql graphqljson) # sample_nointrospection add_executable(sample_nointrospection sample.cpp) target_link_libraries(sample_nointrospection PRIVATE - separategraphql_nointrospection + todaygraphql_nointrospection graphqljson) # benchmark add_executable(benchmark benchmark.cpp) target_link_libraries(benchmark PRIVATE - separategraphql + todaygraphql graphqljson) # benchmark_nointrospection add_executable(benchmark_nointrospection benchmark.cpp) target_link_libraries(benchmark_nointrospection PRIVATE - separategraphql_nointrospection + todaygraphql_nointrospection graphqljson) if(WIN32 AND BUILD_SHARED_LIBS) diff --git a/samples/today/separate/AppointmentConnectionObject.cpp b/samples/today/nointrospection/AppointmentConnectionObject.cpp similarity index 100% rename from samples/today/separate/AppointmentConnectionObject.cpp rename to samples/today/nointrospection/AppointmentConnectionObject.cpp diff --git a/samples/today/separate/AppointmentConnectionObject.h b/samples/today/nointrospection/AppointmentConnectionObject.h similarity index 100% rename from samples/today/separate/AppointmentConnectionObject.h rename to samples/today/nointrospection/AppointmentConnectionObject.h diff --git a/samples/today/separate/AppointmentEdgeObject.cpp b/samples/today/nointrospection/AppointmentEdgeObject.cpp similarity index 100% rename from samples/today/separate/AppointmentEdgeObject.cpp rename to samples/today/nointrospection/AppointmentEdgeObject.cpp diff --git a/samples/today/separate/AppointmentEdgeObject.h b/samples/today/nointrospection/AppointmentEdgeObject.h similarity index 100% rename from samples/today/separate/AppointmentEdgeObject.h rename to samples/today/nointrospection/AppointmentEdgeObject.h diff --git a/samples/today/separate/AppointmentObject.cpp b/samples/today/nointrospection/AppointmentObject.cpp similarity index 100% rename from samples/today/separate/AppointmentObject.cpp rename to samples/today/nointrospection/AppointmentObject.cpp diff --git a/samples/today/separate/AppointmentObject.h b/samples/today/nointrospection/AppointmentObject.h similarity index 100% rename from samples/today/separate/AppointmentObject.h rename to samples/today/nointrospection/AppointmentObject.h diff --git a/samples/today/separate_nointrospection/CMakeLists.txt b/samples/today/nointrospection/CMakeLists.txt similarity index 63% rename from samples/today/separate_nointrospection/CMakeLists.txt rename to samples/today/nointrospection/CMakeLists.txt index 124fc7ed..723d5368 100644 --- a/samples/today/separate_nointrospection/CMakeLists.txt +++ b/samples/today/nointrospection/CMakeLists.txt @@ -7,7 +7,7 @@ cmake_minimum_required(VERSION 3.15) include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/cppgraphqlgen-functions.cmake) if(GRAPHQL_UPDATE_SAMPLES) - update_graphql_schema_files(separate_nointrospection ../schema.today.graphql Today today --stubs --no-introspection) + update_graphql_schema_files(today_nointrospection ../schema.today.graphql Today today --stubs --no-introspection) endif() -add_graphql_schema_no_introspection_target(separate_nointrospection) +add_graphql_schema_no_introspection_target(today_nointrospection) diff --git a/samples/today/separate/CompleteTaskPayloadObject.cpp b/samples/today/nointrospection/CompleteTaskPayloadObject.cpp similarity index 100% rename from samples/today/separate/CompleteTaskPayloadObject.cpp rename to samples/today/nointrospection/CompleteTaskPayloadObject.cpp diff --git a/samples/today/separate/CompleteTaskPayloadObject.h b/samples/today/nointrospection/CompleteTaskPayloadObject.h similarity index 100% rename from samples/today/separate/CompleteTaskPayloadObject.h rename to samples/today/nointrospection/CompleteTaskPayloadObject.h diff --git a/samples/today/separate/ExpensiveObject.cpp b/samples/today/nointrospection/ExpensiveObject.cpp similarity index 100% rename from samples/today/separate/ExpensiveObject.cpp rename to samples/today/nointrospection/ExpensiveObject.cpp diff --git a/samples/today/separate/ExpensiveObject.h b/samples/today/nointrospection/ExpensiveObject.h similarity index 100% rename from samples/today/separate/ExpensiveObject.h rename to samples/today/nointrospection/ExpensiveObject.h diff --git a/samples/today/separate/FolderConnectionObject.cpp b/samples/today/nointrospection/FolderConnectionObject.cpp similarity index 100% rename from samples/today/separate/FolderConnectionObject.cpp rename to samples/today/nointrospection/FolderConnectionObject.cpp diff --git a/samples/today/separate/FolderConnectionObject.h b/samples/today/nointrospection/FolderConnectionObject.h similarity index 100% rename from samples/today/separate/FolderConnectionObject.h rename to samples/today/nointrospection/FolderConnectionObject.h diff --git a/samples/today/separate/FolderEdgeObject.cpp b/samples/today/nointrospection/FolderEdgeObject.cpp similarity index 100% rename from samples/today/separate/FolderEdgeObject.cpp rename to samples/today/nointrospection/FolderEdgeObject.cpp diff --git a/samples/today/separate/FolderEdgeObject.h b/samples/today/nointrospection/FolderEdgeObject.h similarity index 100% rename from samples/today/separate/FolderEdgeObject.h rename to samples/today/nointrospection/FolderEdgeObject.h diff --git a/samples/today/separate/FolderObject.cpp b/samples/today/nointrospection/FolderObject.cpp similarity index 100% rename from samples/today/separate/FolderObject.cpp rename to samples/today/nointrospection/FolderObject.cpp diff --git a/samples/today/separate/FolderObject.h b/samples/today/nointrospection/FolderObject.h similarity index 100% rename from samples/today/separate/FolderObject.h rename to samples/today/nointrospection/FolderObject.h diff --git a/samples/today/separate/MutationObject.cpp b/samples/today/nointrospection/MutationObject.cpp similarity index 100% rename from samples/today/separate/MutationObject.cpp rename to samples/today/nointrospection/MutationObject.cpp diff --git a/samples/today/separate/MutationObject.h b/samples/today/nointrospection/MutationObject.h similarity index 100% rename from samples/today/separate/MutationObject.h rename to samples/today/nointrospection/MutationObject.h diff --git a/samples/today/separate_nointrospection/NestedTypeObject.cpp b/samples/today/nointrospection/NestedTypeObject.cpp similarity index 100% rename from samples/today/separate_nointrospection/NestedTypeObject.cpp rename to samples/today/nointrospection/NestedTypeObject.cpp diff --git a/samples/today/separate/NestedTypeObject.h b/samples/today/nointrospection/NestedTypeObject.h similarity index 100% rename from samples/today/separate/NestedTypeObject.h rename to samples/today/nointrospection/NestedTypeObject.h diff --git a/samples/today/separate/NodeObject.cpp b/samples/today/nointrospection/NodeObject.cpp similarity index 100% rename from samples/today/separate/NodeObject.cpp rename to samples/today/nointrospection/NodeObject.cpp diff --git a/samples/today/separate/NodeObject.h b/samples/today/nointrospection/NodeObject.h similarity index 100% rename from samples/today/separate/NodeObject.h rename to samples/today/nointrospection/NodeObject.h diff --git a/samples/today/separate/PageInfoObject.cpp b/samples/today/nointrospection/PageInfoObject.cpp similarity index 100% rename from samples/today/separate/PageInfoObject.cpp rename to samples/today/nointrospection/PageInfoObject.cpp diff --git a/samples/today/separate/PageInfoObject.h b/samples/today/nointrospection/PageInfoObject.h similarity index 100% rename from samples/today/separate/PageInfoObject.h rename to samples/today/nointrospection/PageInfoObject.h diff --git a/samples/today/separate_nointrospection/QueryObject.cpp b/samples/today/nointrospection/QueryObject.cpp similarity index 100% rename from samples/today/separate_nointrospection/QueryObject.cpp rename to samples/today/nointrospection/QueryObject.cpp diff --git a/samples/today/separate_nointrospection/QueryObject.h b/samples/today/nointrospection/QueryObject.h similarity index 100% rename from samples/today/separate_nointrospection/QueryObject.h rename to samples/today/nointrospection/QueryObject.h diff --git a/samples/today/separate/SubscriptionObject.cpp b/samples/today/nointrospection/SubscriptionObject.cpp similarity index 100% rename from samples/today/separate/SubscriptionObject.cpp rename to samples/today/nointrospection/SubscriptionObject.cpp diff --git a/samples/today/separate/SubscriptionObject.h b/samples/today/nointrospection/SubscriptionObject.h similarity index 100% rename from samples/today/separate/SubscriptionObject.h rename to samples/today/nointrospection/SubscriptionObject.h diff --git a/samples/today/separate/TaskConnectionObject.cpp b/samples/today/nointrospection/TaskConnectionObject.cpp similarity index 100% rename from samples/today/separate/TaskConnectionObject.cpp rename to samples/today/nointrospection/TaskConnectionObject.cpp diff --git a/samples/today/separate/TaskConnectionObject.h b/samples/today/nointrospection/TaskConnectionObject.h similarity index 100% rename from samples/today/separate/TaskConnectionObject.h rename to samples/today/nointrospection/TaskConnectionObject.h diff --git a/samples/today/separate/TaskEdgeObject.cpp b/samples/today/nointrospection/TaskEdgeObject.cpp similarity index 100% rename from samples/today/separate/TaskEdgeObject.cpp rename to samples/today/nointrospection/TaskEdgeObject.cpp diff --git a/samples/today/separate/TaskEdgeObject.h b/samples/today/nointrospection/TaskEdgeObject.h similarity index 100% rename from samples/today/separate/TaskEdgeObject.h rename to samples/today/nointrospection/TaskEdgeObject.h diff --git a/samples/today/separate/TaskObject.cpp b/samples/today/nointrospection/TaskObject.cpp similarity index 100% rename from samples/today/separate/TaskObject.cpp rename to samples/today/nointrospection/TaskObject.cpp diff --git a/samples/today/separate/TaskObject.h b/samples/today/nointrospection/TaskObject.h similarity index 100% rename from samples/today/separate/TaskObject.h rename to samples/today/nointrospection/TaskObject.h diff --git a/samples/today/separate/TodayObjects.h b/samples/today/nointrospection/TodayObjects.h similarity index 100% rename from samples/today/separate/TodayObjects.h rename to samples/today/nointrospection/TodayObjects.h diff --git a/samples/today/separate_nointrospection/TodaySchema.cpp b/samples/today/nointrospection/TodaySchema.cpp similarity index 100% rename from samples/today/separate_nointrospection/TodaySchema.cpp rename to samples/today/nointrospection/TodaySchema.cpp diff --git a/samples/today/separate/TodaySchema.h b/samples/today/nointrospection/TodaySchema.h similarity index 100% rename from samples/today/separate/TodaySchema.h rename to samples/today/nointrospection/TodaySchema.h diff --git a/samples/today/separate/UnionTypeObject.cpp b/samples/today/nointrospection/UnionTypeObject.cpp similarity index 100% rename from samples/today/separate/UnionTypeObject.cpp rename to samples/today/nointrospection/UnionTypeObject.cpp diff --git a/samples/today/separate/UnionTypeObject.h b/samples/today/nointrospection/UnionTypeObject.h similarity index 100% rename from samples/today/separate/UnionTypeObject.h rename to samples/today/nointrospection/UnionTypeObject.h diff --git a/samples/today/separate/separate_schema_files b/samples/today/nointrospection/today_nointrospection_schema_files similarity index 100% rename from samples/today/separate/separate_schema_files rename to samples/today/nointrospection/today_nointrospection_schema_files diff --git a/samples/today/separate_nointrospection/AppointmentConnectionObject.cpp b/samples/today/schema/AppointmentConnectionObject.cpp similarity index 100% rename from samples/today/separate_nointrospection/AppointmentConnectionObject.cpp rename to samples/today/schema/AppointmentConnectionObject.cpp diff --git a/samples/today/separate_nointrospection/AppointmentConnectionObject.h b/samples/today/schema/AppointmentConnectionObject.h similarity index 100% rename from samples/today/separate_nointrospection/AppointmentConnectionObject.h rename to samples/today/schema/AppointmentConnectionObject.h diff --git a/samples/today/separate_nointrospection/AppointmentEdgeObject.cpp b/samples/today/schema/AppointmentEdgeObject.cpp similarity index 100% rename from samples/today/separate_nointrospection/AppointmentEdgeObject.cpp rename to samples/today/schema/AppointmentEdgeObject.cpp diff --git a/samples/today/separate_nointrospection/AppointmentEdgeObject.h b/samples/today/schema/AppointmentEdgeObject.h similarity index 100% rename from samples/today/separate_nointrospection/AppointmentEdgeObject.h rename to samples/today/schema/AppointmentEdgeObject.h diff --git a/samples/today/separate_nointrospection/AppointmentObject.cpp b/samples/today/schema/AppointmentObject.cpp similarity index 100% rename from samples/today/separate_nointrospection/AppointmentObject.cpp rename to samples/today/schema/AppointmentObject.cpp diff --git a/samples/today/separate_nointrospection/AppointmentObject.h b/samples/today/schema/AppointmentObject.h similarity index 100% rename from samples/today/separate_nointrospection/AppointmentObject.h rename to samples/today/schema/AppointmentObject.h diff --git a/samples/today/separate/CMakeLists.txt b/samples/today/schema/CMakeLists.txt similarity index 72% rename from samples/today/separate/CMakeLists.txt rename to samples/today/schema/CMakeLists.txt index 37bb752e..0c6403ec 100644 --- a/samples/today/separate/CMakeLists.txt +++ b/samples/today/schema/CMakeLists.txt @@ -7,7 +7,7 @@ cmake_minimum_required(VERSION 3.15) include(${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake/cppgraphqlgen-functions.cmake) if(GRAPHQL_UPDATE_SAMPLES) - update_graphql_schema_files(separate ../schema.today.graphql Today today --stubs) + update_graphql_schema_files(today ../schema.today.graphql Today today --stubs) endif() -add_graphql_schema_target(separate) +add_graphql_schema_target(today) diff --git a/samples/today/separate_nointrospection/CompleteTaskPayloadObject.cpp b/samples/today/schema/CompleteTaskPayloadObject.cpp similarity index 100% rename from samples/today/separate_nointrospection/CompleteTaskPayloadObject.cpp rename to samples/today/schema/CompleteTaskPayloadObject.cpp diff --git a/samples/today/separate_nointrospection/CompleteTaskPayloadObject.h b/samples/today/schema/CompleteTaskPayloadObject.h similarity index 100% rename from samples/today/separate_nointrospection/CompleteTaskPayloadObject.h rename to samples/today/schema/CompleteTaskPayloadObject.h diff --git a/samples/today/separate_nointrospection/ExpensiveObject.cpp b/samples/today/schema/ExpensiveObject.cpp similarity index 100% rename from samples/today/separate_nointrospection/ExpensiveObject.cpp rename to samples/today/schema/ExpensiveObject.cpp diff --git a/samples/today/separate_nointrospection/ExpensiveObject.h b/samples/today/schema/ExpensiveObject.h similarity index 100% rename from samples/today/separate_nointrospection/ExpensiveObject.h rename to samples/today/schema/ExpensiveObject.h diff --git a/samples/today/separate_nointrospection/FolderConnectionObject.cpp b/samples/today/schema/FolderConnectionObject.cpp similarity index 100% rename from samples/today/separate_nointrospection/FolderConnectionObject.cpp rename to samples/today/schema/FolderConnectionObject.cpp diff --git a/samples/today/separate_nointrospection/FolderConnectionObject.h b/samples/today/schema/FolderConnectionObject.h similarity index 100% rename from samples/today/separate_nointrospection/FolderConnectionObject.h rename to samples/today/schema/FolderConnectionObject.h diff --git a/samples/today/separate_nointrospection/FolderEdgeObject.cpp b/samples/today/schema/FolderEdgeObject.cpp similarity index 100% rename from samples/today/separate_nointrospection/FolderEdgeObject.cpp rename to samples/today/schema/FolderEdgeObject.cpp diff --git a/samples/today/separate_nointrospection/FolderEdgeObject.h b/samples/today/schema/FolderEdgeObject.h similarity index 100% rename from samples/today/separate_nointrospection/FolderEdgeObject.h rename to samples/today/schema/FolderEdgeObject.h diff --git a/samples/today/separate_nointrospection/FolderObject.cpp b/samples/today/schema/FolderObject.cpp similarity index 100% rename from samples/today/separate_nointrospection/FolderObject.cpp rename to samples/today/schema/FolderObject.cpp diff --git a/samples/today/separate_nointrospection/FolderObject.h b/samples/today/schema/FolderObject.h similarity index 100% rename from samples/today/separate_nointrospection/FolderObject.h rename to samples/today/schema/FolderObject.h diff --git a/samples/today/separate_nointrospection/MutationObject.cpp b/samples/today/schema/MutationObject.cpp similarity index 100% rename from samples/today/separate_nointrospection/MutationObject.cpp rename to samples/today/schema/MutationObject.cpp diff --git a/samples/today/separate_nointrospection/MutationObject.h b/samples/today/schema/MutationObject.h similarity index 100% rename from samples/today/separate_nointrospection/MutationObject.h rename to samples/today/schema/MutationObject.h diff --git a/samples/today/separate/NestedTypeObject.cpp b/samples/today/schema/NestedTypeObject.cpp similarity index 100% rename from samples/today/separate/NestedTypeObject.cpp rename to samples/today/schema/NestedTypeObject.cpp diff --git a/samples/today/separate_nointrospection/NestedTypeObject.h b/samples/today/schema/NestedTypeObject.h similarity index 100% rename from samples/today/separate_nointrospection/NestedTypeObject.h rename to samples/today/schema/NestedTypeObject.h diff --git a/samples/today/separate_nointrospection/NodeObject.cpp b/samples/today/schema/NodeObject.cpp similarity index 100% rename from samples/today/separate_nointrospection/NodeObject.cpp rename to samples/today/schema/NodeObject.cpp diff --git a/samples/today/separate_nointrospection/NodeObject.h b/samples/today/schema/NodeObject.h similarity index 100% rename from samples/today/separate_nointrospection/NodeObject.h rename to samples/today/schema/NodeObject.h diff --git a/samples/today/separate_nointrospection/PageInfoObject.cpp b/samples/today/schema/PageInfoObject.cpp similarity index 100% rename from samples/today/separate_nointrospection/PageInfoObject.cpp rename to samples/today/schema/PageInfoObject.cpp diff --git a/samples/today/separate_nointrospection/PageInfoObject.h b/samples/today/schema/PageInfoObject.h similarity index 100% rename from samples/today/separate_nointrospection/PageInfoObject.h rename to samples/today/schema/PageInfoObject.h diff --git a/samples/today/separate/QueryObject.cpp b/samples/today/schema/QueryObject.cpp similarity index 100% rename from samples/today/separate/QueryObject.cpp rename to samples/today/schema/QueryObject.cpp diff --git a/samples/today/separate/QueryObject.h b/samples/today/schema/QueryObject.h similarity index 100% rename from samples/today/separate/QueryObject.h rename to samples/today/schema/QueryObject.h diff --git a/samples/today/separate_nointrospection/SubscriptionObject.cpp b/samples/today/schema/SubscriptionObject.cpp similarity index 100% rename from samples/today/separate_nointrospection/SubscriptionObject.cpp rename to samples/today/schema/SubscriptionObject.cpp diff --git a/samples/today/separate_nointrospection/SubscriptionObject.h b/samples/today/schema/SubscriptionObject.h similarity index 100% rename from samples/today/separate_nointrospection/SubscriptionObject.h rename to samples/today/schema/SubscriptionObject.h diff --git a/samples/today/separate_nointrospection/TaskConnectionObject.cpp b/samples/today/schema/TaskConnectionObject.cpp similarity index 100% rename from samples/today/separate_nointrospection/TaskConnectionObject.cpp rename to samples/today/schema/TaskConnectionObject.cpp diff --git a/samples/today/separate_nointrospection/TaskConnectionObject.h b/samples/today/schema/TaskConnectionObject.h similarity index 100% rename from samples/today/separate_nointrospection/TaskConnectionObject.h rename to samples/today/schema/TaskConnectionObject.h diff --git a/samples/today/separate_nointrospection/TaskEdgeObject.cpp b/samples/today/schema/TaskEdgeObject.cpp similarity index 100% rename from samples/today/separate_nointrospection/TaskEdgeObject.cpp rename to samples/today/schema/TaskEdgeObject.cpp diff --git a/samples/today/separate_nointrospection/TaskEdgeObject.h b/samples/today/schema/TaskEdgeObject.h similarity index 100% rename from samples/today/separate_nointrospection/TaskEdgeObject.h rename to samples/today/schema/TaskEdgeObject.h diff --git a/samples/today/separate_nointrospection/TaskObject.cpp b/samples/today/schema/TaskObject.cpp similarity index 100% rename from samples/today/separate_nointrospection/TaskObject.cpp rename to samples/today/schema/TaskObject.cpp diff --git a/samples/today/separate_nointrospection/TaskObject.h b/samples/today/schema/TaskObject.h similarity index 100% rename from samples/today/separate_nointrospection/TaskObject.h rename to samples/today/schema/TaskObject.h diff --git a/samples/today/separate_nointrospection/TodayObjects.h b/samples/today/schema/TodayObjects.h similarity index 100% rename from samples/today/separate_nointrospection/TodayObjects.h rename to samples/today/schema/TodayObjects.h diff --git a/samples/today/separate/TodaySchema.cpp b/samples/today/schema/TodaySchema.cpp similarity index 100% rename from samples/today/separate/TodaySchema.cpp rename to samples/today/schema/TodaySchema.cpp diff --git a/samples/today/separate_nointrospection/TodaySchema.h b/samples/today/schema/TodaySchema.h similarity index 100% rename from samples/today/separate_nointrospection/TodaySchema.h rename to samples/today/schema/TodaySchema.h diff --git a/samples/today/separate_nointrospection/UnionTypeObject.cpp b/samples/today/schema/UnionTypeObject.cpp similarity index 100% rename from samples/today/separate_nointrospection/UnionTypeObject.cpp rename to samples/today/schema/UnionTypeObject.cpp diff --git a/samples/today/separate_nointrospection/UnionTypeObject.h b/samples/today/schema/UnionTypeObject.h similarity index 100% rename from samples/today/separate_nointrospection/UnionTypeObject.h rename to samples/today/schema/UnionTypeObject.h diff --git a/samples/today/separate_nointrospection/separate_nointrospection_schema_files b/samples/today/schema/today_schema_files similarity index 100% rename from samples/today/separate_nointrospection/separate_nointrospection_schema_files rename to samples/today/schema/today_schema_files diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 0b6bf1a2..4ab213b6 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -16,7 +16,7 @@ gtest_add_tests(TARGET validation_tests) add_executable(today_tests TodayTests.cpp) target_link_libraries(today_tests PRIVATE - separategraphql + todaygraphql graphqljson GTest::GTest GTest::Main) @@ -25,7 +25,7 @@ gtest_add_tests(TARGET today_tests) add_executable(client_tests ClientTests.cpp) target_link_libraries(client_tests PRIVATE - separategraphql + todaygraphql query_client mutate_client subscribe_client @@ -36,7 +36,7 @@ gtest_add_tests(TARGET client_tests) add_executable(nointrospection_tests NoIntrospectionTests.cpp) target_link_libraries(nointrospection_tests PRIVATE - separategraphql_nointrospection + todaygraphql_nointrospection graphqljson GTest::GTest GTest::Main) @@ -45,7 +45,7 @@ gtest_add_tests(TARGET nointrospection_tests) add_executable(argument_tests ArgumentTests.cpp) target_link_libraries(argument_tests PRIVATE - separategraphql + todaygraphql graphqljson GTest::GTest GTest::Main) From 543ed52869ba65332e38fa5c7a52fc3fa974c2e8 Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Thu, 9 Dec 2021 08:58:40 -0800 Subject: [PATCH 071/119] Remove schemagen --merge-files option --- src/SchemaGenerator.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/SchemaGenerator.cpp b/src/SchemaGenerator.cpp index a9c5c4f8..a305d0c7 100644 --- a/src/SchemaGenerator.cpp +++ b/src/SchemaGenerator.cpp @@ -1070,8 +1070,7 @@ void Generator::outputObjectDeclaration( for (auto unionName : objectType.unions) { - headerFile << R"cpp( friend )cpp" << _loader.getSafeCppName(unionName) - << R"cpp(; + headerFile << R"cpp( friend )cpp" << _loader.getSafeCppName(unionName) << R"cpp(; )cpp"; } @@ -3094,7 +3093,6 @@ int main(int argc, char** argv) bool buildCustom = false; bool verbose = false; bool stubs = false; - bool mergeFiles = false; bool noIntrospection = false; std::string schemaFileName; std::string filenamePrefix; @@ -3119,9 +3117,8 @@ int main(int argc, char** argv) po::value(&headerDir), "Target path for the Schema.h header file")("stubs", po::bool_switch(&stubs), - "Unimplemented fields throw runtime exceptions instead of compiler errors")("merge-files", - po::bool_switch(&mergeFiles), - "Generate a single header and source file for the entire schema")("no-introspection", + "Unimplemented fields throw runtime exceptions instead of compiler errors")( + "no-introspection", po::bool_switch(&noIntrospection), "Do not generate support for Introspection"); positional.add("schema", 1).add("prefix", 1).add("namespace", 1); @@ -3208,7 +3205,7 @@ int main(int argc, char** argv) std::move(sourceDir) }, verbose, stubs, - mergeFiles, + false, noIntrospection, }) .Build(); From 875843ccedf57cce6200ebe5caf6af904a731afd Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Thu, 9 Dec 2021 08:59:17 -0800 Subject: [PATCH 072/119] Remove convenience header from TodayMock --- samples/today/TodayMock.cpp | 8 ++++++++ samples/today/TodayMock.h | 14 +++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/samples/today/TodayMock.cpp b/samples/today/TodayMock.cpp index 66c85817..1e1bd736 100644 --- a/samples/today/TodayMock.cpp +++ b/samples/today/TodayMock.cpp @@ -3,6 +3,14 @@ #include "TodayMock.h" +#include "AppointmentConnectionObject.h" +#include "TaskConnectionObject.h" +#include "FolderConnectionObject.h" +#include "UnionTypeObject.h" +#include "NestedTypeObject.h" +#include "ExpensiveObject.h" +#include "CompleteTaskPayloadObject.h" + #include #include #include diff --git a/samples/today/TodayMock.h b/samples/today/TodayMock.h index 5d6883eb..00bb84cb 100644 --- a/samples/today/TodayMock.h +++ b/samples/today/TodayMock.h @@ -6,7 +6,19 @@ #ifndef TODAYMOCK_H #define TODAYMOCK_H -#include "TodayObjects.h" +#include "TodaySchema.h" + +#include "QueryObject.h" +#include "MutationObject.h" +#include "SubscriptionObject.h" +#include "NodeObject.h" +#include "PageInfoObject.h" +#include "AppointmentEdgeObject.h" +#include "TaskEdgeObject.h" +#include "FolderEdgeObject.h" +#include "AppointmentObject.h" +#include "TaskObject.h" +#include "FolderObject.h" #include #include From 218e7d98f1faf9a36fd20c1419d42a85bfd43913 Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Thu, 9 Dec 2021 09:02:29 -0800 Subject: [PATCH 073/119] Stop generating the convenience header --- include/SchemaGenerator.h | 2 - samples/learn/schema/StarWarsObjects.h | 20 ------- samples/today/nointrospection/TodayObjects.h | 32 ----------- samples/today/schema/TodayObjects.h | 32 ----------- samples/validation/schema/ValidationObjects.h | 29 ---------- src/SchemaGenerator.cpp | 57 ------------------- 6 files changed, 172 deletions(-) delete mode 100644 samples/learn/schema/StarWarsObjects.h delete mode 100644 samples/today/nointrospection/TodayObjects.h delete mode 100644 samples/today/schema/TodayObjects.h delete mode 100644 samples/validation/schema/ValidationObjects.h diff --git a/include/SchemaGenerator.h b/include/SchemaGenerator.h index 49b3865c..cd7a9647 100644 --- a/include/SchemaGenerator.h +++ b/include/SchemaGenerator.h @@ -38,7 +38,6 @@ class Generator std::string getHeaderDir() const noexcept; std::string getSourceDir() const noexcept; std::string getHeaderPath() const noexcept; - std::string getObjectHeaderPath() const noexcept; std::string getSourcePath() const noexcept; bool outputHeader() const noexcept; @@ -80,7 +79,6 @@ class Generator const std::string _headerDir; const std::string _sourceDir; const std::string _headerPath; - const std::string _objectHeaderPath; const std::string _sourcePath; }; diff --git a/samples/learn/schema/StarWarsObjects.h b/samples/learn/schema/StarWarsObjects.h deleted file mode 100644 index b3c06e0c..00000000 --- a/samples/learn/schema/StarWarsObjects.h +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// WARNING! Do not edit this file manually, your changes will be overwritten. - -#pragma once - -#ifndef STARWARSOBJECTS_H -#define STARWARSOBJECTS_H - -#include "StarWarsSchema.h" - -#include "CharacterObject.h" -#include "HumanObject.h" -#include "DroidObject.h" -#include "QueryObject.h" -#include "ReviewObject.h" -#include "MutationObject.h" - -#endif // STARWARSOBJECTS_H diff --git a/samples/today/nointrospection/TodayObjects.h b/samples/today/nointrospection/TodayObjects.h deleted file mode 100644 index a172c18f..00000000 --- a/samples/today/nointrospection/TodayObjects.h +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// WARNING! Do not edit this file manually, your changes will be overwritten. - -#pragma once - -#ifndef TODAYOBJECTS_H -#define TODAYOBJECTS_H - -#include "TodaySchema.h" - -#include "NodeObject.h" -#include "UnionTypeObject.h" -#include "QueryObject.h" -#include "PageInfoObject.h" -#include "AppointmentEdgeObject.h" -#include "AppointmentConnectionObject.h" -#include "TaskEdgeObject.h" -#include "TaskConnectionObject.h" -#include "FolderEdgeObject.h" -#include "FolderConnectionObject.h" -#include "CompleteTaskPayloadObject.h" -#include "MutationObject.h" -#include "SubscriptionObject.h" -#include "AppointmentObject.h" -#include "TaskObject.h" -#include "FolderObject.h" -#include "NestedTypeObject.h" -#include "ExpensiveObject.h" - -#endif // TODAYOBJECTS_H diff --git a/samples/today/schema/TodayObjects.h b/samples/today/schema/TodayObjects.h deleted file mode 100644 index a172c18f..00000000 --- a/samples/today/schema/TodayObjects.h +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// WARNING! Do not edit this file manually, your changes will be overwritten. - -#pragma once - -#ifndef TODAYOBJECTS_H -#define TODAYOBJECTS_H - -#include "TodaySchema.h" - -#include "NodeObject.h" -#include "UnionTypeObject.h" -#include "QueryObject.h" -#include "PageInfoObject.h" -#include "AppointmentEdgeObject.h" -#include "AppointmentConnectionObject.h" -#include "TaskEdgeObject.h" -#include "TaskConnectionObject.h" -#include "FolderEdgeObject.h" -#include "FolderConnectionObject.h" -#include "CompleteTaskPayloadObject.h" -#include "MutationObject.h" -#include "SubscriptionObject.h" -#include "AppointmentObject.h" -#include "TaskObject.h" -#include "FolderObject.h" -#include "NestedTypeObject.h" -#include "ExpensiveObject.h" - -#endif // TODAYOBJECTS_H diff --git a/samples/validation/schema/ValidationObjects.h b/samples/validation/schema/ValidationObjects.h deleted file mode 100644 index 903ea138..00000000 --- a/samples/validation/schema/ValidationObjects.h +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// WARNING! Do not edit this file manually, your changes will be overwritten. - -#pragma once - -#ifndef VALIDATIONOBJECTS_H -#define VALIDATIONOBJECTS_H - -#include "ValidationSchema.h" - -#include "SentientObject.h" -#include "PetObject.h" -#include "CatOrDogObject.h" -#include "DogOrHumanObject.h" -#include "HumanOrAlienObject.h" -#include "QueryObject.h" -#include "DogObject.h" -#include "AlienObject.h" -#include "HumanObject.h" -#include "CatObject.h" -#include "MutationObject.h" -#include "MutateDogResultObject.h" -#include "SubscriptionObject.h" -#include "MessageObject.h" -#include "ArgumentsObject.h" - -#endif // VALIDATIONOBJECTS_H diff --git a/src/SchemaGenerator.cpp b/src/SchemaGenerator.cpp index a305d0c7..8f3d3543 100644 --- a/src/SchemaGenerator.cpp +++ b/src/SchemaGenerator.cpp @@ -53,7 +53,6 @@ Generator::Generator(std::optional&& customSchema, GeneratorOptio , _headerDir(getHeaderDir()) , _sourceDir(getSourceDir()) , _headerPath(getHeaderPath()) - , _objectHeaderPath(getObjectHeaderPath()) , _sourcePath(getSourcePath()) { } @@ -90,19 +89,6 @@ std::string Generator::getHeaderPath() const noexcept return fullPath.string(); } -std::string Generator::getObjectHeaderPath() const noexcept -{ - if (!_options.mergeFiles) - { - fs::path fullPath { _headerDir }; - - fullPath /= (std::string { _loader.getFilenamePrefix() } + "Objects.h"); - return fullPath.string(); - } - - return _headerPath; -} - std::string Generator::getSourcePath() const noexcept { fs::path fullPath { _sourceDir }; @@ -1731,8 +1717,6 @@ Operations::Operations()cpp"; { sourceFile << std::endl; - const std::vector emptyInterfaces {}; - for (const auto& interfaceType : _loader.getInterfaceTypes()) { if (!_options.mergeFiles) @@ -2745,47 +2729,6 @@ std::vector Generator::outputSeparateFiles() const noexcept } } - // Output a convenience header - std::ofstream objectHeaderFile(_objectHeaderPath, std::ios_base::trunc); - IncludeGuardScope includeGuard { objectHeaderFile, - fs::path(_objectHeaderPath).filename().string() }; - - objectHeaderFile << R"cpp(#include ")cpp" << fs::path(_headerPath).filename().string() - << R"cpp(" - -)cpp"; - - for (const auto& interfaceType : _loader.getInterfaceTypes()) - { - const auto headerFilename = std::string(interfaceType.cppType) + "Object.h"; - - objectHeaderFile << R"cpp(#include ")cpp" << headerFilename << R"cpp(" -)cpp"; - } - - for (const auto& unionType : _loader.getUnionTypes()) - { - const auto headerFilename = std::string(unionType.cppType) + "Object.h"; - - objectHeaderFile << R"cpp(#include ")cpp" << headerFilename << R"cpp(" -)cpp"; - } - - for (const auto& objectType : _loader.getObjectTypes()) - { - const auto headerFilename = std::string(objectType.cppType) + "Object.h"; - - objectHeaderFile << R"cpp(#include ")cpp" << headerFilename << R"cpp(" -)cpp"; - } - - if (_options.verbose) - { - files.push_back({ _objectHeaderPath }); - } - - const std::vector emptyInterfacesAndUnions {}; - for (const auto& interfaceType : _loader.getInterfaceTypes()) { const auto headerFilename = std::string(interfaceType.cppType) + "Object.h"; From d22231d53c4a4a0b3a22deebb8cb143ffe915073 Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Thu, 9 Dec 2021 13:41:12 -0800 Subject: [PATCH 074/119] Switch IntrospectionSchema to separate files --- cmake/cppgraphqlgen-functions.cmake | 36 +- include/SchemaLoader.h | 1 + .../Introspection.h | 4 +- .../introspection/DirectiveObject.h | 144 +++ .../introspection/EnumValueObject.h | 144 +++ .../introspection/FieldObject.h | 182 ++++ .../introspection/InputValueObject.h | 144 +++ .../introspection/IntrospectionSchema.h | 447 +--------- .../introspection/SchemaObject.h | 163 ++++ .../graphqlservice/introspection/TypeObject.h | 239 +++++ samples/learn/schema/CharacterObject.cpp | 4 +- samples/learn/schema/DroidObject.cpp | 4 +- samples/learn/schema/HumanObject.cpp | 4 +- samples/learn/schema/MutationObject.cpp | 4 +- samples/learn/schema/QueryObject.cpp | 5 +- samples/learn/schema/ReviewObject.cpp | 4 +- samples/learn/schema/StarWarsSchema.cpp | 5 +- .../AppointmentConnectionObject.cpp | 4 +- .../nointrospection/AppointmentEdgeObject.cpp | 4 +- .../nointrospection/AppointmentObject.cpp | 4 +- .../CompleteTaskPayloadObject.cpp | 4 +- .../today/nointrospection/ExpensiveObject.cpp | 4 +- .../FolderConnectionObject.cpp | 4 +- .../nointrospection/FolderEdgeObject.cpp | 4 +- .../today/nointrospection/FolderObject.cpp | 4 +- .../today/nointrospection/MutationObject.cpp | 4 +- .../nointrospection/NestedTypeObject.cpp | 4 +- samples/today/nointrospection/NodeObject.cpp | 4 +- .../today/nointrospection/PageInfoObject.cpp | 4 +- samples/today/nointrospection/QueryObject.cpp | 4 +- .../nointrospection/SubscriptionObject.cpp | 4 +- .../nointrospection/TaskConnectionObject.cpp | 4 +- .../today/nointrospection/TaskEdgeObject.cpp | 4 +- samples/today/nointrospection/TaskObject.cpp | 4 +- samples/today/nointrospection/TodaySchema.cpp | 5 +- .../today/nointrospection/UnionTypeObject.cpp | 4 +- .../schema/AppointmentConnectionObject.cpp | 4 +- .../today/schema/AppointmentEdgeObject.cpp | 4 +- samples/today/schema/AppointmentObject.cpp | 4 +- .../schema/CompleteTaskPayloadObject.cpp | 4 +- samples/today/schema/ExpensiveObject.cpp | 4 +- .../today/schema/FolderConnectionObject.cpp | 4 +- samples/today/schema/FolderEdgeObject.cpp | 4 +- samples/today/schema/FolderObject.cpp | 4 +- samples/today/schema/MutationObject.cpp | 4 +- samples/today/schema/NestedTypeObject.cpp | 4 +- samples/today/schema/NodeObject.cpp | 4 +- samples/today/schema/PageInfoObject.cpp | 4 +- samples/today/schema/QueryObject.cpp | 5 +- samples/today/schema/SubscriptionObject.cpp | 4 +- samples/today/schema/TaskConnectionObject.cpp | 4 +- samples/today/schema/TaskEdgeObject.cpp | 4 +- samples/today/schema/TaskObject.cpp | 4 +- samples/today/schema/TodaySchema.cpp | 5 +- samples/today/schema/UnionTypeObject.cpp | 4 +- samples/validation/schema/AlienObject.cpp | 4 +- samples/validation/schema/ArgumentsObject.cpp | 4 +- samples/validation/schema/CatObject.cpp | 4 +- samples/validation/schema/CatOrDogObject.cpp | 4 +- samples/validation/schema/DogObject.cpp | 4 +- .../validation/schema/DogOrHumanObject.cpp | 4 +- samples/validation/schema/HumanObject.cpp | 4 +- .../validation/schema/HumanOrAlienObject.cpp | 4 +- samples/validation/schema/MessageObject.cpp | 4 +- .../schema/MutateDogResultObject.cpp | 4 +- samples/validation/schema/MutationObject.cpp | 4 +- samples/validation/schema/PetObject.cpp | 4 +- samples/validation/schema/QueryObject.cpp | 4 +- samples/validation/schema/SentientObject.cpp | 4 +- .../validation/schema/SubscriptionObject.cpp | 4 +- .../validation/schema/ValidationSchema.cpp | 5 +- src/CMakeLists.txt | 27 +- src/Introspection.cpp | 11 +- src/IntrospectionSchema.cpp | 820 ------------------ src/RequestLoader.cpp | 2 +- src/SchemaGenerator.cpp | 126 ++- src/SchemaLoader.cpp | 6 +- src/introspection/CMakeLists.txt | 28 + src/introspection/DirectiveObject.cpp | 109 +++ src/introspection/DirectiveObject.h | 144 +++ src/introspection/EnumValueObject.cpp | 108 +++ src/introspection/EnumValueObject.h | 144 +++ src/introspection/FieldObject.cpp | 134 +++ src/introspection/FieldObject.h | 182 ++++ src/introspection/InputValueObject.cpp | 109 +++ src/introspection/InputValueObject.h | 144 +++ src/introspection/IntrospectionSchema.cpp | 208 +++++ src/introspection/IntrospectionSchema.h | 120 +++ src/introspection/SchemaObject.cpp | 122 +++ src/introspection/SchemaObject.h | 163 ++++ src/introspection/TypeObject.cpp | 206 +++++ src/introspection/TypeObject.h | 239 +++++ src/introspection/introspection_schema_files | 7 + .../schema.introspection.graphql | 104 +++ 94 files changed, 3612 insertions(+), 1405 deletions(-) rename include/graphqlservice/{introspection => internal}/Introspection.h (100%) create mode 100644 include/graphqlservice/introspection/DirectiveObject.h create mode 100644 include/graphqlservice/introspection/EnumValueObject.h create mode 100644 include/graphqlservice/introspection/FieldObject.h create mode 100644 include/graphqlservice/introspection/InputValueObject.h create mode 100644 include/graphqlservice/introspection/SchemaObject.h create mode 100644 include/graphqlservice/introspection/TypeObject.h delete mode 100644 src/IntrospectionSchema.cpp create mode 100644 src/introspection/CMakeLists.txt create mode 100644 src/introspection/DirectiveObject.cpp create mode 100644 src/introspection/DirectiveObject.h create mode 100644 src/introspection/EnumValueObject.cpp create mode 100644 src/introspection/EnumValueObject.h create mode 100644 src/introspection/FieldObject.cpp create mode 100644 src/introspection/FieldObject.h create mode 100644 src/introspection/InputValueObject.cpp create mode 100644 src/introspection/InputValueObject.h create mode 100644 src/introspection/IntrospectionSchema.cpp create mode 100644 src/introspection/IntrospectionSchema.h create mode 100644 src/introspection/SchemaObject.cpp create mode 100644 src/introspection/SchemaObject.h create mode 100644 src/introspection/TypeObject.cpp create mode 100644 src/introspection/TypeObject.h create mode 100644 src/introspection/introspection_schema_files create mode 100644 src/introspection/schema.introspection.graphql diff --git a/cmake/cppgraphqlgen-functions.cmake b/cmake/cppgraphqlgen-functions.cmake index 46a0aef6..91fa3404 100644 --- a/cmake/cppgraphqlgen-functions.cmake +++ b/cmake/cppgraphqlgen-functions.cmake @@ -42,22 +42,26 @@ function(add_graphql_schema_target SCHEMA_TARGET) add_custom_target(${SCHEMA_TARGET}_update_schema ALL DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${SCHEMA_TARGET}_schema_files) - file(STRINGS ${SCHEMA_TARGET}_schema_files SCHEMA_FILES) - add_library(${SCHEMA_TARGET}_schema STATIC ${SCHEMA_FILES}) - add_dependencies(${SCHEMA_TARGET}_schema ${SCHEMA_TARGET}_update_schema) - target_include_directories(${SCHEMA_TARGET}_schema PUBLIC $) - target_link_libraries(${SCHEMA_TARGET}_schema PUBLIC cppgraphqlgen::graphqlintrospection) + if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${SCHEMA_TARGET}_schema_files) + file(STRINGS ${CMAKE_CURRENT_SOURCE_DIR}/${SCHEMA_TARGET}_schema_files SCHEMA_FILES) + add_library(${SCHEMA_TARGET}_schema STATIC ${SCHEMA_FILES}) + add_dependencies(${SCHEMA_TARGET}_schema ${SCHEMA_TARGET}_update_schema) + target_include_directories(${SCHEMA_TARGET}_schema PUBLIC $) + target_link_libraries(${SCHEMA_TARGET}_schema PUBLIC cppgraphqlgen::graphqlintrospection) + endif() endfunction() function(add_graphql_schema_no_introspection_target SCHEMA_NO_INTROSPECTION_TARGET) add_custom_target(${SCHEMA_NO_INTROSPECTION_TARGET}_update_schema ALL DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${SCHEMA_NO_INTROSPECTION_TARGET}_schema_files) - file(STRINGS ${SCHEMA_NO_INTROSPECTION_TARGET}_schema_files SCHEMA_FILES) - add_library(${SCHEMA_NO_INTROSPECTION_TARGET}_schema STATIC ${SCHEMA_FILES}) - add_dependencies(${SCHEMA_NO_INTROSPECTION_TARGET}_schema ${SCHEMA_NO_INTROSPECTION_TARGET}_update_schema) - target_include_directories(${SCHEMA_NO_INTROSPECTION_TARGET}_schema PUBLIC $) - target_link_libraries(${SCHEMA_NO_INTROSPECTION_TARGET}_schema PUBLIC cppgraphqlgen::graphqlservice) + if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${SCHEMA_NO_INTROSPECTION_TARGET}_schema_files) + file(STRINGS ${CMAKE_CURRENT_SOURCE_DIR}/${SCHEMA_NO_INTROSPECTION_TARGET}_schema_files SCHEMA_FILES) + add_library(${SCHEMA_NO_INTROSPECTION_TARGET}_schema STATIC ${SCHEMA_FILES}) + add_dependencies(${SCHEMA_NO_INTROSPECTION_TARGET}_schema ${SCHEMA_NO_INTROSPECTION_TARGET}_update_schema) + target_include_directories(${SCHEMA_NO_INTROSPECTION_TARGET}_schema PUBLIC $) + target_link_libraries(${SCHEMA_NO_INTROSPECTION_TARGET}_schema PUBLIC cppgraphqlgen::graphqlservice) + endif() endfunction() function(update_graphql_client_files CLIENT_TARGET SCHEMA_GRAPHQL REQUEST_GRAPHQL CLIENT_PREFIX CLIENT_NAMESPACE) @@ -93,9 +97,11 @@ function(add_graphql_client_target CLIENT_TARGET) add_custom_target(${CLIENT_TARGET}_update_client ALL DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${CLIENT_TARGET}_client_files) - file(STRINGS ${CLIENT_TARGET}_client_files CLIENT_FILES) - add_library(${CLIENT_TARGET}_client STATIC ${CLIENT_FILES}) - add_dependencies(${CLIENT_TARGET}_client ${CLIENT_TARGET}_update_client) - target_include_directories(${CLIENT_TARGET}_client PUBLIC $) - target_link_libraries(${CLIENT_TARGET}_client PUBLIC cppgraphqlgen::graphqlclient) + if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${CLIENT_TARGET}_client_files) + file(STRINGS ${CMAKE_CURRENT_SOURCE_DIR}/${CLIENT_TARGET}_client_files CLIENT_FILES) + add_library(${CLIENT_TARGET}_client STATIC ${CLIENT_FILES}) + add_dependencies(${CLIENT_TARGET}_client ${CLIENT_TARGET}_update_client) + target_include_directories(${CLIENT_TARGET}_client PUBLIC $) + target_link_libraries(${CLIENT_TARGET}_client PUBLIC cppgraphqlgen::graphqlclient) + endif() endfunction() diff --git a/include/SchemaLoader.h b/include/SchemaLoader.h index cbd81698..90c7e83f 100644 --- a/include/SchemaLoader.h +++ b/include/SchemaLoader.h @@ -209,6 +209,7 @@ struct SchemaOptions const std::string schemaFilename; const std::string filenamePrefix; const std::string schemaNamespace; + const bool isIntrospection = false; }; class SchemaLoader diff --git a/include/graphqlservice/introspection/Introspection.h b/include/graphqlservice/internal/Introspection.h similarity index 100% rename from include/graphqlservice/introspection/Introspection.h rename to include/graphqlservice/internal/Introspection.h index 114e878f..0049b6ef 100644 --- a/include/graphqlservice/introspection/Introspection.h +++ b/include/graphqlservice/internal/Introspection.h @@ -6,10 +6,10 @@ #ifndef INTROSPECTION_H #define INTROSPECTION_H -#include "graphqlservice/internal/Schema.h" - #include "graphqlservice/introspection/IntrospectionSchema.h" +#include "graphqlservice/internal/Schema.h" + namespace graphql::introspection { class Schema; diff --git a/include/graphqlservice/introspection/DirectiveObject.h b/include/graphqlservice/introspection/DirectiveObject.h new file mode 100644 index 00000000..953863a4 --- /dev/null +++ b/include/graphqlservice/introspection/DirectiveObject.h @@ -0,0 +1,144 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// WARNING! Do not edit this file manually, your changes will be overwritten. + +#pragma once + +#ifndef DIRECTIVEOBJECT_H +#define DIRECTIVEOBJECT_H + +#include "IntrospectionSchema.h" + +namespace graphql::introspection::object { +namespace methods::DirectiveHas { + +template +concept getNameWithParams = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult { impl.getName(std::move(params)) } }; +}; + +template +concept getName = requires (TImpl impl) +{ + { service::FieldResult { impl.getName() } }; +}; + +template +concept getDescriptionWithParams = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult> { impl.getDescription(std::move(params)) } }; +}; + +template +concept getDescription = requires (TImpl impl) +{ + { service::FieldResult> { impl.getDescription() } }; +}; + +template +concept getLocationsWithParams = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult> { impl.getLocations(std::move(params)) } }; +}; + +template +concept getLocations = requires (TImpl impl) +{ + { service::FieldResult> { impl.getLocations() } }; +}; + +template +concept getArgsWithParams = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult>> { impl.getArgs(std::move(params)) } }; +}; + +template +concept getArgs = requires (TImpl impl) +{ + { service::FieldResult>> { impl.getArgs() } }; +}; + +template +concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.beginSelectionSet(params) }; +}; + +template +concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.endSelectionSet(params) }; +}; + +} // namespace methods::DirectiveHas + +class Directive + : public service::Object +{ +private: + service::AwaitableResolver resolveName(service::ResolverParams&& params) const; + service::AwaitableResolver resolveDescription(service::ResolverParams&& params) const; + service::AwaitableResolver resolveLocations(service::ResolverParams&& params) const; + service::AwaitableResolver resolveArgs(service::ResolverParams&& params) const; + + service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; + + struct Concept + { + virtual ~Concept() = default; + + virtual service::FieldResult getName(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getDescription(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getLocations(service::FieldParams&& params) const = 0; + virtual service::FieldResult>> getArgs(service::FieldParams&& params) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::FieldResult getName(service::FieldParams&&) const final + { + return { _pimpl->getName() }; + } + + service::FieldResult> getDescription(service::FieldParams&&) const final + { + return { _pimpl->getDescription() }; + } + + service::FieldResult> getLocations(service::FieldParams&&) const final + { + return { _pimpl->getLocations() }; + } + + service::FieldResult>> getArgs(service::FieldParams&&) const final + { + return { _pimpl->getArgs() }; + } + + private: + const std::shared_ptr _pimpl; + }; + + const std::unique_ptr _pimpl; + + service::TypeNames getTypeNames() const noexcept; + service::ResolverMap getResolvers() const noexcept; + +public: + GRAPHQLINTROSPECTION_EXPORT Directive(std::shared_ptr pimpl) noexcept; + GRAPHQLINTROSPECTION_EXPORT ~Directive(); +}; + +} // namespace graphql::introspection::object + +#endif // DIRECTIVEOBJECT_H diff --git a/include/graphqlservice/introspection/EnumValueObject.h b/include/graphqlservice/introspection/EnumValueObject.h new file mode 100644 index 00000000..3f2dd71c --- /dev/null +++ b/include/graphqlservice/introspection/EnumValueObject.h @@ -0,0 +1,144 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// WARNING! Do not edit this file manually, your changes will be overwritten. + +#pragma once + +#ifndef ENUMVALUEOBJECT_H +#define ENUMVALUEOBJECT_H + +#include "IntrospectionSchema.h" + +namespace graphql::introspection::object { +namespace methods::EnumValueHas { + +template +concept getNameWithParams = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult { impl.getName(std::move(params)) } }; +}; + +template +concept getName = requires (TImpl impl) +{ + { service::FieldResult { impl.getName() } }; +}; + +template +concept getDescriptionWithParams = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult> { impl.getDescription(std::move(params)) } }; +}; + +template +concept getDescription = requires (TImpl impl) +{ + { service::FieldResult> { impl.getDescription() } }; +}; + +template +concept getIsDeprecatedWithParams = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult { impl.getIsDeprecated(std::move(params)) } }; +}; + +template +concept getIsDeprecated = requires (TImpl impl) +{ + { service::FieldResult { impl.getIsDeprecated() } }; +}; + +template +concept getDeprecationReasonWithParams = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult> { impl.getDeprecationReason(std::move(params)) } }; +}; + +template +concept getDeprecationReason = requires (TImpl impl) +{ + { service::FieldResult> { impl.getDeprecationReason() } }; +}; + +template +concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.beginSelectionSet(params) }; +}; + +template +concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.endSelectionSet(params) }; +}; + +} // namespace methods::EnumValueHas + +class EnumValue + : public service::Object +{ +private: + service::AwaitableResolver resolveName(service::ResolverParams&& params) const; + service::AwaitableResolver resolveDescription(service::ResolverParams&& params) const; + service::AwaitableResolver resolveIsDeprecated(service::ResolverParams&& params) const; + service::AwaitableResolver resolveDeprecationReason(service::ResolverParams&& params) const; + + service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; + + struct Concept + { + virtual ~Concept() = default; + + virtual service::FieldResult getName(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getDescription(service::FieldParams&& params) const = 0; + virtual service::FieldResult getIsDeprecated(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getDeprecationReason(service::FieldParams&& params) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::FieldResult getName(service::FieldParams&&) const final + { + return { _pimpl->getName() }; + } + + service::FieldResult> getDescription(service::FieldParams&&) const final + { + return { _pimpl->getDescription() }; + } + + service::FieldResult getIsDeprecated(service::FieldParams&&) const final + { + return { _pimpl->getIsDeprecated() }; + } + + service::FieldResult> getDeprecationReason(service::FieldParams&&) const final + { + return { _pimpl->getDeprecationReason() }; + } + + private: + const std::shared_ptr _pimpl; + }; + + const std::unique_ptr _pimpl; + + service::TypeNames getTypeNames() const noexcept; + service::ResolverMap getResolvers() const noexcept; + +public: + GRAPHQLINTROSPECTION_EXPORT EnumValue(std::shared_ptr pimpl) noexcept; + GRAPHQLINTROSPECTION_EXPORT ~EnumValue(); +}; + +} // namespace graphql::introspection::object + +#endif // ENUMVALUEOBJECT_H diff --git a/include/graphqlservice/introspection/FieldObject.h b/include/graphqlservice/introspection/FieldObject.h new file mode 100644 index 00000000..0020b6e1 --- /dev/null +++ b/include/graphqlservice/introspection/FieldObject.h @@ -0,0 +1,182 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// WARNING! Do not edit this file manually, your changes will be overwritten. + +#pragma once + +#ifndef FIELDOBJECT_H +#define FIELDOBJECT_H + +#include "IntrospectionSchema.h" + +namespace graphql::introspection::object { +namespace methods::FieldHas { + +template +concept getNameWithParams = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult { impl.getName(std::move(params)) } }; +}; + +template +concept getName = requires (TImpl impl) +{ + { service::FieldResult { impl.getName() } }; +}; + +template +concept getDescriptionWithParams = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult> { impl.getDescription(std::move(params)) } }; +}; + +template +concept getDescription = requires (TImpl impl) +{ + { service::FieldResult> { impl.getDescription() } }; +}; + +template +concept getArgsWithParams = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult>> { impl.getArgs(std::move(params)) } }; +}; + +template +concept getArgs = requires (TImpl impl) +{ + { service::FieldResult>> { impl.getArgs() } }; +}; + +template +concept getTypeWithParams = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult> { impl.getType(std::move(params)) } }; +}; + +template +concept getType = requires (TImpl impl) +{ + { service::FieldResult> { impl.getType() } }; +}; + +template +concept getIsDeprecatedWithParams = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult { impl.getIsDeprecated(std::move(params)) } }; +}; + +template +concept getIsDeprecated = requires (TImpl impl) +{ + { service::FieldResult { impl.getIsDeprecated() } }; +}; + +template +concept getDeprecationReasonWithParams = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult> { impl.getDeprecationReason(std::move(params)) } }; +}; + +template +concept getDeprecationReason = requires (TImpl impl) +{ + { service::FieldResult> { impl.getDeprecationReason() } }; +}; + +template +concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.beginSelectionSet(params) }; +}; + +template +concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.endSelectionSet(params) }; +}; + +} // namespace methods::FieldHas + +class Field + : public service::Object +{ +private: + service::AwaitableResolver resolveName(service::ResolverParams&& params) const; + service::AwaitableResolver resolveDescription(service::ResolverParams&& params) const; + service::AwaitableResolver resolveArgs(service::ResolverParams&& params) const; + service::AwaitableResolver resolveType(service::ResolverParams&& params) const; + service::AwaitableResolver resolveIsDeprecated(service::ResolverParams&& params) const; + service::AwaitableResolver resolveDeprecationReason(service::ResolverParams&& params) const; + + service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; + + struct Concept + { + virtual ~Concept() = default; + + virtual service::FieldResult getName(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getDescription(service::FieldParams&& params) const = 0; + virtual service::FieldResult>> getArgs(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getType(service::FieldParams&& params) const = 0; + virtual service::FieldResult getIsDeprecated(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getDeprecationReason(service::FieldParams&& params) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::FieldResult getName(service::FieldParams&&) const final + { + return { _pimpl->getName() }; + } + + service::FieldResult> getDescription(service::FieldParams&&) const final + { + return { _pimpl->getDescription() }; + } + + service::FieldResult>> getArgs(service::FieldParams&&) const final + { + return { _pimpl->getArgs() }; + } + + service::FieldResult> getType(service::FieldParams&&) const final + { + return { _pimpl->getType() }; + } + + service::FieldResult getIsDeprecated(service::FieldParams&&) const final + { + return { _pimpl->getIsDeprecated() }; + } + + service::FieldResult> getDeprecationReason(service::FieldParams&&) const final + { + return { _pimpl->getDeprecationReason() }; + } + + private: + const std::shared_ptr _pimpl; + }; + + const std::unique_ptr _pimpl; + + service::TypeNames getTypeNames() const noexcept; + service::ResolverMap getResolvers() const noexcept; + +public: + GRAPHQLINTROSPECTION_EXPORT Field(std::shared_ptr pimpl) noexcept; + GRAPHQLINTROSPECTION_EXPORT ~Field(); +}; + +} // namespace graphql::introspection::object + +#endif // FIELDOBJECT_H diff --git a/include/graphqlservice/introspection/InputValueObject.h b/include/graphqlservice/introspection/InputValueObject.h new file mode 100644 index 00000000..b4ec2474 --- /dev/null +++ b/include/graphqlservice/introspection/InputValueObject.h @@ -0,0 +1,144 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// WARNING! Do not edit this file manually, your changes will be overwritten. + +#pragma once + +#ifndef INPUTVALUEOBJECT_H +#define INPUTVALUEOBJECT_H + +#include "IntrospectionSchema.h" + +namespace graphql::introspection::object { +namespace methods::InputValueHas { + +template +concept getNameWithParams = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult { impl.getName(std::move(params)) } }; +}; + +template +concept getName = requires (TImpl impl) +{ + { service::FieldResult { impl.getName() } }; +}; + +template +concept getDescriptionWithParams = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult> { impl.getDescription(std::move(params)) } }; +}; + +template +concept getDescription = requires (TImpl impl) +{ + { service::FieldResult> { impl.getDescription() } }; +}; + +template +concept getTypeWithParams = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult> { impl.getType(std::move(params)) } }; +}; + +template +concept getType = requires (TImpl impl) +{ + { service::FieldResult> { impl.getType() } }; +}; + +template +concept getDefaultValueWithParams = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult> { impl.getDefaultValue(std::move(params)) } }; +}; + +template +concept getDefaultValue = requires (TImpl impl) +{ + { service::FieldResult> { impl.getDefaultValue() } }; +}; + +template +concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.beginSelectionSet(params) }; +}; + +template +concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.endSelectionSet(params) }; +}; + +} // namespace methods::InputValueHas + +class InputValue + : public service::Object +{ +private: + service::AwaitableResolver resolveName(service::ResolverParams&& params) const; + service::AwaitableResolver resolveDescription(service::ResolverParams&& params) const; + service::AwaitableResolver resolveType(service::ResolverParams&& params) const; + service::AwaitableResolver resolveDefaultValue(service::ResolverParams&& params) const; + + service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; + + struct Concept + { + virtual ~Concept() = default; + + virtual service::FieldResult getName(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getDescription(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getType(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getDefaultValue(service::FieldParams&& params) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::FieldResult getName(service::FieldParams&&) const final + { + return { _pimpl->getName() }; + } + + service::FieldResult> getDescription(service::FieldParams&&) const final + { + return { _pimpl->getDescription() }; + } + + service::FieldResult> getType(service::FieldParams&&) const final + { + return { _pimpl->getType() }; + } + + service::FieldResult> getDefaultValue(service::FieldParams&&) const final + { + return { _pimpl->getDefaultValue() }; + } + + private: + const std::shared_ptr _pimpl; + }; + + const std::unique_ptr _pimpl; + + service::TypeNames getTypeNames() const noexcept; + service::ResolverMap getResolvers() const noexcept; + +public: + GRAPHQLINTROSPECTION_EXPORT InputValue(std::shared_ptr pimpl) noexcept; + GRAPHQLINTROSPECTION_EXPORT ~InputValue(); +}; + +} // namespace graphql::introspection::object + +#endif // INPUTVALUEOBJECT_H diff --git a/include/graphqlservice/introspection/IntrospectionSchema.h b/include/graphqlservice/introspection/IntrospectionSchema.h index 420b4c2d..a701780a 100644 --- a/include/graphqlservice/introspection/IntrospectionSchema.h +++ b/include/graphqlservice/introspection/IntrospectionSchema.h @@ -83,448 +83,15 @@ class InputValue; class EnumValue; class Directive; -class Schema - : public service::Object -{ -private: - service::AwaitableResolver resolveTypes(service::ResolverParams&& params) const; - service::AwaitableResolver resolveQueryType(service::ResolverParams&& params) const; - service::AwaitableResolver resolveMutationType(service::ResolverParams&& params) const; - service::AwaitableResolver resolveSubscriptionType(service::ResolverParams&& params) const; - service::AwaitableResolver resolveDirectives(service::ResolverParams&& params) const; - - service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; - - struct Concept - { - virtual ~Concept() = default; - - virtual service::FieldResult>> getTypes(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getQueryType(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getMutationType(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getSubscriptionType(service::FieldParams&& params) const = 0; - virtual service::FieldResult>> getDirectives(service::FieldParams&& params) const = 0; - }; - - template - struct Model - : Concept - { - Model(std::shared_ptr&& pimpl) noexcept - : _pimpl { std::move(pimpl) } - { - } - - service::FieldResult>> getTypes(service::FieldParams&&) const final - { - return { _pimpl->getTypes() }; - } - - service::FieldResult> getQueryType(service::FieldParams&&) const final - { - return { _pimpl->getQueryType() }; - } - - service::FieldResult> getMutationType(service::FieldParams&&) const final - { - return { _pimpl->getMutationType() }; - } - - service::FieldResult> getSubscriptionType(service::FieldParams&&) const final - { - return { _pimpl->getSubscriptionType() }; - } - - service::FieldResult>> getDirectives(service::FieldParams&&) const final - { - return { _pimpl->getDirectives() }; - } - - private: - const std::shared_ptr _pimpl; - }; - - const std::unique_ptr _pimpl; - - service::TypeNames getTypeNames() const noexcept; - service::ResolverMap getResolvers() const noexcept; - -public: - GRAPHQLINTROSPECTION_EXPORT Schema(std::shared_ptr pimpl) noexcept; - GRAPHQLINTROSPECTION_EXPORT ~Schema(); -}; - -class Type - : public service::Object -{ -private: - service::AwaitableResolver resolveKind(service::ResolverParams&& params) const; - service::AwaitableResolver resolveName(service::ResolverParams&& params) const; - service::AwaitableResolver resolveDescription(service::ResolverParams&& params) const; - service::AwaitableResolver resolveFields(service::ResolverParams&& params) const; - service::AwaitableResolver resolveInterfaces(service::ResolverParams&& params) const; - service::AwaitableResolver resolvePossibleTypes(service::ResolverParams&& params) const; - service::AwaitableResolver resolveEnumValues(service::ResolverParams&& params) const; - service::AwaitableResolver resolveInputFields(service::ResolverParams&& params) const; - service::AwaitableResolver resolveOfType(service::ResolverParams&& params) const; - - service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; - - struct Concept - { - virtual ~Concept() = default; - - virtual service::FieldResult getKind(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getName(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getDescription(service::FieldParams&& params) const = 0; - virtual service::FieldResult>>> getFields(service::FieldParams&& params, std::optional&& includeDeprecatedArg) const = 0; - virtual service::FieldResult>>> getInterfaces(service::FieldParams&& params) const = 0; - virtual service::FieldResult>>> getPossibleTypes(service::FieldParams&& params) const = 0; - virtual service::FieldResult>>> getEnumValues(service::FieldParams&& params, std::optional&& includeDeprecatedArg) const = 0; - virtual service::FieldResult>>> getInputFields(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getOfType(service::FieldParams&& params) const = 0; - }; - - template - struct Model - : Concept - { - Model(std::shared_ptr&& pimpl) noexcept - : _pimpl { std::move(pimpl) } - { - } - - service::FieldResult getKind(service::FieldParams&&) const final - { - return { _pimpl->getKind() }; - } - - service::FieldResult> getName(service::FieldParams&&) const final - { - return { _pimpl->getName() }; - } - - service::FieldResult> getDescription(service::FieldParams&&) const final - { - return { _pimpl->getDescription() }; - } - - service::FieldResult>>> getFields(service::FieldParams&&, std::optional&& includeDeprecatedArg) const final - { - return { _pimpl->getFields(std::move(includeDeprecatedArg)) }; - } - - service::FieldResult>>> getInterfaces(service::FieldParams&&) const final - { - return { _pimpl->getInterfaces() }; - } - - service::FieldResult>>> getPossibleTypes(service::FieldParams&&) const final - { - return { _pimpl->getPossibleTypes() }; - } - - service::FieldResult>>> getEnumValues(service::FieldParams&&, std::optional&& includeDeprecatedArg) const final - { - return { _pimpl->getEnumValues(std::move(includeDeprecatedArg)) }; - } - - service::FieldResult>>> getInputFields(service::FieldParams&&) const final - { - return { _pimpl->getInputFields() }; - } - - service::FieldResult> getOfType(service::FieldParams&&) const final - { - return { _pimpl->getOfType() }; - } - - private: - const std::shared_ptr _pimpl; - }; - - const std::unique_ptr _pimpl; - - service::TypeNames getTypeNames() const noexcept; - service::ResolverMap getResolvers() const noexcept; - -public: - GRAPHQLINTROSPECTION_EXPORT Type(std::shared_ptr pimpl) noexcept; - GRAPHQLINTROSPECTION_EXPORT ~Type(); -}; - -class Field - : public service::Object -{ -private: - service::AwaitableResolver resolveName(service::ResolverParams&& params) const; - service::AwaitableResolver resolveDescription(service::ResolverParams&& params) const; - service::AwaitableResolver resolveArgs(service::ResolverParams&& params) const; - service::AwaitableResolver resolveType(service::ResolverParams&& params) const; - service::AwaitableResolver resolveIsDeprecated(service::ResolverParams&& params) const; - service::AwaitableResolver resolveDeprecationReason(service::ResolverParams&& params) const; - - service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; - - struct Concept - { - virtual ~Concept() = default; - - virtual service::FieldResult getName(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getDescription(service::FieldParams&& params) const = 0; - virtual service::FieldResult>> getArgs(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getType(service::FieldParams&& params) const = 0; - virtual service::FieldResult getIsDeprecated(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getDeprecationReason(service::FieldParams&& params) const = 0; - }; - - template - struct Model - : Concept - { - Model(std::shared_ptr&& pimpl) noexcept - : _pimpl { std::move(pimpl) } - { - } - - service::FieldResult getName(service::FieldParams&&) const final - { - return { _pimpl->getName() }; - } - - service::FieldResult> getDescription(service::FieldParams&&) const final - { - return { _pimpl->getDescription() }; - } - - service::FieldResult>> getArgs(service::FieldParams&&) const final - { - return { _pimpl->getArgs() }; - } - - service::FieldResult> getType(service::FieldParams&&) const final - { - return { _pimpl->getType() }; - } - - service::FieldResult getIsDeprecated(service::FieldParams&&) const final - { - return { _pimpl->getIsDeprecated() }; - } - - service::FieldResult> getDeprecationReason(service::FieldParams&&) const final - { - return { _pimpl->getDeprecationReason() }; - } - - private: - const std::shared_ptr _pimpl; - }; - - const std::unique_ptr _pimpl; - - service::TypeNames getTypeNames() const noexcept; - service::ResolverMap getResolvers() const noexcept; - -public: - GRAPHQLINTROSPECTION_EXPORT Field(std::shared_ptr pimpl) noexcept; - GRAPHQLINTROSPECTION_EXPORT ~Field(); -}; - -class InputValue - : public service::Object -{ -private: - service::AwaitableResolver resolveName(service::ResolverParams&& params) const; - service::AwaitableResolver resolveDescription(service::ResolverParams&& params) const; - service::AwaitableResolver resolveType(service::ResolverParams&& params) const; - service::AwaitableResolver resolveDefaultValue(service::ResolverParams&& params) const; - - service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; - - struct Concept - { - virtual ~Concept() = default; - - virtual service::FieldResult getName(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getDescription(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getType(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getDefaultValue(service::FieldParams&& params) const = 0; - }; - - template - struct Model - : Concept - { - Model(std::shared_ptr&& pimpl) noexcept - : _pimpl { std::move(pimpl) } - { - } - - service::FieldResult getName(service::FieldParams&&) const final - { - return { _pimpl->getName() }; - } - - service::FieldResult> getDescription(service::FieldParams&&) const final - { - return { _pimpl->getDescription() }; - } - - service::FieldResult> getType(service::FieldParams&&) const final - { - return { _pimpl->getType() }; - } - - service::FieldResult> getDefaultValue(service::FieldParams&&) const final - { - return { _pimpl->getDefaultValue() }; - } - - private: - const std::shared_ptr _pimpl; - }; - - const std::unique_ptr _pimpl; - - service::TypeNames getTypeNames() const noexcept; - service::ResolverMap getResolvers() const noexcept; - -public: - GRAPHQLINTROSPECTION_EXPORT InputValue(std::shared_ptr pimpl) noexcept; - GRAPHQLINTROSPECTION_EXPORT ~InputValue(); -}; - -class EnumValue - : public service::Object -{ -private: - service::AwaitableResolver resolveName(service::ResolverParams&& params) const; - service::AwaitableResolver resolveDescription(service::ResolverParams&& params) const; - service::AwaitableResolver resolveIsDeprecated(service::ResolverParams&& params) const; - service::AwaitableResolver resolveDeprecationReason(service::ResolverParams&& params) const; - - service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; - - struct Concept - { - virtual ~Concept() = default; - - virtual service::FieldResult getName(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getDescription(service::FieldParams&& params) const = 0; - virtual service::FieldResult getIsDeprecated(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getDeprecationReason(service::FieldParams&& params) const = 0; - }; - - template - struct Model - : Concept - { - Model(std::shared_ptr&& pimpl) noexcept - : _pimpl { std::move(pimpl) } - { - } - - service::FieldResult getName(service::FieldParams&&) const final - { - return { _pimpl->getName() }; - } - - service::FieldResult> getDescription(service::FieldParams&&) const final - { - return { _pimpl->getDescription() }; - } - - service::FieldResult getIsDeprecated(service::FieldParams&&) const final - { - return { _pimpl->getIsDeprecated() }; - } - - service::FieldResult> getDeprecationReason(service::FieldParams&&) const final - { - return { _pimpl->getDeprecationReason() }; - } - - private: - const std::shared_ptr _pimpl; - }; - - const std::unique_ptr _pimpl; - - service::TypeNames getTypeNames() const noexcept; - service::ResolverMap getResolvers() const noexcept; - -public: - GRAPHQLINTROSPECTION_EXPORT EnumValue(std::shared_ptr pimpl) noexcept; - GRAPHQLINTROSPECTION_EXPORT ~EnumValue(); -}; - -class Directive - : public service::Object -{ -private: - service::AwaitableResolver resolveName(service::ResolverParams&& params) const; - service::AwaitableResolver resolveDescription(service::ResolverParams&& params) const; - service::AwaitableResolver resolveLocations(service::ResolverParams&& params) const; - service::AwaitableResolver resolveArgs(service::ResolverParams&& params) const; - - service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; - - struct Concept - { - virtual ~Concept() = default; - - virtual service::FieldResult getName(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getDescription(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getLocations(service::FieldParams&& params) const = 0; - virtual service::FieldResult>> getArgs(service::FieldParams&& params) const = 0; - }; - - template - struct Model - : Concept - { - Model(std::shared_ptr&& pimpl) noexcept - : _pimpl { std::move(pimpl) } - { - } - - service::FieldResult getName(service::FieldParams&&) const final - { - return { _pimpl->getName() }; - } - - service::FieldResult> getDescription(service::FieldParams&&) const final - { - return { _pimpl->getDescription() }; - } - - service::FieldResult> getLocations(service::FieldParams&&) const final - { - return { _pimpl->getLocations() }; - } - - service::FieldResult>> getArgs(service::FieldParams&&) const final - { - return { _pimpl->getArgs() }; - } - - private: - const std::shared_ptr _pimpl; - }; - - const std::unique_ptr _pimpl; - - service::TypeNames getTypeNames() const noexcept; - service::ResolverMap getResolvers() const noexcept; - -public: - GRAPHQLINTROSPECTION_EXPORT Directive(std::shared_ptr pimpl) noexcept; - GRAPHQLINTROSPECTION_EXPORT ~Directive(); -}; - } // namespace object +void AddSchemaDetails(const std::shared_ptr& typeSchema, const std::shared_ptr& schema); +void AddTypeDetails(const std::shared_ptr& typeType, const std::shared_ptr& schema); +void AddFieldDetails(const std::shared_ptr& typeField, const std::shared_ptr& schema); +void AddInputValueDetails(const std::shared_ptr& typeInputValue, const std::shared_ptr& schema); +void AddEnumValueDetails(const std::shared_ptr& typeEnumValue, const std::shared_ptr& schema); +void AddDirectiveDetails(const std::shared_ptr& typeDirective, const std::shared_ptr& schema); + GRAPHQLINTROSPECTION_EXPORT void AddTypesToSchema(const std::shared_ptr& schema); } // namespace introspection diff --git a/include/graphqlservice/introspection/SchemaObject.h b/include/graphqlservice/introspection/SchemaObject.h new file mode 100644 index 00000000..1c982eea --- /dev/null +++ b/include/graphqlservice/introspection/SchemaObject.h @@ -0,0 +1,163 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// WARNING! Do not edit this file manually, your changes will be overwritten. + +#pragma once + +#ifndef SCHEMAOBJECT_H +#define SCHEMAOBJECT_H + +#include "IntrospectionSchema.h" + +namespace graphql::introspection::object { +namespace methods::SchemaHas { + +template +concept getTypesWithParams = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult>> { impl.getTypes(std::move(params)) } }; +}; + +template +concept getTypes = requires (TImpl impl) +{ + { service::FieldResult>> { impl.getTypes() } }; +}; + +template +concept getQueryTypeWithParams = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult> { impl.getQueryType(std::move(params)) } }; +}; + +template +concept getQueryType = requires (TImpl impl) +{ + { service::FieldResult> { impl.getQueryType() } }; +}; + +template +concept getMutationTypeWithParams = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult> { impl.getMutationType(std::move(params)) } }; +}; + +template +concept getMutationType = requires (TImpl impl) +{ + { service::FieldResult> { impl.getMutationType() } }; +}; + +template +concept getSubscriptionTypeWithParams = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult> { impl.getSubscriptionType(std::move(params)) } }; +}; + +template +concept getSubscriptionType = requires (TImpl impl) +{ + { service::FieldResult> { impl.getSubscriptionType() } }; +}; + +template +concept getDirectivesWithParams = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult>> { impl.getDirectives(std::move(params)) } }; +}; + +template +concept getDirectives = requires (TImpl impl) +{ + { service::FieldResult>> { impl.getDirectives() } }; +}; + +template +concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.beginSelectionSet(params) }; +}; + +template +concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.endSelectionSet(params) }; +}; + +} // namespace methods::SchemaHas + +class Schema + : public service::Object +{ +private: + service::AwaitableResolver resolveTypes(service::ResolverParams&& params) const; + service::AwaitableResolver resolveQueryType(service::ResolverParams&& params) const; + service::AwaitableResolver resolveMutationType(service::ResolverParams&& params) const; + service::AwaitableResolver resolveSubscriptionType(service::ResolverParams&& params) const; + service::AwaitableResolver resolveDirectives(service::ResolverParams&& params) const; + + service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; + + struct Concept + { + virtual ~Concept() = default; + + virtual service::FieldResult>> getTypes(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getQueryType(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getMutationType(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getSubscriptionType(service::FieldParams&& params) const = 0; + virtual service::FieldResult>> getDirectives(service::FieldParams&& params) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::FieldResult>> getTypes(service::FieldParams&&) const final + { + return { _pimpl->getTypes() }; + } + + service::FieldResult> getQueryType(service::FieldParams&&) const final + { + return { _pimpl->getQueryType() }; + } + + service::FieldResult> getMutationType(service::FieldParams&&) const final + { + return { _pimpl->getMutationType() }; + } + + service::FieldResult> getSubscriptionType(service::FieldParams&&) const final + { + return { _pimpl->getSubscriptionType() }; + } + + service::FieldResult>> getDirectives(service::FieldParams&&) const final + { + return { _pimpl->getDirectives() }; + } + + private: + const std::shared_ptr _pimpl; + }; + + const std::unique_ptr _pimpl; + + service::TypeNames getTypeNames() const noexcept; + service::ResolverMap getResolvers() const noexcept; + +public: + GRAPHQLINTROSPECTION_EXPORT Schema(std::shared_ptr pimpl) noexcept; + GRAPHQLINTROSPECTION_EXPORT ~Schema(); +}; + +} // namespace graphql::introspection::object + +#endif // SCHEMAOBJECT_H diff --git a/include/graphqlservice/introspection/TypeObject.h b/include/graphqlservice/introspection/TypeObject.h new file mode 100644 index 00000000..164f4165 --- /dev/null +++ b/include/graphqlservice/introspection/TypeObject.h @@ -0,0 +1,239 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// WARNING! Do not edit this file manually, your changes will be overwritten. + +#pragma once + +#ifndef TYPEOBJECT_H +#define TYPEOBJECT_H + +#include "IntrospectionSchema.h" + +namespace graphql::introspection::object { +namespace methods::TypeHas { + +template +concept getKindWithParams = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult { impl.getKind(std::move(params)) } }; +}; + +template +concept getKind = requires (TImpl impl) +{ + { service::FieldResult { impl.getKind() } }; +}; + +template +concept getNameWithParams = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult> { impl.getName(std::move(params)) } }; +}; + +template +concept getName = requires (TImpl impl) +{ + { service::FieldResult> { impl.getName() } }; +}; + +template +concept getDescriptionWithParams = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult> { impl.getDescription(std::move(params)) } }; +}; + +template +concept getDescription = requires (TImpl impl) +{ + { service::FieldResult> { impl.getDescription() } }; +}; + +template +concept getFieldsWithParams = requires (TImpl impl, service::FieldParams params, std::optional includeDeprecatedArg) +{ + { service::FieldResult>>> { impl.getFields(std::move(params), std::move(includeDeprecatedArg)) } }; +}; + +template +concept getFields = requires (TImpl impl, std::optional includeDeprecatedArg) +{ + { service::FieldResult>>> { impl.getFields(std::move(includeDeprecatedArg)) } }; +}; + +template +concept getInterfacesWithParams = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult>>> { impl.getInterfaces(std::move(params)) } }; +}; + +template +concept getInterfaces = requires (TImpl impl) +{ + { service::FieldResult>>> { impl.getInterfaces() } }; +}; + +template +concept getPossibleTypesWithParams = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult>>> { impl.getPossibleTypes(std::move(params)) } }; +}; + +template +concept getPossibleTypes = requires (TImpl impl) +{ + { service::FieldResult>>> { impl.getPossibleTypes() } }; +}; + +template +concept getEnumValuesWithParams = requires (TImpl impl, service::FieldParams params, std::optional includeDeprecatedArg) +{ + { service::FieldResult>>> { impl.getEnumValues(std::move(params), std::move(includeDeprecatedArg)) } }; +}; + +template +concept getEnumValues = requires (TImpl impl, std::optional includeDeprecatedArg) +{ + { service::FieldResult>>> { impl.getEnumValues(std::move(includeDeprecatedArg)) } }; +}; + +template +concept getInputFieldsWithParams = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult>>> { impl.getInputFields(std::move(params)) } }; +}; + +template +concept getInputFields = requires (TImpl impl) +{ + { service::FieldResult>>> { impl.getInputFields() } }; +}; + +template +concept getOfTypeWithParams = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult> { impl.getOfType(std::move(params)) } }; +}; + +template +concept getOfType = requires (TImpl impl) +{ + { service::FieldResult> { impl.getOfType() } }; +}; + +template +concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.beginSelectionSet(params) }; +}; + +template +concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.endSelectionSet(params) }; +}; + +} // namespace methods::TypeHas + +class Type + : public service::Object +{ +private: + service::AwaitableResolver resolveKind(service::ResolverParams&& params) const; + service::AwaitableResolver resolveName(service::ResolverParams&& params) const; + service::AwaitableResolver resolveDescription(service::ResolverParams&& params) const; + service::AwaitableResolver resolveFields(service::ResolverParams&& params) const; + service::AwaitableResolver resolveInterfaces(service::ResolverParams&& params) const; + service::AwaitableResolver resolvePossibleTypes(service::ResolverParams&& params) const; + service::AwaitableResolver resolveEnumValues(service::ResolverParams&& params) const; + service::AwaitableResolver resolveInputFields(service::ResolverParams&& params) const; + service::AwaitableResolver resolveOfType(service::ResolverParams&& params) const; + + service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; + + struct Concept + { + virtual ~Concept() = default; + + virtual service::FieldResult getKind(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getName(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getDescription(service::FieldParams&& params) const = 0; + virtual service::FieldResult>>> getFields(service::FieldParams&& params, std::optional&& includeDeprecatedArg) const = 0; + virtual service::FieldResult>>> getInterfaces(service::FieldParams&& params) const = 0; + virtual service::FieldResult>>> getPossibleTypes(service::FieldParams&& params) const = 0; + virtual service::FieldResult>>> getEnumValues(service::FieldParams&& params, std::optional&& includeDeprecatedArg) const = 0; + virtual service::FieldResult>>> getInputFields(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getOfType(service::FieldParams&& params) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::FieldResult getKind(service::FieldParams&&) const final + { + return { _pimpl->getKind() }; + } + + service::FieldResult> getName(service::FieldParams&&) const final + { + return { _pimpl->getName() }; + } + + service::FieldResult> getDescription(service::FieldParams&&) const final + { + return { _pimpl->getDescription() }; + } + + service::FieldResult>>> getFields(service::FieldParams&&, std::optional&& includeDeprecatedArg) const final + { + return { _pimpl->getFields(std::move(includeDeprecatedArg)) }; + } + + service::FieldResult>>> getInterfaces(service::FieldParams&&) const final + { + return { _pimpl->getInterfaces() }; + } + + service::FieldResult>>> getPossibleTypes(service::FieldParams&&) const final + { + return { _pimpl->getPossibleTypes() }; + } + + service::FieldResult>>> getEnumValues(service::FieldParams&&, std::optional&& includeDeprecatedArg) const final + { + return { _pimpl->getEnumValues(std::move(includeDeprecatedArg)) }; + } + + service::FieldResult>>> getInputFields(service::FieldParams&&) const final + { + return { _pimpl->getInputFields() }; + } + + service::FieldResult> getOfType(service::FieldParams&&) const final + { + return { _pimpl->getOfType() }; + } + + private: + const std::shared_ptr _pimpl; + }; + + const std::unique_ptr _pimpl; + + service::TypeNames getTypeNames() const noexcept; + service::ResolverMap getResolvers() const noexcept; + +public: + GRAPHQLINTROSPECTION_EXPORT Type(std::shared_ptr pimpl) noexcept; + GRAPHQLINTROSPECTION_EXPORT ~Type(); +}; + +} // namespace graphql::introspection::object + +#endif // TYPEOBJECT_H diff --git a/samples/learn/schema/CharacterObject.cpp b/samples/learn/schema/CharacterObject.cpp index c4d361b0..3af5cfcb 100644 --- a/samples/learn/schema/CharacterObject.cpp +++ b/samples/learn/schema/CharacterObject.cpp @@ -5,7 +5,9 @@ #include "CharacterObject.h" -#include "graphqlservice/introspection/Introspection.h" +#include "graphqlservice/internal/Schema.h" + +#include "graphqlservice/introspection/IntrospectionSchema.h" using namespace std::literals; diff --git a/samples/learn/schema/DroidObject.cpp b/samples/learn/schema/DroidObject.cpp index 33ab5986..16fb273c 100644 --- a/samples/learn/schema/DroidObject.cpp +++ b/samples/learn/schema/DroidObject.cpp @@ -6,7 +6,9 @@ #include "DroidObject.h" #include "CharacterObject.h" -#include "graphqlservice/introspection/Introspection.h" +#include "graphqlservice/internal/Schema.h" + +#include "graphqlservice/introspection/IntrospectionSchema.h" #include #include diff --git a/samples/learn/schema/HumanObject.cpp b/samples/learn/schema/HumanObject.cpp index ade5dd79..0bf1cbbd 100644 --- a/samples/learn/schema/HumanObject.cpp +++ b/samples/learn/schema/HumanObject.cpp @@ -6,7 +6,9 @@ #include "HumanObject.h" #include "CharacterObject.h" -#include "graphqlservice/introspection/Introspection.h" +#include "graphqlservice/internal/Schema.h" + +#include "graphqlservice/introspection/IntrospectionSchema.h" #include #include diff --git a/samples/learn/schema/MutationObject.cpp b/samples/learn/schema/MutationObject.cpp index c93ea1b2..874c1218 100644 --- a/samples/learn/schema/MutationObject.cpp +++ b/samples/learn/schema/MutationObject.cpp @@ -6,7 +6,9 @@ #include "MutationObject.h" #include "ReviewObject.h" -#include "graphqlservice/introspection/Introspection.h" +#include "graphqlservice/internal/Schema.h" + +#include "graphqlservice/introspection/IntrospectionSchema.h" #include #include diff --git a/samples/learn/schema/QueryObject.cpp b/samples/learn/schema/QueryObject.cpp index b1e331b5..5b822b0f 100644 --- a/samples/learn/schema/QueryObject.cpp +++ b/samples/learn/schema/QueryObject.cpp @@ -8,7 +8,10 @@ #include "HumanObject.h" #include "DroidObject.h" -#include "graphqlservice/introspection/Introspection.h" +#include "graphqlservice/internal/Introspection.h" + +#include "graphqlservice/introspection/SchemaObject.h" +#include "graphqlservice/introspection/TypeObject.h" #include #include diff --git a/samples/learn/schema/ReviewObject.cpp b/samples/learn/schema/ReviewObject.cpp index 07f604f1..3c6fc43e 100644 --- a/samples/learn/schema/ReviewObject.cpp +++ b/samples/learn/schema/ReviewObject.cpp @@ -5,7 +5,9 @@ #include "ReviewObject.h" -#include "graphqlservice/introspection/Introspection.h" +#include "graphqlservice/internal/Schema.h" + +#include "graphqlservice/introspection/IntrospectionSchema.h" #include #include diff --git a/samples/learn/schema/StarWarsSchema.cpp b/samples/learn/schema/StarWarsSchema.cpp index 235d6561..c5186dc7 100644 --- a/samples/learn/schema/StarWarsSchema.cpp +++ b/samples/learn/schema/StarWarsSchema.cpp @@ -6,7 +6,10 @@ #include "QueryObject.h" #include "MutationObject.h" -#include "graphqlservice/introspection/Introspection.h" + +#include "graphqlservice/internal/Schema.h" + +#include "graphqlservice/introspection/IntrospectionSchema.h" #include #include diff --git a/samples/today/nointrospection/AppointmentConnectionObject.cpp b/samples/today/nointrospection/AppointmentConnectionObject.cpp index acb05f2c..19842a49 100644 --- a/samples/today/nointrospection/AppointmentConnectionObject.cpp +++ b/samples/today/nointrospection/AppointmentConnectionObject.cpp @@ -7,7 +7,9 @@ #include "PageInfoObject.h" #include "AppointmentEdgeObject.h" -#include "graphqlservice/introspection/Introspection.h" +#include "graphqlservice/internal/Schema.h" + +#include "graphqlservice/introspection/IntrospectionSchema.h" #include #include diff --git a/samples/today/nointrospection/AppointmentEdgeObject.cpp b/samples/today/nointrospection/AppointmentEdgeObject.cpp index 4daf5740..ea507e43 100644 --- a/samples/today/nointrospection/AppointmentEdgeObject.cpp +++ b/samples/today/nointrospection/AppointmentEdgeObject.cpp @@ -6,7 +6,9 @@ #include "AppointmentEdgeObject.h" #include "AppointmentObject.h" -#include "graphqlservice/introspection/Introspection.h" +#include "graphqlservice/internal/Schema.h" + +#include "graphqlservice/introspection/IntrospectionSchema.h" #include #include diff --git a/samples/today/nointrospection/AppointmentObject.cpp b/samples/today/nointrospection/AppointmentObject.cpp index 63748bd1..474ee49b 100644 --- a/samples/today/nointrospection/AppointmentObject.cpp +++ b/samples/today/nointrospection/AppointmentObject.cpp @@ -5,7 +5,9 @@ #include "AppointmentObject.h" -#include "graphqlservice/introspection/Introspection.h" +#include "graphqlservice/internal/Schema.h" + +#include "graphqlservice/introspection/IntrospectionSchema.h" #include #include diff --git a/samples/today/nointrospection/CompleteTaskPayloadObject.cpp b/samples/today/nointrospection/CompleteTaskPayloadObject.cpp index ccba911f..bccfeca8 100644 --- a/samples/today/nointrospection/CompleteTaskPayloadObject.cpp +++ b/samples/today/nointrospection/CompleteTaskPayloadObject.cpp @@ -6,7 +6,9 @@ #include "CompleteTaskPayloadObject.h" #include "TaskObject.h" -#include "graphqlservice/introspection/Introspection.h" +#include "graphqlservice/internal/Schema.h" + +#include "graphqlservice/introspection/IntrospectionSchema.h" #include #include diff --git a/samples/today/nointrospection/ExpensiveObject.cpp b/samples/today/nointrospection/ExpensiveObject.cpp index 76ec6277..55268ab3 100644 --- a/samples/today/nointrospection/ExpensiveObject.cpp +++ b/samples/today/nointrospection/ExpensiveObject.cpp @@ -5,7 +5,9 @@ #include "ExpensiveObject.h" -#include "graphqlservice/introspection/Introspection.h" +#include "graphqlservice/internal/Schema.h" + +#include "graphqlservice/introspection/IntrospectionSchema.h" #include #include diff --git a/samples/today/nointrospection/FolderConnectionObject.cpp b/samples/today/nointrospection/FolderConnectionObject.cpp index 64d3a6f9..8008268e 100644 --- a/samples/today/nointrospection/FolderConnectionObject.cpp +++ b/samples/today/nointrospection/FolderConnectionObject.cpp @@ -7,7 +7,9 @@ #include "PageInfoObject.h" #include "FolderEdgeObject.h" -#include "graphqlservice/introspection/Introspection.h" +#include "graphqlservice/internal/Schema.h" + +#include "graphqlservice/introspection/IntrospectionSchema.h" #include #include diff --git a/samples/today/nointrospection/FolderEdgeObject.cpp b/samples/today/nointrospection/FolderEdgeObject.cpp index fd54275c..b26cb3b0 100644 --- a/samples/today/nointrospection/FolderEdgeObject.cpp +++ b/samples/today/nointrospection/FolderEdgeObject.cpp @@ -6,7 +6,9 @@ #include "FolderEdgeObject.h" #include "FolderObject.h" -#include "graphqlservice/introspection/Introspection.h" +#include "graphqlservice/internal/Schema.h" + +#include "graphqlservice/introspection/IntrospectionSchema.h" #include #include diff --git a/samples/today/nointrospection/FolderObject.cpp b/samples/today/nointrospection/FolderObject.cpp index 85cf4a6a..700f5414 100644 --- a/samples/today/nointrospection/FolderObject.cpp +++ b/samples/today/nointrospection/FolderObject.cpp @@ -5,7 +5,9 @@ #include "FolderObject.h" -#include "graphqlservice/introspection/Introspection.h" +#include "graphqlservice/internal/Schema.h" + +#include "graphqlservice/introspection/IntrospectionSchema.h" #include #include diff --git a/samples/today/nointrospection/MutationObject.cpp b/samples/today/nointrospection/MutationObject.cpp index 703e2aa2..97241a03 100644 --- a/samples/today/nointrospection/MutationObject.cpp +++ b/samples/today/nointrospection/MutationObject.cpp @@ -6,7 +6,9 @@ #include "MutationObject.h" #include "CompleteTaskPayloadObject.h" -#include "graphqlservice/introspection/Introspection.h" +#include "graphqlservice/internal/Schema.h" + +#include "graphqlservice/introspection/IntrospectionSchema.h" #include #include diff --git a/samples/today/nointrospection/NestedTypeObject.cpp b/samples/today/nointrospection/NestedTypeObject.cpp index 3574d829..1bb57acd 100644 --- a/samples/today/nointrospection/NestedTypeObject.cpp +++ b/samples/today/nointrospection/NestedTypeObject.cpp @@ -6,7 +6,9 @@ #include "NestedTypeObject.h" #include "NestedTypeObject.h" -#include "graphqlservice/introspection/Introspection.h" +#include "graphqlservice/internal/Schema.h" + +#include "graphqlservice/introspection/IntrospectionSchema.h" #include #include diff --git a/samples/today/nointrospection/NodeObject.cpp b/samples/today/nointrospection/NodeObject.cpp index eb0a6dcc..93d80e05 100644 --- a/samples/today/nointrospection/NodeObject.cpp +++ b/samples/today/nointrospection/NodeObject.cpp @@ -5,7 +5,9 @@ #include "NodeObject.h" -#include "graphqlservice/introspection/Introspection.h" +#include "graphqlservice/internal/Schema.h" + +#include "graphqlservice/introspection/IntrospectionSchema.h" using namespace std::literals; diff --git a/samples/today/nointrospection/PageInfoObject.cpp b/samples/today/nointrospection/PageInfoObject.cpp index 9c6412af..b271ead9 100644 --- a/samples/today/nointrospection/PageInfoObject.cpp +++ b/samples/today/nointrospection/PageInfoObject.cpp @@ -5,7 +5,9 @@ #include "PageInfoObject.h" -#include "graphqlservice/introspection/Introspection.h" +#include "graphqlservice/internal/Schema.h" + +#include "graphqlservice/introspection/IntrospectionSchema.h" #include #include diff --git a/samples/today/nointrospection/QueryObject.cpp b/samples/today/nointrospection/QueryObject.cpp index 701cb42e..78a38d73 100644 --- a/samples/today/nointrospection/QueryObject.cpp +++ b/samples/today/nointrospection/QueryObject.cpp @@ -15,7 +15,9 @@ #include "ExpensiveObject.h" #include "UnionTypeObject.h" -#include "graphqlservice/introspection/Introspection.h" +#include "graphqlservice/internal/Schema.h" + +#include "graphqlservice/introspection/IntrospectionSchema.h" #include #include diff --git a/samples/today/nointrospection/SubscriptionObject.cpp b/samples/today/nointrospection/SubscriptionObject.cpp index 6c936e6a..ac6013b3 100644 --- a/samples/today/nointrospection/SubscriptionObject.cpp +++ b/samples/today/nointrospection/SubscriptionObject.cpp @@ -7,7 +7,9 @@ #include "AppointmentObject.h" #include "NodeObject.h" -#include "graphqlservice/introspection/Introspection.h" +#include "graphqlservice/internal/Schema.h" + +#include "graphqlservice/introspection/IntrospectionSchema.h" #include #include diff --git a/samples/today/nointrospection/TaskConnectionObject.cpp b/samples/today/nointrospection/TaskConnectionObject.cpp index 5231eb62..27c0c6b4 100644 --- a/samples/today/nointrospection/TaskConnectionObject.cpp +++ b/samples/today/nointrospection/TaskConnectionObject.cpp @@ -7,7 +7,9 @@ #include "PageInfoObject.h" #include "TaskEdgeObject.h" -#include "graphqlservice/introspection/Introspection.h" +#include "graphqlservice/internal/Schema.h" + +#include "graphqlservice/introspection/IntrospectionSchema.h" #include #include diff --git a/samples/today/nointrospection/TaskEdgeObject.cpp b/samples/today/nointrospection/TaskEdgeObject.cpp index 3e58f857..6780e548 100644 --- a/samples/today/nointrospection/TaskEdgeObject.cpp +++ b/samples/today/nointrospection/TaskEdgeObject.cpp @@ -6,7 +6,9 @@ #include "TaskEdgeObject.h" #include "TaskObject.h" -#include "graphqlservice/introspection/Introspection.h" +#include "graphqlservice/internal/Schema.h" + +#include "graphqlservice/introspection/IntrospectionSchema.h" #include #include diff --git a/samples/today/nointrospection/TaskObject.cpp b/samples/today/nointrospection/TaskObject.cpp index 8c719282..578ea5bf 100644 --- a/samples/today/nointrospection/TaskObject.cpp +++ b/samples/today/nointrospection/TaskObject.cpp @@ -5,7 +5,9 @@ #include "TaskObject.h" -#include "graphqlservice/introspection/Introspection.h" +#include "graphqlservice/internal/Schema.h" + +#include "graphqlservice/introspection/IntrospectionSchema.h" #include #include diff --git a/samples/today/nointrospection/TodaySchema.cpp b/samples/today/nointrospection/TodaySchema.cpp index c9558b01..c767a52b 100644 --- a/samples/today/nointrospection/TodaySchema.cpp +++ b/samples/today/nointrospection/TodaySchema.cpp @@ -7,7 +7,10 @@ #include "MutationObject.h" #include "SubscriptionObject.h" -#include "graphqlservice/introspection/Introspection.h" + +#include "graphqlservice/internal/Schema.h" + +#include "graphqlservice/introspection/IntrospectionSchema.h" #include #include diff --git a/samples/today/nointrospection/UnionTypeObject.cpp b/samples/today/nointrospection/UnionTypeObject.cpp index 7e3f0874..7955b900 100644 --- a/samples/today/nointrospection/UnionTypeObject.cpp +++ b/samples/today/nointrospection/UnionTypeObject.cpp @@ -5,7 +5,9 @@ #include "UnionTypeObject.h" -#include "graphqlservice/introspection/Introspection.h" +#include "graphqlservice/internal/Schema.h" + +#include "graphqlservice/introspection/IntrospectionSchema.h" using namespace std::literals; diff --git a/samples/today/schema/AppointmentConnectionObject.cpp b/samples/today/schema/AppointmentConnectionObject.cpp index acb05f2c..19842a49 100644 --- a/samples/today/schema/AppointmentConnectionObject.cpp +++ b/samples/today/schema/AppointmentConnectionObject.cpp @@ -7,7 +7,9 @@ #include "PageInfoObject.h" #include "AppointmentEdgeObject.h" -#include "graphqlservice/introspection/Introspection.h" +#include "graphqlservice/internal/Schema.h" + +#include "graphqlservice/introspection/IntrospectionSchema.h" #include #include diff --git a/samples/today/schema/AppointmentEdgeObject.cpp b/samples/today/schema/AppointmentEdgeObject.cpp index 4daf5740..ea507e43 100644 --- a/samples/today/schema/AppointmentEdgeObject.cpp +++ b/samples/today/schema/AppointmentEdgeObject.cpp @@ -6,7 +6,9 @@ #include "AppointmentEdgeObject.h" #include "AppointmentObject.h" -#include "graphqlservice/introspection/Introspection.h" +#include "graphqlservice/internal/Schema.h" + +#include "graphqlservice/introspection/IntrospectionSchema.h" #include #include diff --git a/samples/today/schema/AppointmentObject.cpp b/samples/today/schema/AppointmentObject.cpp index 63748bd1..474ee49b 100644 --- a/samples/today/schema/AppointmentObject.cpp +++ b/samples/today/schema/AppointmentObject.cpp @@ -5,7 +5,9 @@ #include "AppointmentObject.h" -#include "graphqlservice/introspection/Introspection.h" +#include "graphqlservice/internal/Schema.h" + +#include "graphqlservice/introspection/IntrospectionSchema.h" #include #include diff --git a/samples/today/schema/CompleteTaskPayloadObject.cpp b/samples/today/schema/CompleteTaskPayloadObject.cpp index ccba911f..bccfeca8 100644 --- a/samples/today/schema/CompleteTaskPayloadObject.cpp +++ b/samples/today/schema/CompleteTaskPayloadObject.cpp @@ -6,7 +6,9 @@ #include "CompleteTaskPayloadObject.h" #include "TaskObject.h" -#include "graphqlservice/introspection/Introspection.h" +#include "graphqlservice/internal/Schema.h" + +#include "graphqlservice/introspection/IntrospectionSchema.h" #include #include diff --git a/samples/today/schema/ExpensiveObject.cpp b/samples/today/schema/ExpensiveObject.cpp index 76ec6277..55268ab3 100644 --- a/samples/today/schema/ExpensiveObject.cpp +++ b/samples/today/schema/ExpensiveObject.cpp @@ -5,7 +5,9 @@ #include "ExpensiveObject.h" -#include "graphqlservice/introspection/Introspection.h" +#include "graphqlservice/internal/Schema.h" + +#include "graphqlservice/introspection/IntrospectionSchema.h" #include #include diff --git a/samples/today/schema/FolderConnectionObject.cpp b/samples/today/schema/FolderConnectionObject.cpp index 64d3a6f9..8008268e 100644 --- a/samples/today/schema/FolderConnectionObject.cpp +++ b/samples/today/schema/FolderConnectionObject.cpp @@ -7,7 +7,9 @@ #include "PageInfoObject.h" #include "FolderEdgeObject.h" -#include "graphqlservice/introspection/Introspection.h" +#include "graphqlservice/internal/Schema.h" + +#include "graphqlservice/introspection/IntrospectionSchema.h" #include #include diff --git a/samples/today/schema/FolderEdgeObject.cpp b/samples/today/schema/FolderEdgeObject.cpp index fd54275c..b26cb3b0 100644 --- a/samples/today/schema/FolderEdgeObject.cpp +++ b/samples/today/schema/FolderEdgeObject.cpp @@ -6,7 +6,9 @@ #include "FolderEdgeObject.h" #include "FolderObject.h" -#include "graphqlservice/introspection/Introspection.h" +#include "graphqlservice/internal/Schema.h" + +#include "graphqlservice/introspection/IntrospectionSchema.h" #include #include diff --git a/samples/today/schema/FolderObject.cpp b/samples/today/schema/FolderObject.cpp index 85cf4a6a..700f5414 100644 --- a/samples/today/schema/FolderObject.cpp +++ b/samples/today/schema/FolderObject.cpp @@ -5,7 +5,9 @@ #include "FolderObject.h" -#include "graphqlservice/introspection/Introspection.h" +#include "graphqlservice/internal/Schema.h" + +#include "graphqlservice/introspection/IntrospectionSchema.h" #include #include diff --git a/samples/today/schema/MutationObject.cpp b/samples/today/schema/MutationObject.cpp index 703e2aa2..97241a03 100644 --- a/samples/today/schema/MutationObject.cpp +++ b/samples/today/schema/MutationObject.cpp @@ -6,7 +6,9 @@ #include "MutationObject.h" #include "CompleteTaskPayloadObject.h" -#include "graphqlservice/introspection/Introspection.h" +#include "graphqlservice/internal/Schema.h" + +#include "graphqlservice/introspection/IntrospectionSchema.h" #include #include diff --git a/samples/today/schema/NestedTypeObject.cpp b/samples/today/schema/NestedTypeObject.cpp index c3a52e5e..c22c6cb5 100644 --- a/samples/today/schema/NestedTypeObject.cpp +++ b/samples/today/schema/NestedTypeObject.cpp @@ -6,7 +6,9 @@ #include "NestedTypeObject.h" #include "NestedTypeObject.h" -#include "graphqlservice/introspection/Introspection.h" +#include "graphqlservice/internal/Schema.h" + +#include "graphqlservice/introspection/IntrospectionSchema.h" #include #include diff --git a/samples/today/schema/NodeObject.cpp b/samples/today/schema/NodeObject.cpp index eb0a6dcc..93d80e05 100644 --- a/samples/today/schema/NodeObject.cpp +++ b/samples/today/schema/NodeObject.cpp @@ -5,7 +5,9 @@ #include "NodeObject.h" -#include "graphqlservice/introspection/Introspection.h" +#include "graphqlservice/internal/Schema.h" + +#include "graphqlservice/introspection/IntrospectionSchema.h" using namespace std::literals; diff --git a/samples/today/schema/PageInfoObject.cpp b/samples/today/schema/PageInfoObject.cpp index 9c6412af..b271ead9 100644 --- a/samples/today/schema/PageInfoObject.cpp +++ b/samples/today/schema/PageInfoObject.cpp @@ -5,7 +5,9 @@ #include "PageInfoObject.h" -#include "graphqlservice/introspection/Introspection.h" +#include "graphqlservice/internal/Schema.h" + +#include "graphqlservice/introspection/IntrospectionSchema.h" #include #include diff --git a/samples/today/schema/QueryObject.cpp b/samples/today/schema/QueryObject.cpp index d3460dc0..1bcbfbb0 100644 --- a/samples/today/schema/QueryObject.cpp +++ b/samples/today/schema/QueryObject.cpp @@ -15,7 +15,10 @@ #include "ExpensiveObject.h" #include "UnionTypeObject.h" -#include "graphqlservice/introspection/Introspection.h" +#include "graphqlservice/internal/Introspection.h" + +#include "graphqlservice/introspection/SchemaObject.h" +#include "graphqlservice/introspection/TypeObject.h" #include #include diff --git a/samples/today/schema/SubscriptionObject.cpp b/samples/today/schema/SubscriptionObject.cpp index 6c936e6a..ac6013b3 100644 --- a/samples/today/schema/SubscriptionObject.cpp +++ b/samples/today/schema/SubscriptionObject.cpp @@ -7,7 +7,9 @@ #include "AppointmentObject.h" #include "NodeObject.h" -#include "graphqlservice/introspection/Introspection.h" +#include "graphqlservice/internal/Schema.h" + +#include "graphqlservice/introspection/IntrospectionSchema.h" #include #include diff --git a/samples/today/schema/TaskConnectionObject.cpp b/samples/today/schema/TaskConnectionObject.cpp index 5231eb62..27c0c6b4 100644 --- a/samples/today/schema/TaskConnectionObject.cpp +++ b/samples/today/schema/TaskConnectionObject.cpp @@ -7,7 +7,9 @@ #include "PageInfoObject.h" #include "TaskEdgeObject.h" -#include "graphqlservice/introspection/Introspection.h" +#include "graphqlservice/internal/Schema.h" + +#include "graphqlservice/introspection/IntrospectionSchema.h" #include #include diff --git a/samples/today/schema/TaskEdgeObject.cpp b/samples/today/schema/TaskEdgeObject.cpp index 3e58f857..6780e548 100644 --- a/samples/today/schema/TaskEdgeObject.cpp +++ b/samples/today/schema/TaskEdgeObject.cpp @@ -6,7 +6,9 @@ #include "TaskEdgeObject.h" #include "TaskObject.h" -#include "graphqlservice/introspection/Introspection.h" +#include "graphqlservice/internal/Schema.h" + +#include "graphqlservice/introspection/IntrospectionSchema.h" #include #include diff --git a/samples/today/schema/TaskObject.cpp b/samples/today/schema/TaskObject.cpp index 8c719282..578ea5bf 100644 --- a/samples/today/schema/TaskObject.cpp +++ b/samples/today/schema/TaskObject.cpp @@ -5,7 +5,9 @@ #include "TaskObject.h" -#include "graphqlservice/introspection/Introspection.h" +#include "graphqlservice/internal/Schema.h" + +#include "graphqlservice/introspection/IntrospectionSchema.h" #include #include diff --git a/samples/today/schema/TodaySchema.cpp b/samples/today/schema/TodaySchema.cpp index f241e2be..5b5cdd4c 100644 --- a/samples/today/schema/TodaySchema.cpp +++ b/samples/today/schema/TodaySchema.cpp @@ -7,7 +7,10 @@ #include "MutationObject.h" #include "SubscriptionObject.h" -#include "graphqlservice/introspection/Introspection.h" + +#include "graphqlservice/internal/Schema.h" + +#include "graphqlservice/introspection/IntrospectionSchema.h" #include #include diff --git a/samples/today/schema/UnionTypeObject.cpp b/samples/today/schema/UnionTypeObject.cpp index 7e3f0874..7955b900 100644 --- a/samples/today/schema/UnionTypeObject.cpp +++ b/samples/today/schema/UnionTypeObject.cpp @@ -5,7 +5,9 @@ #include "UnionTypeObject.h" -#include "graphqlservice/introspection/Introspection.h" +#include "graphqlservice/internal/Schema.h" + +#include "graphqlservice/introspection/IntrospectionSchema.h" using namespace std::literals; diff --git a/samples/validation/schema/AlienObject.cpp b/samples/validation/schema/AlienObject.cpp index 21be21f3..8e16931e 100644 --- a/samples/validation/schema/AlienObject.cpp +++ b/samples/validation/schema/AlienObject.cpp @@ -5,7 +5,9 @@ #include "AlienObject.h" -#include "graphqlservice/introspection/Introspection.h" +#include "graphqlservice/internal/Schema.h" + +#include "graphqlservice/introspection/IntrospectionSchema.h" #include #include diff --git a/samples/validation/schema/ArgumentsObject.cpp b/samples/validation/schema/ArgumentsObject.cpp index 08828077..f970c85e 100644 --- a/samples/validation/schema/ArgumentsObject.cpp +++ b/samples/validation/schema/ArgumentsObject.cpp @@ -5,7 +5,9 @@ #include "ArgumentsObject.h" -#include "graphqlservice/introspection/Introspection.h" +#include "graphqlservice/internal/Schema.h" + +#include "graphqlservice/introspection/IntrospectionSchema.h" #include #include diff --git a/samples/validation/schema/CatObject.cpp b/samples/validation/schema/CatObject.cpp index 62d3a270..893261fa 100644 --- a/samples/validation/schema/CatObject.cpp +++ b/samples/validation/schema/CatObject.cpp @@ -5,7 +5,9 @@ #include "CatObject.h" -#include "graphqlservice/introspection/Introspection.h" +#include "graphqlservice/internal/Schema.h" + +#include "graphqlservice/introspection/IntrospectionSchema.h" #include #include diff --git a/samples/validation/schema/CatOrDogObject.cpp b/samples/validation/schema/CatOrDogObject.cpp index a826efa7..2b7a4d02 100644 --- a/samples/validation/schema/CatOrDogObject.cpp +++ b/samples/validation/schema/CatOrDogObject.cpp @@ -5,7 +5,9 @@ #include "CatOrDogObject.h" -#include "graphqlservice/introspection/Introspection.h" +#include "graphqlservice/internal/Schema.h" + +#include "graphqlservice/introspection/IntrospectionSchema.h" using namespace std::literals; diff --git a/samples/validation/schema/DogObject.cpp b/samples/validation/schema/DogObject.cpp index 8ff7c70d..72c913e1 100644 --- a/samples/validation/schema/DogObject.cpp +++ b/samples/validation/schema/DogObject.cpp @@ -6,7 +6,9 @@ #include "DogObject.h" #include "HumanObject.h" -#include "graphqlservice/introspection/Introspection.h" +#include "graphqlservice/internal/Schema.h" + +#include "graphqlservice/introspection/IntrospectionSchema.h" #include #include diff --git a/samples/validation/schema/DogOrHumanObject.cpp b/samples/validation/schema/DogOrHumanObject.cpp index bfa1f525..1fac2c21 100644 --- a/samples/validation/schema/DogOrHumanObject.cpp +++ b/samples/validation/schema/DogOrHumanObject.cpp @@ -5,7 +5,9 @@ #include "DogOrHumanObject.h" -#include "graphqlservice/introspection/Introspection.h" +#include "graphqlservice/internal/Schema.h" + +#include "graphqlservice/introspection/IntrospectionSchema.h" using namespace std::literals; diff --git a/samples/validation/schema/HumanObject.cpp b/samples/validation/schema/HumanObject.cpp index 5dd1e6dd..cf243e29 100644 --- a/samples/validation/schema/HumanObject.cpp +++ b/samples/validation/schema/HumanObject.cpp @@ -6,7 +6,9 @@ #include "HumanObject.h" #include "PetObject.h" -#include "graphqlservice/introspection/Introspection.h" +#include "graphqlservice/internal/Schema.h" + +#include "graphqlservice/introspection/IntrospectionSchema.h" #include #include diff --git a/samples/validation/schema/HumanOrAlienObject.cpp b/samples/validation/schema/HumanOrAlienObject.cpp index 85af61e0..cb6f6a2a 100644 --- a/samples/validation/schema/HumanOrAlienObject.cpp +++ b/samples/validation/schema/HumanOrAlienObject.cpp @@ -5,7 +5,9 @@ #include "HumanOrAlienObject.h" -#include "graphqlservice/introspection/Introspection.h" +#include "graphqlservice/internal/Schema.h" + +#include "graphqlservice/introspection/IntrospectionSchema.h" using namespace std::literals; diff --git a/samples/validation/schema/MessageObject.cpp b/samples/validation/schema/MessageObject.cpp index d32bff5b..4fddf185 100644 --- a/samples/validation/schema/MessageObject.cpp +++ b/samples/validation/schema/MessageObject.cpp @@ -5,7 +5,9 @@ #include "MessageObject.h" -#include "graphqlservice/introspection/Introspection.h" +#include "graphqlservice/internal/Schema.h" + +#include "graphqlservice/introspection/IntrospectionSchema.h" #include #include diff --git a/samples/validation/schema/MutateDogResultObject.cpp b/samples/validation/schema/MutateDogResultObject.cpp index 3b6672ed..44f9cd26 100644 --- a/samples/validation/schema/MutateDogResultObject.cpp +++ b/samples/validation/schema/MutateDogResultObject.cpp @@ -5,7 +5,9 @@ #include "MutateDogResultObject.h" -#include "graphqlservice/introspection/Introspection.h" +#include "graphqlservice/internal/Schema.h" + +#include "graphqlservice/introspection/IntrospectionSchema.h" #include #include diff --git a/samples/validation/schema/MutationObject.cpp b/samples/validation/schema/MutationObject.cpp index e7072a7b..9a6a7cd2 100644 --- a/samples/validation/schema/MutationObject.cpp +++ b/samples/validation/schema/MutationObject.cpp @@ -6,7 +6,9 @@ #include "MutationObject.h" #include "MutateDogResultObject.h" -#include "graphqlservice/introspection/Introspection.h" +#include "graphqlservice/internal/Schema.h" + +#include "graphqlservice/introspection/IntrospectionSchema.h" #include #include diff --git a/samples/validation/schema/PetObject.cpp b/samples/validation/schema/PetObject.cpp index 4510dfdb..106161c6 100644 --- a/samples/validation/schema/PetObject.cpp +++ b/samples/validation/schema/PetObject.cpp @@ -5,7 +5,9 @@ #include "PetObject.h" -#include "graphqlservice/introspection/Introspection.h" +#include "graphqlservice/internal/Schema.h" + +#include "graphqlservice/introspection/IntrospectionSchema.h" using namespace std::literals; diff --git a/samples/validation/schema/QueryObject.cpp b/samples/validation/schema/QueryObject.cpp index cc59f797..31098673 100644 --- a/samples/validation/schema/QueryObject.cpp +++ b/samples/validation/schema/QueryObject.cpp @@ -10,7 +10,9 @@ #include "CatOrDogObject.h" #include "ArgumentsObject.h" -#include "graphqlservice/introspection/Introspection.h" +#include "graphqlservice/internal/Schema.h" + +#include "graphqlservice/introspection/IntrospectionSchema.h" #include #include diff --git a/samples/validation/schema/SentientObject.cpp b/samples/validation/schema/SentientObject.cpp index ac94bb87..656ce774 100644 --- a/samples/validation/schema/SentientObject.cpp +++ b/samples/validation/schema/SentientObject.cpp @@ -5,7 +5,9 @@ #include "SentientObject.h" -#include "graphqlservice/introspection/Introspection.h" +#include "graphqlservice/internal/Schema.h" + +#include "graphqlservice/introspection/IntrospectionSchema.h" using namespace std::literals; diff --git a/samples/validation/schema/SubscriptionObject.cpp b/samples/validation/schema/SubscriptionObject.cpp index 56693285..1e7ae9d8 100644 --- a/samples/validation/schema/SubscriptionObject.cpp +++ b/samples/validation/schema/SubscriptionObject.cpp @@ -6,7 +6,9 @@ #include "SubscriptionObject.h" #include "MessageObject.h" -#include "graphqlservice/introspection/Introspection.h" +#include "graphqlservice/internal/Schema.h" + +#include "graphqlservice/introspection/IntrospectionSchema.h" #include #include diff --git a/samples/validation/schema/ValidationSchema.cpp b/samples/validation/schema/ValidationSchema.cpp index 6fbe8498..0a098016 100644 --- a/samples/validation/schema/ValidationSchema.cpp +++ b/samples/validation/schema/ValidationSchema.cpp @@ -7,7 +7,10 @@ #include "MutationObject.h" #include "SubscriptionObject.h" -#include "graphqlservice/introspection/Introspection.h" + +#include "graphqlservice/internal/Schema.h" + +#include "graphqlservice/introspection/IntrospectionSchema.h" #include #include diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 921a1c50..15d6e0c2 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -326,19 +326,7 @@ if(GRAPHQL_BUILD_SCHEMAGEN OR GRAPHQL_BUILD_CLIENTGEN) endif() # introspection -if(GRAPHQL_UPDATE_SAMPLES) - add_custom_command( - OUTPUT updated_introspection - COMMAND schemagen --introspection - COMMAND ${CMAKE_COMMAND} -E copy_if_different IntrospectionSchema.cpp ${CMAKE_CURRENT_SOURCE_DIR} - COMMAND ${CMAKE_COMMAND} -E copy_if_different IntrospectionSchema.h ${CMAKE_CURRENT_SOURCE_DIR}/../include/graphqlservice/introspection - COMMAND ${CMAKE_COMMAND} -E touch updated_introspection - DEPENDS schemagen - COMMENT "Updating IntrospectionSchema files") - - add_custom_target(update_introspection ALL - DEPENDS updated_introspection) -endif() +add_subdirectory(introspection) # graphqlservice add_library(graphqlservice @@ -354,7 +342,7 @@ target_link_libraries(graphqlservice PUBLIC if(GRAPHQL_UPDATE_SAMPLES) # Even though this target doesn't build IntrospectionSchema.cpp, it still # depends on IntrospectionSchema.h for some enum definitions. - add_dependencies(graphqlservice update_introspection) + add_dependencies(graphqlservice update_introspection_headers) endif() if(GRAPHQL_UPDATE_VERSION) @@ -370,9 +358,8 @@ if(WIN32 AND BUILD_SHARED_LIBS) endif() # graphqlintrospection -add_library(graphqlintrospection - Introspection.cpp - IntrospectionSchema.cpp) +file(GLOB INTROSPECTION_SCHEMA_FILES ${CMAKE_CURRENT_SOURCE_DIR}/introspection/*.cpp) +add_library(graphqlintrospection Introspection.cpp ${INTROSPECTION_SCHEMA_FILES}) add_library(cppgraphqlgen::graphqlintrospection ALIAS graphqlintrospection) target_link_libraries(graphqlintrospection PUBLIC graphqlservice) @@ -472,12 +459,6 @@ install(FILES CONFIGURATIONS ${GRAPHQL_INSTALL_CONFIGURATIONS} DESTINATION ${GRAPHQL_INSTALL_INCLUDE_DIR}/graphqlservice/internal) -install(FILES - ${CMAKE_CURRENT_SOURCE_DIR}/../include/graphqlservice/introspection/Introspection.h - ${CMAKE_CURRENT_SOURCE_DIR}/../include/graphqlservice/introspection/IntrospectionSchema.h - CONFIGURATIONS ${GRAPHQL_INSTALL_CONFIGURATIONS} - DESTINATION ${GRAPHQL_INSTALL_INCLUDE_DIR}/graphqlservice/introspection) - # graphqljson if(BUILD_GRAPHQLJSON) option(GRAPHQL_BUILD_TESTS "Build the tests and sample schema library." ON) diff --git a/src/Introspection.cpp b/src/Introspection.cpp index ae1f99d3..963f1a2b 100644 --- a/src/Introspection.cpp +++ b/src/Introspection.cpp @@ -1,7 +1,16 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -#include "graphqlservice/introspection/Introspection.h" +#include "graphqlservice/internal/Introspection.h" + +#include "graphqlservice/introspection/IntrospectionSchema.h" + +#include "graphqlservice/introspection/SchemaObject.h" +#include "graphqlservice/introspection/TypeObject.h" +#include "graphqlservice/introspection/FieldObject.h" +#include "graphqlservice/introspection/InputValueObject.h" +#include "graphqlservice/introspection/EnumValueObject.h" +#include "graphqlservice/introspection/DirectiveObject.h" namespace graphql::introspection { diff --git a/src/IntrospectionSchema.cpp b/src/IntrospectionSchema.cpp deleted file mode 100644 index dc2d20d7..00000000 --- a/src/IntrospectionSchema.cpp +++ /dev/null @@ -1,820 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// WARNING! Do not edit this file manually, your changes will be overwritten. - -#include "graphqlservice/introspection/Introspection.h" - -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace std::literals; - -namespace graphql { -namespace service { - -static const std::array s_namesTypeKind = { - R"gql(SCALAR)gql"sv, - R"gql(OBJECT)gql"sv, - R"gql(INTERFACE)gql"sv, - R"gql(UNION)gql"sv, - R"gql(ENUM)gql"sv, - R"gql(INPUT_OBJECT)gql"sv, - R"gql(LIST)gql"sv, - R"gql(NON_NULL)gql"sv -}; - -template <> -introspection::TypeKind ModifiedArgument::convert(const response::Value& value) -{ - if (!value.maybe_enum()) - { - throw service::schema_exception { { R"ex(not a valid __TypeKind value)ex" } }; - } - - const auto itr = std::find(s_namesTypeKind.cbegin(), s_namesTypeKind.cend(), value.get()); - - if (itr == s_namesTypeKind.cend()) - { - throw service::schema_exception { { R"ex(not a valid __TypeKind value)ex" } }; - } - - return static_cast(itr - s_namesTypeKind.cbegin()); -} - -template <> -service::AwaitableResolver ModifiedResult::convert(service::FieldResult result, ResolverParams params) -{ - return resolve(std::move(result), std::move(params), - [](introspection::TypeKind value, const ResolverParams&) - { - response::Value result(response::Type::EnumValue); - - result.set(std::string { s_namesTypeKind[static_cast(value)] }); - - return result; - }); -} - -static const std::array s_namesDirectiveLocation = { - R"gql(QUERY)gql"sv, - R"gql(MUTATION)gql"sv, - R"gql(SUBSCRIPTION)gql"sv, - R"gql(FIELD)gql"sv, - R"gql(FRAGMENT_DEFINITION)gql"sv, - R"gql(FRAGMENT_SPREAD)gql"sv, - R"gql(INLINE_FRAGMENT)gql"sv, - R"gql(SCHEMA)gql"sv, - R"gql(SCALAR)gql"sv, - R"gql(OBJECT)gql"sv, - R"gql(FIELD_DEFINITION)gql"sv, - R"gql(ARGUMENT_DEFINITION)gql"sv, - R"gql(INTERFACE)gql"sv, - R"gql(UNION)gql"sv, - R"gql(ENUM)gql"sv, - R"gql(ENUM_VALUE)gql"sv, - R"gql(INPUT_OBJECT)gql"sv, - R"gql(INPUT_FIELD_DEFINITION)gql"sv -}; - -template <> -introspection::DirectiveLocation ModifiedArgument::convert(const response::Value& value) -{ - if (!value.maybe_enum()) - { - throw service::schema_exception { { R"ex(not a valid __DirectiveLocation value)ex" } }; - } - - const auto itr = std::find(s_namesDirectiveLocation.cbegin(), s_namesDirectiveLocation.cend(), value.get()); - - if (itr == s_namesDirectiveLocation.cend()) - { - throw service::schema_exception { { R"ex(not a valid __DirectiveLocation value)ex" } }; - } - - return static_cast(itr - s_namesDirectiveLocation.cbegin()); -} - -template <> -service::AwaitableResolver ModifiedResult::convert(service::FieldResult result, ResolverParams params) -{ - return resolve(std::move(result), std::move(params), - [](introspection::DirectiveLocation value, const ResolverParams&) - { - response::Value result(response::Type::EnumValue); - - result.set(std::string { s_namesDirectiveLocation[static_cast(value)] }); - - return result; - }); -} - -} // namespace service - -namespace introspection { -namespace object { - -Schema::Schema(std::shared_ptr pimpl) noexcept - : service::Object{ getTypeNames(), getResolvers() } - , _pimpl { std::make_unique>(std::move(pimpl)) } -{ -} - -Schema::~Schema() -{ - // This is empty, but explicitly defined here so that it can access the un-exported destructor - // of the implementation type. -} - -service::TypeNames Schema::getTypeNames() const noexcept -{ - return { - R"gql(__Schema)gql"sv - }; -} - -service::ResolverMap Schema::getResolvers() const noexcept -{ - return { - { R"gql(types)gql"sv, [this](service::ResolverParams&& params) { return resolveTypes(std::move(params)); } }, - { R"gql(queryType)gql"sv, [this](service::ResolverParams&& params) { return resolveQueryType(std::move(params)); } }, - { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, - { R"gql(directives)gql"sv, [this](service::ResolverParams&& params) { return resolveDirectives(std::move(params)); } }, - { R"gql(mutationType)gql"sv, [this](service::ResolverParams&& params) { return resolveMutationType(std::move(params)); } }, - { R"gql(subscriptionType)gql"sv, [this](service::ResolverParams&& params) { return resolveSubscriptionType(std::move(params)); } } - }; -} - -service::AwaitableResolver Schema::resolveTypes(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getTypes(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Schema::resolveQueryType(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getQueryType(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Schema::resolveMutationType(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getMutationType(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Schema::resolveSubscriptionType(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getSubscriptionType(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Schema::resolveDirectives(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getDirectives(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Schema::resolve_typename(service::ResolverParams&& params) const -{ - return service::ModifiedResult::convert(std::string{ R"gql(__Schema)gql" }, std::move(params)); -} - -Type::Type(std::shared_ptr pimpl) noexcept - : service::Object{ getTypeNames(), getResolvers() } - , _pimpl { std::make_unique>(std::move(pimpl)) } -{ -} - -Type::~Type() -{ - // This is empty, but explicitly defined here so that it can access the un-exported destructor - // of the implementation type. -} - -service::TypeNames Type::getTypeNames() const noexcept -{ - return { - R"gql(__Type)gql"sv - }; -} - -service::ResolverMap Type::getResolvers() const noexcept -{ - return { - { R"gql(kind)gql"sv, [this](service::ResolverParams&& params) { return resolveKind(std::move(params)); } }, - { R"gql(name)gql"sv, [this](service::ResolverParams&& params) { return resolveName(std::move(params)); } }, - { R"gql(fields)gql"sv, [this](service::ResolverParams&& params) { return resolveFields(std::move(params)); } }, - { R"gql(ofType)gql"sv, [this](service::ResolverParams&& params) { return resolveOfType(std::move(params)); } }, - { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, - { R"gql(enumValues)gql"sv, [this](service::ResolverParams&& params) { return resolveEnumValues(std::move(params)); } }, - { R"gql(interfaces)gql"sv, [this](service::ResolverParams&& params) { return resolveInterfaces(std::move(params)); } }, - { R"gql(description)gql"sv, [this](service::ResolverParams&& params) { return resolveDescription(std::move(params)); } }, - { R"gql(inputFields)gql"sv, [this](service::ResolverParams&& params) { return resolveInputFields(std::move(params)); } }, - { R"gql(possibleTypes)gql"sv, [this](service::ResolverParams&& params) { return resolvePossibleTypes(std::move(params)); } } - }; -} - -service::AwaitableResolver Type::resolveKind(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getKind(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Type::resolveName(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getName(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Type::resolveDescription(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getDescription(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Type::resolveFields(service::ResolverParams&& params) const -{ - const auto defaultArguments = []() - { - response::Value values(response::Type::Map); - response::Value entry; - - entry = response::Value(false); - values.emplace_back("includeDeprecated", std::move(entry)); - - return values; - }(); - - auto pairIncludeDeprecated = service::ModifiedArgument::find("includeDeprecated", params.arguments); - auto argIncludeDeprecated = (pairIncludeDeprecated.second - ? std::move(pairIncludeDeprecated.first) - : service::ModifiedArgument::require("includeDeprecated", defaultArguments)); - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getFields(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argIncludeDeprecated)); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Type::resolveInterfaces(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getInterfaces(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Type::resolvePossibleTypes(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getPossibleTypes(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Type::resolveEnumValues(service::ResolverParams&& params) const -{ - const auto defaultArguments = []() - { - response::Value values(response::Type::Map); - response::Value entry; - - entry = response::Value(false); - values.emplace_back("includeDeprecated", std::move(entry)); - - return values; - }(); - - auto pairIncludeDeprecated = service::ModifiedArgument::find("includeDeprecated", params.arguments); - auto argIncludeDeprecated = (pairIncludeDeprecated.second - ? std::move(pairIncludeDeprecated.first) - : service::ModifiedArgument::require("includeDeprecated", defaultArguments)); - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getEnumValues(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argIncludeDeprecated)); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Type::resolveInputFields(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getInputFields(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Type::resolveOfType(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getOfType(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Type::resolve_typename(service::ResolverParams&& params) const -{ - return service::ModifiedResult::convert(std::string{ R"gql(__Type)gql" }, std::move(params)); -} - -Field::Field(std::shared_ptr pimpl) noexcept - : service::Object{ getTypeNames(), getResolvers() } - , _pimpl { std::make_unique>(std::move(pimpl)) } -{ -} - -Field::~Field() -{ - // This is empty, but explicitly defined here so that it can access the un-exported destructor - // of the implementation type. -} - -service::TypeNames Field::getTypeNames() const noexcept -{ - return { - R"gql(__Field)gql"sv - }; -} - -service::ResolverMap Field::getResolvers() const noexcept -{ - return { - { R"gql(args)gql"sv, [this](service::ResolverParams&& params) { return resolveArgs(std::move(params)); } }, - { R"gql(name)gql"sv, [this](service::ResolverParams&& params) { return resolveName(std::move(params)); } }, - { R"gql(type)gql"sv, [this](service::ResolverParams&& params) { return resolveType(std::move(params)); } }, - { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, - { R"gql(description)gql"sv, [this](service::ResolverParams&& params) { return resolveDescription(std::move(params)); } }, - { R"gql(isDeprecated)gql"sv, [this](service::ResolverParams&& params) { return resolveIsDeprecated(std::move(params)); } }, - { R"gql(deprecationReason)gql"sv, [this](service::ResolverParams&& params) { return resolveDeprecationReason(std::move(params)); } } - }; -} - -service::AwaitableResolver Field::resolveName(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getName(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Field::resolveDescription(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getDescription(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Field::resolveArgs(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getArgs(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Field::resolveType(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getType(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Field::resolveIsDeprecated(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getIsDeprecated(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Field::resolveDeprecationReason(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getDeprecationReason(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Field::resolve_typename(service::ResolverParams&& params) const -{ - return service::ModifiedResult::convert(std::string{ R"gql(__Field)gql" }, std::move(params)); -} - -InputValue::InputValue(std::shared_ptr pimpl) noexcept - : service::Object{ getTypeNames(), getResolvers() } - , _pimpl { std::make_unique>(std::move(pimpl)) } -{ -} - -InputValue::~InputValue() -{ - // This is empty, but explicitly defined here so that it can access the un-exported destructor - // of the implementation type. -} - -service::TypeNames InputValue::getTypeNames() const noexcept -{ - return { - R"gql(__InputValue)gql"sv - }; -} - -service::ResolverMap InputValue::getResolvers() const noexcept -{ - return { - { R"gql(name)gql"sv, [this](service::ResolverParams&& params) { return resolveName(std::move(params)); } }, - { R"gql(type)gql"sv, [this](service::ResolverParams&& params) { return resolveType(std::move(params)); } }, - { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, - { R"gql(description)gql"sv, [this](service::ResolverParams&& params) { return resolveDescription(std::move(params)); } }, - { R"gql(defaultValue)gql"sv, [this](service::ResolverParams&& params) { return resolveDefaultValue(std::move(params)); } } - }; -} - -service::AwaitableResolver InputValue::resolveName(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getName(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver InputValue::resolveDescription(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getDescription(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver InputValue::resolveType(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getType(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver InputValue::resolveDefaultValue(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getDefaultValue(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver InputValue::resolve_typename(service::ResolverParams&& params) const -{ - return service::ModifiedResult::convert(std::string{ R"gql(__InputValue)gql" }, std::move(params)); -} - -EnumValue::EnumValue(std::shared_ptr pimpl) noexcept - : service::Object{ getTypeNames(), getResolvers() } - , _pimpl { std::make_unique>(std::move(pimpl)) } -{ -} - -EnumValue::~EnumValue() -{ - // This is empty, but explicitly defined here so that it can access the un-exported destructor - // of the implementation type. -} - -service::TypeNames EnumValue::getTypeNames() const noexcept -{ - return { - R"gql(__EnumValue)gql"sv - }; -} - -service::ResolverMap EnumValue::getResolvers() const noexcept -{ - return { - { R"gql(name)gql"sv, [this](service::ResolverParams&& params) { return resolveName(std::move(params)); } }, - { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, - { R"gql(description)gql"sv, [this](service::ResolverParams&& params) { return resolveDescription(std::move(params)); } }, - { R"gql(isDeprecated)gql"sv, [this](service::ResolverParams&& params) { return resolveIsDeprecated(std::move(params)); } }, - { R"gql(deprecationReason)gql"sv, [this](service::ResolverParams&& params) { return resolveDeprecationReason(std::move(params)); } } - }; -} - -service::AwaitableResolver EnumValue::resolveName(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getName(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver EnumValue::resolveDescription(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getDescription(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver EnumValue::resolveIsDeprecated(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getIsDeprecated(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver EnumValue::resolveDeprecationReason(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getDeprecationReason(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver EnumValue::resolve_typename(service::ResolverParams&& params) const -{ - return service::ModifiedResult::convert(std::string{ R"gql(__EnumValue)gql" }, std::move(params)); -} - -Directive::Directive(std::shared_ptr pimpl) noexcept - : service::Object{ getTypeNames(), getResolvers() } - , _pimpl { std::make_unique>(std::move(pimpl)) } -{ -} - -Directive::~Directive() -{ - // This is empty, but explicitly defined here so that it can access the un-exported destructor - // of the implementation type. -} - -service::TypeNames Directive::getTypeNames() const noexcept -{ - return { - R"gql(__Directive)gql"sv - }; -} - -service::ResolverMap Directive::getResolvers() const noexcept -{ - return { - { R"gql(args)gql"sv, [this](service::ResolverParams&& params) { return resolveArgs(std::move(params)); } }, - { R"gql(name)gql"sv, [this](service::ResolverParams&& params) { return resolveName(std::move(params)); } }, - { R"gql(locations)gql"sv, [this](service::ResolverParams&& params) { return resolveLocations(std::move(params)); } }, - { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, - { R"gql(description)gql"sv, [this](service::ResolverParams&& params) { return resolveDescription(std::move(params)); } } - }; -} - -service::AwaitableResolver Directive::resolveName(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getName(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Directive::resolveDescription(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getDescription(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Directive::resolveLocations(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getLocations(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Directive::resolveArgs(service::ResolverParams&& params) const -{ - std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getArgs(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); - resolverLock.unlock(); - - return service::ModifiedResult::convert(std::move(result), std::move(params)); -} - -service::AwaitableResolver Directive::resolve_typename(service::ResolverParams&& params) const -{ - return service::ModifiedResult::convert(std::string{ R"gql(__Directive)gql" }, std::move(params)); -} - -} // namespace object - -void AddTypesToSchema(const std::shared_ptr& schema) -{ - schema->AddType(R"gql(Boolean)gql"sv, schema::ScalarType::Make(R"gql(Boolean)gql"sv, R"md(Built-in type)md")); - schema->AddType(R"gql(Float)gql"sv, schema::ScalarType::Make(R"gql(Float)gql"sv, R"md(Built-in type)md")); - schema->AddType(R"gql(ID)gql"sv, schema::ScalarType::Make(R"gql(ID)gql"sv, R"md(Built-in type)md")); - schema->AddType(R"gql(Int)gql"sv, schema::ScalarType::Make(R"gql(Int)gql"sv, R"md(Built-in type)md")); - schema->AddType(R"gql(String)gql"sv, schema::ScalarType::Make(R"gql(String)gql"sv, R"md(Built-in type)md")); - auto typeTypeKind = schema::EnumType::Make(R"gql(__TypeKind)gql"sv, R"md()md"sv); - schema->AddType(R"gql(__TypeKind)gql"sv, typeTypeKind); - auto typeDirectiveLocation = schema::EnumType::Make(R"gql(__DirectiveLocation)gql"sv, R"md()md"sv); - schema->AddType(R"gql(__DirectiveLocation)gql"sv, typeDirectiveLocation); - auto typeSchema = schema::ObjectType::Make(R"gql(__Schema)gql"sv, R"md()md"); - schema->AddType(R"gql(__Schema)gql"sv, typeSchema); - auto typeType = schema::ObjectType::Make(R"gql(__Type)gql"sv, R"md()md"); - schema->AddType(R"gql(__Type)gql"sv, typeType); - auto typeField = schema::ObjectType::Make(R"gql(__Field)gql"sv, R"md()md"); - schema->AddType(R"gql(__Field)gql"sv, typeField); - auto typeInputValue = schema::ObjectType::Make(R"gql(__InputValue)gql"sv, R"md()md"); - schema->AddType(R"gql(__InputValue)gql"sv, typeInputValue); - auto typeEnumValue = schema::ObjectType::Make(R"gql(__EnumValue)gql"sv, R"md()md"); - schema->AddType(R"gql(__EnumValue)gql"sv, typeEnumValue); - auto typeDirective = schema::ObjectType::Make(R"gql(__Directive)gql"sv, R"md()md"); - schema->AddType(R"gql(__Directive)gql"sv, typeDirective); - - typeTypeKind->AddEnumValues({ - { service::s_namesTypeKind[static_cast(introspection::TypeKind::SCALAR)], R"md()md"sv, std::nullopt }, - { service::s_namesTypeKind[static_cast(introspection::TypeKind::OBJECT)], R"md()md"sv, std::nullopt }, - { service::s_namesTypeKind[static_cast(introspection::TypeKind::INTERFACE)], R"md()md"sv, std::nullopt }, - { service::s_namesTypeKind[static_cast(introspection::TypeKind::UNION)], R"md()md"sv, std::nullopt }, - { service::s_namesTypeKind[static_cast(introspection::TypeKind::ENUM)], R"md()md"sv, std::nullopt }, - { service::s_namesTypeKind[static_cast(introspection::TypeKind::INPUT_OBJECT)], R"md()md"sv, std::nullopt }, - { service::s_namesTypeKind[static_cast(introspection::TypeKind::LIST)], R"md()md"sv, std::nullopt }, - { service::s_namesTypeKind[static_cast(introspection::TypeKind::NON_NULL)], R"md()md"sv, std::nullopt } - }); - typeDirectiveLocation->AddEnumValues({ - { service::s_namesDirectiveLocation[static_cast(introspection::DirectiveLocation::QUERY)], R"md()md"sv, std::nullopt }, - { service::s_namesDirectiveLocation[static_cast(introspection::DirectiveLocation::MUTATION)], R"md()md"sv, std::nullopt }, - { service::s_namesDirectiveLocation[static_cast(introspection::DirectiveLocation::SUBSCRIPTION)], R"md()md"sv, std::nullopt }, - { service::s_namesDirectiveLocation[static_cast(introspection::DirectiveLocation::FIELD)], R"md()md"sv, std::nullopt }, - { service::s_namesDirectiveLocation[static_cast(introspection::DirectiveLocation::FRAGMENT_DEFINITION)], R"md()md"sv, std::nullopt }, - { service::s_namesDirectiveLocation[static_cast(introspection::DirectiveLocation::FRAGMENT_SPREAD)], R"md()md"sv, std::nullopt }, - { service::s_namesDirectiveLocation[static_cast(introspection::DirectiveLocation::INLINE_FRAGMENT)], R"md()md"sv, std::nullopt }, - { service::s_namesDirectiveLocation[static_cast(introspection::DirectiveLocation::SCHEMA)], R"md()md"sv, std::nullopt }, - { service::s_namesDirectiveLocation[static_cast(introspection::DirectiveLocation::SCALAR)], R"md()md"sv, std::nullopt }, - { service::s_namesDirectiveLocation[static_cast(introspection::DirectiveLocation::OBJECT)], R"md()md"sv, std::nullopt }, - { service::s_namesDirectiveLocation[static_cast(introspection::DirectiveLocation::FIELD_DEFINITION)], R"md()md"sv, std::nullopt }, - { service::s_namesDirectiveLocation[static_cast(introspection::DirectiveLocation::ARGUMENT_DEFINITION)], R"md()md"sv, std::nullopt }, - { service::s_namesDirectiveLocation[static_cast(introspection::DirectiveLocation::INTERFACE)], R"md()md"sv, std::nullopt }, - { service::s_namesDirectiveLocation[static_cast(introspection::DirectiveLocation::UNION)], R"md()md"sv, std::nullopt }, - { service::s_namesDirectiveLocation[static_cast(introspection::DirectiveLocation::ENUM)], R"md()md"sv, std::nullopt }, - { service::s_namesDirectiveLocation[static_cast(introspection::DirectiveLocation::ENUM_VALUE)], R"md()md"sv, std::nullopt }, - { service::s_namesDirectiveLocation[static_cast(introspection::DirectiveLocation::INPUT_OBJECT)], R"md()md"sv, std::nullopt }, - { service::s_namesDirectiveLocation[static_cast(introspection::DirectiveLocation::INPUT_FIELD_DEFINITION)], R"md()md"sv, std::nullopt } - }); - - typeSchema->AddFields({ - schema::Field::Make(R"gql(types)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(__Type)gql"sv))))), - schema::Field::Make(R"gql(queryType)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(__Type)gql"sv))), - schema::Field::Make(R"gql(mutationType)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(__Type)gql"sv)), - schema::Field::Make(R"gql(subscriptionType)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(__Type)gql"sv)), - schema::Field::Make(R"gql(directives)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(__Directive)gql"sv))))) - }); - typeType->AddFields({ - schema::Field::Make(R"gql(kind)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(__TypeKind)gql"sv))), - schema::Field::Make(R"gql(name)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(String)gql"sv)), - schema::Field::Make(R"gql(description)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(String)gql"sv)), - schema::Field::Make(R"gql(fields)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(__Field)gql"sv))), { - schema::InputValue::Make(R"gql(includeDeprecated)gql"sv, R"md()md"sv, schema->LookupType(R"gql(Boolean)gql"sv), R"gql(false)gql"sv) - }), - schema::Field::Make(R"gql(interfaces)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(__Type)gql"sv)))), - schema::Field::Make(R"gql(possibleTypes)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(__Type)gql"sv)))), - schema::Field::Make(R"gql(enumValues)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(__EnumValue)gql"sv))), { - schema::InputValue::Make(R"gql(includeDeprecated)gql"sv, R"md()md"sv, schema->LookupType(R"gql(Boolean)gql"sv), R"gql(false)gql"sv) - }), - schema::Field::Make(R"gql(inputFields)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(__InputValue)gql"sv)))), - schema::Field::Make(R"gql(ofType)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(__Type)gql"sv)) - }); - typeField->AddFields({ - schema::Field::Make(R"gql(name)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(String)gql"sv))), - schema::Field::Make(R"gql(description)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(String)gql"sv)), - schema::Field::Make(R"gql(args)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(__InputValue)gql"sv))))), - schema::Field::Make(R"gql(type)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(__Type)gql"sv))), - schema::Field::Make(R"gql(isDeprecated)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Boolean)gql"sv))), - schema::Field::Make(R"gql(deprecationReason)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(String)gql"sv)) - }); - typeInputValue->AddFields({ - schema::Field::Make(R"gql(name)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(String)gql"sv))), - schema::Field::Make(R"gql(description)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(String)gql"sv)), - schema::Field::Make(R"gql(type)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(__Type)gql"sv))), - schema::Field::Make(R"gql(defaultValue)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(String)gql"sv)) - }); - typeEnumValue->AddFields({ - schema::Field::Make(R"gql(name)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(String)gql"sv))), - schema::Field::Make(R"gql(description)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(String)gql"sv)), - schema::Field::Make(R"gql(isDeprecated)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Boolean)gql"sv))), - schema::Field::Make(R"gql(deprecationReason)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(String)gql"sv)) - }); - typeDirective->AddFields({ - schema::Field::Make(R"gql(name)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(String)gql"sv))), - schema::Field::Make(R"gql(description)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(String)gql"sv)), - schema::Field::Make(R"gql(locations)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(__DirectiveLocation)gql"sv))))), - schema::Field::Make(R"gql(args)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(__InputValue)gql"sv))))) - }); - - schema->AddDirective(schema::Directive::Make(R"gql(skip)gql"sv, R"md()md"sv, { - introspection::DirectiveLocation::FIELD, - introspection::DirectiveLocation::FRAGMENT_SPREAD, - introspection::DirectiveLocation::INLINE_FRAGMENT - }, { - schema::InputValue::Make(R"gql(if)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Boolean)gql"sv)), R"gql()gql"sv) - })); - schema->AddDirective(schema::Directive::Make(R"gql(include)gql"sv, R"md()md"sv, { - introspection::DirectiveLocation::FIELD, - introspection::DirectiveLocation::FRAGMENT_SPREAD, - introspection::DirectiveLocation::INLINE_FRAGMENT - }, { - schema::InputValue::Make(R"gql(if)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Boolean)gql"sv)), R"gql()gql"sv) - })); - schema->AddDirective(schema::Directive::Make(R"gql(deprecated)gql"sv, R"md()md"sv, { - introspection::DirectiveLocation::FIELD_DEFINITION, - introspection::DirectiveLocation::ENUM_VALUE - }, { - schema::InputValue::Make(R"gql(reason)gql"sv, R"md()md"sv, schema->LookupType(R"gql(String)gql"sv), R"gql("No longer supported")gql"sv) - })); -} - -} // namespace introspection -} // namespace graphql diff --git a/src/RequestLoader.cpp b/src/RequestLoader.cpp index 033f55d7..2db44fb7 100644 --- a/src/RequestLoader.cpp +++ b/src/RequestLoader.cpp @@ -7,7 +7,7 @@ #include "graphqlservice/internal/Grammar.h" -#include "graphqlservice/introspection/Introspection.h" +#include "graphqlservice/introspection/IntrospectionSchema.h" #include #include diff --git a/src/SchemaGenerator.cpp b/src/SchemaGenerator.cpp index 8f3d3543..35947322 100644 --- a/src/SchemaGenerator.cpp +++ b/src/SchemaGenerator.cpp @@ -1176,8 +1176,22 @@ bool Generator::outputSource() const noexcept } } - sourceFile << R"cpp(#include "graphqlservice/introspection/Introspection.h" + if (_loader.isIntrospection()) + { + sourceFile << R"cpp( +#include "graphqlservice/internal/Introspection.h" +)cpp"; + } + else + { + sourceFile << R"cpp( +#include "graphqlservice/internal/Schema.h" +#include "graphqlservice/introspection/IntrospectionSchema.h" +)cpp"; + } + + sourceFile << R"cpp( #include #include #include @@ -2773,9 +2787,24 @@ std::vector Generator::outputSeparateFiles() const noexcept #include ")cpp" << headerFilename << R"cpp(" +)cpp"; + + if (_loader.isIntrospection()) + { + sourceFile << R"cpp( +#include "graphqlservice/internal/Introspection.h" +)cpp"; + } + else + { + sourceFile << R"cpp( +#include "graphqlservice/internal/Schema.h" -#include "graphqlservice/introspection/Introspection.h" +#include "graphqlservice/introspection/IntrospectionSchema.h" +)cpp"; + } + sourceFile << R"cpp( using namespace std::literals; )cpp"; @@ -2848,9 +2877,24 @@ using namespace std::literals; #include ")cpp" << headerFilename << R"cpp(" +)cpp"; + + if (_loader.isIntrospection()) + { + sourceFile << R"cpp( +#include "graphqlservice/internal/Introspection.h" +)cpp"; + } + else + { + sourceFile << R"cpp( +#include "graphqlservice/internal/Schema.h" -#include "graphqlservice/introspection/Introspection.h" +#include "graphqlservice/introspection/IntrospectionSchema.h" +)cpp"; + } + sourceFile << R"cpp( using namespace std::literals; )cpp"; @@ -2969,9 +3013,30 @@ using namespace std::literals; } } - sourceFile << R"cpp( -#include "graphqlservice/introspection/Introspection.h" + if (_loader.isIntrospection() || (isQueryType && !_options.noIntrospection)) + { + sourceFile << R"cpp( +#include "graphqlservice/internal/Introspection.h" +)cpp"; + } + else + { + sourceFile << R"cpp( +#include "graphqlservice/internal/Schema.h" + +#include "graphqlservice/introspection/IntrospectionSchema.h" +)cpp"; + } + + if (isQueryType && !_options.noIntrospection) + { + sourceFile << R"cpp( +#include "graphqlservice/introspection/SchemaObject.h" +#include "graphqlservice/introspection/TypeObject.h" +)cpp"; + } + sourceFile << R"cpp( #include #include #include @@ -3119,44 +3184,27 @@ int main(int argc, char** argv) try { - if (buildIntrospection) - { - const auto files = graphql::generator::schema::Generator(std::nullopt, - { - std::nullopt, - verbose, - false, // stubs - true, // mergeFiles - false, // noIntrospection - }) - .Build(); + auto schemaOptions = buildCustom + ? std::make_optional(graphql::generator::SchemaOptions { std::move(schemaFileName), + std::move(filenamePrefix), + std::move(schemaNamespace), + buildIntrospection }) + : std::nullopt; - for (const auto& file : files) + const auto files = graphql::generator::schema::Generator(std::move(schemaOptions), { - std::cout << file << std::endl; - } - } + graphql::generator::schema::GeneratorPaths { std::move(headerDir), + std::move(sourceDir) }, + verbose, + stubs, // stubs + !buildCustom, // mergeFiles + noIntrospection, // noIntrospection + }) + .Build(); - if (buildCustom) + for (const auto& file : files) { - const auto files = graphql::generator::schema::Generator( - std::make_optional(graphql::generator::SchemaOptions { std::move(schemaFileName), - std::move(filenamePrefix), - std::move(schemaNamespace) }), - { - graphql::generator::schema::GeneratorPaths { std::move(headerDir), - std::move(sourceDir) }, - verbose, - stubs, - false, - noIntrospection, - }) - .Build(); - - for (const auto& file : files) - { - std::cout << file << std::endl; - } + std::cout << file << std::endl; } } catch (const graphql::peg::parse_error& pe) diff --git a/src/SchemaLoader.cpp b/src/SchemaLoader.cpp index d6232fa0..597114b4 100644 --- a/src/SchemaLoader.cpp +++ b/src/SchemaLoader.cpp @@ -36,10 +36,10 @@ const std::string_view SchemaLoader::s_scalarCppType = R"cpp(response::Value)cpp SchemaLoader::SchemaLoader(std::optional&& customSchema) : _customSchema(std::move(customSchema)) - , _isIntrospection(!_customSchema) - , _schemaNamespace(_isIntrospection ? s_introspectionNamespace : _customSchema->schemaNamespace) + , _isIntrospection(!_customSchema || _customSchema->isIntrospection) + , _schemaNamespace(_customSchema ? _customSchema->schemaNamespace : s_introspectionNamespace) { - if (_isIntrospection) + if (!_customSchema) { // Introspection Schema: // http://spec.graphql.org/June2018/#sec-Schema-Introspection diff --git a/src/introspection/CMakeLists.txt b/src/introspection/CMakeLists.txt new file mode 100644 index 00000000..0e91e2ac --- /dev/null +++ b/src/introspection/CMakeLists.txt @@ -0,0 +1,28 @@ +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. + +cmake_minimum_required(VERSION 3.15) + +# Normally this would be handled by find_package(cppgraphqlgen CONFIG). +include(${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/cppgraphqlgen-functions.cmake) + +if(GRAPHQL_UPDATE_SAMPLES) + update_graphql_schema_files(introspection schema.introspection.graphql Introspection introspection --introspection) + + add_custom_command( + OUTPUT updated_introspection_schema_headers + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/*.h ${CMAKE_CURRENT_SOURCE_DIR}/../../include/graphqlservice/introspection/ + COMMAND ${CMAKE_COMMAND} -E touch updated_introspection_schema_headers + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/introspection_schema_files + COMMENT "Updating IntrospectionSchema headers") + + add_custom_target(update_introspection_headers ALL + DEPENDS updated_introspection_schema_headers) +endif() + +set_property(DIRECTORY APPEND + PROPERTY CMAKE_CONFIGURE_DEPENDS introspection_schema_files) +file(GLOB SCHEMA_FILES ${CMAKE_CURRENT_SOURCE_DIR}/../../include/graphqlservice/introspection/*.h) +install(FILES ${SCHEMA_FILES} + CONFIGURATIONS ${GRAPHQL_INSTALL_CONFIGURATIONS} + DESTINATION ${GRAPHQL_INSTALL_INCLUDE_DIR}/graphqlservice/introspection) diff --git a/src/introspection/DirectiveObject.cpp b/src/introspection/DirectiveObject.cpp new file mode 100644 index 00000000..7adf45de --- /dev/null +++ b/src/introspection/DirectiveObject.cpp @@ -0,0 +1,109 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// WARNING! Do not edit this file manually, your changes will be overwritten. + +#include "DirectiveObject.h" +#include "InputValueObject.h" + +#include "graphqlservice/internal/Introspection.h" + +#include +#include +#include +#include +#include + +using namespace std::literals; + +namespace graphql::introspection { +namespace object { + +Directive::Directive(std::shared_ptr pimpl) noexcept + : service::Object{ getTypeNames(), getResolvers() } + , _pimpl { std::make_unique>(std::move(pimpl)) } +{ +} + +Directive::~Directive() +{ + // This is empty, but explicitly defined here so that it can access the un-exported destructor + // of the implementation type. +} + +service::TypeNames Directive::getTypeNames() const noexcept +{ + return { + R"gql(__Directive)gql"sv + }; +} + +service::ResolverMap Directive::getResolvers() const noexcept +{ + return { + { R"gql(args)gql"sv, [this](service::ResolverParams&& params) { return resolveArgs(std::move(params)); } }, + { R"gql(name)gql"sv, [this](service::ResolverParams&& params) { return resolveName(std::move(params)); } }, + { R"gql(locations)gql"sv, [this](service::ResolverParams&& params) { return resolveLocations(std::move(params)); } }, + { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, + { R"gql(description)gql"sv, [this](service::ResolverParams&& params) { return resolveDescription(std::move(params)); } } + }; +} + +service::AwaitableResolver Directive::resolveName(service::ResolverParams&& params) const +{ + std::unique_lock resolverLock(_resolverMutex); + auto directives = std::move(params.fieldDirectives); + auto result = _pimpl->getName(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + resolverLock.unlock(); + + return service::ModifiedResult::convert(std::move(result), std::move(params)); +} + +service::AwaitableResolver Directive::resolveDescription(service::ResolverParams&& params) const +{ + std::unique_lock resolverLock(_resolverMutex); + auto directives = std::move(params.fieldDirectives); + auto result = _pimpl->getDescription(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + resolverLock.unlock(); + + return service::ModifiedResult::convert(std::move(result), std::move(params)); +} + +service::AwaitableResolver Directive::resolveLocations(service::ResolverParams&& params) const +{ + std::unique_lock resolverLock(_resolverMutex); + auto directives = std::move(params.fieldDirectives); + auto result = _pimpl->getLocations(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + resolverLock.unlock(); + + return service::ModifiedResult::convert(std::move(result), std::move(params)); +} + +service::AwaitableResolver Directive::resolveArgs(service::ResolverParams&& params) const +{ + std::unique_lock resolverLock(_resolverMutex); + auto directives = std::move(params.fieldDirectives); + auto result = _pimpl->getArgs(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + resolverLock.unlock(); + + return service::ModifiedResult::convert(std::move(result), std::move(params)); +} + +service::AwaitableResolver Directive::resolve_typename(service::ResolverParams&& params) const +{ + return service::ModifiedResult::convert(std::string{ R"gql(__Directive)gql" }, std::move(params)); +} + +} // namespace object + +void AddDirectiveDetails(const std::shared_ptr& typeDirective, const std::shared_ptr& schema) +{ + typeDirective->AddFields({ + schema::Field::Make(R"gql(name)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(String)gql"sv))), + schema::Field::Make(R"gql(description)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(String)gql"sv)), + schema::Field::Make(R"gql(locations)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(__DirectiveLocation)gql"sv))))), + schema::Field::Make(R"gql(args)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(__InputValue)gql"sv))))) + }); +} + +} // namespace graphql::introspection diff --git a/src/introspection/DirectiveObject.h b/src/introspection/DirectiveObject.h new file mode 100644 index 00000000..953863a4 --- /dev/null +++ b/src/introspection/DirectiveObject.h @@ -0,0 +1,144 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// WARNING! Do not edit this file manually, your changes will be overwritten. + +#pragma once + +#ifndef DIRECTIVEOBJECT_H +#define DIRECTIVEOBJECT_H + +#include "IntrospectionSchema.h" + +namespace graphql::introspection::object { +namespace methods::DirectiveHas { + +template +concept getNameWithParams = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult { impl.getName(std::move(params)) } }; +}; + +template +concept getName = requires (TImpl impl) +{ + { service::FieldResult { impl.getName() } }; +}; + +template +concept getDescriptionWithParams = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult> { impl.getDescription(std::move(params)) } }; +}; + +template +concept getDescription = requires (TImpl impl) +{ + { service::FieldResult> { impl.getDescription() } }; +}; + +template +concept getLocationsWithParams = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult> { impl.getLocations(std::move(params)) } }; +}; + +template +concept getLocations = requires (TImpl impl) +{ + { service::FieldResult> { impl.getLocations() } }; +}; + +template +concept getArgsWithParams = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult>> { impl.getArgs(std::move(params)) } }; +}; + +template +concept getArgs = requires (TImpl impl) +{ + { service::FieldResult>> { impl.getArgs() } }; +}; + +template +concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.beginSelectionSet(params) }; +}; + +template +concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.endSelectionSet(params) }; +}; + +} // namespace methods::DirectiveHas + +class Directive + : public service::Object +{ +private: + service::AwaitableResolver resolveName(service::ResolverParams&& params) const; + service::AwaitableResolver resolveDescription(service::ResolverParams&& params) const; + service::AwaitableResolver resolveLocations(service::ResolverParams&& params) const; + service::AwaitableResolver resolveArgs(service::ResolverParams&& params) const; + + service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; + + struct Concept + { + virtual ~Concept() = default; + + virtual service::FieldResult getName(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getDescription(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getLocations(service::FieldParams&& params) const = 0; + virtual service::FieldResult>> getArgs(service::FieldParams&& params) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::FieldResult getName(service::FieldParams&&) const final + { + return { _pimpl->getName() }; + } + + service::FieldResult> getDescription(service::FieldParams&&) const final + { + return { _pimpl->getDescription() }; + } + + service::FieldResult> getLocations(service::FieldParams&&) const final + { + return { _pimpl->getLocations() }; + } + + service::FieldResult>> getArgs(service::FieldParams&&) const final + { + return { _pimpl->getArgs() }; + } + + private: + const std::shared_ptr _pimpl; + }; + + const std::unique_ptr _pimpl; + + service::TypeNames getTypeNames() const noexcept; + service::ResolverMap getResolvers() const noexcept; + +public: + GRAPHQLINTROSPECTION_EXPORT Directive(std::shared_ptr pimpl) noexcept; + GRAPHQLINTROSPECTION_EXPORT ~Directive(); +}; + +} // namespace graphql::introspection::object + +#endif // DIRECTIVEOBJECT_H diff --git a/src/introspection/EnumValueObject.cpp b/src/introspection/EnumValueObject.cpp new file mode 100644 index 00000000..c0dc7797 --- /dev/null +++ b/src/introspection/EnumValueObject.cpp @@ -0,0 +1,108 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// WARNING! Do not edit this file manually, your changes will be overwritten. + +#include "EnumValueObject.h" + +#include "graphqlservice/internal/Introspection.h" + +#include +#include +#include +#include +#include + +using namespace std::literals; + +namespace graphql::introspection { +namespace object { + +EnumValue::EnumValue(std::shared_ptr pimpl) noexcept + : service::Object{ getTypeNames(), getResolvers() } + , _pimpl { std::make_unique>(std::move(pimpl)) } +{ +} + +EnumValue::~EnumValue() +{ + // This is empty, but explicitly defined here so that it can access the un-exported destructor + // of the implementation type. +} + +service::TypeNames EnumValue::getTypeNames() const noexcept +{ + return { + R"gql(__EnumValue)gql"sv + }; +} + +service::ResolverMap EnumValue::getResolvers() const noexcept +{ + return { + { R"gql(name)gql"sv, [this](service::ResolverParams&& params) { return resolveName(std::move(params)); } }, + { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, + { R"gql(description)gql"sv, [this](service::ResolverParams&& params) { return resolveDescription(std::move(params)); } }, + { R"gql(isDeprecated)gql"sv, [this](service::ResolverParams&& params) { return resolveIsDeprecated(std::move(params)); } }, + { R"gql(deprecationReason)gql"sv, [this](service::ResolverParams&& params) { return resolveDeprecationReason(std::move(params)); } } + }; +} + +service::AwaitableResolver EnumValue::resolveName(service::ResolverParams&& params) const +{ + std::unique_lock resolverLock(_resolverMutex); + auto directives = std::move(params.fieldDirectives); + auto result = _pimpl->getName(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + resolverLock.unlock(); + + return service::ModifiedResult::convert(std::move(result), std::move(params)); +} + +service::AwaitableResolver EnumValue::resolveDescription(service::ResolverParams&& params) const +{ + std::unique_lock resolverLock(_resolverMutex); + auto directives = std::move(params.fieldDirectives); + auto result = _pimpl->getDescription(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + resolverLock.unlock(); + + return service::ModifiedResult::convert(std::move(result), std::move(params)); +} + +service::AwaitableResolver EnumValue::resolveIsDeprecated(service::ResolverParams&& params) const +{ + std::unique_lock resolverLock(_resolverMutex); + auto directives = std::move(params.fieldDirectives); + auto result = _pimpl->getIsDeprecated(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + resolverLock.unlock(); + + return service::ModifiedResult::convert(std::move(result), std::move(params)); +} + +service::AwaitableResolver EnumValue::resolveDeprecationReason(service::ResolverParams&& params) const +{ + std::unique_lock resolverLock(_resolverMutex); + auto directives = std::move(params.fieldDirectives); + auto result = _pimpl->getDeprecationReason(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + resolverLock.unlock(); + + return service::ModifiedResult::convert(std::move(result), std::move(params)); +} + +service::AwaitableResolver EnumValue::resolve_typename(service::ResolverParams&& params) const +{ + return service::ModifiedResult::convert(std::string{ R"gql(__EnumValue)gql" }, std::move(params)); +} + +} // namespace object + +void AddEnumValueDetails(const std::shared_ptr& typeEnumValue, const std::shared_ptr& schema) +{ + typeEnumValue->AddFields({ + schema::Field::Make(R"gql(name)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(String)gql"sv))), + schema::Field::Make(R"gql(description)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(String)gql"sv)), + schema::Field::Make(R"gql(isDeprecated)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Boolean)gql"sv))), + schema::Field::Make(R"gql(deprecationReason)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(String)gql"sv)) + }); +} + +} // namespace graphql::introspection diff --git a/src/introspection/EnumValueObject.h b/src/introspection/EnumValueObject.h new file mode 100644 index 00000000..3f2dd71c --- /dev/null +++ b/src/introspection/EnumValueObject.h @@ -0,0 +1,144 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// WARNING! Do not edit this file manually, your changes will be overwritten. + +#pragma once + +#ifndef ENUMVALUEOBJECT_H +#define ENUMVALUEOBJECT_H + +#include "IntrospectionSchema.h" + +namespace graphql::introspection::object { +namespace methods::EnumValueHas { + +template +concept getNameWithParams = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult { impl.getName(std::move(params)) } }; +}; + +template +concept getName = requires (TImpl impl) +{ + { service::FieldResult { impl.getName() } }; +}; + +template +concept getDescriptionWithParams = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult> { impl.getDescription(std::move(params)) } }; +}; + +template +concept getDescription = requires (TImpl impl) +{ + { service::FieldResult> { impl.getDescription() } }; +}; + +template +concept getIsDeprecatedWithParams = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult { impl.getIsDeprecated(std::move(params)) } }; +}; + +template +concept getIsDeprecated = requires (TImpl impl) +{ + { service::FieldResult { impl.getIsDeprecated() } }; +}; + +template +concept getDeprecationReasonWithParams = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult> { impl.getDeprecationReason(std::move(params)) } }; +}; + +template +concept getDeprecationReason = requires (TImpl impl) +{ + { service::FieldResult> { impl.getDeprecationReason() } }; +}; + +template +concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.beginSelectionSet(params) }; +}; + +template +concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.endSelectionSet(params) }; +}; + +} // namespace methods::EnumValueHas + +class EnumValue + : public service::Object +{ +private: + service::AwaitableResolver resolveName(service::ResolverParams&& params) const; + service::AwaitableResolver resolveDescription(service::ResolverParams&& params) const; + service::AwaitableResolver resolveIsDeprecated(service::ResolverParams&& params) const; + service::AwaitableResolver resolveDeprecationReason(service::ResolverParams&& params) const; + + service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; + + struct Concept + { + virtual ~Concept() = default; + + virtual service::FieldResult getName(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getDescription(service::FieldParams&& params) const = 0; + virtual service::FieldResult getIsDeprecated(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getDeprecationReason(service::FieldParams&& params) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::FieldResult getName(service::FieldParams&&) const final + { + return { _pimpl->getName() }; + } + + service::FieldResult> getDescription(service::FieldParams&&) const final + { + return { _pimpl->getDescription() }; + } + + service::FieldResult getIsDeprecated(service::FieldParams&&) const final + { + return { _pimpl->getIsDeprecated() }; + } + + service::FieldResult> getDeprecationReason(service::FieldParams&&) const final + { + return { _pimpl->getDeprecationReason() }; + } + + private: + const std::shared_ptr _pimpl; + }; + + const std::unique_ptr _pimpl; + + service::TypeNames getTypeNames() const noexcept; + service::ResolverMap getResolvers() const noexcept; + +public: + GRAPHQLINTROSPECTION_EXPORT EnumValue(std::shared_ptr pimpl) noexcept; + GRAPHQLINTROSPECTION_EXPORT ~EnumValue(); +}; + +} // namespace graphql::introspection::object + +#endif // ENUMVALUEOBJECT_H diff --git a/src/introspection/FieldObject.cpp b/src/introspection/FieldObject.cpp new file mode 100644 index 00000000..b2825994 --- /dev/null +++ b/src/introspection/FieldObject.cpp @@ -0,0 +1,134 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// WARNING! Do not edit this file manually, your changes will be overwritten. + +#include "FieldObject.h" +#include "InputValueObject.h" +#include "TypeObject.h" + +#include "graphqlservice/internal/Introspection.h" + +#include +#include +#include +#include +#include + +using namespace std::literals; + +namespace graphql::introspection { +namespace object { + +Field::Field(std::shared_ptr pimpl) noexcept + : service::Object{ getTypeNames(), getResolvers() } + , _pimpl { std::make_unique>(std::move(pimpl)) } +{ +} + +Field::~Field() +{ + // This is empty, but explicitly defined here so that it can access the un-exported destructor + // of the implementation type. +} + +service::TypeNames Field::getTypeNames() const noexcept +{ + return { + R"gql(__Field)gql"sv + }; +} + +service::ResolverMap Field::getResolvers() const noexcept +{ + return { + { R"gql(args)gql"sv, [this](service::ResolverParams&& params) { return resolveArgs(std::move(params)); } }, + { R"gql(name)gql"sv, [this](service::ResolverParams&& params) { return resolveName(std::move(params)); } }, + { R"gql(type)gql"sv, [this](service::ResolverParams&& params) { return resolveType(std::move(params)); } }, + { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, + { R"gql(description)gql"sv, [this](service::ResolverParams&& params) { return resolveDescription(std::move(params)); } }, + { R"gql(isDeprecated)gql"sv, [this](service::ResolverParams&& params) { return resolveIsDeprecated(std::move(params)); } }, + { R"gql(deprecationReason)gql"sv, [this](service::ResolverParams&& params) { return resolveDeprecationReason(std::move(params)); } } + }; +} + +service::AwaitableResolver Field::resolveName(service::ResolverParams&& params) const +{ + std::unique_lock resolverLock(_resolverMutex); + auto directives = std::move(params.fieldDirectives); + auto result = _pimpl->getName(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + resolverLock.unlock(); + + return service::ModifiedResult::convert(std::move(result), std::move(params)); +} + +service::AwaitableResolver Field::resolveDescription(service::ResolverParams&& params) const +{ + std::unique_lock resolverLock(_resolverMutex); + auto directives = std::move(params.fieldDirectives); + auto result = _pimpl->getDescription(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + resolverLock.unlock(); + + return service::ModifiedResult::convert(std::move(result), std::move(params)); +} + +service::AwaitableResolver Field::resolveArgs(service::ResolverParams&& params) const +{ + std::unique_lock resolverLock(_resolverMutex); + auto directives = std::move(params.fieldDirectives); + auto result = _pimpl->getArgs(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + resolverLock.unlock(); + + return service::ModifiedResult::convert(std::move(result), std::move(params)); +} + +service::AwaitableResolver Field::resolveType(service::ResolverParams&& params) const +{ + std::unique_lock resolverLock(_resolverMutex); + auto directives = std::move(params.fieldDirectives); + auto result = _pimpl->getType(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + resolverLock.unlock(); + + return service::ModifiedResult::convert(std::move(result), std::move(params)); +} + +service::AwaitableResolver Field::resolveIsDeprecated(service::ResolverParams&& params) const +{ + std::unique_lock resolverLock(_resolverMutex); + auto directives = std::move(params.fieldDirectives); + auto result = _pimpl->getIsDeprecated(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + resolverLock.unlock(); + + return service::ModifiedResult::convert(std::move(result), std::move(params)); +} + +service::AwaitableResolver Field::resolveDeprecationReason(service::ResolverParams&& params) const +{ + std::unique_lock resolverLock(_resolverMutex); + auto directives = std::move(params.fieldDirectives); + auto result = _pimpl->getDeprecationReason(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + resolverLock.unlock(); + + return service::ModifiedResult::convert(std::move(result), std::move(params)); +} + +service::AwaitableResolver Field::resolve_typename(service::ResolverParams&& params) const +{ + return service::ModifiedResult::convert(std::string{ R"gql(__Field)gql" }, std::move(params)); +} + +} // namespace object + +void AddFieldDetails(const std::shared_ptr& typeField, const std::shared_ptr& schema) +{ + typeField->AddFields({ + schema::Field::Make(R"gql(name)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(String)gql"sv))), + schema::Field::Make(R"gql(description)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(String)gql"sv)), + schema::Field::Make(R"gql(args)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(__InputValue)gql"sv))))), + schema::Field::Make(R"gql(type)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(__Type)gql"sv))), + schema::Field::Make(R"gql(isDeprecated)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Boolean)gql"sv))), + schema::Field::Make(R"gql(deprecationReason)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(String)gql"sv)) + }); +} + +} // namespace graphql::introspection diff --git a/src/introspection/FieldObject.h b/src/introspection/FieldObject.h new file mode 100644 index 00000000..0020b6e1 --- /dev/null +++ b/src/introspection/FieldObject.h @@ -0,0 +1,182 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// WARNING! Do not edit this file manually, your changes will be overwritten. + +#pragma once + +#ifndef FIELDOBJECT_H +#define FIELDOBJECT_H + +#include "IntrospectionSchema.h" + +namespace graphql::introspection::object { +namespace methods::FieldHas { + +template +concept getNameWithParams = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult { impl.getName(std::move(params)) } }; +}; + +template +concept getName = requires (TImpl impl) +{ + { service::FieldResult { impl.getName() } }; +}; + +template +concept getDescriptionWithParams = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult> { impl.getDescription(std::move(params)) } }; +}; + +template +concept getDescription = requires (TImpl impl) +{ + { service::FieldResult> { impl.getDescription() } }; +}; + +template +concept getArgsWithParams = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult>> { impl.getArgs(std::move(params)) } }; +}; + +template +concept getArgs = requires (TImpl impl) +{ + { service::FieldResult>> { impl.getArgs() } }; +}; + +template +concept getTypeWithParams = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult> { impl.getType(std::move(params)) } }; +}; + +template +concept getType = requires (TImpl impl) +{ + { service::FieldResult> { impl.getType() } }; +}; + +template +concept getIsDeprecatedWithParams = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult { impl.getIsDeprecated(std::move(params)) } }; +}; + +template +concept getIsDeprecated = requires (TImpl impl) +{ + { service::FieldResult { impl.getIsDeprecated() } }; +}; + +template +concept getDeprecationReasonWithParams = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult> { impl.getDeprecationReason(std::move(params)) } }; +}; + +template +concept getDeprecationReason = requires (TImpl impl) +{ + { service::FieldResult> { impl.getDeprecationReason() } }; +}; + +template +concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.beginSelectionSet(params) }; +}; + +template +concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.endSelectionSet(params) }; +}; + +} // namespace methods::FieldHas + +class Field + : public service::Object +{ +private: + service::AwaitableResolver resolveName(service::ResolverParams&& params) const; + service::AwaitableResolver resolveDescription(service::ResolverParams&& params) const; + service::AwaitableResolver resolveArgs(service::ResolverParams&& params) const; + service::AwaitableResolver resolveType(service::ResolverParams&& params) const; + service::AwaitableResolver resolveIsDeprecated(service::ResolverParams&& params) const; + service::AwaitableResolver resolveDeprecationReason(service::ResolverParams&& params) const; + + service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; + + struct Concept + { + virtual ~Concept() = default; + + virtual service::FieldResult getName(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getDescription(service::FieldParams&& params) const = 0; + virtual service::FieldResult>> getArgs(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getType(service::FieldParams&& params) const = 0; + virtual service::FieldResult getIsDeprecated(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getDeprecationReason(service::FieldParams&& params) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::FieldResult getName(service::FieldParams&&) const final + { + return { _pimpl->getName() }; + } + + service::FieldResult> getDescription(service::FieldParams&&) const final + { + return { _pimpl->getDescription() }; + } + + service::FieldResult>> getArgs(service::FieldParams&&) const final + { + return { _pimpl->getArgs() }; + } + + service::FieldResult> getType(service::FieldParams&&) const final + { + return { _pimpl->getType() }; + } + + service::FieldResult getIsDeprecated(service::FieldParams&&) const final + { + return { _pimpl->getIsDeprecated() }; + } + + service::FieldResult> getDeprecationReason(service::FieldParams&&) const final + { + return { _pimpl->getDeprecationReason() }; + } + + private: + const std::shared_ptr _pimpl; + }; + + const std::unique_ptr _pimpl; + + service::TypeNames getTypeNames() const noexcept; + service::ResolverMap getResolvers() const noexcept; + +public: + GRAPHQLINTROSPECTION_EXPORT Field(std::shared_ptr pimpl) noexcept; + GRAPHQLINTROSPECTION_EXPORT ~Field(); +}; + +} // namespace graphql::introspection::object + +#endif // FIELDOBJECT_H diff --git a/src/introspection/InputValueObject.cpp b/src/introspection/InputValueObject.cpp new file mode 100644 index 00000000..9d1c51a7 --- /dev/null +++ b/src/introspection/InputValueObject.cpp @@ -0,0 +1,109 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// WARNING! Do not edit this file manually, your changes will be overwritten. + +#include "InputValueObject.h" +#include "TypeObject.h" + +#include "graphqlservice/internal/Introspection.h" + +#include +#include +#include +#include +#include + +using namespace std::literals; + +namespace graphql::introspection { +namespace object { + +InputValue::InputValue(std::shared_ptr pimpl) noexcept + : service::Object{ getTypeNames(), getResolvers() } + , _pimpl { std::make_unique>(std::move(pimpl)) } +{ +} + +InputValue::~InputValue() +{ + // This is empty, but explicitly defined here so that it can access the un-exported destructor + // of the implementation type. +} + +service::TypeNames InputValue::getTypeNames() const noexcept +{ + return { + R"gql(__InputValue)gql"sv + }; +} + +service::ResolverMap InputValue::getResolvers() const noexcept +{ + return { + { R"gql(name)gql"sv, [this](service::ResolverParams&& params) { return resolveName(std::move(params)); } }, + { R"gql(type)gql"sv, [this](service::ResolverParams&& params) { return resolveType(std::move(params)); } }, + { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, + { R"gql(description)gql"sv, [this](service::ResolverParams&& params) { return resolveDescription(std::move(params)); } }, + { R"gql(defaultValue)gql"sv, [this](service::ResolverParams&& params) { return resolveDefaultValue(std::move(params)); } } + }; +} + +service::AwaitableResolver InputValue::resolveName(service::ResolverParams&& params) const +{ + std::unique_lock resolverLock(_resolverMutex); + auto directives = std::move(params.fieldDirectives); + auto result = _pimpl->getName(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + resolverLock.unlock(); + + return service::ModifiedResult::convert(std::move(result), std::move(params)); +} + +service::AwaitableResolver InputValue::resolveDescription(service::ResolverParams&& params) const +{ + std::unique_lock resolverLock(_resolverMutex); + auto directives = std::move(params.fieldDirectives); + auto result = _pimpl->getDescription(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + resolverLock.unlock(); + + return service::ModifiedResult::convert(std::move(result), std::move(params)); +} + +service::AwaitableResolver InputValue::resolveType(service::ResolverParams&& params) const +{ + std::unique_lock resolverLock(_resolverMutex); + auto directives = std::move(params.fieldDirectives); + auto result = _pimpl->getType(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + resolverLock.unlock(); + + return service::ModifiedResult::convert(std::move(result), std::move(params)); +} + +service::AwaitableResolver InputValue::resolveDefaultValue(service::ResolverParams&& params) const +{ + std::unique_lock resolverLock(_resolverMutex); + auto directives = std::move(params.fieldDirectives); + auto result = _pimpl->getDefaultValue(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + resolverLock.unlock(); + + return service::ModifiedResult::convert(std::move(result), std::move(params)); +} + +service::AwaitableResolver InputValue::resolve_typename(service::ResolverParams&& params) const +{ + return service::ModifiedResult::convert(std::string{ R"gql(__InputValue)gql" }, std::move(params)); +} + +} // namespace object + +void AddInputValueDetails(const std::shared_ptr& typeInputValue, const std::shared_ptr& schema) +{ + typeInputValue->AddFields({ + schema::Field::Make(R"gql(name)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(String)gql"sv))), + schema::Field::Make(R"gql(description)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(String)gql"sv)), + schema::Field::Make(R"gql(type)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(__Type)gql"sv))), + schema::Field::Make(R"gql(defaultValue)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(String)gql"sv)) + }); +} + +} // namespace graphql::introspection diff --git a/src/introspection/InputValueObject.h b/src/introspection/InputValueObject.h new file mode 100644 index 00000000..b4ec2474 --- /dev/null +++ b/src/introspection/InputValueObject.h @@ -0,0 +1,144 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// WARNING! Do not edit this file manually, your changes will be overwritten. + +#pragma once + +#ifndef INPUTVALUEOBJECT_H +#define INPUTVALUEOBJECT_H + +#include "IntrospectionSchema.h" + +namespace graphql::introspection::object { +namespace methods::InputValueHas { + +template +concept getNameWithParams = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult { impl.getName(std::move(params)) } }; +}; + +template +concept getName = requires (TImpl impl) +{ + { service::FieldResult { impl.getName() } }; +}; + +template +concept getDescriptionWithParams = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult> { impl.getDescription(std::move(params)) } }; +}; + +template +concept getDescription = requires (TImpl impl) +{ + { service::FieldResult> { impl.getDescription() } }; +}; + +template +concept getTypeWithParams = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult> { impl.getType(std::move(params)) } }; +}; + +template +concept getType = requires (TImpl impl) +{ + { service::FieldResult> { impl.getType() } }; +}; + +template +concept getDefaultValueWithParams = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult> { impl.getDefaultValue(std::move(params)) } }; +}; + +template +concept getDefaultValue = requires (TImpl impl) +{ + { service::FieldResult> { impl.getDefaultValue() } }; +}; + +template +concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.beginSelectionSet(params) }; +}; + +template +concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.endSelectionSet(params) }; +}; + +} // namespace methods::InputValueHas + +class InputValue + : public service::Object +{ +private: + service::AwaitableResolver resolveName(service::ResolverParams&& params) const; + service::AwaitableResolver resolveDescription(service::ResolverParams&& params) const; + service::AwaitableResolver resolveType(service::ResolverParams&& params) const; + service::AwaitableResolver resolveDefaultValue(service::ResolverParams&& params) const; + + service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; + + struct Concept + { + virtual ~Concept() = default; + + virtual service::FieldResult getName(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getDescription(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getType(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getDefaultValue(service::FieldParams&& params) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::FieldResult getName(service::FieldParams&&) const final + { + return { _pimpl->getName() }; + } + + service::FieldResult> getDescription(service::FieldParams&&) const final + { + return { _pimpl->getDescription() }; + } + + service::FieldResult> getType(service::FieldParams&&) const final + { + return { _pimpl->getType() }; + } + + service::FieldResult> getDefaultValue(service::FieldParams&&) const final + { + return { _pimpl->getDefaultValue() }; + } + + private: + const std::shared_ptr _pimpl; + }; + + const std::unique_ptr _pimpl; + + service::TypeNames getTypeNames() const noexcept; + service::ResolverMap getResolvers() const noexcept; + +public: + GRAPHQLINTROSPECTION_EXPORT InputValue(std::shared_ptr pimpl) noexcept; + GRAPHQLINTROSPECTION_EXPORT ~InputValue(); +}; + +} // namespace graphql::introspection::object + +#endif // INPUTVALUEOBJECT_H diff --git a/src/introspection/IntrospectionSchema.cpp b/src/introspection/IntrospectionSchema.cpp new file mode 100644 index 00000000..bf7cd362 --- /dev/null +++ b/src/introspection/IntrospectionSchema.cpp @@ -0,0 +1,208 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// WARNING! Do not edit this file manually, your changes will be overwritten. + + +#include "graphqlservice/internal/Introspection.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace std::literals; + +namespace graphql { +namespace service { + +static const std::array s_namesTypeKind = { + R"gql(SCALAR)gql"sv, + R"gql(OBJECT)gql"sv, + R"gql(INTERFACE)gql"sv, + R"gql(UNION)gql"sv, + R"gql(ENUM)gql"sv, + R"gql(INPUT_OBJECT)gql"sv, + R"gql(LIST)gql"sv, + R"gql(NON_NULL)gql"sv +}; + +template <> +introspection::TypeKind ModifiedArgument::convert(const response::Value& value) +{ + if (!value.maybe_enum()) + { + throw service::schema_exception { { R"ex(not a valid __TypeKind value)ex" } }; + } + + const auto itr = std::find(s_namesTypeKind.cbegin(), s_namesTypeKind.cend(), value.get()); + + if (itr == s_namesTypeKind.cend()) + { + throw service::schema_exception { { R"ex(not a valid __TypeKind value)ex" } }; + } + + return static_cast(itr - s_namesTypeKind.cbegin()); +} + +template <> +service::AwaitableResolver ModifiedResult::convert(service::FieldResult result, ResolverParams params) +{ + return resolve(std::move(result), std::move(params), + [](introspection::TypeKind value, const ResolverParams&) + { + response::Value result(response::Type::EnumValue); + + result.set(std::string { s_namesTypeKind[static_cast(value)] }); + + return result; + }); +} + +static const std::array s_namesDirectiveLocation = { + R"gql(QUERY)gql"sv, + R"gql(MUTATION)gql"sv, + R"gql(SUBSCRIPTION)gql"sv, + R"gql(FIELD)gql"sv, + R"gql(FRAGMENT_DEFINITION)gql"sv, + R"gql(FRAGMENT_SPREAD)gql"sv, + R"gql(INLINE_FRAGMENT)gql"sv, + R"gql(SCHEMA)gql"sv, + R"gql(SCALAR)gql"sv, + R"gql(OBJECT)gql"sv, + R"gql(FIELD_DEFINITION)gql"sv, + R"gql(ARGUMENT_DEFINITION)gql"sv, + R"gql(INTERFACE)gql"sv, + R"gql(UNION)gql"sv, + R"gql(ENUM)gql"sv, + R"gql(ENUM_VALUE)gql"sv, + R"gql(INPUT_OBJECT)gql"sv, + R"gql(INPUT_FIELD_DEFINITION)gql"sv +}; + +template <> +introspection::DirectiveLocation ModifiedArgument::convert(const response::Value& value) +{ + if (!value.maybe_enum()) + { + throw service::schema_exception { { R"ex(not a valid __DirectiveLocation value)ex" } }; + } + + const auto itr = std::find(s_namesDirectiveLocation.cbegin(), s_namesDirectiveLocation.cend(), value.get()); + + if (itr == s_namesDirectiveLocation.cend()) + { + throw service::schema_exception { { R"ex(not a valid __DirectiveLocation value)ex" } }; + } + + return static_cast(itr - s_namesDirectiveLocation.cbegin()); +} + +template <> +service::AwaitableResolver ModifiedResult::convert(service::FieldResult result, ResolverParams params) +{ + return resolve(std::move(result), std::move(params), + [](introspection::DirectiveLocation value, const ResolverParams&) + { + response::Value result(response::Type::EnumValue); + + result.set(std::string { s_namesDirectiveLocation[static_cast(value)] }); + + return result; + }); +} + +} // namespace service + +namespace introspection { + +void AddTypesToSchema(const std::shared_ptr& schema) +{ + schema->AddType(R"gql(Boolean)gql"sv, schema::ScalarType::Make(R"gql(Boolean)gql"sv, R"md(Built-in type)md")); + schema->AddType(R"gql(Float)gql"sv, schema::ScalarType::Make(R"gql(Float)gql"sv, R"md(Built-in type)md")); + schema->AddType(R"gql(ID)gql"sv, schema::ScalarType::Make(R"gql(ID)gql"sv, R"md(Built-in type)md")); + schema->AddType(R"gql(Int)gql"sv, schema::ScalarType::Make(R"gql(Int)gql"sv, R"md(Built-in type)md")); + schema->AddType(R"gql(String)gql"sv, schema::ScalarType::Make(R"gql(String)gql"sv, R"md(Built-in type)md")); + auto typeTypeKind = schema::EnumType::Make(R"gql(__TypeKind)gql"sv, R"md()md"sv); + schema->AddType(R"gql(__TypeKind)gql"sv, typeTypeKind); + auto typeDirectiveLocation = schema::EnumType::Make(R"gql(__DirectiveLocation)gql"sv, R"md()md"sv); + schema->AddType(R"gql(__DirectiveLocation)gql"sv, typeDirectiveLocation); + auto typeSchema = schema::ObjectType::Make(R"gql(__Schema)gql"sv, R"md()md"); + schema->AddType(R"gql(__Schema)gql"sv, typeSchema); + auto typeType = schema::ObjectType::Make(R"gql(__Type)gql"sv, R"md()md"); + schema->AddType(R"gql(__Type)gql"sv, typeType); + auto typeField = schema::ObjectType::Make(R"gql(__Field)gql"sv, R"md()md"); + schema->AddType(R"gql(__Field)gql"sv, typeField); + auto typeInputValue = schema::ObjectType::Make(R"gql(__InputValue)gql"sv, R"md()md"); + schema->AddType(R"gql(__InputValue)gql"sv, typeInputValue); + auto typeEnumValue = schema::ObjectType::Make(R"gql(__EnumValue)gql"sv, R"md()md"); + schema->AddType(R"gql(__EnumValue)gql"sv, typeEnumValue); + auto typeDirective = schema::ObjectType::Make(R"gql(__Directive)gql"sv, R"md()md"); + schema->AddType(R"gql(__Directive)gql"sv, typeDirective); + + typeTypeKind->AddEnumValues({ + { service::s_namesTypeKind[static_cast(introspection::TypeKind::SCALAR)], R"md()md"sv, std::nullopt }, + { service::s_namesTypeKind[static_cast(introspection::TypeKind::OBJECT)], R"md()md"sv, std::nullopt }, + { service::s_namesTypeKind[static_cast(introspection::TypeKind::INTERFACE)], R"md()md"sv, std::nullopt }, + { service::s_namesTypeKind[static_cast(introspection::TypeKind::UNION)], R"md()md"sv, std::nullopt }, + { service::s_namesTypeKind[static_cast(introspection::TypeKind::ENUM)], R"md()md"sv, std::nullopt }, + { service::s_namesTypeKind[static_cast(introspection::TypeKind::INPUT_OBJECT)], R"md()md"sv, std::nullopt }, + { service::s_namesTypeKind[static_cast(introspection::TypeKind::LIST)], R"md()md"sv, std::nullopt }, + { service::s_namesTypeKind[static_cast(introspection::TypeKind::NON_NULL)], R"md()md"sv, std::nullopt } + }); + typeDirectiveLocation->AddEnumValues({ + { service::s_namesDirectiveLocation[static_cast(introspection::DirectiveLocation::QUERY)], R"md()md"sv, std::nullopt }, + { service::s_namesDirectiveLocation[static_cast(introspection::DirectiveLocation::MUTATION)], R"md()md"sv, std::nullopt }, + { service::s_namesDirectiveLocation[static_cast(introspection::DirectiveLocation::SUBSCRIPTION)], R"md()md"sv, std::nullopt }, + { service::s_namesDirectiveLocation[static_cast(introspection::DirectiveLocation::FIELD)], R"md()md"sv, std::nullopt }, + { service::s_namesDirectiveLocation[static_cast(introspection::DirectiveLocation::FRAGMENT_DEFINITION)], R"md()md"sv, std::nullopt }, + { service::s_namesDirectiveLocation[static_cast(introspection::DirectiveLocation::FRAGMENT_SPREAD)], R"md()md"sv, std::nullopt }, + { service::s_namesDirectiveLocation[static_cast(introspection::DirectiveLocation::INLINE_FRAGMENT)], R"md()md"sv, std::nullopt }, + { service::s_namesDirectiveLocation[static_cast(introspection::DirectiveLocation::SCHEMA)], R"md()md"sv, std::nullopt }, + { service::s_namesDirectiveLocation[static_cast(introspection::DirectiveLocation::SCALAR)], R"md()md"sv, std::nullopt }, + { service::s_namesDirectiveLocation[static_cast(introspection::DirectiveLocation::OBJECT)], R"md()md"sv, std::nullopt }, + { service::s_namesDirectiveLocation[static_cast(introspection::DirectiveLocation::FIELD_DEFINITION)], R"md()md"sv, std::nullopt }, + { service::s_namesDirectiveLocation[static_cast(introspection::DirectiveLocation::ARGUMENT_DEFINITION)], R"md()md"sv, std::nullopt }, + { service::s_namesDirectiveLocation[static_cast(introspection::DirectiveLocation::INTERFACE)], R"md()md"sv, std::nullopt }, + { service::s_namesDirectiveLocation[static_cast(introspection::DirectiveLocation::UNION)], R"md()md"sv, std::nullopt }, + { service::s_namesDirectiveLocation[static_cast(introspection::DirectiveLocation::ENUM)], R"md()md"sv, std::nullopt }, + { service::s_namesDirectiveLocation[static_cast(introspection::DirectiveLocation::ENUM_VALUE)], R"md()md"sv, std::nullopt }, + { service::s_namesDirectiveLocation[static_cast(introspection::DirectiveLocation::INPUT_OBJECT)], R"md()md"sv, std::nullopt }, + { service::s_namesDirectiveLocation[static_cast(introspection::DirectiveLocation::INPUT_FIELD_DEFINITION)], R"md()md"sv, std::nullopt } + }); + + AddSchemaDetails(typeSchema, schema); + AddTypeDetails(typeType, schema); + AddFieldDetails(typeField, schema); + AddInputValueDetails(typeInputValue, schema); + AddEnumValueDetails(typeEnumValue, schema); + AddDirectiveDetails(typeDirective, schema); + + schema->AddDirective(schema::Directive::Make(R"gql(skip)gql"sv, R"md()md"sv, { + introspection::DirectiveLocation::FIELD, + introspection::DirectiveLocation::FRAGMENT_SPREAD, + introspection::DirectiveLocation::INLINE_FRAGMENT + }, { + schema::InputValue::Make(R"gql(if)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Boolean)gql"sv)), R"gql()gql"sv) + })); + schema->AddDirective(schema::Directive::Make(R"gql(include)gql"sv, R"md()md"sv, { + introspection::DirectiveLocation::FIELD, + introspection::DirectiveLocation::FRAGMENT_SPREAD, + introspection::DirectiveLocation::INLINE_FRAGMENT + }, { + schema::InputValue::Make(R"gql(if)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Boolean)gql"sv)), R"gql()gql"sv) + })); + schema->AddDirective(schema::Directive::Make(R"gql(deprecated)gql"sv, R"md()md"sv, { + introspection::DirectiveLocation::FIELD_DEFINITION, + introspection::DirectiveLocation::ENUM_VALUE + }, { + schema::InputValue::Make(R"gql(reason)gql"sv, R"md()md"sv, schema->LookupType(R"gql(String)gql"sv), R"gql("No longer supported")gql"sv) + })); +} + +} // namespace introspection +} // namespace graphql diff --git a/src/introspection/IntrospectionSchema.h b/src/introspection/IntrospectionSchema.h new file mode 100644 index 00000000..a701780a --- /dev/null +++ b/src/introspection/IntrospectionSchema.h @@ -0,0 +1,120 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// WARNING! Do not edit this file manually, your changes will be overwritten. + +#pragma once + +#ifndef INTROSPECTIONSCHEMA_H +#define INTROSPECTIONSCHEMA_H + +#include "graphqlservice/internal/Schema.h" + +// Check if the library version is compatible with schemagen 4.0.0 +static_assert(graphql::internal::MajorVersion == 4, "regenerate with schemagen: major version mismatch"); +static_assert(graphql::internal::MinorVersion == 0, "regenerate with schemagen: minor version mismatch"); + +// clang-format off +#ifdef GRAPHQL_DLLEXPORTS + #ifdef IMPL_GRAPHQLINTROSPECTION_DLL + #define GRAPHQLINTROSPECTION_EXPORT __declspec(dllexport) + #else // !IMPL_GRAPHQLINTROSPECTION_DLL + #define GRAPHQLINTROSPECTION_EXPORT __declspec(dllimport) + #endif // !IMPL_GRAPHQLINTROSPECTION_DLL +#else // !GRAPHQL_DLLEXPORTS + #define GRAPHQLINTROSPECTION_EXPORT +#endif // !GRAPHQL_DLLEXPORTS +// clang-format on + +#include +#include +#include + +namespace graphql { +namespace introspection { + +enum class TypeKind +{ + SCALAR, + OBJECT, + INTERFACE, + UNION, + ENUM, + INPUT_OBJECT, + LIST, + NON_NULL +}; + +enum class DirectiveLocation +{ + QUERY, + MUTATION, + SUBSCRIPTION, + FIELD, + FRAGMENT_DEFINITION, + FRAGMENT_SPREAD, + INLINE_FRAGMENT, + SCHEMA, + SCALAR, + OBJECT, + FIELD_DEFINITION, + ARGUMENT_DEFINITION, + INTERFACE, + UNION, + ENUM, + ENUM_VALUE, + INPUT_OBJECT, + INPUT_FIELD_DEFINITION +}; + +class Schema; +class Type; +class Field; +class InputValue; +class EnumValue; +class Directive; + +namespace object { + +class Schema; +class Type; +class Field; +class InputValue; +class EnumValue; +class Directive; + +} // namespace object + +void AddSchemaDetails(const std::shared_ptr& typeSchema, const std::shared_ptr& schema); +void AddTypeDetails(const std::shared_ptr& typeType, const std::shared_ptr& schema); +void AddFieldDetails(const std::shared_ptr& typeField, const std::shared_ptr& schema); +void AddInputValueDetails(const std::shared_ptr& typeInputValue, const std::shared_ptr& schema); +void AddEnumValueDetails(const std::shared_ptr& typeEnumValue, const std::shared_ptr& schema); +void AddDirectiveDetails(const std::shared_ptr& typeDirective, const std::shared_ptr& schema); + +GRAPHQLINTROSPECTION_EXPORT void AddTypesToSchema(const std::shared_ptr& schema); + +} // namespace introspection + +namespace service { + +#ifdef GRAPHQL_DLLEXPORTS +// Export all of the built-in converters +template <> +GRAPHQLINTROSPECTION_EXPORT introspection::TypeKind ModifiedArgument::convert( + const response::Value& value); +template <> +GRAPHQLINTROSPECTION_EXPORT AwaitableResolver ModifiedResult::convert( + FieldResult result, ResolverParams params); +template <> +GRAPHQLINTROSPECTION_EXPORT introspection::DirectiveLocation ModifiedArgument::convert( + const response::Value& value); +template <> +GRAPHQLINTROSPECTION_EXPORT AwaitableResolver ModifiedResult::convert( + FieldResult result, ResolverParams params); +#endif // GRAPHQL_DLLEXPORTS + +} // namespace service +} // namespace graphql + +#endif // INTROSPECTIONSCHEMA_H diff --git a/src/introspection/SchemaObject.cpp b/src/introspection/SchemaObject.cpp new file mode 100644 index 00000000..eb5cc0fc --- /dev/null +++ b/src/introspection/SchemaObject.cpp @@ -0,0 +1,122 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// WARNING! Do not edit this file manually, your changes will be overwritten. + +#include "SchemaObject.h" +#include "TypeObject.h" +#include "DirectiveObject.h" + +#include "graphqlservice/internal/Introspection.h" + +#include +#include +#include +#include +#include + +using namespace std::literals; + +namespace graphql::introspection { +namespace object { + +Schema::Schema(std::shared_ptr pimpl) noexcept + : service::Object{ getTypeNames(), getResolvers() } + , _pimpl { std::make_unique>(std::move(pimpl)) } +{ +} + +Schema::~Schema() +{ + // This is empty, but explicitly defined here so that it can access the un-exported destructor + // of the implementation type. +} + +service::TypeNames Schema::getTypeNames() const noexcept +{ + return { + R"gql(__Schema)gql"sv + }; +} + +service::ResolverMap Schema::getResolvers() const noexcept +{ + return { + { R"gql(types)gql"sv, [this](service::ResolverParams&& params) { return resolveTypes(std::move(params)); } }, + { R"gql(queryType)gql"sv, [this](service::ResolverParams&& params) { return resolveQueryType(std::move(params)); } }, + { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, + { R"gql(directives)gql"sv, [this](service::ResolverParams&& params) { return resolveDirectives(std::move(params)); } }, + { R"gql(mutationType)gql"sv, [this](service::ResolverParams&& params) { return resolveMutationType(std::move(params)); } }, + { R"gql(subscriptionType)gql"sv, [this](service::ResolverParams&& params) { return resolveSubscriptionType(std::move(params)); } } + }; +} + +service::AwaitableResolver Schema::resolveTypes(service::ResolverParams&& params) const +{ + std::unique_lock resolverLock(_resolverMutex); + auto directives = std::move(params.fieldDirectives); + auto result = _pimpl->getTypes(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + resolverLock.unlock(); + + return service::ModifiedResult::convert(std::move(result), std::move(params)); +} + +service::AwaitableResolver Schema::resolveQueryType(service::ResolverParams&& params) const +{ + std::unique_lock resolverLock(_resolverMutex); + auto directives = std::move(params.fieldDirectives); + auto result = _pimpl->getQueryType(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + resolverLock.unlock(); + + return service::ModifiedResult::convert(std::move(result), std::move(params)); +} + +service::AwaitableResolver Schema::resolveMutationType(service::ResolverParams&& params) const +{ + std::unique_lock resolverLock(_resolverMutex); + auto directives = std::move(params.fieldDirectives); + auto result = _pimpl->getMutationType(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + resolverLock.unlock(); + + return service::ModifiedResult::convert(std::move(result), std::move(params)); +} + +service::AwaitableResolver Schema::resolveSubscriptionType(service::ResolverParams&& params) const +{ + std::unique_lock resolverLock(_resolverMutex); + auto directives = std::move(params.fieldDirectives); + auto result = _pimpl->getSubscriptionType(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + resolverLock.unlock(); + + return service::ModifiedResult::convert(std::move(result), std::move(params)); +} + +service::AwaitableResolver Schema::resolveDirectives(service::ResolverParams&& params) const +{ + std::unique_lock resolverLock(_resolverMutex); + auto directives = std::move(params.fieldDirectives); + auto result = _pimpl->getDirectives(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + resolverLock.unlock(); + + return service::ModifiedResult::convert(std::move(result), std::move(params)); +} + +service::AwaitableResolver Schema::resolve_typename(service::ResolverParams&& params) const +{ + return service::ModifiedResult::convert(std::string{ R"gql(__Schema)gql" }, std::move(params)); +} + +} // namespace object + +void AddSchemaDetails(const std::shared_ptr& typeSchema, const std::shared_ptr& schema) +{ + typeSchema->AddFields({ + schema::Field::Make(R"gql(types)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(__Type)gql"sv))))), + schema::Field::Make(R"gql(queryType)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(__Type)gql"sv))), + schema::Field::Make(R"gql(mutationType)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(__Type)gql"sv)), + schema::Field::Make(R"gql(subscriptionType)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(__Type)gql"sv)), + schema::Field::Make(R"gql(directives)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(__Directive)gql"sv))))) + }); +} + +} // namespace graphql::introspection diff --git a/src/introspection/SchemaObject.h b/src/introspection/SchemaObject.h new file mode 100644 index 00000000..1c982eea --- /dev/null +++ b/src/introspection/SchemaObject.h @@ -0,0 +1,163 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// WARNING! Do not edit this file manually, your changes will be overwritten. + +#pragma once + +#ifndef SCHEMAOBJECT_H +#define SCHEMAOBJECT_H + +#include "IntrospectionSchema.h" + +namespace graphql::introspection::object { +namespace methods::SchemaHas { + +template +concept getTypesWithParams = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult>> { impl.getTypes(std::move(params)) } }; +}; + +template +concept getTypes = requires (TImpl impl) +{ + { service::FieldResult>> { impl.getTypes() } }; +}; + +template +concept getQueryTypeWithParams = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult> { impl.getQueryType(std::move(params)) } }; +}; + +template +concept getQueryType = requires (TImpl impl) +{ + { service::FieldResult> { impl.getQueryType() } }; +}; + +template +concept getMutationTypeWithParams = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult> { impl.getMutationType(std::move(params)) } }; +}; + +template +concept getMutationType = requires (TImpl impl) +{ + { service::FieldResult> { impl.getMutationType() } }; +}; + +template +concept getSubscriptionTypeWithParams = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult> { impl.getSubscriptionType(std::move(params)) } }; +}; + +template +concept getSubscriptionType = requires (TImpl impl) +{ + { service::FieldResult> { impl.getSubscriptionType() } }; +}; + +template +concept getDirectivesWithParams = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult>> { impl.getDirectives(std::move(params)) } }; +}; + +template +concept getDirectives = requires (TImpl impl) +{ + { service::FieldResult>> { impl.getDirectives() } }; +}; + +template +concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.beginSelectionSet(params) }; +}; + +template +concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.endSelectionSet(params) }; +}; + +} // namespace methods::SchemaHas + +class Schema + : public service::Object +{ +private: + service::AwaitableResolver resolveTypes(service::ResolverParams&& params) const; + service::AwaitableResolver resolveQueryType(service::ResolverParams&& params) const; + service::AwaitableResolver resolveMutationType(service::ResolverParams&& params) const; + service::AwaitableResolver resolveSubscriptionType(service::ResolverParams&& params) const; + service::AwaitableResolver resolveDirectives(service::ResolverParams&& params) const; + + service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; + + struct Concept + { + virtual ~Concept() = default; + + virtual service::FieldResult>> getTypes(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getQueryType(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getMutationType(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getSubscriptionType(service::FieldParams&& params) const = 0; + virtual service::FieldResult>> getDirectives(service::FieldParams&& params) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::FieldResult>> getTypes(service::FieldParams&&) const final + { + return { _pimpl->getTypes() }; + } + + service::FieldResult> getQueryType(service::FieldParams&&) const final + { + return { _pimpl->getQueryType() }; + } + + service::FieldResult> getMutationType(service::FieldParams&&) const final + { + return { _pimpl->getMutationType() }; + } + + service::FieldResult> getSubscriptionType(service::FieldParams&&) const final + { + return { _pimpl->getSubscriptionType() }; + } + + service::FieldResult>> getDirectives(service::FieldParams&&) const final + { + return { _pimpl->getDirectives() }; + } + + private: + const std::shared_ptr _pimpl; + }; + + const std::unique_ptr _pimpl; + + service::TypeNames getTypeNames() const noexcept; + service::ResolverMap getResolvers() const noexcept; + +public: + GRAPHQLINTROSPECTION_EXPORT Schema(std::shared_ptr pimpl) noexcept; + GRAPHQLINTROSPECTION_EXPORT ~Schema(); +}; + +} // namespace graphql::introspection::object + +#endif // SCHEMAOBJECT_H diff --git a/src/introspection/TypeObject.cpp b/src/introspection/TypeObject.cpp new file mode 100644 index 00000000..42bf4548 --- /dev/null +++ b/src/introspection/TypeObject.cpp @@ -0,0 +1,206 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// WARNING! Do not edit this file manually, your changes will be overwritten. + +#include "TypeObject.h" +#include "FieldObject.h" +#include "TypeObject.h" +#include "EnumValueObject.h" +#include "InputValueObject.h" + +#include "graphqlservice/internal/Introspection.h" + +#include +#include +#include +#include +#include + +using namespace std::literals; + +namespace graphql::introspection { +namespace object { + +Type::Type(std::shared_ptr pimpl) noexcept + : service::Object{ getTypeNames(), getResolvers() } + , _pimpl { std::make_unique>(std::move(pimpl)) } +{ +} + +Type::~Type() +{ + // This is empty, but explicitly defined here so that it can access the un-exported destructor + // of the implementation type. +} + +service::TypeNames Type::getTypeNames() const noexcept +{ + return { + R"gql(__Type)gql"sv + }; +} + +service::ResolverMap Type::getResolvers() const noexcept +{ + return { + { R"gql(kind)gql"sv, [this](service::ResolverParams&& params) { return resolveKind(std::move(params)); } }, + { R"gql(name)gql"sv, [this](service::ResolverParams&& params) { return resolveName(std::move(params)); } }, + { R"gql(fields)gql"sv, [this](service::ResolverParams&& params) { return resolveFields(std::move(params)); } }, + { R"gql(ofType)gql"sv, [this](service::ResolverParams&& params) { return resolveOfType(std::move(params)); } }, + { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, + { R"gql(enumValues)gql"sv, [this](service::ResolverParams&& params) { return resolveEnumValues(std::move(params)); } }, + { R"gql(interfaces)gql"sv, [this](service::ResolverParams&& params) { return resolveInterfaces(std::move(params)); } }, + { R"gql(description)gql"sv, [this](service::ResolverParams&& params) { return resolveDescription(std::move(params)); } }, + { R"gql(inputFields)gql"sv, [this](service::ResolverParams&& params) { return resolveInputFields(std::move(params)); } }, + { R"gql(possibleTypes)gql"sv, [this](service::ResolverParams&& params) { return resolvePossibleTypes(std::move(params)); } } + }; +} + +service::AwaitableResolver Type::resolveKind(service::ResolverParams&& params) const +{ + std::unique_lock resolverLock(_resolverMutex); + auto directives = std::move(params.fieldDirectives); + auto result = _pimpl->getKind(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + resolverLock.unlock(); + + return service::ModifiedResult::convert(std::move(result), std::move(params)); +} + +service::AwaitableResolver Type::resolveName(service::ResolverParams&& params) const +{ + std::unique_lock resolverLock(_resolverMutex); + auto directives = std::move(params.fieldDirectives); + auto result = _pimpl->getName(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + resolverLock.unlock(); + + return service::ModifiedResult::convert(std::move(result), std::move(params)); +} + +service::AwaitableResolver Type::resolveDescription(service::ResolverParams&& params) const +{ + std::unique_lock resolverLock(_resolverMutex); + auto directives = std::move(params.fieldDirectives); + auto result = _pimpl->getDescription(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + resolverLock.unlock(); + + return service::ModifiedResult::convert(std::move(result), std::move(params)); +} + +service::AwaitableResolver Type::resolveFields(service::ResolverParams&& params) const +{ + const auto defaultArguments = []() + { + response::Value values(response::Type::Map); + response::Value entry; + + entry = response::Value(false); + values.emplace_back("includeDeprecated", std::move(entry)); + + return values; + }(); + + auto pairIncludeDeprecated = service::ModifiedArgument::find("includeDeprecated", params.arguments); + auto argIncludeDeprecated = (pairIncludeDeprecated.second + ? std::move(pairIncludeDeprecated.first) + : service::ModifiedArgument::require("includeDeprecated", defaultArguments)); + std::unique_lock resolverLock(_resolverMutex); + auto directives = std::move(params.fieldDirectives); + auto result = _pimpl->getFields(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argIncludeDeprecated)); + resolverLock.unlock(); + + return service::ModifiedResult::convert(std::move(result), std::move(params)); +} + +service::AwaitableResolver Type::resolveInterfaces(service::ResolverParams&& params) const +{ + std::unique_lock resolverLock(_resolverMutex); + auto directives = std::move(params.fieldDirectives); + auto result = _pimpl->getInterfaces(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + resolverLock.unlock(); + + return service::ModifiedResult::convert(std::move(result), std::move(params)); +} + +service::AwaitableResolver Type::resolvePossibleTypes(service::ResolverParams&& params) const +{ + std::unique_lock resolverLock(_resolverMutex); + auto directives = std::move(params.fieldDirectives); + auto result = _pimpl->getPossibleTypes(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + resolverLock.unlock(); + + return service::ModifiedResult::convert(std::move(result), std::move(params)); +} + +service::AwaitableResolver Type::resolveEnumValues(service::ResolverParams&& params) const +{ + const auto defaultArguments = []() + { + response::Value values(response::Type::Map); + response::Value entry; + + entry = response::Value(false); + values.emplace_back("includeDeprecated", std::move(entry)); + + return values; + }(); + + auto pairIncludeDeprecated = service::ModifiedArgument::find("includeDeprecated", params.arguments); + auto argIncludeDeprecated = (pairIncludeDeprecated.second + ? std::move(pairIncludeDeprecated.first) + : service::ModifiedArgument::require("includeDeprecated", defaultArguments)); + std::unique_lock resolverLock(_resolverMutex); + auto directives = std::move(params.fieldDirectives); + auto result = _pimpl->getEnumValues(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argIncludeDeprecated)); + resolverLock.unlock(); + + return service::ModifiedResult::convert(std::move(result), std::move(params)); +} + +service::AwaitableResolver Type::resolveInputFields(service::ResolverParams&& params) const +{ + std::unique_lock resolverLock(_resolverMutex); + auto directives = std::move(params.fieldDirectives); + auto result = _pimpl->getInputFields(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + resolverLock.unlock(); + + return service::ModifiedResult::convert(std::move(result), std::move(params)); +} + +service::AwaitableResolver Type::resolveOfType(service::ResolverParams&& params) const +{ + std::unique_lock resolverLock(_resolverMutex); + auto directives = std::move(params.fieldDirectives); + auto result = _pimpl->getOfType(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + resolverLock.unlock(); + + return service::ModifiedResult::convert(std::move(result), std::move(params)); +} + +service::AwaitableResolver Type::resolve_typename(service::ResolverParams&& params) const +{ + return service::ModifiedResult::convert(std::string{ R"gql(__Type)gql" }, std::move(params)); +} + +} // namespace object + +void AddTypeDetails(const std::shared_ptr& typeType, const std::shared_ptr& schema) +{ + typeType->AddFields({ + schema::Field::Make(R"gql(kind)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(__TypeKind)gql"sv))), + schema::Field::Make(R"gql(name)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(String)gql"sv)), + schema::Field::Make(R"gql(description)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(String)gql"sv)), + schema::Field::Make(R"gql(fields)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(__Field)gql"sv))), { + schema::InputValue::Make(R"gql(includeDeprecated)gql"sv, R"md()md"sv, schema->LookupType(R"gql(Boolean)gql"sv), R"gql(false)gql"sv) + }), + schema::Field::Make(R"gql(interfaces)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(__Type)gql"sv)))), + schema::Field::Make(R"gql(possibleTypes)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(__Type)gql"sv)))), + schema::Field::Make(R"gql(enumValues)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(__EnumValue)gql"sv))), { + schema::InputValue::Make(R"gql(includeDeprecated)gql"sv, R"md()md"sv, schema->LookupType(R"gql(Boolean)gql"sv), R"gql(false)gql"sv) + }), + schema::Field::Make(R"gql(inputFields)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(__InputValue)gql"sv)))), + schema::Field::Make(R"gql(ofType)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(__Type)gql"sv)) + }); +} + +} // namespace graphql::introspection diff --git a/src/introspection/TypeObject.h b/src/introspection/TypeObject.h new file mode 100644 index 00000000..164f4165 --- /dev/null +++ b/src/introspection/TypeObject.h @@ -0,0 +1,239 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// WARNING! Do not edit this file manually, your changes will be overwritten. + +#pragma once + +#ifndef TYPEOBJECT_H +#define TYPEOBJECT_H + +#include "IntrospectionSchema.h" + +namespace graphql::introspection::object { +namespace methods::TypeHas { + +template +concept getKindWithParams = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult { impl.getKind(std::move(params)) } }; +}; + +template +concept getKind = requires (TImpl impl) +{ + { service::FieldResult { impl.getKind() } }; +}; + +template +concept getNameWithParams = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult> { impl.getName(std::move(params)) } }; +}; + +template +concept getName = requires (TImpl impl) +{ + { service::FieldResult> { impl.getName() } }; +}; + +template +concept getDescriptionWithParams = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult> { impl.getDescription(std::move(params)) } }; +}; + +template +concept getDescription = requires (TImpl impl) +{ + { service::FieldResult> { impl.getDescription() } }; +}; + +template +concept getFieldsWithParams = requires (TImpl impl, service::FieldParams params, std::optional includeDeprecatedArg) +{ + { service::FieldResult>>> { impl.getFields(std::move(params), std::move(includeDeprecatedArg)) } }; +}; + +template +concept getFields = requires (TImpl impl, std::optional includeDeprecatedArg) +{ + { service::FieldResult>>> { impl.getFields(std::move(includeDeprecatedArg)) } }; +}; + +template +concept getInterfacesWithParams = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult>>> { impl.getInterfaces(std::move(params)) } }; +}; + +template +concept getInterfaces = requires (TImpl impl) +{ + { service::FieldResult>>> { impl.getInterfaces() } }; +}; + +template +concept getPossibleTypesWithParams = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult>>> { impl.getPossibleTypes(std::move(params)) } }; +}; + +template +concept getPossibleTypes = requires (TImpl impl) +{ + { service::FieldResult>>> { impl.getPossibleTypes() } }; +}; + +template +concept getEnumValuesWithParams = requires (TImpl impl, service::FieldParams params, std::optional includeDeprecatedArg) +{ + { service::FieldResult>>> { impl.getEnumValues(std::move(params), std::move(includeDeprecatedArg)) } }; +}; + +template +concept getEnumValues = requires (TImpl impl, std::optional includeDeprecatedArg) +{ + { service::FieldResult>>> { impl.getEnumValues(std::move(includeDeprecatedArg)) } }; +}; + +template +concept getInputFieldsWithParams = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult>>> { impl.getInputFields(std::move(params)) } }; +}; + +template +concept getInputFields = requires (TImpl impl) +{ + { service::FieldResult>>> { impl.getInputFields() } }; +}; + +template +concept getOfTypeWithParams = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult> { impl.getOfType(std::move(params)) } }; +}; + +template +concept getOfType = requires (TImpl impl) +{ + { service::FieldResult> { impl.getOfType() } }; +}; + +template +concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.beginSelectionSet(params) }; +}; + +template +concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) +{ + { impl.endSelectionSet(params) }; +}; + +} // namespace methods::TypeHas + +class Type + : public service::Object +{ +private: + service::AwaitableResolver resolveKind(service::ResolverParams&& params) const; + service::AwaitableResolver resolveName(service::ResolverParams&& params) const; + service::AwaitableResolver resolveDescription(service::ResolverParams&& params) const; + service::AwaitableResolver resolveFields(service::ResolverParams&& params) const; + service::AwaitableResolver resolveInterfaces(service::ResolverParams&& params) const; + service::AwaitableResolver resolvePossibleTypes(service::ResolverParams&& params) const; + service::AwaitableResolver resolveEnumValues(service::ResolverParams&& params) const; + service::AwaitableResolver resolveInputFields(service::ResolverParams&& params) const; + service::AwaitableResolver resolveOfType(service::ResolverParams&& params) const; + + service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; + + struct Concept + { + virtual ~Concept() = default; + + virtual service::FieldResult getKind(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getName(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getDescription(service::FieldParams&& params) const = 0; + virtual service::FieldResult>>> getFields(service::FieldParams&& params, std::optional&& includeDeprecatedArg) const = 0; + virtual service::FieldResult>>> getInterfaces(service::FieldParams&& params) const = 0; + virtual service::FieldResult>>> getPossibleTypes(service::FieldParams&& params) const = 0; + virtual service::FieldResult>>> getEnumValues(service::FieldParams&& params, std::optional&& includeDeprecatedArg) const = 0; + virtual service::FieldResult>>> getInputFields(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getOfType(service::FieldParams&& params) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::FieldResult getKind(service::FieldParams&&) const final + { + return { _pimpl->getKind() }; + } + + service::FieldResult> getName(service::FieldParams&&) const final + { + return { _pimpl->getName() }; + } + + service::FieldResult> getDescription(service::FieldParams&&) const final + { + return { _pimpl->getDescription() }; + } + + service::FieldResult>>> getFields(service::FieldParams&&, std::optional&& includeDeprecatedArg) const final + { + return { _pimpl->getFields(std::move(includeDeprecatedArg)) }; + } + + service::FieldResult>>> getInterfaces(service::FieldParams&&) const final + { + return { _pimpl->getInterfaces() }; + } + + service::FieldResult>>> getPossibleTypes(service::FieldParams&&) const final + { + return { _pimpl->getPossibleTypes() }; + } + + service::FieldResult>>> getEnumValues(service::FieldParams&&, std::optional&& includeDeprecatedArg) const final + { + return { _pimpl->getEnumValues(std::move(includeDeprecatedArg)) }; + } + + service::FieldResult>>> getInputFields(service::FieldParams&&) const final + { + return { _pimpl->getInputFields() }; + } + + service::FieldResult> getOfType(service::FieldParams&&) const final + { + return { _pimpl->getOfType() }; + } + + private: + const std::shared_ptr _pimpl; + }; + + const std::unique_ptr _pimpl; + + service::TypeNames getTypeNames() const noexcept; + service::ResolverMap getResolvers() const noexcept; + +public: + GRAPHQLINTROSPECTION_EXPORT Type(std::shared_ptr pimpl) noexcept; + GRAPHQLINTROSPECTION_EXPORT ~Type(); +}; + +} // namespace graphql::introspection::object + +#endif // TYPEOBJECT_H diff --git a/src/introspection/introspection_schema_files b/src/introspection/introspection_schema_files new file mode 100644 index 00000000..fba57600 --- /dev/null +++ b/src/introspection/introspection_schema_files @@ -0,0 +1,7 @@ +IntrospectionSchema.cpp +SchemaObject.cpp +TypeObject.cpp +FieldObject.cpp +InputValueObject.cpp +EnumValueObject.cpp +DirectiveObject.cpp diff --git a/src/introspection/schema.introspection.graphql b/src/introspection/schema.introspection.graphql new file mode 100644 index 00000000..e5098ac2 --- /dev/null +++ b/src/introspection/schema.introspection.graphql @@ -0,0 +1,104 @@ +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. + +# Introspection Schema: http://spec.graphql.org/June2018/#sec-Schema-Introspection +type __Schema { + types: [__Type!]! + queryType: __Type! + mutationType: __Type + subscriptionType: __Type + directives: [__Directive!]! +} + +type __Type { + kind: __TypeKind! + name: String + description: String + + # OBJECT and INTERFACE only + fields(includeDeprecated: Boolean = false): [__Field!] + + # OBJECT only + interfaces: [__Type!] + + # INTERFACE and UNION only + possibleTypes: [__Type!] + + # ENUM only + enumValues(includeDeprecated: Boolean = false): [__EnumValue!] + + # INPUT_OBJECT only + inputFields: [__InputValue!] + + # NON_NULL and LIST only + ofType: __Type +} + +type __Field { + name: String! + description: String + args: [__InputValue!]! + type: __Type! + isDeprecated: Boolean! + deprecationReason: String +} + +type __InputValue { + name: String! + description: String + type: __Type! + defaultValue: String +} + +type __EnumValue { + name: String! + description: String + isDeprecated: Boolean! + deprecationReason: String +} + +enum __TypeKind { + SCALAR + OBJECT + INTERFACE + UNION + ENUM + INPUT_OBJECT + LIST + NON_NULL +} + +type __Directive { + name: String! + description: String + locations: [__DirectiveLocation!]! + args: [__InputValue!]! +} + +enum __DirectiveLocation { + QUERY + MUTATION + SUBSCRIPTION + FIELD + FRAGMENT_DEFINITION + FRAGMENT_SPREAD + INLINE_FRAGMENT + SCHEMA + SCALAR + OBJECT + FIELD_DEFINITION + ARGUMENT_DEFINITION + INTERFACE + UNION + ENUM + ENUM_VALUE + INPUT_OBJECT + INPUT_FIELD_DEFINITION +} + +# These directives are always defined and should be included in the Introspection schema. +directive @skip(if: Boolean!) on FIELD | FRAGMENT_SPREAD | INLINE_FRAGMENT +directive @include(if: Boolean!) on FIELD | FRAGMENT_SPREAD | INLINE_FRAGMENT +directive @deprecated( + reason: String = "No longer supported" +) on FIELD_DEFINITION | ENUM_VALUE From a771fede9f5e5191f61841334ab1bc5da0b37745 Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Thu, 9 Dec 2021 13:51:45 -0800 Subject: [PATCH 075/119] Remove mergeFiles handling --- include/SchemaGenerator.h | 1 - src/SchemaGenerator.cpp | 256 +++++++------------------------------- 2 files changed, 44 insertions(+), 213 deletions(-) diff --git a/include/SchemaGenerator.h b/include/SchemaGenerator.h index cd7a9647..38972130 100644 --- a/include/SchemaGenerator.h +++ b/include/SchemaGenerator.h @@ -21,7 +21,6 @@ struct GeneratorOptions const std::optional paths; const bool verbose = false; const bool stubs = false; - const bool mergeFiles = false; const bool noIntrospection = false; }; diff --git a/src/SchemaGenerator.cpp b/src/SchemaGenerator.cpp index 35947322..ac73617a 100644 --- a/src/SchemaGenerator.cpp +++ b/src/SchemaGenerator.cpp @@ -111,14 +111,11 @@ std::vector Generator::Build() const noexcept builtFiles.push_back(_sourcePath); } - if (!_options.mergeFiles) - { - auto separateFiles = outputSeparateFiles(); + auto separateFiles = outputSeparateFiles(); - for (auto& file : separateFiles) - { - builtFiles.push_back(std::move(file)); - } + for (auto& file : separateFiles) + { + builtFiles.push_back(std::move(file)); } return builtFiles; @@ -303,90 +300,6 @@ static_assert(graphql::internal::MinorVersion == )cpp" headerFile << std::endl; } - if (_options.mergeFiles) - { - if (!_loader.getInterfaceTypes().empty()) - { - // Output the full declarations - for (const auto& interfaceType : _loader.getInterfaceTypes()) - { - outputInterfaceDeclaration(headerFile, interfaceType.cppType); - headerFile << std::endl; - } - } - - if (!_loader.getUnionTypes().empty()) - { - // Output the full declarations - for (const auto& unionType : _loader.getUnionTypes()) - { - outputInterfaceDeclaration(headerFile, unionType.cppType); - headerFile << std::endl; - } - } - - if (!_loader.getObjectTypes().empty()) - { - if (!_loader.isIntrospection()) - { - objectNamespace.enter(); - - NamespaceScope implementsNamespace { headerFile, R"cpp(implements)cpp", true }; - - for (const auto& objectType : _loader.getObjectTypes()) - { - if (objectType.interfaces.empty()) - { - continue; - } - - if (implementsNamespace.enter()) - { - headerFile << std::endl; - } - - // Output the implements concept declarations - outputObjectImplements(headerFile, objectType); - } - - if (implementsNamespace.exit()) - { - headerFile << std::endl; - } - - NamespaceScope stubNamespace { headerFile, "methods", true }; - - // Output the stub concept declarations - for (const auto& objectType : _loader.getObjectTypes()) - { - if (!stubNamespace.enter()) - { - headerFile << std::endl; - } - - std::ostringstream ossConceptNamespace; - - ossConceptNamespace << objectType.cppType << R"cpp(Has)cpp"; - - const auto conceptNamespace = ossConceptNamespace.str(); - NamespaceScope conceptSubNamespace { headerFile, conceptNamespace }; - - outputObjectStubs(headerFile, objectType); - } - - stubNamespace.exit(); - headerFile << std::endl; - } - - // Output the full declarations - for (const auto& objectType : _loader.getObjectTypes()) - { - outputObjectDeclaration(headerFile, objectType, objectType.type == queryType); - headerFile << std::endl; - } - } - } - if (objectNamespace.exit()) { headerFile << std::endl; @@ -490,49 +403,46 @@ static_assert(graphql::internal::MinorVersion == )cpp" )cpp"; } - if (!_options.mergeFiles) + if (!_loader.getInterfaceTypes().empty()) { - if (!_loader.getInterfaceTypes().empty()) + for (const auto& interfaceType : _loader.getInterfaceTypes()) { - for (const auto& interfaceType : _loader.getInterfaceTypes()) - { - headerFile << R"cpp(void Add)cpp" << interfaceType.cppType - << R"cpp(Details(const std::shared_ptr& type)cpp" - << interfaceType.cppType - << R"cpp(, const std::shared_ptr& schema); + headerFile << R"cpp(void Add)cpp" << interfaceType.cppType + << R"cpp(Details(const std::shared_ptr& type)cpp" + << interfaceType.cppType + << R"cpp(, const std::shared_ptr& schema); )cpp"; - } - - headerFile << std::endl; } - if (!_loader.getUnionTypes().empty()) + headerFile << std::endl; + } + + if (!_loader.getUnionTypes().empty()) + { + for (const auto& unionType : _loader.getUnionTypes()) { - for (const auto& unionType : _loader.getUnionTypes()) - { - headerFile << R"cpp(void Add)cpp" << unionType.cppType - << R"cpp(Details(const std::shared_ptr& type)cpp" - << unionType.cppType - << R"cpp(, const std::shared_ptr& schema); + headerFile << R"cpp(void Add)cpp" << unionType.cppType + << R"cpp(Details(const std::shared_ptr& type)cpp" + << unionType.cppType + << R"cpp(, const std::shared_ptr& schema); )cpp"; - } - - headerFile << std::endl; } - if (!_loader.getObjectTypes().empty()) + headerFile << std::endl; + } + + if (!_loader.getObjectTypes().empty()) + { + for (const auto& objectType : _loader.getObjectTypes()) { - for (const auto& objectType : _loader.getObjectTypes()) - { - headerFile << R"cpp(void Add)cpp" << objectType.cppType - << R"cpp(Details(const std::shared_ptr& type)cpp" - << objectType.cppType - << R"cpp(, const std::shared_ptr& schema); + headerFile << R"cpp(void Add)cpp" << objectType.cppType + << R"cpp(Details(const std::shared_ptr& type)cpp" + << objectType.cppType + << R"cpp(, const std::shared_ptr& schema); )cpp"; - } - - headerFile << std::endl; } + + headerFile << std::endl; } if (_loader.isIntrospection()) @@ -1156,24 +1066,13 @@ bool Generator::outputSource() const noexcept if (!_loader.isIntrospection()) { - if (_options.mergeFiles) + for (const auto& operation : _loader.getOperationTypes()) { - - sourceFile << R"cpp(#include ")cpp" << fs::path(_headerPath).filename().string() - << R"cpp(" - + sourceFile << R"cpp(#include ")cpp" << operation.cppType << R"cpp(Object.h" )cpp"; } - else - { - for (const auto& operation : _loader.getOperationTypes()) - { - sourceFile << R"cpp(#include ")cpp" << operation.cppType << R"cpp(Object.h" -)cpp"; - } - sourceFile << std::endl; - } + sourceFile << std::endl; } if (_loader.isIntrospection()) @@ -1388,44 +1287,6 @@ service::AwaitableResolver ModifiedResult<)cpp" } } - if (_options.mergeFiles) - { - NamespaceScope objectNamespace { sourceFile, "object", true }; - - for (const auto& interfaceType : _loader.getInterfaceTypes()) - { - if (objectNamespace.enter()) - { - sourceFile << std::endl; - } - - outputInterfaceImplementation(sourceFile, interfaceType.cppType); - sourceFile << std::endl; - } - - for (const auto& unionType : _loader.getUnionTypes()) - { - if (objectNamespace.enter()) - { - sourceFile << std::endl; - } - - outputInterfaceImplementation(sourceFile, unionType.cppType); - sourceFile << std::endl; - } - - for (const auto& objectType : _loader.getObjectTypes()) - { - if (objectNamespace.enter()) - { - sourceFile << std::endl; - } - - outputObjectImplementation(sourceFile, objectType, objectType.type == queryType); - sourceFile << std::endl; - } - } - if (!_loader.isIntrospection()) { bool firstOperation = true; @@ -1733,16 +1594,9 @@ Operations::Operations()cpp"; for (const auto& interfaceType : _loader.getInterfaceTypes()) { - if (!_options.mergeFiles) - { - sourceFile << R"cpp( Add)cpp" << interfaceType.cppType << R"cpp(Details(type)cpp" - << interfaceType.cppType << R"cpp(, schema); + sourceFile << R"cpp( Add)cpp" << interfaceType.cppType << R"cpp(Details(type)cpp" + << interfaceType.cppType << R"cpp(, schema); )cpp"; - } - else - { - outputInterfaceIntrospection(sourceFile, interfaceType); - } } } @@ -1752,16 +1606,9 @@ Operations::Operations()cpp"; for (const auto& unionType : _loader.getUnionTypes()) { - if (!_options.mergeFiles) - { - sourceFile << R"cpp( Add)cpp" << unionType.cppType << R"cpp(Details(type)cpp" - << unionType.cppType << R"cpp(, schema); + sourceFile << R"cpp( Add)cpp" << unionType.cppType << R"cpp(Details(type)cpp" + << unionType.cppType << R"cpp(, schema); )cpp"; - } - else - { - outputUnionIntrospection(sourceFile, unionType); - } } } @@ -1771,16 +1618,9 @@ Operations::Operations()cpp"; for (const auto& objectType : _loader.getObjectTypes()) { - if (!_options.mergeFiles) - { - sourceFile << R"cpp( Add)cpp" << objectType.cppType << R"cpp(Details(type)cpp" - << objectType.cppType << R"cpp(, schema); + sourceFile << R"cpp( Add)cpp" << objectType.cppType << R"cpp(Details(type)cpp" + << objectType.cppType << R"cpp(, schema); )cpp"; - } - else - { - outputObjectIntrospection(sourceFile, objectType); - } } } @@ -2285,16 +2125,9 @@ void Generator::outputObjectIntrospection( firstInterface = false; - if (!_options.mergeFiles) - { - sourceFile - << R"cpp( std::static_pointer_cast(schema->LookupType(R"gql()cpp" - << interfaceName << R"cpp()gql"sv)))cpp"; - } - else - { - sourceFile << R"cpp( type)cpp" << _loader.getSafeCppName(interfaceName); - } + sourceFile + << R"cpp( std::static_pointer_cast(schema->LookupType(R"gql()cpp" + << interfaceName << R"cpp()gql"sv)))cpp"; } sourceFile << R"cpp( @@ -3197,7 +3030,6 @@ int main(int argc, char** argv) std::move(sourceDir) }, verbose, stubs, // stubs - !buildCustom, // mergeFiles noIntrospection, // noIntrospection }) .Build(); From e0202d53564aade7498d14a3a63004100f2147e3 Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Thu, 9 Dec 2021 14:13:45 -0800 Subject: [PATCH 076/119] Remove Introspection handling without arguments --- include/ClientGenerator.h | 2 +- include/SchemaGenerator.h | 4 +- include/SchemaLoader.h | 4 +- src/ClientGenerator.cpp | 16 ++--- src/SchemaGenerator.cpp | 35 +++++----- src/SchemaLoader.cpp | 134 +++----------------------------------- 6 files changed, 36 insertions(+), 159 deletions(-) diff --git a/include/ClientGenerator.h b/include/ClientGenerator.h index 36def4f5..f725d4e8 100644 --- a/include/ClientGenerator.h +++ b/include/ClientGenerator.h @@ -19,7 +19,7 @@ struct GeneratorPaths struct GeneratorOptions { - const std::optional paths; + const GeneratorPaths paths; const bool verbose = false; }; diff --git a/include/SchemaGenerator.h b/include/SchemaGenerator.h index 38972130..00ac5b53 100644 --- a/include/SchemaGenerator.h +++ b/include/SchemaGenerator.h @@ -18,7 +18,7 @@ struct GeneratorPaths struct GeneratorOptions { - const std::optional paths; + const GeneratorPaths paths; const bool verbose = false; const bool stubs = false; const bool noIntrospection = false; @@ -28,7 +28,7 @@ class Generator { public: // Initialize the generator with the introspection schema or a custom GraphQL schema. - explicit Generator(std::optional&& customSchema, GeneratorOptions&& options); + explicit Generator(SchemaOptions&& schemaOptions, GeneratorOptions&& options); // Run the generator and return a list of filenames that were output. std::vector Build() const noexcept; diff --git a/include/SchemaLoader.h b/include/SchemaLoader.h index 90c7e83f..fe7def07 100644 --- a/include/SchemaLoader.h +++ b/include/SchemaLoader.h @@ -216,7 +216,7 @@ class SchemaLoader { public: // Initialize the loader with the introspection schema or a custom GraphQL schema. - explicit SchemaLoader(std::optional&& customSchema); + explicit SchemaLoader(SchemaOptions&& schemaOptions); bool isIntrospection() const noexcept; std::string_view getFilenamePrefix() const noexcept; @@ -292,7 +292,7 @@ class SchemaLoader static const CppTypeMap s_builtinCppTypes; static const std::string_view s_scalarCppType; - const std::optional _customSchema; + const SchemaOptions _schemaOptions; const bool _isIntrospection; std::string_view _schemaNamespace; peg::ast _ast; diff --git a/src/ClientGenerator.cpp b/src/ClientGenerator.cpp index 5c293ee3..1d099f55 100644 --- a/src/ClientGenerator.cpp +++ b/src/ClientGenerator.cpp @@ -52,7 +52,7 @@ namespace graphql::generator::client { Generator::Generator( SchemaOptions&& schemaOptions, RequestOptions&& requestOptions, GeneratorOptions&& options) - : _schemaLoader(std::make_optional(std::move(schemaOptions))) + : _schemaLoader(std::move(schemaOptions)) , _requestLoader(std::move(requestOptions), _schemaLoader) , _options(std::move(options)) , _headerDir(getHeaderDir()) @@ -64,9 +64,9 @@ Generator::Generator( std::string Generator::getHeaderDir() const noexcept { - if (_options.paths) + if (!_options.paths.headerPath.empty()) { - return fs::path { _options.paths->headerPath }.string(); + return fs::path { _options.paths.headerPath }.string(); } else { @@ -76,9 +76,9 @@ std::string Generator::getHeaderDir() const noexcept std::string Generator::getSourceDir() const noexcept { - if (_options.paths) + if (!_options.paths.sourcePath.empty()) { - return fs::path(_options.paths->sourcePath).string(); + return fs::path(_options.paths.sourcePath).string(); } else { @@ -223,8 +223,7 @@ static_assert(graphql::internal::MinorVersion == )cpp" { pendingSeparator.reset(); - headerFile << R"cpp(enum class )cpp" << _schemaLoader.getCppType(enumType->name()) - << R"cpp( + headerFile << R"cpp(enum class )cpp" << _schemaLoader.getCppType(enumType->name()) << R"cpp( { )cpp"; for (const auto& enumValue : enumType->enumValues()) @@ -972,8 +971,7 @@ int main(int argc, char** argv) noIntrospection, }, graphql::generator::client::GeneratorOptions { - graphql::generator::client::GeneratorPaths { std::move(headerDir), - std::move(sourceDir) }, + { std::move(headerDir), std::move(sourceDir) }, verbose, }) .Build(); diff --git a/src/SchemaGenerator.cpp b/src/SchemaGenerator.cpp index ac73617a..6185f060 100644 --- a/src/SchemaGenerator.cpp +++ b/src/SchemaGenerator.cpp @@ -47,8 +47,8 @@ using namespace std::literals; namespace graphql::generator::schema { -Generator::Generator(std::optional&& customSchema, GeneratorOptions&& options) - : _loader(std::move(customSchema)) +Generator::Generator(SchemaOptions&& schemaOptions, GeneratorOptions&& options) + : _loader(std::move(schemaOptions)) , _options(std::move(options)) , _headerDir(getHeaderDir()) , _sourceDir(getSourceDir()) @@ -59,9 +59,9 @@ Generator::Generator(std::optional&& customSchema, GeneratorOptio std::string Generator::getHeaderDir() const noexcept { - if (_options.paths) + if (!_options.paths.headerPath.empty()) { - return fs::path { _options.paths->headerPath }.string(); + return fs::path { _options.paths.headerPath }.string(); } else { @@ -71,9 +71,9 @@ std::string Generator::getHeaderDir() const noexcept std::string Generator::getSourceDir() const noexcept { - if (_options.paths) + if (!_options.paths.sourcePath.empty()) { - return fs::path(_options.paths->sourcePath).string(); + return fs::path(_options.paths.sourcePath).string(); } else { @@ -3009,7 +3009,7 @@ int main(int argc, char** argv) outputVersion(std::cout); return 0; } - else if (showUsage || (!buildIntrospection && !buildCustom)) + else if (showUsage || !buildCustom) { outputUsage(std::cout, options); return 0; @@ -3017,20 +3017,15 @@ int main(int argc, char** argv) try { - auto schemaOptions = buildCustom - ? std::make_optional(graphql::generator::SchemaOptions { std::move(schemaFileName), - std::move(filenamePrefix), - std::move(schemaNamespace), - buildIntrospection }) - : std::nullopt; - - const auto files = graphql::generator::schema::Generator(std::move(schemaOptions), + const auto files = graphql::generator::schema::Generator({ std::move(schemaFileName), + std::move(filenamePrefix), + std::move(schemaNamespace), + buildIntrospection }, { - graphql::generator::schema::GeneratorPaths { std::move(headerDir), - std::move(sourceDir) }, - verbose, - stubs, // stubs - noIntrospection, // noIntrospection + { std::move(headerDir), std::move(sourceDir) }, // paths + verbose, // verbose + stubs, // stubs + noIntrospection, // noIntrospection }) .Build(); diff --git a/src/SchemaLoader.cpp b/src/SchemaLoader.cpp index 597114b4..3f6045e3 100644 --- a/src/SchemaLoader.cpp +++ b/src/SchemaLoader.cpp @@ -34,133 +34,17 @@ const CppTypeMap SchemaLoader::s_builtinCppTypes = { const std::string_view SchemaLoader::s_scalarCppType = R"cpp(response::Value)cpp"sv; -SchemaLoader::SchemaLoader(std::optional&& customSchema) - : _customSchema(std::move(customSchema)) - , _isIntrospection(!_customSchema || _customSchema->isIntrospection) - , _schemaNamespace(_customSchema ? _customSchema->schemaNamespace : s_introspectionNamespace) +SchemaLoader::SchemaLoader(SchemaOptions&& schemaOptions) + : _schemaOptions(std::move(schemaOptions)) + , _isIntrospection(_schemaOptions.isIntrospection) + , _schemaNamespace(_schemaOptions.schemaNamespace) { - if (!_customSchema) - { - // Introspection Schema: - // http://spec.graphql.org/June2018/#sec-Schema-Introspection - _ast = peg::parseSchemaString(R"gql( - type __Schema { - types: [__Type!]! - queryType: __Type! - mutationType: __Type - subscriptionType: __Type - directives: [__Directive!]! - } - - type __Type { - kind: __TypeKind! - name: String - description: String - - # OBJECT and INTERFACE only - fields(includeDeprecated: Boolean = false): [__Field!] - - # OBJECT only - interfaces: [__Type!] - - # INTERFACE and UNION only - possibleTypes: [__Type!] - - # ENUM only - enumValues(includeDeprecated: Boolean = false): [__EnumValue!] - - # INPUT_OBJECT only - inputFields: [__InputValue!] - - # NON_NULL and LIST only - ofType: __Type - } - - type __Field { - name: String! - description: String - args: [__InputValue!]! - type: __Type! - isDeprecated: Boolean! - deprecationReason: String - } - - type __InputValue { - name: String! - description: String - type: __Type! - defaultValue: String - } - - type __EnumValue { - name: String! - description: String - isDeprecated: Boolean! - deprecationReason: String - } - - enum __TypeKind { - SCALAR - OBJECT - INTERFACE - UNION - ENUM - INPUT_OBJECT - LIST - NON_NULL - } - - type __Directive { - name: String! - description: String - locations: [__DirectiveLocation!]! - args: [__InputValue!]! - } - - enum __DirectiveLocation { - QUERY - MUTATION - SUBSCRIPTION - FIELD - FRAGMENT_DEFINITION - FRAGMENT_SPREAD - INLINE_FRAGMENT - SCHEMA - SCALAR - OBJECT - FIELD_DEFINITION - ARGUMENT_DEFINITION - INTERFACE - UNION - ENUM - ENUM_VALUE - INPUT_OBJECT - INPUT_FIELD_DEFINITION - } - - # These directives are always defined and should be included in the Introspection schema. - directive @skip(if: Boolean!) on FIELD | FRAGMENT_SPREAD | INLINE_FRAGMENT - directive @include(if: Boolean!) on FIELD | FRAGMENT_SPREAD | INLINE_FRAGMENT - directive @deprecated( - reason: String = "No longer supported" - ) on FIELD_DEFINITION | ENUM_VALUE - )gql"sv); + _ast = peg::parseSchemaFile(_schemaOptions.schemaFilename); - if (!_ast.root) - { - throw std::logic_error("Unable to parse the introspection schema, but there was no " - "error message from the parser!"); - } - } - else + if (!_ast.root) { - _ast = peg::parseSchemaFile(_customSchema->schemaFilename); - - if (!_ast.root) - { - throw std::logic_error("Unable to parse the service schema, but there was no error " - "message from the parser!"); - } + throw std::logic_error("Unable to parse the service schema, but there was no error " + "message from the parser!"); } for (const auto& child : _ast.root->children) @@ -1215,7 +1099,7 @@ bool SchemaLoader::isIntrospection() const noexcept std::string_view SchemaLoader::getFilenamePrefix() const noexcept { - return _customSchema ? _customSchema->filenamePrefix : "Introspection"sv; + return _schemaOptions.filenamePrefix; } std::string_view SchemaLoader::getSchemaNamespace() const noexcept From d720bcbe27a4ad84cd96f5e0b943b46409cefaf9 Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Thu, 9 Dec 2021 14:22:36 -0800 Subject: [PATCH 077/119] Rename introspection/*.h copy target/sentinel --- src/CMakeLists.txt | 2 +- src/introspection/CMakeLists.txt | 10 ++++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 15d6e0c2..7e594f3e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -342,7 +342,7 @@ target_link_libraries(graphqlservice PUBLIC if(GRAPHQL_UPDATE_SAMPLES) # Even though this target doesn't build IntrospectionSchema.cpp, it still # depends on IntrospectionSchema.h for some enum definitions. - add_dependencies(graphqlservice update_introspection_headers) + add_dependencies(graphqlservice copy_introspection_schema_headers) endif() if(GRAPHQL_UPDATE_VERSION) diff --git a/src/introspection/CMakeLists.txt b/src/introspection/CMakeLists.txt index 0e91e2ac..7d4ebcf5 100644 --- a/src/introspection/CMakeLists.txt +++ b/src/introspection/CMakeLists.txt @@ -10,18 +10,16 @@ if(GRAPHQL_UPDATE_SAMPLES) update_graphql_schema_files(introspection schema.introspection.graphql Introspection introspection --introspection) add_custom_command( - OUTPUT updated_introspection_schema_headers + OUTPUT copied_introspection_schema_headers COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/*.h ${CMAKE_CURRENT_SOURCE_DIR}/../../include/graphqlservice/introspection/ - COMMAND ${CMAKE_COMMAND} -E touch updated_introspection_schema_headers + COMMAND ${CMAKE_COMMAND} -E touch copied_introspection_schema_headers DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/introspection_schema_files COMMENT "Updating IntrospectionSchema headers") - add_custom_target(update_introspection_headers ALL - DEPENDS updated_introspection_schema_headers) + add_custom_target(copy_introspection_schema_headers ALL + DEPENDS copied_introspection_schema_headers) endif() -set_property(DIRECTORY APPEND - PROPERTY CMAKE_CONFIGURE_DEPENDS introspection_schema_files) file(GLOB SCHEMA_FILES ${CMAKE_CURRENT_SOURCE_DIR}/../../include/graphqlservice/introspection/*.h) install(FILES ${SCHEMA_FILES} CONFIGURATIONS ${GRAPHQL_INSTALL_CONFIGURATIONS} From 93b7f10878bfa7a93cc3f3b62a9323261f991d52 Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Thu, 9 Dec 2021 14:32:14 -0800 Subject: [PATCH 078/119] Use file(GLOB) for copy_if_different --- src/introspection/CMakeLists.txt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/introspection/CMakeLists.txt b/src/introspection/CMakeLists.txt index 7d4ebcf5..f92e76b2 100644 --- a/src/introspection/CMakeLists.txt +++ b/src/introspection/CMakeLists.txt @@ -9,9 +9,10 @@ include(${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/cppgraphqlgen-functions.cmake) if(GRAPHQL_UPDATE_SAMPLES) update_graphql_schema_files(introspection schema.introspection.graphql Introspection introspection --introspection) + file(GLOB PRIVATE_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/*.h) add_custom_command( OUTPUT copied_introspection_schema_headers - COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/*.h ${CMAKE_CURRENT_SOURCE_DIR}/../../include/graphqlservice/introspection/ + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${PRIVATE_HEADERS} ${CMAKE_CURRENT_SOURCE_DIR}/../../include/graphqlservice/introspection/ COMMAND ${CMAKE_COMMAND} -E touch copied_introspection_schema_headers DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/introspection_schema_files COMMENT "Updating IntrospectionSchema headers") @@ -20,7 +21,7 @@ if(GRAPHQL_UPDATE_SAMPLES) DEPENDS copied_introspection_schema_headers) endif() -file(GLOB SCHEMA_FILES ${CMAKE_CURRENT_SOURCE_DIR}/../../include/graphqlservice/introspection/*.h) -install(FILES ${SCHEMA_FILES} +file(GLOB PUBLIC_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/../../include/graphqlservice/introspection/*.h) +install(FILES ${PUBLIC_HEADERS} CONFIGURATIONS ${GRAPHQL_INSTALL_CONFIGURATIONS} DESTINATION ${GRAPHQL_INSTALL_INCLUDE_DIR}/graphqlservice/introspection) From 044b7e095c2574d7cc4b62697fc8db2e44a583db Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Thu, 9 Dec 2021 14:57:04 -0800 Subject: [PATCH 079/119] Suppress Introspection implement and stub concepts --- .../introspection/DirectiveObject.h | 63 --------- .../introspection/EnumValueObject.h | 63 --------- .../introspection/FieldObject.h | 87 ------------- .../introspection/InputValueObject.h | 63 --------- .../introspection/SchemaObject.h | 75 ----------- .../graphqlservice/introspection/TypeObject.h | 123 ------------------ src/SchemaGenerator.cpp | 30 +++-- src/introspection/CMakeLists.txt | 2 +- src/introspection/DirectiveObject.h | 63 --------- src/introspection/EnumValueObject.h | 63 --------- src/introspection/FieldObject.h | 87 ------------- src/introspection/InputValueObject.h | 63 --------- src/introspection/SchemaObject.h | 75 ----------- src/introspection/TypeObject.h | 123 ------------------ 14 files changed, 17 insertions(+), 963 deletions(-) diff --git a/include/graphqlservice/introspection/DirectiveObject.h b/include/graphqlservice/introspection/DirectiveObject.h index 953863a4..faa56f8d 100644 --- a/include/graphqlservice/introspection/DirectiveObject.h +++ b/include/graphqlservice/introspection/DirectiveObject.h @@ -11,69 +11,6 @@ #include "IntrospectionSchema.h" namespace graphql::introspection::object { -namespace methods::DirectiveHas { - -template -concept getNameWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult { impl.getName(std::move(params)) } }; -}; - -template -concept getName = requires (TImpl impl) -{ - { service::FieldResult { impl.getName() } }; -}; - -template -concept getDescriptionWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getDescription(std::move(params)) } }; -}; - -template -concept getDescription = requires (TImpl impl) -{ - { service::FieldResult> { impl.getDescription() } }; -}; - -template -concept getLocationsWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getLocations(std::move(params)) } }; -}; - -template -concept getLocations = requires (TImpl impl) -{ - { service::FieldResult> { impl.getLocations() } }; -}; - -template -concept getArgsWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult>> { impl.getArgs(std::move(params)) } }; -}; - -template -concept getArgs = requires (TImpl impl) -{ - { service::FieldResult>> { impl.getArgs() } }; -}; - -template -concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) -{ - { impl.beginSelectionSet(params) }; -}; - -template -concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) -{ - { impl.endSelectionSet(params) }; -}; - -} // namespace methods::DirectiveHas class Directive : public service::Object diff --git a/include/graphqlservice/introspection/EnumValueObject.h b/include/graphqlservice/introspection/EnumValueObject.h index 3f2dd71c..003ace70 100644 --- a/include/graphqlservice/introspection/EnumValueObject.h +++ b/include/graphqlservice/introspection/EnumValueObject.h @@ -11,69 +11,6 @@ #include "IntrospectionSchema.h" namespace graphql::introspection::object { -namespace methods::EnumValueHas { - -template -concept getNameWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult { impl.getName(std::move(params)) } }; -}; - -template -concept getName = requires (TImpl impl) -{ - { service::FieldResult { impl.getName() } }; -}; - -template -concept getDescriptionWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getDescription(std::move(params)) } }; -}; - -template -concept getDescription = requires (TImpl impl) -{ - { service::FieldResult> { impl.getDescription() } }; -}; - -template -concept getIsDeprecatedWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult { impl.getIsDeprecated(std::move(params)) } }; -}; - -template -concept getIsDeprecated = requires (TImpl impl) -{ - { service::FieldResult { impl.getIsDeprecated() } }; -}; - -template -concept getDeprecationReasonWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getDeprecationReason(std::move(params)) } }; -}; - -template -concept getDeprecationReason = requires (TImpl impl) -{ - { service::FieldResult> { impl.getDeprecationReason() } }; -}; - -template -concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) -{ - { impl.beginSelectionSet(params) }; -}; - -template -concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) -{ - { impl.endSelectionSet(params) }; -}; - -} // namespace methods::EnumValueHas class EnumValue : public service::Object diff --git a/include/graphqlservice/introspection/FieldObject.h b/include/graphqlservice/introspection/FieldObject.h index 0020b6e1..40159e6f 100644 --- a/include/graphqlservice/introspection/FieldObject.h +++ b/include/graphqlservice/introspection/FieldObject.h @@ -11,93 +11,6 @@ #include "IntrospectionSchema.h" namespace graphql::introspection::object { -namespace methods::FieldHas { - -template -concept getNameWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult { impl.getName(std::move(params)) } }; -}; - -template -concept getName = requires (TImpl impl) -{ - { service::FieldResult { impl.getName() } }; -}; - -template -concept getDescriptionWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getDescription(std::move(params)) } }; -}; - -template -concept getDescription = requires (TImpl impl) -{ - { service::FieldResult> { impl.getDescription() } }; -}; - -template -concept getArgsWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult>> { impl.getArgs(std::move(params)) } }; -}; - -template -concept getArgs = requires (TImpl impl) -{ - { service::FieldResult>> { impl.getArgs() } }; -}; - -template -concept getTypeWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getType(std::move(params)) } }; -}; - -template -concept getType = requires (TImpl impl) -{ - { service::FieldResult> { impl.getType() } }; -}; - -template -concept getIsDeprecatedWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult { impl.getIsDeprecated(std::move(params)) } }; -}; - -template -concept getIsDeprecated = requires (TImpl impl) -{ - { service::FieldResult { impl.getIsDeprecated() } }; -}; - -template -concept getDeprecationReasonWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getDeprecationReason(std::move(params)) } }; -}; - -template -concept getDeprecationReason = requires (TImpl impl) -{ - { service::FieldResult> { impl.getDeprecationReason() } }; -}; - -template -concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) -{ - { impl.beginSelectionSet(params) }; -}; - -template -concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) -{ - { impl.endSelectionSet(params) }; -}; - -} // namespace methods::FieldHas class Field : public service::Object diff --git a/include/graphqlservice/introspection/InputValueObject.h b/include/graphqlservice/introspection/InputValueObject.h index b4ec2474..facdbcd9 100644 --- a/include/graphqlservice/introspection/InputValueObject.h +++ b/include/graphqlservice/introspection/InputValueObject.h @@ -11,69 +11,6 @@ #include "IntrospectionSchema.h" namespace graphql::introspection::object { -namespace methods::InputValueHas { - -template -concept getNameWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult { impl.getName(std::move(params)) } }; -}; - -template -concept getName = requires (TImpl impl) -{ - { service::FieldResult { impl.getName() } }; -}; - -template -concept getDescriptionWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getDescription(std::move(params)) } }; -}; - -template -concept getDescription = requires (TImpl impl) -{ - { service::FieldResult> { impl.getDescription() } }; -}; - -template -concept getTypeWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getType(std::move(params)) } }; -}; - -template -concept getType = requires (TImpl impl) -{ - { service::FieldResult> { impl.getType() } }; -}; - -template -concept getDefaultValueWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getDefaultValue(std::move(params)) } }; -}; - -template -concept getDefaultValue = requires (TImpl impl) -{ - { service::FieldResult> { impl.getDefaultValue() } }; -}; - -template -concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) -{ - { impl.beginSelectionSet(params) }; -}; - -template -concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) -{ - { impl.endSelectionSet(params) }; -}; - -} // namespace methods::InputValueHas class InputValue : public service::Object diff --git a/include/graphqlservice/introspection/SchemaObject.h b/include/graphqlservice/introspection/SchemaObject.h index 1c982eea..0eb08742 100644 --- a/include/graphqlservice/introspection/SchemaObject.h +++ b/include/graphqlservice/introspection/SchemaObject.h @@ -11,81 +11,6 @@ #include "IntrospectionSchema.h" namespace graphql::introspection::object { -namespace methods::SchemaHas { - -template -concept getTypesWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult>> { impl.getTypes(std::move(params)) } }; -}; - -template -concept getTypes = requires (TImpl impl) -{ - { service::FieldResult>> { impl.getTypes() } }; -}; - -template -concept getQueryTypeWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getQueryType(std::move(params)) } }; -}; - -template -concept getQueryType = requires (TImpl impl) -{ - { service::FieldResult> { impl.getQueryType() } }; -}; - -template -concept getMutationTypeWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getMutationType(std::move(params)) } }; -}; - -template -concept getMutationType = requires (TImpl impl) -{ - { service::FieldResult> { impl.getMutationType() } }; -}; - -template -concept getSubscriptionTypeWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getSubscriptionType(std::move(params)) } }; -}; - -template -concept getSubscriptionType = requires (TImpl impl) -{ - { service::FieldResult> { impl.getSubscriptionType() } }; -}; - -template -concept getDirectivesWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult>> { impl.getDirectives(std::move(params)) } }; -}; - -template -concept getDirectives = requires (TImpl impl) -{ - { service::FieldResult>> { impl.getDirectives() } }; -}; - -template -concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) -{ - { impl.beginSelectionSet(params) }; -}; - -template -concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) -{ - { impl.endSelectionSet(params) }; -}; - -} // namespace methods::SchemaHas class Schema : public service::Object diff --git a/include/graphqlservice/introspection/TypeObject.h b/include/graphqlservice/introspection/TypeObject.h index 164f4165..e7429c59 100644 --- a/include/graphqlservice/introspection/TypeObject.h +++ b/include/graphqlservice/introspection/TypeObject.h @@ -11,129 +11,6 @@ #include "IntrospectionSchema.h" namespace graphql::introspection::object { -namespace methods::TypeHas { - -template -concept getKindWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult { impl.getKind(std::move(params)) } }; -}; - -template -concept getKind = requires (TImpl impl) -{ - { service::FieldResult { impl.getKind() } }; -}; - -template -concept getNameWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getName(std::move(params)) } }; -}; - -template -concept getName = requires (TImpl impl) -{ - { service::FieldResult> { impl.getName() } }; -}; - -template -concept getDescriptionWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getDescription(std::move(params)) } }; -}; - -template -concept getDescription = requires (TImpl impl) -{ - { service::FieldResult> { impl.getDescription() } }; -}; - -template -concept getFieldsWithParams = requires (TImpl impl, service::FieldParams params, std::optional includeDeprecatedArg) -{ - { service::FieldResult>>> { impl.getFields(std::move(params), std::move(includeDeprecatedArg)) } }; -}; - -template -concept getFields = requires (TImpl impl, std::optional includeDeprecatedArg) -{ - { service::FieldResult>>> { impl.getFields(std::move(includeDeprecatedArg)) } }; -}; - -template -concept getInterfacesWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult>>> { impl.getInterfaces(std::move(params)) } }; -}; - -template -concept getInterfaces = requires (TImpl impl) -{ - { service::FieldResult>>> { impl.getInterfaces() } }; -}; - -template -concept getPossibleTypesWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult>>> { impl.getPossibleTypes(std::move(params)) } }; -}; - -template -concept getPossibleTypes = requires (TImpl impl) -{ - { service::FieldResult>>> { impl.getPossibleTypes() } }; -}; - -template -concept getEnumValuesWithParams = requires (TImpl impl, service::FieldParams params, std::optional includeDeprecatedArg) -{ - { service::FieldResult>>> { impl.getEnumValues(std::move(params), std::move(includeDeprecatedArg)) } }; -}; - -template -concept getEnumValues = requires (TImpl impl, std::optional includeDeprecatedArg) -{ - { service::FieldResult>>> { impl.getEnumValues(std::move(includeDeprecatedArg)) } }; -}; - -template -concept getInputFieldsWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult>>> { impl.getInputFields(std::move(params)) } }; -}; - -template -concept getInputFields = requires (TImpl impl) -{ - { service::FieldResult>>> { impl.getInputFields() } }; -}; - -template -concept getOfTypeWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getOfType(std::move(params)) } }; -}; - -template -concept getOfType = requires (TImpl impl) -{ - { service::FieldResult> { impl.getOfType() } }; -}; - -template -concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) -{ - { impl.beginSelectionSet(params) }; -}; - -template -concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) -{ - { impl.endSelectionSet(params) }; -}; - -} // namespace methods::TypeHas class Type : public service::Object diff --git a/src/SchemaGenerator.cpp b/src/SchemaGenerator.cpp index 6185f060..e4b23513 100644 --- a/src/SchemaGenerator.cpp +++ b/src/SchemaGenerator.cpp @@ -2779,27 +2779,29 @@ using namespace std::literals; const auto objectNamespace = ossObjectNamespace.str(); NamespaceScope headerNamespace { headerFile, objectNamespace }; - if (!objectType.interfaces.empty()) + if (!_loader.isIntrospection()) { - NamespaceScope implementsNamespace { headerFile, R"cpp(implements)cpp" }; + if (!objectType.interfaces.empty()) + { + NamespaceScope implementsNamespace { headerFile, R"cpp(implements)cpp" }; - headerFile << std::endl; - outputObjectImplements(headerFile, objectType); + headerFile << std::endl; + outputObjectImplements(headerFile, objectType); - implementsNamespace.exit(); - headerFile << std::endl; - } + implementsNamespace.exit(); + headerFile << std::endl; + } - // Output the stub concepts - std::ostringstream ossConceptNamespace; + // Output the stub concepts + std::ostringstream ossConceptNamespace; - ossConceptNamespace << R"cpp(methods::)cpp" << objectType.cppType << R"cpp(Has)cpp"; + ossConceptNamespace << R"cpp(methods::)cpp" << objectType.cppType << R"cpp(Has)cpp"; - const auto conceptNamespace = ossConceptNamespace.str(); - NamespaceScope stubNamespace { headerFile, conceptNamespace }; + const auto conceptNamespace = ossConceptNamespace.str(); + NamespaceScope stubNamespace { headerFile, conceptNamespace }; - outputObjectStubs(headerFile, objectType); - stubNamespace.exit(); + outputObjectStubs(headerFile, objectType); + } // Output the full declaration headerFile << std::endl; diff --git a/src/introspection/CMakeLists.txt b/src/introspection/CMakeLists.txt index f92e76b2..6df7c4c2 100644 --- a/src/introspection/CMakeLists.txt +++ b/src/introspection/CMakeLists.txt @@ -14,7 +14,7 @@ if(GRAPHQL_UPDATE_SAMPLES) OUTPUT copied_introspection_schema_headers COMMAND ${CMAKE_COMMAND} -E copy_if_different ${PRIVATE_HEADERS} ${CMAKE_CURRENT_SOURCE_DIR}/../../include/graphqlservice/introspection/ COMMAND ${CMAKE_COMMAND} -E touch copied_introspection_schema_headers - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/introspection_schema_files + DEPENDS ${PRIVATE_HEADERS} COMMENT "Updating IntrospectionSchema headers") add_custom_target(copy_introspection_schema_headers ALL diff --git a/src/introspection/DirectiveObject.h b/src/introspection/DirectiveObject.h index 953863a4..faa56f8d 100644 --- a/src/introspection/DirectiveObject.h +++ b/src/introspection/DirectiveObject.h @@ -11,69 +11,6 @@ #include "IntrospectionSchema.h" namespace graphql::introspection::object { -namespace methods::DirectiveHas { - -template -concept getNameWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult { impl.getName(std::move(params)) } }; -}; - -template -concept getName = requires (TImpl impl) -{ - { service::FieldResult { impl.getName() } }; -}; - -template -concept getDescriptionWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getDescription(std::move(params)) } }; -}; - -template -concept getDescription = requires (TImpl impl) -{ - { service::FieldResult> { impl.getDescription() } }; -}; - -template -concept getLocationsWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getLocations(std::move(params)) } }; -}; - -template -concept getLocations = requires (TImpl impl) -{ - { service::FieldResult> { impl.getLocations() } }; -}; - -template -concept getArgsWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult>> { impl.getArgs(std::move(params)) } }; -}; - -template -concept getArgs = requires (TImpl impl) -{ - { service::FieldResult>> { impl.getArgs() } }; -}; - -template -concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) -{ - { impl.beginSelectionSet(params) }; -}; - -template -concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) -{ - { impl.endSelectionSet(params) }; -}; - -} // namespace methods::DirectiveHas class Directive : public service::Object diff --git a/src/introspection/EnumValueObject.h b/src/introspection/EnumValueObject.h index 3f2dd71c..003ace70 100644 --- a/src/introspection/EnumValueObject.h +++ b/src/introspection/EnumValueObject.h @@ -11,69 +11,6 @@ #include "IntrospectionSchema.h" namespace graphql::introspection::object { -namespace methods::EnumValueHas { - -template -concept getNameWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult { impl.getName(std::move(params)) } }; -}; - -template -concept getName = requires (TImpl impl) -{ - { service::FieldResult { impl.getName() } }; -}; - -template -concept getDescriptionWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getDescription(std::move(params)) } }; -}; - -template -concept getDescription = requires (TImpl impl) -{ - { service::FieldResult> { impl.getDescription() } }; -}; - -template -concept getIsDeprecatedWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult { impl.getIsDeprecated(std::move(params)) } }; -}; - -template -concept getIsDeprecated = requires (TImpl impl) -{ - { service::FieldResult { impl.getIsDeprecated() } }; -}; - -template -concept getDeprecationReasonWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getDeprecationReason(std::move(params)) } }; -}; - -template -concept getDeprecationReason = requires (TImpl impl) -{ - { service::FieldResult> { impl.getDeprecationReason() } }; -}; - -template -concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) -{ - { impl.beginSelectionSet(params) }; -}; - -template -concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) -{ - { impl.endSelectionSet(params) }; -}; - -} // namespace methods::EnumValueHas class EnumValue : public service::Object diff --git a/src/introspection/FieldObject.h b/src/introspection/FieldObject.h index 0020b6e1..40159e6f 100644 --- a/src/introspection/FieldObject.h +++ b/src/introspection/FieldObject.h @@ -11,93 +11,6 @@ #include "IntrospectionSchema.h" namespace graphql::introspection::object { -namespace methods::FieldHas { - -template -concept getNameWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult { impl.getName(std::move(params)) } }; -}; - -template -concept getName = requires (TImpl impl) -{ - { service::FieldResult { impl.getName() } }; -}; - -template -concept getDescriptionWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getDescription(std::move(params)) } }; -}; - -template -concept getDescription = requires (TImpl impl) -{ - { service::FieldResult> { impl.getDescription() } }; -}; - -template -concept getArgsWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult>> { impl.getArgs(std::move(params)) } }; -}; - -template -concept getArgs = requires (TImpl impl) -{ - { service::FieldResult>> { impl.getArgs() } }; -}; - -template -concept getTypeWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getType(std::move(params)) } }; -}; - -template -concept getType = requires (TImpl impl) -{ - { service::FieldResult> { impl.getType() } }; -}; - -template -concept getIsDeprecatedWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult { impl.getIsDeprecated(std::move(params)) } }; -}; - -template -concept getIsDeprecated = requires (TImpl impl) -{ - { service::FieldResult { impl.getIsDeprecated() } }; -}; - -template -concept getDeprecationReasonWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getDeprecationReason(std::move(params)) } }; -}; - -template -concept getDeprecationReason = requires (TImpl impl) -{ - { service::FieldResult> { impl.getDeprecationReason() } }; -}; - -template -concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) -{ - { impl.beginSelectionSet(params) }; -}; - -template -concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) -{ - { impl.endSelectionSet(params) }; -}; - -} // namespace methods::FieldHas class Field : public service::Object diff --git a/src/introspection/InputValueObject.h b/src/introspection/InputValueObject.h index b4ec2474..facdbcd9 100644 --- a/src/introspection/InputValueObject.h +++ b/src/introspection/InputValueObject.h @@ -11,69 +11,6 @@ #include "IntrospectionSchema.h" namespace graphql::introspection::object { -namespace methods::InputValueHas { - -template -concept getNameWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult { impl.getName(std::move(params)) } }; -}; - -template -concept getName = requires (TImpl impl) -{ - { service::FieldResult { impl.getName() } }; -}; - -template -concept getDescriptionWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getDescription(std::move(params)) } }; -}; - -template -concept getDescription = requires (TImpl impl) -{ - { service::FieldResult> { impl.getDescription() } }; -}; - -template -concept getTypeWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getType(std::move(params)) } }; -}; - -template -concept getType = requires (TImpl impl) -{ - { service::FieldResult> { impl.getType() } }; -}; - -template -concept getDefaultValueWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getDefaultValue(std::move(params)) } }; -}; - -template -concept getDefaultValue = requires (TImpl impl) -{ - { service::FieldResult> { impl.getDefaultValue() } }; -}; - -template -concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) -{ - { impl.beginSelectionSet(params) }; -}; - -template -concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) -{ - { impl.endSelectionSet(params) }; -}; - -} // namespace methods::InputValueHas class InputValue : public service::Object diff --git a/src/introspection/SchemaObject.h b/src/introspection/SchemaObject.h index 1c982eea..0eb08742 100644 --- a/src/introspection/SchemaObject.h +++ b/src/introspection/SchemaObject.h @@ -11,81 +11,6 @@ #include "IntrospectionSchema.h" namespace graphql::introspection::object { -namespace methods::SchemaHas { - -template -concept getTypesWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult>> { impl.getTypes(std::move(params)) } }; -}; - -template -concept getTypes = requires (TImpl impl) -{ - { service::FieldResult>> { impl.getTypes() } }; -}; - -template -concept getQueryTypeWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getQueryType(std::move(params)) } }; -}; - -template -concept getQueryType = requires (TImpl impl) -{ - { service::FieldResult> { impl.getQueryType() } }; -}; - -template -concept getMutationTypeWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getMutationType(std::move(params)) } }; -}; - -template -concept getMutationType = requires (TImpl impl) -{ - { service::FieldResult> { impl.getMutationType() } }; -}; - -template -concept getSubscriptionTypeWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getSubscriptionType(std::move(params)) } }; -}; - -template -concept getSubscriptionType = requires (TImpl impl) -{ - { service::FieldResult> { impl.getSubscriptionType() } }; -}; - -template -concept getDirectivesWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult>> { impl.getDirectives(std::move(params)) } }; -}; - -template -concept getDirectives = requires (TImpl impl) -{ - { service::FieldResult>> { impl.getDirectives() } }; -}; - -template -concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) -{ - { impl.beginSelectionSet(params) }; -}; - -template -concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) -{ - { impl.endSelectionSet(params) }; -}; - -} // namespace methods::SchemaHas class Schema : public service::Object diff --git a/src/introspection/TypeObject.h b/src/introspection/TypeObject.h index 164f4165..e7429c59 100644 --- a/src/introspection/TypeObject.h +++ b/src/introspection/TypeObject.h @@ -11,129 +11,6 @@ #include "IntrospectionSchema.h" namespace graphql::introspection::object { -namespace methods::TypeHas { - -template -concept getKindWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult { impl.getKind(std::move(params)) } }; -}; - -template -concept getKind = requires (TImpl impl) -{ - { service::FieldResult { impl.getKind() } }; -}; - -template -concept getNameWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getName(std::move(params)) } }; -}; - -template -concept getName = requires (TImpl impl) -{ - { service::FieldResult> { impl.getName() } }; -}; - -template -concept getDescriptionWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getDescription(std::move(params)) } }; -}; - -template -concept getDescription = requires (TImpl impl) -{ - { service::FieldResult> { impl.getDescription() } }; -}; - -template -concept getFieldsWithParams = requires (TImpl impl, service::FieldParams params, std::optional includeDeprecatedArg) -{ - { service::FieldResult>>> { impl.getFields(std::move(params), std::move(includeDeprecatedArg)) } }; -}; - -template -concept getFields = requires (TImpl impl, std::optional includeDeprecatedArg) -{ - { service::FieldResult>>> { impl.getFields(std::move(includeDeprecatedArg)) } }; -}; - -template -concept getInterfacesWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult>>> { impl.getInterfaces(std::move(params)) } }; -}; - -template -concept getInterfaces = requires (TImpl impl) -{ - { service::FieldResult>>> { impl.getInterfaces() } }; -}; - -template -concept getPossibleTypesWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult>>> { impl.getPossibleTypes(std::move(params)) } }; -}; - -template -concept getPossibleTypes = requires (TImpl impl) -{ - { service::FieldResult>>> { impl.getPossibleTypes() } }; -}; - -template -concept getEnumValuesWithParams = requires (TImpl impl, service::FieldParams params, std::optional includeDeprecatedArg) -{ - { service::FieldResult>>> { impl.getEnumValues(std::move(params), std::move(includeDeprecatedArg)) } }; -}; - -template -concept getEnumValues = requires (TImpl impl, std::optional includeDeprecatedArg) -{ - { service::FieldResult>>> { impl.getEnumValues(std::move(includeDeprecatedArg)) } }; -}; - -template -concept getInputFieldsWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult>>> { impl.getInputFields(std::move(params)) } }; -}; - -template -concept getInputFields = requires (TImpl impl) -{ - { service::FieldResult>>> { impl.getInputFields() } }; -}; - -template -concept getOfTypeWithParams = requires (TImpl impl, service::FieldParams params) -{ - { service::FieldResult> { impl.getOfType(std::move(params)) } }; -}; - -template -concept getOfType = requires (TImpl impl) -{ - { service::FieldResult> { impl.getOfType() } }; -}; - -template -concept beginSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) -{ - { impl.beginSelectionSet(params) }; -}; - -template -concept endSelectionSet = requires (TImpl impl, const service::SelectionSetParams params) -{ - { impl.endSelectionSet(params) }; -}; - -} // namespace methods::TypeHas class Type : public service::Object From 5c74269fad9388ef4e01f66e5b3f5d8adf20ea7a Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Thu, 9 Dec 2021 15:43:40 -0800 Subject: [PATCH 080/119] Simplify resolvers and keep default args in static --- .../introspection/DirectiveObject.h | 16 ++-- .../introspection/EnumValueObject.h | 16 ++-- .../introspection/FieldObject.h | 24 +++--- .../introspection/InputValueObject.h | 16 ++-- .../introspection/SchemaObject.h | 20 ++--- .../graphqlservice/introspection/TypeObject.h | 36 ++++---- samples/today/nointrospection/QueryObject.cpp | 2 +- samples/today/schema/QueryObject.cpp | 2 +- samples/validation/schema/ArgumentsObject.cpp | 2 +- src/SchemaGenerator.cpp | 85 ++++++++++++++----- src/introspection/CMakeLists.txt | 2 +- src/introspection/DirectiveObject.cpp | 12 +-- src/introspection/DirectiveObject.h | 16 ++-- src/introspection/EnumValueObject.cpp | 12 +-- src/introspection/EnumValueObject.h | 16 ++-- src/introspection/FieldObject.cpp | 18 ++-- src/introspection/FieldObject.h | 24 +++--- src/introspection/InputValueObject.cpp | 12 +-- src/introspection/InputValueObject.h | 16 ++-- src/introspection/SchemaObject.cpp | 15 ++-- src/introspection/SchemaObject.h | 20 ++--- src/introspection/TypeObject.cpp | 31 +++---- src/introspection/TypeObject.h | 36 ++++---- 23 files changed, 229 insertions(+), 220 deletions(-) diff --git a/include/graphqlservice/introspection/DirectiveObject.h b/include/graphqlservice/introspection/DirectiveObject.h index faa56f8d..e0953288 100644 --- a/include/graphqlservice/introspection/DirectiveObject.h +++ b/include/graphqlservice/introspection/DirectiveObject.h @@ -27,10 +27,10 @@ class Directive { virtual ~Concept() = default; - virtual service::FieldResult getName(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getDescription(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getLocations(service::FieldParams&& params) const = 0; - virtual service::FieldResult>> getArgs(service::FieldParams&& params) const = 0; + virtual service::FieldResult getName() const = 0; + virtual service::FieldResult> getDescription() const = 0; + virtual service::FieldResult> getLocations() const = 0; + virtual service::FieldResult>> getArgs() const = 0; }; template @@ -42,22 +42,22 @@ class Directive { } - service::FieldResult getName(service::FieldParams&&) const final + service::FieldResult getName() const final { return { _pimpl->getName() }; } - service::FieldResult> getDescription(service::FieldParams&&) const final + service::FieldResult> getDescription() const final { return { _pimpl->getDescription() }; } - service::FieldResult> getLocations(service::FieldParams&&) const final + service::FieldResult> getLocations() const final { return { _pimpl->getLocations() }; } - service::FieldResult>> getArgs(service::FieldParams&&) const final + service::FieldResult>> getArgs() const final { return { _pimpl->getArgs() }; } diff --git a/include/graphqlservice/introspection/EnumValueObject.h b/include/graphqlservice/introspection/EnumValueObject.h index 003ace70..f52cc584 100644 --- a/include/graphqlservice/introspection/EnumValueObject.h +++ b/include/graphqlservice/introspection/EnumValueObject.h @@ -27,10 +27,10 @@ class EnumValue { virtual ~Concept() = default; - virtual service::FieldResult getName(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getDescription(service::FieldParams&& params) const = 0; - virtual service::FieldResult getIsDeprecated(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getDeprecationReason(service::FieldParams&& params) const = 0; + virtual service::FieldResult getName() const = 0; + virtual service::FieldResult> getDescription() const = 0; + virtual service::FieldResult getIsDeprecated() const = 0; + virtual service::FieldResult> getDeprecationReason() const = 0; }; template @@ -42,22 +42,22 @@ class EnumValue { } - service::FieldResult getName(service::FieldParams&&) const final + service::FieldResult getName() const final { return { _pimpl->getName() }; } - service::FieldResult> getDescription(service::FieldParams&&) const final + service::FieldResult> getDescription() const final { return { _pimpl->getDescription() }; } - service::FieldResult getIsDeprecated(service::FieldParams&&) const final + service::FieldResult getIsDeprecated() const final { return { _pimpl->getIsDeprecated() }; } - service::FieldResult> getDeprecationReason(service::FieldParams&&) const final + service::FieldResult> getDeprecationReason() const final { return { _pimpl->getDeprecationReason() }; } diff --git a/include/graphqlservice/introspection/FieldObject.h b/include/graphqlservice/introspection/FieldObject.h index 40159e6f..1d50a0cd 100644 --- a/include/graphqlservice/introspection/FieldObject.h +++ b/include/graphqlservice/introspection/FieldObject.h @@ -29,12 +29,12 @@ class Field { virtual ~Concept() = default; - virtual service::FieldResult getName(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getDescription(service::FieldParams&& params) const = 0; - virtual service::FieldResult>> getArgs(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getType(service::FieldParams&& params) const = 0; - virtual service::FieldResult getIsDeprecated(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getDeprecationReason(service::FieldParams&& params) const = 0; + virtual service::FieldResult getName() const = 0; + virtual service::FieldResult> getDescription() const = 0; + virtual service::FieldResult>> getArgs() const = 0; + virtual service::FieldResult> getType() const = 0; + virtual service::FieldResult getIsDeprecated() const = 0; + virtual service::FieldResult> getDeprecationReason() const = 0; }; template @@ -46,32 +46,32 @@ class Field { } - service::FieldResult getName(service::FieldParams&&) const final + service::FieldResult getName() const final { return { _pimpl->getName() }; } - service::FieldResult> getDescription(service::FieldParams&&) const final + service::FieldResult> getDescription() const final { return { _pimpl->getDescription() }; } - service::FieldResult>> getArgs(service::FieldParams&&) const final + service::FieldResult>> getArgs() const final { return { _pimpl->getArgs() }; } - service::FieldResult> getType(service::FieldParams&&) const final + service::FieldResult> getType() const final { return { _pimpl->getType() }; } - service::FieldResult getIsDeprecated(service::FieldParams&&) const final + service::FieldResult getIsDeprecated() const final { return { _pimpl->getIsDeprecated() }; } - service::FieldResult> getDeprecationReason(service::FieldParams&&) const final + service::FieldResult> getDeprecationReason() const final { return { _pimpl->getDeprecationReason() }; } diff --git a/include/graphqlservice/introspection/InputValueObject.h b/include/graphqlservice/introspection/InputValueObject.h index facdbcd9..65199e06 100644 --- a/include/graphqlservice/introspection/InputValueObject.h +++ b/include/graphqlservice/introspection/InputValueObject.h @@ -27,10 +27,10 @@ class InputValue { virtual ~Concept() = default; - virtual service::FieldResult getName(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getDescription(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getType(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getDefaultValue(service::FieldParams&& params) const = 0; + virtual service::FieldResult getName() const = 0; + virtual service::FieldResult> getDescription() const = 0; + virtual service::FieldResult> getType() const = 0; + virtual service::FieldResult> getDefaultValue() const = 0; }; template @@ -42,22 +42,22 @@ class InputValue { } - service::FieldResult getName(service::FieldParams&&) const final + service::FieldResult getName() const final { return { _pimpl->getName() }; } - service::FieldResult> getDescription(service::FieldParams&&) const final + service::FieldResult> getDescription() const final { return { _pimpl->getDescription() }; } - service::FieldResult> getType(service::FieldParams&&) const final + service::FieldResult> getType() const final { return { _pimpl->getType() }; } - service::FieldResult> getDefaultValue(service::FieldParams&&) const final + service::FieldResult> getDefaultValue() const final { return { _pimpl->getDefaultValue() }; } diff --git a/include/graphqlservice/introspection/SchemaObject.h b/include/graphqlservice/introspection/SchemaObject.h index 0eb08742..f81ab9c3 100644 --- a/include/graphqlservice/introspection/SchemaObject.h +++ b/include/graphqlservice/introspection/SchemaObject.h @@ -28,11 +28,11 @@ class Schema { virtual ~Concept() = default; - virtual service::FieldResult>> getTypes(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getQueryType(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getMutationType(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getSubscriptionType(service::FieldParams&& params) const = 0; - virtual service::FieldResult>> getDirectives(service::FieldParams&& params) const = 0; + virtual service::FieldResult>> getTypes() const = 0; + virtual service::FieldResult> getQueryType() const = 0; + virtual service::FieldResult> getMutationType() const = 0; + virtual service::FieldResult> getSubscriptionType() const = 0; + virtual service::FieldResult>> getDirectives() const = 0; }; template @@ -44,27 +44,27 @@ class Schema { } - service::FieldResult>> getTypes(service::FieldParams&&) const final + service::FieldResult>> getTypes() const final { return { _pimpl->getTypes() }; } - service::FieldResult> getQueryType(service::FieldParams&&) const final + service::FieldResult> getQueryType() const final { return { _pimpl->getQueryType() }; } - service::FieldResult> getMutationType(service::FieldParams&&) const final + service::FieldResult> getMutationType() const final { return { _pimpl->getMutationType() }; } - service::FieldResult> getSubscriptionType(service::FieldParams&&) const final + service::FieldResult> getSubscriptionType() const final { return { _pimpl->getSubscriptionType() }; } - service::FieldResult>> getDirectives(service::FieldParams&&) const final + service::FieldResult>> getDirectives() const final { return { _pimpl->getDirectives() }; } diff --git a/include/graphqlservice/introspection/TypeObject.h b/include/graphqlservice/introspection/TypeObject.h index e7429c59..87c2101e 100644 --- a/include/graphqlservice/introspection/TypeObject.h +++ b/include/graphqlservice/introspection/TypeObject.h @@ -32,15 +32,15 @@ class Type { virtual ~Concept() = default; - virtual service::FieldResult getKind(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getName(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getDescription(service::FieldParams&& params) const = 0; - virtual service::FieldResult>>> getFields(service::FieldParams&& params, std::optional&& includeDeprecatedArg) const = 0; - virtual service::FieldResult>>> getInterfaces(service::FieldParams&& params) const = 0; - virtual service::FieldResult>>> getPossibleTypes(service::FieldParams&& params) const = 0; - virtual service::FieldResult>>> getEnumValues(service::FieldParams&& params, std::optional&& includeDeprecatedArg) const = 0; - virtual service::FieldResult>>> getInputFields(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getOfType(service::FieldParams&& params) const = 0; + virtual service::FieldResult getKind() const = 0; + virtual service::FieldResult> getName() const = 0; + virtual service::FieldResult> getDescription() const = 0; + virtual service::FieldResult>>> getFields(std::optional&& includeDeprecatedArg) const = 0; + virtual service::FieldResult>>> getInterfaces() const = 0; + virtual service::FieldResult>>> getPossibleTypes() const = 0; + virtual service::FieldResult>>> getEnumValues(std::optional&& includeDeprecatedArg) const = 0; + virtual service::FieldResult>>> getInputFields() const = 0; + virtual service::FieldResult> getOfType() const = 0; }; template @@ -52,47 +52,47 @@ class Type { } - service::FieldResult getKind(service::FieldParams&&) const final + service::FieldResult getKind() const final { return { _pimpl->getKind() }; } - service::FieldResult> getName(service::FieldParams&&) const final + service::FieldResult> getName() const final { return { _pimpl->getName() }; } - service::FieldResult> getDescription(service::FieldParams&&) const final + service::FieldResult> getDescription() const final { return { _pimpl->getDescription() }; } - service::FieldResult>>> getFields(service::FieldParams&&, std::optional&& includeDeprecatedArg) const final + service::FieldResult>>> getFields(std::optional&& includeDeprecatedArg) const final { return { _pimpl->getFields(std::move(includeDeprecatedArg)) }; } - service::FieldResult>>> getInterfaces(service::FieldParams&&) const final + service::FieldResult>>> getInterfaces() const final { return { _pimpl->getInterfaces() }; } - service::FieldResult>>> getPossibleTypes(service::FieldParams&&) const final + service::FieldResult>>> getPossibleTypes() const final { return { _pimpl->getPossibleTypes() }; } - service::FieldResult>>> getEnumValues(service::FieldParams&&, std::optional&& includeDeprecatedArg) const final + service::FieldResult>>> getEnumValues(std::optional&& includeDeprecatedArg) const final { return { _pimpl->getEnumValues(std::move(includeDeprecatedArg)) }; } - service::FieldResult>>> getInputFields(service::FieldParams&&) const final + service::FieldResult>>> getInputFields() const final { return { _pimpl->getInputFields() }; } - service::FieldResult> getOfType(service::FieldParams&&) const final + service::FieldResult> getOfType() const final { return { _pimpl->getOfType() }; } diff --git a/samples/today/nointrospection/QueryObject.cpp b/samples/today/nointrospection/QueryObject.cpp index 78a38d73..0fda8961 100644 --- a/samples/today/nointrospection/QueryObject.cpp +++ b/samples/today/nointrospection/QueryObject.cpp @@ -127,7 +127,7 @@ service::AwaitableResolver Query::resolveUnreadCounts(service::ResolverParams&& service::AwaitableResolver Query::resolveAppointmentsById(service::ResolverParams&& params) const { - const auto defaultArguments = []() + static const auto defaultArguments = []() { response::Value values(response::Type::Map); response::Value entry; diff --git a/samples/today/schema/QueryObject.cpp b/samples/today/schema/QueryObject.cpp index 1bcbfbb0..2a374fdf 100644 --- a/samples/today/schema/QueryObject.cpp +++ b/samples/today/schema/QueryObject.cpp @@ -131,7 +131,7 @@ service::AwaitableResolver Query::resolveUnreadCounts(service::ResolverParams&& service::AwaitableResolver Query::resolveAppointmentsById(service::ResolverParams&& params) const { - const auto defaultArguments = []() + static const auto defaultArguments = []() { response::Value values(response::Type::Map); response::Value entry; diff --git a/samples/validation/schema/ArgumentsObject.cpp b/samples/validation/schema/ArgumentsObject.cpp index f970c85e..a95e0cea 100644 --- a/samples/validation/schema/ArgumentsObject.cpp +++ b/samples/validation/schema/ArgumentsObject.cpp @@ -138,7 +138,7 @@ service::AwaitableResolver Arguments::resolveBooleanListArgField(service::Resolv service::AwaitableResolver Arguments::resolveOptionalNonNullBooleanArgField(service::ResolverParams&& params) const { - const auto defaultArguments = []() + static const auto defaultArguments = []() { response::Value values(response::Type::Map); response::Value entry; diff --git a/src/SchemaGenerator.cpp b/src/SchemaGenerator.cpp index e4b23513..f369a3c4 100644 --- a/src/SchemaGenerator.cpp +++ b/src/SchemaGenerator.cpp @@ -225,7 +225,7 @@ static_assert(graphql::internal::MinorVersion == )cpp" )cpp"; for (const auto& inputField : inputType.fields) { - headerFile << R"cpp( )cpp" << getFieldDeclaration(inputField) << R"cpp(; + headerFile << getFieldDeclaration(inputField) << R"cpp(; )cpp"; } headerFile << R"cpp(}; @@ -757,7 +757,7 @@ void Generator::outputObjectDeclaration( for (const auto& outputField : objectType.fields) { - headerFile << R"cpp( )cpp" << getFieldDeclaration(outputField); + headerFile << getFieldDeclaration(outputField); } headerFile << R"cpp( }; @@ -781,17 +781,25 @@ void Generator::outputObjectDeclaration( headerFile << R"cpp( service::FieldResult<)cpp" << _loader.getOutputCppType(outputField) << R"cpp(> )cpp" << outputField.accessor - << fieldName << R"cpp((service::FieldParams&&)cpp"; + << fieldName << R"cpp(()cpp"; - if (!_loader.isIntrospection()) + bool firstArgument = _loader.isIntrospection(); + + if (!firstArgument) { - headerFile << R"cpp( params)cpp"; + headerFile << R"cpp(service::FieldParams&& params)cpp"; } for (const auto& argument : outputField.arguments) { - headerFile << R"cpp(, )cpp" << _loader.getInputCppType(argument) << R"cpp(&& )cpp" - << argument.cppName << R"cpp(Arg)cpp"; + if (!firstArgument) + { + headerFile << R"cpp(, )cpp"; + } + + headerFile << _loader.getInputCppType(argument) << R"cpp(&& )cpp" << argument.cppName + << R"cpp(Arg)cpp"; + firstArgument = false; } headerFile << R"cpp() const final @@ -799,7 +807,7 @@ void Generator::outputObjectDeclaration( )cpp"; std::ostringstream ossPassedArguments; - bool firstArgument = true; + firstArgument = true; for (const auto& argument : outputField.arguments) { @@ -1013,7 +1021,8 @@ std::string Generator::getFieldDeclaration(const InputField& inputField) const n { std::ostringstream output; - output << _loader.getInputCppType(inputField) << R"cpp( )cpp" << inputField.cppName; + output << R"cpp( )cpp" << _loader.getInputCppType(inputField) << R"cpp( )cpp" + << inputField.cppName; return output.str(); } @@ -1024,14 +1033,26 @@ std::string Generator::getFieldDeclaration(const OutputField& outputField) const std::string fieldName { outputField.cppName }; fieldName[0] = static_cast(std::toupper(static_cast(fieldName[0]))); - output << R"cpp( virtual service::FieldResult<)cpp" << _loader.getOutputCppType(outputField) - << R"cpp(> )cpp" << outputField.accessor << fieldName - << R"cpp((service::FieldParams&& params)cpp"; + output << R"cpp( virtual service::FieldResult<)cpp" + << _loader.getOutputCppType(outputField) << R"cpp(> )cpp" << outputField.accessor + << fieldName << R"cpp(()cpp"; + + bool firstArgument = _loader.isIntrospection(); + + if (!firstArgument) + { + output << R"cpp(service::FieldParams&& params)cpp"; + } for (const auto& argument : outputField.arguments) { - output << R"cpp(, )cpp" << _loader.getInputCppType(argument) << R"cpp(&& )cpp" - << argument.cppName << "Arg"; + if (!firstArgument) + { + output << R"cpp(, )cpp"; + } + + output << _loader.getInputCppType(argument) << R"cpp(&& )cpp" << argument.cppName << "Arg"; + firstArgument = false; } output << R"cpp() const = 0; @@ -1999,7 +2020,7 @@ service::AwaitableResolver )cpp" if (firstArgument) { firstArgument = false; - sourceFile << R"cpp( const auto defaultArguments = []() + sourceFile << R"cpp( static const auto defaultArguments = []() { response::Value values(response::Type::Map); response::Value entry; @@ -2032,12 +2053,25 @@ service::AwaitableResolver )cpp" } } - sourceFile - << R"cpp( std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->)cpp" - << outputField.accessor << fieldName - << R"cpp((service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)))cpp"; + sourceFile << R"cpp( std::unique_lock resolverLock(_resolverMutex); +)cpp"; + + if (!_loader.isIntrospection()) + { + sourceFile << R"cpp( auto directives = std::move(params.fieldDirectives); +)cpp"; + } + + sourceFile << R"cpp( auto result = _pimpl->)cpp" << outputField.accessor << fieldName + << R"cpp(()cpp"; + + bool firstArgument = _loader.isIntrospection(); + + if (!firstArgument) + { + sourceFile + << R"cpp(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)))cpp"; + } if (!outputField.arguments.empty()) { @@ -2047,7 +2081,14 @@ service::AwaitableResolver )cpp" argumentName[0] = static_cast(std::toupper(static_cast(argumentName[0]))); - sourceFile << R"cpp(, std::move(arg)cpp" << argumentName << R"cpp())cpp"; + + if (!firstArgument) + { + sourceFile << R"cpp(, )cpp"; + } + + sourceFile << R"cpp(std::move(arg)cpp" << argumentName << R"cpp())cpp"; + firstArgument = false; } } diff --git a/src/introspection/CMakeLists.txt b/src/introspection/CMakeLists.txt index 6df7c4c2..82b8203d 100644 --- a/src/introspection/CMakeLists.txt +++ b/src/introspection/CMakeLists.txt @@ -14,7 +14,7 @@ if(GRAPHQL_UPDATE_SAMPLES) OUTPUT copied_introspection_schema_headers COMMAND ${CMAKE_COMMAND} -E copy_if_different ${PRIVATE_HEADERS} ${CMAKE_CURRENT_SOURCE_DIR}/../../include/graphqlservice/introspection/ COMMAND ${CMAKE_COMMAND} -E touch copied_introspection_schema_headers - DEPENDS ${PRIVATE_HEADERS} + DEPENDS ${PRIVATE_HEADERS} ${CMAKE_CURRENT_SOURCE_DIR}/introspection_schema_files COMMENT "Updating IntrospectionSchema headers") add_custom_target(copy_introspection_schema_headers ALL diff --git a/src/introspection/DirectiveObject.cpp b/src/introspection/DirectiveObject.cpp index 7adf45de..91e42d95 100644 --- a/src/introspection/DirectiveObject.cpp +++ b/src/introspection/DirectiveObject.cpp @@ -52,8 +52,7 @@ service::ResolverMap Directive::getResolvers() const noexcept service::AwaitableResolver Directive::resolveName(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getName(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getName(); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); @@ -62,8 +61,7 @@ service::AwaitableResolver Directive::resolveName(service::ResolverParams&& para service::AwaitableResolver Directive::resolveDescription(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getDescription(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getDescription(); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); @@ -72,8 +70,7 @@ service::AwaitableResolver Directive::resolveDescription(service::ResolverParams service::AwaitableResolver Directive::resolveLocations(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getLocations(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getLocations(); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); @@ -82,8 +79,7 @@ service::AwaitableResolver Directive::resolveLocations(service::ResolverParams&& service::AwaitableResolver Directive::resolveArgs(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getArgs(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getArgs(); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); diff --git a/src/introspection/DirectiveObject.h b/src/introspection/DirectiveObject.h index faa56f8d..e0953288 100644 --- a/src/introspection/DirectiveObject.h +++ b/src/introspection/DirectiveObject.h @@ -27,10 +27,10 @@ class Directive { virtual ~Concept() = default; - virtual service::FieldResult getName(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getDescription(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getLocations(service::FieldParams&& params) const = 0; - virtual service::FieldResult>> getArgs(service::FieldParams&& params) const = 0; + virtual service::FieldResult getName() const = 0; + virtual service::FieldResult> getDescription() const = 0; + virtual service::FieldResult> getLocations() const = 0; + virtual service::FieldResult>> getArgs() const = 0; }; template @@ -42,22 +42,22 @@ class Directive { } - service::FieldResult getName(service::FieldParams&&) const final + service::FieldResult getName() const final { return { _pimpl->getName() }; } - service::FieldResult> getDescription(service::FieldParams&&) const final + service::FieldResult> getDescription() const final { return { _pimpl->getDescription() }; } - service::FieldResult> getLocations(service::FieldParams&&) const final + service::FieldResult> getLocations() const final { return { _pimpl->getLocations() }; } - service::FieldResult>> getArgs(service::FieldParams&&) const final + service::FieldResult>> getArgs() const final { return { _pimpl->getArgs() }; } diff --git a/src/introspection/EnumValueObject.cpp b/src/introspection/EnumValueObject.cpp index c0dc7797..d571ec2b 100644 --- a/src/introspection/EnumValueObject.cpp +++ b/src/introspection/EnumValueObject.cpp @@ -51,8 +51,7 @@ service::ResolverMap EnumValue::getResolvers() const noexcept service::AwaitableResolver EnumValue::resolveName(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getName(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getName(); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); @@ -61,8 +60,7 @@ service::AwaitableResolver EnumValue::resolveName(service::ResolverParams&& para service::AwaitableResolver EnumValue::resolveDescription(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getDescription(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getDescription(); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); @@ -71,8 +69,7 @@ service::AwaitableResolver EnumValue::resolveDescription(service::ResolverParams service::AwaitableResolver EnumValue::resolveIsDeprecated(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getIsDeprecated(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getIsDeprecated(); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); @@ -81,8 +78,7 @@ service::AwaitableResolver EnumValue::resolveIsDeprecated(service::ResolverParam service::AwaitableResolver EnumValue::resolveDeprecationReason(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getDeprecationReason(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getDeprecationReason(); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); diff --git a/src/introspection/EnumValueObject.h b/src/introspection/EnumValueObject.h index 003ace70..f52cc584 100644 --- a/src/introspection/EnumValueObject.h +++ b/src/introspection/EnumValueObject.h @@ -27,10 +27,10 @@ class EnumValue { virtual ~Concept() = default; - virtual service::FieldResult getName(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getDescription(service::FieldParams&& params) const = 0; - virtual service::FieldResult getIsDeprecated(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getDeprecationReason(service::FieldParams&& params) const = 0; + virtual service::FieldResult getName() const = 0; + virtual service::FieldResult> getDescription() const = 0; + virtual service::FieldResult getIsDeprecated() const = 0; + virtual service::FieldResult> getDeprecationReason() const = 0; }; template @@ -42,22 +42,22 @@ class EnumValue { } - service::FieldResult getName(service::FieldParams&&) const final + service::FieldResult getName() const final { return { _pimpl->getName() }; } - service::FieldResult> getDescription(service::FieldParams&&) const final + service::FieldResult> getDescription() const final { return { _pimpl->getDescription() }; } - service::FieldResult getIsDeprecated(service::FieldParams&&) const final + service::FieldResult getIsDeprecated() const final { return { _pimpl->getIsDeprecated() }; } - service::FieldResult> getDeprecationReason(service::FieldParams&&) const final + service::FieldResult> getDeprecationReason() const final { return { _pimpl->getDeprecationReason() }; } diff --git a/src/introspection/FieldObject.cpp b/src/introspection/FieldObject.cpp index b2825994..93553442 100644 --- a/src/introspection/FieldObject.cpp +++ b/src/introspection/FieldObject.cpp @@ -55,8 +55,7 @@ service::ResolverMap Field::getResolvers() const noexcept service::AwaitableResolver Field::resolveName(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getName(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getName(); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); @@ -65,8 +64,7 @@ service::AwaitableResolver Field::resolveName(service::ResolverParams&& params) service::AwaitableResolver Field::resolveDescription(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getDescription(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getDescription(); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); @@ -75,8 +73,7 @@ service::AwaitableResolver Field::resolveDescription(service::ResolverParams&& p service::AwaitableResolver Field::resolveArgs(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getArgs(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getArgs(); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); @@ -85,8 +82,7 @@ service::AwaitableResolver Field::resolveArgs(service::ResolverParams&& params) service::AwaitableResolver Field::resolveType(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getType(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getType(); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); @@ -95,8 +91,7 @@ service::AwaitableResolver Field::resolveType(service::ResolverParams&& params) service::AwaitableResolver Field::resolveIsDeprecated(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getIsDeprecated(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getIsDeprecated(); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); @@ -105,8 +100,7 @@ service::AwaitableResolver Field::resolveIsDeprecated(service::ResolverParams&& service::AwaitableResolver Field::resolveDeprecationReason(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getDeprecationReason(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getDeprecationReason(); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); diff --git a/src/introspection/FieldObject.h b/src/introspection/FieldObject.h index 40159e6f..1d50a0cd 100644 --- a/src/introspection/FieldObject.h +++ b/src/introspection/FieldObject.h @@ -29,12 +29,12 @@ class Field { virtual ~Concept() = default; - virtual service::FieldResult getName(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getDescription(service::FieldParams&& params) const = 0; - virtual service::FieldResult>> getArgs(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getType(service::FieldParams&& params) const = 0; - virtual service::FieldResult getIsDeprecated(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getDeprecationReason(service::FieldParams&& params) const = 0; + virtual service::FieldResult getName() const = 0; + virtual service::FieldResult> getDescription() const = 0; + virtual service::FieldResult>> getArgs() const = 0; + virtual service::FieldResult> getType() const = 0; + virtual service::FieldResult getIsDeprecated() const = 0; + virtual service::FieldResult> getDeprecationReason() const = 0; }; template @@ -46,32 +46,32 @@ class Field { } - service::FieldResult getName(service::FieldParams&&) const final + service::FieldResult getName() const final { return { _pimpl->getName() }; } - service::FieldResult> getDescription(service::FieldParams&&) const final + service::FieldResult> getDescription() const final { return { _pimpl->getDescription() }; } - service::FieldResult>> getArgs(service::FieldParams&&) const final + service::FieldResult>> getArgs() const final { return { _pimpl->getArgs() }; } - service::FieldResult> getType(service::FieldParams&&) const final + service::FieldResult> getType() const final { return { _pimpl->getType() }; } - service::FieldResult getIsDeprecated(service::FieldParams&&) const final + service::FieldResult getIsDeprecated() const final { return { _pimpl->getIsDeprecated() }; } - service::FieldResult> getDeprecationReason(service::FieldParams&&) const final + service::FieldResult> getDeprecationReason() const final { return { _pimpl->getDeprecationReason() }; } diff --git a/src/introspection/InputValueObject.cpp b/src/introspection/InputValueObject.cpp index 9d1c51a7..bd58ef3a 100644 --- a/src/introspection/InputValueObject.cpp +++ b/src/introspection/InputValueObject.cpp @@ -52,8 +52,7 @@ service::ResolverMap InputValue::getResolvers() const noexcept service::AwaitableResolver InputValue::resolveName(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getName(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getName(); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); @@ -62,8 +61,7 @@ service::AwaitableResolver InputValue::resolveName(service::ResolverParams&& par service::AwaitableResolver InputValue::resolveDescription(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getDescription(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getDescription(); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); @@ -72,8 +70,7 @@ service::AwaitableResolver InputValue::resolveDescription(service::ResolverParam service::AwaitableResolver InputValue::resolveType(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getType(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getType(); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); @@ -82,8 +79,7 @@ service::AwaitableResolver InputValue::resolveType(service::ResolverParams&& par service::AwaitableResolver InputValue::resolveDefaultValue(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getDefaultValue(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getDefaultValue(); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); diff --git a/src/introspection/InputValueObject.h b/src/introspection/InputValueObject.h index facdbcd9..65199e06 100644 --- a/src/introspection/InputValueObject.h +++ b/src/introspection/InputValueObject.h @@ -27,10 +27,10 @@ class InputValue { virtual ~Concept() = default; - virtual service::FieldResult getName(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getDescription(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getType(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getDefaultValue(service::FieldParams&& params) const = 0; + virtual service::FieldResult getName() const = 0; + virtual service::FieldResult> getDescription() const = 0; + virtual service::FieldResult> getType() const = 0; + virtual service::FieldResult> getDefaultValue() const = 0; }; template @@ -42,22 +42,22 @@ class InputValue { } - service::FieldResult getName(service::FieldParams&&) const final + service::FieldResult getName() const final { return { _pimpl->getName() }; } - service::FieldResult> getDescription(service::FieldParams&&) const final + service::FieldResult> getDescription() const final { return { _pimpl->getDescription() }; } - service::FieldResult> getType(service::FieldParams&&) const final + service::FieldResult> getType() const final { return { _pimpl->getType() }; } - service::FieldResult> getDefaultValue(service::FieldParams&&) const final + service::FieldResult> getDefaultValue() const final { return { _pimpl->getDefaultValue() }; } diff --git a/src/introspection/SchemaObject.cpp b/src/introspection/SchemaObject.cpp index eb5cc0fc..16c857a6 100644 --- a/src/introspection/SchemaObject.cpp +++ b/src/introspection/SchemaObject.cpp @@ -54,8 +54,7 @@ service::ResolverMap Schema::getResolvers() const noexcept service::AwaitableResolver Schema::resolveTypes(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getTypes(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getTypes(); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); @@ -64,8 +63,7 @@ service::AwaitableResolver Schema::resolveTypes(service::ResolverParams&& params service::AwaitableResolver Schema::resolveQueryType(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getQueryType(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getQueryType(); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); @@ -74,8 +72,7 @@ service::AwaitableResolver Schema::resolveQueryType(service::ResolverParams&& pa service::AwaitableResolver Schema::resolveMutationType(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getMutationType(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getMutationType(); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); @@ -84,8 +81,7 @@ service::AwaitableResolver Schema::resolveMutationType(service::ResolverParams&& service::AwaitableResolver Schema::resolveSubscriptionType(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getSubscriptionType(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getSubscriptionType(); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); @@ -94,8 +90,7 @@ service::AwaitableResolver Schema::resolveSubscriptionType(service::ResolverPara service::AwaitableResolver Schema::resolveDirectives(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getDirectives(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getDirectives(); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); diff --git a/src/introspection/SchemaObject.h b/src/introspection/SchemaObject.h index 0eb08742..f81ab9c3 100644 --- a/src/introspection/SchemaObject.h +++ b/src/introspection/SchemaObject.h @@ -28,11 +28,11 @@ class Schema { virtual ~Concept() = default; - virtual service::FieldResult>> getTypes(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getQueryType(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getMutationType(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getSubscriptionType(service::FieldParams&& params) const = 0; - virtual service::FieldResult>> getDirectives(service::FieldParams&& params) const = 0; + virtual service::FieldResult>> getTypes() const = 0; + virtual service::FieldResult> getQueryType() const = 0; + virtual service::FieldResult> getMutationType() const = 0; + virtual service::FieldResult> getSubscriptionType() const = 0; + virtual service::FieldResult>> getDirectives() const = 0; }; template @@ -44,27 +44,27 @@ class Schema { } - service::FieldResult>> getTypes(service::FieldParams&&) const final + service::FieldResult>> getTypes() const final { return { _pimpl->getTypes() }; } - service::FieldResult> getQueryType(service::FieldParams&&) const final + service::FieldResult> getQueryType() const final { return { _pimpl->getQueryType() }; } - service::FieldResult> getMutationType(service::FieldParams&&) const final + service::FieldResult> getMutationType() const final { return { _pimpl->getMutationType() }; } - service::FieldResult> getSubscriptionType(service::FieldParams&&) const final + service::FieldResult> getSubscriptionType() const final { return { _pimpl->getSubscriptionType() }; } - service::FieldResult>> getDirectives(service::FieldParams&&) const final + service::FieldResult>> getDirectives() const final { return { _pimpl->getDirectives() }; } diff --git a/src/introspection/TypeObject.cpp b/src/introspection/TypeObject.cpp index 42bf4548..aecb5d2f 100644 --- a/src/introspection/TypeObject.cpp +++ b/src/introspection/TypeObject.cpp @@ -60,8 +60,7 @@ service::ResolverMap Type::getResolvers() const noexcept service::AwaitableResolver Type::resolveKind(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getKind(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getKind(); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); @@ -70,8 +69,7 @@ service::AwaitableResolver Type::resolveKind(service::ResolverParams&& params) c service::AwaitableResolver Type::resolveName(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getName(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getName(); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); @@ -80,8 +78,7 @@ service::AwaitableResolver Type::resolveName(service::ResolverParams&& params) c service::AwaitableResolver Type::resolveDescription(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getDescription(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getDescription(); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); @@ -89,7 +86,7 @@ service::AwaitableResolver Type::resolveDescription(service::ResolverParams&& pa service::AwaitableResolver Type::resolveFields(service::ResolverParams&& params) const { - const auto defaultArguments = []() + static const auto defaultArguments = []() { response::Value values(response::Type::Map); response::Value entry; @@ -105,8 +102,7 @@ service::AwaitableResolver Type::resolveFields(service::ResolverParams&& params) ? std::move(pairIncludeDeprecated.first) : service::ModifiedArgument::require("includeDeprecated", defaultArguments)); std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getFields(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argIncludeDeprecated)); + auto result = _pimpl->getFields(std::move(argIncludeDeprecated)); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); @@ -115,8 +111,7 @@ service::AwaitableResolver Type::resolveFields(service::ResolverParams&& params) service::AwaitableResolver Type::resolveInterfaces(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getInterfaces(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getInterfaces(); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); @@ -125,8 +120,7 @@ service::AwaitableResolver Type::resolveInterfaces(service::ResolverParams&& par service::AwaitableResolver Type::resolvePossibleTypes(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getPossibleTypes(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getPossibleTypes(); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); @@ -134,7 +128,7 @@ service::AwaitableResolver Type::resolvePossibleTypes(service::ResolverParams&& service::AwaitableResolver Type::resolveEnumValues(service::ResolverParams&& params) const { - const auto defaultArguments = []() + static const auto defaultArguments = []() { response::Value values(response::Type::Map); response::Value entry; @@ -150,8 +144,7 @@ service::AwaitableResolver Type::resolveEnumValues(service::ResolverParams&& par ? std::move(pairIncludeDeprecated.first) : service::ModifiedArgument::require("includeDeprecated", defaultArguments)); std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getEnumValues(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives)), std::move(argIncludeDeprecated)); + auto result = _pimpl->getEnumValues(std::move(argIncludeDeprecated)); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); @@ -160,8 +153,7 @@ service::AwaitableResolver Type::resolveEnumValues(service::ResolverParams&& par service::AwaitableResolver Type::resolveInputFields(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getInputFields(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getInputFields(); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); @@ -170,8 +162,7 @@ service::AwaitableResolver Type::resolveInputFields(service::ResolverParams&& pa service::AwaitableResolver Type::resolveOfType(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); - auto directives = std::move(params.fieldDirectives); - auto result = _pimpl->getOfType(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + auto result = _pimpl->getOfType(); resolverLock.unlock(); return service::ModifiedResult::convert(std::move(result), std::move(params)); diff --git a/src/introspection/TypeObject.h b/src/introspection/TypeObject.h index e7429c59..87c2101e 100644 --- a/src/introspection/TypeObject.h +++ b/src/introspection/TypeObject.h @@ -32,15 +32,15 @@ class Type { virtual ~Concept() = default; - virtual service::FieldResult getKind(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getName(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getDescription(service::FieldParams&& params) const = 0; - virtual service::FieldResult>>> getFields(service::FieldParams&& params, std::optional&& includeDeprecatedArg) const = 0; - virtual service::FieldResult>>> getInterfaces(service::FieldParams&& params) const = 0; - virtual service::FieldResult>>> getPossibleTypes(service::FieldParams&& params) const = 0; - virtual service::FieldResult>>> getEnumValues(service::FieldParams&& params, std::optional&& includeDeprecatedArg) const = 0; - virtual service::FieldResult>>> getInputFields(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getOfType(service::FieldParams&& params) const = 0; + virtual service::FieldResult getKind() const = 0; + virtual service::FieldResult> getName() const = 0; + virtual service::FieldResult> getDescription() const = 0; + virtual service::FieldResult>>> getFields(std::optional&& includeDeprecatedArg) const = 0; + virtual service::FieldResult>>> getInterfaces() const = 0; + virtual service::FieldResult>>> getPossibleTypes() const = 0; + virtual service::FieldResult>>> getEnumValues(std::optional&& includeDeprecatedArg) const = 0; + virtual service::FieldResult>>> getInputFields() const = 0; + virtual service::FieldResult> getOfType() const = 0; }; template @@ -52,47 +52,47 @@ class Type { } - service::FieldResult getKind(service::FieldParams&&) const final + service::FieldResult getKind() const final { return { _pimpl->getKind() }; } - service::FieldResult> getName(service::FieldParams&&) const final + service::FieldResult> getName() const final { return { _pimpl->getName() }; } - service::FieldResult> getDescription(service::FieldParams&&) const final + service::FieldResult> getDescription() const final { return { _pimpl->getDescription() }; } - service::FieldResult>>> getFields(service::FieldParams&&, std::optional&& includeDeprecatedArg) const final + service::FieldResult>>> getFields(std::optional&& includeDeprecatedArg) const final { return { _pimpl->getFields(std::move(includeDeprecatedArg)) }; } - service::FieldResult>>> getInterfaces(service::FieldParams&&) const final + service::FieldResult>>> getInterfaces() const final { return { _pimpl->getInterfaces() }; } - service::FieldResult>>> getPossibleTypes(service::FieldParams&&) const final + service::FieldResult>>> getPossibleTypes() const final { return { _pimpl->getPossibleTypes() }; } - service::FieldResult>>> getEnumValues(service::FieldParams&&, std::optional&& includeDeprecatedArg) const final + service::FieldResult>>> getEnumValues(std::optional&& includeDeprecatedArg) const final { return { _pimpl->getEnumValues(std::move(includeDeprecatedArg)) }; } - service::FieldResult>>> getInputFields(service::FieldParams&&) const final + service::FieldResult>>> getInputFields() const final { return { _pimpl->getInputFields() }; } - service::FieldResult> getOfType(service::FieldParams&&) const final + service::FieldResult> getOfType() const final { return { _pimpl->getOfType() }; } From 2344b352814f205ac3e77f75a804404c278b691a Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Fri, 10 Dec 2021 00:17:46 -0800 Subject: [PATCH 081/119] Add support for new GraphQL grammar/Introspection --- include/SchemaLoader.h | 5 + include/graphqlservice/internal/Grammar.h | 203 +++++++++--------- .../graphqlservice/internal/Introspection.h | 3 + include/graphqlservice/internal/Schema.h | 14 +- .../introspection/DirectiveObject.h | 7 + .../introspection/IntrospectionSchema.h | 1 + .../introspection/SchemaObject.h | 7 + .../graphqlservice/introspection/TypeObject.h | 7 + samples/learn/schema/StarWarsSchema.cpp | 12 +- samples/today/nointrospection/TodaySchema.cpp | 52 ++--- samples/today/schema/TodaySchema.cpp | 52 ++--- .../validation/schema/ValidationSchema.cpp | 22 +- src/Introspection.cpp | 21 +- src/RequestLoader.cpp | 7 +- src/Schema.cpp | 36 +++- src/SchemaGenerator.cpp | 34 ++- src/SchemaLoader.cpp | 92 +++++++- src/SyntaxTree.cpp | 5 + src/introspection/DirectiveObject.cpp | 15 +- src/introspection/DirectiveObject.h | 7 + src/introspection/IntrospectionSchema.cpp | 37 ++-- src/introspection/IntrospectionSchema.h | 1 + src/introspection/SchemaObject.cpp | 11 + src/introspection/SchemaObject.h | 7 + src/introspection/TypeObject.cpp | 15 +- src/introspection/TypeObject.h | 7 + .../schema.introspection.graphql | 48 ++--- 27 files changed, 495 insertions(+), 233 deletions(-) diff --git a/include/SchemaLoader.h b/include/SchemaLoader.h index fe7def07..0dcd53e2 100644 --- a/include/SchemaLoader.h +++ b/include/SchemaLoader.h @@ -48,6 +48,7 @@ struct ScalarType { std::string_view type; std::string_view description; + std::string_view specifiedByURL; }; using ScalarTypeList = std::vector; @@ -113,6 +114,7 @@ using InputTypeList = std::vector; struct Directive { std::string_view name; + bool isRepeatable = false; std::vector locations; InputFieldList arguments; std::string_view description; @@ -219,6 +221,7 @@ class SchemaLoader explicit SchemaLoader(SchemaOptions&& schemaOptions); bool isIntrospection() const noexcept; + std::string_view getSchemaDescription() const noexcept; std::string_view getFilenamePrefix() const noexcept; std::string_view getSchemaNamespace() const noexcept; @@ -265,6 +268,7 @@ class SchemaLoader void visitSchemaDefinition(const peg::ast_node& schemaDefinition); void visitSchemaExtension(const peg::ast_node& schemaExtension); void visitScalarTypeDefinition(const peg::ast_node& scalarTypeDefinition); + void visitScalarTypeExtension(const peg::ast_node& scalarTypeExtension); void visitEnumTypeDefinition(const peg::ast_node& enumTypeDefinition); void visitEnumTypeExtension(const peg::ast_node& enumTypeExtension); void visitInputObjectTypeDefinition(const peg::ast_node& inputObjectTypeDefinition); @@ -294,6 +298,7 @@ class SchemaLoader const SchemaOptions _schemaOptions; const bool _isIntrospection; + std::string_view _schemaDescription; std::string_view _schemaNamespace; peg::ast _ast; diff --git a/include/graphqlservice/internal/Grammar.h b/include/graphqlservice/internal/Grammar.h index 1e95e2d3..6076b993 100644 --- a/include/graphqlservice/internal/Grammar.h +++ b/include/graphqlservice/internal/Grammar.h @@ -1,8 +1,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. // -// This grammar is based on the June 2018 Edition of the GraphQL spec: -// http://spec.graphql.org/June2018/ +// This grammar is based on the October 2021 Edition of the GraphQL spec: +// https://spec.graphql.org/October2021/ #pragma once @@ -59,22 +59,22 @@ void on_first_child(const ast_node& n, std::function&& fu } } -// http://spec.graphql.org/June2018/#sec-Source-Text +// https://spec.graphql.org/October2021/#sec-Source-Text struct source_character : sor, utf8::range<0x0020, 0xFFFF>> { }; -// http://spec.graphql.org/June2018/#sec-Comments +// https://spec.graphql.org/October2021/#sec-Comments struct comment : seq, until> { }; -// http://spec.graphql.org/June2018/#sec-Source-Text.Ignored-Tokens +// https://spec.graphql.org/October2021/#sec-Source-Text.Ignored-Tokens struct ignored : sor, comment> { }; -// http://spec.graphql.org/June2018/#sec-Names +// https://spec.graphql.org/October2021/#sec-Names struct name : identifier { }; @@ -83,12 +83,12 @@ struct variable_name_content : name { }; -// http://spec.graphql.org/June2018/#Variable +// https://spec.graphql.org/October2021/#Variable struct variable_name : if_must, variable_name_content> { }; -// http://spec.graphql.org/June2018/#sec-Null-Value +// https://spec.graphql.org/October2021/#sec-Null-Value struct null_keyword : TAO_PEGTL_KEYWORD("null") { }; @@ -109,12 +109,12 @@ struct escaped_unicode_content : list, escaped_unicode_content> { }; -// http://spec.graphql.org/June2018/#EscapedCharacter +// https://spec.graphql.org/October2021/#EscapedCharacter struct escaped_char : one<'"', '\\', '/', 'b', 'f', 'n', 'r', 't'> { }; @@ -137,7 +137,7 @@ struct string_quote_content { }; -// http://spec.graphql.org/June2018/#StringCharacter +// https://spec.graphql.org/October2021/#StringCharacter struct string_quote : if_must { }; @@ -160,17 +160,17 @@ struct block_quote_content { }; -// http://spec.graphql.org/June2018/#BlockStringCharacter +// https://spec.graphql.org/October2021/#BlockStringCharacter struct block_quote : if_must { }; -// http://spec.graphql.org/June2018/#StringValue +// https://spec.graphql.org/October2021/#StringValue struct string_value : sor { }; -// http://spec.graphql.org/June2018/#NonZeroDigit +// https://spec.graphql.org/October2021/#NonZeroDigit struct nonzero_digit : range<'1', '9'> { }; @@ -179,17 +179,17 @@ struct zero_digit : one<'0'> { }; -// http://spec.graphql.org/June2018/#NegativeSign +// https://spec.graphql.org/October2021/#NegativeSign struct negative_sign : one<'-'> { }; -// http://spec.graphql.org/June2018/#IntegerPart +// https://spec.graphql.org/October2021/#IntegerPart struct integer_part : seq, sor>>> { }; -// http://spec.graphql.org/June2018/#IntValue +// https://spec.graphql.org/October2021/#IntValue struct integer_value : integer_part { }; @@ -198,17 +198,17 @@ struct fractional_part_content : plus { }; -// http://spec.graphql.org/June2018/#FractionalPart +// https://spec.graphql.org/October2021/#FractionalPart struct fractional_part : if_must, fractional_part_content> { }; -// http://spec.graphql.org/June2018/#ExponentIndicator +// https://spec.graphql.org/October2021/#ExponentIndicator struct exponent_indicator : one<'e', 'E'> { }; -// http://spec.graphql.org/June2018/#Sign +// https://spec.graphql.org/October2021/#Sign struct sign : one<'+', '-'> { }; @@ -217,12 +217,12 @@ struct exponent_part_content : seq, plus> { }; -// http://spec.graphql.org/June2018/#ExponentPart +// https://spec.graphql.org/October2021/#ExponentPart struct exponent_part : if_must { }; -// http://spec.graphql.org/June2018/#FloatValue +// https://spec.graphql.org/October2021/#FloatValue struct float_value : seq>> { @@ -236,17 +236,17 @@ struct false_keyword : TAO_PEGTL_KEYWORD("false") { }; -// http://spec.graphql.org/June2018/#BooleanValue +// https://spec.graphql.org/October2021/#BooleanValue struct bool_value : sor { }; -// http://spec.graphql.org/June2018/#EnumValue +// https://spec.graphql.org/October2021/#EnumValue struct enum_value : seq, name> { }; -// http://spec.graphql.org/June2018/#OperationType +// https://spec.graphql.org/October2021/#OperationType struct operation_type : sor @@ -257,7 +257,7 @@ struct alias_name : name { }; -// http://spec.graphql.org/June2018/#Alias +// https://spec.graphql.org/October2021/#Alias struct alias : seq, one<':'>> { }; @@ -272,7 +272,7 @@ struct argument_content : seq, one<':'>, star, input_valu { }; -// http://spec.graphql.org/June2018/#Argument +// https://spec.graphql.org/October2021/#Argument struct argument : if_must { }; @@ -282,7 +282,7 @@ struct arguments_content { }; -// http://spec.graphql.org/June2018/#Arguments +// https://spec.graphql.org/October2021/#Arguments struct arguments : if_must, arguments_content> { }; @@ -294,7 +294,7 @@ struct list_value_content { }; -// http://spec.graphql.org/June2018/#ListValue +// https://spec.graphql.org/October2021/#ListValue struct list_value : if_must, list_value_content> { }; @@ -307,7 +307,7 @@ struct object_field_content : seq, one<':'>, star, input_ { }; -// http://spec.graphql.org/June2018/#ObjectField +// https://spec.graphql.org/October2021/#ObjectField struct object_field : if_must { }; @@ -317,7 +317,7 @@ struct object_value_content { }; -// http://spec.graphql.org/June2018/#ObjectValue +// https://spec.graphql.org/October2021/#ObjectValue struct object_value : if_must, object_value_content> { }; @@ -332,7 +332,7 @@ struct input_value_content { }; -// http://spec.graphql.org/June2018/#Value +// https://spec.graphql.org/October2021/#Value struct input_value : must { }; @@ -345,12 +345,12 @@ struct default_value_content : seq, input_value> { }; -// http://spec.graphql.org/June2018/#DefaultValue +// https://spec.graphql.org/October2021/#DefaultValue struct default_value : if_must, default_value_content> { }; -// http://spec.graphql.org/June2018/#NamedType +// https://spec.graphql.org/October2021/#NamedType struct named_type : name { }; @@ -363,12 +363,12 @@ struct list_type_content { }; -// http://spec.graphql.org/June2018/#ListType +// https://spec.graphql.org/October2021/#ListType struct list_type : if_must, list_type_content> { }; -// http://spec.graphql.org/June2018/#NonNullType +// https://spec.graphql.org/October2021/#NonNullType struct nonnull_type : seq, star, one<'!'>> { }; @@ -377,7 +377,7 @@ struct type_name_content : sor { }; -// http://spec.graphql.org/June2018/#Type +// https://spec.graphql.org/October2021/#Type struct type_name : must { }; @@ -387,7 +387,7 @@ struct variable_content { }; -// http://spec.graphql.org/June2018/#VariableDefinition +// https://spec.graphql.org/October2021/#VariableDefinition struct variable : if_must { }; @@ -397,7 +397,7 @@ struct variable_definitions_content { }; -// http://spec.graphql.org/June2018/#VariableDefinitions +// https://spec.graphql.org/October2021/#VariableDefinitions struct variable_definitions : if_must, variable_definitions_content> { }; @@ -410,12 +410,12 @@ struct directive_content : seq, arguments>> { }; -// http://spec.graphql.org/June2018/#Directive +// https://spec.graphql.org/October2021/#Directive struct directive : if_must, directive_content> { }; -// http://spec.graphql.org/June2018/#Directives +// https://spec.graphql.org/October2021/#Directives struct directives : list> { }; @@ -448,7 +448,7 @@ struct field_content { }; -// http://spec.graphql.org/June2018/#Field +// https://spec.graphql.org/October2021/#Field struct field : if_must { }; @@ -457,7 +457,7 @@ struct on_keyword : TAO_PEGTL_KEYWORD("on") { }; -// http://spec.graphql.org/June2018/#FragmentName +// https://spec.graphql.org/October2021/#FragmentName struct fragment_name : seq, name> { }; @@ -466,7 +466,7 @@ struct fragment_token : ellipsis { }; -// http://spec.graphql.org/June2018/#FragmentSpread +// https://spec.graphql.org/October2021/#FragmentSpread struct fragment_spread : seq, fragment_name, opt, directives>> { }; @@ -475,12 +475,12 @@ struct type_condition_content : seq, named_type> { }; -// http://spec.graphql.org/June2018/#TypeCondition +// https://spec.graphql.org/October2021/#TypeCondition struct type_condition : if_must { }; -// http://spec.graphql.org/June2018/#InlineFragment +// https://spec.graphql.org/October2021/#InlineFragment struct inline_fragment : seq, type_condition>, opt, directives>, star, selection_set> @@ -496,7 +496,7 @@ struct fragement_spread_or_inline_fragment { }; -// http://spec.graphql.org/June2018/#Selection +// https://spec.graphql.org/October2021/#Selection struct selection : sor { }; @@ -506,7 +506,7 @@ struct selection_set_content { }; -// http://spec.graphql.org/June2018/#SelectionSet +// https://spec.graphql.org/October2021/#SelectionSet struct selection_set : if_must, selection_set_content> { }; @@ -521,7 +521,7 @@ struct operation_definition_operation_type_content { }; -// http://spec.graphql.org/June2018/#OperationDefinition +// https://spec.graphql.org/October2021/#OperationDefinition struct operation_definition : sor, selection_set> { @@ -533,16 +533,21 @@ struct fragment_definition_content { }; -// http://spec.graphql.org/June2018/#FragmentDefinition +// https://spec.graphql.org/October2021/#FragmentDefinition struct fragment_definition : if_must { }; -// http://spec.graphql.org/June2018/#ExecutableDefinition +// https://spec.graphql.org/October2021/#ExecutableDefinition struct executable_definition : sor { }; +// https://spec.graphql.org/October2021/#Description +struct description : string_value +{ +}; + struct schema_keyword : TAO_PEGTL_KEYWORD("schema") { }; @@ -551,19 +556,23 @@ struct root_operation_definition_content : seq, one<':'>, star { }; +struct schema_definition_start : seq>, schema_keyword> +{ +}; + struct schema_definition_content : seq, directives>, star, one<'{'>, star, list>, star, must>> { }; -// http://spec.graphql.org/June2018/#SchemaDefinition -struct schema_definition : if_must +// https://spec.graphql.org/October2021/#SchemaDefinition +struct schema_definition : if_must { }; @@ -571,11 +580,6 @@ struct scalar_keyword : TAO_PEGTL_KEYWORD("scalar") { }; -// http://spec.graphql.org/June2018/#Description -struct description : string_value -{ -}; - struct scalar_name : name { }; @@ -589,7 +593,7 @@ struct scalar_type_definition_content { }; -// http://spec.graphql.org/June2018/#ScalarTypeDefinition +// https://spec.graphql.org/October2021/#ScalarTypeDefinition struct scalar_type_definition : if_must { @@ -610,7 +614,7 @@ struct arguments_definition_content { }; -// http://spec.graphql.org/June2018/#ArgumentsDefinition +// https://spec.graphql.org/October2021/#ArgumentsDefinition struct arguments_definition : if_must { }; @@ -625,7 +629,7 @@ struct field_definition_content { }; -// http://spec.graphql.org/June2018/#FieldDefinition +// https://spec.graphql.org/October2021/#FieldDefinition struct field_definition : if_must { }; @@ -635,7 +639,7 @@ struct fields_definition_content { }; -// http://spec.graphql.org/June2018/#FieldsDefinition +// https://spec.graphql.org/October2021/#FieldsDefinition struct fields_definition : if_must, fields_definition_content> { }; @@ -650,7 +654,7 @@ struct implements_interfaces_content { }; -// http://spec.graphql.org/June2018/#ImplementsInterfaces +// https://spec.graphql.org/October2021/#ImplementsInterfaces struct implements_interfaces : if_must { @@ -689,7 +693,7 @@ struct object_type_definition_content { }; -// http://spec.graphql.org/June2018/#ObjectTypeDefinition +// https://spec.graphql.org/October2021/#ObjectTypeDefinition struct object_type_definition : if_must { @@ -727,7 +731,7 @@ struct interface_type_definition_content { }; -// http://spec.graphql.org/June2018/#InterfaceTypeDefinition +// https://spec.graphql.org/October2021/#InterfaceTypeDefinition struct interface_type_definition : if_must { @@ -755,7 +759,7 @@ struct union_member_types_content { }; -// http://spec.graphql.org/June2018/#UnionMemberTypes +// https://spec.graphql.org/October2021/#UnionMemberTypes struct union_member_types : if_must { }; @@ -775,7 +779,7 @@ struct union_type_definition_content { }; -// http://spec.graphql.org/June2018/#UnionTypeDefinition +// https://spec.graphql.org/October2021/#UnionTypeDefinition struct union_type_definition : if_must { }; @@ -796,7 +800,7 @@ struct enum_value_definition_content : opt, directives> { }; -// http://spec.graphql.org/June2018/#EnumValueDefinition +// https://spec.graphql.org/October2021/#EnumValueDefinition struct enum_value_definition : if_must { }; @@ -810,7 +814,7 @@ struct enum_values_definition_content { }; -// http://spec.graphql.org/June2018/#EnumValuesDefinition +// https://spec.graphql.org/October2021/#EnumValuesDefinition struct enum_values_definition : if_must { @@ -839,7 +843,7 @@ struct enum_type_definition_content { }; -// http://spec.graphql.org/June2018/#EnumTypeDefinition +// https://spec.graphql.org/October2021/#EnumTypeDefinition struct enum_type_definition : if_must { }; @@ -871,7 +875,7 @@ struct input_field_definition_content { }; -// http://spec.graphql.org/June2018/#InputValueDefinition +// https://spec.graphql.org/October2021/#InputValueDefinition struct input_field_definition : if_must { @@ -886,7 +890,7 @@ struct input_fields_definition_content { }; -// http://spec.graphql.org/June2018/#InputFieldsDefinition +// https://spec.graphql.org/October2021/#InputFieldsDefinition struct input_fields_definition : if_must { @@ -916,20 +920,20 @@ struct input_object_type_definition_content { }; -// http://spec.graphql.org/June2018/#InputObjectTypeDefinition +// https://spec.graphql.org/October2021/#InputObjectTypeDefinition struct input_object_type_definition : if_must { }; -// http://spec.graphql.org/June2018/#TypeDefinition +// https://spec.graphql.org/October2021/#TypeDefinition struct type_definition : sor { }; -// http://spec.graphql.org/June2018/#ExecutableDirectiveLocation +// https://spec.graphql.org/October2021/#ExecutableDirectiveLocation struct executable_directive_location : sor { }; -// http://spec.graphql.org/June2018/#DirectiveLocations +// https://spec.graphql.org/October2021/#DirectiveLocations struct directive_locations : seq, star>, list, one<'|'>, star>>> @@ -965,18 +969,23 @@ struct directive_definition_start { }; +struct repeatable_keyword : TAO_PEGTL_KEYWORD("repeatable") +{ +}; + struct directive_definition_content : seq, one<'@'>, directive_name, opt, arguments_definition>, - plus, on_keyword, plus, directive_locations> + opt, repeatable_keyword>, plus, on_keyword, plus, + directive_locations> { }; -// http://spec.graphql.org/June2018/#DirectiveDefinition +// https://spec.graphql.org/October2021/#DirectiveDefinition struct directive_definition : if_must { }; -// http://spec.graphql.org/June2018/#TypeSystemDefinition +// https://spec.graphql.org/October2021/#TypeSystemDefinition struct type_system_definition : sor { }; @@ -985,7 +994,7 @@ struct extend_keyword : TAO_PEGTL_KEYWORD("extend") { }; -// http://spec.graphql.org/June2018/#OperationTypeDefinition +// https://spec.graphql.org/October2021/#OperationTypeDefinition struct operation_type_definition : root_operation_definition { }; @@ -1006,7 +1015,7 @@ struct schema_extension_content { }; -// http://spec.graphql.org/June2018/#SchemaExtension +// https://spec.graphql.org/October2021/#SchemaExtension struct schema_extension : if_must { }; @@ -1019,7 +1028,7 @@ struct scalar_type_extension_content : seq, scalar_name, star { }; @@ -1050,7 +1059,7 @@ struct object_type_extension_content { }; -// http://spec.graphql.org/June2018/#ObjectTypeExtension +// https://spec.graphql.org/October2021/#ObjectTypeExtension struct object_type_extension : if_must { }; @@ -1065,7 +1074,7 @@ struct interface_type_extension_content { }; -// http://spec.graphql.org/June2018/#InterfaceTypeExtension +// https://spec.graphql.org/October2021/#InterfaceTypeExtension struct interface_type_extension : if_must { @@ -1081,7 +1090,7 @@ struct union_type_extension_content { }; -// http://spec.graphql.org/June2018/#UnionTypeExtension +// https://spec.graphql.org/October2021/#UnionTypeExtension struct union_type_extension : if_must { }; @@ -1096,7 +1105,7 @@ struct enum_type_extension_content { }; -// http://spec.graphql.org/June2018/#EnumTypeExtension +// https://spec.graphql.org/October2021/#EnumTypeExtension struct enum_type_extension : if_must { }; @@ -1111,25 +1120,25 @@ struct input_object_type_extension_content { }; -// http://spec.graphql.org/June2018/#InputObjectTypeExtension +// https://spec.graphql.org/October2021/#InputObjectTypeExtension struct input_object_type_extension : if_must { }; -// http://spec.graphql.org/June2018/#TypeExtension +// https://spec.graphql.org/October2021/#TypeExtension struct type_extension : sor { }; -// http://spec.graphql.org/June2018/#TypeSystemExtension +// https://spec.graphql.org/October2021/#TypeSystemExtension struct type_system_extension : sor { }; -// http://spec.graphql.org/June2018/#Definition +// https://spec.graphql.org/October2021/#Definition struct mixed_definition : sor { }; @@ -1141,7 +1150,7 @@ struct mixed_document_content { }; -// http://spec.graphql.org/June2018/#Document +// https://spec.graphql.org/October2021/#Document struct mixed_document : must { }; @@ -1153,12 +1162,12 @@ struct executable_document_content { }; -// http://spec.graphql.org/June2018/#Document +// https://spec.graphql.org/October2021/#Document struct executable_document : must { }; -// http://spec.graphql.org/June2018/#Definition +// https://spec.graphql.org/October2021/#Definition struct schema_type_definition : sor { }; @@ -1170,7 +1179,7 @@ struct schema_document_content { }; -// http://spec.graphql.org/June2018/#Document +// https://spec.graphql.org/October2021/#Document struct schema_document : must { }; diff --git a/include/graphqlservice/internal/Introspection.h b/include/graphqlservice/internal/Introspection.h index 0049b6ef..b2448e62 100644 --- a/include/graphqlservice/internal/Introspection.h +++ b/include/graphqlservice/internal/Introspection.h @@ -25,6 +25,7 @@ class Schema GRAPHQLINTROSPECTION_EXPORT explicit Schema(const std::shared_ptr& schema); // Accessors + GRAPHQLINTROSPECTION_EXPORT std::optional getDescription() const; GRAPHQLINTROSPECTION_EXPORT std::vector> getTypes() const; GRAPHQLINTROSPECTION_EXPORT std::shared_ptr getQueryType() const; GRAPHQLINTROSPECTION_EXPORT std::shared_ptr getMutationType() const; @@ -56,6 +57,7 @@ class Type GRAPHQLINTROSPECTION_EXPORT std::optional>> getInputFields() const; GRAPHQLINTROSPECTION_EXPORT std::shared_ptr getOfType() const; + GRAPHQLINTROSPECTION_EXPORT std::optional getSpecifiedByURL() const; private: const std::shared_ptr _type; @@ -121,6 +123,7 @@ class Directive GRAPHQLINTROSPECTION_EXPORT std::optional getDescription() const; GRAPHQLINTROSPECTION_EXPORT std::vector getLocations() const; GRAPHQLINTROSPECTION_EXPORT std::vector> getArgs() const; + GRAPHQLINTROSPECTION_EXPORT bool getIsRepeatable() const; private: const std::shared_ptr _directive; diff --git a/include/graphqlservice/internal/Schema.h b/include/graphqlservice/internal/Schema.h index 4e26b694..c3912b2b 100644 --- a/include/graphqlservice/internal/Schema.h +++ b/include/graphqlservice/internal/Schema.h @@ -37,7 +37,8 @@ class EnumValue; class Schema : public std::enable_shared_from_this { public: - GRAPHQLSERVICE_EXPORT explicit Schema(bool noIntrospection = false); + GRAPHQLSERVICE_EXPORT explicit Schema( + bool noIntrospection = false, std::string_view description = ""); GRAPHQLSERVICE_EXPORT void AddQueryType(std::shared_ptr query); GRAPHQLSERVICE_EXPORT void AddMutationType(std::shared_ptr mutation); @@ -51,6 +52,7 @@ class Schema : public std::enable_shared_from_this // Accessors GRAPHQLSERVICE_EXPORT bool supportsIntrospection() const noexcept; + GRAPHQLSERVICE_EXPORT std::string_view description() const noexcept; GRAPHQLSERVICE_EXPORT const std::vector< std::pair>>& types() const noexcept; @@ -63,6 +65,7 @@ class Schema : public std::enable_shared_from_this private: const bool _noIntrospection = false; + const std::string_view _description; std::shared_ptr _query; std::shared_ptr _mutation; @@ -98,6 +101,7 @@ class BaseType : public std::enable_shared_from_this GRAPHQLSERVICE_EXPORT virtual const std::vector>& inputFields() const noexcept; GRAPHQLSERVICE_EXPORT virtual const std::weak_ptr& ofType() const noexcept; + GRAPHQLSERVICE_EXPORT virtual std::string_view specifiedByURL() const noexcept; protected: BaseType(introspection::TypeKind kind, std::string_view description); @@ -118,13 +122,15 @@ class ScalarType : public BaseType explicit ScalarType(init&& params); GRAPHQLSERVICE_EXPORT static std::shared_ptr Make( - std::string_view name, std::string_view description); + std::string_view name, std::string_view description, std::string_view specifiedByURL); // Accessors GRAPHQLSERVICE_EXPORT std::string_view name() const noexcept final; + GRAPHQLSERVICE_EXPORT std::string_view specifiedByURL() const noexcept final; private: const std::string_view _name; + const std::string_view _specifiedByURL; }; class ObjectType : public BaseType @@ -389,7 +395,7 @@ class Directive : public std::enable_shared_from_this GRAPHQLSERVICE_EXPORT static std::shared_ptr Make(std::string_view name, std::string_view description, std::vector&& locations, - std::vector>&& args = {}); + std::vector>&& args, bool isRepeatable); // Accessors GRAPHQLSERVICE_EXPORT std::string_view name() const noexcept; @@ -398,12 +404,14 @@ class Directive : public std::enable_shared_from_this const noexcept; GRAPHQLSERVICE_EXPORT const std::vector>& args() const noexcept; + GRAPHQLSERVICE_EXPORT bool isRepeatable() const noexcept; private: const std::string_view _name; const std::string_view _description; const std::vector _locations; const std::vector> _args; + const bool _isRepeatable; }; } // namespace schema diff --git a/include/graphqlservice/introspection/DirectiveObject.h b/include/graphqlservice/introspection/DirectiveObject.h index e0953288..2349fe17 100644 --- a/include/graphqlservice/introspection/DirectiveObject.h +++ b/include/graphqlservice/introspection/DirectiveObject.h @@ -20,6 +20,7 @@ class Directive service::AwaitableResolver resolveDescription(service::ResolverParams&& params) const; service::AwaitableResolver resolveLocations(service::ResolverParams&& params) const; service::AwaitableResolver resolveArgs(service::ResolverParams&& params) const; + service::AwaitableResolver resolveIsRepeatable(service::ResolverParams&& params) const; service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; @@ -31,6 +32,7 @@ class Directive virtual service::FieldResult> getDescription() const = 0; virtual service::FieldResult> getLocations() const = 0; virtual service::FieldResult>> getArgs() const = 0; + virtual service::FieldResult getIsRepeatable() const = 0; }; template @@ -62,6 +64,11 @@ class Directive return { _pimpl->getArgs() }; } + service::FieldResult getIsRepeatable() const final + { + return { _pimpl->getIsRepeatable() }; + } + private: const std::shared_ptr _pimpl; }; diff --git a/include/graphqlservice/introspection/IntrospectionSchema.h b/include/graphqlservice/introspection/IntrospectionSchema.h index a701780a..d833ce84 100644 --- a/include/graphqlservice/introspection/IntrospectionSchema.h +++ b/include/graphqlservice/introspection/IntrospectionSchema.h @@ -54,6 +54,7 @@ enum class DirectiveLocation FRAGMENT_DEFINITION, FRAGMENT_SPREAD, INLINE_FRAGMENT, + VARIABLE_DEFINITION, SCHEMA, SCALAR, OBJECT, diff --git a/include/graphqlservice/introspection/SchemaObject.h b/include/graphqlservice/introspection/SchemaObject.h index f81ab9c3..9a4b082a 100644 --- a/include/graphqlservice/introspection/SchemaObject.h +++ b/include/graphqlservice/introspection/SchemaObject.h @@ -16,6 +16,7 @@ class Schema : public service::Object { private: + service::AwaitableResolver resolveDescription(service::ResolverParams&& params) const; service::AwaitableResolver resolveTypes(service::ResolverParams&& params) const; service::AwaitableResolver resolveQueryType(service::ResolverParams&& params) const; service::AwaitableResolver resolveMutationType(service::ResolverParams&& params) const; @@ -28,6 +29,7 @@ class Schema { virtual ~Concept() = default; + virtual service::FieldResult> getDescription() const = 0; virtual service::FieldResult>> getTypes() const = 0; virtual service::FieldResult> getQueryType() const = 0; virtual service::FieldResult> getMutationType() const = 0; @@ -44,6 +46,11 @@ class Schema { } + service::FieldResult> getDescription() const final + { + return { _pimpl->getDescription() }; + } + service::FieldResult>> getTypes() const final { return { _pimpl->getTypes() }; diff --git a/include/graphqlservice/introspection/TypeObject.h b/include/graphqlservice/introspection/TypeObject.h index 87c2101e..484980e1 100644 --- a/include/graphqlservice/introspection/TypeObject.h +++ b/include/graphqlservice/introspection/TypeObject.h @@ -25,6 +25,7 @@ class Type service::AwaitableResolver resolveEnumValues(service::ResolverParams&& params) const; service::AwaitableResolver resolveInputFields(service::ResolverParams&& params) const; service::AwaitableResolver resolveOfType(service::ResolverParams&& params) const; + service::AwaitableResolver resolveSpecifiedByURL(service::ResolverParams&& params) const; service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; @@ -41,6 +42,7 @@ class Type virtual service::FieldResult>>> getEnumValues(std::optional&& includeDeprecatedArg) const = 0; virtual service::FieldResult>>> getInputFields() const = 0; virtual service::FieldResult> getOfType() const = 0; + virtual service::FieldResult> getSpecifiedByURL() const = 0; }; template @@ -97,6 +99,11 @@ class Type return { _pimpl->getOfType() }; } + service::FieldResult> getSpecifiedByURL() const final + { + return { _pimpl->getSpecifiedByURL() }; + } + private: const std::shared_ptr _pimpl; }; diff --git a/samples/learn/schema/StarWarsSchema.cpp b/samples/learn/schema/StarWarsSchema.cpp index c5186dc7..85d0e93c 100644 --- a/samples/learn/schema/StarWarsSchema.cpp +++ b/samples/learn/schema/StarWarsSchema.cpp @@ -97,15 +97,15 @@ void AddTypesToSchema(const std::shared_ptr& schema) schema->AddType(R"gql(ReviewInput)gql"sv, typeReviewInput); auto typeCharacter = schema::InterfaceType::Make(R"gql(Character)gql"sv, R"md()md"sv); schema->AddType(R"gql(Character)gql"sv, typeCharacter); - auto typeHuman = schema::ObjectType::Make(R"gql(Human)gql"sv, R"md()md"); + auto typeHuman = schema::ObjectType::Make(R"gql(Human)gql"sv, R"md()md"sv); schema->AddType(R"gql(Human)gql"sv, typeHuman); - auto typeDroid = schema::ObjectType::Make(R"gql(Droid)gql"sv, R"md()md"); + auto typeDroid = schema::ObjectType::Make(R"gql(Droid)gql"sv, R"md()md"sv); schema->AddType(R"gql(Droid)gql"sv, typeDroid); - auto typeQuery = schema::ObjectType::Make(R"gql(Query)gql"sv, R"md()md"); + auto typeQuery = schema::ObjectType::Make(R"gql(Query)gql"sv, R"md()md"sv); schema->AddType(R"gql(Query)gql"sv, typeQuery); - auto typeReview = schema::ObjectType::Make(R"gql(Review)gql"sv, R"md()md"); + auto typeReview = schema::ObjectType::Make(R"gql(Review)gql"sv, R"md()md"sv); schema->AddType(R"gql(Review)gql"sv, typeReview); - auto typeMutation = schema::ObjectType::Make(R"gql(Mutation)gql"sv, R"md()md"); + auto typeMutation = schema::ObjectType::Make(R"gql(Mutation)gql"sv, R"md()md"sv); schema->AddType(R"gql(Mutation)gql"sv, typeMutation); typeEpisode->AddEnumValues({ @@ -138,7 +138,7 @@ std::shared_ptr GetSchema() if (!schema) { - schema = std::make_shared(false); + schema = std::make_shared(false, R"md()md"sv); introspection::AddTypesToSchema(schema); AddTypesToSchema(schema); s_wpSchema = schema; diff --git a/samples/today/nointrospection/TodaySchema.cpp b/samples/today/nointrospection/TodaySchema.cpp index c767a52b..dd89e4c0 100644 --- a/samples/today/nointrospection/TodaySchema.cpp +++ b/samples/today/nointrospection/TodaySchema.cpp @@ -159,8 +159,8 @@ Operations::Operations(std::shared_ptr query, std::shared_ptr& schema) { - schema->AddType(R"gql(ItemCursor)gql"sv, schema::ScalarType::Make(R"gql(ItemCursor)gql"sv, R"md()md")); - schema->AddType(R"gql(DateTime)gql"sv, schema::ScalarType::Make(R"gql(DateTime)gql"sv, R"md()md")); + schema->AddType(R"gql(ItemCursor)gql"sv, schema::ScalarType::Make(R"gql(ItemCursor)gql"sv, R"md()md", R"url()url"sv)); + schema->AddType(R"gql(DateTime)gql"sv, schema::ScalarType::Make(R"gql(DateTime)gql"sv, R"md()md", R"url()url"sv)); auto typeTaskState = schema::EnumType::Make(R"gql(TaskState)gql"sv, R"md()md"sv); schema->AddType(R"gql(TaskState)gql"sv, typeTaskState); auto typeCompleteTaskInput = schema::InputObjectType::Make(R"gql(CompleteTaskInput)gql"sv, R"md()md"sv); @@ -177,37 +177,37 @@ void AddTypesToSchema(const std::shared_ptr& schema) schema->AddType(R"gql(Node)gql"sv, typeNode); auto typeUnionType = schema::UnionType::Make(R"gql(UnionType)gql"sv, R"md()md"sv); schema->AddType(R"gql(UnionType)gql"sv, typeUnionType); - auto typeQuery = schema::ObjectType::Make(R"gql(Query)gql"sv, R"md()md"); + auto typeQuery = schema::ObjectType::Make(R"gql(Query)gql"sv, R"md()md"sv); schema->AddType(R"gql(Query)gql"sv, typeQuery); - auto typePageInfo = schema::ObjectType::Make(R"gql(PageInfo)gql"sv, R"md()md"); + auto typePageInfo = schema::ObjectType::Make(R"gql(PageInfo)gql"sv, R"md()md"sv); schema->AddType(R"gql(PageInfo)gql"sv, typePageInfo); - auto typeAppointmentEdge = schema::ObjectType::Make(R"gql(AppointmentEdge)gql"sv, R"md()md"); + auto typeAppointmentEdge = schema::ObjectType::Make(R"gql(AppointmentEdge)gql"sv, R"md()md"sv); schema->AddType(R"gql(AppointmentEdge)gql"sv, typeAppointmentEdge); - auto typeAppointmentConnection = schema::ObjectType::Make(R"gql(AppointmentConnection)gql"sv, R"md()md"); + auto typeAppointmentConnection = schema::ObjectType::Make(R"gql(AppointmentConnection)gql"sv, R"md()md"sv); schema->AddType(R"gql(AppointmentConnection)gql"sv, typeAppointmentConnection); - auto typeTaskEdge = schema::ObjectType::Make(R"gql(TaskEdge)gql"sv, R"md()md"); + auto typeTaskEdge = schema::ObjectType::Make(R"gql(TaskEdge)gql"sv, R"md()md"sv); schema->AddType(R"gql(TaskEdge)gql"sv, typeTaskEdge); - auto typeTaskConnection = schema::ObjectType::Make(R"gql(TaskConnection)gql"sv, R"md()md"); + auto typeTaskConnection = schema::ObjectType::Make(R"gql(TaskConnection)gql"sv, R"md()md"sv); schema->AddType(R"gql(TaskConnection)gql"sv, typeTaskConnection); - auto typeFolderEdge = schema::ObjectType::Make(R"gql(FolderEdge)gql"sv, R"md()md"); + auto typeFolderEdge = schema::ObjectType::Make(R"gql(FolderEdge)gql"sv, R"md()md"sv); schema->AddType(R"gql(FolderEdge)gql"sv, typeFolderEdge); - auto typeFolderConnection = schema::ObjectType::Make(R"gql(FolderConnection)gql"sv, R"md()md"); + auto typeFolderConnection = schema::ObjectType::Make(R"gql(FolderConnection)gql"sv, R"md()md"sv); schema->AddType(R"gql(FolderConnection)gql"sv, typeFolderConnection); - auto typeCompleteTaskPayload = schema::ObjectType::Make(R"gql(CompleteTaskPayload)gql"sv, R"md()md"); + auto typeCompleteTaskPayload = schema::ObjectType::Make(R"gql(CompleteTaskPayload)gql"sv, R"md()md"sv); schema->AddType(R"gql(CompleteTaskPayload)gql"sv, typeCompleteTaskPayload); - auto typeMutation = schema::ObjectType::Make(R"gql(Mutation)gql"sv, R"md()md"); + auto typeMutation = schema::ObjectType::Make(R"gql(Mutation)gql"sv, R"md()md"sv); schema->AddType(R"gql(Mutation)gql"sv, typeMutation); - auto typeSubscription = schema::ObjectType::Make(R"gql(Subscription)gql"sv, R"md()md"); + auto typeSubscription = schema::ObjectType::Make(R"gql(Subscription)gql"sv, R"md()md"sv); schema->AddType(R"gql(Subscription)gql"sv, typeSubscription); - auto typeAppointment = schema::ObjectType::Make(R"gql(Appointment)gql"sv, R"md()md"); + auto typeAppointment = schema::ObjectType::Make(R"gql(Appointment)gql"sv, R"md()md"sv); schema->AddType(R"gql(Appointment)gql"sv, typeAppointment); - auto typeTask = schema::ObjectType::Make(R"gql(Task)gql"sv, R"md()md"); + auto typeTask = schema::ObjectType::Make(R"gql(Task)gql"sv, R"md()md"sv); schema->AddType(R"gql(Task)gql"sv, typeTask); - auto typeFolder = schema::ObjectType::Make(R"gql(Folder)gql"sv, R"md()md"); + auto typeFolder = schema::ObjectType::Make(R"gql(Folder)gql"sv, R"md()md"sv); schema->AddType(R"gql(Folder)gql"sv, typeFolder); - auto typeNestedType = schema::ObjectType::Make(R"gql(NestedType)gql"sv, R"md()md"); + auto typeNestedType = schema::ObjectType::Make(R"gql(NestedType)gql"sv, R"md()md"sv); schema->AddType(R"gql(NestedType)gql"sv, typeNestedType); - auto typeExpensive = schema::ObjectType::Make(R"gql(Expensive)gql"sv, R"md()md"); + auto typeExpensive = schema::ObjectType::Make(R"gql(Expensive)gql"sv, R"md()md"sv); schema->AddType(R"gql(Expensive)gql"sv, typeExpensive); typeTaskState->AddEnumValues({ @@ -262,37 +262,37 @@ void AddTypesToSchema(const std::shared_ptr& schema) schema->AddDirective(schema::Directive::Make(R"gql(id)gql"sv, R"md()md"sv, { introspection::DirectiveLocation::FIELD_DEFINITION - })); + }, {}, false)); schema->AddDirective(schema::Directive::Make(R"gql(subscriptionTag)gql"sv, R"md()md"sv, { introspection::DirectiveLocation::SUBSCRIPTION }, { schema::InputValue::Make(R"gql(field)gql"sv, R"md()md"sv, schema->LookupType(R"gql(String)gql"sv), R"gql()gql"sv) - })); + }, false)); schema->AddDirective(schema::Directive::Make(R"gql(queryTag)gql"sv, R"md()md"sv, { introspection::DirectiveLocation::QUERY }, { schema::InputValue::Make(R"gql(query)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(String)gql"sv)), R"gql()gql"sv) - })); + }, false)); schema->AddDirective(schema::Directive::Make(R"gql(fieldTag)gql"sv, R"md()md"sv, { introspection::DirectiveLocation::FIELD }, { schema::InputValue::Make(R"gql(field)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(String)gql"sv)), R"gql()gql"sv) - })); + }, false)); schema->AddDirective(schema::Directive::Make(R"gql(fragmentDefinitionTag)gql"sv, R"md()md"sv, { introspection::DirectiveLocation::FRAGMENT_DEFINITION }, { schema::InputValue::Make(R"gql(fragmentDefinition)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(String)gql"sv)), R"gql()gql"sv) - })); + }, false)); schema->AddDirective(schema::Directive::Make(R"gql(fragmentSpreadTag)gql"sv, R"md()md"sv, { introspection::DirectiveLocation::FRAGMENT_SPREAD }, { schema::InputValue::Make(R"gql(fragmentSpread)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(String)gql"sv)), R"gql()gql"sv) - })); + }, false)); schema->AddDirective(schema::Directive::Make(R"gql(inlineFragmentTag)gql"sv, R"md()md"sv, { introspection::DirectiveLocation::INLINE_FRAGMENT }, { schema::InputValue::Make(R"gql(inlineFragment)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(String)gql"sv)), R"gql()gql"sv) - })); + }, false)); schema->AddQueryType(typeQuery); schema->AddMutationType(typeMutation); @@ -306,7 +306,7 @@ std::shared_ptr GetSchema() if (!schema) { - schema = std::make_shared(true); + schema = std::make_shared(true, R"md()md"sv); introspection::AddTypesToSchema(schema); AddTypesToSchema(schema); s_wpSchema = schema; diff --git a/samples/today/schema/TodaySchema.cpp b/samples/today/schema/TodaySchema.cpp index 5b5cdd4c..85e7ab87 100644 --- a/samples/today/schema/TodaySchema.cpp +++ b/samples/today/schema/TodaySchema.cpp @@ -159,8 +159,8 @@ Operations::Operations(std::shared_ptr query, std::shared_ptr& schema) { - schema->AddType(R"gql(ItemCursor)gql"sv, schema::ScalarType::Make(R"gql(ItemCursor)gql"sv, R"md()md")); - schema->AddType(R"gql(DateTime)gql"sv, schema::ScalarType::Make(R"gql(DateTime)gql"sv, R"md()md")); + schema->AddType(R"gql(ItemCursor)gql"sv, schema::ScalarType::Make(R"gql(ItemCursor)gql"sv, R"md()md", R"url()url"sv)); + schema->AddType(R"gql(DateTime)gql"sv, schema::ScalarType::Make(R"gql(DateTime)gql"sv, R"md()md", R"url()url"sv)); auto typeTaskState = schema::EnumType::Make(R"gql(TaskState)gql"sv, R"md()md"sv); schema->AddType(R"gql(TaskState)gql"sv, typeTaskState); auto typeCompleteTaskInput = schema::InputObjectType::Make(R"gql(CompleteTaskInput)gql"sv, R"md()md"sv); @@ -177,37 +177,37 @@ void AddTypesToSchema(const std::shared_ptr& schema) schema->AddType(R"gql(Node)gql"sv, typeNode); auto typeUnionType = schema::UnionType::Make(R"gql(UnionType)gql"sv, R"md()md"sv); schema->AddType(R"gql(UnionType)gql"sv, typeUnionType); - auto typeQuery = schema::ObjectType::Make(R"gql(Query)gql"sv, R"md(Root Query type)md"); + auto typeQuery = schema::ObjectType::Make(R"gql(Query)gql"sv, R"md(Root Query type)md"sv); schema->AddType(R"gql(Query)gql"sv, typeQuery); - auto typePageInfo = schema::ObjectType::Make(R"gql(PageInfo)gql"sv, R"md()md"); + auto typePageInfo = schema::ObjectType::Make(R"gql(PageInfo)gql"sv, R"md()md"sv); schema->AddType(R"gql(PageInfo)gql"sv, typePageInfo); - auto typeAppointmentEdge = schema::ObjectType::Make(R"gql(AppointmentEdge)gql"sv, R"md()md"); + auto typeAppointmentEdge = schema::ObjectType::Make(R"gql(AppointmentEdge)gql"sv, R"md()md"sv); schema->AddType(R"gql(AppointmentEdge)gql"sv, typeAppointmentEdge); - auto typeAppointmentConnection = schema::ObjectType::Make(R"gql(AppointmentConnection)gql"sv, R"md()md"); + auto typeAppointmentConnection = schema::ObjectType::Make(R"gql(AppointmentConnection)gql"sv, R"md()md"sv); schema->AddType(R"gql(AppointmentConnection)gql"sv, typeAppointmentConnection); - auto typeTaskEdge = schema::ObjectType::Make(R"gql(TaskEdge)gql"sv, R"md()md"); + auto typeTaskEdge = schema::ObjectType::Make(R"gql(TaskEdge)gql"sv, R"md()md"sv); schema->AddType(R"gql(TaskEdge)gql"sv, typeTaskEdge); - auto typeTaskConnection = schema::ObjectType::Make(R"gql(TaskConnection)gql"sv, R"md()md"); + auto typeTaskConnection = schema::ObjectType::Make(R"gql(TaskConnection)gql"sv, R"md()md"sv); schema->AddType(R"gql(TaskConnection)gql"sv, typeTaskConnection); - auto typeFolderEdge = schema::ObjectType::Make(R"gql(FolderEdge)gql"sv, R"md()md"); + auto typeFolderEdge = schema::ObjectType::Make(R"gql(FolderEdge)gql"sv, R"md()md"sv); schema->AddType(R"gql(FolderEdge)gql"sv, typeFolderEdge); - auto typeFolderConnection = schema::ObjectType::Make(R"gql(FolderConnection)gql"sv, R"md()md"); + auto typeFolderConnection = schema::ObjectType::Make(R"gql(FolderConnection)gql"sv, R"md()md"sv); schema->AddType(R"gql(FolderConnection)gql"sv, typeFolderConnection); - auto typeCompleteTaskPayload = schema::ObjectType::Make(R"gql(CompleteTaskPayload)gql"sv, R"md()md"); + auto typeCompleteTaskPayload = schema::ObjectType::Make(R"gql(CompleteTaskPayload)gql"sv, R"md()md"sv); schema->AddType(R"gql(CompleteTaskPayload)gql"sv, typeCompleteTaskPayload); - auto typeMutation = schema::ObjectType::Make(R"gql(Mutation)gql"sv, R"md()md"); + auto typeMutation = schema::ObjectType::Make(R"gql(Mutation)gql"sv, R"md()md"sv); schema->AddType(R"gql(Mutation)gql"sv, typeMutation); - auto typeSubscription = schema::ObjectType::Make(R"gql(Subscription)gql"sv, R"md()md"); + auto typeSubscription = schema::ObjectType::Make(R"gql(Subscription)gql"sv, R"md()md"sv); schema->AddType(R"gql(Subscription)gql"sv, typeSubscription); - auto typeAppointment = schema::ObjectType::Make(R"gql(Appointment)gql"sv, R"md()md"); + auto typeAppointment = schema::ObjectType::Make(R"gql(Appointment)gql"sv, R"md()md"sv); schema->AddType(R"gql(Appointment)gql"sv, typeAppointment); - auto typeTask = schema::ObjectType::Make(R"gql(Task)gql"sv, R"md()md"); + auto typeTask = schema::ObjectType::Make(R"gql(Task)gql"sv, R"md()md"sv); schema->AddType(R"gql(Task)gql"sv, typeTask); - auto typeFolder = schema::ObjectType::Make(R"gql(Folder)gql"sv, R"md()md"); + auto typeFolder = schema::ObjectType::Make(R"gql(Folder)gql"sv, R"md()md"sv); schema->AddType(R"gql(Folder)gql"sv, typeFolder); - auto typeNestedType = schema::ObjectType::Make(R"gql(NestedType)gql"sv, R"md(Infinitely nestable type which can be used with nested fragments to test directive handling)md"); + auto typeNestedType = schema::ObjectType::Make(R"gql(NestedType)gql"sv, R"md(Infinitely nestable type which can be used with nested fragments to test directive handling)md"sv); schema->AddType(R"gql(NestedType)gql"sv, typeNestedType); - auto typeExpensive = schema::ObjectType::Make(R"gql(Expensive)gql"sv, R"md()md"); + auto typeExpensive = schema::ObjectType::Make(R"gql(Expensive)gql"sv, R"md()md"sv); schema->AddType(R"gql(Expensive)gql"sv, typeExpensive); typeTaskState->AddEnumValues({ @@ -262,37 +262,37 @@ void AddTypesToSchema(const std::shared_ptr& schema) schema->AddDirective(schema::Directive::Make(R"gql(id)gql"sv, R"md()md"sv, { introspection::DirectiveLocation::FIELD_DEFINITION - })); + }, {}, false)); schema->AddDirective(schema::Directive::Make(R"gql(subscriptionTag)gql"sv, R"md()md"sv, { introspection::DirectiveLocation::SUBSCRIPTION }, { schema::InputValue::Make(R"gql(field)gql"sv, R"md()md"sv, schema->LookupType(R"gql(String)gql"sv), R"gql()gql"sv) - })); + }, false)); schema->AddDirective(schema::Directive::Make(R"gql(queryTag)gql"sv, R"md()md"sv, { introspection::DirectiveLocation::QUERY }, { schema::InputValue::Make(R"gql(query)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(String)gql"sv)), R"gql()gql"sv) - })); + }, false)); schema->AddDirective(schema::Directive::Make(R"gql(fieldTag)gql"sv, R"md()md"sv, { introspection::DirectiveLocation::FIELD }, { schema::InputValue::Make(R"gql(field)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(String)gql"sv)), R"gql()gql"sv) - })); + }, false)); schema->AddDirective(schema::Directive::Make(R"gql(fragmentDefinitionTag)gql"sv, R"md()md"sv, { introspection::DirectiveLocation::FRAGMENT_DEFINITION }, { schema::InputValue::Make(R"gql(fragmentDefinition)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(String)gql"sv)), R"gql()gql"sv) - })); + }, false)); schema->AddDirective(schema::Directive::Make(R"gql(fragmentSpreadTag)gql"sv, R"md()md"sv, { introspection::DirectiveLocation::FRAGMENT_SPREAD }, { schema::InputValue::Make(R"gql(fragmentSpread)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(String)gql"sv)), R"gql()gql"sv) - })); + }, false)); schema->AddDirective(schema::Directive::Make(R"gql(inlineFragmentTag)gql"sv, R"md()md"sv, { introspection::DirectiveLocation::INLINE_FRAGMENT }, { schema::InputValue::Make(R"gql(inlineFragment)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(String)gql"sv)), R"gql()gql"sv) - })); + }, false)); schema->AddQueryType(typeQuery); schema->AddMutationType(typeMutation); @@ -306,7 +306,7 @@ std::shared_ptr GetSchema() if (!schema) { - schema = std::make_shared(false); + schema = std::make_shared(false, R"md()md"sv); introspection::AddTypesToSchema(schema); AddTypesToSchema(schema); s_wpSchema = schema; diff --git a/samples/validation/schema/ValidationSchema.cpp b/samples/validation/schema/ValidationSchema.cpp index 0a098016..7fcf0ae4 100644 --- a/samples/validation/schema/ValidationSchema.cpp +++ b/samples/validation/schema/ValidationSchema.cpp @@ -146,25 +146,25 @@ void AddTypesToSchema(const std::shared_ptr& schema) schema->AddType(R"gql(DogOrHuman)gql"sv, typeDogOrHuman); auto typeHumanOrAlien = schema::UnionType::Make(R"gql(HumanOrAlien)gql"sv, R"md()md"sv); schema->AddType(R"gql(HumanOrAlien)gql"sv, typeHumanOrAlien); - auto typeQuery = schema::ObjectType::Make(R"gql(Query)gql"sv, R"md()md"); + auto typeQuery = schema::ObjectType::Make(R"gql(Query)gql"sv, R"md()md"sv); schema->AddType(R"gql(Query)gql"sv, typeQuery); - auto typeDog = schema::ObjectType::Make(R"gql(Dog)gql"sv, R"md()md"); + auto typeDog = schema::ObjectType::Make(R"gql(Dog)gql"sv, R"md()md"sv); schema->AddType(R"gql(Dog)gql"sv, typeDog); - auto typeAlien = schema::ObjectType::Make(R"gql(Alien)gql"sv, R"md()md"); + auto typeAlien = schema::ObjectType::Make(R"gql(Alien)gql"sv, R"md()md"sv); schema->AddType(R"gql(Alien)gql"sv, typeAlien); - auto typeHuman = schema::ObjectType::Make(R"gql(Human)gql"sv, R"md()md"); + auto typeHuman = schema::ObjectType::Make(R"gql(Human)gql"sv, R"md()md"sv); schema->AddType(R"gql(Human)gql"sv, typeHuman); - auto typeCat = schema::ObjectType::Make(R"gql(Cat)gql"sv, R"md()md"); + auto typeCat = schema::ObjectType::Make(R"gql(Cat)gql"sv, R"md()md"sv); schema->AddType(R"gql(Cat)gql"sv, typeCat); - auto typeMutation = schema::ObjectType::Make(R"gql(Mutation)gql"sv, R"md()md"); + auto typeMutation = schema::ObjectType::Make(R"gql(Mutation)gql"sv, R"md()md"sv); schema->AddType(R"gql(Mutation)gql"sv, typeMutation); - auto typeMutateDogResult = schema::ObjectType::Make(R"gql(MutateDogResult)gql"sv, R"md()md"); + auto typeMutateDogResult = schema::ObjectType::Make(R"gql(MutateDogResult)gql"sv, R"md()md"sv); schema->AddType(R"gql(MutateDogResult)gql"sv, typeMutateDogResult); - auto typeSubscription = schema::ObjectType::Make(R"gql(Subscription)gql"sv, R"md()md"); + auto typeSubscription = schema::ObjectType::Make(R"gql(Subscription)gql"sv, R"md()md"sv); schema->AddType(R"gql(Subscription)gql"sv, typeSubscription); - auto typeMessage = schema::ObjectType::Make(R"gql(Message)gql"sv, R"md()md"); + auto typeMessage = schema::ObjectType::Make(R"gql(Message)gql"sv, R"md()md"sv); schema->AddType(R"gql(Message)gql"sv, typeMessage); - auto typeArguments = schema::ObjectType::Make(R"gql(Arguments)gql"sv, R"md()md"); + auto typeArguments = schema::ObjectType::Make(R"gql(Arguments)gql"sv, R"md()md"sv); schema->AddType(R"gql(Arguments)gql"sv, typeArguments); typeDogCommand->AddEnumValues({ @@ -211,7 +211,7 @@ std::shared_ptr GetSchema() if (!schema) { - schema = std::make_shared(true); + schema = std::make_shared(true, R"md()md"sv); introspection::AddTypesToSchema(schema); AddTypesToSchema(schema); s_wpSchema = schema; diff --git a/src/Introspection.cpp b/src/Introspection.cpp index 963f1a2b..23e1f273 100644 --- a/src/Introspection.cpp +++ b/src/Introspection.cpp @@ -19,6 +19,13 @@ Schema::Schema(const std::shared_ptr& schema) { } +std::optional Schema::getDescription() const +{ + const auto description = _schema->description(); + + return { description.empty() ? std::nullopt : std::make_optional(description) }; +} + std::vector> Schema::getTypes() const { const auto& types = _schema->types(); @@ -235,6 +242,13 @@ std::shared_ptr Type::getOfType() const return ofType ? std::make_shared(std::make_shared(ofType)) : nullptr; } +std::optional Type::getSpecifiedByURL() const +{ + const auto specifiedByURL = _type->specifiedByURL(); + + return { specifiedByURL.empty() ? std::nullopt : std::make_optional(specifiedByURL) }; +} + Field::Field(const std::shared_ptr& field) : _field(field) { @@ -364,7 +378,7 @@ std::optional Directive::getDescription() const std::vector Directive::getLocations() const { - return { _directive->locations() }; + return _directive->locations(); } std::vector> Directive::getArgs() const @@ -379,4 +393,9 @@ std::vector> Directive::getArgs() const return result; } +bool Directive::getIsRepeatable() const +{ + return _directive->isRepeatable(); +} + } // namespace graphql::introspection diff --git a/src/RequestLoader.cpp b/src/RequestLoader.cpp index 2db44fb7..3ef113d7 100644 --- a/src/RequestLoader.cpp +++ b/src/RequestLoader.cpp @@ -276,7 +276,9 @@ void RequestLoader::addTypesToSchema() for (const auto& scalarType : _schemaLoader.getScalarTypes()) { _schema->AddType(scalarType.type, - schema::ScalarType::Make(scalarType.type, scalarType.description)); + schema::ScalarType::Make(scalarType.type, + scalarType.description, + scalarType.specifiedByURL)); } } @@ -542,7 +544,8 @@ void RequestLoader::addTypesToSchema() _schema->AddDirective(schema::Directive::Make(directive.name, directive.description, std::move(locations), - std::move(arguments))); + std::move(arguments), + directive.isRepeatable)); } for (const auto& operationType : _schemaLoader.getOperationTypes()) diff --git a/src/Schema.cpp b/src/Schema.cpp index 4541cab4..8b4cdc40 100644 --- a/src/Schema.cpp +++ b/src/Schema.cpp @@ -9,8 +9,9 @@ using namespace std::literals; namespace graphql::schema { -Schema::Schema(bool noIntrospection) +Schema::Schema(bool noIntrospection, std::string_view description) : _noIntrospection(noIntrospection) + , _description(description) { } @@ -88,6 +89,11 @@ void Schema::AddDirective(std::shared_ptr directive) _directives.emplace_back(std::move(directive)); } +std::string_view Schema::description() const noexcept +{ + return _description; +} + const std::vector>>& Schema::types() const noexcept { @@ -171,20 +177,28 @@ const std::weak_ptr& BaseType::ofType() const noexcept return defaultValue; } +std::string_view BaseType::specifiedByURL() const noexcept +{ + return ""sv; +} + struct ScalarType::init { std::string_view name; std::string_view description; + std::string_view specifiedByURL; }; -std::shared_ptr ScalarType::Make(std::string_view name, std::string_view description) +std::shared_ptr ScalarType::Make( + std::string_view name, std::string_view description, std::string_view specifiedByURL) { - return std::make_shared(init { name, description }); + return std::make_shared(init { name, description, specifiedByURL }); } ScalarType::ScalarType(init&& params) : BaseType(introspection::TypeKind::SCALAR, params.description) , _name(params.name) + , _specifiedByURL(params.specifiedByURL) { } @@ -193,6 +207,11 @@ std::string_view ScalarType::name() const noexcept return _name; } +std::string_view ScalarType::specifiedByURL() const noexcept +{ + return _specifiedByURL; +} + struct ObjectType::init { std::string_view name; @@ -545,13 +564,14 @@ struct Directive::init std::string_view description; std::vector locations; std::vector> args; + bool isRepeatable; }; std::shared_ptr Directive::Make(std::string_view name, std::string_view description, std::vector&& locations, - std::vector>&& args) + std::vector>&& args, bool isRepeatable) { - init params { name, description, std::move(locations), std::move(args) }; + init params { name, description, std::move(locations), std::move(args), isRepeatable }; return std::make_shared(std::move(params)); } @@ -561,6 +581,7 @@ Directive::Directive(init&& params) , _description(params.description) , _locations(std::move(params.locations)) , _args(std::move(params.args)) + , _isRepeatable(params.isRepeatable) { } @@ -584,4 +605,9 @@ const std::vector>& Directive::args() const no return _args; } +bool Directive::isRepeatable() const noexcept +{ + return _isRepeatable; +} + } // namespace graphql::schema diff --git a/src/SchemaGenerator.cpp b/src/SchemaGenerator.cpp index f369a3c4..2013b5d0 100644 --- a/src/SchemaGenerator.cpp +++ b/src/SchemaGenerator.cpp @@ -1385,7 +1385,15 @@ Operations::Operations()cpp"; sourceFile << R"cpp(Built-in type)cpp"; } - sourceFile << R"cpp()md")); + sourceFile << R"cpp()md"sv, R"url()cpp"; + + if (!_options.noIntrospection) + { + sourceFile << R"cpp(https://spec.graphql.org/October2021/#sec-)cpp" + << builtinType.first; + } + + sourceFile << R"cpp()url"sv)); )cpp"; } } @@ -1403,7 +1411,14 @@ Operations::Operations()cpp"; sourceFile << scalarType.description; } - sourceFile << R"cpp()md")); + sourceFile << R"cpp()md", R"url()cpp"; + + if (!_options.noIntrospection) + { + sourceFile << scalarType.specifiedByURL; + } + + sourceFile << R"cpp()url"sv)); )cpp"; } } @@ -1504,7 +1519,7 @@ Operations::Operations()cpp"; sourceFile << objectType.description; } - sourceFile << R"cpp()md"); + sourceFile << R"cpp()md"sv); schema->AddType(R"gql()cpp" << objectType.type << R"cpp()gql"sv, type)cpp" << objectType.cppType << R"cpp(); @@ -1685,14 +1700,13 @@ Operations::Operations()cpp"; )cpp"; } - sourceFile << R"cpp(})cpp"; + sourceFile << R"cpp(}, {)cpp"; if (!directive.arguments.empty()) { bool firstArgument = true; - sourceFile << R"cpp(, { -)cpp"; + sourceFile << std::endl; for (const auto& argument : directive.arguments) { @@ -1718,9 +1732,10 @@ Operations::Operations()cpp"; } sourceFile << R"cpp( - })cpp"; + )cpp"; } - sourceFile << R"cpp()); + sourceFile << R"cpp(}, )cpp" + << (directive.isRepeatable ? R"cpp(true)cpp" : R"cpp(false)cpp") << R"cpp()); )cpp"; } } @@ -1755,7 +1770,8 @@ Operations::Operations()cpp"; if (!schema) { schema = std::make_shared()cpp" - << (_options.noIntrospection ? "true" : "false") << R"cpp(); + << (_options.noIntrospection ? R"cpp(true)cpp" : R"cpp(false)cpp") + << R"cpp(, R"md()cpp" << _loader.getSchemaDescription() << R"cpp()md"sv); )cpp" << SchemaLoader::getIntrospectionNamespace() << R"cpp(::AddTypesToSchema(schema); AddTypesToSchema(schema); diff --git a/src/SchemaLoader.cpp b/src/SchemaLoader.cpp index 3f6045e3..82ea3748 100644 --- a/src/SchemaLoader.cpp +++ b/src/SchemaLoader.cpp @@ -505,6 +505,21 @@ void SchemaLoader::visitDefinition(const peg::ast_node& definition) void SchemaLoader::visitSchemaDefinition(const peg::ast_node& schemaDefinition) { + std::string_view description; + + peg::on_first_child(schemaDefinition, + [&description](const peg::ast_node& child) { + if (!child.children.empty()) + { + description = child.children.front()->unescaped_view(); + } + }); + + if (!_schemaDescription.empty()) + { + _schemaDescription = description; + } + peg::for_each_child(schemaDefinition, [this](const peg::ast_node& child) { const auto operation(child.children.front()->string_view()); @@ -771,7 +786,7 @@ void SchemaLoader::visitEnumTypeExtension(const peg::ast_node& enumTypeExtension directiveName = name.string_view(); }); - if (directiveName == "deprecated") + if (directiveName == "deprecated"sv) { std::string_view reason; @@ -786,7 +801,7 @@ void SchemaLoader::visitEnumTypeExtension(const peg::ast_node& enumTypeExtension argumentName = name.string_view(); }); - if (argumentName == "reason") + if (argumentName == "reason"sv) { peg::on_first_child(argument, [&value](const peg::ast_node& argumentValue) { @@ -828,6 +843,65 @@ void SchemaLoader::visitScalarTypeDefinition(const peg::ast_node& scalarTypeDefi _typePositions.emplace(name, scalarTypeDefinition.begin()); _scalarNames[name] = _scalarTypes.size(); _scalarTypes.push_back({ name, description }); + + visitScalarTypeExtension(scalarTypeDefinition); +} + +void SchemaLoader::visitScalarTypeExtension(const peg::ast_node& scalarTypeExtension) +{ + std::string_view name; + + peg::on_first_child(scalarTypeExtension, [&name](const peg::ast_node& child) { + name = child.string_view(); + }); + + const auto itrType = _scalarNames.find(name); + + if (itrType != _scalarNames.cend()) + { + auto& scalarType = _scalarTypes[itrType->second]; + + peg::on_first_child(scalarTypeExtension, + [&scalarType](const peg::ast_node& directives) { + peg::for_each_child(directives, + [&scalarType](const peg::ast_node& directive) { + std::string_view directiveName; + + peg::on_first_child(directive, + [&directiveName](const peg::ast_node& name) { + directiveName = name.string_view(); + }); + + if (directiveName == "specifiedBy"sv) + { + std::string_view specifiedByURL; + + peg::on_first_child(directive, + [&specifiedByURL](const peg::ast_node& arguments) { + peg::on_first_child(arguments, + [&specifiedByURL](const peg::ast_node& argument) { + std::string_view argumentName; + + peg::on_first_child(argument, + [&argumentName](const peg::ast_node& name) { + argumentName = name.string_view(); + }); + + if (argumentName == "url"sv) + { + peg::on_first_child(argument, + [&specifiedByURL](const peg::ast_node& url) { + specifiedByURL = url.unescaped_view(); + }); + } + }); + }); + + scalarType.specifiedByURL = std::move(specifiedByURL); + } + }); + }); + } } void SchemaLoader::visitUnionTypeDefinition(const peg::ast_node& unionTypeDefinition) @@ -896,6 +970,11 @@ void SchemaLoader::visitDirectiveDefinition(const peg::ast_node& directiveDefini } }); + peg::on_first_child(directiveDefinition, + [&directive](const peg::ast_node& child) { + directive.isRepeatable = true; + }); + peg::for_each_child(directiveDefinition, [&directive](const peg::ast_node& child) { directive.locations.push_back(child.string_view()); @@ -991,7 +1070,7 @@ OutputFieldList SchemaLoader::getOutputFields(const peg::ast_node::children_t& f directiveName = name.string_view(); }); - if (directiveName == "deprecated") + if (directiveName == "deprecated"sv) { std::string_view deprecationReason; @@ -1006,7 +1085,7 @@ OutputFieldList SchemaLoader::getOutputFields(const peg::ast_node::children_t& f argumentName = name.string_view(); }); - if (argumentName == "reason") + if (argumentName == "reason"sv) { peg::on_first_child(argument, [&deprecationReason]( @@ -1097,6 +1176,11 @@ bool SchemaLoader::isIntrospection() const noexcept return _isIntrospection; } +std::string_view SchemaLoader::getSchemaDescription() const noexcept +{ + return _schemaDescription; +} + std::string_view SchemaLoader::getFilenamePrefix() const noexcept { return _schemaOptions.filenamePrefix; diff --git a/src/SyntaxTree.cpp b/src/SyntaxTree.cpp index b323f54c..98e9fa4a 100644 --- a/src/SyntaxTree.cpp +++ b/src/SyntaxTree.cpp @@ -483,6 +483,11 @@ struct schema_selector : std::true_type { }; +template <> +struct schema_selector : std::true_type +{ +}; + template <> struct schema_selector : std::true_type { diff --git a/src/introspection/DirectiveObject.cpp b/src/introspection/DirectiveObject.cpp index 91e42d95..0c58c0a0 100644 --- a/src/introspection/DirectiveObject.cpp +++ b/src/introspection/DirectiveObject.cpp @@ -45,7 +45,8 @@ service::ResolverMap Directive::getResolvers() const noexcept { R"gql(name)gql"sv, [this](service::ResolverParams&& params) { return resolveName(std::move(params)); } }, { R"gql(locations)gql"sv, [this](service::ResolverParams&& params) { return resolveLocations(std::move(params)); } }, { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, - { R"gql(description)gql"sv, [this](service::ResolverParams&& params) { return resolveDescription(std::move(params)); } } + { R"gql(description)gql"sv, [this](service::ResolverParams&& params) { return resolveDescription(std::move(params)); } }, + { R"gql(isRepeatable)gql"sv, [this](service::ResolverParams&& params) { return resolveIsRepeatable(std::move(params)); } } }; } @@ -85,6 +86,15 @@ service::AwaitableResolver Directive::resolveArgs(service::ResolverParams&& para return service::ModifiedResult::convert(std::move(result), std::move(params)); } +service::AwaitableResolver Directive::resolveIsRepeatable(service::ResolverParams&& params) const +{ + std::unique_lock resolverLock(_resolverMutex); + auto result = _pimpl->getIsRepeatable(); + resolverLock.unlock(); + + return service::ModifiedResult::convert(std::move(result), std::move(params)); +} + service::AwaitableResolver Directive::resolve_typename(service::ResolverParams&& params) const { return service::ModifiedResult::convert(std::string{ R"gql(__Directive)gql" }, std::move(params)); @@ -98,7 +108,8 @@ void AddDirectiveDetails(const std::shared_ptr& typeDirectiv schema::Field::Make(R"gql(name)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(String)gql"sv))), schema::Field::Make(R"gql(description)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(String)gql"sv)), schema::Field::Make(R"gql(locations)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(__DirectiveLocation)gql"sv))))), - schema::Field::Make(R"gql(args)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(__InputValue)gql"sv))))) + schema::Field::Make(R"gql(args)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(__InputValue)gql"sv))))), + schema::Field::Make(R"gql(isRepeatable)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Boolean)gql"sv))) }); } diff --git a/src/introspection/DirectiveObject.h b/src/introspection/DirectiveObject.h index e0953288..2349fe17 100644 --- a/src/introspection/DirectiveObject.h +++ b/src/introspection/DirectiveObject.h @@ -20,6 +20,7 @@ class Directive service::AwaitableResolver resolveDescription(service::ResolverParams&& params) const; service::AwaitableResolver resolveLocations(service::ResolverParams&& params) const; service::AwaitableResolver resolveArgs(service::ResolverParams&& params) const; + service::AwaitableResolver resolveIsRepeatable(service::ResolverParams&& params) const; service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; @@ -31,6 +32,7 @@ class Directive virtual service::FieldResult> getDescription() const = 0; virtual service::FieldResult> getLocations() const = 0; virtual service::FieldResult>> getArgs() const = 0; + virtual service::FieldResult getIsRepeatable() const = 0; }; template @@ -62,6 +64,11 @@ class Directive return { _pimpl->getArgs() }; } + service::FieldResult getIsRepeatable() const final + { + return { _pimpl->getIsRepeatable() }; + } + private: const std::shared_ptr _pimpl; }; diff --git a/src/introspection/IntrospectionSchema.cpp b/src/introspection/IntrospectionSchema.cpp index bf7cd362..1c2fbc97 100644 --- a/src/introspection/IntrospectionSchema.cpp +++ b/src/introspection/IntrospectionSchema.cpp @@ -63,7 +63,7 @@ service::AwaitableResolver ModifiedResult::convert(serv }); } -static const std::array s_namesDirectiveLocation = { +static const std::array s_namesDirectiveLocation = { R"gql(QUERY)gql"sv, R"gql(MUTATION)gql"sv, R"gql(SUBSCRIPTION)gql"sv, @@ -71,6 +71,7 @@ static const std::array s_namesDirectiveLocation = { R"gql(FRAGMENT_DEFINITION)gql"sv, R"gql(FRAGMENT_SPREAD)gql"sv, R"gql(INLINE_FRAGMENT)gql"sv, + R"gql(VARIABLE_DEFINITION)gql"sv, R"gql(SCHEMA)gql"sv, R"gql(SCALAR)gql"sv, R"gql(OBJECT)gql"sv, @@ -122,26 +123,26 @@ namespace introspection { void AddTypesToSchema(const std::shared_ptr& schema) { - schema->AddType(R"gql(Boolean)gql"sv, schema::ScalarType::Make(R"gql(Boolean)gql"sv, R"md(Built-in type)md")); - schema->AddType(R"gql(Float)gql"sv, schema::ScalarType::Make(R"gql(Float)gql"sv, R"md(Built-in type)md")); - schema->AddType(R"gql(ID)gql"sv, schema::ScalarType::Make(R"gql(ID)gql"sv, R"md(Built-in type)md")); - schema->AddType(R"gql(Int)gql"sv, schema::ScalarType::Make(R"gql(Int)gql"sv, R"md(Built-in type)md")); - schema->AddType(R"gql(String)gql"sv, schema::ScalarType::Make(R"gql(String)gql"sv, R"md(Built-in type)md")); + schema->AddType(R"gql(Boolean)gql"sv, schema::ScalarType::Make(R"gql(Boolean)gql"sv, R"md(Built-in type)md"sv, R"url(https://spec.graphql.org/October2021/#sec-Boolean)url"sv)); + schema->AddType(R"gql(Float)gql"sv, schema::ScalarType::Make(R"gql(Float)gql"sv, R"md(Built-in type)md"sv, R"url(https://spec.graphql.org/October2021/#sec-Float)url"sv)); + schema->AddType(R"gql(ID)gql"sv, schema::ScalarType::Make(R"gql(ID)gql"sv, R"md(Built-in type)md"sv, R"url(https://spec.graphql.org/October2021/#sec-ID)url"sv)); + schema->AddType(R"gql(Int)gql"sv, schema::ScalarType::Make(R"gql(Int)gql"sv, R"md(Built-in type)md"sv, R"url(https://spec.graphql.org/October2021/#sec-Int)url"sv)); + schema->AddType(R"gql(String)gql"sv, schema::ScalarType::Make(R"gql(String)gql"sv, R"md(Built-in type)md"sv, R"url(https://spec.graphql.org/October2021/#sec-String)url"sv)); auto typeTypeKind = schema::EnumType::Make(R"gql(__TypeKind)gql"sv, R"md()md"sv); schema->AddType(R"gql(__TypeKind)gql"sv, typeTypeKind); auto typeDirectiveLocation = schema::EnumType::Make(R"gql(__DirectiveLocation)gql"sv, R"md()md"sv); schema->AddType(R"gql(__DirectiveLocation)gql"sv, typeDirectiveLocation); - auto typeSchema = schema::ObjectType::Make(R"gql(__Schema)gql"sv, R"md()md"); + auto typeSchema = schema::ObjectType::Make(R"gql(__Schema)gql"sv, R"md()md"sv); schema->AddType(R"gql(__Schema)gql"sv, typeSchema); - auto typeType = schema::ObjectType::Make(R"gql(__Type)gql"sv, R"md()md"); + auto typeType = schema::ObjectType::Make(R"gql(__Type)gql"sv, R"md()md"sv); schema->AddType(R"gql(__Type)gql"sv, typeType); - auto typeField = schema::ObjectType::Make(R"gql(__Field)gql"sv, R"md()md"); + auto typeField = schema::ObjectType::Make(R"gql(__Field)gql"sv, R"md()md"sv); schema->AddType(R"gql(__Field)gql"sv, typeField); - auto typeInputValue = schema::ObjectType::Make(R"gql(__InputValue)gql"sv, R"md()md"); + auto typeInputValue = schema::ObjectType::Make(R"gql(__InputValue)gql"sv, R"md()md"sv); schema->AddType(R"gql(__InputValue)gql"sv, typeInputValue); - auto typeEnumValue = schema::ObjectType::Make(R"gql(__EnumValue)gql"sv, R"md()md"); + auto typeEnumValue = schema::ObjectType::Make(R"gql(__EnumValue)gql"sv, R"md()md"sv); schema->AddType(R"gql(__EnumValue)gql"sv, typeEnumValue); - auto typeDirective = schema::ObjectType::Make(R"gql(__Directive)gql"sv, R"md()md"); + auto typeDirective = schema::ObjectType::Make(R"gql(__Directive)gql"sv, R"md()md"sv); schema->AddType(R"gql(__Directive)gql"sv, typeDirective); typeTypeKind->AddEnumValues({ @@ -162,6 +163,7 @@ void AddTypesToSchema(const std::shared_ptr& schema) { service::s_namesDirectiveLocation[static_cast(introspection::DirectiveLocation::FRAGMENT_DEFINITION)], R"md()md"sv, std::nullopt }, { service::s_namesDirectiveLocation[static_cast(introspection::DirectiveLocation::FRAGMENT_SPREAD)], R"md()md"sv, std::nullopt }, { service::s_namesDirectiveLocation[static_cast(introspection::DirectiveLocation::INLINE_FRAGMENT)], R"md()md"sv, std::nullopt }, + { service::s_namesDirectiveLocation[static_cast(introspection::DirectiveLocation::VARIABLE_DEFINITION)], R"md()md"sv, std::nullopt }, { service::s_namesDirectiveLocation[static_cast(introspection::DirectiveLocation::SCHEMA)], R"md()md"sv, std::nullopt }, { service::s_namesDirectiveLocation[static_cast(introspection::DirectiveLocation::SCALAR)], R"md()md"sv, std::nullopt }, { service::s_namesDirectiveLocation[static_cast(introspection::DirectiveLocation::OBJECT)], R"md()md"sv, std::nullopt }, @@ -188,20 +190,25 @@ void AddTypesToSchema(const std::shared_ptr& schema) introspection::DirectiveLocation::INLINE_FRAGMENT }, { schema::InputValue::Make(R"gql(if)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Boolean)gql"sv)), R"gql()gql"sv) - })); + }, false)); schema->AddDirective(schema::Directive::Make(R"gql(include)gql"sv, R"md()md"sv, { introspection::DirectiveLocation::FIELD, introspection::DirectiveLocation::FRAGMENT_SPREAD, introspection::DirectiveLocation::INLINE_FRAGMENT }, { schema::InputValue::Make(R"gql(if)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Boolean)gql"sv)), R"gql()gql"sv) - })); + }, false)); schema->AddDirective(schema::Directive::Make(R"gql(deprecated)gql"sv, R"md()md"sv, { introspection::DirectiveLocation::FIELD_DEFINITION, introspection::DirectiveLocation::ENUM_VALUE }, { schema::InputValue::Make(R"gql(reason)gql"sv, R"md()md"sv, schema->LookupType(R"gql(String)gql"sv), R"gql("No longer supported")gql"sv) - })); + }, false)); + schema->AddDirective(schema::Directive::Make(R"gql(specifiedBy)gql"sv, R"md()md"sv, { + introspection::DirectiveLocation::SCALAR + }, { + schema::InputValue::Make(R"gql(url)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(String)gql"sv)), R"gql()gql"sv) + }, false)); } } // namespace introspection diff --git a/src/introspection/IntrospectionSchema.h b/src/introspection/IntrospectionSchema.h index a701780a..d833ce84 100644 --- a/src/introspection/IntrospectionSchema.h +++ b/src/introspection/IntrospectionSchema.h @@ -54,6 +54,7 @@ enum class DirectiveLocation FRAGMENT_DEFINITION, FRAGMENT_SPREAD, INLINE_FRAGMENT, + VARIABLE_DEFINITION, SCHEMA, SCALAR, OBJECT, diff --git a/src/introspection/SchemaObject.cpp b/src/introspection/SchemaObject.cpp index 16c857a6..d0face1e 100644 --- a/src/introspection/SchemaObject.cpp +++ b/src/introspection/SchemaObject.cpp @@ -46,11 +46,21 @@ service::ResolverMap Schema::getResolvers() const noexcept { R"gql(queryType)gql"sv, [this](service::ResolverParams&& params) { return resolveQueryType(std::move(params)); } }, { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, { R"gql(directives)gql"sv, [this](service::ResolverParams&& params) { return resolveDirectives(std::move(params)); } }, + { R"gql(description)gql"sv, [this](service::ResolverParams&& params) { return resolveDescription(std::move(params)); } }, { R"gql(mutationType)gql"sv, [this](service::ResolverParams&& params) { return resolveMutationType(std::move(params)); } }, { R"gql(subscriptionType)gql"sv, [this](service::ResolverParams&& params) { return resolveSubscriptionType(std::move(params)); } } }; } +service::AwaitableResolver Schema::resolveDescription(service::ResolverParams&& params) const +{ + std::unique_lock resolverLock(_resolverMutex); + auto result = _pimpl->getDescription(); + resolverLock.unlock(); + + return service::ModifiedResult::convert(std::move(result), std::move(params)); +} + service::AwaitableResolver Schema::resolveTypes(service::ResolverParams&& params) const { std::unique_lock resolverLock(_resolverMutex); @@ -106,6 +116,7 @@ service::AwaitableResolver Schema::resolve_typename(service::ResolverParams&& pa void AddSchemaDetails(const std::shared_ptr& typeSchema, const std::shared_ptr& schema) { typeSchema->AddFields({ + schema::Field::Make(R"gql(description)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(String)gql"sv)), schema::Field::Make(R"gql(types)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(__Type)gql"sv))))), schema::Field::Make(R"gql(queryType)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(__Type)gql"sv))), schema::Field::Make(R"gql(mutationType)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(__Type)gql"sv)), diff --git a/src/introspection/SchemaObject.h b/src/introspection/SchemaObject.h index f81ab9c3..9a4b082a 100644 --- a/src/introspection/SchemaObject.h +++ b/src/introspection/SchemaObject.h @@ -16,6 +16,7 @@ class Schema : public service::Object { private: + service::AwaitableResolver resolveDescription(service::ResolverParams&& params) const; service::AwaitableResolver resolveTypes(service::ResolverParams&& params) const; service::AwaitableResolver resolveQueryType(service::ResolverParams&& params) const; service::AwaitableResolver resolveMutationType(service::ResolverParams&& params) const; @@ -28,6 +29,7 @@ class Schema { virtual ~Concept() = default; + virtual service::FieldResult> getDescription() const = 0; virtual service::FieldResult>> getTypes() const = 0; virtual service::FieldResult> getQueryType() const = 0; virtual service::FieldResult> getMutationType() const = 0; @@ -44,6 +46,11 @@ class Schema { } + service::FieldResult> getDescription() const final + { + return { _pimpl->getDescription() }; + } + service::FieldResult>> getTypes() const final { return { _pimpl->getTypes() }; diff --git a/src/introspection/TypeObject.cpp b/src/introspection/TypeObject.cpp index aecb5d2f..08c3e625 100644 --- a/src/introspection/TypeObject.cpp +++ b/src/introspection/TypeObject.cpp @@ -53,7 +53,8 @@ service::ResolverMap Type::getResolvers() const noexcept { R"gql(interfaces)gql"sv, [this](service::ResolverParams&& params) { return resolveInterfaces(std::move(params)); } }, { R"gql(description)gql"sv, [this](service::ResolverParams&& params) { return resolveDescription(std::move(params)); } }, { R"gql(inputFields)gql"sv, [this](service::ResolverParams&& params) { return resolveInputFields(std::move(params)); } }, - { R"gql(possibleTypes)gql"sv, [this](service::ResolverParams&& params) { return resolvePossibleTypes(std::move(params)); } } + { R"gql(possibleTypes)gql"sv, [this](service::ResolverParams&& params) { return resolvePossibleTypes(std::move(params)); } }, + { R"gql(specifiedByURL)gql"sv, [this](service::ResolverParams&& params) { return resolveSpecifiedByURL(std::move(params)); } } }; } @@ -168,6 +169,15 @@ service::AwaitableResolver Type::resolveOfType(service::ResolverParams&& params) return service::ModifiedResult::convert(std::move(result), std::move(params)); } +service::AwaitableResolver Type::resolveSpecifiedByURL(service::ResolverParams&& params) const +{ + std::unique_lock resolverLock(_resolverMutex); + auto result = _pimpl->getSpecifiedByURL(); + resolverLock.unlock(); + + return service::ModifiedResult::convert(std::move(result), std::move(params)); +} + service::AwaitableResolver Type::resolve_typename(service::ResolverParams&& params) const { return service::ModifiedResult::convert(std::string{ R"gql(__Type)gql" }, std::move(params)); @@ -190,7 +200,8 @@ void AddTypeDetails(const std::shared_ptr& typeType, const s schema::InputValue::Make(R"gql(includeDeprecated)gql"sv, R"md()md"sv, schema->LookupType(R"gql(Boolean)gql"sv), R"gql(false)gql"sv) }), schema::Field::Make(R"gql(inputFields)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::LIST, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(__InputValue)gql"sv)))), - schema::Field::Make(R"gql(ofType)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(__Type)gql"sv)) + schema::Field::Make(R"gql(ofType)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(__Type)gql"sv)), + schema::Field::Make(R"gql(specifiedByURL)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(String)gql"sv)) }); } diff --git a/src/introspection/TypeObject.h b/src/introspection/TypeObject.h index 87c2101e..484980e1 100644 --- a/src/introspection/TypeObject.h +++ b/src/introspection/TypeObject.h @@ -25,6 +25,7 @@ class Type service::AwaitableResolver resolveEnumValues(service::ResolverParams&& params) const; service::AwaitableResolver resolveInputFields(service::ResolverParams&& params) const; service::AwaitableResolver resolveOfType(service::ResolverParams&& params) const; + service::AwaitableResolver resolveSpecifiedByURL(service::ResolverParams&& params) const; service::AwaitableResolver resolve_typename(service::ResolverParams&& params) const; @@ -41,6 +42,7 @@ class Type virtual service::FieldResult>>> getEnumValues(std::optional&& includeDeprecatedArg) const = 0; virtual service::FieldResult>>> getInputFields() const = 0; virtual service::FieldResult> getOfType() const = 0; + virtual service::FieldResult> getSpecifiedByURL() const = 0; }; template @@ -97,6 +99,11 @@ class Type return { _pimpl->getOfType() }; } + service::FieldResult> getSpecifiedByURL() const final + { + return { _pimpl->getSpecifiedByURL() }; + } + private: const std::shared_ptr _pimpl; }; diff --git a/src/introspection/schema.introspection.graphql b/src/introspection/schema.introspection.graphql index e5098ac2..5145f3b2 100644 --- a/src/introspection/schema.introspection.graphql +++ b/src/introspection/schema.introspection.graphql @@ -1,8 +1,9 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. -# Introspection Schema: http://spec.graphql.org/June2018/#sec-Schema-Introspection +# Introspection Schema: https://spec.graphql.org/October2021/#sec-Schema-Introspection.Schema-Introspection-Schema type __Schema { + description: String types: [__Type!]! queryType: __Type! mutationType: __Type @@ -14,24 +15,31 @@ type __Type { kind: __TypeKind! name: String description: String - - # OBJECT and INTERFACE only + # must be non-null for OBJECT and INTERFACE, otherwise null. fields(includeDeprecated: Boolean = false): [__Field!] - - # OBJECT only + # must be non-null for OBJECT and INTERFACE, otherwise null. interfaces: [__Type!] - - # INTERFACE and UNION only + # must be non-null for INTERFACE and UNION, otherwise null. possibleTypes: [__Type!] - - # ENUM only + # must be non-null for ENUM, otherwise null. enumValues(includeDeprecated: Boolean = false): [__EnumValue!] - - # INPUT_OBJECT only + # must be non-null for INPUT_OBJECT, otherwise null. inputFields: [__InputValue!] - - # NON_NULL and LIST only + # must be non-null for NON_NULL and LIST, otherwise null. ofType: __Type + # may be non-null for custom SCALAR, otherwise null. + specifiedByURL: String +} + +enum __TypeKind { + SCALAR + OBJECT + INTERFACE + UNION + ENUM + INPUT_OBJECT + LIST + NON_NULL } type __Field { @@ -57,22 +65,12 @@ type __EnumValue { deprecationReason: String } -enum __TypeKind { - SCALAR - OBJECT - INTERFACE - UNION - ENUM - INPUT_OBJECT - LIST - NON_NULL -} - type __Directive { name: String! description: String locations: [__DirectiveLocation!]! args: [__InputValue!]! + isRepeatable: Boolean! } enum __DirectiveLocation { @@ -83,6 +81,7 @@ enum __DirectiveLocation { FRAGMENT_DEFINITION FRAGMENT_SPREAD INLINE_FRAGMENT + VARIABLE_DEFINITION SCHEMA SCALAR OBJECT @@ -102,3 +101,4 @@ directive @include(if: Boolean!) on FIELD | FRAGMENT_SPREAD | INLINE_FRAGMENT directive @deprecated( reason: String = "No longer supported" ) on FIELD_DEFINITION | ENUM_VALUE +directive @specifiedBy(url: String!) on SCALAR From a377114e834e822855fb095842493a13849a7c23 Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Fri, 10 Dec 2021 00:29:22 -0800 Subject: [PATCH 082/119] Fix schema description --- samples/today/nointrospection/TodaySchema.cpp | 2 +- samples/today/schema.today.graphql | 5 +++-- samples/today/schema/TodaySchema.cpp | 6 +++--- src/SchemaGenerator.cpp | 9 ++++++++- src/SchemaLoader.cpp | 2 +- 5 files changed, 16 insertions(+), 8 deletions(-) diff --git a/samples/today/nointrospection/TodaySchema.cpp b/samples/today/nointrospection/TodaySchema.cpp index dd89e4c0..81f32ced 100644 --- a/samples/today/nointrospection/TodaySchema.cpp +++ b/samples/today/nointrospection/TodaySchema.cpp @@ -267,7 +267,7 @@ void AddTypesToSchema(const std::shared_ptr& schema) introspection::DirectiveLocation::SUBSCRIPTION }, { schema::InputValue::Make(R"gql(field)gql"sv, R"md()md"sv, schema->LookupType(R"gql(String)gql"sv), R"gql()gql"sv) - }, false)); + }, true)); schema->AddDirective(schema::Directive::Make(R"gql(queryTag)gql"sv, R"md()md"sv, { introspection::DirectiveLocation::QUERY }, { diff --git a/samples/today/schema.today.graphql b/samples/today/schema.today.graphql index 0e2bb3e8..f103776f 100644 --- a/samples/today/schema.today.graphql +++ b/samples/today/schema.today.graphql @@ -1,6 +1,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. +"Test Schema based on a dashboard showing daily appointments, tasks, and email folders with unread counts." schema { query: Query mutation: Mutation @@ -102,9 +103,9 @@ type Subscription { nodeChange(id: ID!): Node! } -directive @subscriptionTag(field: String) on SUBSCRIPTION +directive @subscriptionTag(field: String) repeatable on SUBSCRIPTION -scalar DateTime +scalar DateTime @specifiedBy(url: "https://en.wikipedia.org/wiki/ISO_8601") enum TaskState { New diff --git a/samples/today/schema/TodaySchema.cpp b/samples/today/schema/TodaySchema.cpp index 85e7ab87..81a58b48 100644 --- a/samples/today/schema/TodaySchema.cpp +++ b/samples/today/schema/TodaySchema.cpp @@ -160,7 +160,7 @@ Operations::Operations(std::shared_ptr query, std::shared_ptr& schema) { schema->AddType(R"gql(ItemCursor)gql"sv, schema::ScalarType::Make(R"gql(ItemCursor)gql"sv, R"md()md", R"url()url"sv)); - schema->AddType(R"gql(DateTime)gql"sv, schema::ScalarType::Make(R"gql(DateTime)gql"sv, R"md()md", R"url()url"sv)); + schema->AddType(R"gql(DateTime)gql"sv, schema::ScalarType::Make(R"gql(DateTime)gql"sv, R"md()md", R"url(https://en.wikipedia.org/wiki/ISO_8601)url"sv)); auto typeTaskState = schema::EnumType::Make(R"gql(TaskState)gql"sv, R"md()md"sv); schema->AddType(R"gql(TaskState)gql"sv, typeTaskState); auto typeCompleteTaskInput = schema::InputObjectType::Make(R"gql(CompleteTaskInput)gql"sv, R"md()md"sv); @@ -267,7 +267,7 @@ void AddTypesToSchema(const std::shared_ptr& schema) introspection::DirectiveLocation::SUBSCRIPTION }, { schema::InputValue::Make(R"gql(field)gql"sv, R"md()md"sv, schema->LookupType(R"gql(String)gql"sv), R"gql()gql"sv) - }, false)); + }, true)); schema->AddDirective(schema::Directive::Make(R"gql(queryTag)gql"sv, R"md()md"sv, { introspection::DirectiveLocation::QUERY }, { @@ -306,7 +306,7 @@ std::shared_ptr GetSchema() if (!schema) { - schema = std::make_shared(false, R"md()md"sv); + schema = std::make_shared(false, R"md(Test Schema based on a dashboard showing daily appointments, tasks, and email folders with unread counts.)md"sv); introspection::AddTypesToSchema(schema); AddTypesToSchema(schema); s_wpSchema = schema; diff --git a/src/SchemaGenerator.cpp b/src/SchemaGenerator.cpp index 2013b5d0..f83163a0 100644 --- a/src/SchemaGenerator.cpp +++ b/src/SchemaGenerator.cpp @@ -1771,7 +1771,14 @@ Operations::Operations()cpp"; { schema = std::make_shared()cpp" << (_options.noIntrospection ? R"cpp(true)cpp" : R"cpp(false)cpp") - << R"cpp(, R"md()cpp" << _loader.getSchemaDescription() << R"cpp()md"sv); + << R"cpp(, R"md()cpp"; + + if (!_options.noIntrospection) + { + sourceFile << _loader.getSchemaDescription(); + } + + sourceFile << R"cpp()md"sv); )cpp" << SchemaLoader::getIntrospectionNamespace() << R"cpp(::AddTypesToSchema(schema); AddTypesToSchema(schema); diff --git a/src/SchemaLoader.cpp b/src/SchemaLoader.cpp index 82ea3748..0e506e09 100644 --- a/src/SchemaLoader.cpp +++ b/src/SchemaLoader.cpp @@ -515,7 +515,7 @@ void SchemaLoader::visitSchemaDefinition(const peg::ast_node& schemaDefinition) } }); - if (!_schemaDescription.empty()) + if (_schemaDescription.empty()) { _schemaDescription = description; } From 78a8b8005504530c763309f0ebf77c42ebcdf303 Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Fri, 10 Dec 2021 00:36:22 -0800 Subject: [PATCH 083/119] Remove extra blank line from ...Schema.cpp --- samples/learn/schema/StarWarsSchema.cpp | 1 - samples/today/nointrospection/TodaySchema.cpp | 1 - samples/today/schema/TodaySchema.cpp | 1 - samples/validation/schema/ValidationSchema.cpp | 1 - src/SchemaGenerator.cpp | 6 ++---- src/introspection/IntrospectionSchema.cpp | 1 - 6 files changed, 2 insertions(+), 9 deletions(-) diff --git a/samples/learn/schema/StarWarsSchema.cpp b/samples/learn/schema/StarWarsSchema.cpp index 85d0e93c..929485d0 100644 --- a/samples/learn/schema/StarWarsSchema.cpp +++ b/samples/learn/schema/StarWarsSchema.cpp @@ -6,7 +6,6 @@ #include "QueryObject.h" #include "MutationObject.h" - #include "graphqlservice/internal/Schema.h" #include "graphqlservice/introspection/IntrospectionSchema.h" diff --git a/samples/today/nointrospection/TodaySchema.cpp b/samples/today/nointrospection/TodaySchema.cpp index 81f32ced..d5f00300 100644 --- a/samples/today/nointrospection/TodaySchema.cpp +++ b/samples/today/nointrospection/TodaySchema.cpp @@ -7,7 +7,6 @@ #include "MutationObject.h" #include "SubscriptionObject.h" - #include "graphqlservice/internal/Schema.h" #include "graphqlservice/introspection/IntrospectionSchema.h" diff --git a/samples/today/schema/TodaySchema.cpp b/samples/today/schema/TodaySchema.cpp index 81a58b48..668f3aaf 100644 --- a/samples/today/schema/TodaySchema.cpp +++ b/samples/today/schema/TodaySchema.cpp @@ -7,7 +7,6 @@ #include "MutationObject.h" #include "SubscriptionObject.h" - #include "graphqlservice/internal/Schema.h" #include "graphqlservice/introspection/IntrospectionSchema.h" diff --git a/samples/validation/schema/ValidationSchema.cpp b/samples/validation/schema/ValidationSchema.cpp index 7fcf0ae4..dc2848a2 100644 --- a/samples/validation/schema/ValidationSchema.cpp +++ b/samples/validation/schema/ValidationSchema.cpp @@ -7,7 +7,6 @@ #include "MutationObject.h" #include "SubscriptionObject.h" - #include "graphqlservice/internal/Schema.h" #include "graphqlservice/introspection/IntrospectionSchema.h" diff --git a/src/SchemaGenerator.cpp b/src/SchemaGenerator.cpp index f83163a0..9bc19e13 100644 --- a/src/SchemaGenerator.cpp +++ b/src/SchemaGenerator.cpp @@ -1098,14 +1098,12 @@ bool Generator::outputSource() const noexcept if (_loader.isIntrospection()) { - sourceFile << R"cpp( -#include "graphqlservice/internal/Introspection.h" + sourceFile << R"cpp(#include "graphqlservice/internal/Introspection.h" )cpp"; } else { - sourceFile << R"cpp( -#include "graphqlservice/internal/Schema.h" + sourceFile << R"cpp(#include "graphqlservice/internal/Schema.h" #include "graphqlservice/introspection/IntrospectionSchema.h" )cpp"; diff --git a/src/introspection/IntrospectionSchema.cpp b/src/introspection/IntrospectionSchema.cpp index 1c2fbc97..0bf9ba6b 100644 --- a/src/introspection/IntrospectionSchema.cpp +++ b/src/introspection/IntrospectionSchema.cpp @@ -3,7 +3,6 @@ // WARNING! Do not edit this file manually, your changes will be overwritten. - #include "graphqlservice/internal/Introspection.h" #include From 7c91e3a38e3ff2dafe175d5abba4cd400ff8845a Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Fri, 10 Dec 2021 09:00:35 -0800 Subject: [PATCH 084/119] Update URLs in parser error messages --- src/SyntaxTree.cpp | 108 ++++++++++++++++++++++----------------------- 1 file changed, 54 insertions(+), 54 deletions(-) diff --git a/src/SyntaxTree.cpp b/src/SyntaxTree.cpp index 98e9fa4a..f81f112e 100644 --- a/src/SyntaxTree.cpp +++ b/src/SyntaxTree.cpp @@ -578,164 +578,164 @@ const std::string ast_control::error_message = "Expected \"\" template <> const std::string ast_control::error_message = - "Expected http://spec.graphql.org/June2018/#Variable"; + "Expected https://spec.graphql.org/October2021/#Variable"; template <> const std::string ast_control::error_message = - "Expected http://spec.graphql.org/June2018/#EscapedUnicode"; + "Expected https://spec.graphql.org/October2021/#EscapedUnicode"; template <> const std::string ast_control::error_message = - "Expected http://spec.graphql.org/June2018/#EscapedCharacter"; + "Expected https://spec.graphql.org/October2021/#EscapedCharacter"; template <> const std::string ast_control::error_message = - "Expected http://spec.graphql.org/June2018/#StringCharacter"; + "Expected https://spec.graphql.org/October2021/#StringCharacter"; template <> const std::string ast_control::error_message = - "Expected http://spec.graphql.org/June2018/#BlockStringCharacter"; + "Expected https://spec.graphql.org/October2021/#BlockStringCharacter"; template <> const std::string ast_control::error_message = - "Expected http://spec.graphql.org/June2018/#FractionalPart"; + "Expected https://spec.graphql.org/October2021/#FractionalPart"; template <> const std::string ast_control::error_message = - "Expected http://spec.graphql.org/June2018/#ExponentPart"; + "Expected https://spec.graphql.org/October2021/#ExponentPart"; template <> const std::string ast_control::error_message = - "Expected http://spec.graphql.org/June2018/#Argument"; + "Expected https://spec.graphql.org/October2021/#Argument"; template <> const std::string ast_control::error_message = - "Expected http://spec.graphql.org/June2018/#Arguments"; + "Expected https://spec.graphql.org/October2021/#Arguments"; template <> const std::string ast_control::error_message = - "Expected http://spec.graphql.org/June2018/#ListValue"; + "Expected https://spec.graphql.org/October2021/#ListValue"; template <> const std::string ast_control::error_message = - "Expected http://spec.graphql.org/June2018/#ObjectField"; + "Expected https://spec.graphql.org/October2021/#ObjectField"; template <> const std::string ast_control::error_message = - "Expected http://spec.graphql.org/June2018/#ObjectValue"; + "Expected https://spec.graphql.org/October2021/#ObjectValue"; template <> const std::string ast_control::error_message = - "Expected http://spec.graphql.org/June2018/#Value"; + "Expected https://spec.graphql.org/October2021/#Value"; template <> const std::string ast_control::error_message = - "Expected http://spec.graphql.org/June2018/#DefaultValue"; + "Expected https://spec.graphql.org/October2021/#DefaultValue"; template <> const std::string ast_control::error_message = - "Expected http://spec.graphql.org/June2018/#ListType"; + "Expected https://spec.graphql.org/October2021/#ListType"; template <> const std::string ast_control::error_message = - "Expected http://spec.graphql.org/June2018/#Type"; + "Expected https://spec.graphql.org/October2021/#Type"; template <> const std::string ast_control::error_message = - "Expected http://spec.graphql.org/June2018/#VariableDefinition"; + "Expected https://spec.graphql.org/October2021/#VariableDefinition"; template <> const std::string ast_control::error_message = - "Expected http://spec.graphql.org/June2018/#VariableDefinitions"; + "Expected https://spec.graphql.org/October2021/#VariableDefinitions"; template <> const std::string ast_control::error_message = - "Expected http://spec.graphql.org/June2018/#Directive"; + "Expected https://spec.graphql.org/October2021/#Directive"; template <> const std::string ast_control::error_message = - "Expected http://spec.graphql.org/June2018/#Field"; + "Expected https://spec.graphql.org/October2021/#Field"; template <> const std::string ast_control::error_message = - "Expected http://spec.graphql.org/June2018/#TypeCondition"; + "Expected https://spec.graphql.org/October2021/#TypeCondition"; template <> const std::string ast_control::error_message = - "Expected http://spec.graphql.org/June2018/#FragmentSpread or " - "http://spec.graphql.org/June2018/#InlineFragment"; + "Expected https://spec.graphql.org/October2021/#FragmentSpread or " + "https://spec.graphql.org/October2021/#InlineFragment"; template <> const std::string ast_control::error_message = - "Expected http://spec.graphql.org/June2018/#SelectionSet"; + "Expected https://spec.graphql.org/October2021/#SelectionSet"; template <> const std::string ast_control::error_message = - "Expected http://spec.graphql.org/June2018/#OperationDefinition"; + "Expected https://spec.graphql.org/October2021/#OperationDefinition"; template <> const std::string ast_control::error_message = - "Expected http://spec.graphql.org/June2018/#FragmentDefinition"; + "Expected https://spec.graphql.org/October2021/#FragmentDefinition"; template <> const std::string ast_control::error_message = - "Expected http://spec.graphql.org/June2018/#RootOperationTypeDefinition"; + "Expected https://spec.graphql.org/October2021/#RootOperationTypeDefinition"; template <> const std::string ast_control::error_message = - "Expected http://spec.graphql.org/June2018/#SchemaDefinition"; + "Expected https://spec.graphql.org/October2021/#SchemaDefinition"; template <> const std::string ast_control::error_message = - "Expected http://spec.graphql.org/June2018/#ScalarTypeDefinition"; + "Expected https://spec.graphql.org/October2021/#ScalarTypeDefinition"; template <> const std::string ast_control::error_message = - "Expected http://spec.graphql.org/June2018/#ArgumentsDefinition"; + "Expected https://spec.graphql.org/October2021/#ArgumentsDefinition"; template <> const std::string ast_control::error_message = - "Expected http://spec.graphql.org/June2018/#FieldDefinition"; + "Expected https://spec.graphql.org/October2021/#FieldDefinition"; template <> const std::string ast_control::error_message = - "Expected http://spec.graphql.org/June2018/#FieldsDefinition"; + "Expected https://spec.graphql.org/October2021/#FieldsDefinition"; template <> const std::string ast_control::error_message = - "Expected http://spec.graphql.org/June2018/#ImplementsInterfaces"; + "Expected https://spec.graphql.org/October2021/#ImplementsInterfaces"; template <> const std::string ast_control::error_message = - "Expected http://spec.graphql.org/June2018/#ObjectTypeDefinition"; + "Expected https://spec.graphql.org/October2021/#ObjectTypeDefinition"; template <> const std::string ast_control::error_message = - "Expected http://spec.graphql.org/June2018/#InterfaceTypeDefinition"; + "Expected https://spec.graphql.org/October2021/#InterfaceTypeDefinition"; template <> const std::string ast_control::error_message = - "Expected http://spec.graphql.org/June2018/#UnionMemberTypes"; + "Expected https://spec.graphql.org/October2021/#UnionMemberTypes"; template <> const std::string ast_control::error_message = - "Expected http://spec.graphql.org/June2018/#UnionTypeDefinition"; + "Expected https://spec.graphql.org/October2021/#UnionTypeDefinition"; template <> const std::string ast_control::error_message = - "Expected http://spec.graphql.org/June2018/#EnumValueDefinition"; + "Expected https://spec.graphql.org/October2021/#EnumValueDefinition"; template <> const std::string ast_control::error_message = - "Expected http://spec.graphql.org/June2018/#EnumValuesDefinition"; + "Expected https://spec.graphql.org/October2021/#EnumValuesDefinition"; template <> const std::string ast_control::error_message = - "Expected http://spec.graphql.org/June2018/#EnumTypeDefinition"; + "Expected https://spec.graphql.org/October2021/#EnumTypeDefinition"; template <> const std::string ast_control::error_message = - "Expected http://spec.graphql.org/June2018/#InputValueDefinition"; + "Expected https://spec.graphql.org/October2021/#InputValueDefinition"; template <> const std::string ast_control::error_message = - "Expected http://spec.graphql.org/June2018/#InputFieldsDefinition"; + "Expected https://spec.graphql.org/October2021/#InputFieldsDefinition"; template <> const std::string ast_control::error_message = - "Expected http://spec.graphql.org/June2018/#InputObjectTypeDefinition"; + "Expected https://spec.graphql.org/October2021/#InputObjectTypeDefinition"; template <> const std::string ast_control::error_message = - "Expected http://spec.graphql.org/June2018/#DirectiveDefinition"; + "Expected https://spec.graphql.org/October2021/#DirectiveDefinition"; template <> const std::string ast_control::error_message = - "Expected http://spec.graphql.org/June2018/#SchemaExtension"; + "Expected https://spec.graphql.org/October2021/#SchemaExtension"; template <> const std::string ast_control::error_message = - "Expected http://spec.graphql.org/June2018/#ScalarTypeExtension"; + "Expected https://spec.graphql.org/October2021/#ScalarTypeExtension"; template <> const std::string ast_control::error_message = - "Expected http://spec.graphql.org/June2018/#ObjectTypeExtension"; + "Expected https://spec.graphql.org/October2021/#ObjectTypeExtension"; template <> const std::string ast_control::error_message = - "Expected http://spec.graphql.org/June2018/#InterfaceTypeExtension"; + "Expected https://spec.graphql.org/October2021/#InterfaceTypeExtension"; template <> const std::string ast_control::error_message = - "Expected http://spec.graphql.org/June2018/#UnionTypeExtension"; + "Expected https://spec.graphql.org/October2021/#UnionTypeExtension"; template <> const std::string ast_control::error_message = - "Expected http://spec.graphql.org/June2018/#EnumTypeExtension"; + "Expected https://spec.graphql.org/October2021/#EnumTypeExtension"; template <> const std::string ast_control::error_message = - "Expected http://spec.graphql.org/June2018/#InputObjectTypeExtension"; + "Expected https://spec.graphql.org/October2021/#InputObjectTypeExtension"; template <> const std::string ast_control::error_message = - "Expected http://spec.graphql.org/June2018/#Document"; + "Expected https://spec.graphql.org/October2021/#Document"; template <> const std::string ast_control::error_message = - "Expected executable http://spec.graphql.org/June2018/#Document"; + "Expected executable https://spec.graphql.org/October2021/#Document"; template <> const std::string ast_control::error_message = - "Expected schema type http://spec.graphql.org/June2018/#Document"; + "Expected schema type https://spec.graphql.org/October2021/#Document"; ast parseSchemaString(std::string_view input) { From 2ef4bfcb52d0892890b291605e00b014d2efc1fa Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Fri, 10 Dec 2021 09:01:08 -0800 Subject: [PATCH 085/119] Block reserved names in non-Introspection schemas --- include/SchemaLoader.h | 2 + src/SchemaLoader.cpp | 127 +++++++++++++++++++++++++++++++++-------- 2 files changed, 104 insertions(+), 25 deletions(-) diff --git a/include/SchemaLoader.h b/include/SchemaLoader.h index 0dcd53e2..94f7e44c 100644 --- a/include/SchemaLoader.h +++ b/include/SchemaLoader.h @@ -281,6 +281,8 @@ class SchemaLoader void visitObjectTypeExtension(const peg::ast_node& objectTypeExtension); void visitDirectiveDefinition(const peg::ast_node& directiveDefinition); + static void blockReservedName( + std::string_view name, std::optional position = std::nullopt); static OutputFieldList getOutputFields(const peg::ast_node::children_t& fields); static InputFieldList getInputFields(const peg::ast_node::children_t& fields); diff --git a/src/SchemaLoader.cpp b/src/SchemaLoader.cpp index 0e506e09..967d4220 100644 --- a/src/SchemaLoader.cpp +++ b/src/SchemaLoader.cpp @@ -548,8 +548,12 @@ void SchemaLoader::visitObjectTypeDefinition(const peg::ast_node& objectTypeDefi std::string_view description; peg::on_first_child(objectTypeDefinition, - [&name](const peg::ast_node& child) { + [isIntrospection = _isIntrospection, &name](const peg::ast_node& child) { name = child.string_view(); + if (!isIntrospection) + { + blockReservedName(name, child.begin()); + } }); peg::on_first_child(objectTypeDefinition, @@ -575,9 +579,14 @@ void SchemaLoader::visitObjectTypeExtension(const peg::ast_node& objectTypeExten { std::string_view name; - peg::on_first_child(objectTypeExtension, [&name](const peg::ast_node& child) { - name = child.string_view(); - }); + peg::on_first_child(objectTypeExtension, + [isIntrospection = _isIntrospection, &name](const peg::ast_node& child) { + name = child.string_view(); + if (!isIntrospection) + { + blockReservedName(name, child.begin()); + } + }); const auto itrType = _objectNames.find(name); @@ -609,8 +618,12 @@ void SchemaLoader::visitInterfaceTypeDefinition(const peg::ast_node& interfaceTy std::string_view description; peg::on_first_child(interfaceTypeDefinition, - [&name](const peg::ast_node& child) { + [isIntrospection = _isIntrospection, &name](const peg::ast_node& child) { name = child.string_view(); + if (!isIntrospection) + { + blockReservedName(name, child.begin()); + } }); peg::on_first_child(interfaceTypeDefinition, @@ -637,8 +650,12 @@ void SchemaLoader::visitInterfaceTypeExtension(const peg::ast_node& interfaceTyp std::string_view name; peg::on_first_child(interfaceTypeExtension, - [&name](const peg::ast_node& child) { + [isIntrospection = _isIntrospection, &name](const peg::ast_node& child) { name = child.string_view(); + if (!isIntrospection) + { + blockReservedName(name, child.begin()); + } }); const auto itrType = _interfaceNames.find(name); @@ -666,8 +683,12 @@ void SchemaLoader::visitInputObjectTypeDefinition(const peg::ast_node& inputObje std::string_view description; peg::on_first_child(inputObjectTypeDefinition, - [&name](const peg::ast_node& child) { + [isIntrospection = _isIntrospection, &name](const peg::ast_node& child) { name = child.string_view(); + if (!isIntrospection) + { + blockReservedName(name, child.begin()); + } }); peg::on_first_child(inputObjectTypeDefinition, @@ -694,8 +715,12 @@ void SchemaLoader::visitInputObjectTypeExtension(const peg::ast_node& inputObjec std::string_view name; peg::on_first_child(inputObjectTypeExtension, - [&name](const peg::ast_node& child) { + [isIntrospection = _isIntrospection, &name](const peg::ast_node& child) { name = child.string_view(); + if (!isIntrospection) + { + blockReservedName(name, child.begin()); + } }); const auto itrType = _inputNames.find(name); @@ -722,9 +747,14 @@ void SchemaLoader::visitEnumTypeDefinition(const peg::ast_node& enumTypeDefiniti std::string_view name; std::string_view description; - peg::on_first_child(enumTypeDefinition, [&name](const peg::ast_node& child) { - name = child.string_view(); - }); + peg::on_first_child(enumTypeDefinition, + [isIntrospection = _isIntrospection, &name](const peg::ast_node& child) { + name = child.string_view(); + if (!isIntrospection) + { + blockReservedName(name, child.begin()); + } + }); peg::on_first_child(enumTypeDefinition, [&description](const peg::ast_node& child) { @@ -749,9 +779,14 @@ void SchemaLoader::visitEnumTypeExtension(const peg::ast_node& enumTypeExtension { std::string_view name; - peg::on_first_child(enumTypeExtension, [&name](const peg::ast_node& child) { - name = child.string_view(); - }); + peg::on_first_child(enumTypeExtension, + [isIntrospection = _isIntrospection, &name](const peg::ast_node& child) { + name = child.string_view(); + if (!isIntrospection) + { + blockReservedName(name, child.begin()); + } + }); const auto itrType = _enumNames.find(name); @@ -827,8 +862,12 @@ void SchemaLoader::visitScalarTypeDefinition(const peg::ast_node& scalarTypeDefi std::string_view description; peg::on_first_child(scalarTypeDefinition, - [&name](const peg::ast_node& child) { + [isIntrospection = _isIntrospection, &name](const peg::ast_node& child) { name = child.string_view(); + if (!isIntrospection) + { + blockReservedName(name, child.begin()); + } }); peg::on_first_child(scalarTypeDefinition, @@ -851,9 +890,14 @@ void SchemaLoader::visitScalarTypeExtension(const peg::ast_node& scalarTypeExten { std::string_view name; - peg::on_first_child(scalarTypeExtension, [&name](const peg::ast_node& child) { - name = child.string_view(); - }); + peg::on_first_child(scalarTypeExtension, + [isIntrospection = _isIntrospection, &name](const peg::ast_node& child) { + name = child.string_view(); + if (!isIntrospection) + { + blockReservedName(name, child.begin()); + } + }); const auto itrType = _scalarNames.find(name); @@ -909,9 +953,14 @@ void SchemaLoader::visitUnionTypeDefinition(const peg::ast_node& unionTypeDefini std::string_view name; std::string_view description; - peg::on_first_child(unionTypeDefinition, [&name](const peg::ast_node& child) { - name = child.string_view(); - }); + peg::on_first_child(unionTypeDefinition, + [isIntrospection = _isIntrospection, &name](const peg::ast_node& child) { + name = child.string_view(); + if (!isIntrospection) + { + blockReservedName(name, child.begin()); + } + }); peg::on_first_child(unionTypeDefinition, [&description](const peg::ast_node& child) { @@ -936,9 +985,14 @@ void SchemaLoader::visitUnionTypeExtension(const peg::ast_node& unionTypeExtensi { std::string_view name; - peg::on_first_child(unionTypeExtension, [&name](const peg::ast_node& child) { - name = child.string_view(); - }); + peg::on_first_child(unionTypeExtension, + [isIntrospection = _isIntrospection, &name](const peg::ast_node& child) { + name = child.string_view(); + if (!isIntrospection) + { + blockReservedName(name, child.begin()); + } + }); const auto itrType = _unionNames.find(name); @@ -958,8 +1012,12 @@ void SchemaLoader::visitDirectiveDefinition(const peg::ast_node& directiveDefini Directive directive; peg::on_first_child(directiveDefinition, - [&directive](const peg::ast_node& child) { + [isIntrospection = _isIntrospection, &directive](const peg::ast_node& child) { directive.name = child.string_view(); + if (!isIntrospection) + { + blockReservedName(directive.name, child.begin()); + } }); peg::on_first_child(directiveDefinition, @@ -1030,6 +1088,25 @@ std::string_view SchemaLoader::getSafeCppName(std::string_view type) noexcept return (safeNames.cend() == itr) ? type : itr->second->second; } +void SchemaLoader::blockReservedName( + std::string_view name, std::optional position) +{ + // https://spec.graphql.org/October2021/#sec-Names.Reserved-Names + if (name.size() > 1 && name.substr(0, 2) == R"gql(__)gql"sv) + { + std::ostringstream error; + + error << "Names starting with __ are reserved: " << name; + + if (position) + { + error << " line: " << position->line << " column: " << position->column; + } + + throw std::runtime_error(error.str()); + } +} + OutputFieldList SchemaLoader::getOutputFields(const peg::ast_node::children_t& fields) { OutputFieldList outputFields; From 69abcf9716bc3a15fcfcc55818f6f123246d4cf4 Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Fri, 10 Dec 2021 15:37:04 -0800 Subject: [PATCH 086/119] Implement block quote whitespace normalization --- include/graphqlservice/internal/Grammar.h | 21 ++++- samples/today/schema.today.graphql | 8 ++ samples/today/schema/TodaySchema.cpp | 5 +- src/SyntaxTree.cpp | 108 +++++++++++++++++++++- 4 files changed, 138 insertions(+), 4 deletions(-) diff --git a/include/graphqlservice/internal/Grammar.h b/include/graphqlservice/internal/Grammar.h index 6076b993..e992694e 100644 --- a/include/graphqlservice/internal/Grammar.h +++ b/include/graphqlservice/internal/Grammar.h @@ -151,12 +151,29 @@ struct block_escape_sequence : seq }; struct block_quote_character - : plus, not_at, source_character> + : plus, not_at, not_at, source_character> +{ +}; + +struct block_quote_empty_line : star, space> +{ +}; + +struct block_quote_line_content + : plus> +{ +}; + +struct block_quote_line : seq +{ +}; + +struct block_quote_content_lines: opt, eol>> { }; struct block_quote_content - : seq>, must> + : seq> { }; diff --git a/samples/today/schema.today.graphql b/samples/today/schema.today.graphql index f103776f..b072b9d8 100644 --- a/samples/today/schema.today.graphql +++ b/samples/today/schema.today.graphql @@ -96,6 +96,14 @@ type Mutation { setFloat(value: Float!): Float! } + """ + + Subscription type: + + 2nd line... + 3rd line goes here! + + """ type Subscription { nextAppointmentChange : Appointment @deprecated( reason:"""Need to deprecate a [field](http://spec.graphql.org/June2018/#sec-Deprecation)""" diff --git a/samples/today/schema/TodaySchema.cpp b/samples/today/schema/TodaySchema.cpp index 668f3aaf..517bc027 100644 --- a/samples/today/schema/TodaySchema.cpp +++ b/samples/today/schema/TodaySchema.cpp @@ -196,7 +196,10 @@ void AddTypesToSchema(const std::shared_ptr& schema) schema->AddType(R"gql(CompleteTaskPayload)gql"sv, typeCompleteTaskPayload); auto typeMutation = schema::ObjectType::Make(R"gql(Mutation)gql"sv, R"md()md"sv); schema->AddType(R"gql(Mutation)gql"sv, typeMutation); - auto typeSubscription = schema::ObjectType::Make(R"gql(Subscription)gql"sv, R"md()md"sv); + auto typeSubscription = schema::ObjectType::Make(R"gql(Subscription)gql"sv, R"md(Subscription type: + +2nd line... + 3rd line goes here!)md"sv); schema->AddType(R"gql(Subscription)gql"sv, typeSubscription); auto typeAppointment = schema::ObjectType::Make(R"gql(Appointment)gql"sv, R"md()md"sv); schema->AddType(R"gql(Appointment)gql"sv, typeAppointment); diff --git a/src/SyntaxTree.cpp b/src/SyntaxTree.cpp index f81f112e..e7cad6a5 100644 --- a/src/SyntaxTree.cpp +++ b/src/SyntaxTree.cpp @@ -9,9 +9,12 @@ #include #include +#include #include #include +#include #include +#include using namespace std::literals; @@ -47,7 +50,90 @@ std::string_view ast_node::unescaped_view() const { if (!_unescaped) { - if (children.size() > 1) + if (is_type()) + { + // Trim leading and trailing empty lines + const auto isNonEmptyLine = [](const std::unique_ptr& child) noexcept { + return child->is_type(); + }; + const auto itrEndRev = std::make_reverse_iterator( + std::find_if(children.cbegin(), children.cend(), isNonEmptyLine)); + const auto itrRev = std::find_if(children.crbegin(), itrEndRev, isNonEmptyLine); + std::vector>> lines( + std::distance(itrRev, itrEndRev)); + + std::transform(itrRev, + itrEndRev, + lines.rbegin(), + [](const std::unique_ptr& child) noexcept { + return (child->is_type() && !child->children.empty() + && child->children.front()->is_type() + && child->children.back()->is_type()) + ? std::make_optional(std::make_pair(child->children.front()->string_view(), + child->children.back()->unescaped_view())) + : std::nullopt; + }); + + // Calculate the common indent + const auto commonIndent = std::accumulate(lines.cbegin(), + lines.cend(), + std::optional {}, + [](auto value, const auto& line) noexcept { + if (line) + { + const auto indent = line->first.size(); + + if (!value || indent < *value) + { + value = indent; + } + } + + return value; + }); + + const auto trimIndent = commonIndent ? *commonIndent : 0; + std::string joined; + + if (!lines.empty()) + { + joined.reserve(std::accumulate(lines.cbegin(), + lines.cend(), + size_t {}, + [trimIndent](auto value, const auto& line) noexcept { + if (line) + { + value += line->first.size() - trimIndent; + value += line->second.size(); + } + + return value; + }) + + lines.size() - 1); + + bool firstLine = true; + + for (const auto& line : lines) + { + if (!firstLine) + { + joined.append(1, '\n'); + } + + if (line) + { + joined.append(line->first.substr(trimIndent)); + joined.append(line->second); + } + + firstLine = false; + } + } + + const_cast(this)->_unescaped = + std::make_unique(std::move(joined)); + } + else if (children.size() > 1) { std::string joined; @@ -224,6 +310,26 @@ struct ast_selector : std::true_type } }; +template <> +struct ast_selector : std::true_type +{ +}; + +template <> +struct ast_selector : std::true_type +{ +}; + +template <> +struct ast_selector : std::true_type +{ +}; + +template <> +struct ast_selector : std::true_type +{ +}; + template <> struct ast_selector : std::true_type { From 970375f5cd6b51f66aa3514e64631597a23f67a8 Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Fri, 10 Dec 2021 17:54:24 -0800 Subject: [PATCH 087/119] Parse interfaces implementing interfaces --- include/SchemaGenerator.h | 2 + include/SchemaLoader.h | 1 + include/graphqlservice/internal/Grammar.h | 44 +++++++++++++++++----- include/graphqlservice/internal/Schema.h | 3 ++ src/Schema.cpp | 5 +++ src/SchemaGenerator.cpp | 16 +++++--- src/SchemaLoader.cpp | 45 ++++++++++++++++++++++- 7 files changed, 99 insertions(+), 17 deletions(-) diff --git a/include/SchemaGenerator.h b/include/SchemaGenerator.h index 00ac5b53..58ced48f 100644 --- a/include/SchemaGenerator.h +++ b/include/SchemaGenerator.h @@ -57,6 +57,8 @@ class Generator void outputObjectImplementation( std::ostream& sourceFile, const ObjectType& objectType, bool isQueryType) const; void outputObjectIntrospection(std::ostream& sourceFile, const ObjectType& objectType) const; + void outputIntrospectionInterfaces(std::ostream& sourceFile, std::string_view cppType, + const std::vector& interfaces) const; void outputIntrospectionFields( std::ostream& sourceFile, std::string_view cppType, const OutputFieldList& fields) const; std::string getArgumentDefaultValue( diff --git a/include/SchemaLoader.h b/include/SchemaLoader.h index 94f7e44c..e7d085d4 100644 --- a/include/SchemaLoader.h +++ b/include/SchemaLoader.h @@ -176,6 +176,7 @@ struct InterfaceType { std::string_view type; std::string_view cppType; + std::vector interfaces; OutputFieldList fields; std::string_view description; }; diff --git a/include/graphqlservice/internal/Grammar.h b/include/graphqlservice/internal/Grammar.h index e992694e..f1f3d619 100644 --- a/include/graphqlservice/internal/Grammar.h +++ b/include/graphqlservice/internal/Grammar.h @@ -151,7 +151,8 @@ struct block_escape_sequence : seq }; struct block_quote_character - : plus, not_at, not_at, source_character> + : plus, not_at, not_at, + source_character> { }; @@ -159,8 +160,7 @@ struct block_quote_empty_line : star, space> { }; -struct block_quote_line_content - : plus> +struct block_quote_line_content : plus> { }; @@ -168,12 +168,11 @@ struct block_quote_line : seq { }; -struct block_quote_content_lines: opt, eol>> +struct block_quote_content_lines : opt, eol>> { }; -struct block_quote_content - : seq> +struct block_quote_content : seq> { }; @@ -732,7 +731,11 @@ struct interface_type_definition_interface_name : seq, interface_n { }; -struct interface_type_definition_directives : opt, directives> +struct interface_type_definition_implements_interfaces : opt, implements_interfaces> +{ +}; + +struct interface_type_definition_directives : seq, directives> { }; @@ -742,9 +745,13 @@ struct interface_type_definition_fields_definition : seq, fields_d struct interface_type_definition_content : seq, + interface_type_definition_fields_definition>, + seq, - interface_type_definition_directives>> + interface_type_definition_implements_interfaces>> { }; @@ -1085,9 +1092,26 @@ struct interface_type_extension_start : seq, inter { }; +struct interface_type_extension_implements_interfaces : seq, implements_interfaces> +{ +}; + +struct interface_type_extension_directives : seq, directives> +{ +}; + +struct interface_type_extension_fields_definition : seq, fields_definition> +{ +}; + struct interface_type_extension_content : seq, interface_name, star, - sor>, fields_definition>, directives>> + sor, + opt, + interface_type_extension_fields_definition>, + seq, + interface_type_extension_directives>, + interface_type_extension_implements_interfaces>> { }; diff --git a/include/graphqlservice/internal/Schema.h b/include/graphqlservice/internal/Schema.h index c3912b2b..baa400ca 100644 --- a/include/graphqlservice/internal/Schema.h +++ b/include/graphqlservice/internal/Schema.h @@ -178,6 +178,8 @@ class InterfaceType : public BaseType std::string_view name, std::string_view description); GRAPHQLSERVICE_EXPORT void AddPossibleType(std::weak_ptr possibleType); + GRAPHQLSERVICE_EXPORT void AddInterfaces( + std::vector>&& interfaces); GRAPHQLSERVICE_EXPORT void AddFields(std::vector>&& fields); // Accessors @@ -190,6 +192,7 @@ class InterfaceType : public BaseType private: const std::string_view _name; + std::vector> _interfaces; std::vector> _fields; std::vector> _possibleTypes; }; diff --git a/src/Schema.cpp b/src/Schema.cpp index 8b4cdc40..198702f7 100644 --- a/src/Schema.cpp +++ b/src/Schema.cpp @@ -283,6 +283,11 @@ void InterfaceType::AddPossibleType(std::weak_ptr possibleType) _possibleTypes.push_back(possibleType); } +void InterfaceType::AddInterfaces(std::vector>&& interfaces) +{ + _interfaces = std::move(interfaces); +} + void InterfaceType::AddFields(std::vector>&& fields) { _fields = std::move(fields); diff --git a/src/SchemaGenerator.cpp b/src/SchemaGenerator.cpp index 9bc19e13..7425cb4e 100644 --- a/src/SchemaGenerator.cpp +++ b/src/SchemaGenerator.cpp @@ -1824,6 +1824,7 @@ void )cpp" << cppType void Generator::outputInterfaceIntrospection( std::ostream& sourceFile, const InterfaceType& interfaceType) const { + outputIntrospectionInterfaces(sourceFile, interfaceType.cppType, interfaceType.interfaces); outputIntrospectionFields(sourceFile, interfaceType.cppType, interfaceType.fields); } @@ -2170,14 +2171,21 @@ service::AwaitableResolver )cpp" void Generator::outputObjectIntrospection( std::ostream& sourceFile, const ObjectType& objectType) const { - if (!objectType.interfaces.empty()) + outputIntrospectionInterfaces(sourceFile, objectType.cppType, objectType.interfaces); + outputIntrospectionFields(sourceFile, objectType.cppType, objectType.fields); +} + +void Generator::outputIntrospectionInterfaces(std::ostream& sourceFile, std::string_view cppType, + const std::vector& interfaces) const +{ + if (!interfaces.empty()) { bool firstInterface = true; - sourceFile << R"cpp( type)cpp" << objectType.cppType << R"cpp(->AddInterfaces({ + sourceFile << R"cpp( type)cpp" << cppType << R"cpp(->AddInterfaces({ )cpp"; - for (const auto& interfaceName : objectType.interfaces) + for (const auto& interfaceName : interfaces) { if (!firstInterface) { @@ -2196,8 +2204,6 @@ void Generator::outputObjectIntrospection( }); )cpp"; } - - outputIntrospectionFields(sourceFile, objectType.cppType, objectType.fields); } void Generator::outputIntrospectionFields( diff --git a/src/SchemaLoader.cpp b/src/SchemaLoader.cpp index 967d4220..f276e6a2 100644 --- a/src/SchemaLoader.cpp +++ b/src/SchemaLoader.cpp @@ -609,6 +609,18 @@ void SchemaLoader::visitObjectTypeExtension(const peg::ast_node& objectTypeExten objectType.fields.push_back(std::move(field)); } }); + + if (!_isIntrospection) + { + for (const auto& field : objectType.fields) + { + blockReservedName(field.name, field.position); + for (const auto& argument : field.arguments) + { + blockReservedName(argument.name, argument.position); + } + } + } } } @@ -640,7 +652,7 @@ void SchemaLoader::visitInterfaceTypeDefinition(const peg::ast_node& interfaceTy auto cppName = getSafeCppName(name); - _interfaceTypes.push_back({ name, cppName, {}, description }); + _interfaceTypes.push_back({ name, cppName, {}, {}, description }); visitInterfaceTypeExtension(interfaceTypeDefinition); } @@ -664,6 +676,11 @@ void SchemaLoader::visitInterfaceTypeExtension(const peg::ast_node& interfaceTyp { auto& interfaceType = _interfaceTypes[itrType->second]; + peg::for_each_child(interfaceTypeExtension, + [&interfaceType](const peg::ast_node& child) { + interfaceType.interfaces.push_back(child.string_view()); + }); + peg::on_first_child(interfaceTypeExtension, [&interfaceType](const peg::ast_node& child) { auto fields = getOutputFields(child.children); @@ -674,6 +691,18 @@ void SchemaLoader::visitInterfaceTypeExtension(const peg::ast_node& interfaceTyp interfaceType.fields.push_back(std::move(field)); } }); + + if (!_isIntrospection) + { + for (const auto& field : interfaceType.fields) + { + blockReservedName(field.name, field.position); + for (const auto& argument : field.arguments) + { + blockReservedName(argument.name, argument.position); + } + } + } } } @@ -739,6 +768,14 @@ void SchemaLoader::visitInputObjectTypeExtension(const peg::ast_node& inputObjec inputType.fields.push_back(std::move(field)); } }); + + if (!_isIntrospection) + { + for (const auto& field : inputType.fields) + { + blockReservedName(field.name, field.position); + } + } } } @@ -1039,12 +1076,16 @@ void SchemaLoader::visitDirectiveDefinition(const peg::ast_node& directiveDefini }); peg::on_first_child(directiveDefinition, - [&directive](const peg::ast_node& child) { + [isIntrospection = _isIntrospection, &directive](const peg::ast_node& child) { auto fields = getInputFields(child.children); directive.arguments.reserve(directive.arguments.size() + fields.size()); for (auto& field : fields) { + if (!isIntrospection) + { + blockReservedName(field.name, field.position); + } directive.arguments.push_back(std::move(field)); } }); From 673a649bf9758e6a5ec59be22a807a7bb395d333 Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Sat, 11 Dec 2021 13:53:10 -0800 Subject: [PATCH 088/119] Validate implemented interfaces --- include/SchemaLoader.h | 5 ++ src/SchemaLoader.cpp | 199 ++++++++++++++++++++++++++++++++++++----- 2 files changed, 180 insertions(+), 24 deletions(-) diff --git a/include/SchemaLoader.h b/include/SchemaLoader.h index e7d085d4..a3f8b531 100644 --- a/include/SchemaLoader.h +++ b/include/SchemaLoader.h @@ -293,6 +293,11 @@ class SchemaLoader const std::optional& accessor); void fixupInputFieldList(InputFieldList& fields); void reorderInputTypeDependencies(); + void validateImplementedInterfaces() const; + void validateInterfaceFields(std::string_view typeName, const OutputFieldList& typeFields, + std::string_view interfaceName) const; + void validateTransitiveInterfaces( + std::string_view typeName, const std::vector& interfaces) const; static const std::string_view s_introspectionNamespace; static const BuiltinTypeMap s_builtinTypes; diff --git a/src/SchemaLoader.cpp b/src/SchemaLoader.cpp index f276e6a2..8145527b 100644 --- a/src/SchemaLoader.cpp +++ b/src/SchemaLoader.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include @@ -86,6 +87,9 @@ void SchemaLoader::validateSchema() // Handle nested input types by fully declaring the dependencies first. reorderInputTypeDependencies(); + // Validate the interface dependencies and that all of the interface fields are implemented. + validateImplementedInterfaces(); + for (auto& entry : _interfaceTypes) { fixupOutputFieldList(entry.fields, std::nullopt, std::nullopt); @@ -186,30 +190,6 @@ void SchemaLoader::validateSchema() fixupOutputFieldList(entry.fields, interfaceFields, accessor); } - // Validate the interfaces implemented by the object types. - for (const auto& entry : _objectTypes) - { - for (const auto& interfaceName : entry.interfaces) - { - if (_interfaceNames.find(interfaceName) == _interfaceNames.cend()) - { - std::ostringstream error; - auto itrPosition = _typePositions.find(entry.type); - - error << "Unknown interface: " << interfaceName - << " implemented by: " << entry.type; - - if (itrPosition != _typePositions.cend()) - { - error << " line: " << itrPosition->second.line - << " column: " << itrPosition->second.column; - } - - throw std::runtime_error(error.str()); - } - } - } - // Validate the objects that are possible types for unions and add the unions to // the list of matching types for the objects. for (const auto& entry : _unionTypes) @@ -433,6 +413,29 @@ void SchemaLoader::reorderInputTypeDependencies() } } +void SchemaLoader::validateImplementedInterfaces() const +{ + for (const auto& interfaceType : _interfaceTypes) + { + validateTransitiveInterfaces(interfaceType.type, interfaceType.interfaces); + + for (auto interfaceName : interfaceType.interfaces) + { + validateInterfaceFields(interfaceType.type, interfaceType.fields, interfaceName); + } + } + + for (const auto& objectType : _objectTypes) + { + validateTransitiveInterfaces(objectType.type, objectType.interfaces); + + for (auto interfaceName : objectType.interfaces) + { + validateInterfaceFields(objectType.type, objectType.fields, interfaceName); + } + } +} + void SchemaLoader::visitDefinition(const peg::ast_node& definition) { if (definition.is_type()) @@ -1148,6 +1151,154 @@ void SchemaLoader::blockReservedName( } } +void SchemaLoader::validateInterfaceFields(std::string_view typeName, + const OutputFieldList& typeFields, std::string_view interfaceName) const +{ + const auto itrType = _interfaceNames.find(interfaceName); + + if (itrType == _interfaceNames.cend()) + { + std::ostringstream error; + const auto itrPosition = _typePositions.find(typeName); + + error << "Unknown interface: " << interfaceName << " implemented by: " << typeName; + + if (itrPosition != _typePositions.cend()) + { + error << " line: " << itrPosition->second.line + << " column: " << itrPosition->second.column; + } + + throw std::runtime_error(error.str()); + } + + const auto& interfaceType = _interfaceTypes[itrType->second]; + std::set unimplemented; + + for (const auto& entry : interfaceType.fields) + { + unimplemented.insert(entry.name); + } + + for (const auto& entry : typeFields) + { + unimplemented.erase(entry.name); + } + + if (!unimplemented.empty()) + { + std::ostringstream error; + const auto itrPosition = _typePositions.find(typeName); + + error << "Missing interface fields type: " << typeName + << " interface: " << interfaceType.type; + + if (itrPosition != _typePositions.cend()) + { + error << " line: " << itrPosition->second.line + << " column: " << itrPosition->second.column; + } + + for (auto fieldName : unimplemented) + { + error << " field: " << fieldName; + } + + throw std::runtime_error(error.str()); + } +} + +void SchemaLoader::validateTransitiveInterfaces( + std::string_view typeName, const std::vector& interfaces) const +{ + std::set unimplemented; + + for (auto entry : interfaces) + { + const auto itrType = _interfaceNames.find(entry); + + if (itrType == _interfaceNames.cend()) + { + std::ostringstream error; + const auto itrPosition = _typePositions.find(typeName); + + error << "Unknown interface: " << entry << " implemented by: " << typeName; + + if (itrPosition != _typePositions.cend()) + { + error << " line: " << itrPosition->second.line + << " column: " << itrPosition->second.column; + } + + throw std::runtime_error(error.str()); + } + + if (typeName == entry || !unimplemented.insert(entry).second) + { + std::ostringstream error; + const auto itrPosition = _typePositions.find(typeName); + + error << "Interface cycle interface: " << entry << " implemented by: " << typeName; + + if (itrPosition != _typePositions.cend()) + { + error << " line: " << itrPosition->second.line + << " column: " << itrPosition->second.column; + } + + throw std::runtime_error(error.str()); + } + + const auto& interfaceType = _interfaceTypes[itrType->second]; + + for (auto interfaceName : interfaceType.interfaces) + { + if (!unimplemented.insert(interfaceName).second) + { + std::ostringstream error; + const auto itrPosition = _typePositions.find(typeName); + + error << "Interface cycle interface: " << interfaceName + << " implemented by: " << typeName; + + if (itrPosition != _typePositions.cend()) + { + error << " line: " << itrPosition->second.line + << " column: " << itrPosition->second.column; + } + + throw std::runtime_error(error.str()); + } + } + } + + for (auto entry : interfaces) + { + unimplemented.erase(entry); + } + + if (!unimplemented.empty()) + { + std::ostringstream error; + const auto itrPosition = _typePositions.find(typeName); + + error << "Missing transitive interface type: " << typeName; + + if (itrPosition != _typePositions.cend()) + { + error << " line: " << itrPosition->second.line + << " column: " << itrPosition->second.column; + } + + for (auto interfaceName : unimplemented) + { + error << " interface: " << interfaceName; + } + + throw std::runtime_error(error.str()); + } +} + OutputFieldList SchemaLoader::getOutputFields(const peg::ast_node::children_t& fields) { OutputFieldList outputFields; From 9d14621240f92dd05403e9e2cc75e4cd74d47fc0 Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Sat, 11 Dec 2021 15:18:05 -0800 Subject: [PATCH 089/119] Interface validation fixes --- include/SchemaLoader.h | 6 ++-- src/SchemaLoader.cpp | 79 +++++++++++++++--------------------------- 2 files changed, 31 insertions(+), 54 deletions(-) diff --git a/include/SchemaLoader.h b/include/SchemaLoader.h index a3f8b531..1cae7d2d 100644 --- a/include/SchemaLoader.h +++ b/include/SchemaLoader.h @@ -294,8 +294,10 @@ class SchemaLoader void fixupInputFieldList(InputFieldList& fields); void reorderInputTypeDependencies(); void validateImplementedInterfaces() const; - void validateInterfaceFields(std::string_view typeName, const OutputFieldList& typeFields, - std::string_view interfaceName) const; + const InterfaceType& findInterfaceType( + std::string_view typeName, std::string_view interfaceName) const; + void validateInterfaceFields(std::string_view typeName, + std::string_view interfaceName, const OutputFieldList& typeFields) const; void validateTransitiveInterfaces( std::string_view typeName, const std::vector& interfaces) const; diff --git a/src/SchemaLoader.cpp b/src/SchemaLoader.cpp index 8145527b..58453949 100644 --- a/src/SchemaLoader.cpp +++ b/src/SchemaLoader.cpp @@ -421,7 +421,7 @@ void SchemaLoader::validateImplementedInterfaces() const for (auto interfaceName : interfaceType.interfaces) { - validateInterfaceFields(interfaceType.type, interfaceType.fields, interfaceName); + validateInterfaceFields(interfaceType.type, interfaceName, interfaceType.fields); } } @@ -431,7 +431,7 @@ void SchemaLoader::validateImplementedInterfaces() const for (auto interfaceName : objectType.interfaces) { - validateInterfaceFields(objectType.type, objectType.fields, interfaceName); + validateInterfaceFields(objectType.type, interfaceName, objectType.fields); } } } @@ -1151,8 +1151,8 @@ void SchemaLoader::blockReservedName( } } -void SchemaLoader::validateInterfaceFields(std::string_view typeName, - const OutputFieldList& typeFields, std::string_view interfaceName) const +const InterfaceType& SchemaLoader::findInterfaceType( + std::string_view typeName, std::string_view interfaceName) const { const auto itrType = _interfaceNames.find(interfaceName); @@ -1172,7 +1172,13 @@ void SchemaLoader::validateInterfaceFields(std::string_view typeName, throw std::runtime_error(error.str()); } - const auto& interfaceType = _interfaceTypes[itrType->second]; + return _interfaceTypes[itrType->second]; +} + +void SchemaLoader::validateInterfaceFields(std::string_view typeName, + std::string_view interfaceName, const OutputFieldList& typeFields) const +{ + const auto& interfaceType = findInterfaceType(typeName, interfaceName); std::set unimplemented; for (const auto& entry : interfaceType.fields) @@ -1215,61 +1221,30 @@ void SchemaLoader::validateTransitiveInterfaces( for (auto entry : interfaces) { - const auto itrType = _interfaceNames.find(entry); - - if (itrType == _interfaceNames.cend()) - { - std::ostringstream error; - const auto itrPosition = _typePositions.find(typeName); - - error << "Unknown interface: " << entry << " implemented by: " << typeName; - - if (itrPosition != _typePositions.cend()) - { - error << " line: " << itrPosition->second.line - << " column: " << itrPosition->second.column; - } + const auto& interfaceType = findInterfaceType(typeName, entry); - throw std::runtime_error(error.str()); - } - - if (typeName == entry || !unimplemented.insert(entry).second) - { - std::ostringstream error; - const auto itrPosition = _typePositions.find(typeName); - - error << "Interface cycle interface: " << entry << " implemented by: " << typeName; - - if (itrPosition != _typePositions.cend()) - { - error << " line: " << itrPosition->second.line - << " column: " << itrPosition->second.column; - } - - throw std::runtime_error(error.str()); - } - - const auto& interfaceType = _interfaceTypes[itrType->second]; + unimplemented.insert(entry); for (auto interfaceName : interfaceType.interfaces) { - if (!unimplemented.insert(interfaceName).second) - { - std::ostringstream error; - const auto itrPosition = _typePositions.find(typeName); + unimplemented.insert(interfaceName); + } + } - error << "Interface cycle interface: " << interfaceName - << " implemented by: " << typeName; + if (unimplemented.find(typeName) != unimplemented.cend()) + { + std::ostringstream error; + const auto itrPosition = _typePositions.find(typeName); - if (itrPosition != _typePositions.cend()) - { - error << " line: " << itrPosition->second.line - << " column: " << itrPosition->second.column; - } + error << "Interface cycle interface: " << typeName; - throw std::runtime_error(error.str()); - } + if (itrPosition != _typePositions.cend()) + { + error << " line: " << itrPosition->second.line + << " column: " << itrPosition->second.column; } + + throw std::runtime_error(error.str()); } for (auto entry : interfaces) From d4a91a2cf69eb40a0a329fe02bb1263d8ebac15e Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Sat, 11 Dec 2021 23:27:42 -0800 Subject: [PATCH 090/119] Update Validation tests and schema to latest GraphQL spec --- samples/validation/schema/NodeObject.cpp | 42 ++ samples/validation/schema/NodeObject.h | 81 ++++ samples/validation/schema/QueryObject.cpp | 13 + samples/validation/schema/QueryObject.h | 30 ++ samples/validation/schema/ResourceObject.cpp | 46 +++ samples/validation/schema/ResourceObject.h | 81 ++++ .../validation/schema/ValidationSchema.cpp | 6 + samples/validation/schema/ValidationSchema.h | 4 + .../schema/schema.validation.graphql | 56 +-- .../validation/schema/validation_schema_files | 2 + test/ValidationTests.cpp | 366 +++++++++--------- 11 files changed, 531 insertions(+), 196 deletions(-) create mode 100644 samples/validation/schema/NodeObject.cpp create mode 100644 samples/validation/schema/NodeObject.h create mode 100644 samples/validation/schema/ResourceObject.cpp create mode 100644 samples/validation/schema/ResourceObject.h diff --git a/samples/validation/schema/NodeObject.cpp b/samples/validation/schema/NodeObject.cpp new file mode 100644 index 00000000..3db93efb --- /dev/null +++ b/samples/validation/schema/NodeObject.cpp @@ -0,0 +1,42 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// WARNING! Do not edit this file manually, your changes will be overwritten. + +#include "NodeObject.h" + +#include "graphqlservice/internal/Schema.h" + +#include "graphqlservice/introspection/IntrospectionSchema.h" + +using namespace std::literals; + +namespace graphql::validation { +namespace object { + +Node::Node(std::unique_ptr&& pimpl) noexcept + : service::Object { pimpl->getTypeNames(), pimpl->getResolvers() } + , _pimpl { std::move(pimpl) } +{ +} + +void Node::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void Node::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} + +} // namespace object + +void AddNodeDetails(const std::shared_ptr& typeNode, const std::shared_ptr& schema) +{ + typeNode->AddFields({ + schema::Field::Make(R"gql(id)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ID)gql"sv))) + }); +} + +} // namespace graphql::validation diff --git a/samples/validation/schema/NodeObject.h b/samples/validation/schema/NodeObject.h new file mode 100644 index 00000000..3075e854 --- /dev/null +++ b/samples/validation/schema/NodeObject.h @@ -0,0 +1,81 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// WARNING! Do not edit this file manually, your changes will be overwritten. + +#pragma once + +#ifndef NODEOBJECT_H +#define NODEOBJECT_H + +#include "ValidationSchema.h" + +namespace graphql::validation::object { + +class Node + : public service::Object +{ +private: + struct Concept + { + virtual ~Concept() = default; + + virtual service::TypeNames getTypeNames() const noexcept = 0; + virtual service::ResolverMap getResolvers() const noexcept = 0; + + virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::TypeNames getTypeNames() const noexcept final + { + return _pimpl->getTypeNames(); + } + + service::ResolverMap getResolvers() const noexcept final + { + return _pimpl->getResolvers(); + } + + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + _pimpl->beginSelectionSet(params); + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + _pimpl->endSelectionSet(params); + } + + private: + const std::shared_ptr _pimpl; + }; + + Node(std::unique_ptr&& pimpl) noexcept; + + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; + + const std::unique_ptr _pimpl; + +public: + template + Node(std::shared_ptr pimpl) noexcept + : Node { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } + { + static_assert(T::template implements(), "Node is not implemented"); + } +}; + +} // namespace graphql::validation::object + +#endif // NODEOBJECT_H diff --git a/samples/validation/schema/QueryObject.cpp b/samples/validation/schema/QueryObject.cpp index 31098673..80f0caa2 100644 --- a/samples/validation/schema/QueryObject.cpp +++ b/samples/validation/schema/QueryObject.cpp @@ -9,6 +9,7 @@ #include "PetObject.h" #include "CatOrDogObject.h" #include "ArgumentsObject.h" +#include "ResourceObject.h" #include "graphqlservice/internal/Schema.h" @@ -46,6 +47,7 @@ service::ResolverMap Query::getResolvers() const noexcept { R"gql(human)gql"sv, [this](service::ResolverParams&& params) { return resolveHuman(std::move(params)); } }, { R"gql(findDog)gql"sv, [this](service::ResolverParams&& params) { return resolveFindDog(std::move(params)); } }, { R"gql(catOrDog)gql"sv, [this](service::ResolverParams&& params) { return resolveCatOrDog(std::move(params)); } }, + { R"gql(resource)gql"sv, [this](service::ResolverParams&& params) { return resolveResource(std::move(params)); } }, { R"gql(arguments)gql"sv, [this](service::ResolverParams&& params) { return resolveArguments(std::move(params)); } }, { R"gql(__typename)gql"sv, [this](service::ResolverParams&& params) { return resolve_typename(std::move(params)); } }, { R"gql(booleanList)gql"sv, [this](service::ResolverParams&& params) { return resolveBooleanList(std::move(params)); } } @@ -112,6 +114,16 @@ service::AwaitableResolver Query::resolveArguments(service::ResolverParams&& par return service::ModifiedResult::convert(std::move(result), std::move(params)); } +service::AwaitableResolver Query::resolveResource(service::ResolverParams&& params) const +{ + std::unique_lock resolverLock(_resolverMutex); + auto directives = std::move(params.fieldDirectives); + auto result = _pimpl->getResource(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + resolverLock.unlock(); + + return service::ModifiedResult::convert(std::move(result), std::move(params)); +} + service::AwaitableResolver Query::resolveFindDog(service::ResolverParams&& params) const { auto argComplex = service::ModifiedArgument::require("complex", params.arguments); @@ -149,6 +161,7 @@ void AddQueryDetails(const std::shared_ptr& typeQuery, const schema::Field::Make(R"gql(pet)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(Pet)gql"sv)), schema::Field::Make(R"gql(catOrDog)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(CatOrDog)gql"sv)), schema::Field::Make(R"gql(arguments)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(Arguments)gql"sv)), + schema::Field::Make(R"gql(resource)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(Resource)gql"sv)), schema::Field::Make(R"gql(findDog)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(Dog)gql"sv), { schema::InputValue::Make(R"gql(complex)gql"sv, R"md()md"sv, schema->LookupType(R"gql(ComplexInput)gql"sv), R"gql()gql"sv) }), diff --git a/samples/validation/schema/QueryObject.h b/samples/validation/schema/QueryObject.h index d405aff7..c5d971a3 100644 --- a/samples/validation/schema/QueryObject.h +++ b/samples/validation/schema/QueryObject.h @@ -73,6 +73,18 @@ concept getArguments = requires (TImpl impl) { service::FieldResult> { impl.getArguments() } }; }; +template +concept getResourceWithParams = requires (TImpl impl, service::FieldParams params) +{ + { service::FieldResult> { impl.getResource(std::move(params)) } }; +}; + +template +concept getResource = requires (TImpl impl) +{ + { service::FieldResult> { impl.getResource() } }; +}; + template concept getFindDogWithParams = requires (TImpl impl, service::FieldParams params, std::optional complexArg) { @@ -120,6 +132,7 @@ class Query service::AwaitableResolver resolvePet(service::ResolverParams&& params) const; service::AwaitableResolver resolveCatOrDog(service::ResolverParams&& params) const; service::AwaitableResolver resolveArguments(service::ResolverParams&& params) const; + service::AwaitableResolver resolveResource(service::ResolverParams&& params) const; service::AwaitableResolver resolveFindDog(service::ResolverParams&& params) const; service::AwaitableResolver resolveBooleanList(service::ResolverParams&& params) const; @@ -137,6 +150,7 @@ class Query virtual service::FieldResult> getPet(service::FieldParams&& params) const = 0; virtual service::FieldResult> getCatOrDog(service::FieldParams&& params) const = 0; virtual service::FieldResult> getArguments(service::FieldParams&& params) const = 0; + virtual service::FieldResult> getResource(service::FieldParams&& params) const = 0; virtual service::FieldResult> getFindDog(service::FieldParams&& params, std::optional&& complexArg) const = 0; virtual service::FieldResult> getBooleanList(service::FieldParams&& params, std::optional>&& booleanListArgArg) const = 0; }; @@ -230,6 +244,22 @@ class Query } } + service::FieldResult> getResource(service::FieldParams&& params) const final + { + if constexpr (methods::QueryHas::getResourceWithParams) + { + return { _pimpl->getResource(std::move(params)) }; + } + else if constexpr (methods::QueryHas::getResource) + { + return { _pimpl->getResource() }; + } + else + { + throw std::runtime_error(R"ex(Query::getResource is not implemented)ex"); + } + } + service::FieldResult> getFindDog(service::FieldParams&& params, std::optional&& complexArg) const final { if constexpr (methods::QueryHas::getFindDogWithParams) diff --git a/samples/validation/schema/ResourceObject.cpp b/samples/validation/schema/ResourceObject.cpp new file mode 100644 index 00000000..4bea15ce --- /dev/null +++ b/samples/validation/schema/ResourceObject.cpp @@ -0,0 +1,46 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// WARNING! Do not edit this file manually, your changes will be overwritten. + +#include "ResourceObject.h" + +#include "graphqlservice/internal/Schema.h" + +#include "graphqlservice/introspection/IntrospectionSchema.h" + +using namespace std::literals; + +namespace graphql::validation { +namespace object { + +Resource::Resource(std::unique_ptr&& pimpl) noexcept + : service::Object { pimpl->getTypeNames(), pimpl->getResolvers() } + , _pimpl { std::move(pimpl) } +{ +} + +void Resource::beginSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->beginSelectionSet(params); +} + +void Resource::endSelectionSet(const service::SelectionSetParams& params) const +{ + _pimpl->endSelectionSet(params); +} + +} // namespace object + +void AddResourceDetails(const std::shared_ptr& typeResource, const std::shared_ptr& schema) +{ + typeResource->AddInterfaces({ + std::static_pointer_cast(schema->LookupType(R"gql(Node)gql"sv)) + }); + typeResource->AddFields({ + schema::Field::Make(R"gql(id)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ID)gql"sv))), + schema::Field::Make(R"gql(url)gql"sv, R"md()md"sv, std::nullopt, schema->LookupType(R"gql(String)gql"sv)) + }); +} + +} // namespace graphql::validation diff --git a/samples/validation/schema/ResourceObject.h b/samples/validation/schema/ResourceObject.h new file mode 100644 index 00000000..1fa71284 --- /dev/null +++ b/samples/validation/schema/ResourceObject.h @@ -0,0 +1,81 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// WARNING! Do not edit this file manually, your changes will be overwritten. + +#pragma once + +#ifndef RESOURCEOBJECT_H +#define RESOURCEOBJECT_H + +#include "ValidationSchema.h" + +namespace graphql::validation::object { + +class Resource + : public service::Object +{ +private: + struct Concept + { + virtual ~Concept() = default; + + virtual service::TypeNames getTypeNames() const noexcept = 0; + virtual service::ResolverMap getResolvers() const noexcept = 0; + + virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; + virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; + }; + + template + struct Model + : Concept + { + Model(std::shared_ptr&& pimpl) noexcept + : _pimpl { std::move(pimpl) } + { + } + + service::TypeNames getTypeNames() const noexcept final + { + return _pimpl->getTypeNames(); + } + + service::ResolverMap getResolvers() const noexcept final + { + return _pimpl->getResolvers(); + } + + void beginSelectionSet(const service::SelectionSetParams& params) const final + { + _pimpl->beginSelectionSet(params); + } + + void endSelectionSet(const service::SelectionSetParams& params) const final + { + _pimpl->endSelectionSet(params); + } + + private: + const std::shared_ptr _pimpl; + }; + + Resource(std::unique_ptr&& pimpl) noexcept; + + void beginSelectionSet(const service::SelectionSetParams& params) const final; + void endSelectionSet(const service::SelectionSetParams& params) const final; + + const std::unique_ptr _pimpl; + +public: + template + Resource(std::shared_ptr pimpl) noexcept + : Resource { std::unique_ptr { std::make_unique>(std::move(pimpl)) } } + { + static_assert(T::template implements(), "Resource is not implemented"); + } +}; + +} // namespace graphql::validation::object + +#endif // RESOURCEOBJECT_H diff --git a/samples/validation/schema/ValidationSchema.cpp b/samples/validation/schema/ValidationSchema.cpp index dc2848a2..c06e4f27 100644 --- a/samples/validation/schema/ValidationSchema.cpp +++ b/samples/validation/schema/ValidationSchema.cpp @@ -139,6 +139,10 @@ void AddTypesToSchema(const std::shared_ptr& schema) schema->AddType(R"gql(Sentient)gql"sv, typeSentient); auto typePet = schema::InterfaceType::Make(R"gql(Pet)gql"sv, R"md()md"sv); schema->AddType(R"gql(Pet)gql"sv, typePet); + auto typeNode = schema::InterfaceType::Make(R"gql(Node)gql"sv, R"md()md"sv); + schema->AddType(R"gql(Node)gql"sv, typeNode); + auto typeResource = schema::InterfaceType::Make(R"gql(Resource)gql"sv, R"md()md"sv); + schema->AddType(R"gql(Resource)gql"sv, typeResource); auto typeCatOrDog = schema::UnionType::Make(R"gql(CatOrDog)gql"sv, R"md()md"sv); schema->AddType(R"gql(CatOrDog)gql"sv, typeCatOrDog); auto typeDogOrHuman = schema::UnionType::Make(R"gql(DogOrHuman)gql"sv, R"md()md"sv); @@ -182,6 +186,8 @@ void AddTypesToSchema(const std::shared_ptr& schema) AddSentientDetails(typeSentient, schema); AddPetDetails(typePet, schema); + AddNodeDetails(typeNode, schema); + AddResourceDetails(typeResource, schema); AddCatOrDogDetails(typeCatOrDog, schema); AddDogOrHumanDetails(typeDogOrHuman, schema); diff --git a/samples/validation/schema/ValidationSchema.h b/samples/validation/schema/ValidationSchema.h index 13375dc6..98d554ce 100644 --- a/samples/validation/schema/ValidationSchema.h +++ b/samples/validation/schema/ValidationSchema.h @@ -43,6 +43,8 @@ namespace object { class Sentient; class Pet; +class Node; +class Resource; class CatOrDog; class DogOrHuman; @@ -81,6 +83,8 @@ class Operations void AddSentientDetails(const std::shared_ptr& typeSentient, const std::shared_ptr& schema); void AddPetDetails(const std::shared_ptr& typePet, const std::shared_ptr& schema); +void AddNodeDetails(const std::shared_ptr& typeNode, const std::shared_ptr& schema); +void AddResourceDetails(const std::shared_ptr& typeResource, const std::shared_ptr& schema); void AddCatOrDogDetails(const std::shared_ptr& typeCatOrDog, const std::shared_ptr& schema); void AddDogOrHumanDetails(const std::shared_ptr& typeDogOrHuman, const std::shared_ptr& schema); diff --git a/samples/validation/schema/schema.validation.graphql b/samples/validation/schema/schema.validation.graphql index fe3b58ab..c12aa606 100644 --- a/samples/validation/schema/schema.validation.graphql +++ b/samples/validation/schema/schema.validation.graphql @@ -1,7 +1,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. -"GraphQL validation [sample](http://spec.graphql.org/June2018/#example-26a9d)" +"GraphQL validation [sample](http://spec.graphql.org/October2021/#example-19f2a)" type Query { dog: Dog } @@ -32,6 +32,7 @@ type Alien implements Sentient { type Human implements Sentient { name: String! + pets: [Pet!]! } enum CatCommand { JUMP } @@ -47,43 +48,43 @@ union CatOrDog = Cat | Dog union DogOrHuman = Dog | Human union HumanOrAlien = Human | Alien -"Support for [Counter Example 94](http://spec.graphql.org/June2018/#example-77c2e)" +"Support for [Counter Example 105](https://spec.graphql.org/October2021/#example-77c2e)" type Mutation { mutateDog: MutateDogResult } -"Support for [Counter Example 94](http://spec.graphql.org/June2018/#example-77c2e)" +"Support for [Counter Example 105](https://spec.graphql.org/October2021/#example-77c2e)" type MutateDogResult { id: ID! } -"Support for [Example 97](http://spec.graphql.org/June2018/#example-5bbc3) - [Counter Example 101](http://spec.graphql.org/June2018/#example-2353b)" +"Support for [Example 108](https://spec.graphql.org/October2021/#example-5bbc3) - [Counter Example 112](https://spec.graphql.org/October2021/#example-a8fa1)" type Subscription { - "Support for [Example 97](http://spec.graphql.org/June2018/#example-5bbc3) - [Counter Example 101](http://spec.graphql.org/June2018/#example-2353b)" + "Support for [Example 108](https://spec.graphql.org/October2021/#example-5bbc3) - [Counter Example 112](https://spec.graphql.org/October2021/#example-a8fa1)" newMessage: Message! - "Support for [Counter Example 99](http://spec.graphql.org/June2018/#example-3997d) - [Counter Example 100](http://spec.graphql.org/June2018/#example-18466)" + "Support for [Counter Example 110](https://spec.graphql.org/October2021/#example-3997d) - [Counter Example 111](https://spec.graphql.org/October2021/#example-18466)" disallowedSecondRootField: Boolean! } -"Support for [Example 97](http://spec.graphql.org/June2018/#example-5bbc3) - [Counter Example 101](http://spec.graphql.org/June2018/#example-2353b)" +"Support for [Example 108](https://spec.graphql.org/October2021/#example-5bbc3) - [Counter Example 112](https://spec.graphql.org/October2021/#example-a8fa1)" type Message { body: String sender: ID! } -# http://spec.graphql.org/June2018/#example-9bada +# https://spec.graphql.org/October2021/#example-9bada extend type Query { - "Support for [Counter Example 116](http://spec.graphql.org/June2018/#example-77c2e)" + "Support for [Counter Example 127](https://spec.graphql.org/October2021/#example-77c2e)" human: Human - "Support for [Counter Example 116](http://spec.graphql.org/June2018/#example-77c2e)" + "Support for [Counter Example 127](https://spec.graphql.org/October2021/#example-77c2e)" pet: Pet - "Support for [Counter Example 116](http://spec.graphql.org/June2018/#example-77c2e)" + "Support for [Counter Example 127](https://spec.graphql.org/October2021/#example-77c2e)" catOrDog: CatOrDog } -"Support for [Example 120](http://spec.graphql.org/June2018/#example-1891c)" +"Support for [Example 131](https://spec.graphql.org/October2021/#example-73706)" type Arguments { - "Support for [Example 121](http://spec.graphql.org/June2018/#example-18fab)" + "Support for [Example 132](https://spec.graphql.org/October2021/#example-bda7e)" multipleReqs(x: Int!, y: Int!): Int! booleanArgField(booleanArg: Boolean): Boolean floatArgField(floatArg: Float): Float @@ -94,27 +95,38 @@ type Arguments { optionalNonNullBooleanArgField(optionalBooleanArg: Boolean! = false): Boolean! } -# http://spec.graphql.org/June2018/#example-1891c +# https://spec.graphql.org/October2021/#example-73706 extend type Query { - "Support for [Example 120](http://spec.graphql.org/June2018/#example-1891c)" + "Support for [Example 131](https://spec.graphql.org/October2021/#example-73706)" arguments: Arguments } -# http://spec.graphql.org/June2018/#example-6bbad -extend type Human { - "Support for [Counter Example 136](http://spec.graphql.org/June2018/#example-6bbad)" - pets: [Pet!]! +# https://spec.graphql.org/October2021/#example-bc12a +extend type Query { + "Support for [Example 156](https://spec.graphql.org/October2021/#example-bc12a)" + resource: Resource +} + +"Support for [Example 156](https://spec.graphql.org/October2021/#example-bc12a)" +interface Node { + id: ID! +} + +"Support for [Example 156](https://spec.graphql.org/October2021/#example-bc12a)" +interface Resource implements Node { + id: ID! + url: String } -"[Example 155](http://spec.graphql.org/June2018/#example-f3185)" +"[Example 167](https://spec.graphql.org/October2021/#example-ce150)" input ComplexInput { name: String owner: String } extend type Query { - "[Example 155](http://spec.graphql.org/June2018/#example-f3185)" + "[Example 167](https://spec.graphql.org/October2021/#example-ce150)" findDog(complex: ComplexInput): Dog - "[Example 155](http://spec.graphql.org/June2018/#example-f3185)" + "[Example 167](https://spec.graphql.org/October2021/#example-ce150)" booleanList(booleanListArg: [Boolean!]): Boolean } diff --git a/samples/validation/schema/validation_schema_files b/samples/validation/schema/validation_schema_files index fe72dfb8..60750fdd 100644 --- a/samples/validation/schema/validation_schema_files +++ b/samples/validation/schema/validation_schema_files @@ -1,6 +1,8 @@ ValidationSchema.cpp SentientObject.cpp PetObject.cpp +NodeObject.cpp +ResourceObject.cpp CatOrDogObject.cpp DogOrHumanObject.cpp HumanOrAlienObject.cpp diff --git a/test/ValidationTests.cpp b/test/ValidationTests.cpp index 071e9317..d03d0506 100644 --- a/test/ValidationTests.cpp +++ b/test/ValidationTests.cpp @@ -34,9 +34,9 @@ class ValidationExamplesCase : public ::testing::Test std::shared_ptr ValidationExamplesCase::_service; -TEST_F(ValidationExamplesCase, CounterExample91) +TEST_F(ValidationExamplesCase, CounterExample102) { - // http://spec.graphql.org/June2018/#example-12752 + // https://spec.graphql.org/October2021/#example-12752 auto query = R"(query getDogName { dog { name @@ -61,9 +61,9 @@ TEST_F(ValidationExamplesCase, CounterExample91) << "error should match"; } -TEST_F(ValidationExamplesCase, Example92) +TEST_F(ValidationExamplesCase, Example103) { - // http://spec.graphql.org/June2018/#example-069e1 + // https://spec.graphql.org/October2021/#example-069e1 auto query = R"(query getDogName { dog { name @@ -83,9 +83,9 @@ TEST_F(ValidationExamplesCase, Example92) ASSERT_TRUE(errors.empty()); } -TEST_F(ValidationExamplesCase, CounterExample93) +TEST_F(ValidationExamplesCase, CounterExample104) { - // http://spec.graphql.org/June2018/#example-5e409 + // https://spec.graphql.org/October2021/#example-5e409 auto query = R"(query getName { dog { name @@ -110,9 +110,9 @@ TEST_F(ValidationExamplesCase, CounterExample93) << "error should match"; } -TEST_F(ValidationExamplesCase, CounterExample94) +TEST_F(ValidationExamplesCase, CounterExample105) { - // http://spec.graphql.org/June2018/#example-77c2e + // https://spec.graphql.org/October2021/#example-77c2e auto query = R"(query dogOperation { dog { name @@ -135,9 +135,9 @@ TEST_F(ValidationExamplesCase, CounterExample94) << "error should match"; } -TEST_F(ValidationExamplesCase, Example95) +TEST_F(ValidationExamplesCase, Example106) { - // http://spec.graphql.org/June2018/#example-be853 + // https://spec.graphql.org/October2021/#example-be853 auto query = R"({ dog { name @@ -149,9 +149,9 @@ TEST_F(ValidationExamplesCase, Example95) ASSERT_TRUE(errors.empty()); } -TEST_F(ValidationExamplesCase, CounterExample96) +TEST_F(ValidationExamplesCase, CounterExample107) { - // http://spec.graphql.org/June2018/#example-44b85 + // https://spec.graphql.org/October2021/#example-44b85 auto query = R"({ dog { name @@ -176,9 +176,9 @@ TEST_F(ValidationExamplesCase, CounterExample96) << "error should match"; } -TEST_F(ValidationExamplesCase, Example97) +TEST_F(ValidationExamplesCase, Example108) { - // http://spec.graphql.org/June2018/#example-5bbc3 + // https://spec.graphql.org/October2021/#example-5bbc3 auto query = R"(subscription sub { newMessage { body @@ -191,9 +191,9 @@ TEST_F(ValidationExamplesCase, Example97) ASSERT_TRUE(errors.empty()); } -TEST_F(ValidationExamplesCase, Example98) +TEST_F(ValidationExamplesCase, Example109) { - // http://spec.graphql.org/June2018/#example-13061 + // https://spec.graphql.org/October2021/#example-13061 auto query = R"(subscription sub { ...newMessageFields } @@ -210,9 +210,9 @@ TEST_F(ValidationExamplesCase, Example98) ASSERT_TRUE(errors.empty()); } -TEST_F(ValidationExamplesCase, CounterExample99) +TEST_F(ValidationExamplesCase, CounterExample110) { - // http://spec.graphql.org/June2018/#example-3997d + // https://spec.graphql.org/October2021/#example-3997d auto query = R"(subscription sub { newMessage { body @@ -231,9 +231,9 @@ TEST_F(ValidationExamplesCase, CounterExample99) << "error should match"; } -TEST_F(ValidationExamplesCase, CounterExample100) +TEST_F(ValidationExamplesCase, CounterExample111) { - // http://spec.graphql.org/June2018/#example-18466 + // https://spec.graphql.org/October2021/#example-18466 auto query = R"(subscription sub { ...multipleSubscriptions } @@ -256,14 +256,10 @@ TEST_F(ValidationExamplesCase, CounterExample100) << "error should match"; } -TEST_F(ValidationExamplesCase, CounterExample101) +TEST_F(ValidationExamplesCase, CounterExample112) { - // http://spec.graphql.org/June2018/#example-2353b + // https://spec.graphql.org/October2021/#example-a8fa1 auto query = R"(subscription sub { - newMessage { - body - sender - } __typename })"_graphql; @@ -277,9 +273,9 @@ TEST_F(ValidationExamplesCase, CounterExample101) << "error should match"; } -TEST_F(ValidationExamplesCase, CounterExample102) +TEST_F(ValidationExamplesCase, CounterExample113) { - // http://spec.graphql.org/June2018/#example-48706 + // https://spec.graphql.org/October2021/#example-48706 auto query = R"(fragment fieldNotDefined on Dog { meowVolume } @@ -303,9 +299,9 @@ TEST_F(ValidationExamplesCase, CounterExample102) << "error should match"; } -TEST_F(ValidationExamplesCase, Example103) +TEST_F(ValidationExamplesCase, Example114) { - // http://spec.graphql.org/June2018/#example-d34e0 + // https://spec.graphql.org/October2021/#example-d34e0 auto query = R"(fragment interfaceFieldSelection on Pet { name } @@ -321,9 +317,9 @@ TEST_F(ValidationExamplesCase, Example103) ASSERT_TRUE(errors.empty()); } -TEST_F(ValidationExamplesCase, CounterExample104) +TEST_F(ValidationExamplesCase, CounterExample115) { - // http://spec.graphql.org/June2018/#example-db33b + // https://spec.graphql.org/October2021/#example-db33b auto query = R"(fragment definedOnImplementorsButNotInterface on Pet { nickname })"_graphql; @@ -339,9 +335,9 @@ TEST_F(ValidationExamplesCase, CounterExample104) << "error should match"; } -TEST_F(ValidationExamplesCase, Example105) +TEST_F(ValidationExamplesCase, Example116) { - // http://spec.graphql.org/June2018/#example-245fa + // https://spec.graphql.org/October2021/#example-245fa auto query = R"(fragment inDirectFieldSelectionOnUnion on CatOrDog { __typename ... on Pet { @@ -363,9 +359,9 @@ TEST_F(ValidationExamplesCase, Example105) ASSERT_TRUE(errors.empty()); } -TEST_F(ValidationExamplesCase, CounterExample106) +TEST_F(ValidationExamplesCase, CounterExample117) { - // http://spec.graphql.org/June2018/#example-252ad + // https://spec.graphql.org/October2021/#example-252ad auto query = R"(fragment directFieldSelectionOnUnion on CatOrDog { name barkVolume @@ -386,9 +382,9 @@ TEST_F(ValidationExamplesCase, CounterExample106) << "error should match"; } -TEST_F(ValidationExamplesCase, Example107) +TEST_F(ValidationExamplesCase, Example118) { - // http://spec.graphql.org/June2018/#example-4e10c + // https://spec.graphql.org/October2021/#example-4e10c auto query = R"(fragment mergeIdenticalFields on Dog { name name @@ -411,9 +407,9 @@ TEST_F(ValidationExamplesCase, Example107) ASSERT_TRUE(errors.empty()); } -TEST_F(ValidationExamplesCase, CounterExample108) +TEST_F(ValidationExamplesCase, CounterExample119) { - // http://spec.graphql.org/June2018/#example-a2230 + // https://spec.graphql.org/October2021/#example-a2230 auto query = R"(fragment conflictingBecauseAlias on Dog { name: nickname name @@ -430,9 +426,9 @@ TEST_F(ValidationExamplesCase, CounterExample108) << "error should match"; } -TEST_F(ValidationExamplesCase, Example109) +TEST_F(ValidationExamplesCase, Example120) { - // http://spec.graphql.org/June2018/#example-b6369 + // https://spec.graphql.org/October2021/#example-b6369 auto query = R"(fragment mergeIdenticalFieldsWithIdenticalArgs on Dog { doesKnowCommand(dogCommand: SIT) doesKnowCommand(dogCommand: SIT) @@ -460,9 +456,9 @@ TEST_F(ValidationExamplesCase, Example109) ASSERT_TRUE(errors.empty()); } -TEST_F(ValidationExamplesCase, CounterExample110) +TEST_F(ValidationExamplesCase, CounterExample121) { - // http://spec.graphql.org/June2018/#example-00fbf + // https://spec.graphql.org/October2021/#example-00fbf auto query = R"(fragment conflictingArgsOnValues on Dog { doesKnowCommand(dogCommand: SIT) doesKnowCommand(dogCommand: HEEL) @@ -506,9 +502,9 @@ TEST_F(ValidationExamplesCase, CounterExample110) << "error should match"; } -TEST_F(ValidationExamplesCase, Example111) +TEST_F(ValidationExamplesCase, Example122) { - // http://spec.graphql.org/June2018/#example-a8406 + // https://spec.graphql.org/October2021/#example-a8406 auto query = R"(fragment safeDifferingFields on Pet { ... on Dog { volume: barkVolume @@ -539,9 +535,9 @@ TEST_F(ValidationExamplesCase, Example111) ASSERT_TRUE(errors.empty()); } -TEST_F(ValidationExamplesCase, CounterExample112) +TEST_F(ValidationExamplesCase, CounterExample123) { - // http://spec.graphql.org/June2018/#example-54e3d + // https://spec.graphql.org/October2021/#example-54e3d auto query = R"(fragment conflictingDifferingResponses on Pet { ... on Dog { someValue: nickname @@ -562,9 +558,9 @@ TEST_F(ValidationExamplesCase, CounterExample112) << "error should match"; } -TEST_F(ValidationExamplesCase, Example113) +TEST_F(ValidationExamplesCase, Example124) { - // http://spec.graphql.org/June2018/#example-e23c5 + // https://spec.graphql.org/October2021/#example-e23c5 auto query = R"(fragment scalarSelection on Dog { barkVolume } @@ -580,9 +576,9 @@ TEST_F(ValidationExamplesCase, Example113) ASSERT_TRUE(errors.empty()); } -TEST_F(ValidationExamplesCase, CounterExample114) +TEST_F(ValidationExamplesCase, CounterExample125) { - // http://spec.graphql.org/June2018/#example-13b69 + // https://spec.graphql.org/October2021/#example-13b69 auto query = R"(fragment scalarSelectionsNotAllowedOnInt on Dog { barkVolume { sinceWhen @@ -600,9 +596,9 @@ TEST_F(ValidationExamplesCase, CounterExample114) << "error should match"; } -TEST_F(ValidationExamplesCase, Example115) +TEST_F(ValidationExamplesCase, Example126) { - // http://spec.graphql.org/June2018/#example-9bada + // https://spec.graphql.org/October2021/#example-9bada auto query = R"(query { human { name @@ -625,9 +621,9 @@ TEST_F(ValidationExamplesCase, Example115) ASSERT_TRUE(errors.empty()); } -TEST_F(ValidationExamplesCase, CounterExample116) +TEST_F(ValidationExamplesCase, CounterExample127) { - // http://spec.graphql.org/June2018/#example-d68ee + // https://spec.graphql.org/October2021/#example-d68ee auto query = R"(query directQueryOnObjectWithoutSubFields { human } @@ -658,9 +654,9 @@ TEST_F(ValidationExamplesCase, CounterExample116) << "error should match"; } -TEST_F(ValidationExamplesCase, Example117) +TEST_F(ValidationExamplesCase, Example128) { - // http://spec.graphql.org/June2018/#example-760cb + // https://spec.graphql.org/October2021/#example-dfd15 auto query = R"(fragment argOnRequiredArg on Dog { doesKnowCommand(dogCommand: SIT) } @@ -681,9 +677,9 @@ TEST_F(ValidationExamplesCase, Example117) ASSERT_TRUE(errors.empty()); } -TEST_F(ValidationExamplesCase, CounterExample118) +TEST_F(ValidationExamplesCase, CounterExample129) { - // http://spec.graphql.org/June2018/#example-d5639 + // https://spec.graphql.org/October2021/#example-d5639 auto query = R"(fragment invalidArgName on Dog { doesKnowCommand(command: CLEAN_UP_HOUSE) })"_graphql; @@ -699,9 +695,9 @@ TEST_F(ValidationExamplesCase, CounterExample118) << "error should match"; } -TEST_F(ValidationExamplesCase, CounterExample119) +TEST_F(ValidationExamplesCase, CounterExample130) { - // http://spec.graphql.org/June2018/#example-4feee + // https://spec.graphql.org/October2021/#example-df41e auto query = R"(fragment invalidArgName on Dog { isHousetrained(atOtherHomes: true) @include(unless: false) })"_graphql; @@ -717,9 +713,9 @@ TEST_F(ValidationExamplesCase, CounterExample119) << "error should match"; } -TEST_F(ValidationExamplesCase, Example120) +TEST_F(ValidationExamplesCase, Example131) { - // http://spec.graphql.org/June2018/#example-1891c + // https://spec.graphql.org/October2021/#example-73706 auto query = R"(query { arguments { multipleReqs(x: 1, y: 2) @@ -731,9 +727,9 @@ TEST_F(ValidationExamplesCase, Example120) ASSERT_TRUE(errors.empty()); } -TEST_F(ValidationExamplesCase, Example121) +TEST_F(ValidationExamplesCase, Example132) { - // http://spec.graphql.org/June2018/#example-18fab + // https://spec.graphql.org/October2021/#example-bda7e auto query = R"(fragment multipleArgs on Arguments { multipleReqs(x: 1, y: 2) } @@ -759,9 +755,9 @@ TEST_F(ValidationExamplesCase, Example121) ASSERT_TRUE(errors.empty()); } -TEST_F(ValidationExamplesCase, Example122) +TEST_F(ValidationExamplesCase, Example133) { - // http://spec.graphql.org/June2018/#example-503bd + // https://spec.graphql.org/October2021/#example-503bd auto query = R"(fragment goodBooleanArg on Arguments { booleanArgField(booleanArg: true) } @@ -782,9 +778,9 @@ TEST_F(ValidationExamplesCase, Example122) ASSERT_TRUE(errors.empty()); } -TEST_F(ValidationExamplesCase, Example123) +TEST_F(ValidationExamplesCase, Example134) { - // http://spec.graphql.org/June2018/#example-1f1d2 + // https://spec.graphql.org/October2021/#example-1f1d2 auto query = R"(fragment goodBooleanArgDefault on Arguments { booleanArgField } @@ -800,9 +796,9 @@ TEST_F(ValidationExamplesCase, Example123) ASSERT_TRUE(errors.empty()); } -TEST_F(ValidationExamplesCase, CounterExample124) +TEST_F(ValidationExamplesCase, CounterExample135) { - // http://spec.graphql.org/June2018/#example-f12a1 + // https://spec.graphql.org/October2021/#example-f12a1 auto query = R"(fragment missingRequiredArg on Arguments { nonNullBooleanArgField })"_graphql; @@ -818,9 +814,9 @@ TEST_F(ValidationExamplesCase, CounterExample124) << "error should match"; } -TEST_F(ValidationExamplesCase, CounterExample125) +TEST_F(ValidationExamplesCase, CounterExample136) { - // http://spec.graphql.org/June2018/#example-0bc81 + // https://spec.graphql.org/October2021/#example-0bc81 auto query = R"(fragment missingRequiredArg on Arguments { nonNullBooleanArgField(nonNullBooleanArg: null) })"_graphql; @@ -836,9 +832,9 @@ TEST_F(ValidationExamplesCase, CounterExample125) << "error should match"; } -TEST_F(ValidationExamplesCase, Example126) +TEST_F(ValidationExamplesCase, Example137) { - // http://spec.graphql.org/June2018/#example-3703b + // https://spec.graphql.org/October2021/#example-3703b auto query = R"({ dog { ...fragmentOne @@ -861,9 +857,9 @@ TEST_F(ValidationExamplesCase, Example126) ASSERT_TRUE(errors.empty()); } -TEST_F(ValidationExamplesCase, CounterExample127) +TEST_F(ValidationExamplesCase, CounterExample138) { - // http://spec.graphql.org/June2018/#example-2c3e3 + // https://spec.graphql.org/October2021/#example-2c3e3 auto query = R"({ dog { ...fragmentOne @@ -891,9 +887,9 @@ TEST_F(ValidationExamplesCase, CounterExample127) << "error should match"; } -TEST_F(ValidationExamplesCase, Example128) +TEST_F(ValidationExamplesCase, Example139) { - // http://spec.graphql.org/June2018/#example-1b2da + // https://spec.graphql.org/October2021/#example-1b2da auto query = R"(fragment correctType on Dog { name } @@ -923,9 +919,9 @@ TEST_F(ValidationExamplesCase, Example128) ASSERT_TRUE(errors.empty()); } -TEST_F(ValidationExamplesCase, CounterExample129) +TEST_F(ValidationExamplesCase, CounterExample140) { - // http://spec.graphql.org/June2018/#example-463f6 + // https://spec.graphql.org/October2021/#example-463f6 auto query = R"(fragment notOnExistingType on NotInSchema { name } @@ -951,9 +947,9 @@ TEST_F(ValidationExamplesCase, CounterExample129) << "error should match"; } -TEST_F(ValidationExamplesCase, Example130) +TEST_F(ValidationExamplesCase, Example141) { - // http://spec.graphql.org/June2018/#example-3c8d4 + // https://spec.graphql.org/October2021/#example-3c8d4 auto query = R"(fragment fragOnObject on Dog { name } @@ -981,9 +977,9 @@ TEST_F(ValidationExamplesCase, Example130) ASSERT_TRUE(errors.empty()); } -TEST_F(ValidationExamplesCase, CounterExample131) +TEST_F(ValidationExamplesCase, CounterExample142) { - // http://spec.graphql.org/June2018/#example-4d5e5 + // https://spec.graphql.org/October2021/#example-4d5e5 auto query = R"(fragment fragOnScalar on Int { something } @@ -1009,9 +1005,9 @@ TEST_F(ValidationExamplesCase, CounterExample131) << "error should match"; } -TEST_F(ValidationExamplesCase, CounterExample132) +TEST_F(ValidationExamplesCase, CounterExample143) { - // http://spec.graphql.org/June2018/#example-9e1e3 + // https://spec.graphql.org/October2021/#example-9e1e3 auto query = R"(fragment nameFragment on Dog { # unused name } @@ -1033,9 +1029,9 @@ TEST_F(ValidationExamplesCase, CounterExample132) << "error should match"; } -TEST_F(ValidationExamplesCase, CounterExample133) +TEST_F(ValidationExamplesCase, CounterExample144) { - // http://spec.graphql.org/June2018/#example-28421 + // https://spec.graphql.org/October2021/#example-28421 auto query = R"({ dog { ...undefinedFragment @@ -1053,9 +1049,9 @@ TEST_F(ValidationExamplesCase, CounterExample133) << "error should match"; } -TEST_F(ValidationExamplesCase, CounterExample134) +TEST_F(ValidationExamplesCase, CounterExample145) { - // http://spec.graphql.org/June2018/#example-9ceb4 + // https://spec.graphql.org/October2021/#example-9ceb4 auto query = R"({ dog { ...nameFragment @@ -1087,9 +1083,9 @@ TEST_F(ValidationExamplesCase, CounterExample134) << "error should match"; } -TEST_F(ValidationExamplesCase, Example135) +TEST_F(ValidationExamplesCase, Example146) { - // http://spec.graphql.org/June2018/#example-08734 + // https://spec.graphql.org/October2021/#example-08734 auto query = R"({ dog { name @@ -1108,9 +1104,9 @@ TEST_F(ValidationExamplesCase, Example135) ASSERT_TRUE(errors.empty()); } -TEST_F(ValidationExamplesCase, CounterExample136) +TEST_F(ValidationExamplesCase, CounterExample147) { - // http://spec.graphql.org/June2018/#example-6bbad + // https://spec.graphql.org/October2021/#example-cd11c auto query = R"({ dog { ...dogFragment @@ -1148,9 +1144,9 @@ TEST_F(ValidationExamplesCase, CounterExample136) << "error should match"; } -TEST_F(ValidationExamplesCase, Example137) +TEST_F(ValidationExamplesCase, Example148) { - // http://spec.graphql.org/June2018/#example-0fc38 + // https://spec.graphql.org/October2021/#example-0fc38 auto query = R"(fragment dogFragment on Dog { ... on Dog { barkVolume @@ -1168,9 +1164,9 @@ TEST_F(ValidationExamplesCase, Example137) ASSERT_TRUE(errors.empty()); } -TEST_F(ValidationExamplesCase, CounterExample138) +TEST_F(ValidationExamplesCase, CounterExample149) { - // http://spec.graphql.org/June2018/#example-4d411 + // https://spec.graphql.org/October2021/#example-4d411 auto query = R"(fragment catInDogFragmentInvalid on Dog { ... on Cat { meowVolume @@ -1188,9 +1184,9 @@ TEST_F(ValidationExamplesCase, CounterExample138) << "error should match"; } -TEST_F(ValidationExamplesCase, Example139) +TEST_F(ValidationExamplesCase, Example150) { - // http://spec.graphql.org/June2018/#example-2c8d0 + // https://spec.graphql.org/October2021/#example-2c8d0 auto query = R"(fragment petNameFragment on Pet { name } @@ -1210,9 +1206,9 @@ TEST_F(ValidationExamplesCase, Example139) ASSERT_TRUE(errors.empty()); } -TEST_F(ValidationExamplesCase, Example140) +TEST_F(ValidationExamplesCase, Example151) { - // http://spec.graphql.org/June2018/#example-41843 + // https://spec.graphql.org/October2021/#example-41843 auto query = R"(fragment catOrDogNameFragment on CatOrDog { ... on Cat { meowVolume @@ -1234,9 +1230,9 @@ TEST_F(ValidationExamplesCase, Example140) ASSERT_TRUE(errors.empty()); } -TEST_F(ValidationExamplesCase, Example141) +TEST_F(ValidationExamplesCase, Example152) { - // http://spec.graphql.org/June2018/#example-85110 + // https://spec.graphql.org/October2021/#example-85110 auto query = R"(fragment petFragment on Pet { name ... on Dog { @@ -1262,9 +1258,9 @@ TEST_F(ValidationExamplesCase, Example141) ASSERT_TRUE(errors.empty()); } -TEST_F(ValidationExamplesCase, CounterExample142) +TEST_F(ValidationExamplesCase, CounterExample153) { - // http://spec.graphql.org/June2018/#example-a8dcc + // https://spec.graphql.org/October2021/#example-a8dcc auto query = R"(fragment sentientFragment on Sentient { ... on Dog { barkVolume @@ -1292,9 +1288,9 @@ TEST_F(ValidationExamplesCase, CounterExample142) << "error should match"; } -TEST_F(ValidationExamplesCase, Example143) +TEST_F(ValidationExamplesCase, Example154) { - // http://spec.graphql.org/June2018/#example-dc875 + // https://spec.graphql.org/October2021/#example-dc875 auto query = R"(fragment unionWithInterface on Pet { ...dogOrHumanFragment } @@ -1316,9 +1312,9 @@ TEST_F(ValidationExamplesCase, Example143) ASSERT_TRUE(errors.empty()); } -TEST_F(ValidationExamplesCase, CounterExample144) +TEST_F(ValidationExamplesCase, CounterExample155) { - // http://spec.graphql.org/June2018/#example-c9c63 + // https://spec.graphql.org/October2021/#example-c9c63 auto query = R"(fragment nonIntersectingInterfaces on Pet { ...sentientFragment } @@ -1338,9 +1334,31 @@ TEST_F(ValidationExamplesCase, CounterExample144) << "error should match"; } -TEST_F(ValidationExamplesCase, Example145) +TEST_F(ValidationExamplesCase, Example156) +{ + // https://spec.graphql.org/October2021/#example-bc12a + auto query = R"(fragment interfaceWithInterface on Node { + ...resourceFragment + } + + fragment resourceFragment on Resource { + url + } + + query { + resource { + ...interfaceWithInterface + } + })"_graphql; + + auto errors = _service->validate(query); + + ASSERT_TRUE(errors.empty()); +} + +TEST_F(ValidationExamplesCase, Example157) { - // http://spec.graphql.org/June2018/#example-7ee0e + // https://spec.graphql.org/October2021/#example-7ee0e auto query = R"(fragment goodBooleanArg on Arguments { booleanArgField(booleanArg: true) } @@ -1366,9 +1384,9 @@ TEST_F(ValidationExamplesCase, Example145) ASSERT_TRUE(errors.empty()); } -TEST_F(ValidationExamplesCase, CounterExample146) +TEST_F(ValidationExamplesCase, CounterExample158) { - // http://spec.graphql.org/June2018/#example-3a7c1 + // https://spec.graphql.org/October2021/#example-3a7c1 auto query = R"(fragment stringIntoInt on Arguments { intArgField(intArg: "123") } @@ -1401,9 +1419,9 @@ TEST_F(ValidationExamplesCase, CounterExample146) << "error should match"; } -TEST_F(ValidationExamplesCase, Example147) +TEST_F(ValidationExamplesCase, Example159) { - // http://spec.graphql.org/June2018/#example-a940b + // https://spec.graphql.org/October2021/#example-a940b auto query = R"({ findDog(complex: { name: "Fido" }) { name @@ -1415,9 +1433,9 @@ TEST_F(ValidationExamplesCase, Example147) ASSERT_TRUE(errors.empty()); } -TEST_F(ValidationExamplesCase, CounterExample148) +TEST_F(ValidationExamplesCase, CounterExample160) { - // http://spec.graphql.org/June2018/#example-1a5f6 + // https://spec.graphql.org/October2021/#example-1a5f6 auto query = R"({ findDog(complex: { favoriteCookieFlavor: "Bacon" }) { name @@ -1439,9 +1457,9 @@ TEST_F(ValidationExamplesCase, CounterExample148) << "error should match"; } -TEST_F(ValidationExamplesCase, CounterExample149) +TEST_F(ValidationExamplesCase, CounterExample161) { - // http://spec.graphql.org/June2018/#example-5d541 + // https://spec.graphql.org/October2021/#example-5d541 auto query = R"({ findDog(complex: { name: "Fido", name: "Fido" }) { name @@ -1459,9 +1477,9 @@ TEST_F(ValidationExamplesCase, CounterExample149) << "error should match"; } -TEST_F(ValidationExamplesCase, CounterExample150) +TEST_F(ValidationExamplesCase, CounterExample162) { - // http://spec.graphql.org/June2018/#example-55f3f + // https://spec.graphql.org/October2021/#example-55f3f auto query = R"(query @skip(if: $foo) { dog { name @@ -1479,9 +1497,9 @@ TEST_F(ValidationExamplesCase, CounterExample150) << "error should match"; } -TEST_F(ValidationExamplesCase, CounterExample151) +TEST_F(ValidationExamplesCase, CounterExample163) { - // http://spec.graphql.org/June2018/#example-b2e6c + // https://spec.graphql.org/October2021/#example-b2e6c auto query = R"(query ($foo: Boolean = true, $bar: Boolean = false) { dog @skip(if: $foo) @skip(if: $bar) { name @@ -1499,9 +1517,9 @@ TEST_F(ValidationExamplesCase, CounterExample151) << "error should match"; } -TEST_F(ValidationExamplesCase, Example152) +TEST_F(ValidationExamplesCase, Example164) { - // http://spec.graphql.org/June2018/#example-c5ee9 + // https://spec.graphql.org/October2021/#example-c5ee9 auto query = R"(query ($foo: Boolean = true, $bar: Boolean = false) { dog @skip(if: $foo) { name @@ -1516,9 +1534,9 @@ TEST_F(ValidationExamplesCase, Example152) ASSERT_TRUE(errors.empty()); } -TEST_F(ValidationExamplesCase, CounterExample153) +TEST_F(ValidationExamplesCase, CounterExample165) { - // http://spec.graphql.org/June2018/#example-b767a + // https://spec.graphql.org/October2021/#example-abc9c auto query = R"(query houseTrainedQuery($atOtherHomes: Boolean, $atOtherHomes: Boolean) { dog { isHousetrained(atOtherHomes: $atOtherHomes) @@ -1536,9 +1554,9 @@ TEST_F(ValidationExamplesCase, CounterExample153) << "error should match"; } -TEST_F(ValidationExamplesCase, Example154) +TEST_F(ValidationExamplesCase, Example166) { - // http://spec.graphql.org/June2018/#example-6f6b9 + // https://spec.graphql.org/October2021/#example-54c93 auto query = R"(query A($atOtherHomes: Boolean) { ...HouseTrainedFragment } @@ -1558,9 +1576,9 @@ TEST_F(ValidationExamplesCase, Example154) ASSERT_TRUE(errors.empty()); } -TEST_F(ValidationExamplesCase, Example155) +TEST_F(ValidationExamplesCase, Example167) { - // http://spec.graphql.org/June2018/#example-f3185 + // https://spec.graphql.org/October2021/#example-ce150 auto query = R"(query takesComplexInput($complexInput: ComplexInput) { findDog(complex: $complexInput) { name @@ -1572,9 +1590,9 @@ TEST_F(ValidationExamplesCase, Example155) ASSERT_TRUE(errors.empty()); } -TEST_F(ValidationExamplesCase, Example156) +TEST_F(ValidationExamplesCase, Example168) { - // http://spec.graphql.org/June2018/#example-77f18 + // https://spec.graphql.org/October2021/#example-a4255 auto query = R"(query takesBoolean($atOtherHomes: Boolean) { dog { isHousetrained(atOtherHomes: $atOtherHomes) @@ -1596,9 +1614,9 @@ TEST_F(ValidationExamplesCase, Example156) ASSERT_TRUE(errors.empty()); } -TEST_F(ValidationExamplesCase, CounterExample157) +TEST_F(ValidationExamplesCase, CounterExample169) { - // http://spec.graphql.org/June2018/#example-aeba9 + // https://spec.graphql.org/October2021/#example-aeba9 auto query = R"(query takesCat($cat: Cat) { dog { name @@ -1646,9 +1664,9 @@ TEST_F(ValidationExamplesCase, CounterExample157) << "error should match"; } -TEST_F(ValidationExamplesCase, Example158) +TEST_F(ValidationExamplesCase, Example170) { - // http://spec.graphql.org/June2018/#example-a5099 + // https://spec.graphql.org/October2021/#example-38119 auto query = R"(query variableIsDefined($atOtherHomes: Boolean) { dog { isHousetrained(atOtherHomes: $atOtherHomes) @@ -1660,9 +1678,9 @@ TEST_F(ValidationExamplesCase, Example158) ASSERT_TRUE(errors.empty()); } -TEST_F(ValidationExamplesCase, CounterExample159) +TEST_F(ValidationExamplesCase, CounterExample171) { - // http://spec.graphql.org/June2018/#example-c8425 + // https://spec.graphql.org/October2021/#example-5ba94 auto query = R"(query variableIsNotDefined { dog { isHousetrained(atOtherHomes: $atOtherHomes) @@ -1680,9 +1698,9 @@ TEST_F(ValidationExamplesCase, CounterExample159) << "error should match"; } -TEST_F(ValidationExamplesCase, Example160) +TEST_F(ValidationExamplesCase, Example172) { - // http://spec.graphql.org/June2018/#example-f4a77 + // https://spec.graphql.org/October2021/#example-559c2 auto query = R"(query variableIsDefinedUsedInSingleFragment($atOtherHomes: Boolean) { dog { ...isHousetrainedFragment @@ -1698,9 +1716,9 @@ TEST_F(ValidationExamplesCase, Example160) ASSERT_TRUE(errors.empty()); } -TEST_F(ValidationExamplesCase, CounterExample161) +TEST_F(ValidationExamplesCase, CounterExample173) { - // http://spec.graphql.org/June2018/#example-8c8db + // https://spec.graphql.org/October2021/#example-93d3e auto query = R"(query variableIsNotDefinedUsedInSingleFragment { dog { ...isHousetrainedFragment @@ -1722,9 +1740,9 @@ TEST_F(ValidationExamplesCase, CounterExample161) << "error should match"; } -TEST_F(ValidationExamplesCase, CounterExample162) +TEST_F(ValidationExamplesCase, CounterExample174) { - // http://spec.graphql.org/June2018/#example-7b65c + // https://spec.graphql.org/October2021/#example-ee7be auto query = R"(query variableIsNotDefinedUsedInNestedFragment { dog { ...outerHousetrainedFragment @@ -1750,9 +1768,9 @@ TEST_F(ValidationExamplesCase, CounterExample162) << "error should match"; } -TEST_F(ValidationExamplesCase, Example163) +TEST_F(ValidationExamplesCase, Example175) { - // http://spec.graphql.org/June2018/#example-84129 + // https://spec.graphql.org/October2021/#example-d601e auto query = R"(query housetrainedQueryOne($atOtherHomes: Boolean) { dog { ...isHousetrainedFragment @@ -1774,9 +1792,9 @@ TEST_F(ValidationExamplesCase, Example163) ASSERT_TRUE(errors.empty()); } -TEST_F(ValidationExamplesCase, CounterExample164) +TEST_F(ValidationExamplesCase, CounterExample176) { - // http://spec.graphql.org/June2018/#example-ef68a + // https://spec.graphql.org/October2021/#example-2b284 auto query = R"(query housetrainedQueryOne($atOtherHomes: Boolean) { dog { ...isHousetrainedFragment @@ -1804,9 +1822,9 @@ TEST_F(ValidationExamplesCase, CounterExample164) << "error should match"; } -TEST_F(ValidationExamplesCase, CounterExample165) +TEST_F(ValidationExamplesCase, CounterExample177) { - // http://spec.graphql.org/June2018/#example-516af + // https://spec.graphql.org/October2021/#example-464b6 auto query = R"(query variableUnused($atOtherHomes: Boolean) { dog { isHousetrained @@ -1824,9 +1842,9 @@ TEST_F(ValidationExamplesCase, CounterExample165) << "error should match"; } -TEST_F(ValidationExamplesCase, Example166) +TEST_F(ValidationExamplesCase, Example178) { - // http://spec.graphql.org/June2018/#example-ed1fa + // https://spec.graphql.org/October2021/#example-6d4bb auto query = R"(query variableUsedInFragment($atOtherHomes: Boolean) { dog { ...isHousetrainedFragment @@ -1842,9 +1860,9 @@ TEST_F(ValidationExamplesCase, Example166) ASSERT_TRUE(errors.empty()); } -TEST_F(ValidationExamplesCase, CounterExample167) +TEST_F(ValidationExamplesCase, CounterExample179) { - // http://spec.graphql.org/June2018/#example-f6c72 + // https://spec.graphql.org/October2021/#example-a30e2 auto query = R"(query variableNotUsedWithinFragment($atOtherHomes: Boolean) { dog { ...isHousetrainedWithoutVariableFragment @@ -1866,9 +1884,9 @@ TEST_F(ValidationExamplesCase, CounterExample167) << "error should match"; } -TEST_F(ValidationExamplesCase, CounterExample168) +TEST_F(ValidationExamplesCase, CounterExample180) { - // http://spec.graphql.org/June2018/#example-5593f + // https://spec.graphql.org/October2021/#example-e647f auto query = R"(query queryWithUsedVar($atOtherHomes: Boolean) { dog { ...isHousetrainedFragment @@ -1896,9 +1914,9 @@ TEST_F(ValidationExamplesCase, CounterExample168) << "error should match"; } -TEST_F(ValidationExamplesCase, CounterExample169) +TEST_F(ValidationExamplesCase, CounterExample181) { - // http://spec.graphql.org/June2018/#example-2028e + // https://spec.graphql.org/October2021/#example-2028e auto query = R"(query intCannotGoIntoBoolean($intArg: Int) { arguments { booleanArgField(booleanArg: $intArg) @@ -1916,9 +1934,9 @@ TEST_F(ValidationExamplesCase, CounterExample169) << "error should match"; } -TEST_F(ValidationExamplesCase, CounterExample170) +TEST_F(ValidationExamplesCase, CounterExample182) { - // http://spec.graphql.org/June2018/#example-8d369 + // https://spec.graphql.org/October2021/#example-8d369 auto query = R"(query booleanListCannotGoIntoBoolean($booleanListArg: [Boolean]) { arguments { booleanArgField(booleanArg: $booleanListArg) @@ -1936,9 +1954,9 @@ TEST_F(ValidationExamplesCase, CounterExample170) << "error should match"; } -TEST_F(ValidationExamplesCase, CounterExample171) +TEST_F(ValidationExamplesCase, CounterExample183) { - // http://spec.graphql.org/June2018/#example-ed727 + // https://spec.graphql.org/October2021/#example-ed727 auto query = R"(query booleanArgQuery($booleanArg: Boolean) { arguments { nonNullBooleanArgField(nonNullBooleanArg: $booleanArg) @@ -1956,9 +1974,9 @@ TEST_F(ValidationExamplesCase, CounterExample171) << "error should match"; } -TEST_F(ValidationExamplesCase, Example172) +TEST_F(ValidationExamplesCase, Example184) { - // http://spec.graphql.org/June2018/#example-c5959 + // https://spec.graphql.org/October2021/#example-c5959 auto query = R"(query nonNullListToList($nonNullBooleanList: [Boolean]!) { arguments { booleanListArgField(booleanListArg: $nonNullBooleanList) @@ -1970,9 +1988,9 @@ TEST_F(ValidationExamplesCase, Example172) ASSERT_TRUE(errors.empty()); } -TEST_F(ValidationExamplesCase, CounterExample173) +TEST_F(ValidationExamplesCase, CounterExample185) { - // http://spec.graphql.org/June2018/#example-64255 + // https://spec.graphql.org/October2021/#example-64255 auto query = R"(query listToNonNullList($booleanList: [Boolean]) { arguments { nonNullBooleanListField(nonNullBooleanListArg: $booleanList) @@ -1990,9 +2008,9 @@ TEST_F(ValidationExamplesCase, CounterExample173) << "error should match"; } -TEST_F(ValidationExamplesCase, Example174) +TEST_F(ValidationExamplesCase, Example186) { - // http://spec.graphql.org/June2018/#example-0877c + // https://spec.graphql.org/October2021/#example-0877c auto query = R"(query booleanArgQueryWithDefault($booleanArg: Boolean) { arguments { optionalNonNullBooleanArgField(optionalBooleanArg: $booleanArg) @@ -2004,9 +2022,9 @@ TEST_F(ValidationExamplesCase, Example174) ASSERT_TRUE(errors.empty()); } -TEST_F(ValidationExamplesCase, Example175) +TEST_F(ValidationExamplesCase, Example187) { - // http://spec.graphql.org/June2018/#example-d24d9 + // https://spec.graphql.org/October2021/#example-d24d9 auto query = R"(query booleanArgQueryWithDefault($booleanArg: Boolean = true) { arguments { nonNullBooleanArgField(nonNullBooleanArg: $booleanArg) From 3bea5f46db88ee1d1544adcc39130b338fc3c83a Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Sat, 11 Dec 2021 23:52:37 -0800 Subject: [PATCH 091/119] Fix remaining URLs so they point to latest GraphQL spec --- doc/fieldparams.md | 2 +- doc/responses.md | 2 +- include/graphqlservice/GraphQLResponse.h | 2 +- .../nointrospection/SubscriptionObject.cpp | 2 +- samples/today/nointrospection/TodaySchema.cpp | 2 +- samples/today/schema.today.graphql | 4 +- samples/today/schema/SubscriptionObject.cpp | 2 +- samples/today/schema/TodaySchema.cpp | 2 +- .../schema/schema.validation.graphql | 2 +- src/GraphQLService.cpp | 8 +- src/JSONResponse.cpp | 8 +- src/Validation.cpp | 94 +++++++++---------- 12 files changed, 65 insertions(+), 65 deletions(-) diff --git a/doc/fieldparams.md b/doc/fieldparams.md index c098151c..8d33d6c4 100644 --- a/doc/fieldparams.md +++ b/doc/fieldparams.md @@ -120,7 +120,7 @@ implementation detail by client code. It automatically propagates through the field resolvers, and if there is a schema exception or one of the `getField` accessors throws another exception derived from `std::exception`, the `graphqlservice` library will automatically add the resulting path to the error -report, accoring to the [spec](http://spec.graphql.org/June2018/#sec-Errors). +report, accoring to the [spec](https://spec.graphql.org/October2021/#sec-Errors). ### Launch Policy diff --git a/doc/responses.md b/doc/responses.md index 6c4d9cb1..a1cf432b 100644 --- a/doc/responses.md +++ b/doc/responses.md @@ -7,7 +7,7 @@ As the comment in responses are not technically JSON-specific, although that is probably the most common way of representing them. These are the primitive types that may be represented in GraphQL, as of the -[June 2018 spec](http://spec.graphql.org/June2018/#sec-Serialization-Format): +[October 2021 spec](https://spec.graphql.org/October2021/#sec-Serialization-Format): ```c++ enum class Type : uint8_t diff --git a/include/graphqlservice/GraphQLResponse.h b/include/graphqlservice/GraphQLResponse.h index 6681b7b0..f50774b2 100644 --- a/include/graphqlservice/GraphQLResponse.h +++ b/include/graphqlservice/GraphQLResponse.h @@ -30,7 +30,7 @@ namespace graphql::response { // GraphQL responses are not technically JSON-specific, although that is probably the most common // way of representing them. These are the primitive types that may be represented in GraphQL, as -// of the [June 2018 spec](http://spec.graphql.org/June2018/#sec-Serialization-Format). +// of the [October 2021 spec](https://spec.graphql.org/October2021/#sec-Serialization-Format). enum class Type : uint8_t { Map, // JSON Object diff --git a/samples/today/nointrospection/SubscriptionObject.cpp b/samples/today/nointrospection/SubscriptionObject.cpp index ac6013b3..00d348ce 100644 --- a/samples/today/nointrospection/SubscriptionObject.cpp +++ b/samples/today/nointrospection/SubscriptionObject.cpp @@ -85,7 +85,7 @@ service::AwaitableResolver Subscription::resolve_typename(service::ResolverParam void AddSubscriptionDetails(const std::shared_ptr& typeSubscription, const std::shared_ptr& schema) { typeSubscription->AddFields({ - schema::Field::Make(R"gql(nextAppointmentChange)gql"sv, R"md()md"sv, std::make_optional(R"md(Need to deprecate a [field](http://spec.graphql.org/June2018/#sec-Deprecation))md"sv), schema->LookupType(R"gql(Appointment)gql"sv)), + schema::Field::Make(R"gql(nextAppointmentChange)gql"sv, R"md()md"sv, std::make_optional(R"md(Need to deprecate a [field](https://spec.graphql.org/October2021/#sec-Schema-Introspection.Deprecation))md"sv), schema->LookupType(R"gql(Appointment)gql"sv)), schema::Field::Make(R"gql(nodeChange)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Node)gql"sv)), { schema::InputValue::Make(R"gql(id)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ID)gql"sv)), R"gql()gql"sv) }) diff --git a/samples/today/nointrospection/TodaySchema.cpp b/samples/today/nointrospection/TodaySchema.cpp index d5f00300..c17d5c23 100644 --- a/samples/today/nointrospection/TodaySchema.cpp +++ b/samples/today/nointrospection/TodaySchema.cpp @@ -213,7 +213,7 @@ void AddTypesToSchema(const std::shared_ptr& schema) { service::s_namesTaskState[static_cast(today::TaskState::New)], R"md()md"sv, std::nullopt }, { service::s_namesTaskState[static_cast(today::TaskState::Started)], R"md()md"sv, std::nullopt }, { service::s_namesTaskState[static_cast(today::TaskState::Complete)], R"md()md"sv, std::nullopt }, - { service::s_namesTaskState[static_cast(today::TaskState::Unassigned)], R"md()md"sv, std::make_optional(R"md(Need to deprecate an [enum value](http://spec.graphql.org/June2018/#sec-Deprecation))md"sv) } + { service::s_namesTaskState[static_cast(today::TaskState::Unassigned)], R"md()md"sv, std::make_optional(R"md(Need to deprecate an [enum value](https://spec.graphql.org/October2021/#sec-Schema-Introspection.Deprecation))md"sv) } }); typeCompleteTaskInput->AddInputValues({ diff --git a/samples/today/schema.today.graphql b/samples/today/schema.today.graphql index b072b9d8..86cf0a7b 100644 --- a/samples/today/schema.today.graphql +++ b/samples/today/schema.today.graphql @@ -106,7 +106,7 @@ type Mutation { """ type Subscription { nextAppointmentChange : Appointment @deprecated( - reason:"""Need to deprecate a [field](http://spec.graphql.org/June2018/#sec-Deprecation)""" + reason:"""Need to deprecate a [field](https://spec.graphql.org/October2021/#sec-Schema-Introspection.Deprecation)""" ) nodeChange(id: ID!): Node! } @@ -120,7 +120,7 @@ enum TaskState { Started Complete Unassigned @deprecated( - reason:"""Need to deprecate an [enum value](http://spec.graphql.org/June2018/#sec-Deprecation)""" + reason:"""Need to deprecate an [enum value](https://spec.graphql.org/October2021/#sec-Schema-Introspection.Deprecation)""" ) } diff --git a/samples/today/schema/SubscriptionObject.cpp b/samples/today/schema/SubscriptionObject.cpp index ac6013b3..00d348ce 100644 --- a/samples/today/schema/SubscriptionObject.cpp +++ b/samples/today/schema/SubscriptionObject.cpp @@ -85,7 +85,7 @@ service::AwaitableResolver Subscription::resolve_typename(service::ResolverParam void AddSubscriptionDetails(const std::shared_ptr& typeSubscription, const std::shared_ptr& schema) { typeSubscription->AddFields({ - schema::Field::Make(R"gql(nextAppointmentChange)gql"sv, R"md()md"sv, std::make_optional(R"md(Need to deprecate a [field](http://spec.graphql.org/June2018/#sec-Deprecation))md"sv), schema->LookupType(R"gql(Appointment)gql"sv)), + schema::Field::Make(R"gql(nextAppointmentChange)gql"sv, R"md()md"sv, std::make_optional(R"md(Need to deprecate a [field](https://spec.graphql.org/October2021/#sec-Schema-Introspection.Deprecation))md"sv), schema->LookupType(R"gql(Appointment)gql"sv)), schema::Field::Make(R"gql(nodeChange)gql"sv, R"md()md"sv, std::nullopt, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(Node)gql"sv)), { schema::InputValue::Make(R"gql(id)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(ID)gql"sv)), R"gql()gql"sv) }) diff --git a/samples/today/schema/TodaySchema.cpp b/samples/today/schema/TodaySchema.cpp index 517bc027..801e0c12 100644 --- a/samples/today/schema/TodaySchema.cpp +++ b/samples/today/schema/TodaySchema.cpp @@ -216,7 +216,7 @@ void AddTypesToSchema(const std::shared_ptr& schema) { service::s_namesTaskState[static_cast(today::TaskState::New)], R"md()md"sv, std::nullopt }, { service::s_namesTaskState[static_cast(today::TaskState::Started)], R"md()md"sv, std::nullopt }, { service::s_namesTaskState[static_cast(today::TaskState::Complete)], R"md()md"sv, std::nullopt }, - { service::s_namesTaskState[static_cast(today::TaskState::Unassigned)], R"md()md"sv, std::make_optional(R"md(Need to deprecate an [enum value](http://spec.graphql.org/June2018/#sec-Deprecation))md"sv) } + { service::s_namesTaskState[static_cast(today::TaskState::Unassigned)], R"md()md"sv, std::make_optional(R"md(Need to deprecate an [enum value](https://spec.graphql.org/October2021/#sec-Schema-Introspection.Deprecation))md"sv) } }); typeCompleteTaskInput->AddInputValues({ diff --git a/samples/validation/schema/schema.validation.graphql b/samples/validation/schema/schema.validation.graphql index c12aa606..e1515c39 100644 --- a/samples/validation/schema/schema.validation.graphql +++ b/samples/validation/schema/schema.validation.graphql @@ -1,7 +1,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. -"GraphQL validation [sample](http://spec.graphql.org/October2021/#example-19f2a)" +"GraphQL validation [sample](https://spec.graphql.org/October2021/#example-19f2a)" type Query { dog: Dog } diff --git a/src/GraphQLService.cpp b/src/GraphQLService.cpp index 4c8e172b..9157f843 100644 --- a/src/GraphQLService.cpp +++ b/src/GraphQLService.cpp @@ -591,7 +591,7 @@ response::IdType ModifiedArgument::convert(const response::Val void blockSubFields(const ResolverParams& params) { - // http://spec.graphql.org/June2018/#sec-Leaf-Field-Selections + // https://spec.graphql.org/October2021/#sec-Leaf-Field-Selections if (params.selection != nullptr) { auto position = params.selection->begin(); @@ -676,7 +676,7 @@ AwaitableResolver ModifiedResult::convert( void requireSubFields(const ResolverParams& params) { - // http://spec.graphql.org/June2018/#sec-Leaf-Field-Selections + // https://spec.graphql.org/October2021/#sec-Leaf-Field-Selections if (params.selection == nullptr) { auto position = params.field.begin(); @@ -1455,7 +1455,7 @@ void SubscriptionDefinitionVisitor::visitField(const peg::ast_node& field) name = child.string_view(); }); - // http://spec.graphql.org/June2018/#sec-Single-root-field + // https://spec.graphql.org/October2021/#sec-Single-root-field if (!_field.empty()) { auto position = field.begin(); @@ -1698,7 +1698,7 @@ response::AwaitableValue Request::resolve(await_async launch, std::shared_ptr, Respons bool Int(int i) { - // http://spec.graphql.org/June2018/#sec-Int + // https://spec.graphql.org/October2021/#sec-Int static_assert(sizeof(i) == 4, "GraphQL only supports 32-bit signed integers"); auto value = Value(Type::Int); @@ -151,7 +151,7 @@ struct ResponseHandler : rapidjson::BaseReaderHandler, Respons { if (i > static_cast(std::numeric_limits::max())) { - // http://spec.graphql.org/June2018/#sec-Int + // https://spec.graphql.org/October2021/#sec-Int throw std::overflow_error("GraphQL only supports 32-bit signed integers"); } return Int(static_cast(i)); @@ -159,13 +159,13 @@ struct ResponseHandler : rapidjson::BaseReaderHandler, Respons bool Int64(int64_t /*i*/) { - // http://spec.graphql.org/June2018/#sec-Int + // https://spec.graphql.org/October2021/#sec-Int throw std::overflow_error("GraphQL only supports 32-bit signed integers"); } bool Uint64(uint64_t /*i*/) { - // http://spec.graphql.org/June2018/#sec-Int + // https://spec.graphql.org/October2021/#sec-Int throw std::overflow_error("GraphQL only supports 32-bit signed integers"); } diff --git a/src/Validation.cpp b/src/Validation.cpp index e51c8a0f..d67e5820 100644 --- a/src/Validation.cpp +++ b/src/Validation.cpp @@ -243,7 +243,7 @@ void ValidateArgumentValueVisitor::visitObjectValue(const peg::ast_node& objectV if (value.values.find(name) != value.values.end()) { - // http://spec.graphql.org/June2018/#sec-Input-Object-Field-Uniqueness + // https://spec.graphql.org/October2021/#sec-Input-Object-Field-Uniqueness auto position = field->begin(); std::ostringstream message; @@ -481,7 +481,7 @@ void ValidateExecutableVisitor::visit(const peg::ast_node& root) if (!inserted.second) { - // http://spec.graphql.org/June2018/#sec-Fragment-Name-Uniqueness + // https://spec.graphql.org/October2021/#sec-Fragment-Name-Uniqueness auto position = fragmentDefinition.begin(); std::ostringstream error; @@ -505,7 +505,7 @@ void ValidateExecutableVisitor::visit(const peg::ast_node& root) if (!inserted.second) { - // http://spec.graphql.org/June2018/#sec-Operation-Name-Uniqueness + // https://spec.graphql.org/October2021/#sec-Operation-Name-Uniqueness auto position = operationDefinition.begin(); std::ostringstream error; @@ -526,7 +526,7 @@ void ValidateExecutableVisitor::visit(const peg::ast_node& root) if (itr != _operationDefinitions.end()) { - // http://spec.graphql.org/June2018/#sec-Lone-Anonymous-Operation + // https://spec.graphql.org/October2021/#sec-Lone-Anonymous-Operation auto position = itr->second.get().begin(); _errors.push_back( @@ -547,7 +547,7 @@ void ValidateExecutableVisitor::visit(const peg::ast_node& root) } else { - // http://spec.graphql.org/June2018/#sec-Executable-Definitions + // https://spec.graphql.org/October2021/#sec-Executable-Definitions auto position = child->begin(); _errors.push_back({ "Unexpected type definition", { position.line, position.column } }); @@ -556,7 +556,7 @@ void ValidateExecutableVisitor::visit(const peg::ast_node& root) if (!_fragmentDefinitions.empty()) { - // http://spec.graphql.org/June2018/#sec-Fragments-Must-Be-Used + // https://spec.graphql.org/October2021/#sec-Fragments-Must-Be-Used const size_t originalSize = _errors.size(); auto unreferencedFragments = std::move(_fragmentDefinitions); @@ -607,8 +607,8 @@ void ValidateExecutableVisitor::visitFragmentDefinition(const peg::ast_node& fra if (itrType == _types.end() || isScalarType(itrType->second->get().kind())) { - // http://spec.graphql.org/June2018/#sec-Fragment-Spread-Type-Existence - // http://spec.graphql.org/June2018/#sec-Fragments-On-Composite-Types + // https://spec.graphql.org/October2021/#sec-Fragment-Spread-Type-Existence + // https://spec.graphql.org/October2021/#sec-Fragments-On-Composite-Types auto position = typeCondition->begin(); std::ostringstream message; @@ -662,7 +662,7 @@ void ValidateExecutableVisitor::visitOperationDefinition(const peg::ast_node& op if (_operationVariables->find(variableName) != _operationVariables->end()) { - // http://spec.graphql.org/June2018/#sec-Variable-Uniqueness + // https://spec.graphql.org/October2021/#sec-Variable-Uniqueness auto position = child->begin(); std::ostringstream message; @@ -688,7 +688,7 @@ void ValidateExecutableVisitor::visitOperationDefinition(const peg::ast_node& op if (!visitor.isInputType()) { - // http://spec.graphql.org/June2018/#sec-Variables-Are-Input-Types + // https://spec.graphql.org/October2021/#sec-Variables-Are-Input-Types auto position = child->begin(); std::ostringstream message; @@ -717,7 +717,7 @@ void ValidateExecutableVisitor::visitOperationDefinition(const peg::ast_node& op if (!validateInputValue(false, argument, variableArgument.type)) { - // http://spec.graphql.org/June2018/#sec-Values-of-Correct-Type + // https://spec.graphql.org/October2021/#sec-Values-of-Correct-Type auto position = child->begin(); std::ostringstream message; @@ -781,7 +781,7 @@ void ValidateExecutableVisitor::visitOperationDefinition(const peg::ast_node& op if (_fieldCount > 1 && operationType == strSubscription) { - // http://spec.graphql.org/June2018/#sec-Single-root-field + // https://spec.graphql.org/October2021/#sec-Single-root-field auto position = operationDefinition.begin(); std::ostringstream error; @@ -803,7 +803,7 @@ void ValidateExecutableVisitor::visitOperationDefinition(const peg::ast_node& op { if (_referencedVariables.find(variable.first) == _referencedVariables.end()) { - // http://spec.graphql.org/June2018/#sec-All-Variables-Used + // https://spec.graphql.org/October2021/#sec-All-Variables-Used auto position = variable.second.get().begin(); std::ostringstream error; @@ -918,7 +918,7 @@ bool ValidateExecutableVisitor::validateInputValue( if (itrVariable == _operationVariables->end()) { - // http://spec.graphql.org/June2018/#sec-All-Variable-Uses-Defined + // https://spec.graphql.org/October2021/#sec-All-Variable-Uses-Defined std::ostringstream message; message << "Undefined variable name: " << variable.name; @@ -1046,7 +1046,7 @@ bool ValidateExecutableVisitor::validateInputValue( if (itrField == itrFields->second.end()) { - // http://spec.graphql.org/June2018/#sec-Input-Object-Field-Names + // https://spec.graphql.org/October2021/#sec-Input-Object-Field-Names std::ostringstream message; message << "Undefined Input Object field type: " << name @@ -1097,7 +1097,7 @@ bool ValidateExecutableVisitor::validateInputValue( if (fieldKind == introspection::TypeKind::NON_NULL) { - // http://spec.graphql.org/June2018/#sec-Input-Object-Required-Fields + // https://spec.graphql.org/October2021/#sec-Input-Object-Required-Fields std::ostringstream message; message << "Missing Input Object field type: " << name @@ -1272,7 +1272,7 @@ bool ValidateExecutableVisitor::validateVariableType(bool isNonNull, { if (!isNonNull) { - // http://spec.graphql.org/June2018/#sec-All-Variable-Usages-are-Allowed + // https://spec.graphql.org/October2021/#sec-All-Variable-Usages-are-Allowed _errors.push_back({ "Expected Non-Null variable type", position }); return false; } @@ -1293,7 +1293,7 @@ bool ValidateExecutableVisitor::validateVariableType(bool isNonNull, { if (variableKind != inputKind) { - // http://spec.graphql.org/June2018/#sec-All-Variable-Usages-are-Allowed + // https://spec.graphql.org/October2021/#sec-All-Variable-Usages-are-Allowed _errors.push_back({ "Expected List variable type", position }); return false; } @@ -1322,7 +1322,7 @@ bool ValidateExecutableVisitor::validateVariableType(bool isNonNull, { if (variableKind != inputKind) { - // http://spec.graphql.org/June2018/#sec-All-Variable-Usages-are-Allowed + // https://spec.graphql.org/October2021/#sec-All-Variable-Usages-are-Allowed _errors.push_back({ "Expected Input Object variable type", position }); return false; } @@ -1334,7 +1334,7 @@ bool ValidateExecutableVisitor::validateVariableType(bool isNonNull, { if (variableKind != inputKind) { - // http://spec.graphql.org/June2018/#sec-All-Variable-Usages-are-Allowed + // https://spec.graphql.org/October2021/#sec-All-Variable-Usages-are-Allowed _errors.push_back({ "Expected Enum variable type", position }); return false; } @@ -1346,7 +1346,7 @@ bool ValidateExecutableVisitor::validateVariableType(bool isNonNull, { if (variableKind != inputKind) { - // http://spec.graphql.org/June2018/#sec-All-Variable-Usages-are-Allowed + // https://spec.graphql.org/October2021/#sec-All-Variable-Usages-are-Allowed _errors.push_back({ "Expected Scalar variable type", position }); return false; } @@ -1356,7 +1356,7 @@ bool ValidateExecutableVisitor::validateVariableType(bool isNonNull, default: { - // http://spec.graphql.org/June2018/#sec-All-Variable-Usages-are-Allowed + // https://spec.graphql.org/October2021/#sec-All-Variable-Usages-are-Allowed _errors.push_back({ "Unexpected input type", position }); return false; } @@ -1380,7 +1380,7 @@ bool ValidateExecutableVisitor::validateVariableType(bool isNonNull, if (variableName != inputName) { - // http://spec.graphql.org/June2018/#sec-All-Variable-Usages-are-Allowed + // https://spec.graphql.org/October2021/#sec-All-Variable-Usages-are-Allowed std::ostringstream message; message << "Incompatible variable type: " << variableName << " name: " << inputName; @@ -1544,7 +1544,7 @@ void ValidateExecutableVisitor::visitField(const peg::ast_node& field) if (itrType == _typeFields.end()) { - // http://spec.graphql.org/June2018/#sec-Leaf-Field-Selections + // https://spec.graphql.org/October2021/#sec-Leaf-Field-Selections auto position = field.begin(); std::ostringstream message; @@ -1562,7 +1562,7 @@ void ValidateExecutableVisitor::visitField(const peg::ast_node& field) case introspection::TypeKind::OBJECT: case introspection::TypeKind::INTERFACE: { - // http://spec.graphql.org/June2018/#sec-Field-Selections-on-Objects-Interfaces-and-Unions-Types + // https://spec.graphql.org/October2021/#sec-Field-Selections innerType = getFieldType(itrType->second, name); wrappedType = getWrappedFieldType(itrType->second, name); break; @@ -1572,7 +1572,7 @@ void ValidateExecutableVisitor::visitField(const peg::ast_node& field) { if (name != R"gql(__typename)gql"sv) { - // http://spec.graphql.org/June2018/#sec-Leaf-Field-Selections + // https://spec.graphql.org/October2021/#sec-Leaf-Field-Selections auto position = field.begin(); std::ostringstream message; @@ -1583,7 +1583,7 @@ void ValidateExecutableVisitor::visitField(const peg::ast_node& field) return; } - // http://spec.graphql.org/June2018/#sec-Field-Selections-on-Objects-Interfaces-and-Unions-Types + // https://spec.graphql.org/October2021/#sec-Field-Selections innerType = getValidateType(_schema->LookupType("String"sv)); wrappedType = getValidateType( _schema->WrapType(introspection::TypeKind::NON_NULL, getSharedType(innerType))); @@ -1596,7 +1596,7 @@ void ValidateExecutableVisitor::visitField(const peg::ast_node& field) if (!innerType) { - // http://spec.graphql.org/June2018/#sec-Field-Selections-on-Objects-Interfaces-and-Unions-Types + // https://spec.graphql.org/October2021/#sec-Field-Selections auto position = field.begin(); std::ostringstream message; @@ -1631,7 +1631,7 @@ void ValidateExecutableVisitor::visitField(const peg::ast_node& field) if (validateArguments.find(argumentName) != validateArguments.end()) { - // http://spec.graphql.org/June2018/#sec-Argument-Uniqueness + // https://spec.graphql.org/October2021/#sec-Argument-Uniqueness std::ostringstream message; message << "Conflicting argument type: " << _scopedType->get().name() @@ -1668,7 +1668,7 @@ void ValidateExecutableVisitor::visitField(const peg::ast_node& field) } else { - // http://spec.graphql.org/June2018/#sec-Field-Selection-Merging + // https://spec.graphql.org/October2021/#sec-Field-Selection-Merging auto position = field.begin(); std::ostringstream message; @@ -1688,7 +1688,7 @@ void ValidateExecutableVisitor::visitField(const peg::ast_node& field) if (itrArgument == itrField->second.arguments.end()) { - // http://spec.graphql.org/June2018/#sec-Argument-Names + // https://spec.graphql.org/October2021/#sec-Argument-Names std::ostringstream message; message << "Undefined argument type: " << _scopedType->get().name() @@ -1710,7 +1710,7 @@ void ValidateExecutableVisitor::visitField(const peg::ast_node& field) itrArgument->second, argument.second.type)) { - // http://spec.graphql.org/June2018/#sec-Values-of-Correct-Type + // https://spec.graphql.org/October2021/#sec-Values-of-Correct-Type std::ostringstream message; message << "Incompatible argument type: " << _scopedType->get().name() @@ -1731,7 +1731,7 @@ void ValidateExecutableVisitor::visitField(const peg::ast_node& field) if (argument.second.type && introspection::TypeKind::NON_NULL == argument.second.type->get().kind()) { - // http://spec.graphql.org/June2018/#sec-Required-Arguments + // https://spec.graphql.org/October2021/#sec-Required-Arguments auto position = field.begin(); std::ostringstream message; @@ -1776,7 +1776,7 @@ void ValidateExecutableVisitor::visitField(const peg::ast_node& field) if (subFieldCount == 0 && !isScalarType(innerType->get().kind())) { - // http://spec.graphql.org/June2018/#sec-Leaf-Field-Selections + // https://spec.graphql.org/October2021/#sec-Leaf-Field-Selections auto position = field.begin(); std::ostringstream message; @@ -1800,7 +1800,7 @@ void ValidateExecutableVisitor::visitFragmentSpread(const peg::ast_node& fragmen if (itr == _fragmentDefinitions.end()) { - // http://spec.graphql.org/June2018/#sec-Fragment-spread-target-defined + // https://spec.graphql.org/October2021/#sec-Fragment-spread-target-defined auto position = fragmentSpread.begin(); std::ostringstream message; @@ -1814,7 +1814,7 @@ void ValidateExecutableVisitor::visitFragmentSpread(const peg::ast_node& fragmen { if (_fragmentCycles.emplace(name).second) { - // http://spec.graphql.org/June2018/#sec-Fragment-spreads-must-not-form-cycles + // https://spec.graphql.org/October2021/#sec-Fragment-spreads-must-not-form-cycles auto position = fragmentSpread.begin(); std::ostringstream message; @@ -1833,7 +1833,7 @@ void ValidateExecutableVisitor::visitFragmentSpread(const peg::ast_node& fragmen if (itrInner == _types.end() || !matchesScopedType(innerType)) { - // http://spec.graphql.org/June2018/#sec-Fragment-spread-is-possible + // https://spec.graphql.org/October2021/#sec-Fragment-spread-is-possible auto position = fragmentSpread.begin(); std::ostringstream message; @@ -1885,7 +1885,7 @@ void ValidateExecutableVisitor::visitInlineFragment(const peg::ast_node& inlineF if (itrInner == _types.end()) { - // http://spec.graphql.org/June2018/#sec-Fragment-Spread-Type-Existence + // https://spec.graphql.org/October2021/#sec-Fragment-Spread-Type-Existence std::ostringstream message; message << "Undefined target type on inline fragment name: " << innerType; @@ -1898,8 +1898,8 @@ void ValidateExecutableVisitor::visitInlineFragment(const peg::ast_node& inlineF if (isScalarType(fragmentType->get().kind()) || !matchesScopedType(innerType)) { - // http://spec.graphql.org/June2018/#sec-Fragments-On-Composite-Types - // http://spec.graphql.org/June2018/#sec-Fragment-spread-is-possible + // https://spec.graphql.org/October2021/#sec-Fragments-On-Composite-Types + // https://spec.graphql.org/October2021/#sec-Fragment-spread-is-possible std::ostringstream message; message << (isScalarType(fragmentType->get().kind()) @@ -1940,7 +1940,7 @@ void ValidateExecutableVisitor::visitDirectives( if (!uniqueDirectives.emplace(directiveName).second) { - // http://spec.graphql.org/June2018/#sec-Directives-Are-Unique-Per-Location + // https://spec.graphql.org/October2021/#sec-Directives-Are-Unique-Per-Location auto position = directive->begin(); std::ostringstream message; @@ -1954,7 +1954,7 @@ void ValidateExecutableVisitor::visitDirectives( if (itrDirective == _directives.end()) { - // http://spec.graphql.org/June2018/#sec-Directives-Are-Defined + // https://spec.graphql.org/October2021/#sec-Directives-Are-Defined auto position = directive->begin(); std::ostringstream message; @@ -1966,7 +1966,7 @@ void ValidateExecutableVisitor::visitDirectives( if (itrDirective->second.locations.find(location) == itrDirective->second.locations.end()) { - // http://spec.graphql.org/June2018/#sec-Directives-Are-In-Valid-Locations + // https://spec.graphql.org/October2021/#sec-Directives-Are-In-Valid-Locations auto position = directive->begin(); std::ostringstream message; @@ -2023,7 +2023,7 @@ void ValidateExecutableVisitor::visitDirectives( if (validateArguments.find(argumentName) != validateArguments.end()) { - // http://spec.graphql.org/June2018/#sec-Argument-Uniqueness + // https://spec.graphql.org/October2021/#sec-Argument-Uniqueness std::ostringstream message; message << "Conflicting argument directive: " << directiveName @@ -2047,7 +2047,7 @@ void ValidateExecutableVisitor::visitDirectives( if (itrArgument == itrDirective->second.arguments.end()) { - // http://spec.graphql.org/June2018/#sec-Argument-Names + // https://spec.graphql.org/October2021/#sec-Argument-Names std::ostringstream message; message << "Undefined argument directive: " << directiveName @@ -2069,7 +2069,7 @@ void ValidateExecutableVisitor::visitDirectives( itrArgument->second, argument.second.type)) { - // http://spec.graphql.org/June2018/#sec-Values-of-Correct-Type + // https://spec.graphql.org/October2021/#sec-Values-of-Correct-Type std::ostringstream message; message << "Incompatible argument directive: " << directiveName @@ -2090,7 +2090,7 @@ void ValidateExecutableVisitor::visitDirectives( if (argument.second.type && introspection::TypeKind::NON_NULL == argument.second.type->get().kind()) { - // http://spec.graphql.org/June2018/#sec-Required-Arguments + // https://spec.graphql.org/October2021/#sec-Required-Arguments auto position = directive->begin(); std::ostringstream message; From d8edb044594ee2112ab310d15f4f39ed98d7346c Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Sun, 12 Dec 2021 11:55:17 -0800 Subject: [PATCH 092/119] Fix ValidationTests and possibleTypes logic --- include/Validation.h | 1 + include/graphqlservice/internal/Schema.h | 4 +- src/Introspection.cpp | 24 +++++++--- src/Schema.cpp | 15 ++++-- src/Validation.cpp | 61 +++++++++++++++++++----- test/ValidationTests.cpp | 2 +- 6 files changed, 85 insertions(+), 22 deletions(-) diff --git a/include/Validation.h b/include/Validation.h index b109cb7c..59f6f26d 100644 --- a/include/Validation.h +++ b/include/Validation.h @@ -250,6 +250,7 @@ class ValidateExecutableVisitor VariableSet _referencedVariables; FragmentSet _fragmentStack; size_t _fieldCount = 0; + size_t _introspectionFieldCount = 0; TypeFields _typeFields; InputTypeFields _inputTypeFields; ValidateType _scopedType; diff --git a/include/graphqlservice/internal/Schema.h b/include/graphqlservice/internal/Schema.h index baa400ca..3d7d12b3 100644 --- a/include/graphqlservice/internal/Schema.h +++ b/include/graphqlservice/internal/Schema.h @@ -177,7 +177,7 @@ class InterfaceType : public BaseType GRAPHQLSERVICE_EXPORT static std::shared_ptr Make( std::string_view name, std::string_view description); - GRAPHQLSERVICE_EXPORT void AddPossibleType(std::weak_ptr possibleType); + GRAPHQLSERVICE_EXPORT void AddPossibleType(std::weak_ptr possibleType); GRAPHQLSERVICE_EXPORT void AddInterfaces( std::vector>&& interfaces); GRAPHQLSERVICE_EXPORT void AddFields(std::vector>&& fields); @@ -188,6 +188,8 @@ class InterfaceType : public BaseType const noexcept final; GRAPHQLSERVICE_EXPORT const std::vector>& possibleTypes() const noexcept final; + GRAPHQLSERVICE_EXPORT const std::vector>& interfaces() + const noexcept final; private: const std::string_view _name; diff --git a/src/Introspection.cpp b/src/Introspection.cpp index 23e1f273..8c9a781a 100644 --- a/src/Introspection.cpp +++ b/src/Introspection.cpp @@ -5,12 +5,12 @@ #include "graphqlservice/introspection/IntrospectionSchema.h" -#include "graphqlservice/introspection/SchemaObject.h" -#include "graphqlservice/introspection/TypeObject.h" +#include "graphqlservice/introspection/DirectiveObject.h" +#include "graphqlservice/introspection/EnumValueObject.h" #include "graphqlservice/introspection/FieldObject.h" #include "graphqlservice/introspection/InputValueObject.h" -#include "graphqlservice/introspection/EnumValueObject.h" -#include "graphqlservice/introspection/DirectiveObject.h" +#include "graphqlservice/introspection/SchemaObject.h" +#include "graphqlservice/introspection/TypeObject.h" namespace graphql::introspection { @@ -168,9 +168,20 @@ std::optional>> Type::getPossibleTypes possibleTypes.end(), result->begin(), [](const auto& entry) { - return std::make_shared(std::make_shared(entry.lock())); + auto typeEntry = entry.lock(); + + return typeEntry && typeEntry->kind() == introspection::TypeKind::OBJECT + ? std::make_shared(std::make_shared(std::move(typeEntry))) + : std::shared_ptr {}; }); + result->erase(std::remove_if(result->begin(), + result->end(), + [](const auto& entry) noexcept { + return entry != nullptr; + }), + result->cend()); + return result; } @@ -246,7 +257,8 @@ std::optional Type::getSpecifiedByURL() const { const auto specifiedByURL = _type->specifiedByURL(); - return { specifiedByURL.empty() ? std::nullopt : std::make_optional(specifiedByURL) }; + return { specifiedByURL.empty() ? std::nullopt + : std::make_optional(specifiedByURL) }; } Field::Field(const std::shared_ptr& field) diff --git a/src/Schema.cpp b/src/Schema.cpp index 198702f7..efe070ac 100644 --- a/src/Schema.cpp +++ b/src/Schema.cpp @@ -235,8 +235,7 @@ void ObjectType::AddInterfaces(std::vector> for (const auto& interface : _interfaces) { - std::const_pointer_cast(interface)->AddPossibleType( - std::static_pointer_cast(shared_from_this())); + std::const_pointer_cast(interface)->AddPossibleType(shared_from_this()); } } @@ -278,7 +277,7 @@ InterfaceType::InterfaceType(init&& params) { } -void InterfaceType::AddPossibleType(std::weak_ptr possibleType) +void InterfaceType::AddPossibleType(std::weak_ptr possibleType) { _possibleTypes.push_back(possibleType); } @@ -286,6 +285,11 @@ void InterfaceType::AddPossibleType(std::weak_ptr possibleType) void InterfaceType::AddInterfaces(std::vector>&& interfaces) { _interfaces = std::move(interfaces); + + for (const auto& interface : _interfaces) + { + std::const_pointer_cast(interface)->AddPossibleType(shared_from_this()); + } } void InterfaceType::AddFields(std::vector>&& fields) @@ -308,6 +312,11 @@ const std::vector>& InterfaceType::possibleTypes() return _possibleTypes; } +const std::vector>& InterfaceType::interfaces() const noexcept +{ + return _interfaces; +} + struct UnionType::init { std::string_view name; diff --git a/src/Validation.cpp b/src/Validation.cpp index d67e5820..34f0e3f2 100644 --- a/src/Validation.cpp +++ b/src/Validation.cpp @@ -403,7 +403,15 @@ ValidateExecutableVisitor::ValidateExecutableVisitor(std::shared_ptrpossibleTypes(); - matchingTypes.reserve(possibleTypes.size()); + if (kind == introspection::TypeKind::INTERFACE) + { + matchingTypes.reserve(possibleTypes.size() + 1); + matchingTypes.emplace(name); + } + else + { + matchingTypes.reserve(possibleTypes.size()); + } for (const auto& possibleType : possibleTypes) { @@ -773,26 +781,46 @@ void ValidateExecutableVisitor::visitOperationDefinition(const peg::ast_node& op } _scopedType = itrType->second; + _introspectionFieldCount = 0; _fieldCount = 0; const auto& selection = *operationDefinition.children.back(); visitSelection(selection); - if (_fieldCount > 1 && operationType == strSubscription) + if (operationType == strSubscription) { - // https://spec.graphql.org/October2021/#sec-Single-root-field - auto position = operationDefinition.begin(); - std::ostringstream error; + if (_fieldCount > 1) + { + // https://spec.graphql.org/October2021/#sec-Single-root-field + auto position = operationDefinition.begin(); + std::ostringstream error; - error << "Subscription with more than one root field"; + error << "Subscription with more than one root field"; - if (!operationName.empty()) - { - error << " name: " << operationName; + if (!operationName.empty()) + { + error << " name: " << operationName; + } + + _errors.push_back({ error.str(), { position.line, position.column } }); } - _errors.push_back({ error.str(), { position.line, position.column } }); + if (_introspectionFieldCount != 0) + { + // https://spec.graphql.org/October2021/#sec-Single-root-field + auto position = operationDefinition.begin(); + std::ostringstream error; + + error << "Subscription with Introspection root field"; + + if (!operationName.empty()) + { + error << " name: " << operationName; + } + + _errors.push_back({ error.str(), { position.line, position.column } }); + } } _scopedType.reset(); @@ -1622,7 +1650,7 @@ void ValidateExecutableVisitor::visitField(const peg::ast_node& field) std::list argumentNames; peg::on_first_child(field, - [this, &name, &validateArguments, &argumentLocations, &argumentNames]( + [this, name, &validateArguments, &argumentLocations, &argumentNames]( const peg::ast_node& child) { for (auto& argument : child.children) { @@ -1760,8 +1788,10 @@ void ValidateExecutableVisitor::visitField(const peg::ast_node& field) auto outerType = std::move(_scopedType); auto outerFields = std::move(_selectionFields); auto outerFieldCount = _fieldCount; + auto outerIntrospectionFieldCount = _introspectionFieldCount; _fieldCount = 0; + _introspectionFieldCount = 0; _selectionFields.clear(); _scopedType = std::move(innerType); @@ -1771,6 +1801,7 @@ void ValidateExecutableVisitor::visitField(const peg::ast_node& field) _scopedType = std::move(outerType); _selectionFields = std::move(outerFields); subFieldCount = _fieldCount; + _introspectionFieldCount = outerIntrospectionFieldCount; _fieldCount = outerFieldCount; } @@ -1787,6 +1818,14 @@ void ValidateExecutableVisitor::visitField(const peg::ast_node& field) } ++_fieldCount; + + constexpr auto c_introspectionFieldPrefix = R"gql(__)gql"sv; + + if (name.size() >= c_introspectionFieldPrefix.size() + && name.substr(0, c_introspectionFieldPrefix.size()) == c_introspectionFieldPrefix) + { + ++_introspectionFieldCount; + } } void ValidateExecutableVisitor::visitFragmentSpread(const peg::ast_node& fragmentSpread) diff --git a/test/ValidationTests.cpp b/test/ValidationTests.cpp index d03d0506..e14aa1fa 100644 --- a/test/ValidationTests.cpp +++ b/test/ValidationTests.cpp @@ -268,7 +268,7 @@ TEST_F(ValidationExamplesCase, CounterExample112) ASSERT_EQ(errors.size(), 1); EXPECT_EQ( - R"js({"message":"Subscription with more than one root field name: sub","locations":[{"line":1,"column":1}]})js", + R"js({"message":"Subscription with Introspection root field name: sub","locations":[{"line":1,"column":1}]})js", response::toJSON(std::move(errors[0]))) << "error should match"; } From c1d8f31b7792405b9aab9719df6b12ff1370207d Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Sun, 12 Dec 2021 11:57:09 -0800 Subject: [PATCH 093/119] Fix inverted null check in getPossibleTypes --- src/Introspection.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Introspection.cpp b/src/Introspection.cpp index 8c9a781a..0438ecfa 100644 --- a/src/Introspection.cpp +++ b/src/Introspection.cpp @@ -178,7 +178,7 @@ std::optional>> Type::getPossibleTypes result->erase(std::remove_if(result->begin(), result->end(), [](const auto& entry) noexcept { - return entry != nullptr; + return entry == nullptr; }), result->cend()); From 5798230f471693a496e09caa6f7709d9a9bf48c8 Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Sun, 12 Dec 2021 11:59:24 -0800 Subject: [PATCH 094/119] Replace std::remove_if with simpler std::remove --- src/Introspection.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/Introspection.cpp b/src/Introspection.cpp index 0438ecfa..5ac539e9 100644 --- a/src/Introspection.cpp +++ b/src/Introspection.cpp @@ -175,11 +175,7 @@ std::optional>> Type::getPossibleTypes : std::shared_ptr {}; }); - result->erase(std::remove_if(result->begin(), - result->end(), - [](const auto& entry) noexcept { - return entry == nullptr; - }), + result->erase(std::remove(result->begin(), result->end(), std::shared_ptr {}), result->cend()); return result; From 6ed120997492c825317fc3b76c165fe1c071eb00 Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Sun, 12 Dec 2021 14:22:48 -0800 Subject: [PATCH 095/119] Simplify more std::remove_if calls just checking for null --- samples/learn/DroidData.cpp | 6 +----- samples/learn/HumanData.cpp | 6 +----- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/samples/learn/DroidData.cpp b/samples/learn/DroidData.cpp index 79793c21..630d6ee8 100644 --- a/samples/learn/DroidData.cpp +++ b/samples/learn/DroidData.cpp @@ -55,11 +55,7 @@ std::optional>> Droid::getFriends [](const auto& wpFriend) noexcept { return make_hero(wpFriend); }); - result.erase(std::remove_if(result.begin(), - result.end(), - [](const auto& entry) noexcept { - return !entry; - }), + result.erase(std::remove(result.begin(), result.end(), std::shared_ptr {}), result.end()); return result.empty() ? std::nullopt : std::make_optional(std::move(result)); diff --git a/samples/learn/HumanData.cpp b/samples/learn/HumanData.cpp index 5364e115..4650cb94 100644 --- a/samples/learn/HumanData.cpp +++ b/samples/learn/HumanData.cpp @@ -54,11 +54,7 @@ std::optional>> Human::getFriends [](const auto& wpFriend) noexcept { return make_hero(wpFriend); }); - result.erase(std::remove_if(result.begin(), - result.end(), - [](const auto& entry) noexcept { - return !entry; - }), + result.erase(std::remove(result.begin(), result.end(), std::shared_ptr {}), result.end()); return result.empty() ? std::nullopt : std::make_optional(std::move(result)); From c29bcbfa0b299be0d7e06b878b3e182b520246b0 Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Sun, 12 Dec 2021 20:48:36 -0800 Subject: [PATCH 096/119] Support repeatable directives and preserve fragment directives --- include/Validation.h | 1 + include/graphqlservice/GraphQLService.h | 60 +++--- samples/today/TodayMock.cpp | 22 +- samples/today/TodayMock.h | 10 +- samples/today/nointrospection/TodaySchema.cpp | 8 +- samples/today/schema.today.graphql | 3 +- samples/today/schema/TodaySchema.cpp | 8 +- src/GraphQLService.cpp | 201 +++++++----------- src/Validation.cpp | 18 +- test/TodayTests.cpp | 114 +++++++--- 10 files changed, 232 insertions(+), 213 deletions(-) diff --git a/include/Validation.h b/include/Validation.h index 59f6f26d..f9a11f3c 100644 --- a/include/Validation.h +++ b/include/Validation.h @@ -37,6 +37,7 @@ using ValidateDirectiveArguments = internal::string_view_map; struct ValidateDirective { + bool isRepeatable = false; internal::sorted_set locations; ValidateDirectiveArguments arguments; }; diff --git a/include/graphqlservice/GraphQLService.h b/include/graphqlservice/GraphQLService.h index 79d71012..0ab47207 100644 --- a/include/graphqlservice/GraphQLService.h +++ b/include/graphqlservice/GraphQLService.h @@ -229,6 +229,15 @@ class await_async : public coro::suspend_always } }; +// Directive order matters, and some of them are repeatable. So rather than passing them in a +// response::Value, pass directives in something like the underlying response::MapType which +// preserves the order of the elements without complete uniqueness. +using Directives = std::vector>; + +// Traversing a fragment spread adds a new set of directives. +using FragmentDefinitionDirectiveStack = std::list>; +using FragmentSpreadDirectiveStack = std::list; + // Pass a common bundle of parameters to all of the generated Object::getField accessors in a // SelectionSet struct SelectionSetParams @@ -239,14 +248,14 @@ struct SelectionSetParams // The lifetime of each of these borrowed references is guaranteed until the future returned // by the accessor is resolved or destroyed. They are owned by the OperationData shared pointer. const std::shared_ptr& state; - const response::Value& operationDirectives; - const response::Value& fragmentDefinitionDirectives; + const Directives& operationDirectives; + const std::shared_ptr fragmentDefinitionDirectives; // Fragment directives are shared for all fields in that fragment, but they aren't kept alive // after the call to the last accessor in the fragment. If you need to keep them alive longer, - // you'll need to explicitly copy them into other instances of response::Value. - const response::Value& fragmentSpreadDirectives; - const response::Value& inlineFragmentDirectives; + // you'll need to explicitly copy them into other instances of Directives. + const std::shared_ptr fragmentSpreadDirectives; + const std::shared_ptr inlineFragmentDirectives; // Field error path to this selection set. std::optional errorPath; @@ -259,12 +268,12 @@ struct SelectionSetParams struct FieldParams : SelectionSetParams { GRAPHQLSERVICE_EXPORT explicit FieldParams( - SelectionSetParams&& selectionSetParams, response::Value directives); + SelectionSetParams&& selectionSetParams, Directives directives); // Each field owns its own field-specific directives. Once the accessor returns it will be // destroyed, but you can move it into another instance of response::Value to keep it alive // longer. - response::Value fieldDirectives; + Directives fieldDirectives; }; // Field accessors may return either a result of T, an awaitable of T, or a std::future, so at @@ -379,11 +388,11 @@ class Fragment std::string_view getType() const; const peg::ast_node& getSelection() const; - const response::Value& getDirectives() const; + const Directives& getDirectives() const; private: std::string_view _type; - response::Value _directives; + Directives _directives; std::reference_wrapper _selection; }; @@ -399,8 +408,8 @@ struct ResolverParams : SelectionSetParams { GRAPHQLSERVICE_EXPORT explicit ResolverParams(const SelectionSetParams& selectionSetParams, const peg::ast_node& field, std::string&& fieldName, response::Value arguments, - response::Value fieldDirectives, const peg::ast_node* selection, - const FragmentMap& fragments, const response::Value& variables); + Directives fieldDirectives, const peg::ast_node* selection, const FragmentMap& fragments, + const response::Value& variables); GRAPHQLSERVICE_EXPORT schema_location getLocation() const; @@ -408,7 +417,7 @@ struct ResolverParams : SelectionSetParams const peg::ast_node& field; std::string fieldName; response::Value arguments { response::Type::Map }; - response::Value fieldDirectives { response::Type::Map }; + Directives fieldDirectives; const peg::ast_node* selection; // These values remain unchanged for the entire operation, but they're passed to each of the @@ -944,11 +953,11 @@ struct SubscriptionParams struct OperationData : std::enable_shared_from_this { explicit OperationData(std::shared_ptr state, response::Value variables, - response::Value directives, FragmentMap fragments); + Directives directives, FragmentMap fragments); std::shared_ptr state; response::Value variables; - response::Value directives; + Directives directives; FragmentMap fragments; }; @@ -956,7 +965,8 @@ struct OperationData : std::enable_shared_from_this // SelectionSet against the payload. using SubscriptionCallback = std::function; using SubscriptionArguments = std::map; -using SubscriptionFilterCallback = std::function; +using SubscriptionArgumentFilterCallback = std::function; +using SubscriptionDirectiveFilterCallback = std::function; // Subscriptions are stored in maps using these keys. using SubscriptionKey = size_t; @@ -970,7 +980,7 @@ using AwaitableDeliver = internal::Awaitable; struct SubscriptionData : std::enable_shared_from_this { explicit SubscriptionData(std::shared_ptr data, SubscriptionName&& field, - response::Value arguments, response::Value fieldDirectives, peg::ast&& query, + response::Value arguments, Directives fieldDirectives, peg::ast&& query, std::string&& operationName, SubscriptionCallback&& callback, const peg::ast_node& selection); @@ -978,7 +988,7 @@ struct SubscriptionData : std::enable_shared_from_this SubscriptionName field; response::Value arguments; - response::Value fieldDirectives; + Directives fieldDirectives; peg::ast query; std::string operationName; SubscriptionCallback callback; @@ -1023,14 +1033,14 @@ class Request : public std::enable_shared_from_this GRAPHQLSERVICE_EXPORT void deliver(const SubscriptionName& name, const SubscriptionArguments& arguments, std::shared_ptr subscriptionObject) const; GRAPHQLSERVICE_EXPORT void deliver(const SubscriptionName& name, - const SubscriptionArguments& arguments, const SubscriptionArguments& directives, + const SubscriptionArguments& arguments, const Directives& directives, std::shared_ptr subscriptionObject) const; GRAPHQLSERVICE_EXPORT void deliver(const SubscriptionName& name, - const SubscriptionFilterCallback& applyArguments, + const SubscriptionArgumentFilterCallback& applyArguments, std::shared_ptr subscriptionObject) const; GRAPHQLSERVICE_EXPORT void deliver(const SubscriptionName& name, - const SubscriptionFilterCallback& applyArguments, - const SubscriptionFilterCallback& applyDirectives, + const SubscriptionArgumentFilterCallback& applyArguments, + const SubscriptionDirectiveFilterCallback& applyDirectives, std::shared_ptr subscriptionObject) const; GRAPHQLSERVICE_EXPORT AwaitableDeliver deliver(await_async launch, const SubscriptionName& name, @@ -1038,14 +1048,14 @@ class Request : public std::enable_shared_from_this GRAPHQLSERVICE_EXPORT AwaitableDeliver deliver(await_async launch, const SubscriptionName& name, const SubscriptionArguments& arguments, std::shared_ptr subscriptionObject) const; GRAPHQLSERVICE_EXPORT AwaitableDeliver deliver(await_async launch, const SubscriptionName& name, - const SubscriptionArguments& arguments, const SubscriptionArguments& directives, + const SubscriptionArguments& arguments, const Directives& directives, std::shared_ptr subscriptionObject) const; GRAPHQLSERVICE_EXPORT AwaitableDeliver deliver(await_async launch, const SubscriptionName& name, - const SubscriptionFilterCallback& applyArguments, + const SubscriptionArgumentFilterCallback& applyArguments, std::shared_ptr subscriptionObject) const; GRAPHQLSERVICE_EXPORT AwaitableDeliver deliver(await_async launch, const SubscriptionName& name, - const SubscriptionFilterCallback& applyArguments, - const SubscriptionFilterCallback& applyDirectives, + const SubscriptionArgumentFilterCallback& applyArguments, + const SubscriptionDirectiveFilterCallback& applyDirectives, std::shared_ptr subscriptionObject) const; private: diff --git a/samples/today/TodayMock.cpp b/samples/today/TodayMock.cpp index 1e1bd736..62baed4a 100644 --- a/samples/today/TodayMock.cpp +++ b/samples/today/TodayMock.cpp @@ -4,12 +4,12 @@ #include "TodayMock.h" #include "AppointmentConnectionObject.h" -#include "TaskConnectionObject.h" +#include "CompleteTaskPayloadObject.h" +#include "ExpensiveObject.h" #include "FolderConnectionObject.h" -#include "UnionTypeObject.h" #include "NestedTypeObject.h" -#include "ExpensiveObject.h" -#include "CompleteTaskPayloadObject.h" +#include "TaskConnectionObject.h" +#include "UnionTypeObject.h" #include #include @@ -501,10 +501,16 @@ std::stack NestedType::_capturedParams; NestedType::NestedType(service::FieldParams&& params, int depth) : depth(depth) { - _capturedParams.push({ response::Value(params.operationDirectives), - response::Value(params.fragmentDefinitionDirectives), - response::Value(params.fragmentSpreadDirectives), - response::Value(params.inlineFragmentDirectives), + _capturedParams.push({ { params.operationDirectives }, + params.fragmentDefinitionDirectives->empty() + ? service::Directives {} + : service::Directives { params.fragmentDefinitionDirectives->front().get() }, + params.fragmentSpreadDirectives->empty() + ? service::Directives {} + : service::Directives { params.fragmentSpreadDirectives->front() }, + params.inlineFragmentDirectives->empty() + ? service::Directives {} + : service::Directives { params.inlineFragmentDirectives->front() }, std::move(params.fieldDirectives) }); } diff --git a/samples/today/TodayMock.h b/samples/today/TodayMock.h index 00bb84cb..79d26baa 100644 --- a/samples/today/TodayMock.h +++ b/samples/today/TodayMock.h @@ -571,13 +571,13 @@ class NodeChange struct CapturedParams { // Copied in the constructor - const response::Value operationDirectives; - const response::Value fragmentDefinitionDirectives; - const response::Value fragmentSpreadDirectives; - const response::Value inlineFragmentDirectives; + const service::Directives operationDirectives; + const service::Directives fragmentDefinitionDirectives; + const service::Directives fragmentSpreadDirectives; + const service::Directives inlineFragmentDirectives; // Moved in the constructor - const response::Value fieldDirectives; + const service::Directives fieldDirectives; }; class NestedType diff --git a/samples/today/nointrospection/TodaySchema.cpp b/samples/today/nointrospection/TodaySchema.cpp index c17d5c23..b251a3dc 100644 --- a/samples/today/nointrospection/TodaySchema.cpp +++ b/samples/today/nointrospection/TodaySchema.cpp @@ -262,11 +262,6 @@ void AddTypesToSchema(const std::shared_ptr& schema) schema->AddDirective(schema::Directive::Make(R"gql(id)gql"sv, R"md()md"sv, { introspection::DirectiveLocation::FIELD_DEFINITION }, {}, false)); - schema->AddDirective(schema::Directive::Make(R"gql(subscriptionTag)gql"sv, R"md()md"sv, { - introspection::DirectiveLocation::SUBSCRIPTION - }, { - schema::InputValue::Make(R"gql(field)gql"sv, R"md()md"sv, schema->LookupType(R"gql(String)gql"sv), R"gql()gql"sv) - }, true)); schema->AddDirective(schema::Directive::Make(R"gql(queryTag)gql"sv, R"md()md"sv, { introspection::DirectiveLocation::QUERY }, { @@ -292,6 +287,9 @@ void AddTypesToSchema(const std::shared_ptr& schema) }, { schema::InputValue::Make(R"gql(inlineFragment)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(String)gql"sv)), R"gql()gql"sv) }, false)); + schema->AddDirective(schema::Directive::Make(R"gql(repeatableOnField)gql"sv, R"md()md"sv, { + introspection::DirectiveLocation::FIELD + }, {}, true)); schema->AddQueryType(typeQuery); schema->AddMutationType(typeMutation); diff --git a/samples/today/schema.today.graphql b/samples/today/schema.today.graphql index 86cf0a7b..53056ab0 100644 --- a/samples/today/schema.today.graphql +++ b/samples/today/schema.today.graphql @@ -111,8 +111,6 @@ type Subscription { nodeChange(id: ID!): Node! } -directive @subscriptionTag(field: String) repeatable on SUBSCRIPTION - scalar DateTime @specifiedBy(url: "https://en.wikipedia.org/wiki/ISO_8601") enum TaskState { @@ -151,6 +149,7 @@ directive @fieldTag(field: String!) on FIELD directive @fragmentDefinitionTag(fragmentDefinition: String!) on FRAGMENT_DEFINITION directive @fragmentSpreadTag(fragmentSpread: String!) on FRAGMENT_SPREAD directive @inlineFragmentTag(inlineFragment: String!) on INLINE_FRAGMENT +directive @repeatableOnField repeatable on FIELD "Infinitely nestable type which can be used with nested fragments to test directive handling" type NestedType { diff --git a/samples/today/schema/TodaySchema.cpp b/samples/today/schema/TodaySchema.cpp index 801e0c12..cabeee6a 100644 --- a/samples/today/schema/TodaySchema.cpp +++ b/samples/today/schema/TodaySchema.cpp @@ -265,11 +265,6 @@ void AddTypesToSchema(const std::shared_ptr& schema) schema->AddDirective(schema::Directive::Make(R"gql(id)gql"sv, R"md()md"sv, { introspection::DirectiveLocation::FIELD_DEFINITION }, {}, false)); - schema->AddDirective(schema::Directive::Make(R"gql(subscriptionTag)gql"sv, R"md()md"sv, { - introspection::DirectiveLocation::SUBSCRIPTION - }, { - schema::InputValue::Make(R"gql(field)gql"sv, R"md()md"sv, schema->LookupType(R"gql(String)gql"sv), R"gql()gql"sv) - }, true)); schema->AddDirective(schema::Directive::Make(R"gql(queryTag)gql"sv, R"md()md"sv, { introspection::DirectiveLocation::QUERY }, { @@ -295,6 +290,9 @@ void AddTypesToSchema(const std::shared_ptr& schema) }, { schema::InputValue::Make(R"gql(inlineFragment)gql"sv, R"md()md"sv, schema->WrapType(introspection::TypeKind::NON_NULL, schema->LookupType(R"gql(String)gql"sv)), R"gql()gql"sv) }, false)); + schema->AddDirective(schema::Directive::Make(R"gql(repeatableOnField)gql"sv, R"md()md"sv, { + introspection::DirectiveLocation::FIELD + }, {}, true)); schema->AddQueryType(typeQuery); schema->AddMutationType(typeMutation); diff --git a/src/GraphQLService.cpp b/src/GraphQLService.cpp index 9157f843..68f154b9 100644 --- a/src/GraphQLService.cpp +++ b/src/GraphQLService.cpp @@ -164,7 +164,7 @@ response::Value schema_exception::getErrors() return buildErrorValues(std::move(_structuredErrors)); } -FieldParams::FieldParams(SelectionSetParams&& selectionSetParams, response::Value directives) +FieldParams::FieldParams(SelectionSetParams&& selectionSetParams, Directives directives) : SelectionSetParams(std::move(selectionSetParams)) , fieldDirectives(std::move(directives)) { @@ -337,27 +337,26 @@ class DirectiveVisitor void visit(const peg::ast_node& directives); bool shouldSkip() const; - response::Value getDirectives(); + Directives getDirectives(); private: const response::Value& _variables; - response::Value _directives; + Directives _directives; }; DirectiveVisitor::DirectiveVisitor(const response::Value& variables) : _variables(variables) - , _directives(response::Type::Map) { } void DirectiveVisitor::visit(const peg::ast_node& directives) { - response::Value result(response::Type::Map); + Directives result; for (const auto& directive : directives.children) { - std::string directiveName; + std::string_view directiveName; peg::on_first_child(*directive, [&directiveName](const peg::ast_node& child) { @@ -384,13 +383,13 @@ void DirectiveVisitor::visit(const peg::ast_node& directives) } }); - result.emplace_back(std::move(directiveName), std::move(directiveArguments)); + result.emplace_back(directiveName, std::move(directiveArguments)); } _directives = std::move(result); } -response::Value DirectiveVisitor::getDirectives() +Directives DirectiveVisitor::getDirectives() { auto result = std::move(_directives); @@ -399,15 +398,19 @@ response::Value DirectiveVisitor::getDirectives() bool DirectiveVisitor::shouldSkip() const { - static const std::array, 2> skippedNames = { - std::make_pair(true, "skip"), - std::make_pair(false, "include"), + constexpr std::array, 2> c_skippedDirectives = { + std::make_pair(true, R"gql(skip)gql"sv), + std::make_pair(false, R"gql(include)gql"sv), }; - for (const auto& entry : skippedNames) + for (const auto& entry : c_skippedDirectives) { const bool skip = entry.first; - auto itrDirective = _directives.find(entry.second); + auto itrDirective = std::find_if(_directives.cbegin(), + _directives.cend(), + [directiveName = entry.second](const auto& directive) noexcept { + return directive.first == directiveName; + }); if (itrDirective == _directives.end()) { @@ -468,7 +471,6 @@ bool DirectiveVisitor::shouldSkip() const Fragment::Fragment(const peg::ast_node& fragmentDefinition, const response::Value& variables) : _type(fragmentDefinition.children[1]->children.front()->string_view()) - , _directives(response::Type::Map) , _selection(*(fragmentDefinition.children.back())) { peg::on_first_child(fragmentDefinition, @@ -490,14 +492,14 @@ const peg::ast_node& Fragment::getSelection() const return _selection.get(); } -const response::Value& Fragment::getDirectives() const +const Directives& Fragment::getDirectives() const { return _directives; } ResolverParams::ResolverParams(const SelectionSetParams& selectionSetParams, const peg::ast_node& field, std::string&& fieldName, response::Value arguments, - response::Value fieldDirectives, const peg::ast_node* selection, const FragmentMap& fragments, + Directives fieldDirectives, const peg::ast_node* selection, const FragmentMap& fragments, const response::Value& variables) : SelectionSetParams(selectionSetParams) , field(field) @@ -713,17 +715,6 @@ AwaitableResolver ModifiedResult::convert( co_return std::move(document); } -// As we recursively expand fragment spreads and inline fragments, we want to accumulate the -// directives at each location and merge them with any directives included in outer fragments to -// build the complete set of directives for nested fragments. Directives with the same name at the -// same location will be overwritten by the innermost fragment. -struct FragmentDirectives -{ - response::Value fragmentDefinitionDirectives; - response::Value fragmentSpreadDirectives; - response::Value inlineFragmentDirectives; -}; - // SelectionVisitor visits the AST and resolves a field or fragment, unless it's skipped by // a directive or type condition. class SelectionVisitor @@ -744,7 +735,7 @@ class SelectionVisitor const ResolverContext _resolverContext; const std::shared_ptr& _state; - const response::Value& _operationDirectives; + const Directives& _operationDirectives; const std::optional> _path; const await_async _launch; const FragmentMap& _fragments; @@ -752,7 +743,9 @@ class SelectionVisitor const TypeNames& _typeNames; const ResolverMap& _resolvers; - std::list _fragmentDirectives; + std::shared_ptr _fragmentDefinitionDirectives; + std::shared_ptr _fragmentSpreadDirectives; + std::shared_ptr _inlineFragmentDirectives; internal::string_view_set _names; std::vector> _values; }; @@ -771,10 +764,18 @@ SelectionVisitor::SelectionVisitor(const SelectionSetParams& selectionSetParams, , _variables(variables) , _typeNames(typeNames) , _resolvers(resolvers) + , _fragmentDefinitionDirectives { selectionSetParams.fragmentDefinitionDirectives } + , _fragmentSpreadDirectives { selectionSetParams.fragmentSpreadDirectives } + , _inlineFragmentDirectives { selectionSetParams.inlineFragmentDirectives } { - _fragmentDirectives.push_back({ response::Value(response::Type::Map), - response::Value(response::Type::Map), - response::Value(response::Type::Map) }); + static const Directives s_emptyFragmentDefinitionDirectives; + + // Traversing a SelectionSet from an Object type field should start tracking new fragment + // directives. The outer fragment directives are still there in the FragmentSpreadDirectiveStack + // if the field accessors want to inspect them. + _fragmentDefinitionDirectives->push_front(std::cref(s_emptyFragmentDefinitionDirectives)); + _fragmentSpreadDirectives->push_front({}); + _inlineFragmentDirectives->push_front({}); _names.reserve(count); _values.reserve(count); @@ -883,9 +884,9 @@ void SelectionVisitor::visitField(const peg::ast_node& field) _resolverContext, _state, _operationDirectives, - _fragmentDirectives.back().fragmentDefinitionDirectives, - _fragmentDirectives.back().fragmentSpreadDirectives, - _fragmentDirectives.back().inlineFragmentDirectives, + _fragmentDefinitionDirectives, + _fragmentSpreadDirectives, + _inlineFragmentDirectives, std::make_optional(field_path { _path, path_segment { alias } }), _launch, }; @@ -978,33 +979,8 @@ void SelectionVisitor::visitFragmentSpread(const peg::ast_node& fragmentSpread) return; } - auto fragmentSpreadDirectives = directiveVisitor.getDirectives(); - - // Merge outer fragment spread directives as long as they don't conflict. - for (const auto& entry : _fragmentDirectives.back().fragmentSpreadDirectives) - { - if (fragmentSpreadDirectives.find(entry.first) == fragmentSpreadDirectives.end()) - { - fragmentSpreadDirectives.emplace_back(std::string { entry.first }, - response::Value(entry.second)); - } - } - - response::Value fragmentDefinitionDirectives(itr->second.getDirectives()); - - // Merge outer fragment definition directives as long as they don't conflict. - for (const auto& entry : _fragmentDirectives.back().fragmentDefinitionDirectives) - { - if (fragmentDefinitionDirectives.find(entry.first) == fragmentDefinitionDirectives.end()) - { - fragmentDefinitionDirectives.emplace_back(std::string { entry.first }, - response::Value(entry.second)); - } - } - - _fragmentDirectives.push_back({ std::move(fragmentDefinitionDirectives), - std::move(fragmentSpreadDirectives), - response::Value(_fragmentDirectives.back().inlineFragmentDirectives) }); + _fragmentDefinitionDirectives->push_front(itr->second.getDirectives()); + _fragmentSpreadDirectives->push_front(directiveVisitor.getDirectives()); const size_t count = itr->second.getSelection().children.size(); @@ -1019,7 +995,8 @@ void SelectionVisitor::visitFragmentSpread(const peg::ast_node& fragmentSpread) visit(*selection); } - _fragmentDirectives.pop_back(); + _fragmentSpreadDirectives->pop_front(); + _fragmentDefinitionDirectives->pop_front(); } void SelectionVisitor::visitInlineFragment(const peg::ast_node& inlineFragment) @@ -1048,23 +1025,7 @@ void SelectionVisitor::visitInlineFragment(const peg::ast_node& inlineFragment) { peg::on_first_child(inlineFragment, [this, &directiveVisitor](const peg::ast_node& child) { - auto inlineFragmentDirectives = directiveVisitor.getDirectives(); - - // Merge outer inline fragment directives as long as they don't conflict. - for (const auto& entry : _fragmentDirectives.back().inlineFragmentDirectives) - { - if (inlineFragmentDirectives.find(entry.first) - == inlineFragmentDirectives.end()) - { - inlineFragmentDirectives.emplace_back(std::string { entry.first }, - response::Value(entry.second)); - } - } - - _fragmentDirectives.push_back( - { response::Value(_fragmentDirectives.back().fragmentDefinitionDirectives), - response::Value(_fragmentDirectives.back().fragmentSpreadDirectives), - std::move(inlineFragmentDirectives) }); + _inlineFragmentDirectives->push_front(directiveVisitor.getDirectives()); const size_t count = child.children.size(); @@ -1079,7 +1040,7 @@ void SelectionVisitor::visitInlineFragment(const peg::ast_node& inlineFragment) visit(*selection); } - _fragmentDirectives.pop_back(); + _inlineFragmentDirectives->pop_front(); }); } } @@ -1179,7 +1140,7 @@ void Object::endSelectionSet(const SelectionSetParams&) const } OperationData::OperationData(std::shared_ptr state, response::Value variables, - response::Value directives, FragmentMap fragments) + Directives directives, FragmentMap fragments) : state(std::move(state)) , variables(std::move(variables)) , directives(std::move(directives)) @@ -1243,7 +1204,7 @@ class OperationDefinitionVisitor }; SubscriptionData::SubscriptionData(std::shared_ptr data, SubscriptionName&& field, - response::Value arguments, response::Value fieldDirectives, peg::ast&& query, + response::Value arguments, Directives fieldDirectives, peg::ast&& query, std::string&& operationName, SubscriptionCallback&& callback, const peg::ast_node& selection) : data(std::move(data)) , field(std::move(field)) @@ -1262,7 +1223,7 @@ OperationDefinitionVisitor::OperationDefinitionVisitor(ResolverContext resolverC : _resolverContext(resolverContext) , _launch(launch) , _params(std::make_shared( - std::move(state), std::move(variables), response::Value(), std::move(fragments))) + std::move(state), std::move(variables), Directives {}, std::move(fragments))) , _operations(operations) { } @@ -1321,7 +1282,7 @@ void OperationDefinitionVisitor::visit( _params->variables = std::move(operationVariables); - response::Value operationDirectives(response::Type::Map); + Directives operationDirectives; peg::on_first_child(operationDefinition, [this, &operationDirectives](const peg::ast_node& child) { @@ -1333,14 +1294,13 @@ void OperationDefinitionVisitor::visit( _params->directives = std::move(operationDirectives); - const response::Value emptyFragmentDirectives(response::Type::Map); const SelectionSetParams selectionSetParams { _resolverContext, _params->state, _params->directives, - emptyFragmentDirectives, - emptyFragmentDirectives, - emptyFragmentDirectives, + std::make_shared(), + std::make_shared(), + std::make_shared(), std::nullopt, _launch, }; @@ -1375,7 +1335,7 @@ class SubscriptionDefinitionVisitor const std::shared_ptr& _subscriptionObject; SubscriptionName _field; response::Value _arguments; - response::Value _fieldDirectives; + Directives _fieldDirectives; std::shared_ptr _result; }; @@ -1423,7 +1383,7 @@ void SubscriptionDefinitionVisitor::visit(const peg::ast_node& operationDefiniti } } - response::Value directives(response::Type::Map); + Directives directives; peg::on_first_child(operationDefinition, [this, &directives](const peg::ast_node& child) { @@ -1816,14 +1776,13 @@ AwaitableSubscribe Request::subscribe( { const auto& operation = itrOperation->second; const auto& registration = spThis->_subscriptions.at(key); - response::Value emptyFragmentDirectives(response::Type::Map); const SelectionSetParams selectionSetParams { ResolverContext::NotifySubscribe, registration->data->state, registration->data->directives, - emptyFragmentDirectives, - emptyFragmentDirectives, - emptyFragmentDirectives, + std::make_shared(), + std::make_shared(), + std::make_shared(), {}, launch, }; @@ -1886,14 +1845,13 @@ AwaitableUnsubscribe Request::unsubscribe(await_async launch, SubscriptionKey ke { const auto& operation = itrOperation->second; const auto& registration = spThis->_subscriptions.at(key); - response::Value emptyFragmentDirectives(response::Type::Map); const SelectionSetParams selectionSetParams { ResolverContext::NotifyUnsubscribe, registration->data->state, registration->data->directives, - emptyFragmentDirectives, - emptyFragmentDirectives, - emptyFragmentDirectives, + std::make_shared(), + std::make_shared(), + std::make_shared(), {}, launch, }; @@ -1923,22 +1881,22 @@ void Request::deliver(const SubscriptionName& name, const SubscriptionArguments& } void Request::deliver(const SubscriptionName& name, const SubscriptionArguments& arguments, - const SubscriptionArguments& directives, std::shared_ptr subscriptionObject) const + const Directives& directives, std::shared_ptr subscriptionObject) const { deliver(std::launch::deferred, name, arguments, directives, std::move(subscriptionObject)) .get(); } void Request::deliver(const SubscriptionName& name, - const SubscriptionFilterCallback& applyArguments, + const SubscriptionArgumentFilterCallback& applyArguments, std::shared_ptr subscriptionObject) const { deliver(std::launch::deferred, name, applyArguments, std::move(subscriptionObject)).get(); } void Request::deliver(const SubscriptionName& name, - const SubscriptionFilterCallback& applyArguments, - const SubscriptionFilterCallback& applyDirectives, + const SubscriptionArgumentFilterCallback& applyArguments, + const SubscriptionDirectiveFilterCallback& applyDirectives, std::shared_ptr subscriptionObject) const { deliver(std::launch::deferred, @@ -1955,34 +1913,34 @@ AwaitableDeliver Request::deliver(await_async launch, const SubscriptionName& na return deliver(launch, name, SubscriptionArguments {}, - SubscriptionArguments {}, + Directives {}, std::move(subscriptionObject)); } AwaitableDeliver Request::deliver(await_async launch, const SubscriptionName& name, const SubscriptionArguments& arguments, std::shared_ptr subscriptionObject) const { - return deliver(launch, - name, - arguments, - SubscriptionArguments {}, - std::move(subscriptionObject)); + return deliver(launch, name, arguments, Directives {}, std::move(subscriptionObject)); } AwaitableDeliver Request::deliver(await_async launch, const SubscriptionName& name, - const SubscriptionArguments& arguments, const SubscriptionArguments& directives, + const SubscriptionArguments& arguments, const Directives& directives, std::shared_ptr subscriptionObject) const { - SubscriptionFilterCallback argumentsMatch = + SubscriptionArgumentFilterCallback argumentsMatch = [&arguments](response::MapType::const_reference required) noexcept -> bool { auto itrArgument = arguments.find(required.first); return (itrArgument != arguments.end() && itrArgument->second == required.second); }; - SubscriptionFilterCallback directivesMatch = - [&directives](response::MapType::const_reference required) noexcept -> bool { - auto itrDirective = directives.find(required.first); + SubscriptionDirectiveFilterCallback directivesMatch = + [&directives](Directives::const_reference required) noexcept -> bool { + auto itrDirective = std::find_if(directives.cbegin(), + directives.cend(), + [directiveName = required.first](const auto& directive) noexcept { + return directive.first == directiveName; + }); return (itrDirective != directives.end() && itrDirective->second == required.second); }; @@ -1991,22 +1949,22 @@ AwaitableDeliver Request::deliver(await_async launch, const SubscriptionName& na } AwaitableDeliver Request::deliver(await_async launch, const SubscriptionName& name, - const SubscriptionFilterCallback& applyArguments, + const SubscriptionArgumentFilterCallback& applyArguments, std::shared_ptr subscriptionObject) const { return deliver( launch, name, applyArguments, - [](response::MapType::const_reference) noexcept { + [](Directives::const_reference) noexcept { return true; }, std::move(subscriptionObject)); } AwaitableDeliver Request::deliver(await_async launch, const SubscriptionName& name, - const SubscriptionFilterCallback& applyArguments, - const SubscriptionFilterCallback& applyDirectives, + const SubscriptionArgumentFilterCallback& applyArguments, + const SubscriptionDirectiveFilterCallback& applyDirectives, std::shared_ptr subscriptionObject) const { const auto itrOperation = _operations.find(strSubscription); @@ -2085,14 +2043,13 @@ AwaitableDeliver Request::deliver(await_async launch, const SubscriptionName& na for (const auto& registration : registrations) { - response::Value emptyFragmentDirectives(response::Type::Map); const SelectionSetParams selectionSetParams { ResolverContext::Subscription, registration->data->state, registration->data->directives, - emptyFragmentDirectives, - emptyFragmentDirectives, - emptyFragmentDirectives, + std::make_shared(), + std::make_shared(), + std::make_shared(), std::nullopt, launch, }; diff --git a/src/Validation.cpp b/src/Validation.cpp index 34f0e3f2..79197c74 100644 --- a/src/Validation.cpp +++ b/src/Validation.cpp @@ -468,6 +468,8 @@ ValidateExecutableVisitor::ValidateExecutableVisitor(std::shared_ptrargs(); ValidateDirective validateDirective; + validateDirective.isRepeatable = directive->isRepeatable(); + for (const auto location : locations) { validateDirective.locations.emplace(location); @@ -1977,27 +1979,27 @@ void ValidateExecutableVisitor::visitDirectives( directiveName = child.string_view(); }); - if (!uniqueDirectives.emplace(directiveName).second) + const auto itrDirective = _directives.find(directiveName); + + if (itrDirective == _directives.end()) { - // https://spec.graphql.org/October2021/#sec-Directives-Are-Unique-Per-Location + // https://spec.graphql.org/October2021/#sec-Directives-Are-Defined auto position = directive->begin(); std::ostringstream message; - message << "Conflicting directive name: " << directiveName; + message << "Undefined directive name: " << directiveName; _errors.push_back({ message.str(), { position.line, position.column } }); continue; } - auto itrDirective = _directives.find(directiveName); - - if (itrDirective == _directives.end()) + if (!itrDirective->second.isRepeatable && !uniqueDirectives.emplace(directiveName).second) { - // https://spec.graphql.org/October2021/#sec-Directives-Are-Defined + // https://spec.graphql.org/October2021/#sec-Directives-Are-Unique-Per-Location auto position = directive->begin(); std::ostringstream message; - message << "Undefined directive name: " << directiveName; + message << "Conflicting directive name: " << directiveName; _errors.push_back({ message.str(), { position.line, position.column } }); continue; diff --git a/test/TodayTests.cpp b/test/TodayTests.cpp index b47633ea..da8273c6 100644 --- a/test/TodayTests.cpp +++ b/test/TodayTests.cpp @@ -955,7 +955,7 @@ TEST_F(TodayServiceCase, NestedFragmentDirectives) inlineFragmentNested: nested @fieldTag(field: "nested3") { ...on NestedType @inlineFragmentTag(inlineFragment: "inlineFragment4") { ...on NestedType @inlineFragmentTag(inlineFragment: "inlineFragment5") { - inlineFragmentNested: nested @fieldTag(field: "nested4") { + inlineFragmentNested: nested @repeatableOnField @fieldTag(field: "nested4") @repeatableOnField { depth @fieldTag(field: "depth4") } } @@ -995,61 +995,107 @@ TEST_F(TodayServiceCase, NestedFragmentDirectives) capturedParams.pop(); const auto params1 = std::move(capturedParams.top()); capturedParams.pop(); - const auto queryTag1 = - service::ScalarArgument::require("queryTag", params1.operationDirectives); + ASSERT_EQ(size_t(1), params1.operationDirectives.size()) << "missing operation directive"; + const auto itrQueryTag1 = params1.operationDirectives.cbegin(); + ASSERT_TRUE(itrQueryTag1->first == "queryTag"sv) << "missing required directive"; + const auto& queryTag1 = itrQueryTag1->second; const auto query1 = service::StringArgument::require("query", queryTag1); const auto fragmentDefinitionCount1 = params1.fragmentDefinitionDirectives.size(); const auto fragmentSpreadCount1 = params1.fragmentSpreadDirectives.size(); const auto inlineFragmentCount1 = params1.inlineFragmentDirectives.size(); - const auto fieldTag1 = - service::ScalarArgument::require("fieldTag", params1.fieldDirectives); + ASSERT_EQ(size_t(1), params1.fieldDirectives.size()) << "missing operation directive"; + const auto itrFieldTag1 = params1.fieldDirectives.cbegin(); + ASSERT_TRUE(itrFieldTag1->first == "fieldTag"sv) << "missing required directive"; + const auto& fieldTag1 = itrFieldTag1->second; const auto field1 = service::StringArgument::require("field", fieldTag1); - const auto queryTag2 = - service::ScalarArgument::require("queryTag", params2.operationDirectives); + ASSERT_EQ(size_t(1), params2.operationDirectives.size()) << "missing operation directive"; + const auto itrQueryTag2 = params2.operationDirectives.cbegin(); + ASSERT_TRUE(itrQueryTag2->first == "queryTag"sv) << "missing required directive"; + const auto& queryTag2 = itrQueryTag2->second; const auto query2 = service::StringArgument::require("query", queryTag2); - const auto fragmentDefinitionTag2 = - service::ScalarArgument::require("fragmentDefinitionTag", - params2.fragmentDefinitionDirectives); + ASSERT_EQ(size_t(1), params2.fragmentDefinitionDirectives.size()) + << "missing fragment definition directive"; + const auto itrFragmentDefinitionTag2 = params2.fragmentDefinitionDirectives.cbegin(); + ASSERT_TRUE(itrFragmentDefinitionTag2->first == "fragmentDefinitionTag"sv) + << "missing fragment definition directive"; + const auto& fragmentDefinitionTag2 = itrFragmentDefinitionTag2->second; const auto fragmentDefinition2 = service::StringArgument::require("fragmentDefinition", fragmentDefinitionTag2); - const auto fragmentSpreadTag2 = - service::ScalarArgument::require("fragmentSpreadTag", params2.fragmentSpreadDirectives); + ASSERT_EQ(size_t(1), params2.fragmentSpreadDirectives.size()) + << "missing fragment spread directive"; + const auto itrFragmentSpreadTag2 = params2.fragmentSpreadDirectives.cbegin(); + ASSERT_TRUE(itrFragmentSpreadTag2->first == "fragmentSpreadTag"sv) + << "missing fragment spread directive"; + const auto& fragmentSpreadTag2 = itrFragmentSpreadTag2->second; const auto fragmentSpread2 = service::StringArgument::require("fragmentSpread", fragmentSpreadTag2); const auto inlineFragmentCount2 = params2.inlineFragmentDirectives.size(); - const auto fieldTag2 = - service::ScalarArgument::require("fieldTag", params2.fieldDirectives); + ASSERT_EQ(size_t(1), params2.fieldDirectives.size()) << "missing field directive"; + const auto itrFieldTag2 = params2.fieldDirectives.cbegin(); + ASSERT_TRUE(itrFieldTag2->first == "fieldTag"sv) << "missing field directive"; + const auto& fieldTag2 = itrFieldTag2->second; const auto field2 = service::StringArgument::require("field", fieldTag2); - const auto queryTag3 = - service::ScalarArgument::require("queryTag", params3.operationDirectives); + ASSERT_EQ(size_t(1), params3.operationDirectives.size()) << "missing operation directive"; + const auto itrQueryTag3 = params3.operationDirectives.cbegin(); + ASSERT_TRUE(itrQueryTag3->first == "queryTag"sv) << "missing required directive"; + const auto& queryTag3 = itrQueryTag3->second; const auto query3 = service::StringArgument::require("query", queryTag3); - const auto fragmentDefinitionTag3 = - service::ScalarArgument::require("fragmentDefinitionTag", - params3.fragmentDefinitionDirectives); + ASSERT_EQ(size_t(1), params3.fragmentDefinitionDirectives.size()) + << "missing fragment definition directive"; + const auto itrFragmentDefinitionTag3 = params3.fragmentDefinitionDirectives.cbegin(); + ASSERT_TRUE(itrFragmentDefinitionTag3->first == "fragmentDefinitionTag"sv) + << "missing fragment definition directive"; + const auto& fragmentDefinitionTag3 = itrFragmentDefinitionTag3->second; const auto fragmentDefinition3 = service::StringArgument::require("fragmentDefinition", fragmentDefinitionTag3); - const auto fragmentSpreadTag3 = - service::ScalarArgument::require("fragmentSpreadTag", params3.fragmentSpreadDirectives); + ASSERT_EQ(size_t(1), params3.fragmentSpreadDirectives.size()) + << "missing fragment spread directive"; + const auto itrFragmentSpreadTag3 = params3.fragmentSpreadDirectives.cbegin(); + ASSERT_TRUE(itrFragmentSpreadTag3->first == "fragmentSpreadTag"sv) + << "missing fragment spread directive"; + const auto& fragmentSpreadTag3 = itrFragmentSpreadTag3->second; const auto fragmentSpread3 = service::StringArgument::require("fragmentSpread", fragmentSpreadTag3); - const auto inlineFragmentTag3 = - service::ScalarArgument::require("inlineFragmentTag", params3.inlineFragmentDirectives); + ASSERT_EQ(size_t(1), params3.inlineFragmentDirectives.size()) + << "missing inline fragment directive"; + const auto itrInlineFragmentTag3 = params3.inlineFragmentDirectives.cbegin(); + ASSERT_TRUE(itrInlineFragmentTag3->first == "inlineFragmentTag"sv); + const auto& inlineFragmentTag3 = itrInlineFragmentTag3->second; const auto inlineFragment3 = service::StringArgument::require("inlineFragment", inlineFragmentTag3); - const auto fieldTag3 = - service::ScalarArgument::require("fieldTag", params3.fieldDirectives); + ASSERT_EQ(size_t(1), params3.fieldDirectives.size()) << "missing field directive"; + const auto itrFieldTag3 = params3.fieldDirectives.cbegin(); + ASSERT_TRUE(itrFieldTag3->first == "fieldTag"sv) << "missing field directive"; + const auto& fieldTag3 = itrFieldTag3->second; const auto field3 = service::StringArgument::require("field", fieldTag3); - const auto queryTag4 = - service::ScalarArgument::require("queryTag", params4.operationDirectives); + ASSERT_EQ(size_t(1), params4.operationDirectives.size()) << "missing operation directive"; + const auto itrQueryTag4 = params4.operationDirectives.cbegin(); + ASSERT_TRUE(itrQueryTag4->first == "queryTag"sv) << "missing required directive"; + const auto& queryTag4 = itrQueryTag4->second; const auto query4 = service::StringArgument::require("query", queryTag4); const auto fragmentDefinitionCount4 = params4.fragmentDefinitionDirectives.size(); const auto fragmentSpreadCount4 = params4.fragmentSpreadDirectives.size(); - const auto inlineFragmentTag4 = - service::ScalarArgument::require("inlineFragmentTag", params4.inlineFragmentDirectives); + ASSERT_EQ(size_t(1), params4.inlineFragmentDirectives.size()) + << "missing inline fragment directive"; + const auto itrInlineFragmentTag4 = params4.inlineFragmentDirectives.cbegin(); + ASSERT_TRUE(itrInlineFragmentTag4->first == "inlineFragmentTag"sv); + const auto& inlineFragmentTag4 = itrInlineFragmentTag4->second; const auto inlineFragment4 = service::StringArgument::require("inlineFragment", inlineFragmentTag4); - const auto fieldTag4 = - service::ScalarArgument::require("fieldTag", params4.fieldDirectives); + ASSERT_EQ(size_t(3), params4.fieldDirectives.size()) << "missing field directive"; + const auto itrRepeatable1 = params4.fieldDirectives.cbegin(); + ASSERT_TRUE(itrRepeatable1->first == "repeatableOnField"sv) << "missing field directive"; + EXPECT_TRUE(response::Type::Map == itrRepeatable1->second.type()) + << "unexpected arguments type directive"; + EXPECT_EQ(size_t(0), itrRepeatable1->second.size()) << "extra arguments on directive"; + const auto itrFieldTag4 = itrRepeatable1 + 1; + ASSERT_TRUE(itrFieldTag4->first == "fieldTag"sv) << "missing field directive"; + const auto& fieldTag4 = itrFieldTag4->second; + const auto itrRepeatable2 = itrFieldTag4 + 1; + ASSERT_TRUE(itrRepeatable2->first == "repeatableOnField"sv) << "missing field directive"; + EXPECT_TRUE(response::Type::Map == itrRepeatable2->second.type()) + << "unexpected arguments type directive"; + EXPECT_EQ(size_t(0), itrRepeatable2->second.size()) << "extra arguments on directive"; const auto field4 = service::StringArgument::require("field", fieldTag4); ASSERT_EQ(1, depth1); @@ -1079,9 +1125,11 @@ TEST_F(TodayServiceCase, NestedFragmentDirectives) ASSERT_EQ("nested3", field3) << "remember the field directives"; ASSERT_EQ("nested", query4) << "remember the operation directives"; ASSERT_EQ(size_t(0), fragmentDefinitionCount4) - << "traversing a field to a nested object SelectionSet resets the fragment directives"; + << "traversing a field to a nested object SelectionSet resets the fragment " + "directives"; ASSERT_EQ(size_t(0), fragmentSpreadCount4) - << "traversing a field to a nested object SelectionSet resets the fragment directives"; + << "traversing a field to a nested object SelectionSet resets the fragment " + "directives"; ASSERT_EQ("inlineFragment5", inlineFragment4) << "nested inline fragments don't reset, but do overwrite on collision"; ASSERT_EQ("nested4", field4) << "remember the field directives"; From 172dff7a4bfcff31de39acc1b2f909d181161b7d Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Sun, 12 Dec 2021 23:16:31 -0800 Subject: [PATCH 097/119] Export a type erased JSON writer object --- include/graphqlservice/GraphQLResponse.h | 96 ++++++++++++++++++ src/GraphQLResponse.cpp | 82 ++++++++++++++++ src/JSONResponse.cpp | 120 ++++++++++------------- 3 files changed, 228 insertions(+), 70 deletions(-) diff --git a/include/graphqlservice/GraphQLResponse.h b/include/graphqlservice/GraphQLResponse.h index f50774b2..5f70404d 100644 --- a/include/graphqlservice/GraphQLResponse.h +++ b/include/graphqlservice/GraphQLResponse.h @@ -263,6 +263,102 @@ GRAPHQLRESPONSE_EXPORT IdType Value::release(); using AwaitableValue = internal::Awaitable; +class Writer +{ +private: + struct Concept + { + virtual ~Concept() = default; + + virtual void start_object() const = 0; + virtual void add_member(const std::string& key) const = 0; + virtual void end_object() const = 0; + + virtual void start_array() const = 0; + virtual void end_arrary() const = 0; + + virtual void write_null() const = 0; + virtual void write_string(const std::string& value) const = 0; + virtual void write_bool(bool value) const = 0; + virtual void write_int(int value) const = 0; + virtual void write_float(double value) const = 0; + }; + + template + struct Model : Concept + { + Model(std::unique_ptr&& pimpl) + : _pimpl { std::move(pimpl) } + { + } + + void start_object() const final + { + _pimpl->start_object(); + } + + void add_member(const std::string& key) const final + { + _pimpl->add_member(key); + } + + void end_object() const final + { + _pimpl->end_object(); + } + + void start_array() const final + { + _pimpl->start_array(); + } + + void end_arrary() const final + { + _pimpl->end_arrary(); + } + + void write_null() const final + { + _pimpl->write_null(); + } + + void write_string(const std::string& value) const final + { + _pimpl->write_string(value); + } + + void write_bool(bool value) const final + { + _pimpl->write_bool(value); + } + + void write_int(int value) const final + { + _pimpl->write_int(value); + } + + void write_float(double value) const final + { + _pimpl->write_float(value); + } + + private: + std::unique_ptr _pimpl; + }; + + const std::shared_ptr _concept; + +public: + template + Writer(std::unique_ptr writer) + : _concept { std::static_pointer_cast( + std::make_shared>(std::move(writer))) } + { + } + + GRAPHQLRESPONSE_EXPORT void write(Value value) const; +}; + } // namespace graphql::response #endif // GRAPHQLRESPONSE_H diff --git a/src/GraphQLResponse.cpp b/src/GraphQLResponse.cpp index 7ddaf651..f23cac12 100644 --- a/src/GraphQLResponse.cpp +++ b/src/GraphQLResponse.cpp @@ -695,4 +695,86 @@ const Value& Value::operator[](size_t index) const return std::get(_data).at(index); } +void Writer::write(Value response) const +{ + switch (response.type()) + { + case Type::Map: + { + auto members = response.release(); + + _concept->start_object(); + + for (auto& entry : members) + { + _concept->add_member(entry.first); + write(std::move(entry.second)); + } + + _concept->end_object(); + break; + } + + case Type::List: + { + auto elements = response.release(); + + _concept->start_array(); + + for (auto& entry : elements) + { + write(std::move(entry)); + } + + _concept->end_arrary(); + break; + } + + case Type::String: + case Type::EnumValue: + { + auto value = response.release(); + + _concept->write_string(value); + break; + } + + case Type::Null: + { + _concept->write_null(); + break; + } + + case Type::Boolean: + { + _concept->write_bool(response.get()); + break; + } + + case Type::Int: + { + _concept->write_int(response.get()); + break; + } + + case Type::Float: + { + _concept->write_float(response.get()); + break; + } + + case Type::Scalar: + { + write(response.release()); + break; + } + + default: + { + _concept->write_null(); + break; + } + } +} + } // namespace graphql::response diff --git a/src/JSONResponse.cpp b/src/JSONResponse.cpp index f0608f77..cc5dbacb 100644 --- a/src/JSONResponse.cpp +++ b/src/JSONResponse.cpp @@ -16,94 +16,74 @@ namespace graphql::response { -void writeResponse(rapidjson::Writer& writer, Value&& response) +class StringWriter { - switch (response.type()) +public: + StringWriter(rapidjson::StringBuffer& buffer) + : _writer { buffer } { - case Type::Map: - { - auto members = response.release(); - - writer.StartObject(); - - for (auto& entry : members) - { - writer.Key(entry.first.c_str()); - writeResponse(writer, std::move(entry.second)); - } - - writer.EndObject(); - break; - } - - case Type::List: - { - auto elements = response.release(); - - writer.StartArray(); + } - for (auto& entry : elements) - { - writeResponse(writer, std::move(entry)); - } + void start_object() + { + _writer.StartObject(); + } - writer.EndArray(); - break; - } + void add_member(const std::string& key) + { + _writer.Key(key.c_str()); + } - case Type::String: - case Type::EnumValue: - { - auto value = response.release(); + void end_object() + { + _writer.EndObject(); + } - writer.String(value.c_str()); - break; - } + void start_array() + { + _writer.StartArray(); + } - case Type::Null: - { - writer.Null(); - break; - } + void end_arrary() + { + _writer.EndArray(); + } - case Type::Boolean: - { - writer.Bool(response.get()); - break; - } + void write_null() + { + _writer.Null(); + } - case Type::Int: - { - writer.Int(response.get()); - break; - } + void write_string(const std::string& value) + { + _writer.String(value.c_str()); + } - case Type::Float: - { - writer.Double(response.get()); - break; - } + void write_bool(bool value) + { + _writer.Bool(value); + } - case Type::Scalar: - { - writeResponse(writer, response.release()); - break; - } + void write_int(int value) + { + _writer.Int(value); + } - default: - { - writer.Null(); - break; - } + void write_float(double value) + { + _writer.Double(value); } -} + +private: + rapidjson::Writer _writer; +}; std::string toJSON(Value&& response) { rapidjson::StringBuffer buffer; - rapidjson::Writer writer(buffer); + Writer writer { std::make_unique(buffer) }; - writeResponse(writer, std::move(response)); + writer.write(std::move(response)); return buffer.GetString(); } From 5291b0f9e80b4dfdc8b160e48943ae2ceea333d0 Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Mon, 13 Dec 2021 14:25:38 -0800 Subject: [PATCH 098/119] Default-init params structs in Request methods --- doc/subscriptions.md | 8 +- include/graphqlservice/GraphQLService.h | 182 +++++--- samples/client/benchmark.cpp | 3 +- samples/learn/sample.cpp | 8 +- samples/today/benchmark.cpp | 3 +- samples/today/sample.cpp | 8 +- src/GraphQLService.cpp | 566 ++++++++++++------------ test/ClientTests.cpp | 25 +- test/NoIntrospectionTests.cpp | 11 +- test/TodayTests.cpp | 325 ++++++++------ 10 files changed, 597 insertions(+), 542 deletions(-) diff --git a/doc/subscriptions.md b/doc/subscriptions.md index a693df03..d5929820 100644 --- a/doc/subscriptions.md +++ b/doc/subscriptions.md @@ -14,20 +14,20 @@ Subscriptions are created or removed by calling the `Request::subscribe` and `Request::unsubscribe` methods in [GraphQLService.h](../include/graphqlservice/GraphQLService.h): ```cpp GRAPHQLSERVICE_EXPORT SubscriptionKey subscribe( - SubscriptionParams&& params, SubscriptionCallback&& callback); + RequestSubscribeParams&& params, SubscriptionCallback&& callback); GRAPHQLSERVICE_EXPORT AwaitableSubscribe subscribe( - std::launch launch, SubscriptionParams&& params, SubscriptionCallback&& callback); + std::launch launch, RequestSubscribeParams&& params, SubscriptionCallback&& callback); GRAPHQLSERVICE_EXPORT void unsubscribe(SubscriptionKey key); GRAPHQLSERVICE_EXPORT AwaitableUnsubscribe unsubscribe(std::launch launch, SubscriptionKey key); ``` -You need to fill in a `SubscriptionParams` struct with the [parsed](./parsing.md) +You need to fill in a `RequestSubscribeParams` struct with the [parsed](./parsing.md) query and any other relevant operation parameters: ```cpp // You can still sub-class RequestState and use that in the state parameter to Request::subscribe // to add your own state to the service callbacks that you receive while executing the subscription // query. -struct SubscriptionParams +struct RequestSubscribeParams { std::shared_ptr state; peg::ast query; diff --git a/include/graphqlservice/GraphQLService.h b/include/graphqlservice/GraphQLService.h index 0ab47207..ceacd71c 100644 --- a/include/graphqlservice/GraphQLService.h +++ b/include/graphqlservice/GraphQLService.h @@ -162,7 +162,7 @@ struct await_worker_thread : coro::suspend_always } }; -// Type-erased awaitable, if you want finer grain control. +// Type-erased awaitable. class await_async : public coro::suspend_always { private: @@ -172,6 +172,7 @@ class await_async : public coro::suspend_always virtual bool await_ready() const = 0; virtual void await_suspend(coro::coroutine_handle<> h) const = 0; + virtual void await_resume() const = 0; }; template @@ -192,6 +193,11 @@ class await_async : public coro::suspend_always _pimpl->await_suspend(std::move(h)); } + void await_resume() const final + { + _pimpl->await_resume(); + } + private: std::shared_ptr _pimpl; }; @@ -199,12 +205,21 @@ class await_async : public coro::suspend_always const std::shared_ptr _pimpl; public: + // Type-erased explicit constructor for a custom awaitable. template - await_async(std::shared_ptr pimpl) + explicit await_async(std::shared_ptr pimpl) : _pimpl { std::make_shared>(std::move(pimpl)) } { } + // Default to immediate synchronous execution. + await_async() + : _pimpl { std::static_pointer_cast( + std::make_shared>(std::make_shared())) } + { + } + + // Implicitly convert a std::launch parameter used with std::async to an awaitable. await_async(std::launch launch) : _pimpl { ((launch & std::launch::async) == std::launch::async) ? std::static_pointer_cast(std::make_shared>( @@ -224,8 +239,9 @@ class await_async : public coro::suspend_always _pimpl->await_suspend(std::move(h)); } - constexpr void await_resume() const noexcept + void await_resume() const { + _pimpl->await_resume(); } }; @@ -261,7 +277,7 @@ struct SelectionSetParams std::optional errorPath; // Async launch policy for sub-field resolvers. - const await_async launch { std::launch::deferred }; + const await_async launch {}; }; // Pass a common bundle of parameters to all of the generated Object::getField accessors. @@ -931,19 +947,96 @@ GRAPHQLSERVICE_EXPORT AwaitableResolver ModifiedResult::convert( FieldResult> result, ResolverParams params); #endif // GRAPHQL_DLLEXPORTS -using TypeMap = internal::string_view_map>; +// Subscription callbacks receive the response::Value representing the result of evaluating the +// SelectionSet against the payload. +using SubscriptionCallback = std::function; + +// Subscriptions are stored in maps using these keys. +using SubscriptionKey = size_t; +using SubscriptionName = std::string; + +using AwaitableSubscribe = internal::Awaitable; +using AwaitableUnsubscribe = internal::Awaitable; +using AwaitableDeliver = internal::Awaitable; -// You can still sub-class RequestState and use that in the state parameter to Request::subscribe -// to add your own state to the service callbacks that you receive while executing the subscription -// query. -struct SubscriptionParams +struct RequestResolveParams { + // Required query information. + peg::ast& query; + std::string_view operationName {}; + response::Value variables { response::Type::Map }; + + // Optional async execution awaitable. + await_async launch; + + // Optional sub-class of RequestState which will be passed to each resolver and field accessor. std::shared_ptr state; +}; + +struct RequestSubscribeParams +{ + // Callback which receives the event data. + SubscriptionCallback callback; + + // Required query information. peg::ast query; - std::string operationName; - response::Value variables; + std::string operationName {}; + response::Value variables { response::Type::Map }; + + // Optional async execution awaitable. + await_async launch; + + // Optional sub-class of RequestState which will be passed to each resolver and field accessor. + std::shared_ptr state; +}; + +struct RequestUnsubscribeParams +{ + // Key returned by a previous call to subscribe. + SubscriptionKey key; + + // Optional async execution awaitable. + await_async launch; }; +using SubscriptionArguments = std::map; +using SubscriptionArgumentFilterCallback = std::function; +using SubscriptionDirectiveFilterCallback = std::function; + +struct SubscriptionFilter +{ + // Deliver to subscriptions on this field. + std::string_view field; + + // Optional field argument filter, which can either be a set of required arguments, or a + // callback which returns true if the arguments match custom criteria. + std::optional> + arguments; + + // Optional field directives filter, which can either be a set of required directives and + // arguments, or a callback which returns true if the directives match custom criteria. + std::optional> directives; +}; + +// Deliver to a specific subscription key, or apply custom criteria for the field name, arguments, +// and directives in the Subscription query. +using RequestDeliverFilter = std::optional>; + +struct RequestDeliverParams +{ + // Optional filter to control which subscriptions will receive the event. If not specified, + // every subscription will receive the event and evaluate their queries against it. + RequestDeliverFilter filter; + + // Optional async execution awaitable. + await_async launch; + + // Optional override for the default Subscription operation object. + std::shared_ptr subscriptionObject; +}; + +using TypeMap = internal::string_view_map>; + // State which is captured and kept alive until all pending futures have been resolved for an // operation. Note: SelectionSet is the other parameter that gets passed to the top level Object, // it's a borrowed reference to an element in the AST. In the case of query and mutation operations, @@ -961,21 +1054,6 @@ struct OperationData : std::enable_shared_from_this FragmentMap fragments; }; -// Subscription callbacks receive the response::Value representing the result of evaluating the -// SelectionSet against the payload. -using SubscriptionCallback = std::function; -using SubscriptionArguments = std::map; -using SubscriptionArgumentFilterCallback = std::function; -using SubscriptionDirectiveFilterCallback = std::function; - -// Subscriptions are stored in maps using these keys. -using SubscriptionKey = size_t; -using SubscriptionName = std::string; - -using AwaitableSubscribe = internal::Awaitable; -using AwaitableUnsubscribe = internal::Awaitable; -using AwaitableDeliver = internal::Awaitable; - // Registration information for subscription, cached in the Request::subscribe call. struct SubscriptionData : std::enable_shared_from_this { @@ -1014,51 +1092,17 @@ class Request : public std::enable_shared_from_this GRAPHQLSERVICE_EXPORT std::pair findOperationDefinition( peg::ast& query, std::string_view operationName) const; - GRAPHQLSERVICE_EXPORT response::AwaitableValue resolve(std::shared_ptr state, - peg::ast& query, std::string_view operationName, response::Value variables) const; - GRAPHQLSERVICE_EXPORT response::AwaitableValue resolve(await_async launch, - std::shared_ptr state, peg::ast& query, std::string_view operationName, - response::Value variables) const; - - GRAPHQLSERVICE_EXPORT SubscriptionKey subscribe( - SubscriptionParams&& params, SubscriptionCallback&& callback); - GRAPHQLSERVICE_EXPORT AwaitableSubscribe subscribe( - await_async launch, SubscriptionParams&& params, SubscriptionCallback&& callback); - - GRAPHQLSERVICE_EXPORT void unsubscribe(SubscriptionKey key); - GRAPHQLSERVICE_EXPORT AwaitableUnsubscribe unsubscribe(await_async launch, SubscriptionKey key); - - GRAPHQLSERVICE_EXPORT void deliver( - const SubscriptionName& name, const std::shared_ptr& subscriptionObject) const; - GRAPHQLSERVICE_EXPORT void deliver(const SubscriptionName& name, - const SubscriptionArguments& arguments, std::shared_ptr subscriptionObject) const; - GRAPHQLSERVICE_EXPORT void deliver(const SubscriptionName& name, - const SubscriptionArguments& arguments, const Directives& directives, - std::shared_ptr subscriptionObject) const; - GRAPHQLSERVICE_EXPORT void deliver(const SubscriptionName& name, - const SubscriptionArgumentFilterCallback& applyArguments, - std::shared_ptr subscriptionObject) const; - GRAPHQLSERVICE_EXPORT void deliver(const SubscriptionName& name, - const SubscriptionArgumentFilterCallback& applyArguments, - const SubscriptionDirectiveFilterCallback& applyDirectives, - std::shared_ptr subscriptionObject) const; - - GRAPHQLSERVICE_EXPORT AwaitableDeliver deliver(await_async launch, const SubscriptionName& name, - std::shared_ptr subscriptionObject) const; - GRAPHQLSERVICE_EXPORT AwaitableDeliver deliver(await_async launch, const SubscriptionName& name, - const SubscriptionArguments& arguments, std::shared_ptr subscriptionObject) const; - GRAPHQLSERVICE_EXPORT AwaitableDeliver deliver(await_async launch, const SubscriptionName& name, - const SubscriptionArguments& arguments, const Directives& directives, - std::shared_ptr subscriptionObject) const; - GRAPHQLSERVICE_EXPORT AwaitableDeliver deliver(await_async launch, const SubscriptionName& name, - const SubscriptionArgumentFilterCallback& applyArguments, - std::shared_ptr subscriptionObject) const; - GRAPHQLSERVICE_EXPORT AwaitableDeliver deliver(await_async launch, const SubscriptionName& name, - const SubscriptionArgumentFilterCallback& applyArguments, - const SubscriptionDirectiveFilterCallback& applyDirectives, - std::shared_ptr subscriptionObject) const; + GRAPHQLSERVICE_EXPORT response::AwaitableValue resolve(RequestResolveParams params) const; + GRAPHQLSERVICE_EXPORT AwaitableSubscribe subscribe(RequestSubscribeParams params); + GRAPHQLSERVICE_EXPORT AwaitableUnsubscribe unsubscribe(RequestUnsubscribeParams params); + GRAPHQLSERVICE_EXPORT AwaitableDeliver deliver(RequestDeliverParams params) const; private: + SubscriptionKey addSubscription(RequestSubscribeParams&& params); + void removeSubscription(SubscriptionKey key); + std::vector> collectRegistrations( + RequestDeliverFilter&& filter) const noexcept; + const TypeMap _operations; std::unique_ptr _validation; internal::sorted_map> _subscriptions; diff --git a/samples/client/benchmark.cpp b/samples/client/benchmark.cpp index 3f002876..ddcfab6b 100644 --- a/samples/client/benchmark.cpp +++ b/samples/client/benchmark.cpp @@ -141,8 +141,7 @@ int main(int argc, char** argv) auto query = GetRequestObject(); const auto startResolve = std::chrono::steady_clock::now(); - auto response = - service->resolve(nullptr, query, "", response::Value(response::Type::Map)).get(); + auto response = service->resolve({ query }).get(); const auto startParseServiceResponse = std::chrono::steady_clock::now(); auto serviceResponse = client::parseServiceResponse(std::move(response)); const auto startParseResponse = std::chrono::steady_clock::now(); diff --git a/samples/learn/sample.cpp b/samples/learn/sample.cpp index d95da7a0..954916c1 100644 --- a/samples/learn/sample.cpp +++ b/samples/learn/sample.cpp @@ -43,12 +43,8 @@ int main(int argc, char** argv) std::cout << "Executing query..." << std::endl; - std::cout << response::toJSON(service - ->resolve(nullptr, - query, - ((argc > 2) ? argv[2] : ""), - response::Value(response::Type::Map)) - .get()) + std::cout << response::toJSON( + service->resolve({ query, ((argc > 2) ? argv[2] : "") }).get()) << std::endl; } catch (const std::runtime_error& ex) diff --git a/samples/today/benchmark.cpp b/samples/today/benchmark.cpp index acb6c354..3733ba98 100644 --- a/samples/today/benchmark.cpp +++ b/samples/today/benchmark.cpp @@ -157,8 +157,7 @@ int main(int argc, char** argv) service->validate(query); const auto startResolve = std::chrono::steady_clock::now(); - auto response = - service->resolve(nullptr, query, "", response::Value(response::Type::Map)).get(); + auto response = service->resolve({ query }).get(); const auto startToJson = std::chrono::steady_clock::now(); response::toJSON(std::move(response)); diff --git a/samples/today/sample.cpp b/samples/today/sample.cpp index 376a7300..2c2e9f97 100644 --- a/samples/today/sample.cpp +++ b/samples/today/sample.cpp @@ -84,12 +84,8 @@ int main(int argc, char** argv) std::cout << "Executing query..." << std::endl; - std::cout << response::toJSON(service - ->resolve(nullptr, - query, - ((argc > 2) ? argv[2] : ""), - response::Value(response::Type::Map)) - .get()) + std::cout << response::toJSON( + service->resolve({ query, ((argc > 2) ? argv[2] : "") }).get()) << std::endl; } catch (const std::runtime_error& ex) diff --git a/src/GraphQLService.cpp b/src/GraphQLService.cpp index 68f154b9..72c9984d 100644 --- a/src/GraphQLService.cpp +++ b/src/GraphQLService.cpp @@ -1316,8 +1316,8 @@ void OperationDefinitionVisitor::visit( class SubscriptionDefinitionVisitor { public: - SubscriptionDefinitionVisitor(SubscriptionParams&& params, SubscriptionCallback&& callback, - FragmentMap&& fragments, const std::shared_ptr& subscriptionObject); + SubscriptionDefinitionVisitor(RequestSubscribeParams&& params, FragmentMap&& fragments, + const std::shared_ptr& subscriptionObject); const peg::ast_node& getRoot() const; std::shared_ptr getRegistration(); @@ -1329,8 +1329,7 @@ class SubscriptionDefinitionVisitor void visitFragmentSpread(const peg::ast_node& fragmentSpread); void visitInlineFragment(const peg::ast_node& inlineFragment); - SubscriptionParams _params; - SubscriptionCallback _callback; + RequestSubscribeParams _params; FragmentMap _fragments; const std::shared_ptr& _subscriptionObject; SubscriptionName _field; @@ -1339,11 +1338,9 @@ class SubscriptionDefinitionVisitor std::shared_ptr _result; }; -SubscriptionDefinitionVisitor::SubscriptionDefinitionVisitor(SubscriptionParams&& params, - SubscriptionCallback&& callback, FragmentMap&& fragments, - const std::shared_ptr& subscriptionObject) +SubscriptionDefinitionVisitor::SubscriptionDefinitionVisitor(RequestSubscribeParams&& params, + FragmentMap&& fragments, const std::shared_ptr& subscriptionObject) : _params(std::move(params)) - , _callback(std::move(callback)) , _fragments(std::move(fragments)) , _subscriptionObject(subscriptionObject) { @@ -1403,7 +1400,7 @@ void SubscriptionDefinitionVisitor::visit(const peg::ast_node& operationDefiniti std::move(_fieldDirectives), std::move(_params.query), std::move(_params.operationName), - std::move(_callback), + std::move(_params.callback), selection); } @@ -1600,30 +1597,19 @@ std::pair Request::findOperationDefiniti return result; } -response::AwaitableValue Request::resolve(std::shared_ptr state, peg::ast& query, - std::string_view operationName, response::Value variables) const -{ - return resolve(std::launch::deferred, - std::move(state), - query, - operationName, - std::move(variables)); -} - -response::AwaitableValue Request::resolve(await_async launch, std::shared_ptr state, - peg::ast& query, std::string_view operationName, response::Value variables) const +response::AwaitableValue Request::resolve(RequestResolveParams params) const { try { - FragmentDefinitionVisitor fragmentVisitor(variables); + FragmentDefinitionVisitor fragmentVisitor(params.variables); - peg::for_each_child(*query.root, + peg::for_each_child(*params.query.root, [&fragmentVisitor](const peg::ast_node& child) { fragmentVisitor.visit(child); }); auto fragments = fragmentVisitor.getFragments(); - auto operationDefinition = findOperationDefinition(query, operationName); + auto operationDefinition = findOperationDefinition(params.query, params.operationName); if (!operationDefinition.second) { @@ -1631,9 +1617,9 @@ response::AwaitableValue Request::resolve(await_async launch, std::shared_ptr(*params.query.root, - [&fragmentVisitor](const peg::ast_node& child) { - fragmentVisitor.visit(child); - }); - - auto fragments = fragmentVisitor.getFragments(); - auto operationDefinition = findOperationDefinition(params.query, params.operationName); - - if (!operationDefinition.second) - { - std::ostringstream message; - - message << "Missing subscription"; - - if (!params.operationName.empty()) - { - message << " name: " << params.operationName; - } - - throw schema_exception { { message.str() } }; - } - else if (operationDefinition.first != strSubscription) - { - auto position = operationDefinition.second->begin(); - std::ostringstream message; - - message << "Unexpected operation type: " << operationDefinition.first; - - if (!params.operationName.empty()) - { - message << " name: " << params.operationName; - } - - throw schema_exception { - { schema_error { message.str(), { position.line, position.column } } } - }; - } - - auto itr = _operations.find(strSubscription); - SubscriptionDefinitionVisitor subscriptionVisitor(std::move(params), - std::move(callback), - std::move(fragments), - itr->second); - - peg::for_each_child(subscriptionVisitor.getRoot(), - [&subscriptionVisitor](const peg::ast_node& child) { - subscriptionVisitor.visit(child); - }); - - auto registration = subscriptionVisitor.getRegistration(); - auto key = _nextKey++; - - _listeners[registration->field].emplace(key); - _subscriptions.emplace(key, std::move(registration)); - - return key; -} - -AwaitableSubscribe Request::subscribe( - await_async launch, SubscriptionParams&& params, SubscriptionCallback&& callback) +AwaitableSubscribe Request::subscribe(RequestSubscribeParams params) { const auto spThis = shared_from_this(); - const auto key = spThis->subscribe(std::move(params), std::move(callback)); + auto launch = params.launch; + const auto key = spThis->addSubscription(std::move(params)); const auto itrOperation = spThis->_operations.find(strSubscription); if (itrOperation != spThis->_operations.end()) @@ -1798,7 +1715,7 @@ AwaitableSubscribe Request::subscribe( catch (const std::exception& ex) { // Rethrow the exception, but don't leave it subscribed if the resolver failed. - spThis->unsubscribe(key); + spThis->removeSubscription(key); throw ex; } } @@ -1806,37 +1723,7 @@ AwaitableSubscribe Request::subscribe( co_return key; } -void Request::unsubscribe(SubscriptionKey key) -{ - auto itrSubscription = _subscriptions.find(key); - - if (itrSubscription == _subscriptions.end()) - { - return; - } - - const auto listenerKey = std::string_view { itrSubscription->second->field }; - auto& listener = _listeners.at(listenerKey); - - listener.erase(key); - if (listener.empty()) - { - _listeners.erase(listenerKey); - } - - _subscriptions.erase(itrSubscription); - - if (_subscriptions.empty()) - { - _nextKey = 0; - } - else - { - _nextKey = _subscriptions.rbegin()->first + 1; - } -} - -AwaitableUnsubscribe Request::unsubscribe(await_async launch, SubscriptionKey key) +AwaitableUnsubscribe Request::unsubscribe(RequestUnsubscribeParams params) { const auto spThis = shared_from_this(); const auto itrOperation = spThis->_operations.find(strSubscription); @@ -1844,7 +1731,7 @@ AwaitableUnsubscribe Request::unsubscribe(await_async launch, SubscriptionKey ke if (itrOperation != spThis->_operations.end()) { const auto& operation = itrOperation->second; - const auto& registration = spThis->_subscriptions.at(key); + const auto& registration = spThis->_subscriptions.at(params.key); const SelectionSetParams selectionSetParams { ResolverContext::NotifyUnsubscribe, registration->data->state, @@ -1853,119 +1740,22 @@ AwaitableUnsubscribe Request::unsubscribe(await_async launch, SubscriptionKey ke std::make_shared(), std::make_shared(), {}, - launch, + params.launch, }; - co_await launch; + co_await params.launch; co_await operation->resolve(selectionSetParams, registration->selection, registration->data->fragments, registration->data->variables); } - spThis->unsubscribe(key); + spThis->removeSubscription(params.key); co_return; } -void Request::deliver( - const SubscriptionName& name, const std::shared_ptr& subscriptionObject) const -{ - deliver(std::launch::deferred, name, subscriptionObject).get(); -} - -void Request::deliver(const SubscriptionName& name, const SubscriptionArguments& arguments, - std::shared_ptr subscriptionObject) const -{ - deliver(std::launch::deferred, name, arguments, std::move(subscriptionObject)).get(); -} - -void Request::deliver(const SubscriptionName& name, const SubscriptionArguments& arguments, - const Directives& directives, std::shared_ptr subscriptionObject) const -{ - deliver(std::launch::deferred, name, arguments, directives, std::move(subscriptionObject)) - .get(); -} - -void Request::deliver(const SubscriptionName& name, - const SubscriptionArgumentFilterCallback& applyArguments, - std::shared_ptr subscriptionObject) const -{ - deliver(std::launch::deferred, name, applyArguments, std::move(subscriptionObject)).get(); -} - -void Request::deliver(const SubscriptionName& name, - const SubscriptionArgumentFilterCallback& applyArguments, - const SubscriptionDirectiveFilterCallback& applyDirectives, - std::shared_ptr subscriptionObject) const -{ - deliver(std::launch::deferred, - name, - applyArguments, - applyDirectives, - std::move(subscriptionObject)) - .get(); -} - -AwaitableDeliver Request::deliver(await_async launch, const SubscriptionName& name, - std::shared_ptr subscriptionObject) const -{ - return deliver(launch, - name, - SubscriptionArguments {}, - Directives {}, - std::move(subscriptionObject)); -} - -AwaitableDeliver Request::deliver(await_async launch, const SubscriptionName& name, - const SubscriptionArguments& arguments, std::shared_ptr subscriptionObject) const -{ - return deliver(launch, name, arguments, Directives {}, std::move(subscriptionObject)); -} - -AwaitableDeliver Request::deliver(await_async launch, const SubscriptionName& name, - const SubscriptionArguments& arguments, const Directives& directives, - std::shared_ptr subscriptionObject) const -{ - SubscriptionArgumentFilterCallback argumentsMatch = - [&arguments](response::MapType::const_reference required) noexcept -> bool { - auto itrArgument = arguments.find(required.first); - - return (itrArgument != arguments.end() && itrArgument->second == required.second); - }; - - SubscriptionDirectiveFilterCallback directivesMatch = - [&directives](Directives::const_reference required) noexcept -> bool { - auto itrDirective = std::find_if(directives.cbegin(), - directives.cend(), - [directiveName = required.first](const auto& directive) noexcept { - return directive.first == directiveName; - }); - - return (itrDirective != directives.end() && itrDirective->second == required.second); - }; - - return deliver(launch, name, argumentsMatch, directivesMatch, std::move(subscriptionObject)); -} - -AwaitableDeliver Request::deliver(await_async launch, const SubscriptionName& name, - const SubscriptionArgumentFilterCallback& applyArguments, - std::shared_ptr subscriptionObject) const -{ - return deliver( - launch, - name, - applyArguments, - [](Directives::const_reference) noexcept { - return true; - }, - std::move(subscriptionObject)); -} - -AwaitableDeliver Request::deliver(await_async launch, const SubscriptionName& name, - const SubscriptionArgumentFilterCallback& applyArguments, - const SubscriptionDirectiveFilterCallback& applyDirectives, - std::shared_ptr subscriptionObject) const +AwaitableDeliver Request::deliver(RequestDeliverParams params) const { const auto itrOperation = _operations.find(strSubscription); @@ -1977,7 +1767,7 @@ AwaitableDeliver Request::deliver(await_async launch, const SubscriptionName& na } const auto optionalOrDefaultSubscription = - subscriptionObject ? std::move(subscriptionObject) : itrOperation->second; + params.subscriptionObject ? std::move(params.subscriptionObject) : itrOperation->second; if (!optionalOrDefaultSubscription) { @@ -1986,61 +1776,13 @@ AwaitableDeliver Request::deliver(await_async launch, const SubscriptionName& na throw std::invalid_argument("Missing subscriptionObject"); } - auto itrListeners = _listeners.find(name); + const auto registrations = collectRegistrations(std::move(params.filter)); - if (itrListeners == _listeners.end()) + if (registrations.empty()) { co_return; } - std::vector> registrations; - - registrations.reserve(itrListeners->second.size()); - for (const auto& key : itrListeners->second) - { - auto itrSubscription = _subscriptions.find(key); - auto registration = itrSubscription->second; - const auto& subscriptionArguments = registration->arguments; - bool matchedArguments = true; - - // If the field in this subscription had arguments that did not match what was provided - // in this event, don't deliver the event to this subscription - for (const auto& required : subscriptionArguments) - { - if (!applyArguments(required)) - { - matchedArguments = false; - break; - } - } - - if (!matchedArguments) - { - continue; - } - - // If the field in this subscription had field directives that did not match what was - // provided in this event, don't deliver the event to this subscription - const auto& subscriptionFieldDirectives = registration->fieldDirectives; - bool matchedFieldDirectives = true; - - for (const auto& required : subscriptionFieldDirectives) - { - if (!applyDirectives(required)) - { - matchedFieldDirectives = false; - break; - } - } - - if (!matchedFieldDirectives) - { - continue; - } - - registrations.push_back(std::move(registration)); - } - for (const auto& registration : registrations) { const SelectionSetParams selectionSetParams { @@ -2051,14 +1793,14 @@ AwaitableDeliver Request::deliver(await_async launch, const SubscriptionName& na std::make_shared(), std::make_shared(), std::nullopt, - launch, + params.launch, }; response::Value document { response::Type::Map }; try { - co_await launch; + co_await params.launch; auto result = co_await optionalOrDefaultSubscription->resolve(selectionSetParams, registration->selection, @@ -2085,4 +1827,244 @@ AwaitableDeliver Request::deliver(await_async launch, const SubscriptionName& na co_return; } +SubscriptionKey Request::addSubscription(RequestSubscribeParams&& params) +{ + auto errors = validate(params.query); + + if (!errors.empty()) + { + throw schema_exception { std::move(errors) }; + } + + FragmentDefinitionVisitor fragmentVisitor(params.variables); + + peg::for_each_child(*params.query.root, + [&fragmentVisitor](const peg::ast_node& child) { + fragmentVisitor.visit(child); + }); + + auto fragments = fragmentVisitor.getFragments(); + auto operationDefinition = findOperationDefinition(params.query, params.operationName); + + if (!operationDefinition.second) + { + std::ostringstream message; + + message << "Missing subscription"; + + if (!params.operationName.empty()) + { + message << " name: " << params.operationName; + } + + throw schema_exception { { message.str() } }; + } + else if (operationDefinition.first != strSubscription) + { + auto position = operationDefinition.second->begin(); + std::ostringstream message; + + message << "Unexpected operation type: " << operationDefinition.first; + + if (!params.operationName.empty()) + { + message << " name: " << params.operationName; + } + + throw schema_exception { + { schema_error { message.str(), { position.line, position.column } } } + }; + } + + auto itr = _operations.find(strSubscription); + SubscriptionDefinitionVisitor subscriptionVisitor(std::move(params), + std::move(fragments), + itr->second); + + peg::for_each_child(subscriptionVisitor.getRoot(), + [&subscriptionVisitor](const peg::ast_node& child) { + subscriptionVisitor.visit(child); + }); + + auto registration = subscriptionVisitor.getRegistration(); + auto key = _nextKey++; + + _listeners[registration->field].emplace(key); + _subscriptions.emplace(key, std::move(registration)); + + return key; +} + +void Request::removeSubscription(SubscriptionKey key) +{ + auto itrSubscription = _subscriptions.find(key); + + if (itrSubscription == _subscriptions.end()) + { + return; + } + + const auto listenerKey = std::string_view { itrSubscription->second->field }; + auto& listener = _listeners.at(listenerKey); + + listener.erase(key); + if (listener.empty()) + { + _listeners.erase(listenerKey); + } + + _subscriptions.erase(itrSubscription); + + if (_subscriptions.empty()) + { + _nextKey = 0; + } + else + { + _nextKey = _subscriptions.rbegin()->first + 1; + } +} + +std::vector> Request::collectRegistrations( + RequestDeliverFilter&& filter) const noexcept +{ + std::vector> registrations; + + if (!filter) + { + // Return all of the registered subscriptions. + registrations.reserve(_subscriptions.size()); + std::transform(_subscriptions.begin(), + _subscriptions.end(), + std::back_inserter(registrations), + [](const auto& entry) noexcept { + return entry.second; + }); + } + else if (std::holds_alternative(*filter)) + { + // Return the specific subscription for this key. + const auto itr = _subscriptions.find(std::get(*filter)); + + if (itr != _subscriptions.end()) + { + registrations.push_back(itr->second); + } + } + else if (std::holds_alternative(*filter)) + { + auto& subscriptionFilter = std::get(*filter); + const auto itrListeners = _listeners.find(subscriptionFilter.field); + + if (itrListeners != _listeners.end()) + { + registrations.reserve(itrListeners->second.size()); + + std::optional argumentsMatch; + + if (subscriptionFilter.arguments) + { + if (std::holds_alternative(*subscriptionFilter.arguments)) + { + argumentsMatch = [arguments = std::move(std::get( + *subscriptionFilter.arguments))]( + response::MapType::const_reference required) noexcept { + auto itrArgument = arguments.find(required.first); + + return (itrArgument != arguments.end() + && itrArgument->second == required.second); + }; + } + else if (std::holds_alternative( + *subscriptionFilter.arguments)) + { + argumentsMatch = std::move(std::get( + *subscriptionFilter.arguments)); + } + } + + std::optional directivesMatch; + + if (subscriptionFilter.directives) + { + if (std::holds_alternative(*subscriptionFilter.directives)) + { + directivesMatch = [directives = std::move( + std::get(*subscriptionFilter.directives))]( + Directives::const_reference required) noexcept { + auto itrDirective = std::find_if(directives.cbegin(), + directives.cend(), + [directiveName = required.first](const auto& directive) noexcept { + return directive.first == directiveName; + }); + + return (itrDirective != directives.end() + && itrDirective->second == required.second); + }; + } + else if (std::holds_alternative( + *subscriptionFilter.directives)) + { + directivesMatch = std::move(std::get( + *subscriptionFilter.directives)); + } + } + + for (const auto& key : itrListeners->second) + { + auto itrSubscription = _subscriptions.find(key); + auto registration = itrSubscription->second; + + if (argumentsMatch) + { + const auto& subscriptionArguments = registration->arguments; + bool matchedArguments = true; + + // If the field in this subscription had arguments that did not match what was + // provided in this event, don't deliver the event to this subscription + for (const auto& required : subscriptionArguments) + { + if (!(*argumentsMatch)(required)) + { + matchedArguments = false; + break; + } + } + + if (!matchedArguments) + { + continue; + } + } + + if (directivesMatch) + { + // If the field in this subscription had field directives that did not match + // what was provided in this event, don't deliver the event to this subscription + const auto& subscriptionFieldDirectives = registration->fieldDirectives; + bool matchedFieldDirectives = true; + + for (const auto& required : subscriptionFieldDirectives) + { + if (!(*directivesMatch)(required)) + { + matchedFieldDirectives = false; + break; + } + } + + if (!matchedFieldDirectives) + { + continue; + } + } + + registrations.push_back(std::move(registration)); + } + } + } + + return registrations; +} + } // namespace graphql::service diff --git a/test/ClientTests.cpp b/test/ClientTests.cpp index acef05f0..ba4f5b9a 100644 --- a/test/ClientTests.cpp +++ b/test/ClientTests.cpp @@ -108,7 +108,7 @@ TEST_F(ClientCase, QueryEverything) response::Value variables(response::Type::Map); auto state = std::make_shared(1); auto result = - _service->resolve(std::launch::async, state, query, "", std::move(variables)).get(); + _service->resolve({ query, {}, std::move(variables), std::launch::async, state }).get(); EXPECT_EQ(size_t(1), _getAppointmentsCount) << "today service lazy loads the appointments and caches the result"; EXPECT_EQ(size_t(1), _getTasksCount) @@ -200,7 +200,7 @@ TEST_F(ClientCase, MutateCompleteTask) std::make_optional("Hi There!"s) } }); auto state = std::make_shared(5); - auto result = _service->resolve(state, query, "", std::move(variables)).get(); + auto result = _service->resolve({ query, {}, std::move(variables), {}, state }).get(); try { @@ -237,15 +237,18 @@ TEST_F(ClientCase, SubscribeNextAppointmentChangeDefault) response::Value variables(response::Type::Map); auto state = std::make_shared(6); response::Value result; - auto key = _service->subscribe(service::SubscriptionParams { state, - std::move(query), - "TestSubscription", - std::move(variables) }, - [&result](response::Value&& response) { - result = std::move(response); - }); - _service->deliver("nextAppointmentChange", nullptr); - _service->unsubscribe(key); + auto key = _service + ->subscribe({ [&result](response::Value&& response) { + result = std::move(response); + }, + std::move(query), + "TestSubscription"s, + std::move(variables), + {}, + state }) + .get(); + _service->deliver({ { service::SubscriptionFilter { "nextAppointmentChange"sv } } }).get(); + _service->unsubscribe({ key }).get(); try { diff --git a/test/NoIntrospectionTests.cpp b/test/NoIntrospectionTests.cpp index 697bc50d..1115e938 100644 --- a/test/NoIntrospectionTests.cpp +++ b/test/NoIntrospectionTests.cpp @@ -143,7 +143,8 @@ TEST_F(NoIntrospectionServiceCase, QueryEverything) response::Value variables(response::Type::Map); auto state = std::make_shared(1); auto result = - _service->resolve(std::launch::async, state, query, "Everything", std::move(variables)) + _service->resolve( + { query, "Everything"sv, std::move(variables), std::launch::async, state }) .get(); EXPECT_EQ(size_t(1), _getAppointmentsCount) << "today service lazy loads the appointments and caches the result"; @@ -232,9 +233,7 @@ TEST_F(NoIntrospectionServiceCase, NoSchema) queryType { name } } })"_graphql; - response::Value variables(response::Type::Map); - auto result = - _service->resolve(std::launch::deferred, nullptr, query, "", std::move(variables)).get(); + auto result = _service->resolve({ query }).get(); try { @@ -260,9 +259,7 @@ TEST_F(NoIntrospectionServiceCase, NoType) description } })"_graphql; - response::Value variables(response::Type::Map); - auto result = - _service->resolve(std::launch::deferred, nullptr, query, "", std::move(variables)).get(); + auto result = _service->resolve({ query }).get(); try { diff --git a/test/TodayTests.cpp b/test/TodayTests.cpp index da8273c6..f4ea145d 100644 --- a/test/TodayTests.cpp +++ b/test/TodayTests.cpp @@ -137,7 +137,8 @@ TEST_F(TodayServiceCase, QueryEverything) response::Value variables(response::Type::Map); auto state = std::make_shared(1); auto result = - _service->resolve(std::launch::async, state, query, "Everything", std::move(variables)) + _service->resolve( + { query, "Everything"sv, std::move(variables), std::launch::async, state }) .get(); EXPECT_EQ(size_t(1), _getAppointmentsCount) << "today service lazy loads the appointments and caches the result"; @@ -235,7 +236,7 @@ TEST_F(TodayServiceCase, QueryAppointments) })"_graphql; response::Value variables(response::Type::Map); auto state = std::make_shared(2); - auto result = _service->resolve(state, query, "", std::move(variables)).get(); + auto result = _service->resolve({ query, {}, std::move(variables), {}, state }).get(); EXPECT_EQ(size_t(1), _getAppointmentsCount) << "today service lazy loads the appointments and caches the result"; EXPECT_GE(size_t(1), _getTasksCount) @@ -300,7 +301,7 @@ TEST_F(TodayServiceCase, QueryAppointmentsWithForceError) })"_graphql; response::Value variables(response::Type::Map); auto state = std::make_shared(2); - auto result = _service->resolve(state, query, "", std::move(variables)).get(); + auto result = _service->resolve({ query, {}, std::move(variables), {}, state }).get(); EXPECT_EQ(size_t(1), _getAppointmentsCount) << "today service lazy loads the appointments and caches the result"; EXPECT_GE(size_t(1), _getTasksCount) @@ -373,7 +374,7 @@ TEST_F(TodayServiceCase, QueryAppointmentsWithForceErrorAsync) response::Value variables(response::Type::Map); auto state = std::make_shared(2); auto result = - _service->resolve(std::launch::async, state, query, "", std::move(variables)).get(); + _service->resolve({ query, {}, std::move(variables), std::launch::async, state }).get(); EXPECT_EQ(size_t(1), _getAppointmentsCount) << "today service lazy loads the appointments and caches the result"; EXPECT_GE(size_t(1), _getTasksCount) @@ -443,7 +444,7 @@ TEST_F(TodayServiceCase, QueryTasks) })gql"_graphql; response::Value variables(response::Type::Map); auto state = std::make_shared(3); - auto result = _service->resolve(state, query, "", std::move(variables)).get(); + auto result = _service->resolve({ query, {}, std::move(variables), {}, state }).get(); EXPECT_GE(size_t(1), _getAppointmentsCount) << "today service lazy loads the appointments and caches the result"; EXPECT_EQ(size_t(1), _getTasksCount) @@ -501,7 +502,7 @@ TEST_F(TodayServiceCase, QueryUnreadCounts) })"_graphql; response::Value variables(response::Type::Map); auto state = std::make_shared(4); - auto result = _service->resolve(state, query, "", std::move(variables)).get(); + auto result = _service->resolve({ query, {}, std::move(variables), {}, state }).get(); EXPECT_GE(size_t(1), _getAppointmentsCount) << "today service lazy loads the appointments and caches the result"; EXPECT_GE(size_t(1), _getTasksCount) @@ -560,7 +561,7 @@ TEST_F(TodayServiceCase, MutateCompleteTask) })"_graphql; response::Value variables(response::Type::Map); auto state = std::make_shared(5); - auto result = _service->resolve(state, query, "", std::move(variables)).get(); + auto result = _service->resolve({ query, {}, std::move(variables), {}, state }).get(); try { @@ -607,15 +608,18 @@ TEST_F(TodayServiceCase, SubscribeNextAppointmentChangeDefault) response::Value variables(response::Type::Map); auto state = std::make_shared(6); response::Value result; - auto key = _service->subscribe(service::SubscriptionParams { state, - std::move(query), - "TestSubscription", - std::move(variables) }, - [&result](response::Value&& response) { - result = std::move(response); - }); - _service->deliver("nextAppointmentChange", nullptr); - _service->unsubscribe(key); + auto key = _service + ->subscribe({ [&result](response::Value&& response) { + result = std::move(response); + }, + std::move(query), + "TestSubscription"s, + std::move(variables), + {}, + state }) + .get(); + _service->deliver({ { service::SubscriptionFilter { "nextAppointmentChange"sv } } }).get(); + _service->unsubscribe({ key }).get(); try { @@ -667,16 +671,22 @@ TEST_F(TodayServiceCase, SubscribeNextAppointmentChangeOverride) true); }); response::Value result; - auto key = _service->subscribe(service::SubscriptionParams { state, - std::move(query), - "TestSubscription", - std::move(variables) }, - [&result](response::Value&& response) { - result = std::move(response); - }); - _service->deliver("nextAppointmentChange", - std::make_shared(std::move(subscriptionObject))); - _service->unsubscribe(key); + auto key = _service + ->subscribe({ [&result](response::Value&& response) { + result = std::move(response); + }, + std::move(query), + "TestSubscription"s, + std::move(variables), + {}, + state }) + .get(); + _service + ->deliver({ { service::SubscriptionFilter { "nextAppointmentChange"sv } }, + {}, + std::make_shared(std::move(subscriptionObject)) }) + .get(); + _service->unsubscribe({ key }).get(); try { @@ -712,7 +722,7 @@ TEST_F(TodayServiceCase, DeliverNextAppointmentChangeNoSubscriptionObject) try { - service->deliver("nextAppointmentChange", nullptr); + service->deliver({ { service::SubscriptionFilter { "nextAppointmentChange"sv } } }).get(); } catch (const std::invalid_argument& ex) { @@ -730,7 +740,7 @@ TEST_F(TodayServiceCase, DeliverNextAppointmentChangeNoSubscriptionSupport) try { - service->deliver("nextAppointmentChange", nullptr); + service->deliver({ { service::SubscriptionFilter { "nextAppointmentChange"sv } } }).get(); } catch (const std::logic_error& ex) { @@ -779,7 +789,7 @@ TEST_F(TodayServiceCase, Introspection) response::Value variables(response::Type::Map); auto state = std::make_shared(8); auto result = - _service->resolve(std::launch::async, state, query, "", std::move(variables)).get(); + _service->resolve({ query, {}, std::move(variables), std::launch::async, state }).get(); try { @@ -844,7 +854,7 @@ TEST_F(TodayServiceCase, SkipDirective) })"_graphql; response::Value variables(response::Type::Map); auto state = std::make_shared(9); - auto result = _service->resolve(state, query, "", std::move(variables)).get(); + auto result = _service->resolve({ query, {}, std::move(variables), {}, state }).get(); try { @@ -909,7 +919,7 @@ TEST_F(TodayServiceCase, IncludeDirective) })"_graphql; response::Value variables(response::Type::Map); auto state = std::make_shared(10); - auto result = _service->resolve(state, query, "", std::move(variables)).get(); + auto result = _service->resolve({ query, {}, std::move(variables), {}, state }).get(); try { @@ -967,7 +977,7 @@ TEST_F(TodayServiceCase, NestedFragmentDirectives) })"_graphql; response::Value variables(response::Type::Map); auto state = std::make_shared(11); - auto result = _service->resolve(state, query, "", std::move(variables)).get(); + auto result = _service->resolve({ query, {}, std::move(variables), {}, state }).get(); try { @@ -1151,10 +1161,9 @@ TEST_F(TodayServiceCase, QueryAppointmentsById) } })"_graphql; response::Value variables(response::Type::Map); - variables.emplace_back("appointmentId", - response::Value(std::string("ZmFrZUFwcG9pbnRtZW50SWQ="))); + variables.emplace_back("appointmentId", response::Value("ZmFrZUFwcG9pbnRtZW50SWQ="s)); auto state = std::make_shared(12); - auto result = _service->resolve(state, query, "", std::move(variables)).get(); + auto result = _service->resolve({ query, {}, std::move(variables), {}, state }).get(); EXPECT_EQ(size_t(1), _getAppointmentsCount) << "today service lazy loads the appointments and caches the result"; EXPECT_GE(size_t(1), _getTasksCount) @@ -1204,8 +1213,7 @@ TEST_F(TodayServiceCase, UnimplementedFieldError) auto query = R"(query { unimplemented })"_graphql; - response::Value variables(response::Type::Map); - auto result = _service->resolve(nullptr, query, "", std::move(variables)).get(); + auto result = _service->resolve({ query }).get(); try { @@ -1250,17 +1258,24 @@ TEST_F(TodayServiceCase, SubscribeNodeChangeMatchingId) true))); }); response::Value result; - auto key = _service->subscribe(service::SubscriptionParams { state, - std::move(query), - "TestSubscription", - std::move(variables) }, - [&result](response::Value&& response) { - result = std::move(response); - }); - _service->deliver("nodeChange", - { { "id", response::Value(std::string("ZmFrZVRhc2tJZA==")) } }, - std::make_shared(std::move(subscriptionObject))); - _service->unsubscribe(key); + auto key = _service + ->subscribe({ [&result](response::Value&& response) { + result = std::move(response); + }, + std::move(query), + "TestSubscription", + std::move(variables), + {}, + state }) + .get(); + _service + ->deliver({ { service::SubscriptionFilter { "nodeChange"sv, + { service::SubscriptionArguments { + { "id", response::Value("ZmFrZVRhc2tJZA=="s) } } } } }, + {}, + std::make_shared(std::move(subscriptionObject)) }) + .get(); + _service->unsubscribe({ key }).get(); try { @@ -1306,17 +1321,22 @@ TEST_F(TodayServiceCase, SubscribeNodeChangeMismatchedId) return nullptr; }); bool calledGet = false; - auto key = _service->subscribe(service::SubscriptionParams { nullptr, - std::move(query), - "TestSubscription", - std::move(variables) }, - [&calledGet](response::Value&&) { - calledGet = true; - }); - _service->deliver("nodeChange", - { { "id", response::Value(std::string("ZmFrZUFwcG9pbnRtZW50SWQ=")) } }, - std::make_shared(std::move(subscriptionObject))); - _service->unsubscribe(key); + auto key = _service + ->subscribe({ [&calledGet](response::Value&&) { + calledGet = true; + }, + std::move(query), + "TestSubscription"s, + std::move(variables) }) + .get(); + _service + ->deliver({ { service::SubscriptionFilter { "nodeChange"sv, + { service::SubscriptionArguments { + { "id", response::Value("ZmFrZUFwcG9pbnRtZW50SWQ="s) } } } } }, + {}, + std::make_shared(std::move(subscriptionObject)) }) + .get(); + _service->unsubscribe({ key }).get(); try { @@ -1365,17 +1385,24 @@ TEST_F(TodayServiceCase, SubscribeNodeChangeFuzzyComparator) true))); }); response::Value result; - auto key = _service->subscribe(service::SubscriptionParams { state, - std::move(query), - "TestSubscription", - std::move(variables) }, - [&result](response::Value&& response) { - result = std::move(response); - }); - _service->deliver("nodeChange", - filterCallback, - std::make_shared(std::move(subscriptionObject))); - _service->unsubscribe(key); + auto key = _service + ->subscribe({ [&result](response::Value&& response) { + result = std::move(response); + }, + std::move(query), + "TestSubscription"s, + std::move(variables), + {}, + state }) + .get(); + _service + ->deliver( + { { service::SubscriptionFilter { "nodeChange"sv, + { service::SubscriptionArgumentFilterCallback { std::move(filterCallback) } } } }, + {}, + std::make_shared(std::move(subscriptionObject)) }) + .get(); + _service->unsubscribe({ key }).get(); try { @@ -1431,17 +1458,22 @@ TEST_F(TodayServiceCase, SubscribeNodeChangeFuzzyMismatch) return nullptr; }); bool calledGet = false; - auto key = _service->subscribe(service::SubscriptionParams { nullptr, - std::move(query), - "TestSubscription", - std::move(variables) }, - [&calledGet](response::Value&&) { - calledGet = true; - }); - _service->deliver("nodeChange", - filterCallback, - std::make_shared(std::move(subscriptionObject))); - _service->unsubscribe(key); + auto key = _service + ->subscribe({ [&calledGet](response::Value&&) { + calledGet = true; + }, + std::move(query), + "TestSubscription"s, + std::move(variables) }) + .get(); + _service + ->deliver( + { { service::SubscriptionFilter { "nodeChange"sv, + { service::SubscriptionArgumentFilterCallback { std::move(filterCallback) } } } }, + {}, + std::make_shared(std::move(subscriptionObject)) }) + .get(); + _service->unsubscribe({ key }).get(); try { @@ -1467,7 +1499,7 @@ TEST_F(TodayServiceCase, SubscribeNodeChangeMatchingVariable) } })"); response::Value variables(response::Type::Map); - variables.emplace_back("taskId", response::Value(std::string("ZmFrZVRhc2tJZA=="))); + variables.emplace_back("taskId", response::Value("ZmFrZVRhc2tJZA=="s)); auto state = std::make_shared(14); auto subscriptionObject = std::make_shared( [this](const std::shared_ptr& state, @@ -1481,17 +1513,24 @@ TEST_F(TodayServiceCase, SubscribeNodeChangeMatchingVariable) true))); }); response::Value result; - auto key = _service->subscribe(service::SubscriptionParams { state, - std::move(query), - "TestSubscription", - std::move(variables) }, - [&result](response::Value&& response) { - result = std::move(response); - }); - _service->deliver("nodeChange", - { { "id", response::Value(std::string("ZmFrZVRhc2tJZA==")) } }, - std::make_shared(std::move(subscriptionObject))); - _service->unsubscribe(key); + auto key = _service + ->subscribe({ [&result](response::Value&& response) { + result = std::move(response); + }, + std::move(query), + "TestSubscription", + std::move(variables), + {}, + state }) + .get(); + _service + ->deliver({ { service::SubscriptionFilter { "nodeChange"sv, + { service::SubscriptionArguments { + { "id", response::Value("ZmFrZVRhc2tJZA=="s) } } } } }, + {}, + std::make_shared(std::move(subscriptionObject)) }) + .get(); + _service->unsubscribe({ key }).get(); try { @@ -1528,11 +1567,9 @@ TEST_F(TodayServiceCase, DeferredQueryAppointmentsById) } })"_graphql; response::Value variables(response::Type::Map); - variables.emplace_back("appointmentId", - response::Value(std::string("ZmFrZUFwcG9pbnRtZW50SWQ="))); + variables.emplace_back("appointmentId", response::Value("ZmFrZUFwcG9pbnRtZW50SWQ="s)); auto state = std::make_shared(15); - auto result = - _service->resolve(std::launch::deferred, state, query, "", std::move(variables)).get(); + auto result = _service->resolve({ query, {}, std::move(variables), {}, state }).get(); EXPECT_EQ(size_t(1), _getAppointmentsCount) << "today service lazy loads the appointments and caches the result"; EXPECT_GE(size_t(1), _getTasksCount) @@ -1588,11 +1625,10 @@ TEST_F(TodayServiceCase, NonBlockingQueryAppointmentsById) } })"_graphql; response::Value variables(response::Type::Map); - variables.emplace_back("appointmentId", - response::Value(std::string("ZmFrZUFwcG9pbnRtZW50SWQ="))); + variables.emplace_back("appointmentId", response::Value("ZmFrZUFwcG9pbnRtZW50SWQ="s)); auto state = std::make_shared(16); auto result = - _service->resolve(std::launch::async, state, query, "", std::move(variables)).get(); + _service->resolve({ query, {}, std::move(variables), std::launch::async, state }).get(); EXPECT_EQ(size_t(1), _getAppointmentsCount) << "today service lazy loads the appointments and caches the result"; EXPECT_GE(size_t(1), _getTasksCount) @@ -1644,9 +1680,7 @@ TEST_F(TodayServiceCase, NonExistentTypeIntrospection) description } })"_graphql; - response::Value variables(response::Type::Map); - auto result = - _service->resolve(std::launch::deferred, nullptr, query, "", std::move(variables)).get(); + auto result = _service->resolve({ query }).get(); try { @@ -1678,15 +1712,21 @@ TEST_F(TodayServiceCase, SubscribeNextAppointmentChangeAsync) response::Value variables(response::Type::Map); auto state = std::make_shared(17); response::Value result; - auto key = _service->subscribe(service::SubscriptionParams { state, - std::move(query), - "TestSubscription", - std::move(variables) }, - [&result](response::Value&& response) { - result = std::move(response); - }); - _service->deliver(std::launch::async, "nextAppointmentChange", nullptr).get(); - _service->unsubscribe(key); + auto key = _service + ->subscribe({ [&result](response::Value&& response) { + result = std::move(response); + }, + std::move(query), + "TestSubscription"s, + std::move(variables), + {}, + state }) + .get(); + _service + ->deliver( + { { service::SubscriptionFilter { "nextAppointmentChange"sv } }, std::launch::async }) + .get(); + _service->unsubscribe({ key }).get(); try { @@ -1725,13 +1765,10 @@ TEST_F(TodayServiceCase, NonblockingDeferredExpensive) response::Value variables(response::Type::Map); auto state = std::make_shared(18); std::unique_lock testLock(today::Expensive::testMutex); - auto result = _service - ->resolve(std::launch::deferred, - state, - query, - "NonblockingDeferredExpensive", - std::move(variables)) - .get(); + auto result = + _service + ->resolve({ query, "NonblockingDeferredExpensive"sv, std::move(variables), {}, state }) + .get(); try { @@ -1762,11 +1799,11 @@ TEST_F(TodayServiceCase, BlockingAsyncExpensive) auto state = std::make_shared(19); std::unique_lock testLock(today::Expensive::testMutex); auto result = _service - ->resolve(std::launch::async, - state, - query, - "BlockingAsyncExpensive", - std::move(variables)) + ->resolve({ query, + "BlockingAsyncExpensive"sv, + std::move(variables), + std::launch::async, + state }) .get(); try @@ -1809,7 +1846,7 @@ TEST_F(TodayServiceCase, QueryAppointmentsThroughUnionTypeFragment) })"_graphql; response::Value variables(response::Type::Map); auto state = std::make_shared(20); - auto result = _service->resolve(state, query, "", std::move(variables)).get(); + auto result = _service->resolve({ query, {}, std::move(variables), {}, state }).get(); EXPECT_EQ(size_t(1), _getAppointmentsCount) << "today service lazy loads the appointments and caches the result"; EXPECT_GE(size_t(1), _getTasksCount) @@ -1881,16 +1918,18 @@ TEST_F(TodayServiceCase, SubscribeUnsubscribeNotificationsAsync) const auto notifyUnsubscribeBegin = today::NextAppointmentChange::getCount(service::ResolverContext::NotifyUnsubscribe); auto key = _service - ->subscribe(std::launch::async, - service::SubscriptionParams { state, - std::move(query), - "TestSubscription", - std::move(variables) }, + ->subscribe({ [&calledCallback](response::Value&& response) { calledCallback = true; - }) + }, + std::move(query), + "TestSubscription"s, + std::move(variables), + std::launch::async, + state, + }) .get(); - _service->unsubscribe(std::launch::async, key).get(); + _service->unsubscribe({ key, std::launch::async }).get(); const auto notifySubscribeEnd = today::NextAppointmentChange::getCount(service::ResolverContext::NotifySubscribe); const auto subscriptionEnd = @@ -1933,16 +1972,16 @@ TEST_F(TodayServiceCase, SubscribeUnsubscribeNotificationsDeferred) const auto notifyUnsubscribeBegin = today::NextAppointmentChange::getCount(service::ResolverContext::NotifyUnsubscribe); auto key = _service - ->subscribe(std::launch::deferred, - service::SubscriptionParams { state, - std::move(query), - "TestSubscription", - std::move(variables) }, - [&calledCallback](response::Value&& response) { - calledCallback = true; - }) + ->subscribe({ [&calledCallback](response::Value&& response) { + calledCallback = true; + }, + std::move(query), + "TestSubscription"s, + std::move(variables), + {}, + state }) .get(); - _service->unsubscribe(std::launch::deferred, key).get(); + _service->unsubscribe({ key }).get(); const auto notifySubscribeEnd = today::NextAppointmentChange::getCount(service::ResolverContext::NotifySubscribe); const auto subscriptionEnd = @@ -1972,7 +2011,7 @@ TEST_F(TodayServiceCase, MutateSetFloat) })"_graphql; response::Value variables(response::Type::Map); auto state = std::make_shared(22); - auto result = _service->resolve(state, query, "", std::move(variables)).get(); + auto result = _service->resolve({ query, {}, std::move(variables), {}, state }).get(); try { @@ -2002,7 +2041,7 @@ TEST_F(TodayServiceCase, MutateCoerceSetFloat) })"_graphql; response::Value variables(response::Type::Map); auto state = std::make_shared(22); - auto result = _service->resolve(state, query, "", std::move(variables)).get(); + auto result = _service->resolve({ query, {}, std::move(variables), {}, state }).get(); try { From 3b677d6fbeb7a9d21dfaffcf3b342668c3b13703 Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Mon, 13 Dec 2021 21:17:52 -0800 Subject: [PATCH 099/119] Let response::Value hold copy-on-write shared_ptr --- include/graphqlservice/GraphQLResponse.h | 8 +- src/GraphQLResponse.cpp | 190 +++++++++++++++++++---- 2 files changed, 163 insertions(+), 35 deletions(-) diff --git a/include/graphqlservice/GraphQLResponse.h b/include/graphqlservice/GraphQLResponse.h index 5f70404d..09a6f020 100644 --- a/include/graphqlservice/GraphQLResponse.h +++ b/include/graphqlservice/GraphQLResponse.h @@ -131,6 +131,8 @@ struct Value GRAPHQLRESPONSE_EXPORT Value(Value&& other) noexcept; GRAPHQLRESPONSE_EXPORT explicit Value(const Value& other); + GRAPHQLRESPONSE_EXPORT Value(std::shared_ptr other) noexcept; + GRAPHQLRESPONSE_EXPORT Value& operator=(Value&& rhs) noexcept; Value& operator=(const Value& rhs) = delete; @@ -213,8 +215,12 @@ struct Value std::unique_ptr scalar; }; + using SharedData = std::shared_ptr; + using TypeData = std::variant; + FloatType, EnumData, ScalarData, SharedData>; + + const TypeData& data() const noexcept; TypeData _data; }; diff --git a/src/GraphQLResponse.cpp b/src/GraphQLResponse.cpp index f23cac12..e773d8c9 100644 --- a/src/GraphQLResponse.cpp +++ b/src/GraphQLResponse.cpp @@ -42,6 +42,11 @@ bool Value::ScalarData::operator==(const ScalarData& rhs) const template <> void Value::set(StringType&& value) { + if (std::holds_alternative(_data)) + { + *this = Value { *std::get(_data) }; + } + if (std::holds_alternative(_data)) { std::get(_data) = std::move(value); @@ -59,6 +64,11 @@ void Value::set(StringType&& value) template <> void Value::set(BooleanType value) { + if (std::holds_alternative(_data)) + { + *this = Value { *std::get(_data) }; + } + if (!std::holds_alternative(_data)) { throw std::logic_error("Invalid call to Value::set for BooleanType"); @@ -70,6 +80,11 @@ void Value::set(BooleanType value) template <> void Value::set(IntType value) { + if (std::holds_alternative(_data)) + { + *this = Value { *std::get(_data) }; + } + if (std::holds_alternative(_data)) { // Coerce IntType to FloatType @@ -88,6 +103,11 @@ void Value::set(IntType value) template <> void Value::set(FloatType value) { + if (std::holds_alternative(_data)) + { + *this = Value { *std::get(_data) }; + } + if (!std::holds_alternative(_data)) { throw std::logic_error("Invalid call to Value::set for FloatType"); @@ -99,6 +119,11 @@ void Value::set(FloatType value) template <> void Value::set(ScalarType&& value) { + if (std::holds_alternative(_data)) + { + *this = Value { *std::get(_data) }; + } + if (!std::holds_alternative(_data)) { throw std::logic_error("Invalid call to Value::set for ScalarType"); @@ -110,6 +135,11 @@ void Value::set(ScalarType&& value) template <> void Value::set(const IdType& value) { + if (std::holds_alternative(_data)) + { + *this = Value { *std::get(_data) }; + } + if (!std::holds_alternative(_data)) { throw std::logic_error("Invalid call to Value::set for IdType"); @@ -121,35 +151,41 @@ void Value::set(const IdType& value) template <> const MapType& Value::get() const { - if (!std::holds_alternative(_data)) + const auto& typeData = data(); + + if (!std::holds_alternative(typeData)) { throw std::logic_error("Invalid call to Value::get for MapType"); } - return std::get(_data).map; + return std::get(typeData).map; } template <> const ListType& Value::get() const { - if (!std::holds_alternative(_data)) + const auto& typeData = data(); + + if (!std::holds_alternative(typeData)) { throw std::logic_error("Invalid call to Value::get for ListType"); } - return std::get(_data); + return std::get(typeData); } template <> const StringType& Value::get() const { - if (std::holds_alternative(_data)) + const auto& typeData = data(); + + if (std::holds_alternative(typeData)) { - return std::get(_data); + return std::get(typeData); } - else if (std::holds_alternative(_data)) + else if (std::holds_alternative(typeData)) { - return std::get(_data).string; + return std::get(typeData).string; } throw std::logic_error("Invalid call to Value::get for StringType"); @@ -158,51 +194,59 @@ const StringType& Value::get() const template <> BooleanType Value::get() const { - if (!std::holds_alternative(_data)) + const auto& typeData = data(); + + if (!std::holds_alternative(typeData)) { throw std::logic_error("Invalid call to Value::get for BooleanType"); } - return std::get(_data); + return std::get(typeData); } template <> IntType Value::get() const { - if (!std::holds_alternative(_data)) + const auto& typeData = data(); + + if (!std::holds_alternative(typeData)) { throw std::logic_error("Invalid call to Value::get for IntType"); } - return std::get(_data); + return std::get(typeData); } template <> FloatType Value::get() const { - if (std::holds_alternative(_data)) + const auto& typeData = data(); + + if (std::holds_alternative(typeData)) { // Coerce IntType to FloatType - return static_cast(std::get(_data)); + return static_cast(std::get(typeData)); } - if (!std::holds_alternative(_data)) + if (!std::holds_alternative(typeData)) { throw std::logic_error("Invalid call to Value::get for FloatType"); } - return std::get(_data); + return std::get(typeData); } template <> const ScalarType& Value::get() const { - if (!std::holds_alternative(_data)) + const auto& typeData = data(); + + if (!std::holds_alternative(typeData)) { throw std::logic_error("Invalid call to Value::get for ScalarType"); } - const auto& scalar = std::get(_data).scalar; + const auto& scalar = std::get(typeData).scalar; if (!scalar) { @@ -215,17 +259,24 @@ const ScalarType& Value::get() const template <> IdType Value::get() const { - if (!std::holds_alternative(_data)) + const auto& typeData = data(); + + if (!std::holds_alternative(typeData)) { throw std::logic_error("Invalid call to Value::get for IdType"); } - return internal::Base64::fromBase64(std::get(_data).string); + return internal::Base64::fromBase64(std::get(typeData).string); } template <> MapType Value::release() { + if (std::holds_alternative(_data)) + { + *this = Value { *std::get(_data) }; + } + if (!std::holds_alternative(_data)) { throw std::logic_error("Invalid call to Value::release for MapType"); @@ -242,6 +293,11 @@ MapType Value::release() template <> ListType Value::release() { + if (std::holds_alternative(_data)) + { + *this = Value { *std::get(_data) }; + } + if (!std::holds_alternative(_data)) { throw std::logic_error("Invalid call to Value::release for ListType"); @@ -255,6 +311,11 @@ ListType Value::release() template <> StringType Value::release() { + if (std::holds_alternative(_data)) + { + *this = Value { *std::get(_data) }; + } + StringType result; if (std::holds_alternative(_data)) @@ -279,6 +340,11 @@ StringType Value::release() template <> ScalarType Value::release() { + if (std::holds_alternative(_data)) + { + *this = Value { *std::get(_data) }; + } + if (!std::holds_alternative(_data)) { throw std::logic_error("Invalid call to Value::release for ScalarType"); @@ -299,6 +365,11 @@ ScalarType Value::release() template <> IdType Value::release() { + if (std::holds_alternative(_data)) + { + *this = Value { *std::get(_data) }; + } + if (!std::holds_alternative(_data)) { throw std::logic_error("Invalid call to Value::release for IdType"); @@ -396,6 +467,12 @@ Value::Value(Value&& other) noexcept Value::Value(const Value& other) { + if (std::holds_alternative(other._data)) + { + _data = std::get(other._data); + return; + } + switch (other.type()) { case Type::Map: @@ -471,6 +548,16 @@ Value::Value(const Value& other) } } +Value::Value(std::shared_ptr value) noexcept + : _data(TypeData { value }) +{ +} + +const Value::TypeData& Value::data() const noexcept +{ + return std::holds_alternative(_data) ? std::get(_data)->data() : _data; +} + Value& Value::operator=(Value&& rhs) noexcept { if (&rhs != this) @@ -483,7 +570,7 @@ Value& Value::operator=(Value&& rhs) noexcept bool Value::operator==(const Value& rhs) const noexcept { - return _data == rhs._data; + return data() == rhs.data(); } bool Value::operator!=(const Value& rhs) const noexcept @@ -493,6 +580,11 @@ bool Value::operator!=(const Value& rhs) const noexcept Type Value::type() const noexcept { + if (std::holds_alternative(_data)) + { + return std::get(_data)->type(); + } + // As long as the order of the variant alternatives matches the Type enum, we can cast the index // to the Type in one step. static_assert( @@ -533,7 +625,11 @@ Type Value::type() const noexcept Value&& Value::from_json() noexcept { - if (std::holds_alternative(_data)) + if (std::holds_alternative(_data)) + { + _data = StringData { { get() }, true }; + } + else if (std::holds_alternative(_data)) { std::get(_data).from_json = true; } @@ -543,12 +639,20 @@ Value&& Value::from_json() noexcept bool Value::maybe_enum() const noexcept { - return std::holds_alternative(_data) - || (std::holds_alternative(_data) && std::get(_data).from_json); + const auto& typeData = data(); + + return std::holds_alternative(typeData) + || (std::holds_alternative(typeData) + && std::get(typeData).from_json); } void Value::reserve(size_t count) { + if (std::holds_alternative(_data)) + { + *this = Value { *std::get(_data) }; + } + switch (type()) { case Type::Map: @@ -577,12 +681,12 @@ size_t Value::size() const { case Type::Map: { - return std::get(_data).map.size(); + return std::get(data()).map.size(); } case Type::List: { - return std::get(_data).size(); + return std::get(data()).size(); } default: @@ -592,6 +696,11 @@ size_t Value::size() const bool Value::emplace_back(std::string&& name, Value&& value) { + if (std::holds_alternative(_data)) + { + *this = Value { *std::get(_data) }; + } + if (!std::holds_alternative(_data)) { throw std::logic_error("Invalid call to Value::emplace_back for MapType"); @@ -620,12 +729,14 @@ bool Value::emplace_back(std::string&& name, Value&& value) MapType::const_iterator Value::find(std::string_view name) const { - if (!std::holds_alternative(_data)) + const auto& typeData = data(); + + if (!std::holds_alternative(typeData)) { throw std::logic_error("Invalid call to Value::find for MapType"); } - const auto& mapData = std::get(_data); + const auto& mapData = std::get(typeData); const auto [itr, itrEnd] = std::equal_range(mapData.members.cbegin(), mapData.members.cend(), std::nullopt, @@ -645,22 +756,26 @@ MapType::const_iterator Value::find(std::string_view name) const MapType::const_iterator Value::begin() const { - if (!std::holds_alternative(_data)) + const auto& typeData = data(); + + if (!std::holds_alternative(typeData)) { throw std::logic_error("Invalid call to Value::begin for MapType"); } - return std::get(_data).map.cbegin(); + return std::get(typeData).map.cbegin(); } MapType::const_iterator Value::end() const { - if (!std::holds_alternative(_data)) + const auto& typeData = data(); + + if (!std::holds_alternative(typeData)) { throw std::logic_error("Invalid call to Value::end for MapType"); } - return std::get(_data).map.cend(); + return std::get(typeData).map.cend(); } const Value& Value::operator[](std::string_view name) const @@ -677,6 +792,11 @@ const Value& Value::operator[](std::string_view name) const void Value::emplace_back(Value&& value) { + if (std::holds_alternative(_data)) + { + *this = Value { *std::get(_data) }; + } + if (!std::holds_alternative(_data)) { throw std::logic_error("Invalid call to Value::emplace_back for ListType"); @@ -687,12 +807,14 @@ void Value::emplace_back(Value&& value) const Value& Value::operator[](size_t index) const { - if (!std::holds_alternative(_data)) + const auto& typeData = data(); + + if (!std::holds_alternative(typeData)) { throw std::logic_error("Invalid call to Value::operator[] for ListType"); } - return std::get(_data).at(index); + return std::get(typeData).at(index); } void Writer::write(Value response) const From e1819779ee2fdd6d05f996479bab3ad4b6b201ea Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Mon, 13 Dec 2021 22:59:38 -0800 Subject: [PATCH 100/119] Check for shared_ptr to Value before awaiting --- include/graphqlservice/GraphQLService.h | 66 ++++++++++++++++++++++++- src/GraphQLService.cpp | 7 +++ 2 files changed, 71 insertions(+), 2 deletions(-) diff --git a/include/graphqlservice/GraphQLService.h b/include/graphqlservice/GraphQLService.h index ceacd71c..f08b9f59 100644 --- a/include/graphqlservice/GraphQLService.h +++ b/include/graphqlservice/GraphQLService.h @@ -357,6 +357,11 @@ class FieldResult return value.wait_for(0s) != std::future_status::timeout; } + else if constexpr (std::is_same_v>) + { + return true; + } }, _value); } @@ -375,7 +380,7 @@ class FieldResult T await_resume() { return std::visit( - [](auto&& value) { + [](auto&& value) -> T { using value_type = std::decay_t; if constexpr (std::is_same_v) @@ -386,12 +391,34 @@ class FieldResult { return value.get(); } + else if constexpr (std::is_same_v>) + { + throw std::logic_error("Cannot await std::shared_ptr"); + } + }, + std::move(_value)); + } + + std::shared_ptr get_value() noexcept + { + return std::visit( + [](auto&& value) noexcept { + using value_type = std::decay_t; + std::shared_ptr result; + + if constexpr (std::is_same_v>) + { + result = std::move(value); + } + + return result; }, std::move(_value)); } private: - std::variant> _value; + std::variant, std::shared_ptr> _value; }; // Fragments are referenced by name and have a single type condition (except for inline @@ -710,6 +737,13 @@ struct ModifiedResult static_assert(std::is_same_v, typename ResultTraits::type>, "this is the derived object type"); + auto value = result.get_value(); + + if (value) + { + co_return ResolverResult { response::Value { std::shared_ptr { std::move(value) } } }; + } + co_await params.launch; auto awaitedResult = co_await ModifiedResult::convert( @@ -738,6 +772,13 @@ struct ModifiedResult convert( typename ResultTraits::future_type result, ResolverParams params) { + auto value = result.get_value(); + + if (value) + { + co_return ResolverResult { response::Value { std::shared_ptr { std::move(value) } } }; + } + co_await params.launch; auto awaitedResult = co_await std::move(result); @@ -765,6 +806,13 @@ struct ModifiedResult typename ResultTraits::type>, "this is the optional version"); + auto value = result.get_value(); + + if (value) + { + co_return ResolverResult { response::Value { std::shared_ptr { std::move(value) } } }; + } + co_await params.launch; auto awaitedResult = co_await std::move(result); @@ -785,6 +833,13 @@ struct ModifiedResult static typename std::enable_if_t convert( typename ResultTraits::future_type result, ResolverParams params) { + auto value = result.get_value(); + + if (value) + { + co_return ResolverResult { response::Value { std::shared_ptr { std::move(value) } } }; + } + std::vector children; const auto parentPath = params.errorPath; @@ -879,6 +934,13 @@ struct ModifiedResult static_assert(!std::is_base_of_v, "ModfiedResult needs special handling"); + auto value = result.get_value(); + + if (value) + { + co_return ResolverResult { response::Value { std::shared_ptr { std::move(value) } } }; + } + auto pendingResolver = std::move(resolver); ResolverResult document; diff --git a/src/GraphQLService.cpp b/src/GraphQLService.cpp index 72c9984d..6fdb7fbf 100644 --- a/src/GraphQLService.cpp +++ b/src/GraphQLService.cpp @@ -696,6 +696,13 @@ template <> AwaitableResolver ModifiedResult::convert( FieldResult> result, ResolverParams params) { + auto value = result.get_value(); + + if (value) + { + co_return ResolverResult { response::Value { std::shared_ptr { std::move(value) } } }; + } + requireSubFields(params); co_await params.launch; From 91a5359b4fb07bc6063fbd6e44699f10dab88665 Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Mon, 13 Dec 2021 23:17:51 -0800 Subject: [PATCH 101/119] Add tests for shared_ptr field results --- samples/today/TodayMock.cpp | 8 ++++---- samples/today/TodayMock.h | 37 +++++++++++++++++++------------------ 2 files changed, 23 insertions(+), 22 deletions(-) diff --git a/samples/today/TodayMock.cpp b/samples/today/TodayMock.cpp index 62baed4a..2a3c758b 100644 --- a/samples/today/TodayMock.cpp +++ b/samples/today/TodayMock.cpp @@ -21,22 +21,22 @@ namespace graphql::today { Appointment::Appointment( response::IdType&& id, std::string&& when, std::string&& subject, bool isNow) : _id(std::move(id)) - , _when(std::move(when)) - , _subject(std::move(subject)) + , _when(std::make_shared(std::move(when))) + , _subject(std::make_shared(std::move(subject))) , _isNow(isNow) { } Task::Task(response::IdType&& id, std::string&& title, bool isComplete) : _id(std::move(id)) - , _title(std::move(title)) + , _title(std::make_shared(std::move(title))) , _isComplete(isComplete) { } Folder::Folder(response::IdType&& id, std::string&& name, int unreadCount) : _id(std::move(id)) - , _name(std::move(name)) + , _name(std::make_shared(std::move(name))) , _unreadCount(unreadCount) { } diff --git a/samples/today/TodayMock.h b/samples/today/TodayMock.h index 79d26baa..8c9f5acb 100644 --- a/samples/today/TodayMock.h +++ b/samples/today/TodayMock.h @@ -8,19 +8,20 @@ #include "TodaySchema.h" -#include "QueryObject.h" +#include "AppointmentEdgeObject.h" +#include "AppointmentObject.h" +#include "FolderEdgeObject.h" +#include "FolderObject.h" #include "MutationObject.h" -#include "SubscriptionObject.h" #include "NodeObject.h" #include "PageInfoObject.h" -#include "AppointmentEdgeObject.h" +#include "QueryObject.h" +#include "SubscriptionObject.h" #include "TaskEdgeObject.h" -#include "FolderEdgeObject.h" -#include "AppointmentObject.h" #include "TaskObject.h" -#include "FolderObject.h" #include +#include #include namespace graphql::today { @@ -146,14 +147,14 @@ class Appointment return _id; } - std::optional getWhen() const noexcept + std::shared_ptr getWhen() const noexcept { - return std::make_optional(std::string(_when)); + return _when; } - std::optional getSubject() const noexcept + std::shared_ptr getSubject() const noexcept { - return std::make_optional(_subject); + return _subject; } bool getIsNow() const noexcept @@ -168,8 +169,8 @@ class Appointment private: response::IdType _id; - std::string _when; - std::string _subject; + std::shared_ptr _when; + std::shared_ptr _subject; bool _isNow; }; @@ -247,9 +248,9 @@ class Task return _id; } - std::optional getTitle() const noexcept + std::shared_ptr getTitle() const noexcept { - return std::make_optional(_title); + return _title; } bool getIsComplete() const noexcept @@ -259,7 +260,7 @@ class Task private: response::IdType _id; - std::string _title; + std::shared_ptr _title; bool _isComplete; TaskState _state = TaskState::New; }; @@ -337,9 +338,9 @@ class Folder return _id; } - std::optional getName() const noexcept + std::shared_ptr getName() const noexcept { - return std::make_optional(_name); + return _name; } int getUnreadCount() const noexcept @@ -349,7 +350,7 @@ class Folder private: response::IdType _id; - std::string _name; + std::shared_ptr _name; int _unreadCount; }; From a33724a98d1c3b1a800c938197f4e87fed7220be Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Tue, 14 Dec 2021 10:44:19 -0800 Subject: [PATCH 102/119] Distinguish AwaitableScalar from AwaitableObject --- doc/resolvers.md | 2 +- include/graphqlservice/GraphQLService.h | 173 ++++++++++++++---- .../introspection/DirectiveObject.h | 20 +- .../introspection/EnumValueObject.h | 16 +- .../introspection/FieldObject.h | 24 +-- .../introspection/InputValueObject.h | 16 +- .../introspection/IntrospectionSchema.h | 4 +- .../introspection/SchemaObject.h | 24 +-- .../graphqlservice/introspection/TypeObject.h | 40 ++-- samples/learn/schema/DroidObject.h | 40 ++-- samples/learn/schema/HumanObject.h | 40 ++-- samples/learn/schema/MutationObject.h | 8 +- samples/learn/schema/QueryObject.h | 24 +-- samples/learn/schema/ReviewObject.h | 16 +- samples/learn/schema/StarWarsSchema.cpp | 2 +- samples/today/TodayMock.cpp | 2 +- samples/today/TodayMock.h | 14 +- .../AppointmentConnectionObject.h | 16 +- .../nointrospection/AppointmentEdgeObject.h | 16 +- .../today/nointrospection/AppointmentObject.h | 40 ++-- .../CompleteTaskPayloadObject.h | 16 +- .../today/nointrospection/ExpensiveObject.h | 8 +- .../nointrospection/FolderConnectionObject.h | 16 +- .../today/nointrospection/FolderEdgeObject.h | 16 +- samples/today/nointrospection/FolderObject.h | 24 +-- .../today/nointrospection/MutationObject.h | 16 +- .../today/nointrospection/NestedTypeObject.h | 16 +- .../today/nointrospection/PageInfoObject.h | 16 +- samples/today/nointrospection/QueryObject.h | 96 +++++----- .../nointrospection/SubscriptionObject.h | 16 +- .../nointrospection/TaskConnectionObject.h | 16 +- .../today/nointrospection/TaskEdgeObject.h | 16 +- samples/today/nointrospection/TaskObject.h | 24 +-- samples/today/nointrospection/TodaySchema.cpp | 2 +- .../schema/AppointmentConnectionObject.h | 16 +- samples/today/schema/AppointmentEdgeObject.h | 16 +- samples/today/schema/AppointmentObject.h | 40 ++-- .../today/schema/CompleteTaskPayloadObject.h | 16 +- samples/today/schema/ExpensiveObject.h | 8 +- samples/today/schema/FolderConnectionObject.h | 16 +- samples/today/schema/FolderEdgeObject.h | 16 +- samples/today/schema/FolderObject.h | 24 +-- samples/today/schema/MutationObject.h | 16 +- samples/today/schema/NestedTypeObject.h | 16 +- samples/today/schema/PageInfoObject.h | 16 +- samples/today/schema/QueryObject.h | 96 +++++----- samples/today/schema/SubscriptionObject.h | 16 +- samples/today/schema/TaskConnectionObject.h | 16 +- samples/today/schema/TaskEdgeObject.h | 16 +- samples/today/schema/TaskObject.h | 24 +-- samples/today/schema/TodaySchema.cpp | 2 +- samples/validation/schema/AlienObject.h | 16 +- samples/validation/schema/ArgumentsObject.h | 64 +++---- samples/validation/schema/CatObject.h | 32 ++-- samples/validation/schema/DogObject.h | 48 ++--- samples/validation/schema/HumanObject.h | 16 +- samples/validation/schema/MessageObject.h | 16 +- .../validation/schema/MutateDogResultObject.h | 8 +- samples/validation/schema/MutationObject.h | 8 +- samples/validation/schema/QueryObject.h | 64 +++---- .../validation/schema/SubscriptionObject.h | 16 +- .../validation/schema/ValidationSchema.cpp | 4 +- src/GraphQLService.cpp | 22 +-- src/SchemaGenerator.cpp | 20 +- src/SchemaLoader.cpp | 16 ++ src/introspection/DirectiveObject.h | 20 +- src/introspection/EnumValueObject.h | 16 +- src/introspection/FieldObject.h | 24 +-- src/introspection/InputValueObject.h | 16 +- src/introspection/IntrospectionSchema.cpp | 4 +- src/introspection/IntrospectionSchema.h | 4 +- src/introspection/SchemaObject.h | 24 +-- src/introspection/TypeObject.h | 40 ++-- 73 files changed, 908 insertions(+), 795 deletions(-) diff --git a/doc/resolvers.md b/doc/resolvers.md index cf328e64..a66e3b4e 100644 --- a/doc/resolvers.md +++ b/doc/resolvers.md @@ -73,7 +73,7 @@ service::AwaitableResolver resolveId(service::ResolverParams&& params); ``` In this example, the `resolveId` method invokes `getId`: ```cpp -virtual service::FieldResult getId(service::FieldParams&& params) const override; +virtual service::AwaitableScalar getId(service::FieldParams&& params) const override; ``` There are a couple of interesting quirks in this example: diff --git a/include/graphqlservice/GraphQLService.h b/include/graphqlservice/GraphQLService.h index f08b9f59..72586736 100644 --- a/include/graphqlservice/GraphQLService.h +++ b/include/graphqlservice/GraphQLService.h @@ -295,19 +295,25 @@ struct FieldParams : SelectionSetParams // Field accessors may return either a result of T, an awaitable of T, or a std::future, so at // runtime the implementer may choose to return by value or defer/parallelize expensive operations // by returning an async future or an awaitable coroutine. +// +// If the overhead of conversion to response::Value is too expensive, scalar type field accessors +// can store and return a std::shared_ptr directly. However, be careful using +// this mechanism, because there's no validation that the response::Value you return matches the +// GraphQL type of this field. It will be inserted directly into the response document without +// modification. template -class FieldResult +class AwaitableScalar { public: template - FieldResult(U&& value) + AwaitableScalar(U&& value) : _value { std::forward(value) } { } struct promise_type { - FieldResult get_return_object() noexcept + AwaitableScalar get_return_object() noexcept { return { _promise.get_future() }; } @@ -421,6 +427,108 @@ class FieldResult std::variant, std::shared_ptr> _value; }; +// Field accessors may return either a result of T, an awaitable of T, or a std::future, so at +// runtime the implementer may choose to return by value or defer/parallelize expensive operations +// by returning an async future or an awaitable coroutine. +template +class AwaitableObject +{ +public: + template + AwaitableObject(U&& value) + : _value { std::forward(value) } + { + } + + struct promise_type + { + AwaitableObject get_return_object() noexcept + { + return { _promise.get_future() }; + } + + coro::suspend_never initial_suspend() const noexcept + { + return {}; + } + + coro::suspend_never final_suspend() const noexcept + { + return {}; + } + + void return_value(const T& value) noexcept(std::is_nothrow_copy_constructible_v) + { + _promise.set_value(value); + } + + void return_value(T&& value) noexcept(std::is_nothrow_move_constructible_v) + { + _promise.set_value(std::move(value)); + } + + void unhandled_exception() noexcept + { + _promise.set_exception(std::current_exception()); + } + + private: + std::promise _promise; + }; + + bool await_ready() const noexcept + { + return std::visit( + [](const auto& value) noexcept { + using value_type = std::decay_t; + + if constexpr (std::is_same_v) + { + return true; + } + else if constexpr (std::is_same_v>) + { + using namespace std::literals; + + return value.wait_for(0s) != std::future_status::timeout; + } + }, + _value); + } + + void await_suspend(coro::coroutine_handle<> h) const + { + std::thread( + [this](coro::coroutine_handle<> h) noexcept { + std::get>(_value).wait(); + h.resume(); + }, + std::move(h)) + .detach(); + } + + T await_resume() + { + return std::visit( + [](auto&& value) -> T { + using value_type = std::decay_t; + + if constexpr (std::is_same_v) + { + return T { std::move(value) }; + } + else if constexpr (std::is_same_v>) + { + return value.get(); + } + }, + std::move(_value)); + } + +private: + std::variant> _value; +}; + // Fragments are referenced by name and have a single type condition (except for inline // fragments, where the type condition is common but optional). They contain a set of fields // (with optional aliases and sub-selections) and potentially references to other fragments. @@ -708,7 +816,8 @@ struct ModifiedResult std::vector::type>, typename std::conditional_t, std::shared_ptr, U>>>; - using future_type = FieldResult; + using future_type = typename std::conditional_t, + AwaitableObject, AwaitableScalar>; }; template @@ -718,7 +827,7 @@ struct ModifiedResult typename std::conditional_t, std::shared_ptr, U>; using future_type = typename std::conditional_t, - FieldResult>, FieldResult>; + AwaitableObject>, AwaitableScalar>; }; // Convert a single value of the specified type to JSON. @@ -730,20 +839,13 @@ struct ModifiedResult static typename std::enable_if_t && std::is_base_of_v, AwaitableResolver> - convert(FieldResult::type> result, ResolverParams params) + convert(AwaitableObject::type> result, ResolverParams params) { // Call through to the Object specialization with a static_pointer_cast for subclasses of // Object. static_assert(std::is_same_v, typename ResultTraits::type>, "this is the derived object type"); - auto value = result.get_value(); - - if (value) - { - co_return ResolverResult { response::Value { std::shared_ptr { std::move(value) } } }; - } - co_await params.launch; auto awaitedResult = co_await ModifiedResult::convert( @@ -772,13 +874,6 @@ struct ModifiedResult convert( typename ResultTraits::future_type result, ResolverParams params) { - auto value = result.get_value(); - - if (value) - { - co_return ResolverResult { response::Value { std::shared_ptr { std::move(value) } } }; - } - co_await params.launch; auto awaitedResult = co_await std::move(result); @@ -806,11 +901,15 @@ struct ModifiedResult typename ResultTraits::type>, "this is the optional version"); - auto value = result.get_value(); - - if (value) + if constexpr (!std::is_base_of_v) { - co_return ResolverResult { response::Value { std::shared_ptr { std::move(value) } } }; + auto value = result.get_value(); + + if (value) + { + co_return ResolverResult { response::Value { + std::shared_ptr { std::move(value) } } }; + } } co_await params.launch; @@ -833,11 +932,15 @@ struct ModifiedResult static typename std::enable_if_t convert( typename ResultTraits::future_type result, ResolverParams params) { - auto value = result.get_value(); - - if (value) + if constexpr (!std::is_base_of_v) { - co_return ResolverResult { response::Value { std::shared_ptr { std::move(value) } } }; + auto value = result.get_value(); + + if (value) + { + co_return ResolverResult { response::Value { + std::shared_ptr { std::move(value) } } }; + } } std::vector children; @@ -988,25 +1091,25 @@ using ObjectResult = ModifiedResult; // Export all of the built-in converters template <> GRAPHQLSERVICE_EXPORT AwaitableResolver ModifiedResult::convert( - FieldResult result, ResolverParams params); + AwaitableScalar result, ResolverParams params); template <> GRAPHQLSERVICE_EXPORT AwaitableResolver ModifiedResult::convert( - FieldResult result, ResolverParams params); + AwaitableScalar result, ResolverParams params); template <> GRAPHQLSERVICE_EXPORT AwaitableResolver ModifiedResult::convert( - FieldResult result, ResolverParams params); + AwaitableScalar result, ResolverParams params); template <> GRAPHQLSERVICE_EXPORT AwaitableResolver ModifiedResult::convert( - FieldResult result, ResolverParams params); + AwaitableScalar result, ResolverParams params); template <> GRAPHQLSERVICE_EXPORT AwaitableResolver ModifiedResult::convert( - FieldResult result, ResolverParams params); + AwaitableScalar result, ResolverParams params); template <> GRAPHQLSERVICE_EXPORT AwaitableResolver ModifiedResult::convert( - FieldResult result, ResolverParams params); + AwaitableScalar result, ResolverParams params); template <> GRAPHQLSERVICE_EXPORT AwaitableResolver ModifiedResult::convert( - FieldResult> result, ResolverParams params); + AwaitableObject> result, ResolverParams params); #endif // GRAPHQL_DLLEXPORTS // Subscription callbacks receive the response::Value representing the result of evaluating the diff --git a/include/graphqlservice/introspection/DirectiveObject.h b/include/graphqlservice/introspection/DirectiveObject.h index 2349fe17..22b77759 100644 --- a/include/graphqlservice/introspection/DirectiveObject.h +++ b/include/graphqlservice/introspection/DirectiveObject.h @@ -28,11 +28,11 @@ class Directive { virtual ~Concept() = default; - virtual service::FieldResult getName() const = 0; - virtual service::FieldResult> getDescription() const = 0; - virtual service::FieldResult> getLocations() const = 0; - virtual service::FieldResult>> getArgs() const = 0; - virtual service::FieldResult getIsRepeatable() const = 0; + virtual service::AwaitableScalar getName() const = 0; + virtual service::AwaitableScalar> getDescription() const = 0; + virtual service::AwaitableScalar> getLocations() const = 0; + virtual service::AwaitableObject>> getArgs() const = 0; + virtual service::AwaitableScalar getIsRepeatable() const = 0; }; template @@ -44,27 +44,27 @@ class Directive { } - service::FieldResult getName() const final + service::AwaitableScalar getName() const final { return { _pimpl->getName() }; } - service::FieldResult> getDescription() const final + service::AwaitableScalar> getDescription() const final { return { _pimpl->getDescription() }; } - service::FieldResult> getLocations() const final + service::AwaitableScalar> getLocations() const final { return { _pimpl->getLocations() }; } - service::FieldResult>> getArgs() const final + service::AwaitableObject>> getArgs() const final { return { _pimpl->getArgs() }; } - service::FieldResult getIsRepeatable() const final + service::AwaitableScalar getIsRepeatable() const final { return { _pimpl->getIsRepeatable() }; } diff --git a/include/graphqlservice/introspection/EnumValueObject.h b/include/graphqlservice/introspection/EnumValueObject.h index f52cc584..390565c7 100644 --- a/include/graphqlservice/introspection/EnumValueObject.h +++ b/include/graphqlservice/introspection/EnumValueObject.h @@ -27,10 +27,10 @@ class EnumValue { virtual ~Concept() = default; - virtual service::FieldResult getName() const = 0; - virtual service::FieldResult> getDescription() const = 0; - virtual service::FieldResult getIsDeprecated() const = 0; - virtual service::FieldResult> getDeprecationReason() const = 0; + virtual service::AwaitableScalar getName() const = 0; + virtual service::AwaitableScalar> getDescription() const = 0; + virtual service::AwaitableScalar getIsDeprecated() const = 0; + virtual service::AwaitableScalar> getDeprecationReason() const = 0; }; template @@ -42,22 +42,22 @@ class EnumValue { } - service::FieldResult getName() const final + service::AwaitableScalar getName() const final { return { _pimpl->getName() }; } - service::FieldResult> getDescription() const final + service::AwaitableScalar> getDescription() const final { return { _pimpl->getDescription() }; } - service::FieldResult getIsDeprecated() const final + service::AwaitableScalar getIsDeprecated() const final { return { _pimpl->getIsDeprecated() }; } - service::FieldResult> getDeprecationReason() const final + service::AwaitableScalar> getDeprecationReason() const final { return { _pimpl->getDeprecationReason() }; } diff --git a/include/graphqlservice/introspection/FieldObject.h b/include/graphqlservice/introspection/FieldObject.h index 1d50a0cd..778286e0 100644 --- a/include/graphqlservice/introspection/FieldObject.h +++ b/include/graphqlservice/introspection/FieldObject.h @@ -29,12 +29,12 @@ class Field { virtual ~Concept() = default; - virtual service::FieldResult getName() const = 0; - virtual service::FieldResult> getDescription() const = 0; - virtual service::FieldResult>> getArgs() const = 0; - virtual service::FieldResult> getType() const = 0; - virtual service::FieldResult getIsDeprecated() const = 0; - virtual service::FieldResult> getDeprecationReason() const = 0; + virtual service::AwaitableScalar getName() const = 0; + virtual service::AwaitableScalar> getDescription() const = 0; + virtual service::AwaitableObject>> getArgs() const = 0; + virtual service::AwaitableObject> getType() const = 0; + virtual service::AwaitableScalar getIsDeprecated() const = 0; + virtual service::AwaitableScalar> getDeprecationReason() const = 0; }; template @@ -46,32 +46,32 @@ class Field { } - service::FieldResult getName() const final + service::AwaitableScalar getName() const final { return { _pimpl->getName() }; } - service::FieldResult> getDescription() const final + service::AwaitableScalar> getDescription() const final { return { _pimpl->getDescription() }; } - service::FieldResult>> getArgs() const final + service::AwaitableObject>> getArgs() const final { return { _pimpl->getArgs() }; } - service::FieldResult> getType() const final + service::AwaitableObject> getType() const final { return { _pimpl->getType() }; } - service::FieldResult getIsDeprecated() const final + service::AwaitableScalar getIsDeprecated() const final { return { _pimpl->getIsDeprecated() }; } - service::FieldResult> getDeprecationReason() const final + service::AwaitableScalar> getDeprecationReason() const final { return { _pimpl->getDeprecationReason() }; } diff --git a/include/graphqlservice/introspection/InputValueObject.h b/include/graphqlservice/introspection/InputValueObject.h index 65199e06..1b9ed622 100644 --- a/include/graphqlservice/introspection/InputValueObject.h +++ b/include/graphqlservice/introspection/InputValueObject.h @@ -27,10 +27,10 @@ class InputValue { virtual ~Concept() = default; - virtual service::FieldResult getName() const = 0; - virtual service::FieldResult> getDescription() const = 0; - virtual service::FieldResult> getType() const = 0; - virtual service::FieldResult> getDefaultValue() const = 0; + virtual service::AwaitableScalar getName() const = 0; + virtual service::AwaitableScalar> getDescription() const = 0; + virtual service::AwaitableObject> getType() const = 0; + virtual service::AwaitableScalar> getDefaultValue() const = 0; }; template @@ -42,22 +42,22 @@ class InputValue { } - service::FieldResult getName() const final + service::AwaitableScalar getName() const final { return { _pimpl->getName() }; } - service::FieldResult> getDescription() const final + service::AwaitableScalar> getDescription() const final { return { _pimpl->getDescription() }; } - service::FieldResult> getType() const final + service::AwaitableObject> getType() const final { return { _pimpl->getType() }; } - service::FieldResult> getDefaultValue() const final + service::AwaitableScalar> getDefaultValue() const final { return { _pimpl->getDefaultValue() }; } diff --git a/include/graphqlservice/introspection/IntrospectionSchema.h b/include/graphqlservice/introspection/IntrospectionSchema.h index d833ce84..6c50cd2f 100644 --- a/include/graphqlservice/introspection/IntrospectionSchema.h +++ b/include/graphqlservice/introspection/IntrospectionSchema.h @@ -106,13 +106,13 @@ GRAPHQLINTROSPECTION_EXPORT introspection::TypeKind ModifiedArgument GRAPHQLINTROSPECTION_EXPORT AwaitableResolver ModifiedResult::convert( - FieldResult result, ResolverParams params); + AwaitableScalar result, ResolverParams params); template <> GRAPHQLINTROSPECTION_EXPORT introspection::DirectiveLocation ModifiedArgument::convert( const response::Value& value); template <> GRAPHQLINTROSPECTION_EXPORT AwaitableResolver ModifiedResult::convert( - FieldResult result, ResolverParams params); + AwaitableScalar result, ResolverParams params); #endif // GRAPHQL_DLLEXPORTS } // namespace service diff --git a/include/graphqlservice/introspection/SchemaObject.h b/include/graphqlservice/introspection/SchemaObject.h index 9a4b082a..a8f05373 100644 --- a/include/graphqlservice/introspection/SchemaObject.h +++ b/include/graphqlservice/introspection/SchemaObject.h @@ -29,12 +29,12 @@ class Schema { virtual ~Concept() = default; - virtual service::FieldResult> getDescription() const = 0; - virtual service::FieldResult>> getTypes() const = 0; - virtual service::FieldResult> getQueryType() const = 0; - virtual service::FieldResult> getMutationType() const = 0; - virtual service::FieldResult> getSubscriptionType() const = 0; - virtual service::FieldResult>> getDirectives() const = 0; + virtual service::AwaitableScalar> getDescription() const = 0; + virtual service::AwaitableObject>> getTypes() const = 0; + virtual service::AwaitableObject> getQueryType() const = 0; + virtual service::AwaitableObject> getMutationType() const = 0; + virtual service::AwaitableObject> getSubscriptionType() const = 0; + virtual service::AwaitableObject>> getDirectives() const = 0; }; template @@ -46,32 +46,32 @@ class Schema { } - service::FieldResult> getDescription() const final + service::AwaitableScalar> getDescription() const final { return { _pimpl->getDescription() }; } - service::FieldResult>> getTypes() const final + service::AwaitableObject>> getTypes() const final { return { _pimpl->getTypes() }; } - service::FieldResult> getQueryType() const final + service::AwaitableObject> getQueryType() const final { return { _pimpl->getQueryType() }; } - service::FieldResult> getMutationType() const final + service::AwaitableObject> getMutationType() const final { return { _pimpl->getMutationType() }; } - service::FieldResult> getSubscriptionType() const final + service::AwaitableObject> getSubscriptionType() const final { return { _pimpl->getSubscriptionType() }; } - service::FieldResult>> getDirectives() const final + service::AwaitableObject>> getDirectives() const final { return { _pimpl->getDirectives() }; } diff --git a/include/graphqlservice/introspection/TypeObject.h b/include/graphqlservice/introspection/TypeObject.h index 484980e1..32bc9bdb 100644 --- a/include/graphqlservice/introspection/TypeObject.h +++ b/include/graphqlservice/introspection/TypeObject.h @@ -33,16 +33,16 @@ class Type { virtual ~Concept() = default; - virtual service::FieldResult getKind() const = 0; - virtual service::FieldResult> getName() const = 0; - virtual service::FieldResult> getDescription() const = 0; - virtual service::FieldResult>>> getFields(std::optional&& includeDeprecatedArg) const = 0; - virtual service::FieldResult>>> getInterfaces() const = 0; - virtual service::FieldResult>>> getPossibleTypes() const = 0; - virtual service::FieldResult>>> getEnumValues(std::optional&& includeDeprecatedArg) const = 0; - virtual service::FieldResult>>> getInputFields() const = 0; - virtual service::FieldResult> getOfType() const = 0; - virtual service::FieldResult> getSpecifiedByURL() const = 0; + virtual service::AwaitableScalar getKind() const = 0; + virtual service::AwaitableScalar> getName() const = 0; + virtual service::AwaitableScalar> getDescription() const = 0; + virtual service::AwaitableObject>>> getFields(std::optional&& includeDeprecatedArg) const = 0; + virtual service::AwaitableObject>>> getInterfaces() const = 0; + virtual service::AwaitableObject>>> getPossibleTypes() const = 0; + virtual service::AwaitableObject>>> getEnumValues(std::optional&& includeDeprecatedArg) const = 0; + virtual service::AwaitableObject>>> getInputFields() const = 0; + virtual service::AwaitableObject> getOfType() const = 0; + virtual service::AwaitableScalar> getSpecifiedByURL() const = 0; }; template @@ -54,52 +54,52 @@ class Type { } - service::FieldResult getKind() const final + service::AwaitableScalar getKind() const final { return { _pimpl->getKind() }; } - service::FieldResult> getName() const final + service::AwaitableScalar> getName() const final { return { _pimpl->getName() }; } - service::FieldResult> getDescription() const final + service::AwaitableScalar> getDescription() const final { return { _pimpl->getDescription() }; } - service::FieldResult>>> getFields(std::optional&& includeDeprecatedArg) const final + service::AwaitableObject>>> getFields(std::optional&& includeDeprecatedArg) const final { return { _pimpl->getFields(std::move(includeDeprecatedArg)) }; } - service::FieldResult>>> getInterfaces() const final + service::AwaitableObject>>> getInterfaces() const final { return { _pimpl->getInterfaces() }; } - service::FieldResult>>> getPossibleTypes() const final + service::AwaitableObject>>> getPossibleTypes() const final { return { _pimpl->getPossibleTypes() }; } - service::FieldResult>>> getEnumValues(std::optional&& includeDeprecatedArg) const final + service::AwaitableObject>>> getEnumValues(std::optional&& includeDeprecatedArg) const final { return { _pimpl->getEnumValues(std::move(includeDeprecatedArg)) }; } - service::FieldResult>>> getInputFields() const final + service::AwaitableObject>>> getInputFields() const final { return { _pimpl->getInputFields() }; } - service::FieldResult> getOfType() const final + service::AwaitableObject> getOfType() const final { return { _pimpl->getOfType() }; } - service::FieldResult> getSpecifiedByURL() const final + service::AwaitableScalar> getSpecifiedByURL() const final { return { _pimpl->getSpecifiedByURL() }; } diff --git a/samples/learn/schema/DroidObject.h b/samples/learn/schema/DroidObject.h index edd290b9..748b5d0e 100644 --- a/samples/learn/schema/DroidObject.h +++ b/samples/learn/schema/DroidObject.h @@ -23,61 +23,61 @@ namespace methods::DroidHas { template concept getIdWithParams = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult { impl.getId(std::move(params)) } }; + { service::AwaitableScalar { impl.getId(std::move(params)) } }; }; template concept getId = requires (TImpl impl) { - { service::FieldResult { impl.getId() } }; + { service::AwaitableScalar { impl.getId() } }; }; template concept getNameWithParams = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult> { impl.getName(std::move(params)) } }; + { service::AwaitableScalar> { impl.getName(std::move(params)) } }; }; template concept getName = requires (TImpl impl) { - { service::FieldResult> { impl.getName() } }; + { service::AwaitableScalar> { impl.getName() } }; }; template concept getFriendsWithParams = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult>>> { impl.getFriends(std::move(params)) } }; + { service::AwaitableObject>>> { impl.getFriends(std::move(params)) } }; }; template concept getFriends = requires (TImpl impl) { - { service::FieldResult>>> { impl.getFriends() } }; + { service::AwaitableObject>>> { impl.getFriends() } }; }; template concept getAppearsInWithParams = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult>>> { impl.getAppearsIn(std::move(params)) } }; + { service::AwaitableScalar>>> { impl.getAppearsIn(std::move(params)) } }; }; template concept getAppearsIn = requires (TImpl impl) { - { service::FieldResult>>> { impl.getAppearsIn() } }; + { service::AwaitableScalar>>> { impl.getAppearsIn() } }; }; template concept getPrimaryFunctionWithParams = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult> { impl.getPrimaryFunction(std::move(params)) } }; + { service::AwaitableScalar> { impl.getPrimaryFunction(std::move(params)) } }; }; template concept getPrimaryFunction = requires (TImpl impl) { - { service::FieldResult> { impl.getPrimaryFunction() } }; + { service::AwaitableScalar> { impl.getPrimaryFunction() } }; }; template @@ -113,11 +113,11 @@ class Droid virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual service::FieldResult getId(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getName(service::FieldParams&& params) const = 0; - virtual service::FieldResult>>> getFriends(service::FieldParams&& params) const = 0; - virtual service::FieldResult>>> getAppearsIn(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getPrimaryFunction(service::FieldParams&& params) const = 0; + virtual service::AwaitableScalar getId(service::FieldParams&& params) const = 0; + virtual service::AwaitableScalar> getName(service::FieldParams&& params) const = 0; + virtual service::AwaitableObject>>> getFriends(service::FieldParams&& params) const = 0; + virtual service::AwaitableScalar>>> getAppearsIn(service::FieldParams&& params) const = 0; + virtual service::AwaitableScalar> getPrimaryFunction(service::FieldParams&& params) const = 0; }; template @@ -129,7 +129,7 @@ class Droid { } - service::FieldResult getId(service::FieldParams&& params) const final + service::AwaitableScalar getId(service::FieldParams&& params) const final { if constexpr (methods::DroidHas::getIdWithParams) { @@ -142,7 +142,7 @@ class Droid } } - service::FieldResult> getName(service::FieldParams&& params) const final + service::AwaitableScalar> getName(service::FieldParams&& params) const final { if constexpr (methods::DroidHas::getNameWithParams) { @@ -155,7 +155,7 @@ class Droid } } - service::FieldResult>>> getFriends(service::FieldParams&& params) const final + service::AwaitableObject>>> getFriends(service::FieldParams&& params) const final { if constexpr (methods::DroidHas::getFriendsWithParams) { @@ -168,7 +168,7 @@ class Droid } } - service::FieldResult>>> getAppearsIn(service::FieldParams&& params) const final + service::AwaitableScalar>>> getAppearsIn(service::FieldParams&& params) const final { if constexpr (methods::DroidHas::getAppearsInWithParams) { @@ -181,7 +181,7 @@ class Droid } } - service::FieldResult> getPrimaryFunction(service::FieldParams&& params) const final + service::AwaitableScalar> getPrimaryFunction(service::FieldParams&& params) const final { if constexpr (methods::DroidHas::getPrimaryFunctionWithParams) { diff --git a/samples/learn/schema/HumanObject.h b/samples/learn/schema/HumanObject.h index 60b0ced4..11eef4e0 100644 --- a/samples/learn/schema/HumanObject.h +++ b/samples/learn/schema/HumanObject.h @@ -23,61 +23,61 @@ namespace methods::HumanHas { template concept getIdWithParams = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult { impl.getId(std::move(params)) } }; + { service::AwaitableScalar { impl.getId(std::move(params)) } }; }; template concept getId = requires (TImpl impl) { - { service::FieldResult { impl.getId() } }; + { service::AwaitableScalar { impl.getId() } }; }; template concept getNameWithParams = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult> { impl.getName(std::move(params)) } }; + { service::AwaitableScalar> { impl.getName(std::move(params)) } }; }; template concept getName = requires (TImpl impl) { - { service::FieldResult> { impl.getName() } }; + { service::AwaitableScalar> { impl.getName() } }; }; template concept getFriendsWithParams = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult>>> { impl.getFriends(std::move(params)) } }; + { service::AwaitableObject>>> { impl.getFriends(std::move(params)) } }; }; template concept getFriends = requires (TImpl impl) { - { service::FieldResult>>> { impl.getFriends() } }; + { service::AwaitableObject>>> { impl.getFriends() } }; }; template concept getAppearsInWithParams = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult>>> { impl.getAppearsIn(std::move(params)) } }; + { service::AwaitableScalar>>> { impl.getAppearsIn(std::move(params)) } }; }; template concept getAppearsIn = requires (TImpl impl) { - { service::FieldResult>>> { impl.getAppearsIn() } }; + { service::AwaitableScalar>>> { impl.getAppearsIn() } }; }; template concept getHomePlanetWithParams = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult> { impl.getHomePlanet(std::move(params)) } }; + { service::AwaitableScalar> { impl.getHomePlanet(std::move(params)) } }; }; template concept getHomePlanet = requires (TImpl impl) { - { service::FieldResult> { impl.getHomePlanet() } }; + { service::AwaitableScalar> { impl.getHomePlanet() } }; }; template @@ -113,11 +113,11 @@ class Human virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual service::FieldResult getId(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getName(service::FieldParams&& params) const = 0; - virtual service::FieldResult>>> getFriends(service::FieldParams&& params) const = 0; - virtual service::FieldResult>>> getAppearsIn(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getHomePlanet(service::FieldParams&& params) const = 0; + virtual service::AwaitableScalar getId(service::FieldParams&& params) const = 0; + virtual service::AwaitableScalar> getName(service::FieldParams&& params) const = 0; + virtual service::AwaitableObject>>> getFriends(service::FieldParams&& params) const = 0; + virtual service::AwaitableScalar>>> getAppearsIn(service::FieldParams&& params) const = 0; + virtual service::AwaitableScalar> getHomePlanet(service::FieldParams&& params) const = 0; }; template @@ -129,7 +129,7 @@ class Human { } - service::FieldResult getId(service::FieldParams&& params) const final + service::AwaitableScalar getId(service::FieldParams&& params) const final { if constexpr (methods::HumanHas::getIdWithParams) { @@ -142,7 +142,7 @@ class Human } } - service::FieldResult> getName(service::FieldParams&& params) const final + service::AwaitableScalar> getName(service::FieldParams&& params) const final { if constexpr (methods::HumanHas::getNameWithParams) { @@ -155,7 +155,7 @@ class Human } } - service::FieldResult>>> getFriends(service::FieldParams&& params) const final + service::AwaitableObject>>> getFriends(service::FieldParams&& params) const final { if constexpr (methods::HumanHas::getFriendsWithParams) { @@ -168,7 +168,7 @@ class Human } } - service::FieldResult>>> getAppearsIn(service::FieldParams&& params) const final + service::AwaitableScalar>>> getAppearsIn(service::FieldParams&& params) const final { if constexpr (methods::HumanHas::getAppearsInWithParams) { @@ -181,7 +181,7 @@ class Human } } - service::FieldResult> getHomePlanet(service::FieldParams&& params) const final + service::AwaitableScalar> getHomePlanet(service::FieldParams&& params) const final { if constexpr (methods::HumanHas::getHomePlanetWithParams) { diff --git a/samples/learn/schema/MutationObject.h b/samples/learn/schema/MutationObject.h index a6cf98d7..f4fc93a6 100644 --- a/samples/learn/schema/MutationObject.h +++ b/samples/learn/schema/MutationObject.h @@ -16,13 +16,13 @@ namespace methods::MutationHas { template concept applyCreateReviewWithParams = requires (TImpl impl, service::FieldParams params, Episode epArg, ReviewInput reviewArg) { - { service::FieldResult> { impl.applyCreateReview(std::move(params), std::move(epArg), std::move(reviewArg)) } }; + { service::AwaitableObject> { impl.applyCreateReview(std::move(params), std::move(epArg), std::move(reviewArg)) } }; }; template concept applyCreateReview = requires (TImpl impl, Episode epArg, ReviewInput reviewArg) { - { service::FieldResult> { impl.applyCreateReview(std::move(epArg), std::move(reviewArg)) } }; + { service::AwaitableObject> { impl.applyCreateReview(std::move(epArg), std::move(reviewArg)) } }; }; template @@ -54,7 +54,7 @@ class Mutation virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual service::FieldResult> applyCreateReview(service::FieldParams&& params, Episode&& epArg, ReviewInput&& reviewArg) const = 0; + virtual service::AwaitableObject> applyCreateReview(service::FieldParams&& params, Episode&& epArg, ReviewInput&& reviewArg) const = 0; }; template @@ -66,7 +66,7 @@ class Mutation { } - service::FieldResult> applyCreateReview(service::FieldParams&& params, Episode&& epArg, ReviewInput&& reviewArg) const final + service::AwaitableObject> applyCreateReview(service::FieldParams&& params, Episode&& epArg, ReviewInput&& reviewArg) const final { if constexpr (methods::MutationHas::applyCreateReviewWithParams) { diff --git a/samples/learn/schema/QueryObject.h b/samples/learn/schema/QueryObject.h index b3fa5bab..fba68923 100644 --- a/samples/learn/schema/QueryObject.h +++ b/samples/learn/schema/QueryObject.h @@ -16,37 +16,37 @@ namespace methods::QueryHas { template concept getHeroWithParams = requires (TImpl impl, service::FieldParams params, std::optional episodeArg) { - { service::FieldResult> { impl.getHero(std::move(params), std::move(episodeArg)) } }; + { service::AwaitableObject> { impl.getHero(std::move(params), std::move(episodeArg)) } }; }; template concept getHero = requires (TImpl impl, std::optional episodeArg) { - { service::FieldResult> { impl.getHero(std::move(episodeArg)) } }; + { service::AwaitableObject> { impl.getHero(std::move(episodeArg)) } }; }; template concept getHumanWithParams = requires (TImpl impl, service::FieldParams params, std::string idArg) { - { service::FieldResult> { impl.getHuman(std::move(params), std::move(idArg)) } }; + { service::AwaitableObject> { impl.getHuman(std::move(params), std::move(idArg)) } }; }; template concept getHuman = requires (TImpl impl, std::string idArg) { - { service::FieldResult> { impl.getHuman(std::move(idArg)) } }; + { service::AwaitableObject> { impl.getHuman(std::move(idArg)) } }; }; template concept getDroidWithParams = requires (TImpl impl, service::FieldParams params, std::string idArg) { - { service::FieldResult> { impl.getDroid(std::move(params), std::move(idArg)) } }; + { service::AwaitableObject> { impl.getDroid(std::move(params), std::move(idArg)) } }; }; template concept getDroid = requires (TImpl impl, std::string idArg) { - { service::FieldResult> { impl.getDroid(std::move(idArg)) } }; + { service::AwaitableObject> { impl.getDroid(std::move(idArg)) } }; }; template @@ -84,9 +84,9 @@ class Query virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual service::FieldResult> getHero(service::FieldParams&& params, std::optional&& episodeArg) const = 0; - virtual service::FieldResult> getHuman(service::FieldParams&& params, std::string&& idArg) const = 0; - virtual service::FieldResult> getDroid(service::FieldParams&& params, std::string&& idArg) const = 0; + virtual service::AwaitableObject> getHero(service::FieldParams&& params, std::optional&& episodeArg) const = 0; + virtual service::AwaitableObject> getHuman(service::FieldParams&& params, std::string&& idArg) const = 0; + virtual service::AwaitableObject> getDroid(service::FieldParams&& params, std::string&& idArg) const = 0; }; template @@ -98,7 +98,7 @@ class Query { } - service::FieldResult> getHero(service::FieldParams&& params, std::optional&& episodeArg) const final + service::AwaitableObject> getHero(service::FieldParams&& params, std::optional&& episodeArg) const final { if constexpr (methods::QueryHas::getHeroWithParams) { @@ -111,7 +111,7 @@ class Query } } - service::FieldResult> getHuman(service::FieldParams&& params, std::string&& idArg) const final + service::AwaitableObject> getHuman(service::FieldParams&& params, std::string&& idArg) const final { if constexpr (methods::QueryHas::getHumanWithParams) { @@ -124,7 +124,7 @@ class Query } } - service::FieldResult> getDroid(service::FieldParams&& params, std::string&& idArg) const final + service::AwaitableObject> getDroid(service::FieldParams&& params, std::string&& idArg) const final { if constexpr (methods::QueryHas::getDroidWithParams) { diff --git a/samples/learn/schema/ReviewObject.h b/samples/learn/schema/ReviewObject.h index efa4128e..e47228e7 100644 --- a/samples/learn/schema/ReviewObject.h +++ b/samples/learn/schema/ReviewObject.h @@ -16,25 +16,25 @@ namespace methods::ReviewHas { template concept getStarsWithParams = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult { impl.getStars(std::move(params)) } }; + { service::AwaitableScalar { impl.getStars(std::move(params)) } }; }; template concept getStars = requires (TImpl impl) { - { service::FieldResult { impl.getStars() } }; + { service::AwaitableScalar { impl.getStars() } }; }; template concept getCommentaryWithParams = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult> { impl.getCommentary(std::move(params)) } }; + { service::AwaitableScalar> { impl.getCommentary(std::move(params)) } }; }; template concept getCommentary = requires (TImpl impl) { - { service::FieldResult> { impl.getCommentary() } }; + { service::AwaitableScalar> { impl.getCommentary() } }; }; template @@ -67,8 +67,8 @@ class Review virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual service::FieldResult getStars(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getCommentary(service::FieldParams&& params) const = 0; + virtual service::AwaitableScalar getStars(service::FieldParams&& params) const = 0; + virtual service::AwaitableScalar> getCommentary(service::FieldParams&& params) const = 0; }; template @@ -80,7 +80,7 @@ class Review { } - service::FieldResult getStars(service::FieldParams&& params) const final + service::AwaitableScalar getStars(service::FieldParams&& params) const final { if constexpr (methods::ReviewHas::getStarsWithParams) { @@ -93,7 +93,7 @@ class Review } } - service::FieldResult> getCommentary(service::FieldParams&& params) const final + service::AwaitableScalar> getCommentary(service::FieldParams&& params) const final { if constexpr (methods::ReviewHas::getCommentaryWithParams) { diff --git a/samples/learn/schema/StarWarsSchema.cpp b/samples/learn/schema/StarWarsSchema.cpp index 929485d0..b67dfdbc 100644 --- a/samples/learn/schema/StarWarsSchema.cpp +++ b/samples/learn/schema/StarWarsSchema.cpp @@ -49,7 +49,7 @@ learn::Episode ModifiedArgument::convert(const response::Value& } template <> -service::AwaitableResolver ModifiedResult::convert(service::FieldResult result, ResolverParams params) +service::AwaitableResolver ModifiedResult::convert(service::AwaitableScalar result, ResolverParams params) { return resolve(std::move(result), std::move(params), [](learn::Episode value, const ResolverParams&) diff --git a/samples/today/TodayMock.cpp b/samples/today/TodayMock.cpp index 2a3c758b..cd4f9fb5 100644 --- a/samples/today/TodayMock.cpp +++ b/samples/today/TodayMock.cpp @@ -174,7 +174,7 @@ auto operator co_await(std::chrono::duration<_Rep, _Period> delay) return awaiter { delay }; } -service::FieldResult> Query::getNode( +service::AwaitableObject> Query::getNode( service::FieldParams params, response::IdType id) { // query { node(id: "ZmFrZVRhc2tJZA==") { ...on Task { title } } } diff --git a/samples/today/TodayMock.h b/samples/today/TodayMock.h index 8c9f5acb..c9bd3c37 100644 --- a/samples/today/TodayMock.h +++ b/samples/today/TodayMock.h @@ -59,7 +59,7 @@ class Query : public std::enable_shared_from_this explicit Query(appointmentsLoader&& getAppointments, tasksLoader&& getTasks, unreadCountsLoader&& getUnreadCounts); - service::FieldResult> getNode( + service::AwaitableObject> getNode( service::FieldParams params, response::IdType id); std::future> getAppointments( const service::FieldParams& params, std::optional first, @@ -142,7 +142,7 @@ class Appointment return _id; } - service::FieldResult getId() const noexcept + service::AwaitableScalar getId() const noexcept { return _id; } @@ -187,7 +187,7 @@ class AppointmentEdge return std::make_shared(_appointment); } - service::FieldResult getCursor() const + service::AwaitableScalar getCursor() const { co_return response::Value(co_await _appointment->getId()); } @@ -243,7 +243,7 @@ class Task return _id; } - service::FieldResult getId() const noexcept + service::AwaitableScalar getId() const noexcept { return _id; } @@ -278,7 +278,7 @@ class TaskEdge return std::make_shared(_task); } - service::FieldResult getCursor() const noexcept + service::AwaitableScalar getCursor() const noexcept { co_return response::Value(co_await _task->getId()); } @@ -333,7 +333,7 @@ class Folder return _id; } - service::FieldResult getId() const noexcept + service::AwaitableScalar getId() const noexcept { return _id; } @@ -367,7 +367,7 @@ class FolderEdge return std::make_shared(_folder); } - service::FieldResult getCursor() const noexcept + service::AwaitableScalar getCursor() const noexcept { co_return response::Value(co_await _folder->getId()); } diff --git a/samples/today/nointrospection/AppointmentConnectionObject.h b/samples/today/nointrospection/AppointmentConnectionObject.h index b7d5baee..8c065063 100644 --- a/samples/today/nointrospection/AppointmentConnectionObject.h +++ b/samples/today/nointrospection/AppointmentConnectionObject.h @@ -16,25 +16,25 @@ namespace methods::AppointmentConnectionHas { template concept getPageInfoWithParams = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult> { impl.getPageInfo(std::move(params)) } }; + { service::AwaitableObject> { impl.getPageInfo(std::move(params)) } }; }; template concept getPageInfo = requires (TImpl impl) { - { service::FieldResult> { impl.getPageInfo() } }; + { service::AwaitableObject> { impl.getPageInfo() } }; }; template concept getEdgesWithParams = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult>>> { impl.getEdges(std::move(params)) } }; + { service::AwaitableObject>>> { impl.getEdges(std::move(params)) } }; }; template concept getEdges = requires (TImpl impl) { - { service::FieldResult>>> { impl.getEdges() } }; + { service::AwaitableObject>>> { impl.getEdges() } }; }; template @@ -67,8 +67,8 @@ class AppointmentConnection virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual service::FieldResult> getPageInfo(service::FieldParams&& params) const = 0; - virtual service::FieldResult>>> getEdges(service::FieldParams&& params) const = 0; + virtual service::AwaitableObject> getPageInfo(service::FieldParams&& params) const = 0; + virtual service::AwaitableObject>>> getEdges(service::FieldParams&& params) const = 0; }; template @@ -80,7 +80,7 @@ class AppointmentConnection { } - service::FieldResult> getPageInfo(service::FieldParams&& params) const final + service::AwaitableObject> getPageInfo(service::FieldParams&& params) const final { if constexpr (methods::AppointmentConnectionHas::getPageInfoWithParams) { @@ -96,7 +96,7 @@ class AppointmentConnection } } - service::FieldResult>>> getEdges(service::FieldParams&& params) const final + service::AwaitableObject>>> getEdges(service::FieldParams&& params) const final { if constexpr (methods::AppointmentConnectionHas::getEdgesWithParams) { diff --git a/samples/today/nointrospection/AppointmentEdgeObject.h b/samples/today/nointrospection/AppointmentEdgeObject.h index 7477476b..205d2d3f 100644 --- a/samples/today/nointrospection/AppointmentEdgeObject.h +++ b/samples/today/nointrospection/AppointmentEdgeObject.h @@ -16,25 +16,25 @@ namespace methods::AppointmentEdgeHas { template concept getNodeWithParams = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult> { impl.getNode(std::move(params)) } }; + { service::AwaitableObject> { impl.getNode(std::move(params)) } }; }; template concept getNode = requires (TImpl impl) { - { service::FieldResult> { impl.getNode() } }; + { service::AwaitableObject> { impl.getNode() } }; }; template concept getCursorWithParams = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult { impl.getCursor(std::move(params)) } }; + { service::AwaitableScalar { impl.getCursor(std::move(params)) } }; }; template concept getCursor = requires (TImpl impl) { - { service::FieldResult { impl.getCursor() } }; + { service::AwaitableScalar { impl.getCursor() } }; }; template @@ -67,8 +67,8 @@ class AppointmentEdge virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual service::FieldResult> getNode(service::FieldParams&& params) const = 0; - virtual service::FieldResult getCursor(service::FieldParams&& params) const = 0; + virtual service::AwaitableObject> getNode(service::FieldParams&& params) const = 0; + virtual service::AwaitableScalar getCursor(service::FieldParams&& params) const = 0; }; template @@ -80,7 +80,7 @@ class AppointmentEdge { } - service::FieldResult> getNode(service::FieldParams&& params) const final + service::AwaitableObject> getNode(service::FieldParams&& params) const final { if constexpr (methods::AppointmentEdgeHas::getNodeWithParams) { @@ -96,7 +96,7 @@ class AppointmentEdge } } - service::FieldResult getCursor(service::FieldParams&& params) const final + service::AwaitableScalar getCursor(service::FieldParams&& params) const final { if constexpr (methods::AppointmentEdgeHas::getCursorWithParams) { diff --git a/samples/today/nointrospection/AppointmentObject.h b/samples/today/nointrospection/AppointmentObject.h index b55c94d1..22817647 100644 --- a/samples/today/nointrospection/AppointmentObject.h +++ b/samples/today/nointrospection/AppointmentObject.h @@ -23,61 +23,61 @@ namespace methods::AppointmentHas { template concept getIdWithParams = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult { impl.getId(std::move(params)) } }; + { service::AwaitableScalar { impl.getId(std::move(params)) } }; }; template concept getId = requires (TImpl impl) { - { service::FieldResult { impl.getId() } }; + { service::AwaitableScalar { impl.getId() } }; }; template concept getWhenWithParams = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult> { impl.getWhen(std::move(params)) } }; + { service::AwaitableScalar> { impl.getWhen(std::move(params)) } }; }; template concept getWhen = requires (TImpl impl) { - { service::FieldResult> { impl.getWhen() } }; + { service::AwaitableScalar> { impl.getWhen() } }; }; template concept getSubjectWithParams = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult> { impl.getSubject(std::move(params)) } }; + { service::AwaitableScalar> { impl.getSubject(std::move(params)) } }; }; template concept getSubject = requires (TImpl impl) { - { service::FieldResult> { impl.getSubject() } }; + { service::AwaitableScalar> { impl.getSubject() } }; }; template concept getIsNowWithParams = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult { impl.getIsNow(std::move(params)) } }; + { service::AwaitableScalar { impl.getIsNow(std::move(params)) } }; }; template concept getIsNow = requires (TImpl impl) { - { service::FieldResult { impl.getIsNow() } }; + { service::AwaitableScalar { impl.getIsNow() } }; }; template concept getForceErrorWithParams = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult> { impl.getForceError(std::move(params)) } }; + { service::AwaitableScalar> { impl.getForceError(std::move(params)) } }; }; template concept getForceError = requires (TImpl impl) { - { service::FieldResult> { impl.getForceError() } }; + { service::AwaitableScalar> { impl.getForceError() } }; }; template @@ -113,11 +113,11 @@ class Appointment virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual service::FieldResult getId(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getWhen(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getSubject(service::FieldParams&& params) const = 0; - virtual service::FieldResult getIsNow(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getForceError(service::FieldParams&& params) const = 0; + virtual service::AwaitableScalar getId(service::FieldParams&& params) const = 0; + virtual service::AwaitableScalar> getWhen(service::FieldParams&& params) const = 0; + virtual service::AwaitableScalar> getSubject(service::FieldParams&& params) const = 0; + virtual service::AwaitableScalar getIsNow(service::FieldParams&& params) const = 0; + virtual service::AwaitableScalar> getForceError(service::FieldParams&& params) const = 0; }; template @@ -129,7 +129,7 @@ class Appointment { } - service::FieldResult getId(service::FieldParams&& params) const final + service::AwaitableScalar getId(service::FieldParams&& params) const final { if constexpr (methods::AppointmentHas::getIdWithParams) { @@ -145,7 +145,7 @@ class Appointment } } - service::FieldResult> getWhen(service::FieldParams&& params) const final + service::AwaitableScalar> getWhen(service::FieldParams&& params) const final { if constexpr (methods::AppointmentHas::getWhenWithParams) { @@ -161,7 +161,7 @@ class Appointment } } - service::FieldResult> getSubject(service::FieldParams&& params) const final + service::AwaitableScalar> getSubject(service::FieldParams&& params) const final { if constexpr (methods::AppointmentHas::getSubjectWithParams) { @@ -177,7 +177,7 @@ class Appointment } } - service::FieldResult getIsNow(service::FieldParams&& params) const final + service::AwaitableScalar getIsNow(service::FieldParams&& params) const final { if constexpr (methods::AppointmentHas::getIsNowWithParams) { @@ -193,7 +193,7 @@ class Appointment } } - service::FieldResult> getForceError(service::FieldParams&& params) const final + service::AwaitableScalar> getForceError(service::FieldParams&& params) const final { if constexpr (methods::AppointmentHas::getForceErrorWithParams) { diff --git a/samples/today/nointrospection/CompleteTaskPayloadObject.h b/samples/today/nointrospection/CompleteTaskPayloadObject.h index 806cf182..3385815a 100644 --- a/samples/today/nointrospection/CompleteTaskPayloadObject.h +++ b/samples/today/nointrospection/CompleteTaskPayloadObject.h @@ -16,25 +16,25 @@ namespace methods::CompleteTaskPayloadHas { template concept getTaskWithParams = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult> { impl.getTask(std::move(params)) } }; + { service::AwaitableObject> { impl.getTask(std::move(params)) } }; }; template concept getTask = requires (TImpl impl) { - { service::FieldResult> { impl.getTask() } }; + { service::AwaitableObject> { impl.getTask() } }; }; template concept getClientMutationIdWithParams = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult> { impl.getClientMutationId(std::move(params)) } }; + { service::AwaitableScalar> { impl.getClientMutationId(std::move(params)) } }; }; template concept getClientMutationId = requires (TImpl impl) { - { service::FieldResult> { impl.getClientMutationId() } }; + { service::AwaitableScalar> { impl.getClientMutationId() } }; }; template @@ -67,8 +67,8 @@ class CompleteTaskPayload virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual service::FieldResult> getTask(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getClientMutationId(service::FieldParams&& params) const = 0; + virtual service::AwaitableObject> getTask(service::FieldParams&& params) const = 0; + virtual service::AwaitableScalar> getClientMutationId(service::FieldParams&& params) const = 0; }; template @@ -80,7 +80,7 @@ class CompleteTaskPayload { } - service::FieldResult> getTask(service::FieldParams&& params) const final + service::AwaitableObject> getTask(service::FieldParams&& params) const final { if constexpr (methods::CompleteTaskPayloadHas::getTaskWithParams) { @@ -96,7 +96,7 @@ class CompleteTaskPayload } } - service::FieldResult> getClientMutationId(service::FieldParams&& params) const final + service::AwaitableScalar> getClientMutationId(service::FieldParams&& params) const final { if constexpr (methods::CompleteTaskPayloadHas::getClientMutationIdWithParams) { diff --git a/samples/today/nointrospection/ExpensiveObject.h b/samples/today/nointrospection/ExpensiveObject.h index 920d34d5..19c717e1 100644 --- a/samples/today/nointrospection/ExpensiveObject.h +++ b/samples/today/nointrospection/ExpensiveObject.h @@ -16,13 +16,13 @@ namespace methods::ExpensiveHas { template concept getOrderWithParams = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult { impl.getOrder(std::move(params)) } }; + { service::AwaitableScalar { impl.getOrder(std::move(params)) } }; }; template concept getOrder = requires (TImpl impl) { - { service::FieldResult { impl.getOrder() } }; + { service::AwaitableScalar { impl.getOrder() } }; }; template @@ -54,7 +54,7 @@ class Expensive virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual service::FieldResult getOrder(service::FieldParams&& params) const = 0; + virtual service::AwaitableScalar getOrder(service::FieldParams&& params) const = 0; }; template @@ -66,7 +66,7 @@ class Expensive { } - service::FieldResult getOrder(service::FieldParams&& params) const final + service::AwaitableScalar getOrder(service::FieldParams&& params) const final { if constexpr (methods::ExpensiveHas::getOrderWithParams) { diff --git a/samples/today/nointrospection/FolderConnectionObject.h b/samples/today/nointrospection/FolderConnectionObject.h index d2de2dea..cd92557b 100644 --- a/samples/today/nointrospection/FolderConnectionObject.h +++ b/samples/today/nointrospection/FolderConnectionObject.h @@ -16,25 +16,25 @@ namespace methods::FolderConnectionHas { template concept getPageInfoWithParams = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult> { impl.getPageInfo(std::move(params)) } }; + { service::AwaitableObject> { impl.getPageInfo(std::move(params)) } }; }; template concept getPageInfo = requires (TImpl impl) { - { service::FieldResult> { impl.getPageInfo() } }; + { service::AwaitableObject> { impl.getPageInfo() } }; }; template concept getEdgesWithParams = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult>>> { impl.getEdges(std::move(params)) } }; + { service::AwaitableObject>>> { impl.getEdges(std::move(params)) } }; }; template concept getEdges = requires (TImpl impl) { - { service::FieldResult>>> { impl.getEdges() } }; + { service::AwaitableObject>>> { impl.getEdges() } }; }; template @@ -67,8 +67,8 @@ class FolderConnection virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual service::FieldResult> getPageInfo(service::FieldParams&& params) const = 0; - virtual service::FieldResult>>> getEdges(service::FieldParams&& params) const = 0; + virtual service::AwaitableObject> getPageInfo(service::FieldParams&& params) const = 0; + virtual service::AwaitableObject>>> getEdges(service::FieldParams&& params) const = 0; }; template @@ -80,7 +80,7 @@ class FolderConnection { } - service::FieldResult> getPageInfo(service::FieldParams&& params) const final + service::AwaitableObject> getPageInfo(service::FieldParams&& params) const final { if constexpr (methods::FolderConnectionHas::getPageInfoWithParams) { @@ -96,7 +96,7 @@ class FolderConnection } } - service::FieldResult>>> getEdges(service::FieldParams&& params) const final + service::AwaitableObject>>> getEdges(service::FieldParams&& params) const final { if constexpr (methods::FolderConnectionHas::getEdgesWithParams) { diff --git a/samples/today/nointrospection/FolderEdgeObject.h b/samples/today/nointrospection/FolderEdgeObject.h index 993f0c3c..65280232 100644 --- a/samples/today/nointrospection/FolderEdgeObject.h +++ b/samples/today/nointrospection/FolderEdgeObject.h @@ -16,25 +16,25 @@ namespace methods::FolderEdgeHas { template concept getNodeWithParams = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult> { impl.getNode(std::move(params)) } }; + { service::AwaitableObject> { impl.getNode(std::move(params)) } }; }; template concept getNode = requires (TImpl impl) { - { service::FieldResult> { impl.getNode() } }; + { service::AwaitableObject> { impl.getNode() } }; }; template concept getCursorWithParams = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult { impl.getCursor(std::move(params)) } }; + { service::AwaitableScalar { impl.getCursor(std::move(params)) } }; }; template concept getCursor = requires (TImpl impl) { - { service::FieldResult { impl.getCursor() } }; + { service::AwaitableScalar { impl.getCursor() } }; }; template @@ -67,8 +67,8 @@ class FolderEdge virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual service::FieldResult> getNode(service::FieldParams&& params) const = 0; - virtual service::FieldResult getCursor(service::FieldParams&& params) const = 0; + virtual service::AwaitableObject> getNode(service::FieldParams&& params) const = 0; + virtual service::AwaitableScalar getCursor(service::FieldParams&& params) const = 0; }; template @@ -80,7 +80,7 @@ class FolderEdge { } - service::FieldResult> getNode(service::FieldParams&& params) const final + service::AwaitableObject> getNode(service::FieldParams&& params) const final { if constexpr (methods::FolderEdgeHas::getNodeWithParams) { @@ -96,7 +96,7 @@ class FolderEdge } } - service::FieldResult getCursor(service::FieldParams&& params) const final + service::AwaitableScalar getCursor(service::FieldParams&& params) const final { if constexpr (methods::FolderEdgeHas::getCursorWithParams) { diff --git a/samples/today/nointrospection/FolderObject.h b/samples/today/nointrospection/FolderObject.h index 7928ba74..9d2cbbfc 100644 --- a/samples/today/nointrospection/FolderObject.h +++ b/samples/today/nointrospection/FolderObject.h @@ -23,37 +23,37 @@ namespace methods::FolderHas { template concept getIdWithParams = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult { impl.getId(std::move(params)) } }; + { service::AwaitableScalar { impl.getId(std::move(params)) } }; }; template concept getId = requires (TImpl impl) { - { service::FieldResult { impl.getId() } }; + { service::AwaitableScalar { impl.getId() } }; }; template concept getNameWithParams = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult> { impl.getName(std::move(params)) } }; + { service::AwaitableScalar> { impl.getName(std::move(params)) } }; }; template concept getName = requires (TImpl impl) { - { service::FieldResult> { impl.getName() } }; + { service::AwaitableScalar> { impl.getName() } }; }; template concept getUnreadCountWithParams = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult { impl.getUnreadCount(std::move(params)) } }; + { service::AwaitableScalar { impl.getUnreadCount(std::move(params)) } }; }; template concept getUnreadCount = requires (TImpl impl) { - { service::FieldResult { impl.getUnreadCount() } }; + { service::AwaitableScalar { impl.getUnreadCount() } }; }; template @@ -87,9 +87,9 @@ class Folder virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual service::FieldResult getId(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getName(service::FieldParams&& params) const = 0; - virtual service::FieldResult getUnreadCount(service::FieldParams&& params) const = 0; + virtual service::AwaitableScalar getId(service::FieldParams&& params) const = 0; + virtual service::AwaitableScalar> getName(service::FieldParams&& params) const = 0; + virtual service::AwaitableScalar getUnreadCount(service::FieldParams&& params) const = 0; }; template @@ -101,7 +101,7 @@ class Folder { } - service::FieldResult getId(service::FieldParams&& params) const final + service::AwaitableScalar getId(service::FieldParams&& params) const final { if constexpr (methods::FolderHas::getIdWithParams) { @@ -117,7 +117,7 @@ class Folder } } - service::FieldResult> getName(service::FieldParams&& params) const final + service::AwaitableScalar> getName(service::FieldParams&& params) const final { if constexpr (methods::FolderHas::getNameWithParams) { @@ -133,7 +133,7 @@ class Folder } } - service::FieldResult getUnreadCount(service::FieldParams&& params) const final + service::AwaitableScalar getUnreadCount(service::FieldParams&& params) const final { if constexpr (methods::FolderHas::getUnreadCountWithParams) { diff --git a/samples/today/nointrospection/MutationObject.h b/samples/today/nointrospection/MutationObject.h index f9ecb4b8..8ef746d8 100644 --- a/samples/today/nointrospection/MutationObject.h +++ b/samples/today/nointrospection/MutationObject.h @@ -16,25 +16,25 @@ namespace methods::MutationHas { template concept applyCompleteTaskWithParams = requires (TImpl impl, service::FieldParams params, CompleteTaskInput inputArg) { - { service::FieldResult> { impl.applyCompleteTask(std::move(params), std::move(inputArg)) } }; + { service::AwaitableObject> { impl.applyCompleteTask(std::move(params), std::move(inputArg)) } }; }; template concept applyCompleteTask = requires (TImpl impl, CompleteTaskInput inputArg) { - { service::FieldResult> { impl.applyCompleteTask(std::move(inputArg)) } }; + { service::AwaitableObject> { impl.applyCompleteTask(std::move(inputArg)) } }; }; template concept applySetFloatWithParams = requires (TImpl impl, service::FieldParams params, double valueArg) { - { service::FieldResult { impl.applySetFloat(std::move(params), std::move(valueArg)) } }; + { service::AwaitableScalar { impl.applySetFloat(std::move(params), std::move(valueArg)) } }; }; template concept applySetFloat = requires (TImpl impl, double valueArg) { - { service::FieldResult { impl.applySetFloat(std::move(valueArg)) } }; + { service::AwaitableScalar { impl.applySetFloat(std::move(valueArg)) } }; }; template @@ -67,8 +67,8 @@ class Mutation virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual service::FieldResult> applyCompleteTask(service::FieldParams&& params, CompleteTaskInput&& inputArg) const = 0; - virtual service::FieldResult applySetFloat(service::FieldParams&& params, double&& valueArg) const = 0; + virtual service::AwaitableObject> applyCompleteTask(service::FieldParams&& params, CompleteTaskInput&& inputArg) const = 0; + virtual service::AwaitableScalar applySetFloat(service::FieldParams&& params, double&& valueArg) const = 0; }; template @@ -80,7 +80,7 @@ class Mutation { } - service::FieldResult> applyCompleteTask(service::FieldParams&& params, CompleteTaskInput&& inputArg) const final + service::AwaitableObject> applyCompleteTask(service::FieldParams&& params, CompleteTaskInput&& inputArg) const final { if constexpr (methods::MutationHas::applyCompleteTaskWithParams) { @@ -96,7 +96,7 @@ class Mutation } } - service::FieldResult applySetFloat(service::FieldParams&& params, double&& valueArg) const final + service::AwaitableScalar applySetFloat(service::FieldParams&& params, double&& valueArg) const final { if constexpr (methods::MutationHas::applySetFloatWithParams) { diff --git a/samples/today/nointrospection/NestedTypeObject.h b/samples/today/nointrospection/NestedTypeObject.h index 6215cf06..a2f0e22f 100644 --- a/samples/today/nointrospection/NestedTypeObject.h +++ b/samples/today/nointrospection/NestedTypeObject.h @@ -16,25 +16,25 @@ namespace methods::NestedTypeHas { template concept getDepthWithParams = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult { impl.getDepth(std::move(params)) } }; + { service::AwaitableScalar { impl.getDepth(std::move(params)) } }; }; template concept getDepth = requires (TImpl impl) { - { service::FieldResult { impl.getDepth() } }; + { service::AwaitableScalar { impl.getDepth() } }; }; template concept getNestedWithParams = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult> { impl.getNested(std::move(params)) } }; + { service::AwaitableObject> { impl.getNested(std::move(params)) } }; }; template concept getNested = requires (TImpl impl) { - { service::FieldResult> { impl.getNested() } }; + { service::AwaitableObject> { impl.getNested() } }; }; template @@ -67,8 +67,8 @@ class NestedType virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual service::FieldResult getDepth(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getNested(service::FieldParams&& params) const = 0; + virtual service::AwaitableScalar getDepth(service::FieldParams&& params) const = 0; + virtual service::AwaitableObject> getNested(service::FieldParams&& params) const = 0; }; template @@ -80,7 +80,7 @@ class NestedType { } - service::FieldResult getDepth(service::FieldParams&& params) const final + service::AwaitableScalar getDepth(service::FieldParams&& params) const final { if constexpr (methods::NestedTypeHas::getDepthWithParams) { @@ -96,7 +96,7 @@ class NestedType } } - service::FieldResult> getNested(service::FieldParams&& params) const final + service::AwaitableObject> getNested(service::FieldParams&& params) const final { if constexpr (methods::NestedTypeHas::getNestedWithParams) { diff --git a/samples/today/nointrospection/PageInfoObject.h b/samples/today/nointrospection/PageInfoObject.h index d5c1cf4f..5c46a6c6 100644 --- a/samples/today/nointrospection/PageInfoObject.h +++ b/samples/today/nointrospection/PageInfoObject.h @@ -16,25 +16,25 @@ namespace methods::PageInfoHas { template concept getHasNextPageWithParams = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult { impl.getHasNextPage(std::move(params)) } }; + { service::AwaitableScalar { impl.getHasNextPage(std::move(params)) } }; }; template concept getHasNextPage = requires (TImpl impl) { - { service::FieldResult { impl.getHasNextPage() } }; + { service::AwaitableScalar { impl.getHasNextPage() } }; }; template concept getHasPreviousPageWithParams = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult { impl.getHasPreviousPage(std::move(params)) } }; + { service::AwaitableScalar { impl.getHasPreviousPage(std::move(params)) } }; }; template concept getHasPreviousPage = requires (TImpl impl) { - { service::FieldResult { impl.getHasPreviousPage() } }; + { service::AwaitableScalar { impl.getHasPreviousPage() } }; }; template @@ -67,8 +67,8 @@ class PageInfo virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual service::FieldResult getHasNextPage(service::FieldParams&& params) const = 0; - virtual service::FieldResult getHasPreviousPage(service::FieldParams&& params) const = 0; + virtual service::AwaitableScalar getHasNextPage(service::FieldParams&& params) const = 0; + virtual service::AwaitableScalar getHasPreviousPage(service::FieldParams&& params) const = 0; }; template @@ -80,7 +80,7 @@ class PageInfo { } - service::FieldResult getHasNextPage(service::FieldParams&& params) const final + service::AwaitableScalar getHasNextPage(service::FieldParams&& params) const final { if constexpr (methods::PageInfoHas::getHasNextPageWithParams) { @@ -96,7 +96,7 @@ class PageInfo } } - service::FieldResult getHasPreviousPage(service::FieldParams&& params) const final + service::AwaitableScalar getHasPreviousPage(service::FieldParams&& params) const final { if constexpr (methods::PageInfoHas::getHasPreviousPageWithParams) { diff --git a/samples/today/nointrospection/QueryObject.h b/samples/today/nointrospection/QueryObject.h index 9840cdb9..d4485e1a 100644 --- a/samples/today/nointrospection/QueryObject.h +++ b/samples/today/nointrospection/QueryObject.h @@ -16,145 +16,145 @@ namespace methods::QueryHas { template concept getNodeWithParams = requires (TImpl impl, service::FieldParams params, response::IdType idArg) { - { service::FieldResult> { impl.getNode(std::move(params), std::move(idArg)) } }; + { service::AwaitableObject> { impl.getNode(std::move(params), std::move(idArg)) } }; }; template concept getNode = requires (TImpl impl, response::IdType idArg) { - { service::FieldResult> { impl.getNode(std::move(idArg)) } }; + { service::AwaitableObject> { impl.getNode(std::move(idArg)) } }; }; template concept getAppointmentsWithParams = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) { - { service::FieldResult> { impl.getAppointments(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; + { service::AwaitableObject> { impl.getAppointments(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; }; template concept getAppointments = requires (TImpl impl, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) { - { service::FieldResult> { impl.getAppointments(std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; + { service::AwaitableObject> { impl.getAppointments(std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; }; template concept getTasksWithParams = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) { - { service::FieldResult> { impl.getTasks(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; + { service::AwaitableObject> { impl.getTasks(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; }; template concept getTasks = requires (TImpl impl, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) { - { service::FieldResult> { impl.getTasks(std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; + { service::AwaitableObject> { impl.getTasks(std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; }; template concept getUnreadCountsWithParams = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) { - { service::FieldResult> { impl.getUnreadCounts(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; + { service::AwaitableObject> { impl.getUnreadCounts(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; }; template concept getUnreadCounts = requires (TImpl impl, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) { - { service::FieldResult> { impl.getUnreadCounts(std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; + { service::AwaitableObject> { impl.getUnreadCounts(std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; }; template concept getAppointmentsByIdWithParams = requires (TImpl impl, service::FieldParams params, std::vector idsArg) { - { service::FieldResult>> { impl.getAppointmentsById(std::move(params), std::move(idsArg)) } }; + { service::AwaitableObject>> { impl.getAppointmentsById(std::move(params), std::move(idsArg)) } }; }; template concept getAppointmentsById = requires (TImpl impl, std::vector idsArg) { - { service::FieldResult>> { impl.getAppointmentsById(std::move(idsArg)) } }; + { service::AwaitableObject>> { impl.getAppointmentsById(std::move(idsArg)) } }; }; template concept getTasksByIdWithParams = requires (TImpl impl, service::FieldParams params, std::vector idsArg) { - { service::FieldResult>> { impl.getTasksById(std::move(params), std::move(idsArg)) } }; + { service::AwaitableObject>> { impl.getTasksById(std::move(params), std::move(idsArg)) } }; }; template concept getTasksById = requires (TImpl impl, std::vector idsArg) { - { service::FieldResult>> { impl.getTasksById(std::move(idsArg)) } }; + { service::AwaitableObject>> { impl.getTasksById(std::move(idsArg)) } }; }; template concept getUnreadCountsByIdWithParams = requires (TImpl impl, service::FieldParams params, std::vector idsArg) { - { service::FieldResult>> { impl.getUnreadCountsById(std::move(params), std::move(idsArg)) } }; + { service::AwaitableObject>> { impl.getUnreadCountsById(std::move(params), std::move(idsArg)) } }; }; template concept getUnreadCountsById = requires (TImpl impl, std::vector idsArg) { - { service::FieldResult>> { impl.getUnreadCountsById(std::move(idsArg)) } }; + { service::AwaitableObject>> { impl.getUnreadCountsById(std::move(idsArg)) } }; }; template concept getNestedWithParams = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult> { impl.getNested(std::move(params)) } }; + { service::AwaitableObject> { impl.getNested(std::move(params)) } }; }; template concept getNested = requires (TImpl impl) { - { service::FieldResult> { impl.getNested() } }; + { service::AwaitableObject> { impl.getNested() } }; }; template concept getUnimplementedWithParams = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult { impl.getUnimplemented(std::move(params)) } }; + { service::AwaitableScalar { impl.getUnimplemented(std::move(params)) } }; }; template concept getUnimplemented = requires (TImpl impl) { - { service::FieldResult { impl.getUnimplemented() } }; + { service::AwaitableScalar { impl.getUnimplemented() } }; }; template concept getExpensiveWithParams = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult>> { impl.getExpensive(std::move(params)) } }; + { service::AwaitableObject>> { impl.getExpensive(std::move(params)) } }; }; template concept getExpensive = requires (TImpl impl) { - { service::FieldResult>> { impl.getExpensive() } }; + { service::AwaitableObject>> { impl.getExpensive() } }; }; template concept getTestTaskStateWithParams = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult { impl.getTestTaskState(std::move(params)) } }; + { service::AwaitableScalar { impl.getTestTaskState(std::move(params)) } }; }; template concept getTestTaskState = requires (TImpl impl) { - { service::FieldResult { impl.getTestTaskState() } }; + { service::AwaitableScalar { impl.getTestTaskState() } }; }; template concept getAnyTypeWithParams = requires (TImpl impl, service::FieldParams params, std::vector idsArg) { - { service::FieldResult>> { impl.getAnyType(std::move(params), std::move(idsArg)) } }; + { service::AwaitableObject>> { impl.getAnyType(std::move(params), std::move(idsArg)) } }; }; template concept getAnyType = requires (TImpl impl, std::vector idsArg) { - { service::FieldResult>> { impl.getAnyType(std::move(idsArg)) } }; + { service::AwaitableObject>> { impl.getAnyType(std::move(idsArg)) } }; }; template @@ -197,18 +197,18 @@ class Query virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual service::FieldResult> getNode(service::FieldParams&& params, response::IdType&& idArg) const = 0; - virtual service::FieldResult> getAppointments(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const = 0; - virtual service::FieldResult> getTasks(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const = 0; - virtual service::FieldResult> getUnreadCounts(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const = 0; - virtual service::FieldResult>> getAppointmentsById(service::FieldParams&& params, std::vector&& idsArg) const = 0; - virtual service::FieldResult>> getTasksById(service::FieldParams&& params, std::vector&& idsArg) const = 0; - virtual service::FieldResult>> getUnreadCountsById(service::FieldParams&& params, std::vector&& idsArg) const = 0; - virtual service::FieldResult> getNested(service::FieldParams&& params) const = 0; - virtual service::FieldResult getUnimplemented(service::FieldParams&& params) const = 0; - virtual service::FieldResult>> getExpensive(service::FieldParams&& params) const = 0; - virtual service::FieldResult getTestTaskState(service::FieldParams&& params) const = 0; - virtual service::FieldResult>> getAnyType(service::FieldParams&& params, std::vector&& idsArg) const = 0; + virtual service::AwaitableObject> getNode(service::FieldParams&& params, response::IdType&& idArg) const = 0; + virtual service::AwaitableObject> getAppointments(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const = 0; + virtual service::AwaitableObject> getTasks(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const = 0; + virtual service::AwaitableObject> getUnreadCounts(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const = 0; + virtual service::AwaitableObject>> getAppointmentsById(service::FieldParams&& params, std::vector&& idsArg) const = 0; + virtual service::AwaitableObject>> getTasksById(service::FieldParams&& params, std::vector&& idsArg) const = 0; + virtual service::AwaitableObject>> getUnreadCountsById(service::FieldParams&& params, std::vector&& idsArg) const = 0; + virtual service::AwaitableObject> getNested(service::FieldParams&& params) const = 0; + virtual service::AwaitableScalar getUnimplemented(service::FieldParams&& params) const = 0; + virtual service::AwaitableObject>> getExpensive(service::FieldParams&& params) const = 0; + virtual service::AwaitableScalar getTestTaskState(service::FieldParams&& params) const = 0; + virtual service::AwaitableObject>> getAnyType(service::FieldParams&& params, std::vector&& idsArg) const = 0; }; template @@ -220,7 +220,7 @@ class Query { } - service::FieldResult> getNode(service::FieldParams&& params, response::IdType&& idArg) const final + service::AwaitableObject> getNode(service::FieldParams&& params, response::IdType&& idArg) const final { if constexpr (methods::QueryHas::getNodeWithParams) { @@ -236,7 +236,7 @@ class Query } } - service::FieldResult> getAppointments(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const final + service::AwaitableObject> getAppointments(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const final { if constexpr (methods::QueryHas::getAppointmentsWithParams) { @@ -252,7 +252,7 @@ class Query } } - service::FieldResult> getTasks(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const final + service::AwaitableObject> getTasks(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const final { if constexpr (methods::QueryHas::getTasksWithParams) { @@ -268,7 +268,7 @@ class Query } } - service::FieldResult> getUnreadCounts(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const final + service::AwaitableObject> getUnreadCounts(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const final { if constexpr (methods::QueryHas::getUnreadCountsWithParams) { @@ -284,7 +284,7 @@ class Query } } - service::FieldResult>> getAppointmentsById(service::FieldParams&& params, std::vector&& idsArg) const final + service::AwaitableObject>> getAppointmentsById(service::FieldParams&& params, std::vector&& idsArg) const final { if constexpr (methods::QueryHas::getAppointmentsByIdWithParams) { @@ -300,7 +300,7 @@ class Query } } - service::FieldResult>> getTasksById(service::FieldParams&& params, std::vector&& idsArg) const final + service::AwaitableObject>> getTasksById(service::FieldParams&& params, std::vector&& idsArg) const final { if constexpr (methods::QueryHas::getTasksByIdWithParams) { @@ -316,7 +316,7 @@ class Query } } - service::FieldResult>> getUnreadCountsById(service::FieldParams&& params, std::vector&& idsArg) const final + service::AwaitableObject>> getUnreadCountsById(service::FieldParams&& params, std::vector&& idsArg) const final { if constexpr (methods::QueryHas::getUnreadCountsByIdWithParams) { @@ -332,7 +332,7 @@ class Query } } - service::FieldResult> getNested(service::FieldParams&& params) const final + service::AwaitableObject> getNested(service::FieldParams&& params) const final { if constexpr (methods::QueryHas::getNestedWithParams) { @@ -348,7 +348,7 @@ class Query } } - service::FieldResult getUnimplemented(service::FieldParams&& params) const final + service::AwaitableScalar getUnimplemented(service::FieldParams&& params) const final { if constexpr (methods::QueryHas::getUnimplementedWithParams) { @@ -364,7 +364,7 @@ class Query } } - service::FieldResult>> getExpensive(service::FieldParams&& params) const final + service::AwaitableObject>> getExpensive(service::FieldParams&& params) const final { if constexpr (methods::QueryHas::getExpensiveWithParams) { @@ -380,7 +380,7 @@ class Query } } - service::FieldResult getTestTaskState(service::FieldParams&& params) const final + service::AwaitableScalar getTestTaskState(service::FieldParams&& params) const final { if constexpr (methods::QueryHas::getTestTaskStateWithParams) { @@ -396,7 +396,7 @@ class Query } } - service::FieldResult>> getAnyType(service::FieldParams&& params, std::vector&& idsArg) const final + service::AwaitableObject>> getAnyType(service::FieldParams&& params, std::vector&& idsArg) const final { if constexpr (methods::QueryHas::getAnyTypeWithParams) { diff --git a/samples/today/nointrospection/SubscriptionObject.h b/samples/today/nointrospection/SubscriptionObject.h index 86e5e8c8..4729e852 100644 --- a/samples/today/nointrospection/SubscriptionObject.h +++ b/samples/today/nointrospection/SubscriptionObject.h @@ -16,25 +16,25 @@ namespace methods::SubscriptionHas { template concept getNextAppointmentChangeWithParams = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult> { impl.getNextAppointmentChange(std::move(params)) } }; + { service::AwaitableObject> { impl.getNextAppointmentChange(std::move(params)) } }; }; template concept getNextAppointmentChange = requires (TImpl impl) { - { service::FieldResult> { impl.getNextAppointmentChange() } }; + { service::AwaitableObject> { impl.getNextAppointmentChange() } }; }; template concept getNodeChangeWithParams = requires (TImpl impl, service::FieldParams params, response::IdType idArg) { - { service::FieldResult> { impl.getNodeChange(std::move(params), std::move(idArg)) } }; + { service::AwaitableObject> { impl.getNodeChange(std::move(params), std::move(idArg)) } }; }; template concept getNodeChange = requires (TImpl impl, response::IdType idArg) { - { service::FieldResult> { impl.getNodeChange(std::move(idArg)) } }; + { service::AwaitableObject> { impl.getNodeChange(std::move(idArg)) } }; }; template @@ -67,8 +67,8 @@ class Subscription virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual service::FieldResult> getNextAppointmentChange(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getNodeChange(service::FieldParams&& params, response::IdType&& idArg) const = 0; + virtual service::AwaitableObject> getNextAppointmentChange(service::FieldParams&& params) const = 0; + virtual service::AwaitableObject> getNodeChange(service::FieldParams&& params, response::IdType&& idArg) const = 0; }; template @@ -80,7 +80,7 @@ class Subscription { } - service::FieldResult> getNextAppointmentChange(service::FieldParams&& params) const final + service::AwaitableObject> getNextAppointmentChange(service::FieldParams&& params) const final { if constexpr (methods::SubscriptionHas::getNextAppointmentChangeWithParams) { @@ -96,7 +96,7 @@ class Subscription } } - service::FieldResult> getNodeChange(service::FieldParams&& params, response::IdType&& idArg) const final + service::AwaitableObject> getNodeChange(service::FieldParams&& params, response::IdType&& idArg) const final { if constexpr (methods::SubscriptionHas::getNodeChangeWithParams) { diff --git a/samples/today/nointrospection/TaskConnectionObject.h b/samples/today/nointrospection/TaskConnectionObject.h index a7015334..b926979d 100644 --- a/samples/today/nointrospection/TaskConnectionObject.h +++ b/samples/today/nointrospection/TaskConnectionObject.h @@ -16,25 +16,25 @@ namespace methods::TaskConnectionHas { template concept getPageInfoWithParams = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult> { impl.getPageInfo(std::move(params)) } }; + { service::AwaitableObject> { impl.getPageInfo(std::move(params)) } }; }; template concept getPageInfo = requires (TImpl impl) { - { service::FieldResult> { impl.getPageInfo() } }; + { service::AwaitableObject> { impl.getPageInfo() } }; }; template concept getEdgesWithParams = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult>>> { impl.getEdges(std::move(params)) } }; + { service::AwaitableObject>>> { impl.getEdges(std::move(params)) } }; }; template concept getEdges = requires (TImpl impl) { - { service::FieldResult>>> { impl.getEdges() } }; + { service::AwaitableObject>>> { impl.getEdges() } }; }; template @@ -67,8 +67,8 @@ class TaskConnection virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual service::FieldResult> getPageInfo(service::FieldParams&& params) const = 0; - virtual service::FieldResult>>> getEdges(service::FieldParams&& params) const = 0; + virtual service::AwaitableObject> getPageInfo(service::FieldParams&& params) const = 0; + virtual service::AwaitableObject>>> getEdges(service::FieldParams&& params) const = 0; }; template @@ -80,7 +80,7 @@ class TaskConnection { } - service::FieldResult> getPageInfo(service::FieldParams&& params) const final + service::AwaitableObject> getPageInfo(service::FieldParams&& params) const final { if constexpr (methods::TaskConnectionHas::getPageInfoWithParams) { @@ -96,7 +96,7 @@ class TaskConnection } } - service::FieldResult>>> getEdges(service::FieldParams&& params) const final + service::AwaitableObject>>> getEdges(service::FieldParams&& params) const final { if constexpr (methods::TaskConnectionHas::getEdgesWithParams) { diff --git a/samples/today/nointrospection/TaskEdgeObject.h b/samples/today/nointrospection/TaskEdgeObject.h index 1dbd5980..7a934280 100644 --- a/samples/today/nointrospection/TaskEdgeObject.h +++ b/samples/today/nointrospection/TaskEdgeObject.h @@ -16,25 +16,25 @@ namespace methods::TaskEdgeHas { template concept getNodeWithParams = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult> { impl.getNode(std::move(params)) } }; + { service::AwaitableObject> { impl.getNode(std::move(params)) } }; }; template concept getNode = requires (TImpl impl) { - { service::FieldResult> { impl.getNode() } }; + { service::AwaitableObject> { impl.getNode() } }; }; template concept getCursorWithParams = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult { impl.getCursor(std::move(params)) } }; + { service::AwaitableScalar { impl.getCursor(std::move(params)) } }; }; template concept getCursor = requires (TImpl impl) { - { service::FieldResult { impl.getCursor() } }; + { service::AwaitableScalar { impl.getCursor() } }; }; template @@ -67,8 +67,8 @@ class TaskEdge virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual service::FieldResult> getNode(service::FieldParams&& params) const = 0; - virtual service::FieldResult getCursor(service::FieldParams&& params) const = 0; + virtual service::AwaitableObject> getNode(service::FieldParams&& params) const = 0; + virtual service::AwaitableScalar getCursor(service::FieldParams&& params) const = 0; }; template @@ -80,7 +80,7 @@ class TaskEdge { } - service::FieldResult> getNode(service::FieldParams&& params) const final + service::AwaitableObject> getNode(service::FieldParams&& params) const final { if constexpr (methods::TaskEdgeHas::getNodeWithParams) { @@ -96,7 +96,7 @@ class TaskEdge } } - service::FieldResult getCursor(service::FieldParams&& params) const final + service::AwaitableScalar getCursor(service::FieldParams&& params) const final { if constexpr (methods::TaskEdgeHas::getCursorWithParams) { diff --git a/samples/today/nointrospection/TaskObject.h b/samples/today/nointrospection/TaskObject.h index 49f6bb02..b0746bd8 100644 --- a/samples/today/nointrospection/TaskObject.h +++ b/samples/today/nointrospection/TaskObject.h @@ -23,37 +23,37 @@ namespace methods::TaskHas { template concept getIdWithParams = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult { impl.getId(std::move(params)) } }; + { service::AwaitableScalar { impl.getId(std::move(params)) } }; }; template concept getId = requires (TImpl impl) { - { service::FieldResult { impl.getId() } }; + { service::AwaitableScalar { impl.getId() } }; }; template concept getTitleWithParams = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult> { impl.getTitle(std::move(params)) } }; + { service::AwaitableScalar> { impl.getTitle(std::move(params)) } }; }; template concept getTitle = requires (TImpl impl) { - { service::FieldResult> { impl.getTitle() } }; + { service::AwaitableScalar> { impl.getTitle() } }; }; template concept getIsCompleteWithParams = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult { impl.getIsComplete(std::move(params)) } }; + { service::AwaitableScalar { impl.getIsComplete(std::move(params)) } }; }; template concept getIsComplete = requires (TImpl impl) { - { service::FieldResult { impl.getIsComplete() } }; + { service::AwaitableScalar { impl.getIsComplete() } }; }; template @@ -87,9 +87,9 @@ class Task virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual service::FieldResult getId(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getTitle(service::FieldParams&& params) const = 0; - virtual service::FieldResult getIsComplete(service::FieldParams&& params) const = 0; + virtual service::AwaitableScalar getId(service::FieldParams&& params) const = 0; + virtual service::AwaitableScalar> getTitle(service::FieldParams&& params) const = 0; + virtual service::AwaitableScalar getIsComplete(service::FieldParams&& params) const = 0; }; template @@ -101,7 +101,7 @@ class Task { } - service::FieldResult getId(service::FieldParams&& params) const final + service::AwaitableScalar getId(service::FieldParams&& params) const final { if constexpr (methods::TaskHas::getIdWithParams) { @@ -117,7 +117,7 @@ class Task } } - service::FieldResult> getTitle(service::FieldParams&& params) const final + service::AwaitableScalar> getTitle(service::FieldParams&& params) const final { if constexpr (methods::TaskHas::getTitleWithParams) { @@ -133,7 +133,7 @@ class Task } } - service::FieldResult getIsComplete(service::FieldParams&& params) const final + service::AwaitableScalar getIsComplete(service::FieldParams&& params) const final { if constexpr (methods::TaskHas::getIsCompleteWithParams) { diff --git a/samples/today/nointrospection/TodaySchema.cpp b/samples/today/nointrospection/TodaySchema.cpp index b251a3dc..4a327101 100644 --- a/samples/today/nointrospection/TodaySchema.cpp +++ b/samples/today/nointrospection/TodaySchema.cpp @@ -51,7 +51,7 @@ today::TaskState ModifiedArgument::convert(const response::Val } template <> -service::AwaitableResolver ModifiedResult::convert(service::FieldResult result, ResolverParams params) +service::AwaitableResolver ModifiedResult::convert(service::AwaitableScalar result, ResolverParams params) { return resolve(std::move(result), std::move(params), [](today::TaskState value, const ResolverParams&) diff --git a/samples/today/schema/AppointmentConnectionObject.h b/samples/today/schema/AppointmentConnectionObject.h index b7d5baee..8c065063 100644 --- a/samples/today/schema/AppointmentConnectionObject.h +++ b/samples/today/schema/AppointmentConnectionObject.h @@ -16,25 +16,25 @@ namespace methods::AppointmentConnectionHas { template concept getPageInfoWithParams = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult> { impl.getPageInfo(std::move(params)) } }; + { service::AwaitableObject> { impl.getPageInfo(std::move(params)) } }; }; template concept getPageInfo = requires (TImpl impl) { - { service::FieldResult> { impl.getPageInfo() } }; + { service::AwaitableObject> { impl.getPageInfo() } }; }; template concept getEdgesWithParams = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult>>> { impl.getEdges(std::move(params)) } }; + { service::AwaitableObject>>> { impl.getEdges(std::move(params)) } }; }; template concept getEdges = requires (TImpl impl) { - { service::FieldResult>>> { impl.getEdges() } }; + { service::AwaitableObject>>> { impl.getEdges() } }; }; template @@ -67,8 +67,8 @@ class AppointmentConnection virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual service::FieldResult> getPageInfo(service::FieldParams&& params) const = 0; - virtual service::FieldResult>>> getEdges(service::FieldParams&& params) const = 0; + virtual service::AwaitableObject> getPageInfo(service::FieldParams&& params) const = 0; + virtual service::AwaitableObject>>> getEdges(service::FieldParams&& params) const = 0; }; template @@ -80,7 +80,7 @@ class AppointmentConnection { } - service::FieldResult> getPageInfo(service::FieldParams&& params) const final + service::AwaitableObject> getPageInfo(service::FieldParams&& params) const final { if constexpr (methods::AppointmentConnectionHas::getPageInfoWithParams) { @@ -96,7 +96,7 @@ class AppointmentConnection } } - service::FieldResult>>> getEdges(service::FieldParams&& params) const final + service::AwaitableObject>>> getEdges(service::FieldParams&& params) const final { if constexpr (methods::AppointmentConnectionHas::getEdgesWithParams) { diff --git a/samples/today/schema/AppointmentEdgeObject.h b/samples/today/schema/AppointmentEdgeObject.h index 7477476b..205d2d3f 100644 --- a/samples/today/schema/AppointmentEdgeObject.h +++ b/samples/today/schema/AppointmentEdgeObject.h @@ -16,25 +16,25 @@ namespace methods::AppointmentEdgeHas { template concept getNodeWithParams = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult> { impl.getNode(std::move(params)) } }; + { service::AwaitableObject> { impl.getNode(std::move(params)) } }; }; template concept getNode = requires (TImpl impl) { - { service::FieldResult> { impl.getNode() } }; + { service::AwaitableObject> { impl.getNode() } }; }; template concept getCursorWithParams = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult { impl.getCursor(std::move(params)) } }; + { service::AwaitableScalar { impl.getCursor(std::move(params)) } }; }; template concept getCursor = requires (TImpl impl) { - { service::FieldResult { impl.getCursor() } }; + { service::AwaitableScalar { impl.getCursor() } }; }; template @@ -67,8 +67,8 @@ class AppointmentEdge virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual service::FieldResult> getNode(service::FieldParams&& params) const = 0; - virtual service::FieldResult getCursor(service::FieldParams&& params) const = 0; + virtual service::AwaitableObject> getNode(service::FieldParams&& params) const = 0; + virtual service::AwaitableScalar getCursor(service::FieldParams&& params) const = 0; }; template @@ -80,7 +80,7 @@ class AppointmentEdge { } - service::FieldResult> getNode(service::FieldParams&& params) const final + service::AwaitableObject> getNode(service::FieldParams&& params) const final { if constexpr (methods::AppointmentEdgeHas::getNodeWithParams) { @@ -96,7 +96,7 @@ class AppointmentEdge } } - service::FieldResult getCursor(service::FieldParams&& params) const final + service::AwaitableScalar getCursor(service::FieldParams&& params) const final { if constexpr (methods::AppointmentEdgeHas::getCursorWithParams) { diff --git a/samples/today/schema/AppointmentObject.h b/samples/today/schema/AppointmentObject.h index b55c94d1..22817647 100644 --- a/samples/today/schema/AppointmentObject.h +++ b/samples/today/schema/AppointmentObject.h @@ -23,61 +23,61 @@ namespace methods::AppointmentHas { template concept getIdWithParams = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult { impl.getId(std::move(params)) } }; + { service::AwaitableScalar { impl.getId(std::move(params)) } }; }; template concept getId = requires (TImpl impl) { - { service::FieldResult { impl.getId() } }; + { service::AwaitableScalar { impl.getId() } }; }; template concept getWhenWithParams = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult> { impl.getWhen(std::move(params)) } }; + { service::AwaitableScalar> { impl.getWhen(std::move(params)) } }; }; template concept getWhen = requires (TImpl impl) { - { service::FieldResult> { impl.getWhen() } }; + { service::AwaitableScalar> { impl.getWhen() } }; }; template concept getSubjectWithParams = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult> { impl.getSubject(std::move(params)) } }; + { service::AwaitableScalar> { impl.getSubject(std::move(params)) } }; }; template concept getSubject = requires (TImpl impl) { - { service::FieldResult> { impl.getSubject() } }; + { service::AwaitableScalar> { impl.getSubject() } }; }; template concept getIsNowWithParams = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult { impl.getIsNow(std::move(params)) } }; + { service::AwaitableScalar { impl.getIsNow(std::move(params)) } }; }; template concept getIsNow = requires (TImpl impl) { - { service::FieldResult { impl.getIsNow() } }; + { service::AwaitableScalar { impl.getIsNow() } }; }; template concept getForceErrorWithParams = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult> { impl.getForceError(std::move(params)) } }; + { service::AwaitableScalar> { impl.getForceError(std::move(params)) } }; }; template concept getForceError = requires (TImpl impl) { - { service::FieldResult> { impl.getForceError() } }; + { service::AwaitableScalar> { impl.getForceError() } }; }; template @@ -113,11 +113,11 @@ class Appointment virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual service::FieldResult getId(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getWhen(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getSubject(service::FieldParams&& params) const = 0; - virtual service::FieldResult getIsNow(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getForceError(service::FieldParams&& params) const = 0; + virtual service::AwaitableScalar getId(service::FieldParams&& params) const = 0; + virtual service::AwaitableScalar> getWhen(service::FieldParams&& params) const = 0; + virtual service::AwaitableScalar> getSubject(service::FieldParams&& params) const = 0; + virtual service::AwaitableScalar getIsNow(service::FieldParams&& params) const = 0; + virtual service::AwaitableScalar> getForceError(service::FieldParams&& params) const = 0; }; template @@ -129,7 +129,7 @@ class Appointment { } - service::FieldResult getId(service::FieldParams&& params) const final + service::AwaitableScalar getId(service::FieldParams&& params) const final { if constexpr (methods::AppointmentHas::getIdWithParams) { @@ -145,7 +145,7 @@ class Appointment } } - service::FieldResult> getWhen(service::FieldParams&& params) const final + service::AwaitableScalar> getWhen(service::FieldParams&& params) const final { if constexpr (methods::AppointmentHas::getWhenWithParams) { @@ -161,7 +161,7 @@ class Appointment } } - service::FieldResult> getSubject(service::FieldParams&& params) const final + service::AwaitableScalar> getSubject(service::FieldParams&& params) const final { if constexpr (methods::AppointmentHas::getSubjectWithParams) { @@ -177,7 +177,7 @@ class Appointment } } - service::FieldResult getIsNow(service::FieldParams&& params) const final + service::AwaitableScalar getIsNow(service::FieldParams&& params) const final { if constexpr (methods::AppointmentHas::getIsNowWithParams) { @@ -193,7 +193,7 @@ class Appointment } } - service::FieldResult> getForceError(service::FieldParams&& params) const final + service::AwaitableScalar> getForceError(service::FieldParams&& params) const final { if constexpr (methods::AppointmentHas::getForceErrorWithParams) { diff --git a/samples/today/schema/CompleteTaskPayloadObject.h b/samples/today/schema/CompleteTaskPayloadObject.h index 806cf182..3385815a 100644 --- a/samples/today/schema/CompleteTaskPayloadObject.h +++ b/samples/today/schema/CompleteTaskPayloadObject.h @@ -16,25 +16,25 @@ namespace methods::CompleteTaskPayloadHas { template concept getTaskWithParams = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult> { impl.getTask(std::move(params)) } }; + { service::AwaitableObject> { impl.getTask(std::move(params)) } }; }; template concept getTask = requires (TImpl impl) { - { service::FieldResult> { impl.getTask() } }; + { service::AwaitableObject> { impl.getTask() } }; }; template concept getClientMutationIdWithParams = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult> { impl.getClientMutationId(std::move(params)) } }; + { service::AwaitableScalar> { impl.getClientMutationId(std::move(params)) } }; }; template concept getClientMutationId = requires (TImpl impl) { - { service::FieldResult> { impl.getClientMutationId() } }; + { service::AwaitableScalar> { impl.getClientMutationId() } }; }; template @@ -67,8 +67,8 @@ class CompleteTaskPayload virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual service::FieldResult> getTask(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getClientMutationId(service::FieldParams&& params) const = 0; + virtual service::AwaitableObject> getTask(service::FieldParams&& params) const = 0; + virtual service::AwaitableScalar> getClientMutationId(service::FieldParams&& params) const = 0; }; template @@ -80,7 +80,7 @@ class CompleteTaskPayload { } - service::FieldResult> getTask(service::FieldParams&& params) const final + service::AwaitableObject> getTask(service::FieldParams&& params) const final { if constexpr (methods::CompleteTaskPayloadHas::getTaskWithParams) { @@ -96,7 +96,7 @@ class CompleteTaskPayload } } - service::FieldResult> getClientMutationId(service::FieldParams&& params) const final + service::AwaitableScalar> getClientMutationId(service::FieldParams&& params) const final { if constexpr (methods::CompleteTaskPayloadHas::getClientMutationIdWithParams) { diff --git a/samples/today/schema/ExpensiveObject.h b/samples/today/schema/ExpensiveObject.h index 920d34d5..19c717e1 100644 --- a/samples/today/schema/ExpensiveObject.h +++ b/samples/today/schema/ExpensiveObject.h @@ -16,13 +16,13 @@ namespace methods::ExpensiveHas { template concept getOrderWithParams = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult { impl.getOrder(std::move(params)) } }; + { service::AwaitableScalar { impl.getOrder(std::move(params)) } }; }; template concept getOrder = requires (TImpl impl) { - { service::FieldResult { impl.getOrder() } }; + { service::AwaitableScalar { impl.getOrder() } }; }; template @@ -54,7 +54,7 @@ class Expensive virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual service::FieldResult getOrder(service::FieldParams&& params) const = 0; + virtual service::AwaitableScalar getOrder(service::FieldParams&& params) const = 0; }; template @@ -66,7 +66,7 @@ class Expensive { } - service::FieldResult getOrder(service::FieldParams&& params) const final + service::AwaitableScalar getOrder(service::FieldParams&& params) const final { if constexpr (methods::ExpensiveHas::getOrderWithParams) { diff --git a/samples/today/schema/FolderConnectionObject.h b/samples/today/schema/FolderConnectionObject.h index d2de2dea..cd92557b 100644 --- a/samples/today/schema/FolderConnectionObject.h +++ b/samples/today/schema/FolderConnectionObject.h @@ -16,25 +16,25 @@ namespace methods::FolderConnectionHas { template concept getPageInfoWithParams = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult> { impl.getPageInfo(std::move(params)) } }; + { service::AwaitableObject> { impl.getPageInfo(std::move(params)) } }; }; template concept getPageInfo = requires (TImpl impl) { - { service::FieldResult> { impl.getPageInfo() } }; + { service::AwaitableObject> { impl.getPageInfo() } }; }; template concept getEdgesWithParams = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult>>> { impl.getEdges(std::move(params)) } }; + { service::AwaitableObject>>> { impl.getEdges(std::move(params)) } }; }; template concept getEdges = requires (TImpl impl) { - { service::FieldResult>>> { impl.getEdges() } }; + { service::AwaitableObject>>> { impl.getEdges() } }; }; template @@ -67,8 +67,8 @@ class FolderConnection virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual service::FieldResult> getPageInfo(service::FieldParams&& params) const = 0; - virtual service::FieldResult>>> getEdges(service::FieldParams&& params) const = 0; + virtual service::AwaitableObject> getPageInfo(service::FieldParams&& params) const = 0; + virtual service::AwaitableObject>>> getEdges(service::FieldParams&& params) const = 0; }; template @@ -80,7 +80,7 @@ class FolderConnection { } - service::FieldResult> getPageInfo(service::FieldParams&& params) const final + service::AwaitableObject> getPageInfo(service::FieldParams&& params) const final { if constexpr (methods::FolderConnectionHas::getPageInfoWithParams) { @@ -96,7 +96,7 @@ class FolderConnection } } - service::FieldResult>>> getEdges(service::FieldParams&& params) const final + service::AwaitableObject>>> getEdges(service::FieldParams&& params) const final { if constexpr (methods::FolderConnectionHas::getEdgesWithParams) { diff --git a/samples/today/schema/FolderEdgeObject.h b/samples/today/schema/FolderEdgeObject.h index 993f0c3c..65280232 100644 --- a/samples/today/schema/FolderEdgeObject.h +++ b/samples/today/schema/FolderEdgeObject.h @@ -16,25 +16,25 @@ namespace methods::FolderEdgeHas { template concept getNodeWithParams = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult> { impl.getNode(std::move(params)) } }; + { service::AwaitableObject> { impl.getNode(std::move(params)) } }; }; template concept getNode = requires (TImpl impl) { - { service::FieldResult> { impl.getNode() } }; + { service::AwaitableObject> { impl.getNode() } }; }; template concept getCursorWithParams = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult { impl.getCursor(std::move(params)) } }; + { service::AwaitableScalar { impl.getCursor(std::move(params)) } }; }; template concept getCursor = requires (TImpl impl) { - { service::FieldResult { impl.getCursor() } }; + { service::AwaitableScalar { impl.getCursor() } }; }; template @@ -67,8 +67,8 @@ class FolderEdge virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual service::FieldResult> getNode(service::FieldParams&& params) const = 0; - virtual service::FieldResult getCursor(service::FieldParams&& params) const = 0; + virtual service::AwaitableObject> getNode(service::FieldParams&& params) const = 0; + virtual service::AwaitableScalar getCursor(service::FieldParams&& params) const = 0; }; template @@ -80,7 +80,7 @@ class FolderEdge { } - service::FieldResult> getNode(service::FieldParams&& params) const final + service::AwaitableObject> getNode(service::FieldParams&& params) const final { if constexpr (methods::FolderEdgeHas::getNodeWithParams) { @@ -96,7 +96,7 @@ class FolderEdge } } - service::FieldResult getCursor(service::FieldParams&& params) const final + service::AwaitableScalar getCursor(service::FieldParams&& params) const final { if constexpr (methods::FolderEdgeHas::getCursorWithParams) { diff --git a/samples/today/schema/FolderObject.h b/samples/today/schema/FolderObject.h index 7928ba74..9d2cbbfc 100644 --- a/samples/today/schema/FolderObject.h +++ b/samples/today/schema/FolderObject.h @@ -23,37 +23,37 @@ namespace methods::FolderHas { template concept getIdWithParams = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult { impl.getId(std::move(params)) } }; + { service::AwaitableScalar { impl.getId(std::move(params)) } }; }; template concept getId = requires (TImpl impl) { - { service::FieldResult { impl.getId() } }; + { service::AwaitableScalar { impl.getId() } }; }; template concept getNameWithParams = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult> { impl.getName(std::move(params)) } }; + { service::AwaitableScalar> { impl.getName(std::move(params)) } }; }; template concept getName = requires (TImpl impl) { - { service::FieldResult> { impl.getName() } }; + { service::AwaitableScalar> { impl.getName() } }; }; template concept getUnreadCountWithParams = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult { impl.getUnreadCount(std::move(params)) } }; + { service::AwaitableScalar { impl.getUnreadCount(std::move(params)) } }; }; template concept getUnreadCount = requires (TImpl impl) { - { service::FieldResult { impl.getUnreadCount() } }; + { service::AwaitableScalar { impl.getUnreadCount() } }; }; template @@ -87,9 +87,9 @@ class Folder virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual service::FieldResult getId(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getName(service::FieldParams&& params) const = 0; - virtual service::FieldResult getUnreadCount(service::FieldParams&& params) const = 0; + virtual service::AwaitableScalar getId(service::FieldParams&& params) const = 0; + virtual service::AwaitableScalar> getName(service::FieldParams&& params) const = 0; + virtual service::AwaitableScalar getUnreadCount(service::FieldParams&& params) const = 0; }; template @@ -101,7 +101,7 @@ class Folder { } - service::FieldResult getId(service::FieldParams&& params) const final + service::AwaitableScalar getId(service::FieldParams&& params) const final { if constexpr (methods::FolderHas::getIdWithParams) { @@ -117,7 +117,7 @@ class Folder } } - service::FieldResult> getName(service::FieldParams&& params) const final + service::AwaitableScalar> getName(service::FieldParams&& params) const final { if constexpr (methods::FolderHas::getNameWithParams) { @@ -133,7 +133,7 @@ class Folder } } - service::FieldResult getUnreadCount(service::FieldParams&& params) const final + service::AwaitableScalar getUnreadCount(service::FieldParams&& params) const final { if constexpr (methods::FolderHas::getUnreadCountWithParams) { diff --git a/samples/today/schema/MutationObject.h b/samples/today/schema/MutationObject.h index f9ecb4b8..8ef746d8 100644 --- a/samples/today/schema/MutationObject.h +++ b/samples/today/schema/MutationObject.h @@ -16,25 +16,25 @@ namespace methods::MutationHas { template concept applyCompleteTaskWithParams = requires (TImpl impl, service::FieldParams params, CompleteTaskInput inputArg) { - { service::FieldResult> { impl.applyCompleteTask(std::move(params), std::move(inputArg)) } }; + { service::AwaitableObject> { impl.applyCompleteTask(std::move(params), std::move(inputArg)) } }; }; template concept applyCompleteTask = requires (TImpl impl, CompleteTaskInput inputArg) { - { service::FieldResult> { impl.applyCompleteTask(std::move(inputArg)) } }; + { service::AwaitableObject> { impl.applyCompleteTask(std::move(inputArg)) } }; }; template concept applySetFloatWithParams = requires (TImpl impl, service::FieldParams params, double valueArg) { - { service::FieldResult { impl.applySetFloat(std::move(params), std::move(valueArg)) } }; + { service::AwaitableScalar { impl.applySetFloat(std::move(params), std::move(valueArg)) } }; }; template concept applySetFloat = requires (TImpl impl, double valueArg) { - { service::FieldResult { impl.applySetFloat(std::move(valueArg)) } }; + { service::AwaitableScalar { impl.applySetFloat(std::move(valueArg)) } }; }; template @@ -67,8 +67,8 @@ class Mutation virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual service::FieldResult> applyCompleteTask(service::FieldParams&& params, CompleteTaskInput&& inputArg) const = 0; - virtual service::FieldResult applySetFloat(service::FieldParams&& params, double&& valueArg) const = 0; + virtual service::AwaitableObject> applyCompleteTask(service::FieldParams&& params, CompleteTaskInput&& inputArg) const = 0; + virtual service::AwaitableScalar applySetFloat(service::FieldParams&& params, double&& valueArg) const = 0; }; template @@ -80,7 +80,7 @@ class Mutation { } - service::FieldResult> applyCompleteTask(service::FieldParams&& params, CompleteTaskInput&& inputArg) const final + service::AwaitableObject> applyCompleteTask(service::FieldParams&& params, CompleteTaskInput&& inputArg) const final { if constexpr (methods::MutationHas::applyCompleteTaskWithParams) { @@ -96,7 +96,7 @@ class Mutation } } - service::FieldResult applySetFloat(service::FieldParams&& params, double&& valueArg) const final + service::AwaitableScalar applySetFloat(service::FieldParams&& params, double&& valueArg) const final { if constexpr (methods::MutationHas::applySetFloatWithParams) { diff --git a/samples/today/schema/NestedTypeObject.h b/samples/today/schema/NestedTypeObject.h index 6215cf06..a2f0e22f 100644 --- a/samples/today/schema/NestedTypeObject.h +++ b/samples/today/schema/NestedTypeObject.h @@ -16,25 +16,25 @@ namespace methods::NestedTypeHas { template concept getDepthWithParams = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult { impl.getDepth(std::move(params)) } }; + { service::AwaitableScalar { impl.getDepth(std::move(params)) } }; }; template concept getDepth = requires (TImpl impl) { - { service::FieldResult { impl.getDepth() } }; + { service::AwaitableScalar { impl.getDepth() } }; }; template concept getNestedWithParams = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult> { impl.getNested(std::move(params)) } }; + { service::AwaitableObject> { impl.getNested(std::move(params)) } }; }; template concept getNested = requires (TImpl impl) { - { service::FieldResult> { impl.getNested() } }; + { service::AwaitableObject> { impl.getNested() } }; }; template @@ -67,8 +67,8 @@ class NestedType virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual service::FieldResult getDepth(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getNested(service::FieldParams&& params) const = 0; + virtual service::AwaitableScalar getDepth(service::FieldParams&& params) const = 0; + virtual service::AwaitableObject> getNested(service::FieldParams&& params) const = 0; }; template @@ -80,7 +80,7 @@ class NestedType { } - service::FieldResult getDepth(service::FieldParams&& params) const final + service::AwaitableScalar getDepth(service::FieldParams&& params) const final { if constexpr (methods::NestedTypeHas::getDepthWithParams) { @@ -96,7 +96,7 @@ class NestedType } } - service::FieldResult> getNested(service::FieldParams&& params) const final + service::AwaitableObject> getNested(service::FieldParams&& params) const final { if constexpr (methods::NestedTypeHas::getNestedWithParams) { diff --git a/samples/today/schema/PageInfoObject.h b/samples/today/schema/PageInfoObject.h index d5c1cf4f..5c46a6c6 100644 --- a/samples/today/schema/PageInfoObject.h +++ b/samples/today/schema/PageInfoObject.h @@ -16,25 +16,25 @@ namespace methods::PageInfoHas { template concept getHasNextPageWithParams = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult { impl.getHasNextPage(std::move(params)) } }; + { service::AwaitableScalar { impl.getHasNextPage(std::move(params)) } }; }; template concept getHasNextPage = requires (TImpl impl) { - { service::FieldResult { impl.getHasNextPage() } }; + { service::AwaitableScalar { impl.getHasNextPage() } }; }; template concept getHasPreviousPageWithParams = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult { impl.getHasPreviousPage(std::move(params)) } }; + { service::AwaitableScalar { impl.getHasPreviousPage(std::move(params)) } }; }; template concept getHasPreviousPage = requires (TImpl impl) { - { service::FieldResult { impl.getHasPreviousPage() } }; + { service::AwaitableScalar { impl.getHasPreviousPage() } }; }; template @@ -67,8 +67,8 @@ class PageInfo virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual service::FieldResult getHasNextPage(service::FieldParams&& params) const = 0; - virtual service::FieldResult getHasPreviousPage(service::FieldParams&& params) const = 0; + virtual service::AwaitableScalar getHasNextPage(service::FieldParams&& params) const = 0; + virtual service::AwaitableScalar getHasPreviousPage(service::FieldParams&& params) const = 0; }; template @@ -80,7 +80,7 @@ class PageInfo { } - service::FieldResult getHasNextPage(service::FieldParams&& params) const final + service::AwaitableScalar getHasNextPage(service::FieldParams&& params) const final { if constexpr (methods::PageInfoHas::getHasNextPageWithParams) { @@ -96,7 +96,7 @@ class PageInfo } } - service::FieldResult getHasPreviousPage(service::FieldParams&& params) const final + service::AwaitableScalar getHasPreviousPage(service::FieldParams&& params) const final { if constexpr (methods::PageInfoHas::getHasPreviousPageWithParams) { diff --git a/samples/today/schema/QueryObject.h b/samples/today/schema/QueryObject.h index 31af69a6..44c2d420 100644 --- a/samples/today/schema/QueryObject.h +++ b/samples/today/schema/QueryObject.h @@ -16,145 +16,145 @@ namespace methods::QueryHas { template concept getNodeWithParams = requires (TImpl impl, service::FieldParams params, response::IdType idArg) { - { service::FieldResult> { impl.getNode(std::move(params), std::move(idArg)) } }; + { service::AwaitableObject> { impl.getNode(std::move(params), std::move(idArg)) } }; }; template concept getNode = requires (TImpl impl, response::IdType idArg) { - { service::FieldResult> { impl.getNode(std::move(idArg)) } }; + { service::AwaitableObject> { impl.getNode(std::move(idArg)) } }; }; template concept getAppointmentsWithParams = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) { - { service::FieldResult> { impl.getAppointments(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; + { service::AwaitableObject> { impl.getAppointments(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; }; template concept getAppointments = requires (TImpl impl, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) { - { service::FieldResult> { impl.getAppointments(std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; + { service::AwaitableObject> { impl.getAppointments(std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; }; template concept getTasksWithParams = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) { - { service::FieldResult> { impl.getTasks(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; + { service::AwaitableObject> { impl.getTasks(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; }; template concept getTasks = requires (TImpl impl, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) { - { service::FieldResult> { impl.getTasks(std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; + { service::AwaitableObject> { impl.getTasks(std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; }; template concept getUnreadCountsWithParams = requires (TImpl impl, service::FieldParams params, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) { - { service::FieldResult> { impl.getUnreadCounts(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; + { service::AwaitableObject> { impl.getUnreadCounts(std::move(params), std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; }; template concept getUnreadCounts = requires (TImpl impl, std::optional firstArg, std::optional afterArg, std::optional lastArg, std::optional beforeArg) { - { service::FieldResult> { impl.getUnreadCounts(std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; + { service::AwaitableObject> { impl.getUnreadCounts(std::move(firstArg), std::move(afterArg), std::move(lastArg), std::move(beforeArg)) } }; }; template concept getAppointmentsByIdWithParams = requires (TImpl impl, service::FieldParams params, std::vector idsArg) { - { service::FieldResult>> { impl.getAppointmentsById(std::move(params), std::move(idsArg)) } }; + { service::AwaitableObject>> { impl.getAppointmentsById(std::move(params), std::move(idsArg)) } }; }; template concept getAppointmentsById = requires (TImpl impl, std::vector idsArg) { - { service::FieldResult>> { impl.getAppointmentsById(std::move(idsArg)) } }; + { service::AwaitableObject>> { impl.getAppointmentsById(std::move(idsArg)) } }; }; template concept getTasksByIdWithParams = requires (TImpl impl, service::FieldParams params, std::vector idsArg) { - { service::FieldResult>> { impl.getTasksById(std::move(params), std::move(idsArg)) } }; + { service::AwaitableObject>> { impl.getTasksById(std::move(params), std::move(idsArg)) } }; }; template concept getTasksById = requires (TImpl impl, std::vector idsArg) { - { service::FieldResult>> { impl.getTasksById(std::move(idsArg)) } }; + { service::AwaitableObject>> { impl.getTasksById(std::move(idsArg)) } }; }; template concept getUnreadCountsByIdWithParams = requires (TImpl impl, service::FieldParams params, std::vector idsArg) { - { service::FieldResult>> { impl.getUnreadCountsById(std::move(params), std::move(idsArg)) } }; + { service::AwaitableObject>> { impl.getUnreadCountsById(std::move(params), std::move(idsArg)) } }; }; template concept getUnreadCountsById = requires (TImpl impl, std::vector idsArg) { - { service::FieldResult>> { impl.getUnreadCountsById(std::move(idsArg)) } }; + { service::AwaitableObject>> { impl.getUnreadCountsById(std::move(idsArg)) } }; }; template concept getNestedWithParams = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult> { impl.getNested(std::move(params)) } }; + { service::AwaitableObject> { impl.getNested(std::move(params)) } }; }; template concept getNested = requires (TImpl impl) { - { service::FieldResult> { impl.getNested() } }; + { service::AwaitableObject> { impl.getNested() } }; }; template concept getUnimplementedWithParams = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult { impl.getUnimplemented(std::move(params)) } }; + { service::AwaitableScalar { impl.getUnimplemented(std::move(params)) } }; }; template concept getUnimplemented = requires (TImpl impl) { - { service::FieldResult { impl.getUnimplemented() } }; + { service::AwaitableScalar { impl.getUnimplemented() } }; }; template concept getExpensiveWithParams = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult>> { impl.getExpensive(std::move(params)) } }; + { service::AwaitableObject>> { impl.getExpensive(std::move(params)) } }; }; template concept getExpensive = requires (TImpl impl) { - { service::FieldResult>> { impl.getExpensive() } }; + { service::AwaitableObject>> { impl.getExpensive() } }; }; template concept getTestTaskStateWithParams = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult { impl.getTestTaskState(std::move(params)) } }; + { service::AwaitableScalar { impl.getTestTaskState(std::move(params)) } }; }; template concept getTestTaskState = requires (TImpl impl) { - { service::FieldResult { impl.getTestTaskState() } }; + { service::AwaitableScalar { impl.getTestTaskState() } }; }; template concept getAnyTypeWithParams = requires (TImpl impl, service::FieldParams params, std::vector idsArg) { - { service::FieldResult>> { impl.getAnyType(std::move(params), std::move(idsArg)) } }; + { service::AwaitableObject>> { impl.getAnyType(std::move(params), std::move(idsArg)) } }; }; template concept getAnyType = requires (TImpl impl, std::vector idsArg) { - { service::FieldResult>> { impl.getAnyType(std::move(idsArg)) } }; + { service::AwaitableObject>> { impl.getAnyType(std::move(idsArg)) } }; }; template @@ -201,18 +201,18 @@ class Query virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual service::FieldResult> getNode(service::FieldParams&& params, response::IdType&& idArg) const = 0; - virtual service::FieldResult> getAppointments(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const = 0; - virtual service::FieldResult> getTasks(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const = 0; - virtual service::FieldResult> getUnreadCounts(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const = 0; - virtual service::FieldResult>> getAppointmentsById(service::FieldParams&& params, std::vector&& idsArg) const = 0; - virtual service::FieldResult>> getTasksById(service::FieldParams&& params, std::vector&& idsArg) const = 0; - virtual service::FieldResult>> getUnreadCountsById(service::FieldParams&& params, std::vector&& idsArg) const = 0; - virtual service::FieldResult> getNested(service::FieldParams&& params) const = 0; - virtual service::FieldResult getUnimplemented(service::FieldParams&& params) const = 0; - virtual service::FieldResult>> getExpensive(service::FieldParams&& params) const = 0; - virtual service::FieldResult getTestTaskState(service::FieldParams&& params) const = 0; - virtual service::FieldResult>> getAnyType(service::FieldParams&& params, std::vector&& idsArg) const = 0; + virtual service::AwaitableObject> getNode(service::FieldParams&& params, response::IdType&& idArg) const = 0; + virtual service::AwaitableObject> getAppointments(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const = 0; + virtual service::AwaitableObject> getTasks(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const = 0; + virtual service::AwaitableObject> getUnreadCounts(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const = 0; + virtual service::AwaitableObject>> getAppointmentsById(service::FieldParams&& params, std::vector&& idsArg) const = 0; + virtual service::AwaitableObject>> getTasksById(service::FieldParams&& params, std::vector&& idsArg) const = 0; + virtual service::AwaitableObject>> getUnreadCountsById(service::FieldParams&& params, std::vector&& idsArg) const = 0; + virtual service::AwaitableObject> getNested(service::FieldParams&& params) const = 0; + virtual service::AwaitableScalar getUnimplemented(service::FieldParams&& params) const = 0; + virtual service::AwaitableObject>> getExpensive(service::FieldParams&& params) const = 0; + virtual service::AwaitableScalar getTestTaskState(service::FieldParams&& params) const = 0; + virtual service::AwaitableObject>> getAnyType(service::FieldParams&& params, std::vector&& idsArg) const = 0; }; template @@ -224,7 +224,7 @@ class Query { } - service::FieldResult> getNode(service::FieldParams&& params, response::IdType&& idArg) const final + service::AwaitableObject> getNode(service::FieldParams&& params, response::IdType&& idArg) const final { if constexpr (methods::QueryHas::getNodeWithParams) { @@ -240,7 +240,7 @@ class Query } } - service::FieldResult> getAppointments(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const final + service::AwaitableObject> getAppointments(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const final { if constexpr (methods::QueryHas::getAppointmentsWithParams) { @@ -256,7 +256,7 @@ class Query } } - service::FieldResult> getTasks(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const final + service::AwaitableObject> getTasks(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const final { if constexpr (methods::QueryHas::getTasksWithParams) { @@ -272,7 +272,7 @@ class Query } } - service::FieldResult> getUnreadCounts(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const final + service::AwaitableObject> getUnreadCounts(service::FieldParams&& params, std::optional&& firstArg, std::optional&& afterArg, std::optional&& lastArg, std::optional&& beforeArg) const final { if constexpr (methods::QueryHas::getUnreadCountsWithParams) { @@ -288,7 +288,7 @@ class Query } } - service::FieldResult>> getAppointmentsById(service::FieldParams&& params, std::vector&& idsArg) const final + service::AwaitableObject>> getAppointmentsById(service::FieldParams&& params, std::vector&& idsArg) const final { if constexpr (methods::QueryHas::getAppointmentsByIdWithParams) { @@ -304,7 +304,7 @@ class Query } } - service::FieldResult>> getTasksById(service::FieldParams&& params, std::vector&& idsArg) const final + service::AwaitableObject>> getTasksById(service::FieldParams&& params, std::vector&& idsArg) const final { if constexpr (methods::QueryHas::getTasksByIdWithParams) { @@ -320,7 +320,7 @@ class Query } } - service::FieldResult>> getUnreadCountsById(service::FieldParams&& params, std::vector&& idsArg) const final + service::AwaitableObject>> getUnreadCountsById(service::FieldParams&& params, std::vector&& idsArg) const final { if constexpr (methods::QueryHas::getUnreadCountsByIdWithParams) { @@ -336,7 +336,7 @@ class Query } } - service::FieldResult> getNested(service::FieldParams&& params) const final + service::AwaitableObject> getNested(service::FieldParams&& params) const final { if constexpr (methods::QueryHas::getNestedWithParams) { @@ -352,7 +352,7 @@ class Query } } - service::FieldResult getUnimplemented(service::FieldParams&& params) const final + service::AwaitableScalar getUnimplemented(service::FieldParams&& params) const final { if constexpr (methods::QueryHas::getUnimplementedWithParams) { @@ -368,7 +368,7 @@ class Query } } - service::FieldResult>> getExpensive(service::FieldParams&& params) const final + service::AwaitableObject>> getExpensive(service::FieldParams&& params) const final { if constexpr (methods::QueryHas::getExpensiveWithParams) { @@ -384,7 +384,7 @@ class Query } } - service::FieldResult getTestTaskState(service::FieldParams&& params) const final + service::AwaitableScalar getTestTaskState(service::FieldParams&& params) const final { if constexpr (methods::QueryHas::getTestTaskStateWithParams) { @@ -400,7 +400,7 @@ class Query } } - service::FieldResult>> getAnyType(service::FieldParams&& params, std::vector&& idsArg) const final + service::AwaitableObject>> getAnyType(service::FieldParams&& params, std::vector&& idsArg) const final { if constexpr (methods::QueryHas::getAnyTypeWithParams) { diff --git a/samples/today/schema/SubscriptionObject.h b/samples/today/schema/SubscriptionObject.h index 86e5e8c8..4729e852 100644 --- a/samples/today/schema/SubscriptionObject.h +++ b/samples/today/schema/SubscriptionObject.h @@ -16,25 +16,25 @@ namespace methods::SubscriptionHas { template concept getNextAppointmentChangeWithParams = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult> { impl.getNextAppointmentChange(std::move(params)) } }; + { service::AwaitableObject> { impl.getNextAppointmentChange(std::move(params)) } }; }; template concept getNextAppointmentChange = requires (TImpl impl) { - { service::FieldResult> { impl.getNextAppointmentChange() } }; + { service::AwaitableObject> { impl.getNextAppointmentChange() } }; }; template concept getNodeChangeWithParams = requires (TImpl impl, service::FieldParams params, response::IdType idArg) { - { service::FieldResult> { impl.getNodeChange(std::move(params), std::move(idArg)) } }; + { service::AwaitableObject> { impl.getNodeChange(std::move(params), std::move(idArg)) } }; }; template concept getNodeChange = requires (TImpl impl, response::IdType idArg) { - { service::FieldResult> { impl.getNodeChange(std::move(idArg)) } }; + { service::AwaitableObject> { impl.getNodeChange(std::move(idArg)) } }; }; template @@ -67,8 +67,8 @@ class Subscription virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual service::FieldResult> getNextAppointmentChange(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getNodeChange(service::FieldParams&& params, response::IdType&& idArg) const = 0; + virtual service::AwaitableObject> getNextAppointmentChange(service::FieldParams&& params) const = 0; + virtual service::AwaitableObject> getNodeChange(service::FieldParams&& params, response::IdType&& idArg) const = 0; }; template @@ -80,7 +80,7 @@ class Subscription { } - service::FieldResult> getNextAppointmentChange(service::FieldParams&& params) const final + service::AwaitableObject> getNextAppointmentChange(service::FieldParams&& params) const final { if constexpr (methods::SubscriptionHas::getNextAppointmentChangeWithParams) { @@ -96,7 +96,7 @@ class Subscription } } - service::FieldResult> getNodeChange(service::FieldParams&& params, response::IdType&& idArg) const final + service::AwaitableObject> getNodeChange(service::FieldParams&& params, response::IdType&& idArg) const final { if constexpr (methods::SubscriptionHas::getNodeChangeWithParams) { diff --git a/samples/today/schema/TaskConnectionObject.h b/samples/today/schema/TaskConnectionObject.h index a7015334..b926979d 100644 --- a/samples/today/schema/TaskConnectionObject.h +++ b/samples/today/schema/TaskConnectionObject.h @@ -16,25 +16,25 @@ namespace methods::TaskConnectionHas { template concept getPageInfoWithParams = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult> { impl.getPageInfo(std::move(params)) } }; + { service::AwaitableObject> { impl.getPageInfo(std::move(params)) } }; }; template concept getPageInfo = requires (TImpl impl) { - { service::FieldResult> { impl.getPageInfo() } }; + { service::AwaitableObject> { impl.getPageInfo() } }; }; template concept getEdgesWithParams = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult>>> { impl.getEdges(std::move(params)) } }; + { service::AwaitableObject>>> { impl.getEdges(std::move(params)) } }; }; template concept getEdges = requires (TImpl impl) { - { service::FieldResult>>> { impl.getEdges() } }; + { service::AwaitableObject>>> { impl.getEdges() } }; }; template @@ -67,8 +67,8 @@ class TaskConnection virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual service::FieldResult> getPageInfo(service::FieldParams&& params) const = 0; - virtual service::FieldResult>>> getEdges(service::FieldParams&& params) const = 0; + virtual service::AwaitableObject> getPageInfo(service::FieldParams&& params) const = 0; + virtual service::AwaitableObject>>> getEdges(service::FieldParams&& params) const = 0; }; template @@ -80,7 +80,7 @@ class TaskConnection { } - service::FieldResult> getPageInfo(service::FieldParams&& params) const final + service::AwaitableObject> getPageInfo(service::FieldParams&& params) const final { if constexpr (methods::TaskConnectionHas::getPageInfoWithParams) { @@ -96,7 +96,7 @@ class TaskConnection } } - service::FieldResult>>> getEdges(service::FieldParams&& params) const final + service::AwaitableObject>>> getEdges(service::FieldParams&& params) const final { if constexpr (methods::TaskConnectionHas::getEdgesWithParams) { diff --git a/samples/today/schema/TaskEdgeObject.h b/samples/today/schema/TaskEdgeObject.h index 1dbd5980..7a934280 100644 --- a/samples/today/schema/TaskEdgeObject.h +++ b/samples/today/schema/TaskEdgeObject.h @@ -16,25 +16,25 @@ namespace methods::TaskEdgeHas { template concept getNodeWithParams = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult> { impl.getNode(std::move(params)) } }; + { service::AwaitableObject> { impl.getNode(std::move(params)) } }; }; template concept getNode = requires (TImpl impl) { - { service::FieldResult> { impl.getNode() } }; + { service::AwaitableObject> { impl.getNode() } }; }; template concept getCursorWithParams = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult { impl.getCursor(std::move(params)) } }; + { service::AwaitableScalar { impl.getCursor(std::move(params)) } }; }; template concept getCursor = requires (TImpl impl) { - { service::FieldResult { impl.getCursor() } }; + { service::AwaitableScalar { impl.getCursor() } }; }; template @@ -67,8 +67,8 @@ class TaskEdge virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual service::FieldResult> getNode(service::FieldParams&& params) const = 0; - virtual service::FieldResult getCursor(service::FieldParams&& params) const = 0; + virtual service::AwaitableObject> getNode(service::FieldParams&& params) const = 0; + virtual service::AwaitableScalar getCursor(service::FieldParams&& params) const = 0; }; template @@ -80,7 +80,7 @@ class TaskEdge { } - service::FieldResult> getNode(service::FieldParams&& params) const final + service::AwaitableObject> getNode(service::FieldParams&& params) const final { if constexpr (methods::TaskEdgeHas::getNodeWithParams) { @@ -96,7 +96,7 @@ class TaskEdge } } - service::FieldResult getCursor(service::FieldParams&& params) const final + service::AwaitableScalar getCursor(service::FieldParams&& params) const final { if constexpr (methods::TaskEdgeHas::getCursorWithParams) { diff --git a/samples/today/schema/TaskObject.h b/samples/today/schema/TaskObject.h index 49f6bb02..b0746bd8 100644 --- a/samples/today/schema/TaskObject.h +++ b/samples/today/schema/TaskObject.h @@ -23,37 +23,37 @@ namespace methods::TaskHas { template concept getIdWithParams = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult { impl.getId(std::move(params)) } }; + { service::AwaitableScalar { impl.getId(std::move(params)) } }; }; template concept getId = requires (TImpl impl) { - { service::FieldResult { impl.getId() } }; + { service::AwaitableScalar { impl.getId() } }; }; template concept getTitleWithParams = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult> { impl.getTitle(std::move(params)) } }; + { service::AwaitableScalar> { impl.getTitle(std::move(params)) } }; }; template concept getTitle = requires (TImpl impl) { - { service::FieldResult> { impl.getTitle() } }; + { service::AwaitableScalar> { impl.getTitle() } }; }; template concept getIsCompleteWithParams = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult { impl.getIsComplete(std::move(params)) } }; + { service::AwaitableScalar { impl.getIsComplete(std::move(params)) } }; }; template concept getIsComplete = requires (TImpl impl) { - { service::FieldResult { impl.getIsComplete() } }; + { service::AwaitableScalar { impl.getIsComplete() } }; }; template @@ -87,9 +87,9 @@ class Task virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual service::FieldResult getId(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getTitle(service::FieldParams&& params) const = 0; - virtual service::FieldResult getIsComplete(service::FieldParams&& params) const = 0; + virtual service::AwaitableScalar getId(service::FieldParams&& params) const = 0; + virtual service::AwaitableScalar> getTitle(service::FieldParams&& params) const = 0; + virtual service::AwaitableScalar getIsComplete(service::FieldParams&& params) const = 0; }; template @@ -101,7 +101,7 @@ class Task { } - service::FieldResult getId(service::FieldParams&& params) const final + service::AwaitableScalar getId(service::FieldParams&& params) const final { if constexpr (methods::TaskHas::getIdWithParams) { @@ -117,7 +117,7 @@ class Task } } - service::FieldResult> getTitle(service::FieldParams&& params) const final + service::AwaitableScalar> getTitle(service::FieldParams&& params) const final { if constexpr (methods::TaskHas::getTitleWithParams) { @@ -133,7 +133,7 @@ class Task } } - service::FieldResult getIsComplete(service::FieldParams&& params) const final + service::AwaitableScalar getIsComplete(service::FieldParams&& params) const final { if constexpr (methods::TaskHas::getIsCompleteWithParams) { diff --git a/samples/today/schema/TodaySchema.cpp b/samples/today/schema/TodaySchema.cpp index cabeee6a..ef5a373e 100644 --- a/samples/today/schema/TodaySchema.cpp +++ b/samples/today/schema/TodaySchema.cpp @@ -51,7 +51,7 @@ today::TaskState ModifiedArgument::convert(const response::Val } template <> -service::AwaitableResolver ModifiedResult::convert(service::FieldResult result, ResolverParams params) +service::AwaitableResolver ModifiedResult::convert(service::AwaitableScalar result, ResolverParams params) { return resolve(std::move(result), std::move(params), [](today::TaskState value, const ResolverParams&) diff --git a/samples/validation/schema/AlienObject.h b/samples/validation/schema/AlienObject.h index 3b46405e..18456bca 100644 --- a/samples/validation/schema/AlienObject.h +++ b/samples/validation/schema/AlienObject.h @@ -23,25 +23,25 @@ namespace methods::AlienHas { template concept getNameWithParams = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult { impl.getName(std::move(params)) } }; + { service::AwaitableScalar { impl.getName(std::move(params)) } }; }; template concept getName = requires (TImpl impl) { - { service::FieldResult { impl.getName() } }; + { service::AwaitableScalar { impl.getName() } }; }; template concept getHomePlanetWithParams = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult> { impl.getHomePlanet(std::move(params)) } }; + { service::AwaitableScalar> { impl.getHomePlanet(std::move(params)) } }; }; template concept getHomePlanet = requires (TImpl impl) { - { service::FieldResult> { impl.getHomePlanet() } }; + { service::AwaitableScalar> { impl.getHomePlanet() } }; }; template @@ -74,8 +74,8 @@ class Alien virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual service::FieldResult getName(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getHomePlanet(service::FieldParams&& params) const = 0; + virtual service::AwaitableScalar getName(service::FieldParams&& params) const = 0; + virtual service::AwaitableScalar> getHomePlanet(service::FieldParams&& params) const = 0; }; template @@ -87,7 +87,7 @@ class Alien { } - service::FieldResult getName(service::FieldParams&& params) const final + service::AwaitableScalar getName(service::FieldParams&& params) const final { if constexpr (methods::AlienHas::getNameWithParams) { @@ -103,7 +103,7 @@ class Alien } } - service::FieldResult> getHomePlanet(service::FieldParams&& params) const final + service::AwaitableScalar> getHomePlanet(service::FieldParams&& params) const final { if constexpr (methods::AlienHas::getHomePlanetWithParams) { diff --git a/samples/validation/schema/ArgumentsObject.h b/samples/validation/schema/ArgumentsObject.h index 3e719ab8..d9f72e75 100644 --- a/samples/validation/schema/ArgumentsObject.h +++ b/samples/validation/schema/ArgumentsObject.h @@ -16,97 +16,97 @@ namespace methods::ArgumentsHas { template concept getMultipleReqsWithParams = requires (TImpl impl, service::FieldParams params, int xArg, int yArg) { - { service::FieldResult { impl.getMultipleReqs(std::move(params), std::move(xArg), std::move(yArg)) } }; + { service::AwaitableScalar { impl.getMultipleReqs(std::move(params), std::move(xArg), std::move(yArg)) } }; }; template concept getMultipleReqs = requires (TImpl impl, int xArg, int yArg) { - { service::FieldResult { impl.getMultipleReqs(std::move(xArg), std::move(yArg)) } }; + { service::AwaitableScalar { impl.getMultipleReqs(std::move(xArg), std::move(yArg)) } }; }; template concept getBooleanArgFieldWithParams = requires (TImpl impl, service::FieldParams params, std::optional booleanArgArg) { - { service::FieldResult> { impl.getBooleanArgField(std::move(params), std::move(booleanArgArg)) } }; + { service::AwaitableScalar> { impl.getBooleanArgField(std::move(params), std::move(booleanArgArg)) } }; }; template concept getBooleanArgField = requires (TImpl impl, std::optional booleanArgArg) { - { service::FieldResult> { impl.getBooleanArgField(std::move(booleanArgArg)) } }; + { service::AwaitableScalar> { impl.getBooleanArgField(std::move(booleanArgArg)) } }; }; template concept getFloatArgFieldWithParams = requires (TImpl impl, service::FieldParams params, std::optional floatArgArg) { - { service::FieldResult> { impl.getFloatArgField(std::move(params), std::move(floatArgArg)) } }; + { service::AwaitableScalar> { impl.getFloatArgField(std::move(params), std::move(floatArgArg)) } }; }; template concept getFloatArgField = requires (TImpl impl, std::optional floatArgArg) { - { service::FieldResult> { impl.getFloatArgField(std::move(floatArgArg)) } }; + { service::AwaitableScalar> { impl.getFloatArgField(std::move(floatArgArg)) } }; }; template concept getIntArgFieldWithParams = requires (TImpl impl, service::FieldParams params, std::optional intArgArg) { - { service::FieldResult> { impl.getIntArgField(std::move(params), std::move(intArgArg)) } }; + { service::AwaitableScalar> { impl.getIntArgField(std::move(params), std::move(intArgArg)) } }; }; template concept getIntArgField = requires (TImpl impl, std::optional intArgArg) { - { service::FieldResult> { impl.getIntArgField(std::move(intArgArg)) } }; + { service::AwaitableScalar> { impl.getIntArgField(std::move(intArgArg)) } }; }; template concept getNonNullBooleanArgFieldWithParams = requires (TImpl impl, service::FieldParams params, bool nonNullBooleanArgArg) { - { service::FieldResult { impl.getNonNullBooleanArgField(std::move(params), std::move(nonNullBooleanArgArg)) } }; + { service::AwaitableScalar { impl.getNonNullBooleanArgField(std::move(params), std::move(nonNullBooleanArgArg)) } }; }; template concept getNonNullBooleanArgField = requires (TImpl impl, bool nonNullBooleanArgArg) { - { service::FieldResult { impl.getNonNullBooleanArgField(std::move(nonNullBooleanArgArg)) } }; + { service::AwaitableScalar { impl.getNonNullBooleanArgField(std::move(nonNullBooleanArgArg)) } }; }; template concept getNonNullBooleanListFieldWithParams = requires (TImpl impl, service::FieldParams params, std::optional> nonNullBooleanListArgArg) { - { service::FieldResult>> { impl.getNonNullBooleanListField(std::move(params), std::move(nonNullBooleanListArgArg)) } }; + { service::AwaitableScalar>> { impl.getNonNullBooleanListField(std::move(params), std::move(nonNullBooleanListArgArg)) } }; }; template concept getNonNullBooleanListField = requires (TImpl impl, std::optional> nonNullBooleanListArgArg) { - { service::FieldResult>> { impl.getNonNullBooleanListField(std::move(nonNullBooleanListArgArg)) } }; + { service::AwaitableScalar>> { impl.getNonNullBooleanListField(std::move(nonNullBooleanListArgArg)) } }; }; template concept getBooleanListArgFieldWithParams = requires (TImpl impl, service::FieldParams params, std::vector> booleanListArgArg) { - { service::FieldResult>>> { impl.getBooleanListArgField(std::move(params), std::move(booleanListArgArg)) } }; + { service::AwaitableScalar>>> { impl.getBooleanListArgField(std::move(params), std::move(booleanListArgArg)) } }; }; template concept getBooleanListArgField = requires (TImpl impl, std::vector> booleanListArgArg) { - { service::FieldResult>>> { impl.getBooleanListArgField(std::move(booleanListArgArg)) } }; + { service::AwaitableScalar>>> { impl.getBooleanListArgField(std::move(booleanListArgArg)) } }; }; template concept getOptionalNonNullBooleanArgFieldWithParams = requires (TImpl impl, service::FieldParams params, bool optionalBooleanArgArg) { - { service::FieldResult { impl.getOptionalNonNullBooleanArgField(std::move(params), std::move(optionalBooleanArgArg)) } }; + { service::AwaitableScalar { impl.getOptionalNonNullBooleanArgField(std::move(params), std::move(optionalBooleanArgArg)) } }; }; template concept getOptionalNonNullBooleanArgField = requires (TImpl impl, bool optionalBooleanArgArg) { - { service::FieldResult { impl.getOptionalNonNullBooleanArgField(std::move(optionalBooleanArgArg)) } }; + { service::AwaitableScalar { impl.getOptionalNonNullBooleanArgField(std::move(optionalBooleanArgArg)) } }; }; template @@ -145,14 +145,14 @@ class Arguments virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual service::FieldResult getMultipleReqs(service::FieldParams&& params, int&& xArg, int&& yArg) const = 0; - virtual service::FieldResult> getBooleanArgField(service::FieldParams&& params, std::optional&& booleanArgArg) const = 0; - virtual service::FieldResult> getFloatArgField(service::FieldParams&& params, std::optional&& floatArgArg) const = 0; - virtual service::FieldResult> getIntArgField(service::FieldParams&& params, std::optional&& intArgArg) const = 0; - virtual service::FieldResult getNonNullBooleanArgField(service::FieldParams&& params, bool&& nonNullBooleanArgArg) const = 0; - virtual service::FieldResult>> getNonNullBooleanListField(service::FieldParams&& params, std::optional>&& nonNullBooleanListArgArg) const = 0; - virtual service::FieldResult>>> getBooleanListArgField(service::FieldParams&& params, std::vector>&& booleanListArgArg) const = 0; - virtual service::FieldResult getOptionalNonNullBooleanArgField(service::FieldParams&& params, bool&& optionalBooleanArgArg) const = 0; + virtual service::AwaitableScalar getMultipleReqs(service::FieldParams&& params, int&& xArg, int&& yArg) const = 0; + virtual service::AwaitableScalar> getBooleanArgField(service::FieldParams&& params, std::optional&& booleanArgArg) const = 0; + virtual service::AwaitableScalar> getFloatArgField(service::FieldParams&& params, std::optional&& floatArgArg) const = 0; + virtual service::AwaitableScalar> getIntArgField(service::FieldParams&& params, std::optional&& intArgArg) const = 0; + virtual service::AwaitableScalar getNonNullBooleanArgField(service::FieldParams&& params, bool&& nonNullBooleanArgArg) const = 0; + virtual service::AwaitableScalar>> getNonNullBooleanListField(service::FieldParams&& params, std::optional>&& nonNullBooleanListArgArg) const = 0; + virtual service::AwaitableScalar>>> getBooleanListArgField(service::FieldParams&& params, std::vector>&& booleanListArgArg) const = 0; + virtual service::AwaitableScalar getOptionalNonNullBooleanArgField(service::FieldParams&& params, bool&& optionalBooleanArgArg) const = 0; }; template @@ -164,7 +164,7 @@ class Arguments { } - service::FieldResult getMultipleReqs(service::FieldParams&& params, int&& xArg, int&& yArg) const final + service::AwaitableScalar getMultipleReqs(service::FieldParams&& params, int&& xArg, int&& yArg) const final { if constexpr (methods::ArgumentsHas::getMultipleReqsWithParams) { @@ -180,7 +180,7 @@ class Arguments } } - service::FieldResult> getBooleanArgField(service::FieldParams&& params, std::optional&& booleanArgArg) const final + service::AwaitableScalar> getBooleanArgField(service::FieldParams&& params, std::optional&& booleanArgArg) const final { if constexpr (methods::ArgumentsHas::getBooleanArgFieldWithParams) { @@ -196,7 +196,7 @@ class Arguments } } - service::FieldResult> getFloatArgField(service::FieldParams&& params, std::optional&& floatArgArg) const final + service::AwaitableScalar> getFloatArgField(service::FieldParams&& params, std::optional&& floatArgArg) const final { if constexpr (methods::ArgumentsHas::getFloatArgFieldWithParams) { @@ -212,7 +212,7 @@ class Arguments } } - service::FieldResult> getIntArgField(service::FieldParams&& params, std::optional&& intArgArg) const final + service::AwaitableScalar> getIntArgField(service::FieldParams&& params, std::optional&& intArgArg) const final { if constexpr (methods::ArgumentsHas::getIntArgFieldWithParams) { @@ -228,7 +228,7 @@ class Arguments } } - service::FieldResult getNonNullBooleanArgField(service::FieldParams&& params, bool&& nonNullBooleanArgArg) const final + service::AwaitableScalar getNonNullBooleanArgField(service::FieldParams&& params, bool&& nonNullBooleanArgArg) const final { if constexpr (methods::ArgumentsHas::getNonNullBooleanArgFieldWithParams) { @@ -244,7 +244,7 @@ class Arguments } } - service::FieldResult>> getNonNullBooleanListField(service::FieldParams&& params, std::optional>&& nonNullBooleanListArgArg) const final + service::AwaitableScalar>> getNonNullBooleanListField(service::FieldParams&& params, std::optional>&& nonNullBooleanListArgArg) const final { if constexpr (methods::ArgumentsHas::getNonNullBooleanListFieldWithParams) { @@ -260,7 +260,7 @@ class Arguments } } - service::FieldResult>>> getBooleanListArgField(service::FieldParams&& params, std::vector>&& booleanListArgArg) const final + service::AwaitableScalar>>> getBooleanListArgField(service::FieldParams&& params, std::vector>&& booleanListArgArg) const final { if constexpr (methods::ArgumentsHas::getBooleanListArgFieldWithParams) { @@ -276,7 +276,7 @@ class Arguments } } - service::FieldResult getOptionalNonNullBooleanArgField(service::FieldParams&& params, bool&& optionalBooleanArgArg) const final + service::AwaitableScalar getOptionalNonNullBooleanArgField(service::FieldParams&& params, bool&& optionalBooleanArgArg) const final { if constexpr (methods::ArgumentsHas::getOptionalNonNullBooleanArgFieldWithParams) { diff --git a/samples/validation/schema/CatObject.h b/samples/validation/schema/CatObject.h index 857b9363..47829209 100644 --- a/samples/validation/schema/CatObject.h +++ b/samples/validation/schema/CatObject.h @@ -23,49 +23,49 @@ namespace methods::CatHas { template concept getNameWithParams = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult { impl.getName(std::move(params)) } }; + { service::AwaitableScalar { impl.getName(std::move(params)) } }; }; template concept getName = requires (TImpl impl) { - { service::FieldResult { impl.getName() } }; + { service::AwaitableScalar { impl.getName() } }; }; template concept getNicknameWithParams = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult> { impl.getNickname(std::move(params)) } }; + { service::AwaitableScalar> { impl.getNickname(std::move(params)) } }; }; template concept getNickname = requires (TImpl impl) { - { service::FieldResult> { impl.getNickname() } }; + { service::AwaitableScalar> { impl.getNickname() } }; }; template concept getDoesKnowCommandWithParams = requires (TImpl impl, service::FieldParams params, CatCommand catCommandArg) { - { service::FieldResult { impl.getDoesKnowCommand(std::move(params), std::move(catCommandArg)) } }; + { service::AwaitableScalar { impl.getDoesKnowCommand(std::move(params), std::move(catCommandArg)) } }; }; template concept getDoesKnowCommand = requires (TImpl impl, CatCommand catCommandArg) { - { service::FieldResult { impl.getDoesKnowCommand(std::move(catCommandArg)) } }; + { service::AwaitableScalar { impl.getDoesKnowCommand(std::move(catCommandArg)) } }; }; template concept getMeowVolumeWithParams = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult> { impl.getMeowVolume(std::move(params)) } }; + { service::AwaitableScalar> { impl.getMeowVolume(std::move(params)) } }; }; template concept getMeowVolume = requires (TImpl impl) { - { service::FieldResult> { impl.getMeowVolume() } }; + { service::AwaitableScalar> { impl.getMeowVolume() } }; }; template @@ -100,10 +100,10 @@ class Cat virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual service::FieldResult getName(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getNickname(service::FieldParams&& params) const = 0; - virtual service::FieldResult getDoesKnowCommand(service::FieldParams&& params, CatCommand&& catCommandArg) const = 0; - virtual service::FieldResult> getMeowVolume(service::FieldParams&& params) const = 0; + virtual service::AwaitableScalar getName(service::FieldParams&& params) const = 0; + virtual service::AwaitableScalar> getNickname(service::FieldParams&& params) const = 0; + virtual service::AwaitableScalar getDoesKnowCommand(service::FieldParams&& params, CatCommand&& catCommandArg) const = 0; + virtual service::AwaitableScalar> getMeowVolume(service::FieldParams&& params) const = 0; }; template @@ -115,7 +115,7 @@ class Cat { } - service::FieldResult getName(service::FieldParams&& params) const final + service::AwaitableScalar getName(service::FieldParams&& params) const final { if constexpr (methods::CatHas::getNameWithParams) { @@ -131,7 +131,7 @@ class Cat } } - service::FieldResult> getNickname(service::FieldParams&& params) const final + service::AwaitableScalar> getNickname(service::FieldParams&& params) const final { if constexpr (methods::CatHas::getNicknameWithParams) { @@ -147,7 +147,7 @@ class Cat } } - service::FieldResult getDoesKnowCommand(service::FieldParams&& params, CatCommand&& catCommandArg) const final + service::AwaitableScalar getDoesKnowCommand(service::FieldParams&& params, CatCommand&& catCommandArg) const final { if constexpr (methods::CatHas::getDoesKnowCommandWithParams) { @@ -163,7 +163,7 @@ class Cat } } - service::FieldResult> getMeowVolume(service::FieldParams&& params) const final + service::AwaitableScalar> getMeowVolume(service::FieldParams&& params) const final { if constexpr (methods::CatHas::getMeowVolumeWithParams) { diff --git a/samples/validation/schema/DogObject.h b/samples/validation/schema/DogObject.h index d50eba34..bd8b3180 100644 --- a/samples/validation/schema/DogObject.h +++ b/samples/validation/schema/DogObject.h @@ -23,73 +23,73 @@ namespace methods::DogHas { template concept getNameWithParams = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult { impl.getName(std::move(params)) } }; + { service::AwaitableScalar { impl.getName(std::move(params)) } }; }; template concept getName = requires (TImpl impl) { - { service::FieldResult { impl.getName() } }; + { service::AwaitableScalar { impl.getName() } }; }; template concept getNicknameWithParams = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult> { impl.getNickname(std::move(params)) } }; + { service::AwaitableScalar> { impl.getNickname(std::move(params)) } }; }; template concept getNickname = requires (TImpl impl) { - { service::FieldResult> { impl.getNickname() } }; + { service::AwaitableScalar> { impl.getNickname() } }; }; template concept getBarkVolumeWithParams = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult> { impl.getBarkVolume(std::move(params)) } }; + { service::AwaitableScalar> { impl.getBarkVolume(std::move(params)) } }; }; template concept getBarkVolume = requires (TImpl impl) { - { service::FieldResult> { impl.getBarkVolume() } }; + { service::AwaitableScalar> { impl.getBarkVolume() } }; }; template concept getDoesKnowCommandWithParams = requires (TImpl impl, service::FieldParams params, DogCommand dogCommandArg) { - { service::FieldResult { impl.getDoesKnowCommand(std::move(params), std::move(dogCommandArg)) } }; + { service::AwaitableScalar { impl.getDoesKnowCommand(std::move(params), std::move(dogCommandArg)) } }; }; template concept getDoesKnowCommand = requires (TImpl impl, DogCommand dogCommandArg) { - { service::FieldResult { impl.getDoesKnowCommand(std::move(dogCommandArg)) } }; + { service::AwaitableScalar { impl.getDoesKnowCommand(std::move(dogCommandArg)) } }; }; template concept getIsHousetrainedWithParams = requires (TImpl impl, service::FieldParams params, std::optional atOtherHomesArg) { - { service::FieldResult { impl.getIsHousetrained(std::move(params), std::move(atOtherHomesArg)) } }; + { service::AwaitableScalar { impl.getIsHousetrained(std::move(params), std::move(atOtherHomesArg)) } }; }; template concept getIsHousetrained = requires (TImpl impl, std::optional atOtherHomesArg) { - { service::FieldResult { impl.getIsHousetrained(std::move(atOtherHomesArg)) } }; + { service::AwaitableScalar { impl.getIsHousetrained(std::move(atOtherHomesArg)) } }; }; template concept getOwnerWithParams = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult> { impl.getOwner(std::move(params)) } }; + { service::AwaitableObject> { impl.getOwner(std::move(params)) } }; }; template concept getOwner = requires (TImpl impl) { - { service::FieldResult> { impl.getOwner() } }; + { service::AwaitableObject> { impl.getOwner() } }; }; template @@ -126,12 +126,12 @@ class Dog virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual service::FieldResult getName(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getNickname(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getBarkVolume(service::FieldParams&& params) const = 0; - virtual service::FieldResult getDoesKnowCommand(service::FieldParams&& params, DogCommand&& dogCommandArg) const = 0; - virtual service::FieldResult getIsHousetrained(service::FieldParams&& params, std::optional&& atOtherHomesArg) const = 0; - virtual service::FieldResult> getOwner(service::FieldParams&& params) const = 0; + virtual service::AwaitableScalar getName(service::FieldParams&& params) const = 0; + virtual service::AwaitableScalar> getNickname(service::FieldParams&& params) const = 0; + virtual service::AwaitableScalar> getBarkVolume(service::FieldParams&& params) const = 0; + virtual service::AwaitableScalar getDoesKnowCommand(service::FieldParams&& params, DogCommand&& dogCommandArg) const = 0; + virtual service::AwaitableScalar getIsHousetrained(service::FieldParams&& params, std::optional&& atOtherHomesArg) const = 0; + virtual service::AwaitableObject> getOwner(service::FieldParams&& params) const = 0; }; template @@ -143,7 +143,7 @@ class Dog { } - service::FieldResult getName(service::FieldParams&& params) const final + service::AwaitableScalar getName(service::FieldParams&& params) const final { if constexpr (methods::DogHas::getNameWithParams) { @@ -159,7 +159,7 @@ class Dog } } - service::FieldResult> getNickname(service::FieldParams&& params) const final + service::AwaitableScalar> getNickname(service::FieldParams&& params) const final { if constexpr (methods::DogHas::getNicknameWithParams) { @@ -175,7 +175,7 @@ class Dog } } - service::FieldResult> getBarkVolume(service::FieldParams&& params) const final + service::AwaitableScalar> getBarkVolume(service::FieldParams&& params) const final { if constexpr (methods::DogHas::getBarkVolumeWithParams) { @@ -191,7 +191,7 @@ class Dog } } - service::FieldResult getDoesKnowCommand(service::FieldParams&& params, DogCommand&& dogCommandArg) const final + service::AwaitableScalar getDoesKnowCommand(service::FieldParams&& params, DogCommand&& dogCommandArg) const final { if constexpr (methods::DogHas::getDoesKnowCommandWithParams) { @@ -207,7 +207,7 @@ class Dog } } - service::FieldResult getIsHousetrained(service::FieldParams&& params, std::optional&& atOtherHomesArg) const final + service::AwaitableScalar getIsHousetrained(service::FieldParams&& params, std::optional&& atOtherHomesArg) const final { if constexpr (methods::DogHas::getIsHousetrainedWithParams) { @@ -223,7 +223,7 @@ class Dog } } - service::FieldResult> getOwner(service::FieldParams&& params) const final + service::AwaitableObject> getOwner(service::FieldParams&& params) const final { if constexpr (methods::DogHas::getOwnerWithParams) { diff --git a/samples/validation/schema/HumanObject.h b/samples/validation/schema/HumanObject.h index 7496a46f..948e3d07 100644 --- a/samples/validation/schema/HumanObject.h +++ b/samples/validation/schema/HumanObject.h @@ -23,25 +23,25 @@ namespace methods::HumanHas { template concept getNameWithParams = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult { impl.getName(std::move(params)) } }; + { service::AwaitableScalar { impl.getName(std::move(params)) } }; }; template concept getName = requires (TImpl impl) { - { service::FieldResult { impl.getName() } }; + { service::AwaitableScalar { impl.getName() } }; }; template concept getPetsWithParams = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult>> { impl.getPets(std::move(params)) } }; + { service::AwaitableObject>> { impl.getPets(std::move(params)) } }; }; template concept getPets = requires (TImpl impl) { - { service::FieldResult>> { impl.getPets() } }; + { service::AwaitableObject>> { impl.getPets() } }; }; template @@ -74,8 +74,8 @@ class Human virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual service::FieldResult getName(service::FieldParams&& params) const = 0; - virtual service::FieldResult>> getPets(service::FieldParams&& params) const = 0; + virtual service::AwaitableScalar getName(service::FieldParams&& params) const = 0; + virtual service::AwaitableObject>> getPets(service::FieldParams&& params) const = 0; }; template @@ -87,7 +87,7 @@ class Human { } - service::FieldResult getName(service::FieldParams&& params) const final + service::AwaitableScalar getName(service::FieldParams&& params) const final { if constexpr (methods::HumanHas::getNameWithParams) { @@ -103,7 +103,7 @@ class Human } } - service::FieldResult>> getPets(service::FieldParams&& params) const final + service::AwaitableObject>> getPets(service::FieldParams&& params) const final { if constexpr (methods::HumanHas::getPetsWithParams) { diff --git a/samples/validation/schema/MessageObject.h b/samples/validation/schema/MessageObject.h index c0e6dc03..05e56a38 100644 --- a/samples/validation/schema/MessageObject.h +++ b/samples/validation/schema/MessageObject.h @@ -16,25 +16,25 @@ namespace methods::MessageHas { template concept getBodyWithParams = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult> { impl.getBody(std::move(params)) } }; + { service::AwaitableScalar> { impl.getBody(std::move(params)) } }; }; template concept getBody = requires (TImpl impl) { - { service::FieldResult> { impl.getBody() } }; + { service::AwaitableScalar> { impl.getBody() } }; }; template concept getSenderWithParams = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult { impl.getSender(std::move(params)) } }; + { service::AwaitableScalar { impl.getSender(std::move(params)) } }; }; template concept getSender = requires (TImpl impl) { - { service::FieldResult { impl.getSender() } }; + { service::AwaitableScalar { impl.getSender() } }; }; template @@ -67,8 +67,8 @@ class Message virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual service::FieldResult> getBody(service::FieldParams&& params) const = 0; - virtual service::FieldResult getSender(service::FieldParams&& params) const = 0; + virtual service::AwaitableScalar> getBody(service::FieldParams&& params) const = 0; + virtual service::AwaitableScalar getSender(service::FieldParams&& params) const = 0; }; template @@ -80,7 +80,7 @@ class Message { } - service::FieldResult> getBody(service::FieldParams&& params) const final + service::AwaitableScalar> getBody(service::FieldParams&& params) const final { if constexpr (methods::MessageHas::getBodyWithParams) { @@ -96,7 +96,7 @@ class Message } } - service::FieldResult getSender(service::FieldParams&& params) const final + service::AwaitableScalar getSender(service::FieldParams&& params) const final { if constexpr (methods::MessageHas::getSenderWithParams) { diff --git a/samples/validation/schema/MutateDogResultObject.h b/samples/validation/schema/MutateDogResultObject.h index ff6a27ac..dddb50e3 100644 --- a/samples/validation/schema/MutateDogResultObject.h +++ b/samples/validation/schema/MutateDogResultObject.h @@ -16,13 +16,13 @@ namespace methods::MutateDogResultHas { template concept getIdWithParams = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult { impl.getId(std::move(params)) } }; + { service::AwaitableScalar { impl.getId(std::move(params)) } }; }; template concept getId = requires (TImpl impl) { - { service::FieldResult { impl.getId() } }; + { service::AwaitableScalar { impl.getId() } }; }; template @@ -54,7 +54,7 @@ class MutateDogResult virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual service::FieldResult getId(service::FieldParams&& params) const = 0; + virtual service::AwaitableScalar getId(service::FieldParams&& params) const = 0; }; template @@ -66,7 +66,7 @@ class MutateDogResult { } - service::FieldResult getId(service::FieldParams&& params) const final + service::AwaitableScalar getId(service::FieldParams&& params) const final { if constexpr (methods::MutateDogResultHas::getIdWithParams) { diff --git a/samples/validation/schema/MutationObject.h b/samples/validation/schema/MutationObject.h index 1980eebc..7096c006 100644 --- a/samples/validation/schema/MutationObject.h +++ b/samples/validation/schema/MutationObject.h @@ -16,13 +16,13 @@ namespace methods::MutationHas { template concept applyMutateDogWithParams = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult> { impl.applyMutateDog(std::move(params)) } }; + { service::AwaitableObject> { impl.applyMutateDog(std::move(params)) } }; }; template concept applyMutateDog = requires (TImpl impl) { - { service::FieldResult> { impl.applyMutateDog() } }; + { service::AwaitableObject> { impl.applyMutateDog() } }; }; template @@ -54,7 +54,7 @@ class Mutation virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual service::FieldResult> applyMutateDog(service::FieldParams&& params) const = 0; + virtual service::AwaitableObject> applyMutateDog(service::FieldParams&& params) const = 0; }; template @@ -66,7 +66,7 @@ class Mutation { } - service::FieldResult> applyMutateDog(service::FieldParams&& params) const final + service::AwaitableObject> applyMutateDog(service::FieldParams&& params) const final { if constexpr (methods::MutationHas::applyMutateDogWithParams) { diff --git a/samples/validation/schema/QueryObject.h b/samples/validation/schema/QueryObject.h index c5d971a3..d2935dc0 100644 --- a/samples/validation/schema/QueryObject.h +++ b/samples/validation/schema/QueryObject.h @@ -16,97 +16,97 @@ namespace methods::QueryHas { template concept getDogWithParams = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult> { impl.getDog(std::move(params)) } }; + { service::AwaitableObject> { impl.getDog(std::move(params)) } }; }; template concept getDog = requires (TImpl impl) { - { service::FieldResult> { impl.getDog() } }; + { service::AwaitableObject> { impl.getDog() } }; }; template concept getHumanWithParams = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult> { impl.getHuman(std::move(params)) } }; + { service::AwaitableObject> { impl.getHuman(std::move(params)) } }; }; template concept getHuman = requires (TImpl impl) { - { service::FieldResult> { impl.getHuman() } }; + { service::AwaitableObject> { impl.getHuman() } }; }; template concept getPetWithParams = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult> { impl.getPet(std::move(params)) } }; + { service::AwaitableObject> { impl.getPet(std::move(params)) } }; }; template concept getPet = requires (TImpl impl) { - { service::FieldResult> { impl.getPet() } }; + { service::AwaitableObject> { impl.getPet() } }; }; template concept getCatOrDogWithParams = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult> { impl.getCatOrDog(std::move(params)) } }; + { service::AwaitableObject> { impl.getCatOrDog(std::move(params)) } }; }; template concept getCatOrDog = requires (TImpl impl) { - { service::FieldResult> { impl.getCatOrDog() } }; + { service::AwaitableObject> { impl.getCatOrDog() } }; }; template concept getArgumentsWithParams = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult> { impl.getArguments(std::move(params)) } }; + { service::AwaitableObject> { impl.getArguments(std::move(params)) } }; }; template concept getArguments = requires (TImpl impl) { - { service::FieldResult> { impl.getArguments() } }; + { service::AwaitableObject> { impl.getArguments() } }; }; template concept getResourceWithParams = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult> { impl.getResource(std::move(params)) } }; + { service::AwaitableObject> { impl.getResource(std::move(params)) } }; }; template concept getResource = requires (TImpl impl) { - { service::FieldResult> { impl.getResource() } }; + { service::AwaitableObject> { impl.getResource() } }; }; template concept getFindDogWithParams = requires (TImpl impl, service::FieldParams params, std::optional complexArg) { - { service::FieldResult> { impl.getFindDog(std::move(params), std::move(complexArg)) } }; + { service::AwaitableObject> { impl.getFindDog(std::move(params), std::move(complexArg)) } }; }; template concept getFindDog = requires (TImpl impl, std::optional complexArg) { - { service::FieldResult> { impl.getFindDog(std::move(complexArg)) } }; + { service::AwaitableObject> { impl.getFindDog(std::move(complexArg)) } }; }; template concept getBooleanListWithParams = requires (TImpl impl, service::FieldParams params, std::optional> booleanListArgArg) { - { service::FieldResult> { impl.getBooleanList(std::move(params), std::move(booleanListArgArg)) } }; + { service::AwaitableScalar> { impl.getBooleanList(std::move(params), std::move(booleanListArgArg)) } }; }; template concept getBooleanList = requires (TImpl impl, std::optional> booleanListArgArg) { - { service::FieldResult> { impl.getBooleanList(std::move(booleanListArgArg)) } }; + { service::AwaitableScalar> { impl.getBooleanList(std::move(booleanListArgArg)) } }; }; template @@ -145,14 +145,14 @@ class Query virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual service::FieldResult> getDog(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getHuman(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getPet(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getCatOrDog(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getArguments(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getResource(service::FieldParams&& params) const = 0; - virtual service::FieldResult> getFindDog(service::FieldParams&& params, std::optional&& complexArg) const = 0; - virtual service::FieldResult> getBooleanList(service::FieldParams&& params, std::optional>&& booleanListArgArg) const = 0; + virtual service::AwaitableObject> getDog(service::FieldParams&& params) const = 0; + virtual service::AwaitableObject> getHuman(service::FieldParams&& params) const = 0; + virtual service::AwaitableObject> getPet(service::FieldParams&& params) const = 0; + virtual service::AwaitableObject> getCatOrDog(service::FieldParams&& params) const = 0; + virtual service::AwaitableObject> getArguments(service::FieldParams&& params) const = 0; + virtual service::AwaitableObject> getResource(service::FieldParams&& params) const = 0; + virtual service::AwaitableObject> getFindDog(service::FieldParams&& params, std::optional&& complexArg) const = 0; + virtual service::AwaitableScalar> getBooleanList(service::FieldParams&& params, std::optional>&& booleanListArgArg) const = 0; }; template @@ -164,7 +164,7 @@ class Query { } - service::FieldResult> getDog(service::FieldParams&& params) const final + service::AwaitableObject> getDog(service::FieldParams&& params) const final { if constexpr (methods::QueryHas::getDogWithParams) { @@ -180,7 +180,7 @@ class Query } } - service::FieldResult> getHuman(service::FieldParams&& params) const final + service::AwaitableObject> getHuman(service::FieldParams&& params) const final { if constexpr (methods::QueryHas::getHumanWithParams) { @@ -196,7 +196,7 @@ class Query } } - service::FieldResult> getPet(service::FieldParams&& params) const final + service::AwaitableObject> getPet(service::FieldParams&& params) const final { if constexpr (methods::QueryHas::getPetWithParams) { @@ -212,7 +212,7 @@ class Query } } - service::FieldResult> getCatOrDog(service::FieldParams&& params) const final + service::AwaitableObject> getCatOrDog(service::FieldParams&& params) const final { if constexpr (methods::QueryHas::getCatOrDogWithParams) { @@ -228,7 +228,7 @@ class Query } } - service::FieldResult> getArguments(service::FieldParams&& params) const final + service::AwaitableObject> getArguments(service::FieldParams&& params) const final { if constexpr (methods::QueryHas::getArgumentsWithParams) { @@ -244,7 +244,7 @@ class Query } } - service::FieldResult> getResource(service::FieldParams&& params) const final + service::AwaitableObject> getResource(service::FieldParams&& params) const final { if constexpr (methods::QueryHas::getResourceWithParams) { @@ -260,7 +260,7 @@ class Query } } - service::FieldResult> getFindDog(service::FieldParams&& params, std::optional&& complexArg) const final + service::AwaitableObject> getFindDog(service::FieldParams&& params, std::optional&& complexArg) const final { if constexpr (methods::QueryHas::getFindDogWithParams) { @@ -276,7 +276,7 @@ class Query } } - service::FieldResult> getBooleanList(service::FieldParams&& params, std::optional>&& booleanListArgArg) const final + service::AwaitableScalar> getBooleanList(service::FieldParams&& params, std::optional>&& booleanListArgArg) const final { if constexpr (methods::QueryHas::getBooleanListWithParams) { diff --git a/samples/validation/schema/SubscriptionObject.h b/samples/validation/schema/SubscriptionObject.h index e1eac1e3..4474734e 100644 --- a/samples/validation/schema/SubscriptionObject.h +++ b/samples/validation/schema/SubscriptionObject.h @@ -16,25 +16,25 @@ namespace methods::SubscriptionHas { template concept getNewMessageWithParams = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult> { impl.getNewMessage(std::move(params)) } }; + { service::AwaitableObject> { impl.getNewMessage(std::move(params)) } }; }; template concept getNewMessage = requires (TImpl impl) { - { service::FieldResult> { impl.getNewMessage() } }; + { service::AwaitableObject> { impl.getNewMessage() } }; }; template concept getDisallowedSecondRootFieldWithParams = requires (TImpl impl, service::FieldParams params) { - { service::FieldResult { impl.getDisallowedSecondRootField(std::move(params)) } }; + { service::AwaitableScalar { impl.getDisallowedSecondRootField(std::move(params)) } }; }; template concept getDisallowedSecondRootField = requires (TImpl impl) { - { service::FieldResult { impl.getDisallowedSecondRootField() } }; + { service::AwaitableScalar { impl.getDisallowedSecondRootField() } }; }; template @@ -67,8 +67,8 @@ class Subscription virtual void beginSelectionSet(const service::SelectionSetParams& params) const = 0; virtual void endSelectionSet(const service::SelectionSetParams& params) const = 0; - virtual service::FieldResult> getNewMessage(service::FieldParams&& params) const = 0; - virtual service::FieldResult getDisallowedSecondRootField(service::FieldParams&& params) const = 0; + virtual service::AwaitableObject> getNewMessage(service::FieldParams&& params) const = 0; + virtual service::AwaitableScalar getDisallowedSecondRootField(service::FieldParams&& params) const = 0; }; template @@ -80,7 +80,7 @@ class Subscription { } - service::FieldResult> getNewMessage(service::FieldParams&& params) const final + service::AwaitableObject> getNewMessage(service::FieldParams&& params) const final { if constexpr (methods::SubscriptionHas::getNewMessageWithParams) { @@ -96,7 +96,7 @@ class Subscription } } - service::FieldResult getDisallowedSecondRootField(service::FieldParams&& params) const final + service::AwaitableScalar getDisallowedSecondRootField(service::FieldParams&& params) const final { if constexpr (methods::SubscriptionHas::getDisallowedSecondRootFieldWithParams) { diff --git a/samples/validation/schema/ValidationSchema.cpp b/samples/validation/schema/ValidationSchema.cpp index c06e4f27..317247ad 100644 --- a/samples/validation/schema/ValidationSchema.cpp +++ b/samples/validation/schema/ValidationSchema.cpp @@ -50,7 +50,7 @@ validation::DogCommand ModifiedArgument::convert(const r } template <> -service::AwaitableResolver ModifiedResult::convert(service::FieldResult result, ResolverParams params) +service::AwaitableResolver ModifiedResult::convert(service::AwaitableScalar result, ResolverParams params) { return resolve(std::move(result), std::move(params), [](validation::DogCommand value, const ResolverParams&) @@ -86,7 +86,7 @@ validation::CatCommand ModifiedArgument::convert(const r } template <> -service::AwaitableResolver ModifiedResult::convert(service::FieldResult result, ResolverParams params) +service::AwaitableResolver ModifiedResult::convert(service::AwaitableScalar result, ResolverParams params) { return resolve(std::move(result), std::move(params), [](validation::CatCommand value, const ResolverParams&) diff --git a/src/GraphQLService.cpp b/src/GraphQLService.cpp index 6fdb7fbf..b877ab76 100644 --- a/src/GraphQLService.cpp +++ b/src/GraphQLService.cpp @@ -608,7 +608,7 @@ void blockSubFields(const ResolverParams& params) } template <> -AwaitableResolver ModifiedResult::convert(FieldResult result, ResolverParams params) +AwaitableResolver ModifiedResult::convert(AwaitableScalar result, ResolverParams params) { blockSubFields(params); @@ -618,7 +618,8 @@ AwaitableResolver ModifiedResult::convert(FieldResult result, Resolver } template <> -AwaitableResolver ModifiedResult::convert(FieldResult result, ResolverParams params) +AwaitableResolver ModifiedResult::convert( + AwaitableScalar result, ResolverParams params) { blockSubFields(params); @@ -629,7 +630,7 @@ AwaitableResolver ModifiedResult::convert(FieldResult result, Re template <> AwaitableResolver ModifiedResult::convert( - FieldResult result, ResolverParams params) + AwaitableScalar result, ResolverParams params) { blockSubFields(params); @@ -641,7 +642,7 @@ AwaitableResolver ModifiedResult::convert( } template <> -AwaitableResolver ModifiedResult::convert(FieldResult result, ResolverParams params) +AwaitableResolver ModifiedResult::convert(AwaitableScalar result, ResolverParams params) { blockSubFields(params); @@ -652,7 +653,7 @@ AwaitableResolver ModifiedResult::convert(FieldResult result, Resolv template <> AwaitableResolver ModifiedResult::convert( - FieldResult result, ResolverParams params) + AwaitableScalar result, ResolverParams params) { blockSubFields(params); @@ -665,7 +666,7 @@ AwaitableResolver ModifiedResult::convert( template <> AwaitableResolver ModifiedResult::convert( - FieldResult result, ResolverParams params) + AwaitableScalar result, ResolverParams params) { blockSubFields(params); @@ -694,15 +695,8 @@ void requireSubFields(const ResolverParams& params) template <> AwaitableResolver ModifiedResult::convert( - FieldResult> result, ResolverParams params) + AwaitableObject> result, ResolverParams params) { - auto value = result.get_value(); - - if (value) - { - co_return ResolverResult { response::Value { std::shared_ptr { std::move(value) } } }; - } - requireSubFields(params); co_await params.launch; diff --git a/src/SchemaGenerator.cpp b/src/SchemaGenerator.cpp index 7425cb4e..f108d467 100644 --- a/src/SchemaGenerator.cpp +++ b/src/SchemaGenerator.cpp @@ -478,7 +478,7 @@ template <> GRAPHQLINTROSPECTION_EXPORT AwaitableResolver ModifiedResult<)cpp" << _loader.getSchemaNamespace() << R"cpp(::)cpp" << enumType.cppType << R"cpp(>::convert( - FieldResult<)cpp" << _loader.getSchemaNamespace() + AwaitableScalar<)cpp" << _loader.getSchemaNamespace() << R"cpp(::)cpp" << enumType.cppType << R"cpp(> result, ResolverParams params); )cpp"; @@ -658,8 +658,8 @@ concept )cpp" << outputField.accessor headerFile << R"cpp() { - { service::FieldResult<)cpp" - << _loader.getOutputCppType(outputField) << R"cpp(> { impl.)cpp" + { )cpp" + << _loader.getOutputCppType(outputField) << R"cpp( { impl.)cpp" << outputField.accessor << fieldName << R"cpp((std::move(params))cpp"; if (!passedArguments.empty()) @@ -681,8 +681,8 @@ concept )cpp" << outputField.accessor headerFile << R"cpp() { - { service::FieldResult<)cpp" - << _loader.getOutputCppType(outputField) << R"cpp(> { impl.)cpp" + { )cpp" + << _loader.getOutputCppType(outputField) << R"cpp( { impl.)cpp" << outputField.accessor << fieldName << R"cpp(()cpp"; if (!passedArguments.empty()) @@ -779,8 +779,8 @@ void Generator::outputObjectDeclaration( fieldName[0] = static_cast(std::toupper(static_cast(fieldName[0]))); headerFile << R"cpp( - service::FieldResult<)cpp" - << _loader.getOutputCppType(outputField) << R"cpp(> )cpp" << outputField.accessor + )cpp" + << _loader.getOutputCppType(outputField) << R"cpp( )cpp" << outputField.accessor << fieldName << R"cpp(()cpp"; bool firstArgument = _loader.isIntrospection(); @@ -1033,8 +1033,8 @@ std::string Generator::getFieldDeclaration(const OutputField& outputField) const std::string fieldName { outputField.cppName }; fieldName[0] = static_cast(std::toupper(static_cast(fieldName[0]))); - output << R"cpp( virtual service::FieldResult<)cpp" - << _loader.getOutputCppType(outputField) << R"cpp(> )cpp" << outputField.accessor + output << R"cpp( virtual )cpp" + << _loader.getOutputCppType(outputField) << R"cpp( )cpp" << outputField.accessor << fieldName << R"cpp(()cpp"; bool firstArgument = _loader.isIntrospection(); @@ -1186,7 +1186,7 @@ template <> template <> service::AwaitableResolver ModifiedResult<)cpp" << _loader.getSchemaNamespace() << R"cpp(::)cpp" << enumType.cppType - << R"cpp(>::convert(service::FieldResult<)cpp" + << R"cpp(>::convert(service::AwaitableScalar<)cpp" << _loader.getSchemaNamespace() << R"cpp(::)cpp" << enumType.cppType << R"cpp(> result, ResolverParams params) { diff --git a/src/SchemaLoader.cpp b/src/SchemaLoader.cpp index 58453949..daeca935 100644 --- a/src/SchemaLoader.cpp +++ b/src/SchemaLoader.cpp @@ -1604,6 +1604,22 @@ std::string SchemaLoader::getOutputCppType(const OutputField& field) const noexc size_t templateCount = 0; std::ostringstream outputType; + switch (field.fieldType) + { + case OutputFieldType::Object: + case OutputFieldType::Union: + case OutputFieldType::Interface: + // Even if it's non-nullable, we still want to return a shared_ptr for complex types + outputType << R"cpp(service::AwaitableObject<)cpp"; + ++templateCount; + break; + + default: + outputType << R"cpp(service::AwaitableScalar<)cpp"; + ++templateCount; + break; + } + for (auto modifier : field.modifiers) { if (!nonNull) diff --git a/src/introspection/DirectiveObject.h b/src/introspection/DirectiveObject.h index 2349fe17..22b77759 100644 --- a/src/introspection/DirectiveObject.h +++ b/src/introspection/DirectiveObject.h @@ -28,11 +28,11 @@ class Directive { virtual ~Concept() = default; - virtual service::FieldResult getName() const = 0; - virtual service::FieldResult> getDescription() const = 0; - virtual service::FieldResult> getLocations() const = 0; - virtual service::FieldResult>> getArgs() const = 0; - virtual service::FieldResult getIsRepeatable() const = 0; + virtual service::AwaitableScalar getName() const = 0; + virtual service::AwaitableScalar> getDescription() const = 0; + virtual service::AwaitableScalar> getLocations() const = 0; + virtual service::AwaitableObject>> getArgs() const = 0; + virtual service::AwaitableScalar getIsRepeatable() const = 0; }; template @@ -44,27 +44,27 @@ class Directive { } - service::FieldResult getName() const final + service::AwaitableScalar getName() const final { return { _pimpl->getName() }; } - service::FieldResult> getDescription() const final + service::AwaitableScalar> getDescription() const final { return { _pimpl->getDescription() }; } - service::FieldResult> getLocations() const final + service::AwaitableScalar> getLocations() const final { return { _pimpl->getLocations() }; } - service::FieldResult>> getArgs() const final + service::AwaitableObject>> getArgs() const final { return { _pimpl->getArgs() }; } - service::FieldResult getIsRepeatable() const final + service::AwaitableScalar getIsRepeatable() const final { return { _pimpl->getIsRepeatable() }; } diff --git a/src/introspection/EnumValueObject.h b/src/introspection/EnumValueObject.h index f52cc584..390565c7 100644 --- a/src/introspection/EnumValueObject.h +++ b/src/introspection/EnumValueObject.h @@ -27,10 +27,10 @@ class EnumValue { virtual ~Concept() = default; - virtual service::FieldResult getName() const = 0; - virtual service::FieldResult> getDescription() const = 0; - virtual service::FieldResult getIsDeprecated() const = 0; - virtual service::FieldResult> getDeprecationReason() const = 0; + virtual service::AwaitableScalar getName() const = 0; + virtual service::AwaitableScalar> getDescription() const = 0; + virtual service::AwaitableScalar getIsDeprecated() const = 0; + virtual service::AwaitableScalar> getDeprecationReason() const = 0; }; template @@ -42,22 +42,22 @@ class EnumValue { } - service::FieldResult getName() const final + service::AwaitableScalar getName() const final { return { _pimpl->getName() }; } - service::FieldResult> getDescription() const final + service::AwaitableScalar> getDescription() const final { return { _pimpl->getDescription() }; } - service::FieldResult getIsDeprecated() const final + service::AwaitableScalar getIsDeprecated() const final { return { _pimpl->getIsDeprecated() }; } - service::FieldResult> getDeprecationReason() const final + service::AwaitableScalar> getDeprecationReason() const final { return { _pimpl->getDeprecationReason() }; } diff --git a/src/introspection/FieldObject.h b/src/introspection/FieldObject.h index 1d50a0cd..778286e0 100644 --- a/src/introspection/FieldObject.h +++ b/src/introspection/FieldObject.h @@ -29,12 +29,12 @@ class Field { virtual ~Concept() = default; - virtual service::FieldResult getName() const = 0; - virtual service::FieldResult> getDescription() const = 0; - virtual service::FieldResult>> getArgs() const = 0; - virtual service::FieldResult> getType() const = 0; - virtual service::FieldResult getIsDeprecated() const = 0; - virtual service::FieldResult> getDeprecationReason() const = 0; + virtual service::AwaitableScalar getName() const = 0; + virtual service::AwaitableScalar> getDescription() const = 0; + virtual service::AwaitableObject>> getArgs() const = 0; + virtual service::AwaitableObject> getType() const = 0; + virtual service::AwaitableScalar getIsDeprecated() const = 0; + virtual service::AwaitableScalar> getDeprecationReason() const = 0; }; template @@ -46,32 +46,32 @@ class Field { } - service::FieldResult getName() const final + service::AwaitableScalar getName() const final { return { _pimpl->getName() }; } - service::FieldResult> getDescription() const final + service::AwaitableScalar> getDescription() const final { return { _pimpl->getDescription() }; } - service::FieldResult>> getArgs() const final + service::AwaitableObject>> getArgs() const final { return { _pimpl->getArgs() }; } - service::FieldResult> getType() const final + service::AwaitableObject> getType() const final { return { _pimpl->getType() }; } - service::FieldResult getIsDeprecated() const final + service::AwaitableScalar getIsDeprecated() const final { return { _pimpl->getIsDeprecated() }; } - service::FieldResult> getDeprecationReason() const final + service::AwaitableScalar> getDeprecationReason() const final { return { _pimpl->getDeprecationReason() }; } diff --git a/src/introspection/InputValueObject.h b/src/introspection/InputValueObject.h index 65199e06..1b9ed622 100644 --- a/src/introspection/InputValueObject.h +++ b/src/introspection/InputValueObject.h @@ -27,10 +27,10 @@ class InputValue { virtual ~Concept() = default; - virtual service::FieldResult getName() const = 0; - virtual service::FieldResult> getDescription() const = 0; - virtual service::FieldResult> getType() const = 0; - virtual service::FieldResult> getDefaultValue() const = 0; + virtual service::AwaitableScalar getName() const = 0; + virtual service::AwaitableScalar> getDescription() const = 0; + virtual service::AwaitableObject> getType() const = 0; + virtual service::AwaitableScalar> getDefaultValue() const = 0; }; template @@ -42,22 +42,22 @@ class InputValue { } - service::FieldResult getName() const final + service::AwaitableScalar getName() const final { return { _pimpl->getName() }; } - service::FieldResult> getDescription() const final + service::AwaitableScalar> getDescription() const final { return { _pimpl->getDescription() }; } - service::FieldResult> getType() const final + service::AwaitableObject> getType() const final { return { _pimpl->getType() }; } - service::FieldResult> getDefaultValue() const final + service::AwaitableScalar> getDefaultValue() const final { return { _pimpl->getDefaultValue() }; } diff --git a/src/introspection/IntrospectionSchema.cpp b/src/introspection/IntrospectionSchema.cpp index 0bf9ba6b..366b62f0 100644 --- a/src/introspection/IntrospectionSchema.cpp +++ b/src/introspection/IntrospectionSchema.cpp @@ -49,7 +49,7 @@ introspection::TypeKind ModifiedArgument::convert(const } template <> -service::AwaitableResolver ModifiedResult::convert(service::FieldResult result, ResolverParams params) +service::AwaitableResolver ModifiedResult::convert(service::AwaitableScalar result, ResolverParams params) { return resolve(std::move(result), std::move(params), [](introspection::TypeKind value, const ResolverParams&) @@ -103,7 +103,7 @@ introspection::DirectiveLocation ModifiedArgument -service::AwaitableResolver ModifiedResult::convert(service::FieldResult result, ResolverParams params) +service::AwaitableResolver ModifiedResult::convert(service::AwaitableScalar result, ResolverParams params) { return resolve(std::move(result), std::move(params), [](introspection::DirectiveLocation value, const ResolverParams&) diff --git a/src/introspection/IntrospectionSchema.h b/src/introspection/IntrospectionSchema.h index d833ce84..6c50cd2f 100644 --- a/src/introspection/IntrospectionSchema.h +++ b/src/introspection/IntrospectionSchema.h @@ -106,13 +106,13 @@ GRAPHQLINTROSPECTION_EXPORT introspection::TypeKind ModifiedArgument GRAPHQLINTROSPECTION_EXPORT AwaitableResolver ModifiedResult::convert( - FieldResult result, ResolverParams params); + AwaitableScalar result, ResolverParams params); template <> GRAPHQLINTROSPECTION_EXPORT introspection::DirectiveLocation ModifiedArgument::convert( const response::Value& value); template <> GRAPHQLINTROSPECTION_EXPORT AwaitableResolver ModifiedResult::convert( - FieldResult result, ResolverParams params); + AwaitableScalar result, ResolverParams params); #endif // GRAPHQL_DLLEXPORTS } // namespace service diff --git a/src/introspection/SchemaObject.h b/src/introspection/SchemaObject.h index 9a4b082a..a8f05373 100644 --- a/src/introspection/SchemaObject.h +++ b/src/introspection/SchemaObject.h @@ -29,12 +29,12 @@ class Schema { virtual ~Concept() = default; - virtual service::FieldResult> getDescription() const = 0; - virtual service::FieldResult>> getTypes() const = 0; - virtual service::FieldResult> getQueryType() const = 0; - virtual service::FieldResult> getMutationType() const = 0; - virtual service::FieldResult> getSubscriptionType() const = 0; - virtual service::FieldResult>> getDirectives() const = 0; + virtual service::AwaitableScalar> getDescription() const = 0; + virtual service::AwaitableObject>> getTypes() const = 0; + virtual service::AwaitableObject> getQueryType() const = 0; + virtual service::AwaitableObject> getMutationType() const = 0; + virtual service::AwaitableObject> getSubscriptionType() const = 0; + virtual service::AwaitableObject>> getDirectives() const = 0; }; template @@ -46,32 +46,32 @@ class Schema { } - service::FieldResult> getDescription() const final + service::AwaitableScalar> getDescription() const final { return { _pimpl->getDescription() }; } - service::FieldResult>> getTypes() const final + service::AwaitableObject>> getTypes() const final { return { _pimpl->getTypes() }; } - service::FieldResult> getQueryType() const final + service::AwaitableObject> getQueryType() const final { return { _pimpl->getQueryType() }; } - service::FieldResult> getMutationType() const final + service::AwaitableObject> getMutationType() const final { return { _pimpl->getMutationType() }; } - service::FieldResult> getSubscriptionType() const final + service::AwaitableObject> getSubscriptionType() const final { return { _pimpl->getSubscriptionType() }; } - service::FieldResult>> getDirectives() const final + service::AwaitableObject>> getDirectives() const final { return { _pimpl->getDirectives() }; } diff --git a/src/introspection/TypeObject.h b/src/introspection/TypeObject.h index 484980e1..32bc9bdb 100644 --- a/src/introspection/TypeObject.h +++ b/src/introspection/TypeObject.h @@ -33,16 +33,16 @@ class Type { virtual ~Concept() = default; - virtual service::FieldResult getKind() const = 0; - virtual service::FieldResult> getName() const = 0; - virtual service::FieldResult> getDescription() const = 0; - virtual service::FieldResult>>> getFields(std::optional&& includeDeprecatedArg) const = 0; - virtual service::FieldResult>>> getInterfaces() const = 0; - virtual service::FieldResult>>> getPossibleTypes() const = 0; - virtual service::FieldResult>>> getEnumValues(std::optional&& includeDeprecatedArg) const = 0; - virtual service::FieldResult>>> getInputFields() const = 0; - virtual service::FieldResult> getOfType() const = 0; - virtual service::FieldResult> getSpecifiedByURL() const = 0; + virtual service::AwaitableScalar getKind() const = 0; + virtual service::AwaitableScalar> getName() const = 0; + virtual service::AwaitableScalar> getDescription() const = 0; + virtual service::AwaitableObject>>> getFields(std::optional&& includeDeprecatedArg) const = 0; + virtual service::AwaitableObject>>> getInterfaces() const = 0; + virtual service::AwaitableObject>>> getPossibleTypes() const = 0; + virtual service::AwaitableObject>>> getEnumValues(std::optional&& includeDeprecatedArg) const = 0; + virtual service::AwaitableObject>>> getInputFields() const = 0; + virtual service::AwaitableObject> getOfType() const = 0; + virtual service::AwaitableScalar> getSpecifiedByURL() const = 0; }; template @@ -54,52 +54,52 @@ class Type { } - service::FieldResult getKind() const final + service::AwaitableScalar getKind() const final { return { _pimpl->getKind() }; } - service::FieldResult> getName() const final + service::AwaitableScalar> getName() const final { return { _pimpl->getName() }; } - service::FieldResult> getDescription() const final + service::AwaitableScalar> getDescription() const final { return { _pimpl->getDescription() }; } - service::FieldResult>>> getFields(std::optional&& includeDeprecatedArg) const final + service::AwaitableObject>>> getFields(std::optional&& includeDeprecatedArg) const final { return { _pimpl->getFields(std::move(includeDeprecatedArg)) }; } - service::FieldResult>>> getInterfaces() const final + service::AwaitableObject>>> getInterfaces() const final { return { _pimpl->getInterfaces() }; } - service::FieldResult>>> getPossibleTypes() const final + service::AwaitableObject>>> getPossibleTypes() const final { return { _pimpl->getPossibleTypes() }; } - service::FieldResult>>> getEnumValues(std::optional&& includeDeprecatedArg) const final + service::AwaitableObject>>> getEnumValues(std::optional&& includeDeprecatedArg) const final { return { _pimpl->getEnumValues(std::move(includeDeprecatedArg)) }; } - service::FieldResult>>> getInputFields() const final + service::AwaitableObject>>> getInputFields() const final { return { _pimpl->getInputFields() }; } - service::FieldResult> getOfType() const final + service::AwaitableObject> getOfType() const final { return { _pimpl->getOfType() }; } - service::FieldResult> getSpecifiedByURL() const final + service::AwaitableScalar> getSpecifiedByURL() const final { return { _pimpl->getSpecifiedByURL() }; } From 92e36af7e31486459eb0714615c5fcb79069e670 Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Tue, 14 Dec 2021 15:49:51 -0800 Subject: [PATCH 103/119] Validate custom response::Value in ModifiedResult --- include/graphqlservice/GraphQLService.h | 73 +++++++++++++++++-- .../introspection/IntrospectionSchema.h | 6 ++ samples/learn/schema/StarWarsSchema.cpp | 16 ++++ samples/today/nointrospection/TodaySchema.cpp | 16 ++++ samples/today/schema/TodaySchema.cpp | 16 ++++ .../validation/schema/ValidationSchema.cpp | 32 ++++++++ src/GraphQLService.cpp | 60 +++++++++++++++ src/SchemaGenerator.cpp | 49 ++++++++++--- src/introspection/IntrospectionSchema.cpp | 32 ++++++++ src/introspection/IntrospectionSchema.h | 6 ++ 10 files changed, 288 insertions(+), 18 deletions(-) diff --git a/include/graphqlservice/GraphQLService.h b/include/graphqlservice/GraphQLService.h index 72586736..ebd026a1 100644 --- a/include/graphqlservice/GraphQLService.h +++ b/include/graphqlservice/GraphQLService.h @@ -297,10 +297,7 @@ struct FieldParams : SelectionSetParams // by returning an async future or an awaitable coroutine. // // If the overhead of conversion to response::Value is too expensive, scalar type field accessors -// can store and return a std::shared_ptr directly. However, be careful using -// this mechanism, because there's no validation that the response::Value you return matches the -// GraphQL type of this field. It will be inserted directly into the response document without -// modification. +// can store and return a std::shared_ptr directly. template class AwaitableScalar { @@ -836,13 +833,14 @@ struct ModifiedResult // Peel off the none modifier. If it's included, it should always be last in the list. template - static typename std::enable_if_t && std::is_base_of_v, AwaitableResolver> convert(AwaitableObject::type> result, ResolverParams params) { // Call through to the Object specialization with a static_pointer_cast for subclasses of // Object. + static_assert(sizeof...(Other) == 0, "None modifier should always be last"); static_assert(std::is_same_v, typename ResultTraits::type>, "this is the derived object type"); @@ -857,11 +855,13 @@ struct ModifiedResult // Peel off the none modifier. If it's included, it should always be last in the list. template - static typename std::enable_if_t || !std::is_base_of_v), AwaitableResolver> convert(typename ResultTraits::future_type result, ResolverParams params) { + static_assert(sizeof...(Other) == 0, "None modifier should always be last"); + // Just call through to the partial specialization without the modifier. return convert(std::move(result), std::move(params)); } @@ -907,6 +907,7 @@ struct ModifiedResult if (value) { + ModifiedResult::validateScalar(*value); co_return ResolverResult { response::Value { std::shared_ptr { std::move(value) } } }; } @@ -938,6 +939,7 @@ struct ModifiedResult if (value) { + ModifiedResult::validateScalar(*value); co_return ResolverResult { response::Value { std::shared_ptr { std::move(value) } } }; } @@ -1028,6 +1030,47 @@ struct ModifiedResult } private: + // Validate a single scalar value is the expected type. + static void validateScalar(const response::Value& value); + + // Peel off the none modifier. If it's included, it should always be last in the list. + template + static void validateScalar( + typename std::enable_if_t value) + { + static_assert(sizeof...(Other) == 0, "None modifier should always be last"); + + // Just call through to the partial specialization without the modifier. + validateScalar(value); + } + + // Peel off nullable modifiers. + template + static void validateScalar( + typename std::enable_if_t value) + { + if (value.type() != response::Type::Null) + { + ModifiedResult::validateScalar(value); + } + } + + // Peel off list modifiers. + template + static void validateScalar( + typename std::enable_if_t value) + { + if (value.type() != response::Type::List) + { + throw schema_exception { { R"ex(not a valid List value)ex" } }; + } + + for (size_t i = 0; i < value.size(); ++i) + { + ModifiedResult::validateScalar(value[i]); + } + } + using ResolverCallback = std::function::type, const ResolverParams&)>; @@ -1041,6 +1084,7 @@ struct ModifiedResult if (value) { + ModifiedResult::validateScalar(*value); co_return ResolverResult { response::Value { std::shared_ptr { std::move(value) } } }; } @@ -1110,6 +1154,23 @@ GRAPHQLSERVICE_EXPORT AwaitableResolver ModifiedResult::convert template <> GRAPHQLSERVICE_EXPORT AwaitableResolver ModifiedResult::convert( AwaitableObject> result, ResolverParams params); + +// Export all of the scalar value validation methods +template <> +GRAPHQLSERVICE_EXPORT void ModifiedResult::validateScalar(const response::Value& value); +template <> +GRAPHQLSERVICE_EXPORT void ModifiedResult::validateScalar(const response::Value& value); +template <> +GRAPHQLSERVICE_EXPORT void ModifiedResult::validateScalar( + const response::Value& value); +template <> +GRAPHQLSERVICE_EXPORT void ModifiedResult::validateScalar(const response::Value& value); +template <> +GRAPHQLSERVICE_EXPORT void ModifiedResult::validateScalar( + const response::Value& value); +template <> +GRAPHQLSERVICE_EXPORT void ModifiedResult::validateScalar( + const response::Value& value); #endif // GRAPHQL_DLLEXPORTS // Subscription callbacks receive the response::Value representing the result of evaluating the diff --git a/include/graphqlservice/introspection/IntrospectionSchema.h b/include/graphqlservice/introspection/IntrospectionSchema.h index 6c50cd2f..9507b218 100644 --- a/include/graphqlservice/introspection/IntrospectionSchema.h +++ b/include/graphqlservice/introspection/IntrospectionSchema.h @@ -108,11 +108,17 @@ template <> GRAPHQLINTROSPECTION_EXPORT AwaitableResolver ModifiedResult::convert( AwaitableScalar result, ResolverParams params); template <> +GRAPHQLINTROSPECTION_EXPORT void ModifiedResult::validateScalar( + const response::Value& value); +template <> GRAPHQLINTROSPECTION_EXPORT introspection::DirectiveLocation ModifiedArgument::convert( const response::Value& value); template <> GRAPHQLINTROSPECTION_EXPORT AwaitableResolver ModifiedResult::convert( AwaitableScalar result, ResolverParams params); +template <> +GRAPHQLINTROSPECTION_EXPORT void ModifiedResult::validateScalar( + const response::Value& value); #endif // GRAPHQL_DLLEXPORTS } // namespace service diff --git a/samples/learn/schema/StarWarsSchema.cpp b/samples/learn/schema/StarWarsSchema.cpp index b67dfdbc..f99c4fa8 100644 --- a/samples/learn/schema/StarWarsSchema.cpp +++ b/samples/learn/schema/StarWarsSchema.cpp @@ -62,6 +62,22 @@ service::AwaitableResolver ModifiedResult::convert(service::Awai }); } +template <> +void ModifiedResult::validateScalar(const response::Value& value) +{ + if (!value.maybe_enum()) + { + throw service::schema_exception { { R"ex(not a valid Episode value)ex" } }; + } + + const auto itr = std::find(s_namesEpisode.cbegin(), s_namesEpisode.cend(), value.get()); + + if (itr == s_namesEpisode.cend()) + { + throw service::schema_exception { { R"ex(not a valid Episode value)ex" } }; + } +} + template <> learn::ReviewInput ModifiedArgument::convert(const response::Value& value) { diff --git a/samples/today/nointrospection/TodaySchema.cpp b/samples/today/nointrospection/TodaySchema.cpp index 4a327101..30d1db46 100644 --- a/samples/today/nointrospection/TodaySchema.cpp +++ b/samples/today/nointrospection/TodaySchema.cpp @@ -64,6 +64,22 @@ service::AwaitableResolver ModifiedResult::convert(service::Aw }); } +template <> +void ModifiedResult::validateScalar(const response::Value& value) +{ + if (!value.maybe_enum()) + { + throw service::schema_exception { { R"ex(not a valid TaskState value)ex" } }; + } + + const auto itr = std::find(s_namesTaskState.cbegin(), s_namesTaskState.cend(), value.get()); + + if (itr == s_namesTaskState.cend()) + { + throw service::schema_exception { { R"ex(not a valid TaskState value)ex" } }; + } +} + template <> today::CompleteTaskInput ModifiedArgument::convert(const response::Value& value) { diff --git a/samples/today/schema/TodaySchema.cpp b/samples/today/schema/TodaySchema.cpp index ef5a373e..994ea7d6 100644 --- a/samples/today/schema/TodaySchema.cpp +++ b/samples/today/schema/TodaySchema.cpp @@ -64,6 +64,22 @@ service::AwaitableResolver ModifiedResult::convert(service::Aw }); } +template <> +void ModifiedResult::validateScalar(const response::Value& value) +{ + if (!value.maybe_enum()) + { + throw service::schema_exception { { R"ex(not a valid TaskState value)ex" } }; + } + + const auto itr = std::find(s_namesTaskState.cbegin(), s_namesTaskState.cend(), value.get()); + + if (itr == s_namesTaskState.cend()) + { + throw service::schema_exception { { R"ex(not a valid TaskState value)ex" } }; + } +} + template <> today::CompleteTaskInput ModifiedArgument::convert(const response::Value& value) { diff --git a/samples/validation/schema/ValidationSchema.cpp b/samples/validation/schema/ValidationSchema.cpp index 317247ad..8245eead 100644 --- a/samples/validation/schema/ValidationSchema.cpp +++ b/samples/validation/schema/ValidationSchema.cpp @@ -63,6 +63,22 @@ service::AwaitableResolver ModifiedResult::convert(servi }); } +template <> +void ModifiedResult::validateScalar(const response::Value& value) +{ + if (!value.maybe_enum()) + { + throw service::schema_exception { { R"ex(not a valid DogCommand value)ex" } }; + } + + const auto itr = std::find(s_namesDogCommand.cbegin(), s_namesDogCommand.cend(), value.get()); + + if (itr == s_namesDogCommand.cend()) + { + throw service::schema_exception { { R"ex(not a valid DogCommand value)ex" } }; + } +} + static const std::array s_namesCatCommand = { R"gql(JUMP)gql"sv }; @@ -99,6 +115,22 @@ service::AwaitableResolver ModifiedResult::convert(servi }); } +template <> +void ModifiedResult::validateScalar(const response::Value& value) +{ + if (!value.maybe_enum()) + { + throw service::schema_exception { { R"ex(not a valid CatCommand value)ex" } }; + } + + const auto itr = std::find(s_namesCatCommand.cbegin(), s_namesCatCommand.cend(), value.get()); + + if (itr == s_namesCatCommand.cend()) + { + throw service::schema_exception { { R"ex(not a valid CatCommand value)ex" } }; + } +} + template <> validation::ComplexInput ModifiedArgument::convert(const response::Value& value) { diff --git a/src/GraphQLService.cpp b/src/GraphQLService.cpp index b877ab76..3e4b8051 100644 --- a/src/GraphQLService.cpp +++ b/src/GraphQLService.cpp @@ -716,6 +716,66 @@ AwaitableResolver ModifiedResult::convert( co_return std::move(document); } +template <> +void ModifiedResult::validateScalar(const response::Value& value) +{ + if (value.type() != response::Type::Int) + { + throw schema_exception { { R"ex(not a valid Int value)ex" } }; + } +} + +template <> +void ModifiedResult::validateScalar(const response::Value& value) +{ + if (value.type() != response::Type::Float) + { + throw schema_exception { { R"ex(not a valid Float value)ex" } }; + } +} + +template <> +void ModifiedResult::validateScalar(const response::Value& value) +{ + if (value.type() != response::Type::String) + { + throw schema_exception { { R"ex(not a valid String value)ex" } }; + } +} + +template <> +void ModifiedResult::validateScalar(const response::Value& value) +{ + if (value.type() != response::Type::Boolean) + { + throw schema_exception { { R"ex(not a valid Boolean value)ex" } }; + } +} + +template <> +void ModifiedResult::validateScalar(const response::Value& value) +{ + if (value.type() != response::Type::String) + { + throw schema_exception { { R"ex(not a valid String value)ex" } }; + } + + try + { + const auto result = value.get(); + } + catch (const std::logic_error& ex) + { + throw schema_exception { { ex.what() } }; + } +} + +template <> +void ModifiedResult::validateScalar(const response::Value&) +{ + // Any response::Value is valid for a custom scalar type. +} + // SelectionVisitor visits the AST and resolves a field or fragment, unless it's skipped by // a directive or type condition. class SelectionVisitor diff --git a/src/SchemaGenerator.cpp b/src/SchemaGenerator.cpp index f108d467..492a736c 100644 --- a/src/SchemaGenerator.cpp +++ b/src/SchemaGenerator.cpp @@ -481,6 +481,11 @@ GRAPHQLINTROSPECTION_EXPORT AwaitableResolver ModifiedResult<)cpp" AwaitableScalar<)cpp" << _loader.getSchemaNamespace() << R"cpp(::)cpp" << enumType.cppType << R"cpp(> result, ResolverParams params); +template <> +GRAPHQLINTROSPECTION_EXPORT void ModifiedResult<)cpp" + << _loader.getSchemaNamespace() << R"cpp(::)cpp" << enumType.cppType + << R"cpp(>::validateScalar( + const response::Value& value); )cpp"; } @@ -658,9 +663,9 @@ concept )cpp" << outputField.accessor headerFile << R"cpp() { - { )cpp" - << _loader.getOutputCppType(outputField) << R"cpp( { impl.)cpp" - << outputField.accessor << fieldName << R"cpp((std::move(params))cpp"; + { )cpp" << _loader.getOutputCppType(outputField) + << R"cpp( { impl.)cpp" << outputField.accessor << fieldName + << R"cpp((std::move(params))cpp"; if (!passedArguments.empty()) { @@ -681,9 +686,8 @@ concept )cpp" << outputField.accessor headerFile << R"cpp() { - { )cpp" - << _loader.getOutputCppType(outputField) << R"cpp( { impl.)cpp" - << outputField.accessor << fieldName << R"cpp(()cpp"; + { )cpp" << _loader.getOutputCppType(outputField) + << R"cpp( { impl.)cpp" << outputField.accessor << fieldName << R"cpp(()cpp"; if (!passedArguments.empty()) { @@ -779,9 +783,8 @@ void Generator::outputObjectDeclaration( fieldName[0] = static_cast(std::toupper(static_cast(fieldName[0]))); headerFile << R"cpp( - )cpp" - << _loader.getOutputCppType(outputField) << R"cpp( )cpp" << outputField.accessor - << fieldName << R"cpp(()cpp"; + )cpp" << _loader.getOutputCppType(outputField) + << R"cpp( )cpp" << outputField.accessor << fieldName << R"cpp(()cpp"; bool firstArgument = _loader.isIntrospection(); @@ -1033,9 +1036,8 @@ std::string Generator::getFieldDeclaration(const OutputField& outputField) const std::string fieldName { outputField.cppName }; fieldName[0] = static_cast(std::toupper(static_cast(fieldName[0]))); - output << R"cpp( virtual )cpp" - << _loader.getOutputCppType(outputField) << R"cpp( )cpp" << outputField.accessor - << fieldName << R"cpp(()cpp"; + output << R"cpp( virtual )cpp" << _loader.getOutputCppType(outputField) << R"cpp( )cpp" + << outputField.accessor << fieldName << R"cpp(()cpp"; bool firstArgument = _loader.isIntrospection(); @@ -1203,6 +1205,29 @@ service::AwaitableResolver ModifiedResult<)cpp" }); } +template <> +void ModifiedResult<)cpp" + << _loader.getSchemaNamespace() << R"cpp(::)cpp" << enumType.cppType + << R"cpp(>::validateScalar(const response::Value& value) +{ + if (!value.maybe_enum()) + { + throw service::schema_exception { { R"ex(not a valid )cpp" + << enumType.type << R"cpp( value)ex" } }; + } + + const auto itr = std::find(s_names)cpp" + << enumType.cppType << R"cpp(.cbegin(), s_names)cpp" << enumType.cppType + << R"cpp(.cend(), value.get()); + + if (itr == s_names)cpp" + << enumType.cppType << R"cpp(.cend()) + { + throw service::schema_exception { { R"ex(not a valid )cpp" + << enumType.type << R"cpp( value)ex" } }; + } +} + )cpp"; } diff --git a/src/introspection/IntrospectionSchema.cpp b/src/introspection/IntrospectionSchema.cpp index 366b62f0..6ea44bde 100644 --- a/src/introspection/IntrospectionSchema.cpp +++ b/src/introspection/IntrospectionSchema.cpp @@ -62,6 +62,22 @@ service::AwaitableResolver ModifiedResult::convert(serv }); } +template <> +void ModifiedResult::validateScalar(const response::Value& value) +{ + if (!value.maybe_enum()) + { + throw service::schema_exception { { R"ex(not a valid __TypeKind value)ex" } }; + } + + const auto itr = std::find(s_namesTypeKind.cbegin(), s_namesTypeKind.cend(), value.get()); + + if (itr == s_namesTypeKind.cend()) + { + throw service::schema_exception { { R"ex(not a valid __TypeKind value)ex" } }; + } +} + static const std::array s_namesDirectiveLocation = { R"gql(QUERY)gql"sv, R"gql(MUTATION)gql"sv, @@ -116,6 +132,22 @@ service::AwaitableResolver ModifiedResult::con }); } +template <> +void ModifiedResult::validateScalar(const response::Value& value) +{ + if (!value.maybe_enum()) + { + throw service::schema_exception { { R"ex(not a valid __DirectiveLocation value)ex" } }; + } + + const auto itr = std::find(s_namesDirectiveLocation.cbegin(), s_namesDirectiveLocation.cend(), value.get()); + + if (itr == s_namesDirectiveLocation.cend()) + { + throw service::schema_exception { { R"ex(not a valid __DirectiveLocation value)ex" } }; + } +} + } // namespace service namespace introspection { diff --git a/src/introspection/IntrospectionSchema.h b/src/introspection/IntrospectionSchema.h index 6c50cd2f..9507b218 100644 --- a/src/introspection/IntrospectionSchema.h +++ b/src/introspection/IntrospectionSchema.h @@ -108,11 +108,17 @@ template <> GRAPHQLINTROSPECTION_EXPORT AwaitableResolver ModifiedResult::convert( AwaitableScalar result, ResolverParams params); template <> +GRAPHQLINTROSPECTION_EXPORT void ModifiedResult::validateScalar( + const response::Value& value); +template <> GRAPHQLINTROSPECTION_EXPORT introspection::DirectiveLocation ModifiedArgument::convert( const response::Value& value); template <> GRAPHQLINTROSPECTION_EXPORT AwaitableResolver ModifiedResult::convert( AwaitableScalar result, ResolverParams params); +template <> +GRAPHQLINTROSPECTION_EXPORT void ModifiedResult::validateScalar( + const response::Value& value); #endif // GRAPHQL_DLLEXPORTS } // namespace service From 8c9f37251b7cd7fa6bcf8289f0f13339df03907e Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Tue, 14 Dec 2021 18:49:42 -0800 Subject: [PATCH 104/119] Only install new CMake files for install configs --- cmake/CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 18e37011..1db60cea 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -10,7 +10,11 @@ write_basic_package_version_file(${PROJECT_NAME}-config-version.cmake COMPATIBIL install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}-config.cmake ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake + DESTINATION ${GRAPHQL_INSTALL_CMAKE_DIR}/${PROJECT_NAME}) + +install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}-functions.cmake ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}-update-schema-files.cmake ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}-update-client-files.cmake + CONFIGURATIONS ${GRAPHQL_INSTALL_CONFIGURATIONS} DESTINATION ${GRAPHQL_INSTALL_CMAKE_DIR}/${PROJECT_NAME}) From b324eb417fe62c72d3bfadcb2fc2327364c91886 Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Tue, 14 Dec 2021 23:01:01 -0800 Subject: [PATCH 105/119] Output include statements for unions even if no interfaces --- src/SchemaGenerator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SchemaGenerator.cpp b/src/SchemaGenerator.cpp index 492a736c..580fe487 100644 --- a/src/SchemaGenerator.cpp +++ b/src/SchemaGenerator.cpp @@ -2874,7 +2874,7 @@ using namespace std::literals; if (!_loader.isIntrospection()) { - if (!objectType.interfaces.empty()) + if (!objectType.interfaces.empty() || !objectType.unions.empty()) { NamespaceScope implementsNamespace { headerFile, R"cpp(implements)cpp" }; From 29eeba41a7825e1caaba59dd19519c0c603b5073 Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Tue, 14 Dec 2021 23:17:57 -0800 Subject: [PATCH 106/119] Install Introspection.h under graphqlservice/internal/ --- src/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7e594f3e..abd456f6 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -452,6 +452,7 @@ install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/../include/graphqlservice/internal/Awaitable.h ${CMAKE_CURRENT_SOURCE_DIR}/../include/graphqlservice/internal/Base64.h ${CMAKE_CURRENT_SOURCE_DIR}/../include/graphqlservice/internal/Grammar.h + ${CMAKE_CURRENT_SOURCE_DIR}/../include/graphqlservice/internal/Introspection.h ${CMAKE_CURRENT_SOURCE_DIR}/../include/graphqlservice/internal/Schema.h ${CMAKE_CURRENT_SOURCE_DIR}/../include/graphqlservice/internal/SortedMap.h ${CMAKE_CURRENT_SOURCE_DIR}/../include/graphqlservice/internal/SyntaxTree.h From 7952633a48511d079942a33c6bbe7d50777731d0 Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Tue, 14 Dec 2021 23:49:43 -0800 Subject: [PATCH 107/119] Use a static_assert for the None modifier in ModifiedArgument too --- include/graphqlservice/GraphQLService.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/include/graphqlservice/GraphQLService.h b/include/graphqlservice/GraphQLService.h index ebd026a1..4c020298 100644 --- a/include/graphqlservice/GraphQLService.h +++ b/include/graphqlservice/GraphQLService.h @@ -663,9 +663,11 @@ struct ModifiedArgument // Peel off the none modifier. If it's included, it should always be last in the list. template - static typename std::enable_if_t - require(std::string_view name, const response::Value& arguments) + static typename std::enable_if_t require( + std::string_view name, const response::Value& arguments) { + static_assert(sizeof...(Other) == 0, "None modifier should always be last"); + // Just call through to the non-template method without the modifiers. return require(name, arguments); } From 6c99aeff3d47a7b121a0008d64f692dc9f3c4fcf Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Wed, 15 Dec 2021 13:21:07 -0800 Subject: [PATCH 108/119] Update related projects --- README.md | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index d0e95987..532fd9f9 100644 --- a/README.md +++ b/README.md @@ -36,16 +36,38 @@ any variables to the service and parse its responses into a `graphql::response:: ## Related projects -I created a couple of sample projects that work with the latest version to demonstrate integrating the -[schema.today.graphql](./samples/schema.today.graphql) service into an Electron app. They're available under -my personal account, feel free to use either or both of these as a starting point to integrate your own generated -service with Node or Electron. PRs with links to your own samples are always welcome. +The most complete examples I've built are related to [GqlMAPI](https://github.com/microsoft/gqlmapi): + +- [eMAPI](https://github.com/microsoft/eMAPI): Windows-only Electron app which lets you access +the [MAPI](https://en.wikipedia.org/wiki/MAPI) interface used by +[Microsoft Outlook](https://en.wikipedia.org/wiki/Microsoft_Outlook). Its goal is to be a spiritual +successor to a debugging and diagnostic tool called +[MFCMAPI](https://github.com/stephenegriffin/mfcmapi). +- [electron-gqlmapi](https://github.com/microsoft/electron-gqlmapi): Native module for Electron +which hosts `GqlMAPI` in `eMAPI`. It includes JS libraries for calling the native module across the +Electron IPC channel. +- [Tauri-GqlMAPI](https://github.com/wravery/tauri-gqlmapi): Reimplementation of `eMAPI` built +in [Rust](https://www.rust-lang.org/) and [TypeScript](https://www.typescriptlang.org/) on top of +[Tauri](https://tauri.studio/en). +- [gqlmapi-rs](https://github.com/wravery/gqlmapi-rs): `Rust` crate I built to expose safe +bindings for `GqlMAPI`. It is loosely based on `electron-gqlmapi`, and it is used by +`Tauri-GqlMAPI`. + +I created a couple of sample projects that worked with earlier versions of `cppgraphqlgen` to +demonstrate integrating the [schema.today.graphql](./samples/schema.today.graphql) service into an +Electron app. They're still available under my personal account, but I haven't updated them +recently: - [electron-cppgraphql](https://github.com/wravery/electron-cppgraphql): Node Native Module which compiles -against the version of the Node headers included in Electron. +against the version of the Node headers included in Electron. This was the starting point for +`electron-gqlmapi`, and it is still useful as a sample because it does not depend on a platform-specific +API like `MAPI`, so it works cross-platform. - [cppgraphiql](https://github.com/wravery/cppgraphiql): Electron app which consumes `electron-cppgraphql` and exposes an instance of [GraphiQL](https://github.com/graphql/graphiql) on top of it. +Feel free to use either or both of these as a starting point to integrate your own generated +service with `Node`, `Electron`, or `Tauri`. PRs with links to your own samples are always welcome. + ## Installation process I've tested this on Windows with both Visual Studio 2017 and 2019, and on Linux using an Ubuntu 20.04 LTS instance running in From f759e0e6f148dcde7100c1cd023668d746f6d9b0 Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Wed, 15 Dec 2021 16:49:56 -0800 Subject: [PATCH 109/119] Remove std::filesystem fallbacks from early versions of C++17 --- cmake/test_filesystem.cpp | 19 ++++++++++++ cmake/test_filesystem.cpp.in | 22 -------------- src/CMakeLists.txt | 58 +++++++----------------------------- src/ClientGenerator.cpp | 34 ++++++--------------- src/SchemaGenerator.cpp | 54 +++++++++++++-------------------- 5 files changed, 60 insertions(+), 127 deletions(-) create mode 100644 cmake/test_filesystem.cpp delete mode 100644 cmake/test_filesystem.cpp.in diff --git a/cmake/test_filesystem.cpp b/cmake/test_filesystem.cpp new file mode 100644 index 00000000..240e7d6b --- /dev/null +++ b/cmake/test_filesystem.cpp @@ -0,0 +1,19 @@ +// This is a dummy program that just needs to compile and link to tell us if +// the C++17 std::filesystem API requires any additional libraries. + +#include + +int main() +{ + try + { + throw std::filesystem::filesystem_error("instantiate one to make sure it links", + std::make_error_code(std::errc::function_not_supported)); + } + catch (const std::filesystem::filesystem_error& error) + { + return -1; + } + + return !std::filesystem::temp_directory_path().is_absolute(); +} \ No newline at end of file diff --git a/cmake/test_filesystem.cpp.in b/cmake/test_filesystem.cpp.in deleted file mode 100644 index e29d850d..00000000 --- a/cmake/test_filesystem.cpp.in +++ /dev/null @@ -1,22 +0,0 @@ -// This is a dummy program that just needs to compile and link to tell us if -// the C++17 std::filesystem API is available. Use CMake's configure_file -// command to replace the FILESYSTEM_HEADER and FILESYSTEM_NAMESPACE tokens -// for each combination of headers and namespaces which we want to pass to the -// CMake try_compile command. - -#include <@FILESYSTEM_HEADER@> - -int main() -{ - try - { - throw @FILESYSTEM_NAMESPACE@::filesystem_error("instantiate one to make sure it links", - std::make_error_code(std::errc::function_not_supported)); - } - catch (const @FILESYSTEM_NAMESPACE@::filesystem_error& error) - { - return -1; - } - - return !@FILESYSTEM_NAMESPACE@::temp_directory_path().is_absolute(); -} \ No newline at end of file diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index abd456f6..3a798528 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -245,18 +245,12 @@ endif() # Common schemagen and clientgen filesystem and Boost dependencies if(GRAPHQL_BUILD_SCHEMAGEN OR GRAPHQL_BUILD_CLIENTGEN) - set(BOOST_COMPONENTS program_options) - set(BOOST_LIBRARIES Boost::program_options) - # Try compiling a test program with std::filesystem or one of its alternatives. - function(check_filesystem_impl FILESYSTEM_HEADER FILESYSTEM_NAMESPACE OPTIONAL_LIBS OUT_RESULT) - set(TEST_FILE "test_${OUT_RESULT}.cpp") - configure_file(${CMAKE_CURRENT_SOURCE_DIR}/../cmake/test_filesystem.cpp.in ${TEST_FILE} @ONLY) - + function(check_filesystem_impl OPTIONAL_LIBS) try_compile(TEST_RESULT ${CMAKE_CURRENT_BINARY_DIR} - ${CMAKE_CURRENT_BINARY_DIR}/${TEST_FILE} - CXX_STANDARD 17) + ${CMAKE_CURRENT_SOURCE_DIR}/../cmake/test_filesystem.cpp + CXX_STANDARD 20) if(NOT TEST_RESULT) # Retry with each of the optional libraries. @@ -265,7 +259,7 @@ if(GRAPHQL_BUILD_SCHEMAGEN OR GRAPHQL_BUILD_CLIENTGEN) ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/${TEST_FILE} LINK_LIBRARIES ${OPTIONAL_LIB} - CXX_STANDARD 17) + CXX_STANDARD 20) if(TEST_RESULT) # Looks like the optional library was required, go ahead and add it to the link options. @@ -279,49 +273,19 @@ if(GRAPHQL_BUILD_SCHEMAGEN OR GRAPHQL_BUILD_CLIENTGEN) endif() endforeach(OPTIONAL_LIB) endif() - - set(${OUT_RESULT} ${TEST_RESULT} PARENT_SCOPE) endfunction(check_filesystem_impl) - # Try compiling a minimal program with each header/namespace, in order of preference: - # C++17: #include // std::filesystem - # Experimental C++17: #include // std::experimental::filesystem - # Boost.Filesystem: #include // boost::filesystem - check_filesystem_impl("filesystem" "std::filesystem" "stdc++fs;c++fs" STD_FILESYTEM) - if(STD_FILESYTEM) - if(GRAPHQL_BUILD_SCHEMAGEN) - target_compile_definitions(schemagen PRIVATE USE_STD_FILESYSTEM) - endif() - if(GRAPHQL_BUILD_CLIENTGEN) - target_compile_definitions(clientgen PRIVATE USE_STD_FILESYSTEM) - endif() - else() - check_filesystem_impl("experimental/filesystem" "std::experimental::filesystem" "stdc++fs;c++fs" STD_EXPERIMENTAL_FILESYTEM) - if(STD_EXPERIMENTAL_FILESYTEM) - if(GRAPHQL_BUILD_SCHEMAGEN) - target_compile_definitions(schemagen PRIVATE USE_STD_EXPERIMENTAL_FILESYSTEM) - endif() - if(GRAPHQL_BUILD_CLIENTGEN) - target_compile_definitions(clientgen PRIVATE USE_STD_EXPERIMENTAL_FILESYSTEM) - endif() - else() - set(BOOST_COMPONENTS ${BOOST_COMPONENTS} filesystem) - set(BOOST_LIBRARIES ${BOOST_LIBRARIES} Boost::filesystem) - if(GRAPHQL_BUILD_SCHEMAGEN) - target_compile_definitions(schemagen PRIVATE USE_BOOST_FILESYSTEM) - endif() - if(GRAPHQL_BUILD_CLIENTGEN) - target_compile_definitions(clientgen PRIVATE USE_BOOST_FILESYSTEM) - endif() - endif() - endif() + # Try compiling a minimal program without any extra libraries, then with each optional library until it succeeded: + # stdc++fs + # c++fs + check_filesystem_impl("stdc++fs;c++fs" STD_FILESYTEM) - find_package(Boost REQUIRED COMPONENTS ${BOOST_COMPONENTS}) + find_package(Boost REQUIRED COMPONENTS program_options) if(GRAPHQL_BUILD_SCHEMAGEN) - target_link_libraries(schemagen PRIVATE ${BOOST_LIBRARIES}) + target_link_libraries(schemagen PRIVATE Boost::program_options) endif() if(GRAPHQL_BUILD_CLIENTGEN) - target_link_libraries(clientgen PRIVATE ${BOOST_LIBRARIES}) + target_link_libraries(clientgen PRIVATE Boost::program_options) endif() endif() diff --git a/src/ClientGenerator.cpp b/src/ClientGenerator.cpp index 1d099f55..14b7d9a6 100644 --- a/src/ClientGenerator.cpp +++ b/src/ClientGenerator.cpp @@ -20,26 +20,8 @@ #pragma warning(pop) #endif // _MSC_VER -// clang-format off -#ifdef USE_STD_FILESYSTEM - #include - namespace fs = std::filesystem; -#else - #ifdef USE_STD_EXPERIMENTAL_FILESYSTEM - #include - namespace fs = std::experimental::filesystem; - #else - #ifdef USE_BOOST_FILESYSTEM - #include - namespace fs = boost::filesystem; - #else - #error "No std::filesystem implementation defined" - #endif - #endif -#endif -// clang-format on - #include +#include #include #include #include @@ -66,7 +48,7 @@ std::string Generator::getHeaderDir() const noexcept { if (!_options.paths.headerPath.empty()) { - return fs::path { _options.paths.headerPath }.string(); + return std::filesystem::path { _options.paths.headerPath }.string(); } else { @@ -78,7 +60,7 @@ std::string Generator::getSourceDir() const noexcept { if (!_options.paths.sourcePath.empty()) { - return fs::path(_options.paths.sourcePath).string(); + return std::filesystem::path(_options.paths.sourcePath).string(); } else { @@ -88,7 +70,7 @@ std::string Generator::getSourceDir() const noexcept std::string Generator::getHeaderPath() const noexcept { - fs::path fullPath { _headerDir }; + std::filesystem::path fullPath { _headerDir }; fullPath /= (std::string { _schemaLoader.getFilenamePrefix() } + "Client.h"); @@ -97,7 +79,7 @@ std::string Generator::getHeaderPath() const noexcept std::string Generator::getSourcePath() const noexcept { - fs::path fullPath { _sourceDir }; + std::filesystem::path fullPath { _sourceDir }; fullPath /= (std::string { _schemaLoader.getFilenamePrefix() } + "Client.cpp"); @@ -188,7 +170,8 @@ std::vector Generator::Build() const noexcept bool Generator::outputHeader() const noexcept { std::ofstream headerFile(_headerPath, std::ios_base::trunc); - IncludeGuardScope includeGuard { headerFile, fs::path(_headerPath).filename().string() }; + IncludeGuardScope includeGuard { headerFile, + std::filesystem::path(_headerPath).filename().string() }; headerFile << R"cpp(#include "graphqlservice/GraphQLClient.h" #include "graphqlservice/GraphQLParse.h" @@ -223,7 +206,8 @@ static_assert(graphql::internal::MinorVersion == )cpp" { pendingSeparator.reset(); - headerFile << R"cpp(enum class )cpp" << _schemaLoader.getCppType(enumType->name()) << R"cpp( + headerFile << R"cpp(enum class )cpp" << _schemaLoader.getCppType(enumType->name()) + << R"cpp( { )cpp"; for (const auto& enumValue : enumType->enumValues()) diff --git a/src/SchemaGenerator.cpp b/src/SchemaGenerator.cpp index 580fe487..3ff453f0 100644 --- a/src/SchemaGenerator.cpp +++ b/src/SchemaGenerator.cpp @@ -16,26 +16,8 @@ #pragma warning(pop) #endif // _MSC_VER -// clang-format off -#ifdef USE_STD_FILESYSTEM - #include - namespace fs = std::filesystem; -#else - #ifdef USE_STD_EXPERIMENTAL_FILESYSTEM - #include - namespace fs = std::experimental::filesystem; - #else - #ifdef USE_BOOST_FILESYSTEM - #include - namespace fs = boost::filesystem; - #else - #error "No std::filesystem implementation defined" - #endif - #endif -#endif -// clang-format on - #include +#include #include #include #include @@ -61,7 +43,7 @@ std::string Generator::getHeaderDir() const noexcept { if (!_options.paths.headerPath.empty()) { - return fs::path { _options.paths.headerPath }.string(); + return std::filesystem::path { _options.paths.headerPath }.string(); } else { @@ -73,7 +55,7 @@ std::string Generator::getSourceDir() const noexcept { if (!_options.paths.sourcePath.empty()) { - return fs::path(_options.paths.sourcePath).string(); + return std::filesystem::path(_options.paths.sourcePath).string(); } else { @@ -83,7 +65,7 @@ std::string Generator::getSourceDir() const noexcept std::string Generator::getHeaderPath() const noexcept { - fs::path fullPath { _headerDir }; + std::filesystem::path fullPath { _headerDir }; fullPath /= (std::string { _loader.getFilenamePrefix() } + "Schema.h"); return fullPath.string(); @@ -91,7 +73,7 @@ std::string Generator::getHeaderPath() const noexcept std::string Generator::getSourcePath() const noexcept { - fs::path fullPath { _sourceDir }; + std::filesystem::path fullPath { _sourceDir }; fullPath /= (std::string { _loader.getFilenamePrefix() } + "Schema.cpp"); return fullPath.string(); @@ -124,7 +106,8 @@ std::vector Generator::Build() const noexcept bool Generator::outputHeader() const noexcept { std::ofstream headerFile(_headerPath, std::ios_base::trunc); - IncludeGuardScope includeGuard { headerFile, fs::path(_headerPath).filename().string() }; + IncludeGuardScope includeGuard { headerFile, + std::filesystem::path(_headerPath).filename().string() }; headerFile << R"cpp(#include "graphqlservice/internal/Schema.h" @@ -977,7 +960,8 @@ void Generator::outputObjectDeclaration( for (auto unionName : objectType.unions) { - headerFile << R"cpp( friend )cpp" << _loader.getSafeCppName(unionName) << R"cpp(; + headerFile << R"cpp( friend )cpp" << _loader.getSafeCppName(unionName) + << R"cpp(; )cpp"; } @@ -1758,7 +1742,8 @@ Operations::Operations()cpp"; )cpp"; } sourceFile << R"cpp(}, )cpp" - << (directive.isRepeatable ? R"cpp(true)cpp" : R"cpp(false)cpp") << R"cpp()); + << (directive.isRepeatable ? R"cpp(true)cpp" : R"cpp(false)cpp") + << R"cpp()); )cpp"; } } @@ -2655,8 +2640,8 @@ std::string Generator::getIntrospectionType( std::vector Generator::outputSeparateFiles() const noexcept { - const fs::path headerDir(_headerDir); - const fs::path sourceDir(_sourceDir); + const std::filesystem::path headerDir(_headerDir); + const std::filesystem::path sourceDir(_sourceDir); std::vector files; std::string_view queryType; @@ -2676,7 +2661,8 @@ std::vector Generator::outputSeparateFiles() const noexcept std::ofstream headerFile(headerPath, std::ios_base::trunc); IncludeGuardScope includeGuard { headerFile, headerFilename }; - headerFile << R"cpp(#include ")cpp" << fs::path(_headerPath).filename().string() << R"cpp(" + headerFile << R"cpp(#include ")cpp" + << std::filesystem::path(_headerPath).filename().string() << R"cpp(" )cpp"; @@ -2766,7 +2752,8 @@ using namespace std::literals; std::ofstream headerFile(headerPath, std::ios_base::trunc); IncludeGuardScope includeGuard { headerFile, headerFilename }; - headerFile << R"cpp(#include ")cpp" << fs::path(_headerPath).filename().string() << R"cpp(" + headerFile << R"cpp(#include ")cpp" + << std::filesystem::path(_headerPath).filename().string() << R"cpp(" )cpp"; @@ -2856,7 +2843,8 @@ using namespace std::literals; std::ofstream headerFile(headerPath, std::ios_base::trunc); IncludeGuardScope includeGuard { headerFile, headerFilename }; - headerFile << R"cpp(#include ")cpp" << fs::path(_headerPath).filename().string() << R"cpp(" + headerFile << R"cpp(#include ")cpp" + << std::filesystem::path(_headerPath).filename().string() << R"cpp(" )cpp"; @@ -3053,8 +3041,8 @@ int main(int argc, char** argv) po::value(&headerDir), "Target path for the Schema.h header file")("stubs", po::bool_switch(&stubs), - "Unimplemented fields throw runtime exceptions instead of compiler errors")( - "no-introspection", + "Unimplemented fields throw runtime exceptions instead of compiler errors")("no-" + "introspection", po::bool_switch(&noIntrospection), "Do not generate support for Introspection"); positional.add("schema", 1).add("prefix", 1).add("namespace", 1); From 9d3462ac4a3bac623b079c218fc93fc0664988aa Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Wed, 15 Dec 2021 16:54:48 -0800 Subject: [PATCH 110/119] Finish a pass through the root README --- README.md | 119 +++++++++++++++++++++++++++++++++++------------------- 1 file changed, 77 insertions(+), 42 deletions(-) diff --git a/README.md b/README.md index 532fd9f9..e6aeb5fc 100644 --- a/README.md +++ b/README.md @@ -23,8 +23,7 @@ service, you can use the same GraphQL client code to access your native data sou service online. You might even be able to share some more of that code between a progressive web app and your native/hybrid app. -If what you're after is a way to consume a GraphQL service from C++, as of -[v3.6.0](https://github.com/microsoft/cppgraphqlgen/releases/tag/v3.6.0) this project also includes +If what you're after is a way to consume a GraphQL service from C++, this project also includes a `graphqlclient` library and a `clientgen` utility to generate types matching a GraphQL request document, its variables, and all of the serialization code you need to talk to a `graphqlservice` implementation. If you want to consume another service, you will need access to the schema definition @@ -32,12 +31,9 @@ implementation. If you want to consume another service, you will need access to any variables to the service and parse its responses into a `graphql::response::Value` (e.g. with the `graphqljson` library) in your code. -# Getting Started - ## Related projects The most complete examples I've built are related to [GqlMAPI](https://github.com/microsoft/gqlmapi): - - [eMAPI](https://github.com/microsoft/eMAPI): Windows-only Electron app which lets you access the [MAPI](https://en.wikipedia.org/wiki/MAPI) interface used by [Microsoft Outlook](https://en.wikipedia.org/wiki/Microsoft_Outlook). Its goal is to be a spiritual @@ -57,7 +53,6 @@ I created a couple of sample projects that worked with earlier versions of `cppg demonstrate integrating the [schema.today.graphql](./samples/schema.today.graphql) service into an Electron app. They're still available under my personal account, but I haven't updated them recently: - - [electron-cppgraphql](https://github.com/wravery/electron-cppgraphql): Node Native Module which compiles against the version of the Node headers included in Electron. This was the starting point for `electron-gqlmapi`, and it is still useful as a sample because it does not depend on a platform-specific @@ -68,39 +63,53 @@ exposes an instance of [GraphiQL](https://github.com/graphql/graphiql) on top of Feel free to use either or both of these as a starting point to integrate your own generated service with `Node`, `Electron`, or `Tauri`. PRs with links to your own samples are always welcome. -## Installation process - -I've tested this on Windows with both Visual Studio 2017 and 2019, and on Linux using an Ubuntu 20.04 LTS instance running in -WSL with both gcc 9.3.0 and clang 10.0.0. The key compiler requirement is support for C++17 including std::filesystem, earlier -versions of gcc and clang may not have enough support for that. +# Getting Started -The easiest way to get all of these and to build `cppgraphqlgen` in one step is to use -[microsoft/vcpkg](https://github.com/microsoft/vcpkg). To install with vcpkg, make sure you've pulled the latest version -and then run `vcpkg install cppgraphqlgen` (or `cppgraphqlgen:x64-windows`, `cppgraphqlgen:x86-windows-static`, etc. -depending on your platform). To install just the dependencies and work in a clone of this repo, you'll need some subset -of `vcpkg install pegtl boost-program-options rapidjson gtest`. It works for Windows, Linux, and Mac, -but if you want to try building for another platform (e.g. Android or iOS), you'll need to do more of this manually. +## Installation process -Manual installation will work best if you clone the GitHub repos for each of the dependencies and follow the installation -instructions for each project. You might also be able to find pre-built packages depending on your platform, but the -versions need to match. +The minimum OS and toolchain versions I've tested with this version of `cppgraphqlgen` are: +- Microsoft Windows: Visual Studio 2019 +- Linux: Ubuntu 20.04 LTS with gcc 10.3.0 +- macOS: 11 (Big Sur) with AppleClang 13.0.0. + +The key compiler requirement is support for C++20 including coroutines and concepts. Some of these compiler +versions still treat coroutine support as experimental, and the CMake configuration can auto-detect that, +but earlier versions of gcc and clang do not seem to have enough support for C++20. + +The easiest way to build and install `cppgraphqlgen` is to use [microsoft/vcpkg](https://github.com/microsoft/vcpkg). +See the [Getting Started](https://github.com/microsoft/vcpkg#getting-started) section of the `vcpkg` README +for details. Once you have that configured, run `vcpkg install cppgraphqlgen` (or `cppgraphqlgen:x64-windows`, +`cppgraphqlgen:x86-windows-static`, etc. depending on your platform). That will build and install all of the +dependencies for `cppgraphqlgen`, and then build `cppgraphqlgen` itself without any other setup. The `cppgraphqlgen` +package (and its dependencies) are advertised to the `CMake` `find_package` function through the +`-DCMAKE_TOOLCHAIN_FILE=<...>/scripts/buildsystems/vcpkg.cmake` parameter/variable. There are more details about +this in the `vcpkg` documentation. + +If you want to build `cppgraphqlgen` yourself, you can do that with `CMake` from a clone or archive of this repo. +See the [Build and Test](#build-and-test) section below for instructions. You will need to install the dependencies +first where `find_package` can find them. If `vcpkg` works otherwise, you can do that with `vcpkg install pegtl +boost-program-options rapidjson gtest`. Some of these are optional, if for example you do not build the tests. If +`vcpkg` does not work, please see the documentation for each of those dependencies, as well as your +platform/toolchain documentation for perferred installation mechanisms. You may need to build some or all of them +separately from source. ## Software dependencies The build system for this project uses [CMake](http://www.cmake.org/). You will need to have CMake (at least version -3.8.0) installed, and the library dependencies need to be where CMake can find them. Otherwise you need to disable the +3.15.0) installed, and the library dependencies need to be where CMake can find them. Otherwise you need to disable the options which depend on them. -I also picked a few other projects as dependencies, most of which are optional when consuming this project. If you -redistribute any binaries built from these libraries, you should still follow the terms of their individual licenses. As -of this writing, this library and all of its redistributable dependencies are available under the MIT license, which -means you need to include an acknowledgement along with the license text. +Besides the MIT license for this project, if you redistribute any source code or binaries built from these library +dependencies, you should still follow the terms of their individual licenses. As of this writing, this library and +all of its dependencies are available under either the MIT License or the Boost Software License (BSL). Both +licenses roughly mean that you may redistribute them freely as long as you include an acknowledgement along with +the license text. Please see the license or copyright notice which comes with each project for more details. ### graphqlpeg -- GraphQL parsing: [Parsing Expression Grammar Template Library (PEGTL)](https://github.com/taocpp/PEGTL) release 3.2.0, +- GraphQL parsing: [Parsing Expression Grammar Template Library (PEGTL)](https://github.com/taocpp/PEGTL) release 3.2.2, which is part of [The Art of C++](https://taocpp.github.io/) library collection. I've added this as a sub-module, so you -do not need to install this separately. If you already have 3.2.0 installed where CMake can find it, it will use that +do not need to install this separately. If you already have 3.2.2 installed where CMake can find it, it will use that instead of the sub-module and avoid installing another copy of PEGTL. ### graphqlservice @@ -179,7 +188,7 @@ The generated code depends on the `graphqlclient` library for serialization of b code, you'll also need to link `graphqlclient`, `graphqlpeg` for the pre-parsed, pre-validated request AST, and `graphqlresponse` for the `graphql::response::Value` implementation. -Sample output for `clientgen` is in the [samples/client](samples/client) directory, and each sample is consumed by +Sample output for `clientgen` is in the sub-directories of [samples/client](samples/client), and each sample is consumed by a unit test in [test/ClientTests.cpp](test/ClientTests.cpp). ### tests (`GRAPHQL_BUILD_TESTS=ON`) @@ -191,9 +200,21 @@ configuration. ## API references See [GraphQLService.h](include/graphqlservice/GraphQLService.h) for the base types implemented in -the `graphql::service` namespace. Take a look at [TodayMock.h](samples/today/TodayMock.h) and -[TodayMock.cpp](samples/today/TodayMock.cpp) to see a sample implementation of a custom schema defined -in [schema.today.graphql](samples/schema.today.graphql) for testing purposes. +the `graphql::service` namespace. + +Take a look at the [samples/learn](samples/learn) directory, starting with +[StarWarsData.cpp](samples/learn/StarWarsData.cpp) to see a sample implementation of a custom schema defined in +[schema.learn.graphql](samples/learn/schema/schema.learn.graphql). This is the same schema and sample data used in the +GraphQL tutorial on https://graphql.org/learn/. This directory builds an interactive command line application which +can execute query and mutation operations against the sample data in memory. + +There are several helper functions for `CMake` declared in +[cmake/cppgraphqlgen-functions.cmake](cmake/cppgraphqlgen-functions.cmake), which is automatically included if you use +`find_package(cppgraphqlgen)` in your own `CMake` project. See +[samples/learn/schema/CMakeLists.txt](samples/learn/schema/CMakeLists.txt) and +[samples/learn/CMakeLists.txt](samples/learn/CMakeLists.txt), or the `CMakeLists.txt` files in some of the +other samples sub-directories for examples of how to use them to automatically rerun the code generators and update +the files in your source directory. ### Additional Documentation @@ -209,14 +230,28 @@ There are some more targeted documents in the [doc](./doc) directory: ### Samples -All of the generated files are in the [samples](samples/) directory. There are two different versions of -the generated code, one which creates a single pair of files (`samples/unified/`), and one which uses the -`--separate-files` flag with `schemagen` to generate individual header and source files (`samples/separate/`) -for each of the object types which need to be implemeneted. The only difference between -[TodayMock.h](samples/today/TodayMock.h) with and without `IMPL_SEPARATE_TODAY` defined should be that the -`--separate-files` option generates a [TodayObjects.h](samples/separate/TodayObjects.h) convenience header -which includes all of the inidividual object header along with the rest of the schema in -[TodaySchema.h](samples/separate/TodaySchema.h). +All of the samples are under [samples](samples/), with nested sub-directories for generated files: +- [samples/today](samples/today/): There are two different samples generated from +[schema.today.graphql](samples/today/schema.today.graphql) in this directory. The default +[schema](samples/today/schema/) target includes Introspection support (which is the default), while the +[nointrospection](samples/today/nointrospection/) target demonstrates how to disable Introspection support +with the `schemagen --no-introspection` parameter. The mock implementation of the service for both schemas is in +[samples/today/TodayMock.h](samples/today/TodayMock.h) and [samples/today/TodayMock.cpp](samples/today/TodayMock.cpp). +It builds an interactive `sample`/`sample_nointrospection` and `benchmark`/`benchmark_nointrospection` target for +each version, and it uses each of them in several unit tests. +- [samples/client](samples/client/): Several sample queries built with `clientgen` against the +[schema.today.graphql](samples/today/schema.today.graphql) schema shared with [samples/today](samples/today/). It +includes a `client_benchmark` executable for comparison with benchmark executables using the same hardcoded query +in [samples/today/]. The benchmark links with the default [schema](samples/today/schema/) target in +[samples/today](samples/today/) to handle the benchmark query. +- [samples/learn](samples/learn/): Simpler standalone which builds a `learn_star_wars` executable that follows +the tutorial examples on https://graphql.org/learn/. +- [samples/validation](samples/validation/): This schema is based on the examples and counter-examples from the +[Validation](https://spec.graphql.org/October2021/#sec-Validation) section of the October 2021 GraphQL spec. There +is no implementation of this schema, it relies entirely generated stubs (created with `schemagen --stubs`) to build +successfully without defining more than placeholder objects fo the Query, Mutation, and Subscription operations in +[samples/validation/ValidationMock.h](samples/validation/ValidationMock.h). It is used to test the validation logic +with every example or counter-example in the spec in [test/ValidationTests.cpp](test/ValidationTests.cpp). # Build and Test @@ -233,7 +268,7 @@ can run all of them from there. Your experience will vary depending on your build toolchain. The same instructions should work for any platform that CMake supports. These basic steps will build and run the tests. You can add options to build in another target directory, -change the config from `Debug` (default) to `Release`, use another build tool like `Ninja`, etc. If you are using vcpkg +change the config from `Debug` (default) to `Release`, use another build tool like `Ninja`, etc. If you are using `vcpkg` to install the dependencies, remember to specify the `-DCMAKE_TOOLCHAIN_FILE=...` option when you run the initial build configuration. @@ -248,8 +283,8 @@ You can then optionally install the public outputs by configuring it with `Relea ## Interactive tests -If you want to try an interactive version, you can run `samples/sample` and paste in queries against -the same mock service or load a query from a file on the command line. +If you want to try an interactive version, you can run `samples/today/sample` or `samples/today/sample_nointrospection` +and paste in queries against the same mock service or load a query from a file on the command line. ## Reporting Security Issues From af152e223d077d97595ad515310c996b5bded629 Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Wed, 15 Dec 2021 16:58:39 -0800 Subject: [PATCH 111/119] Document specifiedBy directive handling --- doc/directives.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/doc/directives.md b/doc/directives.md index cc13f849..faa67a9b 100644 --- a/doc/directives.md +++ b/doc/directives.md @@ -2,7 +2,7 @@ Directives in GraphQL are extensible annotations which alter the runtime evaluation of a query or which add information to the `schema` definition. -They always begin with an `@`. There are three built-in directives which this +They always begin with an `@`. There are four built-in directives which this library automatically handles: 1. `@include(if: Boolean!)`: Only resolve this field and include it in the @@ -11,9 +11,11 @@ results if the `if` argument evaluates to `true`. results if the `if` argument evaluates to `false`. 3. `@deprecated(reason: String)`: Mark the field or enum value as deprecated through introspection with the specified `reason` string. +4. `@specifiedBy(url: String!)`: Mark the custom scalar type through +introspection as specified by a human readable page at the specified URL. The `schema` can also define custom `directives` which are valid on different elements of the `query`. The library does not handle them automatically, but it -will pass them to the `getField` implementations through the +will pass them to the `getField` implementations through the optional `graphql::service::FieldParams` struct (see [fieldparams.md](fieldparams.md) for more information). \ No newline at end of file From d62207e4e38e86de6fcb0cc435393842a7905f38 Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Wed, 15 Dec 2021 17:31:44 -0800 Subject: [PATCH 112/119] Update documentation for service::FieldParams --- doc/fieldparams.md | 166 +++++++++++++++++++++++++++++++++------------ 1 file changed, 124 insertions(+), 42 deletions(-) diff --git a/doc/fieldparams.md b/doc/fieldparams.md index 8d33d6c4..53a2b1ec 100644 --- a/doc/fieldparams.md +++ b/doc/fieldparams.md @@ -7,31 +7,18 @@ shared state or `directives` from the `query`, so the `resolveField` method also packs that information into a `graphql::service::FieldParams` struct and passes it to every `getField` method as the first parameter. +This parameter is optional. The type-erased implementation of `graphql::service::Object` +for each `Object` type in the schema declares a pair of `methods::ObjectHas::getFieldWithParams` +and `methods::ObjectHas::getField` concepts for each field getter. If the implementation +type supports passing the `graphql::service::FieldParams` struct as the first parameter, +the type-erased `object::Object` invokes the `getFieldWithParams` version, otherwise it +drops the parameter and calls the `getField` version with whatever other field +arguments the schema specified. + ## Details of Field Parameters The `graphql::service::FieldParams` struct is declared in [GraphQLService.h](../include/graphqlservice/GraphQLService.h): ```cpp -// Resolvers may be called in multiple different Operation contexts. -enum class ResolverContext -{ - // Resolving a Query operation. - Query, - - // Resolving a Mutation operation. - Mutation, - - // Adding a Subscription. If you need to prepare to send events for this Subsciption - // (e.g. registering an event sink of your own), this is a chance to do that. - NotifySubscribe, - - // Resolving a Subscription event. - Subscription, - - // Removing a Subscription. If there are no more Subscriptions registered this is an - // opportunity to release resources which are no longer needed. - NotifyUnsubscribe, -}; - // Pass a common bundle of parameters to all of the generated Object::getField accessors in a // SelectionSet struct SelectionSetParams @@ -42,39 +29,61 @@ struct SelectionSetParams // The lifetime of each of these borrowed references is guaranteed until the future returned // by the accessor is resolved or destroyed. They are owned by the OperationData shared pointer. const std::shared_ptr& state; - const response::Value& operationDirectives; - const response::Value& fragmentDefinitionDirectives; + const Directives& operationDirectives; + const std::shared_ptr fragmentDefinitionDirectives; // Fragment directives are shared for all fields in that fragment, but they aren't kept alive // after the call to the last accessor in the fragment. If you need to keep them alive longer, - // you'll need to explicitly copy them into other instances of response::Value. - const response::Value& fragmentSpreadDirectives; - const response::Value& inlineFragmentDirectives; + // you'll need to explicitly copy them into other instances of Directives. + const std::shared_ptr fragmentSpreadDirectives; + const std::shared_ptr inlineFragmentDirectives; // Field error path to this selection set. std::optional errorPath; // Async launch policy for sub-field resolvers. - const std::launch launch = std::launch::deferred; + const await_async launch {}; }; // Pass a common bundle of parameters to all of the generated Object::getField accessors. struct FieldParams : SelectionSetParams { GRAPHQLSERVICE_EXPORT explicit FieldParams( - SelectionSetParams&& selectionSetParams, response::Value&& directives); + SelectionSetParams&& selectionSetParams, Directives directives); // Each field owns its own field-specific directives. Once the accessor returns it will be // destroyed, but you can move it into another instance of response::Value to keep it alive // longer. - response::Value fieldDirectives; + Directives fieldDirectives; }; ``` ### Resolver Context The `SelectionSetParams::resolverContext` enum member informs the `getField` -accessors about what type of operation is being resolved. +accessors about what type of operation is being resolved: +```cpp +// Resolvers may be called in multiple different Operation contexts. +enum class ResolverContext +{ + // Resolving a Query operation. + Query, + + // Resolving a Mutation operation. + Mutation, + + // Adding a Subscription. If you need to prepare to send events for this Subsciption + // (e.g. registering an event sink of your own), this is a chance to do that. + NotifySubscribe, + + // Resolving a Subscription event. + Subscription, + + // Removing a Subscription. If there are no more Subscriptions registered this is an + // opportunity to release resources which are no longer needed. + NotifyUnsubscribe, +}; +``` ### Request State @@ -82,10 +91,10 @@ The `SelectionSetParams::state` member is a reference to the `std::shared_ptr` parameter passed to `Request::resolve` (see [resolvers.md](./resolvers.md) for more info): ```cpp -// The RequestState is nullable, but if you have multiple threads processing requests and there's any -// per-request state that you want to maintain throughout the request (e.g. optimizing or batching -// backend requests), you can inherit from RequestState and pass it to Request::resolve to correlate the -// asynchronous/recursive callbacks and accumulate state in it. +// The RequestState is nullable, but if you have multiple threads processing requests and there's +// any per-request state that you want to maintain throughout the request (e.g. optimizing or +// batching backend requests), you can inherit from RequestState and pass it to Request::resolve to +// correlate the asynchronous/recursive callbacks and accumulate state in it. struct RequestState : std::enable_shared_from_this { }; @@ -96,16 +105,27 @@ struct RequestState : std::enable_shared_from_this Each of the `directives` members contains the values of the `directives` and any of their arguments which were in effect at that scope of the `query`. Implementers may inspect those values in the call to `getField` and alter their -behavior based on those custom `directives`. +behavior based on those custom `directives`: +```cpp +// Directive order matters, and some of them are repeatable. So rather than passing them in a +// response::Value, pass directives in something like the underlying response::MapType which +// preserves the order of the elements without complete uniqueness. +using Directives = std::vector>; + +// Traversing a fragment spread adds a new set of directives. +using FragmentDefinitionDirectiveStack = std::list>; +using FragmentSpreadDirectiveStack = std::list; +``` As noted in the comments, the `fragmentSpreadDirectives` and -`inlineFragmentDirectives` are borrowed `const` references, shared accross -calls to multiple `getField` methods, but they will not be kept alive after -the relevant `SelectionSet` has been resolved. The `fieldDirectives` member is -passed by value and is not shared with other `getField` method calls, but it -will not be kept alive after that call returns. It's up to the implementer to -capture the values in these `directives` which they might need for asynchronous -evaulation after the call to the current `getField` method has returned. +`inlineFragmentDirectives` are stacks of directives passed down through nested +inline fragments and fragment spreads. The `Directives` object for each frame of +the stack is shared accross calls to multiple `getField` methods in a single fragment, +but they will be popped from the stack when the last field has been visited. The +`fieldDirectives` member is passed by value and is not shared with other `getField` +method calls. It's up to the implementer to capture the values in these `directives` +which they might need for asynchronous evaulation after the call to the current +`getField` method has returned. The implementer does not need to capture the values of `operationDirectives` or `fragmentDefinitionDirectives` because those are kept alive until the @@ -132,6 +152,68 @@ this member in their `FieldParams` argument, and they may change their own behavior based on that, but they cannot alter the launch policy which `graphqlservice` uses for the resolvers themselves. +In previous versions, this was a `std::launch` enum value used with the +`std::async` standard library function. In the latest version, this is a C++20 +`Awaitable`, specifically a type-erased type defined in `graphql::service::await_async`: +```cpp +// Type-erased awaitable. +class await_async : public coro::suspend_always +{ +private: + struct Concept + { + virtual ~Concept() = default; + + virtual bool await_ready() const = 0; + virtual void await_suspend(coro::coroutine_handle<> h) const = 0; + virtual void await_resume() const = 0; + }; +... + +public: + // Type-erased explicit constructor for a custom awaitable. + template + explicit await_async(std::shared_ptr pimpl) + : _pimpl { std::make_shared>(std::move(pimpl)) } + { + } + + // Default to immediate synchronous execution. + await_async() + : _pimpl { std::static_pointer_cast( + std::make_shared>(std::make_shared())) } + { + } + + // Implicitly convert a std::launch parameter used with std::async to an awaitable. + await_async(std::launch launch) + : _pimpl { ((launch & std::launch::async) == std::launch::async) + ? std::static_pointer_cast(std::make_shared>( + std::make_shared())) + : std::static_pointer_cast(std::make_shared>( + std::make_shared())) } + { + } +... +}; +``` +For convenience, it will use `graphql::service::await_worker_thread` if you specify `std::launch::async`, +which should have the same behavior as calling `std::async(std::launch::async, ...)` did before. + +If you specify any other flags for `std::launch`, it does not honor them. It will use `coro::suspend_never` +(an alias for `std::suspend_never` or `std::experimental::suspend_never`), which as the name suggests, +continues executing the coroutine without suspending. In other words, `std::launch::deferred` will no +longer defer execution as in previous versions, it will execute immediately. + +There is also a default constructor which also uses `coro::suspend_never`, so that is the default +behavior anywhere that `await_async` is default-initialized with `{}`. + +Other than simplification, the big advantage this brings is in the type-erased template constructor. +If you are using another C++20 library or thread/task pool with coroutine support, you can implement +your own `Awaitable` for it and wrap that in `graphql::service::await_async`. It should automatically +start parallelizing all of its resolvers using your custom scheduler, which can pause and resume the +coroutine when and where it likes. + ## Related Documents 1. The `getField` methods are discussed in more detail in [resolvers.md](./resolvers.md). From 8d58e3a8a693ce7d82b8be9c2e7f2aeae72e3507 Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Wed, 15 Dec 2021 17:42:45 -0800 Subject: [PATCH 113/119] Update JSON documentation to describe response::Writer --- doc/json.md | 47 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/doc/json.md b/doc/json.md index 57202daa..8ea8b0c4 100644 --- a/doc/json.md +++ b/doc/json.md @@ -37,4 +37,49 @@ comment in that file for more information: # implementation, and you should set BUILD_GRAPHQLJSON so that the test dependencies know # about your version of graphqljson. option(GRAPHQL_USE_RAPIDJSON "Use RapidJSON for JSON serialization." ON) -``` \ No newline at end of file +``` + +## response::Writer + +You can plug-in a type-erased streaming `response::Writer` to serialize a `response::Value` +to some other output mechanism, without building a single string buffer for the entire +document in memory. For example, you might use this to write directly to a buffered IPC pipe +or network connection: +```cpp +class Writer +{ +private: + struct Concept + { + virtual ~Concept() = default; + + virtual void start_object() const = 0; + virtual void add_member(const std::string& key) const = 0; + virtual void end_object() const = 0; + + virtual void start_array() const = 0; + virtual void end_arrary() const = 0; + + virtual void write_null() const = 0; + virtual void write_string(const std::string& value) const = 0; + virtual void write_bool(bool value) const = 0; + virtual void write_int(int value) const = 0; + virtual void write_float(double value) const = 0; + }; +... + +public: + template + Writer(std::unique_ptr writer) + : _concept { std::static_pointer_cast( + std::make_shared>(std::move(writer))) } + { + } + + GRAPHQLRESPONSE_EXPORT void write(Value value) const; +}; +``` + +Internally, this is what `graphqljson` uses to implement `response::toJSON` with RapidJSON. +It wraps a `rapidjson::Writer` in `response::Writer` and then writes into a +`rapidjson::StringBuffer` through that. From e46b5727b808934a6b517724fe85cdd47f77ac5b Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Wed, 15 Dec 2021 17:45:02 -0800 Subject: [PATCH 114/119] Minor correction to comment about parseSchema --- doc/parsing.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/parsing.md b/doc/parsing.md index 018e0fbb..300fe816 100644 --- a/doc/parsing.md +++ b/doc/parsing.md @@ -49,7 +49,7 @@ mix of executable and schema definitions. There are `parseSchemaString` and `parseSchemaFile` functions which do the opposite, but unless you are building additional tooling on top of the `graphqlpeg` library, you will probably not need them. They have only been used -by `schemagen` in this project. +by `schemagen` and `clientgen` in this project. ## Encoding From 3e97396f1661c3e0c70b2d308f629a0e7215e7e8 Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Wed, 15 Dec 2021 21:46:00 -0800 Subject: [PATCH 115/119] Move RequestDeliverParams field name out of SubscriptionFilter --- include/graphqlservice/GraphQLService.h | 10 ++--- src/GraphQLService.cpp | 53 +++++++++++----------- test/ClientTests.cpp | 2 +- test/TodayTests.cpp | 60 ++++++++++++------------- 4 files changed, 63 insertions(+), 62 deletions(-) diff --git a/include/graphqlservice/GraphQLService.h b/include/graphqlservice/GraphQLService.h index 4c020298..1f08e3d3 100644 --- a/include/graphqlservice/GraphQLService.h +++ b/include/graphqlservice/GraphQLService.h @@ -1233,9 +1233,6 @@ using SubscriptionDirectiveFilterCallback = std::function> @@ -1252,8 +1249,11 @@ using RequestDeliverFilter = std::optional SubscriptionKey addSubscription(RequestSubscribeParams&& params); void removeSubscription(SubscriptionKey key); std::vector> collectRegistrations( - RequestDeliverFilter&& filter) const noexcept; + std::string_view field, RequestDeliverFilter&& filter) const noexcept; const TypeMap _operations; std::unique_ptr _validation; diff --git a/src/GraphQLService.cpp b/src/GraphQLService.cpp index 3e4b8051..4d0b77ef 100644 --- a/src/GraphQLService.cpp +++ b/src/GraphQLService.cpp @@ -1837,7 +1837,7 @@ AwaitableDeliver Request::deliver(RequestDeliverParams params) const throw std::invalid_argument("Missing subscriptionObject"); } - const auto registrations = collectRegistrations(std::move(params.filter)); + const auto registrations = collectRegistrations(params.field, std::move(params.filter)); if (registrations.empty()) { @@ -1987,38 +1987,41 @@ void Request::removeSubscription(SubscriptionKey key) } std::vector> Request::collectRegistrations( - RequestDeliverFilter&& filter) const noexcept + std::string_view field, RequestDeliverFilter&& filter) const noexcept { std::vector> registrations; + const auto itrListeners = _listeners.find(field); - if (!filter) + if (itrListeners != _listeners.end()) { - // Return all of the registered subscriptions. - registrations.reserve(_subscriptions.size()); - std::transform(_subscriptions.begin(), - _subscriptions.end(), - std::back_inserter(registrations), - [](const auto& entry) noexcept { - return entry.second; - }); - } - else if (std::holds_alternative(*filter)) - { - // Return the specific subscription for this key. - const auto itr = _subscriptions.find(std::get(*filter)); - - if (itr != _subscriptions.end()) + if (!filter) { - registrations.push_back(itr->second); + // Return all of the registered subscriptions for this field. + registrations.reserve(itrListeners->second.size()); + std::transform(itrListeners->second.begin(), + itrListeners->second.end(), + std::back_inserter(registrations), + [this](const auto& key) noexcept { + const auto itr = _subscriptions.find(key); + + return itr == _subscriptions.end() ? std::shared_ptr {} + : itr->second; + }); } - } - else if (std::holds_alternative(*filter)) - { - auto& subscriptionFilter = std::get(*filter); - const auto itrListeners = _listeners.find(subscriptionFilter.field); + else if (std::holds_alternative(*filter)) + { + // Return the specific subscription for this key. + const auto itr = _subscriptions.find(std::get(*filter)); - if (itrListeners != _listeners.end()) + if (itr != _subscriptions.end() && itr->second->field == field) + { + registrations.push_back(itr->second); + } + } + else if (std::holds_alternative(*filter)) { + auto& subscriptionFilter = std::get(*filter); + registrations.reserve(itrListeners->second.size()); std::optional argumentsMatch; diff --git a/test/ClientTests.cpp b/test/ClientTests.cpp index ba4f5b9a..37068041 100644 --- a/test/ClientTests.cpp +++ b/test/ClientTests.cpp @@ -247,7 +247,7 @@ TEST_F(ClientCase, SubscribeNextAppointmentChangeDefault) {}, state }) .get(); - _service->deliver({ { service::SubscriptionFilter { "nextAppointmentChange"sv } } }).get(); + _service->deliver({ "nextAppointmentChange"sv }).get(); _service->unsubscribe({ key }).get(); try diff --git a/test/TodayTests.cpp b/test/TodayTests.cpp index f4ea145d..8130f23b 100644 --- a/test/TodayTests.cpp +++ b/test/TodayTests.cpp @@ -618,7 +618,7 @@ TEST_F(TodayServiceCase, SubscribeNextAppointmentChangeDefault) {}, state }) .get(); - _service->deliver({ { service::SubscriptionFilter { "nextAppointmentChange"sv } } }).get(); + _service->deliver({ "nextAppointmentChange"sv }).get(); _service->unsubscribe({ key }).get(); try @@ -682,8 +682,9 @@ TEST_F(TodayServiceCase, SubscribeNextAppointmentChangeOverride) state }) .get(); _service - ->deliver({ { service::SubscriptionFilter { "nextAppointmentChange"sv } }, - {}, + ->deliver({ "nextAppointmentChange"sv, + {}, // filter + {}, // launch std::make_shared(std::move(subscriptionObject)) }) .get(); _service->unsubscribe({ key }).get(); @@ -722,7 +723,7 @@ TEST_F(TodayServiceCase, DeliverNextAppointmentChangeNoSubscriptionObject) try { - service->deliver({ { service::SubscriptionFilter { "nextAppointmentChange"sv } } }).get(); + service->deliver({ "nextAppointmentChange"sv }).get(); } catch (const std::invalid_argument& ex) { @@ -740,7 +741,7 @@ TEST_F(TodayServiceCase, DeliverNextAppointmentChangeNoSubscriptionSupport) try { - service->deliver({ { service::SubscriptionFilter { "nextAppointmentChange"sv } } }).get(); + service->deliver({ "nextAppointmentChange"sv }).get(); } catch (const std::logic_error& ex) { @@ -1269,10 +1270,10 @@ TEST_F(TodayServiceCase, SubscribeNodeChangeMatchingId) state }) .get(); _service - ->deliver({ { service::SubscriptionFilter { "nodeChange"sv, - { service::SubscriptionArguments { - { "id", response::Value("ZmFrZVRhc2tJZA=="s) } } } } }, - {}, + ->deliver({ "nodeChange"sv, + { service::SubscriptionFilter { { service::SubscriptionArguments { + { "id", response::Value("ZmFrZVRhc2tJZA=="s) } } } } }, + {}, // launch std::make_shared(std::move(subscriptionObject)) }) .get(); _service->unsubscribe({ key }).get(); @@ -1330,10 +1331,10 @@ TEST_F(TodayServiceCase, SubscribeNodeChangeMismatchedId) std::move(variables) }) .get(); _service - ->deliver({ { service::SubscriptionFilter { "nodeChange"sv, - { service::SubscriptionArguments { - { "id", response::Value("ZmFrZUFwcG9pbnRtZW50SWQ="s) } } } } }, - {}, + ->deliver({ "nodeChange"sv, + { service::SubscriptionFilter { { service::SubscriptionArguments { + { "id", response::Value("ZmFrZUFwcG9pbnRtZW50SWQ="s) } } } } }, + {}, // launch std::make_shared(std::move(subscriptionObject)) }) .get(); _service->unsubscribe({ key }).get(); @@ -1396,11 +1397,11 @@ TEST_F(TodayServiceCase, SubscribeNodeChangeFuzzyComparator) state }) .get(); _service - ->deliver( - { { service::SubscriptionFilter { "nodeChange"sv, - { service::SubscriptionArgumentFilterCallback { std::move(filterCallback) } } } }, - {}, - std::make_shared(std::move(subscriptionObject)) }) + ->deliver({ "nodeChange"sv, + { service::SubscriptionFilter { + { service::SubscriptionArgumentFilterCallback { std::move(filterCallback) } } } }, + {}, // launch + std::make_shared(std::move(subscriptionObject)) }) .get(); _service->unsubscribe({ key }).get(); @@ -1467,11 +1468,11 @@ TEST_F(TodayServiceCase, SubscribeNodeChangeFuzzyMismatch) std::move(variables) }) .get(); _service - ->deliver( - { { service::SubscriptionFilter { "nodeChange"sv, - { service::SubscriptionArgumentFilterCallback { std::move(filterCallback) } } } }, - {}, - std::make_shared(std::move(subscriptionObject)) }) + ->deliver({ "nodeChange"sv, + { service::SubscriptionFilter { + { service::SubscriptionArgumentFilterCallback { std::move(filterCallback) } } } }, + {}, // launch + std::make_shared(std::move(subscriptionObject)) }) .get(); _service->unsubscribe({ key }).get(); @@ -1524,10 +1525,10 @@ TEST_F(TodayServiceCase, SubscribeNodeChangeMatchingVariable) state }) .get(); _service - ->deliver({ { service::SubscriptionFilter { "nodeChange"sv, - { service::SubscriptionArguments { - { "id", response::Value("ZmFrZVRhc2tJZA=="s) } } } } }, - {}, + ->deliver({ "nodeChange"sv, + { service::SubscriptionFilter { { service::SubscriptionArguments { + { "id", response::Value("ZmFrZVRhc2tJZA=="s) } } } } }, + {}, // launch std::make_shared(std::move(subscriptionObject)) }) .get(); _service->unsubscribe({ key }).get(); @@ -1722,10 +1723,7 @@ TEST_F(TodayServiceCase, SubscribeNextAppointmentChangeAsync) {}, state }) .get(); - _service - ->deliver( - { { service::SubscriptionFilter { "nextAppointmentChange"sv } }, std::launch::async }) - .get(); + _service->deliver({ "nextAppointmentChange"sv, {}, std::launch::async }).get(); _service->unsubscribe({ key }).get(); try From 3b42b472b54db9f8bad7b5f1d9b1c47ab9d494ae Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Wed, 15 Dec 2021 21:46:12 -0800 Subject: [PATCH 116/119] Finish documentation pass --- doc/awaitable.md | 267 +++++++++++++++++++++++++++++++++++++++++++ doc/fieldparams.md | 79 +------------ doc/resolvers.md | 154 ++++++++++++++++++------- doc/subscriptions.md | 204 +++++++++++++++++++-------------- 4 files changed, 507 insertions(+), 197 deletions(-) create mode 100644 doc/awaitable.md diff --git a/doc/awaitable.md b/doc/awaitable.md new file mode 100644 index 00000000..0d41be36 --- /dev/null +++ b/doc/awaitable.md @@ -0,0 +1,267 @@ +# Awaitable + +## Launch Policy + +In previous versions, this was a `std::launch` enum value used with the +`std::async` standard library function. Now, this is a C++20 `Awaitable`, +specifically a type-erased `graphql::service::await_async` class in +[GraphQLService.h](../include/graphqlservice/GraphQLService.h): +```cpp +// Type-erased awaitable. +class await_async : public coro::suspend_always +{ +private: + struct Concept + { + virtual ~Concept() = default; + + virtual bool await_ready() const = 0; + virtual void await_suspend(coro::coroutine_handle<> h) const = 0; + virtual void await_resume() const = 0; + }; +... + +public: + // Type-erased explicit constructor for a custom awaitable. + template + explicit await_async(std::shared_ptr pimpl) + : _pimpl { std::make_shared>(std::move(pimpl)) } + { + } + + // Default to immediate synchronous execution. + await_async() + : _pimpl { std::static_pointer_cast( + std::make_shared>(std::make_shared())) } + { + } + + // Implicitly convert a std::launch parameter used with std::async to an awaitable. + await_async(std::launch launch) + : _pimpl { ((launch & std::launch::async) == std::launch::async) + ? std::static_pointer_cast(std::make_shared>( + std::make_shared())) + : std::static_pointer_cast(std::make_shared>( + std::make_shared())) } + { + } +... +}; +``` +For convenience, it will use `graphql::service::await_worker_thread` if you specify `std::launch::async`, +which should have the same behavior as calling `std::async(std::launch::async, ...)` did before. + +If you specify any other flags for `std::launch`, it does not honor them. It will use `coro::suspend_never` +(an alias for `std::suspend_never` or `std::experimental::suspend_never`), which as the name suggests, +continues executing the coroutine without suspending. In other words, `std::launch::deferred` will no +longer defer execution as in previous versions, it will execute immediately. + +There is also a default constructor which also uses `coro::suspend_never`, so that is the default +behavior anywhere that `await_async` is default-initialized with `{}`. + +Other than simplification, the big advantage this brings is in the type-erased template constructor. +If you are using another C++20 library or thread/task pool with coroutine support, you can implement +your own `Awaitable` for it and wrap that in `graphql::service::await_async`. It should automatically +start parallelizing all of its resolvers using your custom scheduler, which can pause and resume the +coroutine when and where it likes. + +## Awaitable Results + +Many APIs which used to return some sort of `std::future` now return an alias for +`graphql::internal::Awaitable<...>`. This template is defined in [Awaitable.h](../include/graphqlservice/internal/Awaitable.h): +```cpp +template +class Awaitable +{ +public: + Awaitable(std::future value) + : _value { std::move(value) } + { + } + + T get() + { + return _value.get(); + } + + struct promise_type + { + Awaitable get_return_object() noexcept + { + return { _promise.get_future() }; + } + + ... + + void return_value(T&& value) noexcept(std::is_nothrow_move_constructible_v) + { + _promise.set_value(std::move(value)); + } + + ... + + private: + std::promise _promise; + + }; + + constexpr bool await_ready() const noexcept + { + return true; + } + + void await_suspend(coro::coroutine_handle<> h) const + { + h.resume(); + } + + T await_resume() + { + return _value.get(); + } + +private: + std::future _value; +}; +``` + +The key details are that it implements the required `promise_type` and `await_` methods so +that you can turn any `co_return` statement into a `std::future`, and it can either +`co_await` for that `std::future` from a coroutine, or call `T get()` to block a regular +function until it completes. + +## AwaitableScalar and AwaitableObject + +In previous versions, `service::FieldResult` created an abstraction over return types `T` and +`std::future`, when returning from a field getter you could return either and it would +implicitly convert that to a `service::FieldResult` which looked and acted like a +`std::future`. + +Now, `service::FieldResult` is replaced with `service::AwaitableScalar` for `scalar` type +fields without a selection set of sub-fields, or `service::AwaitableObject` for `object` +type fields which must have a selection set of sub-fields. The difference between +`service::AwaitableScalar` and `service::AwaitableObject` is that `scalar` type fields can +also return `std::shared_ptr` directly, which bypasses all of the +conversion logic in `service::ModifiedResult` and just validates that the shape of the +`response::Value` matches the `scalar` type with all of its modifiers. These are both defined +in [GraphQLService.h](../include/graphqlservice/GraphQLService.h): +```cpp +// Field accessors may return either a result of T, an awaitable of T, or a std::future, so at +// runtime the implementer may choose to return by value or defer/parallelize expensive operations +// by returning an async future or an awaitable coroutine. +// +// If the overhead of conversion to response::Value is too expensive, scalar type field accessors +// can store and return a std::shared_ptr directly. +template +class AwaitableScalar +{ +public: + template + AwaitableScalar(U&& value) + : _value { std::forward(value) } + { + } + + struct promise_type + { + AwaitableScalar get_return_object() noexcept + { + return { _promise.get_future() }; + } + + ... + + void return_value(const T& value) noexcept(std::is_nothrow_copy_constructible_v) + { + _promise.set_value(value); + } + + void return_value(T&& value) noexcept(std::is_nothrow_move_constructible_v) + { + _promise.set_value(std::move(value)); + } + + ... + + private: + std::promise _promise; + }; + + bool await_ready() const noexcept { ... } + + void await_suspend(coro::coroutine_handle<> h) const { ... } + + T await_resume() + { + ... // Throws std::logic_error("Cannot await std::shared_ptr") if called with that alternative + } + + std::shared_ptr get_value() noexcept + { + ... // Returns an empty std::shared_ptr if called with a different alternative + } + +private: + std::variant, std::shared_ptr> _value; +}; + +// Field accessors may return either a result of T, an awaitable of T, or a std::future, so at +// runtime the implementer may choose to return by value or defer/parallelize expensive operations +// by returning an async future or an awaitable coroutine. +template +class AwaitableObject +{ +public: + template + AwaitableObject(U&& value) + : _value { std::forward(value) } + { + } + + struct promise_type + { + AwaitableObject get_return_object() noexcept + { + return { _promise.get_future() }; + } + + ... + + void return_value(const T& value) noexcept(std::is_nothrow_copy_constructible_v) + { + _promise.set_value(value); + } + + void return_value(T&& value) noexcept(std::is_nothrow_move_constructible_v) + { + _promise.set_value(std::move(value)); + } + + ... + + private: + std::promise _promise; + }; + + bool await_ready() const noexcept { ... } + + void await_suspend(coro::coroutine_handle<> h) const { ... } + + T await_resume() { ... } + +private: + std::variant> _value; +}; +``` + +These types both add a `promise_type` for `T`, but coroutines need their own return type to do that. +Making `service::AwaitableScalar` or `service::AwaitableObject` the return type of a field +getter means you can turn it into a coroutine by just replacing `return` with `co_return`, and +potentially start to `co_await` other awaitables and coroutines. + +Type-erasure made it so you do not need to use a special return type, the type-erased +`Object::Model` type just needs to be able to pass the return result from your field +getter into a constructor for one of these return types. So if you want to implement +your field getters as coroutines, you should still wrap the return type in +`service::AwaitableScalar` or `service::AwaitableObject`. Otherwise, you can remove +the template wrapper from all of your field getters. diff --git a/doc/fieldparams.md b/doc/fieldparams.md index 53a2b1ec..7ca8d7c1 100644 --- a/doc/fieldparams.md +++ b/doc/fieldparams.md @@ -144,80 +144,13 @@ report, accoring to the [spec](https://spec.graphql.org/October2021/#sec-Errors) ### Launch Policy -The `graphqlservice` library uses the `SelectionSetParams::launch` parameter to -determine how it should handle async resolvers in the same selection set or -elements in the same list. It is passed from the top-most `resolve`, `deliver`, -or async `subscribe`/`unsubscribe` call. The `getField` accessors get a copy of -this member in their `FieldParams` argument, and they may change their own -behavior based on that, but they cannot alter the launch policy which -`graphqlservice` uses for the resolvers themselves. - -In previous versions, this was a `std::launch` enum value used with the -`std::async` standard library function. In the latest version, this is a C++20 -`Awaitable`, specifically a type-erased type defined in `graphql::service::await_async`: -```cpp -// Type-erased awaitable. -class await_async : public coro::suspend_always -{ -private: - struct Concept - { - virtual ~Concept() = default; - - virtual bool await_ready() const = 0; - virtual void await_suspend(coro::coroutine_handle<> h) const = 0; - virtual void await_resume() const = 0; - }; -... - -public: - // Type-erased explicit constructor for a custom awaitable. - template - explicit await_async(std::shared_ptr pimpl) - : _pimpl { std::make_shared>(std::move(pimpl)) } - { - } - - // Default to immediate synchronous execution. - await_async() - : _pimpl { std::static_pointer_cast( - std::make_shared>(std::make_shared())) } - { - } - - // Implicitly convert a std::launch parameter used with std::async to an awaitable. - await_async(std::launch launch) - : _pimpl { ((launch & std::launch::async) == std::launch::async) - ? std::static_pointer_cast(std::make_shared>( - std::make_shared())) - : std::static_pointer_cast(std::make_shared>( - std::make_shared())) } - { - } -... -}; -``` -For convenience, it will use `graphql::service::await_worker_thread` if you specify `std::launch::async`, -which should have the same behavior as calling `std::async(std::launch::async, ...)` did before. - -If you specify any other flags for `std::launch`, it does not honor them. It will use `coro::suspend_never` -(an alias for `std::suspend_never` or `std::experimental::suspend_never`), which as the name suggests, -continues executing the coroutine without suspending. In other words, `std::launch::deferred` will no -longer defer execution as in previous versions, it will execute immediately. - -There is also a default constructor which also uses `coro::suspend_never`, so that is the default -behavior anywhere that `await_async` is default-initialized with `{}`. - -Other than simplification, the big advantage this brings is in the type-erased template constructor. -If you are using another C++20 library or thread/task pool with coroutine support, you can implement -your own `Awaitable` for it and wrap that in `graphql::service::await_async`. It should automatically -start parallelizing all of its resolvers using your custom scheduler, which can pause and resume the -coroutine when and where it likes. +See the [Awaitable](./awaitable.md) document for more information about +`service::await_async`. ## Related Documents 1. The `getField` methods are discussed in more detail in [resolvers.md](./resolvers.md). -2. Built-in and custom `directives` are discussed in [directives.md](./directives.md). -3. Subscription resolvers get called up to 3 times depending on which -`subscribe`/`unsubscribe` overrides you call. See [subscriptions.md](./subscriptions.md) -for more details. \ No newline at end of file +2. Awaitable types are covered in [awaitable.md](./awaitable.md). +3. Built-in and custom `directives` are discussed in [directives.md](./directives.md). +4. Subscription resolvers may be called 2 extra times, inside of subscribe` and `unsubscribe`. +See [subscriptions.md](./subscriptions.md) for more details. \ No newline at end of file diff --git a/doc/resolvers.md b/doc/resolvers.md index a66e3b4e..a294392d 100644 --- a/doc/resolvers.md +++ b/doc/resolvers.md @@ -34,20 +34,37 @@ schema { Executing a query or mutation starts by calling `Request::resolve` from [GraphQLService.h](../include/graphqlservice/GraphQLService.h): ```cpp -GRAPHQLSERVICE_EXPORT response::AwaitableValue resolve( - const std::shared_ptr& state, peg::ast& query, - const std::string& operationName, response::Value&& variables) const; +GRAPHQLSERVICE_EXPORT response::AwaitableValue resolve(RequestResolveParams params) const; ``` -By default, the `std::future` results are resolved on-demand but synchronously. -You can also use an override of `Request::resolve` which lets you substitute -the `std::launch::async` option to begin executing the query on multiple -threads in parallel: + +The `RequestResolveParams` struct is defined in the same header: ```cpp -GRAPHQLSERVICE_EXPORT response::AwaitableValue resolve(std::launch launch, - const std::shared_ptr& state, peg::ast& query, - const std::string& operationName, response::Value&& variables) const; +struct RequestResolveParams +{ + // Required query information. + peg::ast& query; + std::string_view operationName {}; + response::Value variables { response::Type::Map }; + + // Optional async execution awaitable. + await_async launch; + + // Optional sub-class of RequestState which will be passed to each resolver and field accessor. + std::shared_ptr state; +}; ``` +The only parameter which cannot be default initialized is `query`. + +The `service::await_async` launch policy is described in [awaitable.md](./awaitable.md). +By default, the resolvers will run on the same thread synchronously. + +The `response::AwaitableValue` return type is a type alias in [GraphQLResponse.h](../include/graphqlservice/GraphQLResponse.h): +```cpp +using AwaitableValue = internal::Awaitable; +``` +The `internal::Awaitable` template is described in [awaitable.md](./awaitable.md). + ### `graphql::service::Request` and `graphql::::Operations` Anywhere in the documentation where it mentions `graphql::service::Request` @@ -55,45 +72,104 @@ methods, the concrete type will actually be `graphql::::Operations`. This `class` is defined by `schemagen` and inherits from `graphql::service::Request`. It links the top-level objects for the custom schema to the `resolve` methods on its base class. See -`graphql::today::Operations` in [TodaySchema.h](../samples/separate/TodaySchema.h) +`graphql::today::Operations` in [TodaySchema.h](../samples/today/schema/TodaySchema.h) for an example. ## Generated Service Schema -The `schemagen` tool generates C++ types in the `graphql::::object` -namespace with `resolveField` methods for each `field` which parse the -arguments from the `query` and automatically dispatch the call to a `getField` -virtual method to retrieve the `field` result. On `object` types, it will also -recursively call the `resolvers` for each of the `fields` in the nested -`SelectionSet`. See for example the generated -`graphql::today::object::Appointment` object from the `today` sample in -[AppointmentObject.h](../samples/separate/AppointmentObject.h). +The `schemagen` tool generates type-erased C++ types in the `graphql::::object` +namespace with `resolveField` methods for each `field` which parse the arguments from +the `query` and automatically dispatch the call to a `getField` method on the +implementation type to retrieve the `field` result. On `object` types, it will also +recursively call the `resolvers` for each of the `fields` in the nested `SelectionSet`. +See for example the generated `graphql::today::object::Appointment` object from the `today` +sample in [AppointmentObject.cpp](../samples/today/schema/AppointmentObject.cpp): ```cpp -service::AwaitableResolver resolveId(service::ResolverParams&& params); +service::AwaitableResolver Appointment::resolveId(service::ResolverParams&& params) const +{ + std::unique_lock resolverLock(_resolverMutex); + auto directives = std::move(params.fieldDirectives); + auto result = _pimpl->getId(service::FieldParams(service::SelectionSetParams{ params }, std::move(directives))); + resolverLock.unlock(); + + return service::ModifiedResult::convert(std::move(result), std::move(params)); +} ``` -In this example, the `resolveId` method invokes `getId`: +In this example, the `resolveId` method invokes `Concept::getId(service::FieldParams&&)`, +which is implemented by `Model::getId(service::FieldParams&&)`: ```cpp -virtual service::AwaitableScalar getId(service::FieldParams&& params) const override; +service::AwaitableScalar getId(service::FieldParams&& params) const final +{ + if constexpr (methods::AppointmentHas::getIdWithParams) + { + return { _pimpl->getId(std::move(params)) }; + } + else if constexpr (methods::AppointmentHas::getId) + { + return { _pimpl->getId() }; + } + else + { + throw std::runtime_error(R"ex(Appointment::getId is not implemented)ex"); + } +} ``` -There are a couple of interesting quirks in this example: -1. The `Appointment object` implements and inherits from the `Node interface`, -which already declared `getId` as a pure-virtual method. That's what the -`override` keyword refers to. -2. This schema was generated with default stub implementations (without the -`schemagen --no-stubs` parameter) which speed up initial development with NYI -(Not Yet Implemented) stubs. With that parameter, there would be no -declaration of `Appointment::getId` since it would inherit a pure-virtual -declaration and the implementer would need to define an override on the -concrete implementation of `graphql::today::object::Appointment`. The NYI stub -will throw a `std::runtime_error`, which the `resolver` converts into an entry -in the `response errors` collection: +There are a couple of interesting points in this example: +1. The `methods::AppointmentHas::getIdWithParams` and +`methods::AppointmentHas::getIdWith` concepts are automatically generated at the top of +[AppointmentObject.h](../samples/today/schema/AppointmentObject.h). The implementation +of the virtual method from the `object::Appointment::Concept` interface uses +`if constexpr (...)` to conditionally compile just one of the 3 method bodies, depending +on whether or not `T` matches those concepts: ```cpp -throw std::runtime_error(R"ex(Appointment::getId is not implemented)ex"); +namespace methods::AppointmentHas { + +template +concept getIdWithParams = requires (TImpl impl, service::FieldParams params) +{ + { service::AwaitableScalar { impl.getId(std::move(params)) } }; +}; + +template +concept getId = requires (TImpl impl) +{ + { service::AwaitableScalar { impl.getId() } }; +}; + +... + +} // namespace methods::AppointmentHas +``` +2. This schema was generated with default stub implementations (using the +`schemagen --stubs` parameter) which speeds up initial development with NYI +(Not Yet Implemented) stubs. If the implementation type `T` does not match either +concept, it will still implement this method on `object::Appointment::Model`, but +it will always throw a `std::runtime_error` indicating that the method was not implemented. +Compared to the type-erased objects generated for the [learn](../samples/learn/), such as +[HumanObject.h](../samples/learn/schema/HumanObject.h), without `schemagen --stubs` it +adds a `static_assert` instead, so it will trigger a compile-time error if you do not +implement all of the field getters: +```cpp +service::AwaitableScalar getId(service::FieldParams&& params) const final +{ + if constexpr (methods::HumanHas::getIdWithParams) + { + return { _pimpl->getId(std::move(params)) }; + } + else + { + static_assert(methods::HumanHas::getId, R"msg(Human::getId is not implemented)msg"); + return { _pimpl->getId() }; + } +} ``` Although the `id field` does not take any arguments according to the sample -[schema](../samples/schema.today.graphql), this example also shows how -every `getField` method takes a `graphql::service::FieldParams` struct as -its first parameter. There are more details on this in the [fieldparams.md](./fieldparams.md) -document. \ No newline at end of file +[schema](../samples/today/schema.today.graphql), this example also shows how every `getField` +method on the `object::Appointment::Concept` takes a `graphql::service::FieldParams` struct +as its first parameter from the resolver. If the implementation type can take that parameter +and matches the concept, the `object::Appointment::Model` `getField` method will pass +it through to the implementation type. If it does not, it will silently ignore that +parameter and invoke the implementation type `getField` method without it. There are more +details on this in the [fieldparams.md](./fieldparams.md) document. \ No newline at end of file diff --git a/doc/subscriptions.md b/doc/subscriptions.md index d5929820..3ee8f02a 100644 --- a/doc/subscriptions.md +++ b/doc/subscriptions.md @@ -8,48 +8,84 @@ provide a way to register callbacks when adding a subscription, and you can define trigger conditions when delivering an update to selectively dispatch the subscriptions to those listeners. -## Adding/Removing a Listener +## Adding a Listener -Subscriptions are created or removed by calling the `Request::subscribe` -and `Request::unsubscribe` methods in [GraphQLService.h](../include/graphqlservice/GraphQLService.h): +Subscriptions are created by calling the `Request::subscribe` method in +[GraphQLService.h](../include/graphqlservice/GraphQLService.h): ```cpp -GRAPHQLSERVICE_EXPORT SubscriptionKey subscribe( - RequestSubscribeParams&& params, SubscriptionCallback&& callback); -GRAPHQLSERVICE_EXPORT AwaitableSubscribe subscribe( - std::launch launch, RequestSubscribeParams&& params, SubscriptionCallback&& callback); - -GRAPHQLSERVICE_EXPORT void unsubscribe(SubscriptionKey key); -GRAPHQLSERVICE_EXPORT AwaitableUnsubscribe unsubscribe(std::launch launch, SubscriptionKey key); +GRAPHQLSERVICE_EXPORT AwaitableSubscribe subscribe(RequestSubscribeParams params); ``` -You need to fill in a `RequestSubscribeParams` struct with the [parsed](./parsing.md) -query and any other relevant operation parameters: + +You need to fill in a `RequestSubscribeParams` struct with the subscription event +callback, the [parsed](./parsing.md) `query` and any other relevant operation parameters: ```cpp -// You can still sub-class RequestState and use that in the state parameter to Request::subscribe -// to add your own state to the service callbacks that you receive while executing the subscription -// query. struct RequestSubscribeParams { - std::shared_ptr state; + // Callback which receives the event data. + SubscriptionCallback callback; + + // Required query information. peg::ast query; - std::string operationName; - response::Value variables; + std::string operationName {}; + response::Value variables { response::Type::Map }; + + // Optional async execution awaitable. + await_async launch; + + // Optional sub-class of RequestState which will be passed to each resolver and field accessor. + std::shared_ptr state; }; ``` + The `SubscriptionCallback` signature is: ```cpp // Subscription callbacks receive the response::Value representing the result of evaluating the // SelectionSet against the payload. -using SubscriptionCallback = std::function; +using SubscriptionCallback = std::function; +``` + +The `service::await_async` launch policy is described in [awaitable.md](./awaitable.md). +By default, the resolvers will run on the same thread synchronously. + +The `std::shared_ptr` state is described in [fieldparams.md](./fieldparams.md). + +The `AwaitableSubscribe` return type is a type alias in +[GraphQLResponse.h](../include/graphqlservice/GraphQLResponse.h): +```cpp +using AwaitableSubscribe = internal::Awaitable; +``` +The `internal::Awaitable` template is described in [awaitable.md](./awaitable.md). + +## Removing a Listener + +Subscriptions are removed by calling the `Request::unsubscribe` method in +[GraphQLService.h](../include/graphqlservice/GraphQLService.h): +```cpp +GRAPHQLSERVICE_EXPORT AwaitableUnsubscribe unsubscribe(RequestUnsubscribeParams params); +``` + +You need to fill in a `RequestUnsubscribeParams` struct with the `SubscriptionKey` +returned by `Request::subscribe` in `AwaitableSubscribe`: +```cpp +struct RequestUnsubscribeParams +{ + // Key returned by a previous call to subscribe. + SubscriptionKey key; + + // Optional async execution awaitable. + await_async launch; +}; ``` +The `service::await_async` launch policy is described in [awaitable.md](./awaitable.md). +By default, the resolvers will run on the same thread synchronously. + ## `ResolverContext::NotifySubscribe` and `ResolverContext::NotifyUnsubscribe` -If you use the async version of `subscribe` and `unsubscribe` which take a -`std::launch` parameter, and you provide a default instance of the -`Subscription` object to the `Request`/`Operations` constructor, you will get -additional callbacks with the `ResolverContext::NotifySubscribe` and -`ResolverContext::NotifyUnsubscribe` values for the -`FieldParams::resolverContext` member. These are passed by the async +If you provide a default instance of the `Subscription` object to the `Request`/ +`Operations` constructor, you will get additional callbacks with the +`ResolverContext::NotifySubscribe` and `ResolverContext::NotifyUnsubscribe` values +for the `FieldParams::resolverContext` member. These are passed by the `subscribe` and `unsubscribe` calls to the default subscription object, and they provide an opportunity to acquire or release resources that are required to implement the subscription. @@ -62,79 +98,77 @@ event payload for a `deliver` call will be resolved with ## Delivering Subscription Updates -If you pass an empty `std::shared_ptr` for the `subscriptionObject` -parameter, `deliver` will fall back to resolving the query against the default -`Subscription` object passed to the `Request`/`Operations` constructor. If both -`Subscription` object parameters are empty, `deliver` will throw an exception. - -There are currently five `Request::deliver` overrides you can choose from when -sending updates to any subscribed listeners. The first one is the simplest, -it will evaluate each subscribed query against the `subscriptionObject` -parameter (which should match the `Subscription` type in the `schema`). It will -unconditionally invoke every subscribed `SubscriptionCallback` callback with -the response to its query: +If you pass an empty `std::shared_ptr` for the +`subscriptionObject` parameter, `deliver` will fall back to resolving the query +against the default `Subscription` object passed to the `Request`/`Operations` +constructor. If both `Subscription` object parameters are empty, `deliver` +will throw an exception: ```cpp -GRAPHQLSERVICE_EXPORT void deliver( - const SubscriptionName& name, const std::shared_ptr& subscriptionObject) const; +GRAPHQLSERVICE_EXPORT AwaitableDeliver deliver(RequestDeliverParams params) const; ``` -The second override adds argument filtering. It will look at the field -arguments in the subscription `query`, and if all of the required parameters -in the `arguments` parameter are present and are an exact match it will -dispatch the callback to that subscription: +The `Request::deliver` method determines which subscriptions should receive +an event based on several factors, which makes the `RequestDeliverParams` struct +more complicated: ```cpp -GRAPHQLSERVICE_EXPORT void deliver(const SubscriptionName& name, - const SubscriptionArguments& arguments, - const std::shared_ptr& subscriptionObject) const; -``` +struct RequestDeliverParams +{ + // Deliver to subscriptions on this field. + std::string_view field; -The third override adds directive filtering. It will look at both the field -arguments and the directives with their own arguments in the subscription -`query`, and if all of them match it will dispatch the callback to that -subscription: -```cpp -GRAPHQLSERVICE_EXPORT void deliver(const SubscriptionName& name, - const SubscriptionArguments& arguments, const SubscriptionArguments& directives, - const std::shared_ptr& subscriptionObject) const; + // Optional filter to control which subscriptions will receive the event. If not specified, + // every subscription on this field will receive the event and evaluate their queries. + RequestDeliverFilter filter; + + // Optional async execution awaitable. + await_async launch; + + // Optional override for the default Subscription operation object. + std::shared_ptr subscriptionObject; +}; ``` -The last two overrides let you customize the the way that the required -arguments and directives are matched. Instead of an exact match or making all -of the arguments required, it will dispatch the callback if the `apply` -function parameters return true for every required field and directive in the -subscription `query`. +First, the `Request::deliver` method selects only the subscriptions which are listening +to events for this field. Then, if you specify the `RequestDeliverFilter`, it filters the set +of subscriptions down to the ones which it matches: ```cpp -GRAPHQLSERVICE_EXPORT void deliver(const SubscriptionName& name, - const SubscriptionFilterCallback& applyArguments, - const std::shared_ptr& subscriptionObject) const; -GRAPHQLSERVICE_EXPORT void deliver(const SubscriptionName& name, - const SubscriptionFilterCallback& applyArguments, - const SubscriptionFilterCallback& applyDirectives, - const std::shared_ptr& subscriptionObject) const; +// Deliver to a specific subscription key, or apply custom criteria for the field name, arguments, +// and directives in the Subscription query. +using RequestDeliverFilter = std::optional>; ``` -By default, `deliver` invokes all of the `SubscriptionCallback` listeners with -`std::future` payloads which are resolved on-demand but synchronously. You can -also use an override of `Request::resolve` which lets you substitute the -`std::launch::async` option to begin executing the queries and invoke the -callbacks on multiple threads in parallel: +The simplest filter is the `SubscriptionKey`. If you specify that, and the subscription is +listening to `field` events, `Request::deliver` will only deliver to that one subscription. + +The `SubscriptionFilter struct` adds alternative filters for the field arguments and any field +directives which might have been specified in the subscription query. For each one, you can either +specify a callback which will test each argument or directive, or you can specify a set of required +arguments or directives which must all be present: ```cpp -GRAPHQLSERVICE_EXPORT AwaitableDeliver deliver(std::launch launch, const SubscriptionName& name, - std::shared_ptr subscriptionObject) const; -GRAPHQLSERVICE_EXPORT AwaitableDeliver deliver(std::launch launch, const SubscriptionName& name, - const SubscriptionArguments& arguments, std::shared_ptr subscriptionObject) const; -GRAPHQLSERVICE_EXPORT AwaitableDeliver deliver(std::launch launch, const SubscriptionName& name, - const SubscriptionArguments& arguments, const SubscriptionArguments& directives, - std::shared_ptr subscriptionObject) const; -GRAPHQLSERVICE_EXPORT AwaitableDeliver deliver(std::launch launch, const SubscriptionName& name, - const SubscriptionFilterCallback& applyArguments, - std::shared_ptr subscriptionObject) const; -GRAPHQLSERVICE_EXPORT AwaitableDeliver deliver(std::launch launch, const SubscriptionName& name, - const SubscriptionFilterCallback& applyArguments, - const SubscriptionFilterCallback& applyDirectives, - std::shared_ptr subscriptionObject) const; +using SubscriptionArguments = std::map; +using SubscriptionArgumentFilterCallback = std::function; +using SubscriptionDirectiveFilterCallback = std::function; + +struct SubscriptionFilter +{ + // Optional field argument filter, which can either be a set of required arguments, or a + // callback which returns true if the arguments match custom criteria. + std::optional> + arguments; + + // Optional field directives filter, which can either be a set of required directives and + // arguments, or a callback which returns true if the directives match custom criteria. + std::optional> directives; +}; ``` +The `service::await_async` launch policy is described in [awaitable.md](./awaitable.md). +By default, the resolvers will run on the same thread synchronously. + +The optional `std::shared_ptr subscriptionObject` parameter can override the +default Subscription operation object passed to the `Operations` constructor, or supply +one if no default instance was included. + ## Handling Multiple Operation Types Some service implementations (e.g. Apollo over HTTP) use a single pipe to From 59eb71345df3ea082a36a63c03de89c57cafed15 Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Wed, 15 Dec 2021 21:48:15 -0800 Subject: [PATCH 117/119] Update doc list to include awaitable.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index e6aeb5fc..5f8e6fce 100644 --- a/README.md +++ b/README.md @@ -220,6 +220,7 @@ the files in your source directory. There are some more targeted documents in the [doc](./doc) directory: +* [Awaitable Types](./doc/awaitable.md) * [Parsing GraphQL](./doc/parsing.md) * [Query Responses](./doc/responses.md) * [JSON Representation](./doc/json.md) From 0b47cf154130abb74bbe85b9c1c909b5fa60b222 Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Thu, 16 Dec 2021 10:24:25 -0800 Subject: [PATCH 118/119] Default initialize input type struct members --- samples/learn/schema/StarWarsSchema.h | 4 ++-- samples/today/nointrospection/TodaySchema.h | 22 ++++++++++---------- samples/today/schema/TodaySchema.h | 22 ++++++++++---------- samples/validation/schema/ValidationSchema.h | 4 ++-- src/SchemaGenerator.cpp | 2 +- 5 files changed, 27 insertions(+), 27 deletions(-) diff --git a/samples/learn/schema/StarWarsSchema.h b/samples/learn/schema/StarWarsSchema.h index 652d290f..59ac67bf 100644 --- a/samples/learn/schema/StarWarsSchema.h +++ b/samples/learn/schema/StarWarsSchema.h @@ -30,8 +30,8 @@ enum class Episode struct ReviewInput { - int stars; - std::optional commentary; + int stars {}; + std::optional commentary {}; }; namespace object { diff --git a/samples/today/nointrospection/TodaySchema.h b/samples/today/nointrospection/TodaySchema.h index 053a5157..bb0834b2 100644 --- a/samples/today/nointrospection/TodaySchema.h +++ b/samples/today/nointrospection/TodaySchema.h @@ -31,33 +31,33 @@ enum class TaskState struct CompleteTaskInput { - response::IdType id; - std::optional testTaskState; - std::optional isComplete; - std::optional clientMutationId; + response::IdType id {}; + std::optional testTaskState {}; + std::optional isComplete {}; + std::optional clientMutationId {}; }; struct ThirdNestedInput { - response::IdType id; + response::IdType id {}; }; struct FourthNestedInput { - response::IdType id; + response::IdType id {}; }; struct SecondNestedInput { - response::IdType id; - ThirdNestedInput third; + response::IdType id {}; + ThirdNestedInput third {}; }; struct FirstNestedInput { - response::IdType id; - SecondNestedInput second; - ThirdNestedInput third; + response::IdType id {}; + SecondNestedInput second {}; + ThirdNestedInput third {}; }; namespace object { diff --git a/samples/today/schema/TodaySchema.h b/samples/today/schema/TodaySchema.h index 053a5157..bb0834b2 100644 --- a/samples/today/schema/TodaySchema.h +++ b/samples/today/schema/TodaySchema.h @@ -31,33 +31,33 @@ enum class TaskState struct CompleteTaskInput { - response::IdType id; - std::optional testTaskState; - std::optional isComplete; - std::optional clientMutationId; + response::IdType id {}; + std::optional testTaskState {}; + std::optional isComplete {}; + std::optional clientMutationId {}; }; struct ThirdNestedInput { - response::IdType id; + response::IdType id {}; }; struct FourthNestedInput { - response::IdType id; + response::IdType id {}; }; struct SecondNestedInput { - response::IdType id; - ThirdNestedInput third; + response::IdType id {}; + ThirdNestedInput third {}; }; struct FirstNestedInput { - response::IdType id; - SecondNestedInput second; - ThirdNestedInput third; + response::IdType id {}; + SecondNestedInput second {}; + ThirdNestedInput third {}; }; namespace object { diff --git a/samples/validation/schema/ValidationSchema.h b/samples/validation/schema/ValidationSchema.h index 98d554ce..129ac91e 100644 --- a/samples/validation/schema/ValidationSchema.h +++ b/samples/validation/schema/ValidationSchema.h @@ -35,8 +35,8 @@ enum class CatCommand struct ComplexInput { - std::optional name; - std::optional owner; + std::optional name {}; + std::optional owner {}; }; namespace object { diff --git a/src/SchemaGenerator.cpp b/src/SchemaGenerator.cpp index 3ff453f0..8a0ca86e 100644 --- a/src/SchemaGenerator.cpp +++ b/src/SchemaGenerator.cpp @@ -208,7 +208,7 @@ static_assert(graphql::internal::MinorVersion == )cpp" )cpp"; for (const auto& inputField : inputType.fields) { - headerFile << getFieldDeclaration(inputField) << R"cpp(; + headerFile << getFieldDeclaration(inputField) << R"cpp( {}; )cpp"; } headerFile << R"cpp(}; From 70e804fd34a0f0196c91db3a0c35924a677fded8 Mon Sep 17 00:00:00 2001 From: Bill Avery Date: Thu, 16 Dec 2021 10:51:19 -0800 Subject: [PATCH 119/119] Fix scope of headerPath and sourcePath variables --- src/SchemaGenerator.cpp | 331 +++++++++++++++++++--------------------- 1 file changed, 153 insertions(+), 178 deletions(-) diff --git a/src/SchemaGenerator.cpp b/src/SchemaGenerator.cpp index 8a0ca86e..4c0c72c0 100644 --- a/src/SchemaGenerator.cpp +++ b/src/SchemaGenerator.cpp @@ -2654,93 +2654,87 @@ std::vector Generator::outputSeparateFiles() const noexcept } } + std::ostringstream ossNamespace; + + ossNamespace << R"cpp(graphql::)cpp" << _loader.getSchemaNamespace(); + + const auto schemaNamespace = ossNamespace.str(); + std::ostringstream ossInterfaceNamespace; + + ossInterfaceNamespace << schemaNamespace << R"cpp(::object)cpp"; + + const auto objectNamespace = ossInterfaceNamespace.str(); + for (const auto& interfaceType : _loader.getInterfaceTypes()) { const auto headerFilename = std::string(interfaceType.cppType) + "Object.h"; auto headerPath = (headerDir / headerFilename).string(); - std::ofstream headerFile(headerPath, std::ios_base::trunc); - IncludeGuardScope includeGuard { headerFile, headerFilename }; - - headerFile << R"cpp(#include ")cpp" - << std::filesystem::path(_headerPath).filename().string() << R"cpp(" - -)cpp"; - - std::ostringstream ossNamespace; - ossNamespace << R"cpp(graphql::)cpp" << _loader.getSchemaNamespace(); + { + std::ofstream headerFile(headerPath, std::ios_base::trunc); + IncludeGuardScope includeGuard { headerFile, headerFilename }; - const auto schemaNamespace = ossNamespace.str(); - std::ostringstream ossInterfaceNamespace; + headerFile << R"cpp(#include ")cpp" + << std::filesystem::path(_headerPath).filename().string() << R"cpp(" - ossInterfaceNamespace << schemaNamespace << R"cpp(::object)cpp"; +)cpp"; - const auto objectNamespace = ossInterfaceNamespace.str(); - NamespaceScope headerNamespace { headerFile, objectNamespace }; + NamespaceScope headerNamespace { headerFile, objectNamespace }; - // Output the full declaration - headerFile << std::endl; - outputInterfaceDeclaration(headerFile, interfaceType.cppType); - headerFile << std::endl; + // Output the full declaration + headerFile << std::endl; + outputInterfaceDeclaration(headerFile, interfaceType.cppType); + headerFile << std::endl; - if (_options.verbose) - { - files.push_back(std::move(headerPath)); + if (_options.verbose) + { + files.push_back(std::move(headerPath)); + } } const auto sourceFilename = std::string(interfaceType.cppType) + "Object.cpp"; auto sourcePath = (sourceDir / sourceFilename).string(); - std::ofstream sourceFile(sourcePath, std::ios_base::trunc); - sourceFile << R"cpp(// Copyright (c) Microsoft Corporation. All rights reserved. + { + std::ofstream sourceFile(sourcePath, std::ios_base::trunc); + + sourceFile << R"cpp(// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. // WARNING! Do not edit this file manually, your changes will be overwritten. #include ")cpp" << headerFilename - << R"cpp(" -)cpp"; + << R"cpp(" - if (_loader.isIntrospection()) - { - sourceFile << R"cpp( -#include "graphqlservice/internal/Introspection.h" -)cpp"; - } - else - { - sourceFile << R"cpp( #include "graphqlservice/internal/Schema.h" #include "graphqlservice/introspection/IntrospectionSchema.h" -)cpp"; - } - sourceFile << R"cpp( using namespace std::literals; )cpp"; - NamespaceScope sourceSchemaNamespace { sourceFile, schemaNamespace }; - NamespaceScope sourceInterfaceNamespace { sourceFile, "object" }; + NamespaceScope sourceSchemaNamespace { sourceFile, schemaNamespace }; + NamespaceScope sourceInterfaceNamespace { sourceFile, "object" }; - sourceFile << std::endl; - outputInterfaceImplementation(sourceFile, interfaceType.cppType); - sourceFile << std::endl; + sourceFile << std::endl; + outputInterfaceImplementation(sourceFile, interfaceType.cppType); + sourceFile << std::endl; - sourceInterfaceNamespace.exit(); - sourceFile << std::endl; + sourceInterfaceNamespace.exit(); + sourceFile << std::endl; - sourceFile << R"cpp(void Add)cpp" << interfaceType.cppType - << R"cpp(Details(const std::shared_ptr& type)cpp" - << interfaceType.cppType - << R"cpp(, const std::shared_ptr& schema) + sourceFile << R"cpp(void Add)cpp" << interfaceType.cppType + << R"cpp(Details(const std::shared_ptr& type)cpp" + << interfaceType.cppType + << R"cpp(, const std::shared_ptr& schema) { )cpp"; - outputInterfaceIntrospection(sourceFile, interfaceType); - sourceFile << R"cpp(} + outputInterfaceIntrospection(sourceFile, interfaceType); + sourceFile << R"cpp(} )cpp"; + } files.push_back(std::move(sourcePath)); } @@ -2749,30 +2743,23 @@ using namespace std::literals; { const auto headerFilename = std::string(unionType.cppType) + "Object.h"; auto headerPath = (headerDir / headerFilename).string(); - std::ofstream headerFile(headerPath, std::ios_base::trunc); - IncludeGuardScope includeGuard { headerFile, headerFilename }; - - headerFile << R"cpp(#include ")cpp" - << std::filesystem::path(_headerPath).filename().string() << R"cpp(" -)cpp"; - - std::ostringstream ossNamespace; - - ossNamespace << R"cpp(graphql::)cpp" << _loader.getSchemaNamespace(); + { + std::ofstream headerFile(headerPath, std::ios_base::trunc); + IncludeGuardScope includeGuard { headerFile, headerFilename }; - const auto schemaNamespace = ossNamespace.str(); - std::ostringstream ossUnionNamespace; + headerFile << R"cpp(#include ")cpp" + << std::filesystem::path(_headerPath).filename().string() << R"cpp(" - ossUnionNamespace << schemaNamespace << R"cpp(::object)cpp"; +)cpp"; - const auto objectNamespace = ossUnionNamespace.str(); - NamespaceScope headerNamespace { headerFile, objectNamespace }; + NamespaceScope headerNamespace { headerFile, objectNamespace }; - // Output the full declaration - headerFile << std::endl; - outputInterfaceDeclaration(headerFile, unionType.cppType); - headerFile << std::endl; + // Output the full declaration + headerFile << std::endl; + outputInterfaceDeclaration(headerFile, unionType.cppType); + headerFile << std::endl; + } if (_options.verbose) { @@ -2781,56 +2768,47 @@ using namespace std::literals; const auto sourceFilename = std::string(unionType.cppType) + "Object.cpp"; auto sourcePath = (sourceDir / sourceFilename).string(); - std::ofstream sourceFile(sourcePath, std::ios_base::trunc); - sourceFile << R"cpp(// Copyright (c) Microsoft Corporation. All rights reserved. + { + std::ofstream sourceFile(sourcePath, std::ios_base::trunc); + + sourceFile << R"cpp(// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. // WARNING! Do not edit this file manually, your changes will be overwritten. #include ")cpp" << headerFilename - << R"cpp(" -)cpp"; + << R"cpp(" - if (_loader.isIntrospection()) - { - sourceFile << R"cpp( -#include "graphqlservice/internal/Introspection.h" -)cpp"; - } - else - { - sourceFile << R"cpp( #include "graphqlservice/internal/Schema.h" #include "graphqlservice/introspection/IntrospectionSchema.h" -)cpp"; - } - sourceFile << R"cpp( using namespace std::literals; )cpp"; - NamespaceScope sourceSchemaNamespace { sourceFile, schemaNamespace }; - NamespaceScope sourceUnionNamespace { sourceFile, "object" }; + NamespaceScope sourceSchemaNamespace { sourceFile, schemaNamespace }; + NamespaceScope sourceUnionNamespace { sourceFile, "object" }; - sourceFile << std::endl; - outputInterfaceImplementation(sourceFile, unionType.cppType); - sourceFile << std::endl; + sourceFile << std::endl; + outputInterfaceImplementation(sourceFile, unionType.cppType); + sourceFile << std::endl; - sourceUnionNamespace.exit(); - sourceFile << std::endl; + sourceUnionNamespace.exit(); + sourceFile << std::endl; - sourceFile << R"cpp(void Add)cpp" << unionType.cppType - << R"cpp(Details(const std::shared_ptr& type)cpp" - << unionType.cppType << R"cpp(, const std::shared_ptr& schema) + sourceFile << R"cpp(void Add)cpp" << unionType.cppType + << R"cpp(Details(const std::shared_ptr& type)cpp" + << unionType.cppType + << R"cpp(, const std::shared_ptr& schema) { )cpp"; - outputUnionIntrospection(sourceFile, unionType); - sourceFile << R"cpp(} + outputUnionIntrospection(sourceFile, unionType); + sourceFile << R"cpp(} )cpp"; + } files.push_back(std::move(sourcePath)); } @@ -2840,55 +2818,48 @@ using namespace std::literals; const bool isQueryType = objectType.type == queryType; const auto headerFilename = std::string(objectType.cppType) + "Object.h"; auto headerPath = (headerDir / headerFilename).string(); - std::ofstream headerFile(headerPath, std::ios_base::trunc); - IncludeGuardScope includeGuard { headerFile, headerFilename }; - headerFile << R"cpp(#include ")cpp" - << std::filesystem::path(_headerPath).filename().string() << R"cpp(" + { + std::ofstream headerFile(headerPath, std::ios_base::trunc); + IncludeGuardScope includeGuard { headerFile, headerFilename }; + + headerFile << R"cpp(#include ")cpp" + << std::filesystem::path(_headerPath).filename().string() << R"cpp(" )cpp"; - std::ostringstream ossNamespace; + NamespaceScope headerNamespace { headerFile, objectNamespace }; - ossNamespace << R"cpp(graphql::)cpp" << _loader.getSchemaNamespace(); + if (!_loader.isIntrospection()) + { + if (!objectType.interfaces.empty() || !objectType.unions.empty()) + { + NamespaceScope implementsNamespace { headerFile, R"cpp(implements)cpp" }; - const auto schemaNamespace = ossNamespace.str(); - std::ostringstream ossObjectNamespace; + headerFile << std::endl; + outputObjectImplements(headerFile, objectType); - ossObjectNamespace << schemaNamespace << R"cpp(::object)cpp"; + implementsNamespace.exit(); + headerFile << std::endl; + } - const auto objectNamespace = ossObjectNamespace.str(); - NamespaceScope headerNamespace { headerFile, objectNamespace }; + // Output the stub concepts + std::ostringstream ossConceptNamespace; - if (!_loader.isIntrospection()) - { - if (!objectType.interfaces.empty() || !objectType.unions.empty()) - { - NamespaceScope implementsNamespace { headerFile, R"cpp(implements)cpp" }; + ossConceptNamespace << R"cpp(methods::)cpp" << objectType.cppType << R"cpp(Has)cpp"; - headerFile << std::endl; - outputObjectImplements(headerFile, objectType); + const auto conceptNamespace = ossConceptNamespace.str(); + NamespaceScope stubNamespace { headerFile, conceptNamespace }; - implementsNamespace.exit(); - headerFile << std::endl; + outputObjectStubs(headerFile, objectType); } - // Output the stub concepts - std::ostringstream ossConceptNamespace; - - ossConceptNamespace << R"cpp(methods::)cpp" << objectType.cppType << R"cpp(Has)cpp"; - - const auto conceptNamespace = ossConceptNamespace.str(); - NamespaceScope stubNamespace { headerFile, conceptNamespace }; - - outputObjectStubs(headerFile, objectType); + // Output the full declaration + headerFile << std::endl; + outputObjectDeclaration(headerFile, objectType, isQueryType); + headerFile << std::endl; } - // Output the full declaration - headerFile << std::endl; - outputObjectDeclaration(headerFile, objectType, isQueryType); - headerFile << std::endl; - if (_options.verbose) { files.push_back(std::move(headerPath)); @@ -2896,63 +2867,65 @@ using namespace std::literals; const auto sourceFilename = std::string(objectType.cppType) + "Object.cpp"; auto sourcePath = (sourceDir / sourceFilename).string(); - std::ofstream sourceFile(sourcePath, std::ios_base::trunc); - sourceFile << R"cpp(// Copyright (c) Microsoft Corporation. All rights reserved. + { + std::ofstream sourceFile(sourcePath, std::ios_base::trunc); + + sourceFile << R"cpp(// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. // WARNING! Do not edit this file manually, your changes will be overwritten. #include ")cpp" << headerFilename - << R"cpp(" + << R"cpp(" )cpp"; - std::unordered_set includedObjects; + std::unordered_set includedObjects; - for (const auto& field : objectType.fields) - { - switch (field.fieldType) + for (const auto& field : objectType.fields) { - case OutputFieldType::Interface: - case OutputFieldType::Union: - case OutputFieldType::Object: - if (includedObjects.insert(field.type).second) - { - sourceFile << R"cpp(#include ")cpp" << _loader.getSafeCppName(field.type) - << R"cpp(Object.h" -)cpp"; - } - break; - - default: - break; + switch (field.fieldType) + { + case OutputFieldType::Interface: + case OutputFieldType::Union: + case OutputFieldType::Object: + if (includedObjects.insert(field.type).second) + { + sourceFile << R"cpp(#include ")cpp" + << _loader.getSafeCppName(field.type) << R"cpp(Object.h" +)cpp"; + } + break; + + default: + break; + } } - } - if (_loader.isIntrospection() || (isQueryType && !_options.noIntrospection)) - { - sourceFile << R"cpp( + if (_loader.isIntrospection() || (isQueryType && !_options.noIntrospection)) + { + sourceFile << R"cpp( #include "graphqlservice/internal/Introspection.h" )cpp"; - } - else - { - sourceFile << R"cpp( + } + else + { + sourceFile << R"cpp( #include "graphqlservice/internal/Schema.h" #include "graphqlservice/introspection/IntrospectionSchema.h" )cpp"; - } + } - if (isQueryType && !_options.noIntrospection) - { - sourceFile << R"cpp( + if (isQueryType && !_options.noIntrospection) + { + sourceFile << R"cpp( #include "graphqlservice/introspection/SchemaObject.h" #include "graphqlservice/introspection/TypeObject.h" )cpp"; - } + } - sourceFile << R"cpp( + sourceFile << R"cpp( #include #include #include @@ -2963,25 +2936,27 @@ using namespace std::literals; )cpp"; - NamespaceScope sourceSchemaNamespace { sourceFile, schemaNamespace }; - NamespaceScope sourceObjectNamespace { sourceFile, "object" }; + NamespaceScope sourceSchemaNamespace { sourceFile, schemaNamespace }; + NamespaceScope sourceObjectNamespace { sourceFile, "object" }; - sourceFile << std::endl; - outputObjectImplementation(sourceFile, objectType, isQueryType); - sourceFile << std::endl; + sourceFile << std::endl; + outputObjectImplementation(sourceFile, objectType, isQueryType); + sourceFile << std::endl; - sourceObjectNamespace.exit(); - sourceFile << std::endl; + sourceObjectNamespace.exit(); + sourceFile << std::endl; - sourceFile << R"cpp(void Add)cpp" << objectType.cppType - << R"cpp(Details(const std::shared_ptr& type)cpp" - << objectType.cppType << R"cpp(, const std::shared_ptr& schema) + sourceFile << R"cpp(void Add)cpp" << objectType.cppType + << R"cpp(Details(const std::shared_ptr& type)cpp" + << objectType.cppType + << R"cpp(, const std::shared_ptr& schema) { )cpp"; - outputObjectIntrospection(sourceFile, objectType); - sourceFile << R"cpp(} + outputObjectIntrospection(sourceFile, objectType); + sourceFile << R"cpp(} )cpp"; + } files.push_back(std::move(sourcePath)); }