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..ebd026a1 100644 --- a/include/graphqlservice/GraphQLService.h +++ b/include/graphqlservice/GraphQLService.h @@ -295,19 +295,22 @@ 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. 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 +424,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 +813,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 +824,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. @@ -727,23 +833,17 @@ 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(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(sizeof...(Other) == 0, "None modifier should always be last"); 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( @@ -755,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)); } @@ -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,16 @@ 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) + { + ModifiedResult::validateScalar(*value); + co_return ResolverResult { response::Value { + std::shared_ptr { std::move(value) } } }; + } } co_await params.launch; @@ -833,11 +933,16 @@ 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) + { + ModifiedResult::validateScalar(*value); + co_return ResolverResult { response::Value { + std::shared_ptr { std::move(value) } } }; + } } std::vector children; @@ -925,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&)>; @@ -938,6 +1084,7 @@ struct ModifiedResult if (value) { + ModifiedResult::validateScalar(*value); co_return ResolverResult { response::Value { std::shared_ptr { std::move(value) } } }; } @@ -988,25 +1135,42 @@ 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); + +// 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/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..9507b218 100644 --- a/include/graphqlservice/introspection/IntrospectionSchema.h +++ b/include/graphqlservice/introspection/IntrospectionSchema.h @@ -106,13 +106,19 @@ GRAPHQLINTROSPECTION_EXPORT introspection::TypeKind ModifiedArgument GRAPHQLINTROSPECTION_EXPORT AwaitableResolver ModifiedResult::convert( - FieldResult result, ResolverParams params); + 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( - FieldResult result, ResolverParams params); + AwaitableScalar result, ResolverParams params); +template <> +GRAPHQLINTROSPECTION_EXPORT void ModifiedResult::validateScalar( + const response::Value& value); #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..f99c4fa8 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&) @@ -62,6 +62,22 @@ service::AwaitableResolver ModifiedResult::convert(service::Fiel }); } +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/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..30d1db46 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&) @@ -64,6 +64,22 @@ service::AwaitableResolver ModifiedResult::convert(service::Fi }); } +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/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..994ea7d6 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&) @@ -64,6 +64,22 @@ service::AwaitableResolver ModifiedResult::convert(service::Fi }); } +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/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..8245eead 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&) @@ -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 }; @@ -86,7 +102,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&) @@ -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 6fdb7fbf..3e4b8051 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; @@ -722,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 7425cb4e..492a736c 100644 --- a/src/SchemaGenerator.cpp +++ b/src/SchemaGenerator.cpp @@ -478,9 +478,14 @@ 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); +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() { - { service::FieldResult<)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() { - { service::FieldResult<)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( - service::FieldResult<)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 service::FieldResult<)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(); @@ -1186,7 +1188,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) { @@ -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/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..6ea44bde 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&) @@ -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, @@ -103,7 +119,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&) @@ -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 d833ce84..9507b218 100644 --- a/src/introspection/IntrospectionSchema.h +++ b/src/introspection/IntrospectionSchema.h @@ -106,13 +106,19 @@ GRAPHQLINTROSPECTION_EXPORT introspection::TypeKind ModifiedArgument GRAPHQLINTROSPECTION_EXPORT AwaitableResolver ModifiedResult::convert( - FieldResult result, ResolverParams params); + 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( - FieldResult result, ResolverParams params); + AwaitableScalar result, ResolverParams params); +template <> +GRAPHQLINTROSPECTION_EXPORT void ModifiedResult::validateScalar( + const response::Value& value); #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() }; }