@@ -897,7 +897,7 @@ struct Result
897897 AwaitableObject<std::shared_ptr<const Object>>, AwaitableScalar<Type>>;
898898
899899 // Convert a single value of the specified type to JSON.
900- [[nodiscard]] static AwaitableResolver convert (future_type result, ResolverParams params);
900+ [[nodiscard]] static AwaitableResolver convert (future_type result, ResolverParams&& params);
901901
902902 // Validate a single scalar value is the expected type.
903903 static void validateScalar (const response::Value& value);
@@ -907,25 +907,25 @@ struct Result
907907// Export all of the built-in converters
908908template <>
909909GRAPHQLSERVICE_EXPORT AwaitableResolver Result<int >::convert(
910- AwaitableScalar<int > result, ResolverParams params);
910+ AwaitableScalar<int > result, ResolverParams&& params);
911911template <>
912912GRAPHQLSERVICE_EXPORT AwaitableResolver Result<double >::convert(
913- AwaitableScalar<double > result, ResolverParams params);
913+ AwaitableScalar<double > result, ResolverParams&& params);
914914template <>
915915GRAPHQLSERVICE_EXPORT AwaitableResolver Result<std::string>::convert(
916- AwaitableScalar<std::string> result, ResolverParams params);
916+ AwaitableScalar<std::string> result, ResolverParams&& params);
917917template <>
918918GRAPHQLSERVICE_EXPORT AwaitableResolver Result<bool >::convert(
919- AwaitableScalar<bool > result, ResolverParams params);
919+ AwaitableScalar<bool > result, ResolverParams&& params);
920920template <>
921921GRAPHQLSERVICE_EXPORT AwaitableResolver Result<response::IdType>::convert(
922- AwaitableScalar<response::IdType> result, ResolverParams params);
922+ AwaitableScalar<response::IdType> result, ResolverParams&& params);
923923template <>
924924GRAPHQLSERVICE_EXPORT AwaitableResolver Result<response::Value>::convert(
925- AwaitableScalar<response::Value> result, ResolverParams params);
925+ AwaitableScalar<response::Value> result, ResolverParams&& params);
926926template <>
927927GRAPHQLSERVICE_EXPORT AwaitableResolver Result<Object>::convert(
928- AwaitableObject<std::shared_ptr<const Object>> result, ResolverParams params);
928+ AwaitableObject<std::shared_ptr<const Object>> result, ResolverParams&& params);
929929
930930// Export all of the scalar value validation methods
931931template <>
@@ -1010,7 +1010,7 @@ struct ModifiedResult
10101010 // Peel off the none modifier. If it's included, it should always be last in the list.
10111011 template <TypeModifier Modifier = TypeModifier::None, TypeModifier... Other>
10121012 [[nodiscard]] static AwaitableResolver convert (
1013- AwaitableObject<typename ResultTraits<Type>::type> result, ResolverParams params )
1013+ AwaitableObject<typename ResultTraits<Type>::type> result, ResolverParams&& paramsArg )
10141014 requires NoneObjectDerivedType<Type, Modifier>
10151015 {
10161016 // Call through to the Object specialization with a static_pointer_cast for subclasses of
@@ -1019,6 +1019,9 @@ struct ModifiedResult
10191019 static_assert (std::is_same_v<std::shared_ptr<Type>, typename ResultTraits<Type>::type>,
10201020 " this is the derived object type" );
10211021
1022+ // Move the paramsArg into a local variable before the first suspension point.
1023+ auto params = std::move (paramsArg);
1024+
10221025 co_await params.launch ;
10231026
10241027 auto awaitedResult = co_await Result<Object>::convert (
@@ -1031,7 +1034,7 @@ struct ModifiedResult
10311034 // Peel off the none modifier. If it's included, it should always be last in the list.
10321035 template <TypeModifier Modifier = TypeModifier::None, TypeModifier... Other>
10331036 [[nodiscard]] static AwaitableResolver convert (
1034- typename ResultTraits<Type>::future_type result, ResolverParams params)
1037+ typename ResultTraits<Type>::future_type result, ResolverParams&& params)
10351038 requires NoneScalarOrObjectType<Type, Modifier>
10361039 {
10371040 static_assert (sizeof ...(Other) == 0 , " None modifier should always be last" );
@@ -1043,9 +1046,13 @@ struct ModifiedResult
10431046 // Peel off final nullable modifiers for std::shared_ptr of Object and subclasses of Object.
10441047 template <TypeModifier Modifier, TypeModifier... Other>
10451048 [[nodiscard]] static AwaitableResolver convert (
1046- typename ResultTraits<Type, Modifier, Other...>::future_type result, ResolverParams params)
1049+ typename ResultTraits<Type, Modifier, Other...>::future_type result,
1050+ ResolverParams&& paramsArg)
10471051 requires NullableResultSharedPtr<Type, Modifier, Other...>
10481052 {
1053+ // Move the paramsArg into a local variable before the first suspension point.
1054+ auto params = std::move (paramsArg);
1055+
10491056 co_await params.launch ;
10501057
10511058 auto awaitedResult = co_await std::move (result);
@@ -1064,7 +1071,8 @@ struct ModifiedResult
10641071 // Peel off nullable modifiers for anything else, which should all be std::optional.
10651072 template <TypeModifier Modifier, TypeModifier... Other>
10661073 [[nodiscard]] static AwaitableResolver convert (
1067- typename ResultTraits<Type, Modifier, Other...>::future_type result, ResolverParams params)
1074+ typename ResultTraits<Type, Modifier, Other...>::future_type result,
1075+ ResolverParams&& paramsArg)
10681076 requires NullableResultOptional<Type, Modifier, Other...>
10691077 {
10701078 static_assert (std::is_same_v<std::optional<typename ResultTraits<Type, Other...>::type>,
@@ -1083,6 +1091,9 @@ struct ModifiedResult
10831091 }
10841092 }
10851093
1094+ // Move the paramsArg into a local variable before the first suspension point.
1095+ auto params = std::move (paramsArg);
1096+
10861097 co_await params.launch ;
10871098
10881099 auto awaitedResult = co_await std::move (result);
@@ -1101,7 +1112,8 @@ struct ModifiedResult
11011112 // Peel off list modifiers.
11021113 template <TypeModifier Modifier, TypeModifier... Other>
11031114 [[nodiscard]] static AwaitableResolver convert (
1104- typename ResultTraits<Type, Modifier, Other...>::future_type result, ResolverParams params)
1115+ typename ResultTraits<Type, Modifier, Other...>::future_type result,
1116+ ResolverParams&& paramsArg)
11051117 requires ListModifier<Modifier>
11061118 {
11071119 if constexpr (!ObjectBaseType<Type>)
@@ -1116,6 +1128,9 @@ struct ModifiedResult
11161128 }
11171129 }
11181130
1131+ // Move the paramsArg into a local variable before the first suspension point.
1132+ auto params = std::move (paramsArg);
1133+
11191134 std::vector<AwaitableResolver> children;
11201135 const auto parentPath = params.errorPath ;
11211136
@@ -1242,7 +1257,7 @@ struct ModifiedResult
12421257 std::function<response::Value(typename ResultTraits<Type>::type, const ResolverParams&)>;
12431258
12441259 [[nodiscard]] static AwaitableResolver resolve (typename ResultTraits<Type>::future_type result,
1245- ResolverParams params , ResolverCallback&& resolver)
1260+ ResolverParams&& paramsArg , ResolverCallback&& resolver)
12461261 {
12471262 static_assert (!ObjectBaseType<Type>, " ModfiedResult<Object> needs special handling" );
12481263
@@ -1257,6 +1272,9 @@ struct ModifiedResult
12571272 auto pendingResolver = std::move (resolver);
12581273 ResolverResult document;
12591274
1275+ // Move the paramsArg into a local variable before the first suspension point.
1276+ auto params = std::move (paramsArg);
1277+
12601278 try
12611279 {
12621280 co_await params.launch ;
0 commit comments