diff --git a/SchemaGenerator.cpp b/SchemaGenerator.cpp index 85dabe79..1b81f001 100644 --- a/SchemaGenerator.cpp +++ b/SchemaGenerator.cpp @@ -1365,7 +1365,7 @@ struct )cpp" << interfaceType.type << R"cpp( )cpp"; for (const auto& outputField : interfaceType.fields) { - headerFile << getFieldDeclaration(outputField, true); + headerFile << getFieldDeclaration(outputField, true, false); } headerFile << R"cpp(}; )cpp"; @@ -1432,10 +1432,7 @@ class )cpp" << objectType.type << R"cpp( for (const auto& outputField : objectType.fields) { - if (interfaceFields.find(outputField.name) != interfaceFields.cend()) - { - continue; - } + const bool inheritedField = interfaceFields.find(outputField.name) != interfaceFields.cend(); if (firstField) { @@ -1445,7 +1442,7 @@ class )cpp" << objectType.type << R"cpp( firstField = false; } - headerFile << getFieldDeclaration(outputField, false); + headerFile << getFieldDeclaration(outputField, false, inheritedField); } headerFile << R"cpp( @@ -1541,7 +1538,7 @@ std::string Generator::getFieldDeclaration(const InputField & inputField) const return output.str(); } -std::string Generator::getFieldDeclaration(const OutputField & outputField, bool interfaceField) const noexcept +std::string Generator::getFieldDeclaration(const OutputField & outputField, bool interfaceField, bool inheritedField) const noexcept { std::ostringstream output; std::string fieldName(outputField.name); @@ -1556,7 +1553,16 @@ std::string Generator::getFieldDeclaration(const OutputField & outputField, bool << R"cpp(&& )cpp" << argument.name << "Arg"; } - output << R"cpp() const = 0; + output << R"cpp() const)cpp"; + if (interfaceField) + { + output << R"cpp( = 0)cpp"; + } + else if (inheritedField) + { + output << R"cpp( override)cpp"; + } + output << R"cpp(; )cpp"; return output.str(); @@ -1890,6 +1896,28 @@ namespace object { fieldName[0] = static_cast(std::toupper(static_cast(fieldName[0]))); sourceFile << R"cpp( +std::future<)cpp" << getOutputCppType(outputField, false) +<< R"cpp(> )cpp" << objectType.type +<< R"cpp(::get)cpp" << fieldName +<< R"cpp((service::FieldParams&&)cpp"; + for (const auto& argument : outputField.arguments) + { + sourceFile << R"cpp(, )cpp" << getInputCppType(argument) + << R"cpp(&&)cpp"; + } + + sourceFile << R"cpp() const +{ + std::promise<)cpp" << getOutputCppType(outputField, false) + << R"cpp(> promise; + + promise.set_exception(std::make_exception_ptr(std::runtime_error(R"ex()cpp" << objectType.type + << R"cpp(::get)cpp" << fieldName + << R"cpp( is not implemented)ex"))); + + return promise.get_future(); +} + std::future )cpp" << objectType.type << R"cpp(::resolve)cpp" << fieldName << R"cpp((service::ResolverParams&& params) diff --git a/include/SchemaGenerator.h b/include/SchemaGenerator.h index 5199e7af..37499fcc 100644 --- a/include/SchemaGenerator.h +++ b/include/SchemaGenerator.h @@ -277,7 +277,7 @@ class Generator bool outputHeader() const noexcept; std::string getFieldDeclaration(const InputField& inputField) const noexcept; - std::string getFieldDeclaration(const OutputField& outputField, bool interfaceField) const noexcept; + std::string getFieldDeclaration(const OutputField& outputField, bool interfaceField, bool inheritedField) const noexcept; std::string getResolverDeclaration(const OutputField& outputField) const noexcept; bool outputSource() const noexcept; diff --git a/samples/IntrospectionSchema.cpp b/samples/IntrospectionSchema.cpp index 6a14078c..7cad955f 100644 --- a/samples/IntrospectionSchema.cpp +++ b/samples/IntrospectionSchema.cpp @@ -160,6 +160,15 @@ __Schema::__Schema() { } +std::future>> __Schema::getTypes(service::FieldParams&&) const +{ + std::promise>> promise; + + promise.set_exception(std::make_exception_ptr(std::runtime_error(R"ex(__Schema::getTypes is not implemented)ex"))); + + return promise.get_future(); +} + std::future __Schema::resolveTypes(service::ResolverParams&& params) { auto result = getTypes(service::FieldParams(params, std::move(params.fieldDirectives))); @@ -167,6 +176,15 @@ std::future __Schema::resolveTypes(service::ResolverParams&& pa return service::ModifiedResult<__Type>::convert(std::move(result), std::move(params)); } +std::future> __Schema::getQueryType(service::FieldParams&&) const +{ + std::promise> promise; + + promise.set_exception(std::make_exception_ptr(std::runtime_error(R"ex(__Schema::getQueryType is not implemented)ex"))); + + return promise.get_future(); +} + std::future __Schema::resolveQueryType(service::ResolverParams&& params) { auto result = getQueryType(service::FieldParams(params, std::move(params.fieldDirectives))); @@ -174,6 +192,15 @@ std::future __Schema::resolveQueryType(service::ResolverParams& return service::ModifiedResult<__Type>::convert(std::move(result), std::move(params)); } +std::future> __Schema::getMutationType(service::FieldParams&&) const +{ + std::promise> promise; + + promise.set_exception(std::make_exception_ptr(std::runtime_error(R"ex(__Schema::getMutationType is not implemented)ex"))); + + return promise.get_future(); +} + std::future __Schema::resolveMutationType(service::ResolverParams&& params) { auto result = getMutationType(service::FieldParams(params, std::move(params.fieldDirectives))); @@ -181,6 +208,15 @@ std::future __Schema::resolveMutationType(service::ResolverPara return service::ModifiedResult<__Type>::convert(std::move(result), std::move(params)); } +std::future> __Schema::getSubscriptionType(service::FieldParams&&) const +{ + std::promise> promise; + + promise.set_exception(std::make_exception_ptr(std::runtime_error(R"ex(__Schema::getSubscriptionType is not implemented)ex"))); + + return promise.get_future(); +} + std::future __Schema::resolveSubscriptionType(service::ResolverParams&& params) { auto result = getSubscriptionType(service::FieldParams(params, std::move(params.fieldDirectives))); @@ -188,6 +224,15 @@ std::future __Schema::resolveSubscriptionType(service::Resolver return service::ModifiedResult<__Type>::convert(std::move(result), std::move(params)); } +std::future>> __Schema::getDirectives(service::FieldParams&&) const +{ + std::promise>> promise; + + promise.set_exception(std::make_exception_ptr(std::runtime_error(R"ex(__Schema::getDirectives is not implemented)ex"))); + + return promise.get_future(); +} + std::future __Schema::resolveDirectives(service::ResolverParams&& params) { auto result = getDirectives(service::FieldParams(params, std::move(params.fieldDirectives))); @@ -222,6 +267,15 @@ __Type::__Type() { } +std::future<__TypeKind> __Type::getKind(service::FieldParams&&) const +{ + std::promise<__TypeKind> promise; + + promise.set_exception(std::make_exception_ptr(std::runtime_error(R"ex(__Type::getKind is not implemented)ex"))); + + return promise.get_future(); +} + std::future __Type::resolveKind(service::ResolverParams&& params) { auto result = getKind(service::FieldParams(params, std::move(params.fieldDirectives))); @@ -229,6 +283,15 @@ std::future __Type::resolveKind(service::ResolverParams&& param return service::ModifiedResult<__TypeKind>::convert(std::move(result), std::move(params)); } +std::future> __Type::getName(service::FieldParams&&) const +{ + std::promise> promise; + + promise.set_exception(std::make_exception_ptr(std::runtime_error(R"ex(__Type::getName is not implemented)ex"))); + + return promise.get_future(); +} + std::future __Type::resolveName(service::ResolverParams&& params) { auto result = getName(service::FieldParams(params, std::move(params.fieldDirectives))); @@ -236,6 +299,15 @@ std::future __Type::resolveName(service::ResolverParams&& param return service::ModifiedResult::convert(std::move(result), std::move(params)); } +std::future> __Type::getDescription(service::FieldParams&&) const +{ + std::promise> promise; + + promise.set_exception(std::make_exception_ptr(std::runtime_error(R"ex(__Type::getDescription is not implemented)ex"))); + + return promise.get_future(); +} + std::future __Type::resolveDescription(service::ResolverParams&& params) { auto result = getDescription(service::FieldParams(params, std::move(params.fieldDirectives))); @@ -243,6 +315,15 @@ std::future __Type::resolveDescription(service::ResolverParams& return service::ModifiedResult::convert(std::move(result), std::move(params)); } +std::future>>> __Type::getFields(service::FieldParams&&, std::unique_ptr&&) const +{ + std::promise>>> promise; + + promise.set_exception(std::make_exception_ptr(std::runtime_error(R"ex(__Type::getFields is not implemented)ex"))); + + return promise.get_future(); +} + std::future __Type::resolveFields(service::ResolverParams&& params) { const auto defaultArguments = []() @@ -265,6 +346,15 @@ std::future __Type::resolveFields(service::ResolverParams&& par return service::ModifiedResult<__Field>::convert(std::move(result), std::move(params)); } +std::future>>> __Type::getInterfaces(service::FieldParams&&) const +{ + std::promise>>> promise; + + promise.set_exception(std::make_exception_ptr(std::runtime_error(R"ex(__Type::getInterfaces is not implemented)ex"))); + + return promise.get_future(); +} + std::future __Type::resolveInterfaces(service::ResolverParams&& params) { auto result = getInterfaces(service::FieldParams(params, std::move(params.fieldDirectives))); @@ -272,6 +362,15 @@ std::future __Type::resolveInterfaces(service::ResolverParams&& return service::ModifiedResult<__Type>::convert(std::move(result), std::move(params)); } +std::future>>> __Type::getPossibleTypes(service::FieldParams&&) const +{ + std::promise>>> promise; + + promise.set_exception(std::make_exception_ptr(std::runtime_error(R"ex(__Type::getPossibleTypes is not implemented)ex"))); + + return promise.get_future(); +} + std::future __Type::resolvePossibleTypes(service::ResolverParams&& params) { auto result = getPossibleTypes(service::FieldParams(params, std::move(params.fieldDirectives))); @@ -279,6 +378,15 @@ std::future __Type::resolvePossibleTypes(service::ResolverParam return service::ModifiedResult<__Type>::convert(std::move(result), std::move(params)); } +std::future>>> __Type::getEnumValues(service::FieldParams&&, std::unique_ptr&&) const +{ + std::promise>>> promise; + + promise.set_exception(std::make_exception_ptr(std::runtime_error(R"ex(__Type::getEnumValues is not implemented)ex"))); + + return promise.get_future(); +} + std::future __Type::resolveEnumValues(service::ResolverParams&& params) { const auto defaultArguments = []() @@ -301,6 +409,15 @@ std::future __Type::resolveEnumValues(service::ResolverParams&& return service::ModifiedResult<__EnumValue>::convert(std::move(result), std::move(params)); } +std::future>>> __Type::getInputFields(service::FieldParams&&) const +{ + std::promise>>> promise; + + promise.set_exception(std::make_exception_ptr(std::runtime_error(R"ex(__Type::getInputFields is not implemented)ex"))); + + return promise.get_future(); +} + std::future __Type::resolveInputFields(service::ResolverParams&& params) { auto result = getInputFields(service::FieldParams(params, std::move(params.fieldDirectives))); @@ -308,6 +425,15 @@ std::future __Type::resolveInputFields(service::ResolverParams& return service::ModifiedResult<__InputValue>::convert(std::move(result), std::move(params)); } +std::future> __Type::getOfType(service::FieldParams&&) const +{ + std::promise> promise; + + promise.set_exception(std::make_exception_ptr(std::runtime_error(R"ex(__Type::getOfType is not implemented)ex"))); + + return promise.get_future(); +} + std::future __Type::resolveOfType(service::ResolverParams&& params) { auto result = getOfType(service::FieldParams(params, std::move(params.fieldDirectives))); @@ -339,6 +465,15 @@ __Field::__Field() { } +std::future __Field::getName(service::FieldParams&&) const +{ + std::promise promise; + + promise.set_exception(std::make_exception_ptr(std::runtime_error(R"ex(__Field::getName is not implemented)ex"))); + + return promise.get_future(); +} + std::future __Field::resolveName(service::ResolverParams&& params) { auto result = getName(service::FieldParams(params, std::move(params.fieldDirectives))); @@ -346,6 +481,15 @@ std::future __Field::resolveName(service::ResolverParams&& para return service::ModifiedResult::convert(std::move(result), std::move(params)); } +std::future> __Field::getDescription(service::FieldParams&&) const +{ + std::promise> promise; + + promise.set_exception(std::make_exception_ptr(std::runtime_error(R"ex(__Field::getDescription is not implemented)ex"))); + + return promise.get_future(); +} + std::future __Field::resolveDescription(service::ResolverParams&& params) { auto result = getDescription(service::FieldParams(params, std::move(params.fieldDirectives))); @@ -353,6 +497,15 @@ std::future __Field::resolveDescription(service::ResolverParams return service::ModifiedResult::convert(std::move(result), std::move(params)); } +std::future>> __Field::getArgs(service::FieldParams&&) const +{ + std::promise>> promise; + + promise.set_exception(std::make_exception_ptr(std::runtime_error(R"ex(__Field::getArgs is not implemented)ex"))); + + return promise.get_future(); +} + std::future __Field::resolveArgs(service::ResolverParams&& params) { auto result = getArgs(service::FieldParams(params, std::move(params.fieldDirectives))); @@ -360,6 +513,15 @@ std::future __Field::resolveArgs(service::ResolverParams&& para return service::ModifiedResult<__InputValue>::convert(std::move(result), std::move(params)); } +std::future> __Field::getType(service::FieldParams&&) const +{ + std::promise> promise; + + promise.set_exception(std::make_exception_ptr(std::runtime_error(R"ex(__Field::getType is not implemented)ex"))); + + return promise.get_future(); +} + std::future __Field::resolveType(service::ResolverParams&& params) { auto result = getType(service::FieldParams(params, std::move(params.fieldDirectives))); @@ -367,6 +529,15 @@ std::future __Field::resolveType(service::ResolverParams&& para return service::ModifiedResult<__Type>::convert(std::move(result), std::move(params)); } +std::future __Field::getIsDeprecated(service::FieldParams&&) const +{ + std::promise promise; + + promise.set_exception(std::make_exception_ptr(std::runtime_error(R"ex(__Field::getIsDeprecated is not implemented)ex"))); + + return promise.get_future(); +} + std::future __Field::resolveIsDeprecated(service::ResolverParams&& params) { auto result = getIsDeprecated(service::FieldParams(params, std::move(params.fieldDirectives))); @@ -374,6 +545,15 @@ std::future __Field::resolveIsDeprecated(service::ResolverParam return service::ModifiedResult::convert(std::move(result), std::move(params)); } +std::future> __Field::getDeprecationReason(service::FieldParams&&) const +{ + std::promise> promise; + + promise.set_exception(std::make_exception_ptr(std::runtime_error(R"ex(__Field::getDeprecationReason is not implemented)ex"))); + + return promise.get_future(); +} + std::future __Field::resolveDeprecationReason(service::ResolverParams&& params) { auto result = getDeprecationReason(service::FieldParams(params, std::move(params.fieldDirectives))); @@ -403,6 +583,15 @@ __InputValue::__InputValue() { } +std::future __InputValue::getName(service::FieldParams&&) const +{ + std::promise promise; + + promise.set_exception(std::make_exception_ptr(std::runtime_error(R"ex(__InputValue::getName is not implemented)ex"))); + + return promise.get_future(); +} + std::future __InputValue::resolveName(service::ResolverParams&& params) { auto result = getName(service::FieldParams(params, std::move(params.fieldDirectives))); @@ -410,6 +599,15 @@ std::future __InputValue::resolveName(service::ResolverParams&& return service::ModifiedResult::convert(std::move(result), std::move(params)); } +std::future> __InputValue::getDescription(service::FieldParams&&) const +{ + std::promise> promise; + + promise.set_exception(std::make_exception_ptr(std::runtime_error(R"ex(__InputValue::getDescription is not implemented)ex"))); + + return promise.get_future(); +} + std::future __InputValue::resolveDescription(service::ResolverParams&& params) { auto result = getDescription(service::FieldParams(params, std::move(params.fieldDirectives))); @@ -417,6 +615,15 @@ std::future __InputValue::resolveDescription(service::ResolverP return service::ModifiedResult::convert(std::move(result), std::move(params)); } +std::future> __InputValue::getType(service::FieldParams&&) const +{ + std::promise> promise; + + promise.set_exception(std::make_exception_ptr(std::runtime_error(R"ex(__InputValue::getType is not implemented)ex"))); + + return promise.get_future(); +} + std::future __InputValue::resolveType(service::ResolverParams&& params) { auto result = getType(service::FieldParams(params, std::move(params.fieldDirectives))); @@ -424,6 +631,15 @@ std::future __InputValue::resolveType(service::ResolverParams&& return service::ModifiedResult<__Type>::convert(std::move(result), std::move(params)); } +std::future> __InputValue::getDefaultValue(service::FieldParams&&) const +{ + std::promise> promise; + + promise.set_exception(std::make_exception_ptr(std::runtime_error(R"ex(__InputValue::getDefaultValue is not implemented)ex"))); + + return promise.get_future(); +} + std::future __InputValue::resolveDefaultValue(service::ResolverParams&& params) { auto result = getDefaultValue(service::FieldParams(params, std::move(params.fieldDirectives))); @@ -453,6 +669,15 @@ __EnumValue::__EnumValue() { } +std::future __EnumValue::getName(service::FieldParams&&) const +{ + std::promise promise; + + promise.set_exception(std::make_exception_ptr(std::runtime_error(R"ex(__EnumValue::getName is not implemented)ex"))); + + return promise.get_future(); +} + std::future __EnumValue::resolveName(service::ResolverParams&& params) { auto result = getName(service::FieldParams(params, std::move(params.fieldDirectives))); @@ -460,6 +685,15 @@ std::future __EnumValue::resolveName(service::ResolverParams&& return service::ModifiedResult::convert(std::move(result), std::move(params)); } +std::future> __EnumValue::getDescription(service::FieldParams&&) const +{ + std::promise> promise; + + promise.set_exception(std::make_exception_ptr(std::runtime_error(R"ex(__EnumValue::getDescription is not implemented)ex"))); + + return promise.get_future(); +} + std::future __EnumValue::resolveDescription(service::ResolverParams&& params) { auto result = getDescription(service::FieldParams(params, std::move(params.fieldDirectives))); @@ -467,6 +701,15 @@ std::future __EnumValue::resolveDescription(service::ResolverPa return service::ModifiedResult::convert(std::move(result), std::move(params)); } +std::future __EnumValue::getIsDeprecated(service::FieldParams&&) const +{ + std::promise promise; + + promise.set_exception(std::make_exception_ptr(std::runtime_error(R"ex(__EnumValue::getIsDeprecated is not implemented)ex"))); + + return promise.get_future(); +} + std::future __EnumValue::resolveIsDeprecated(service::ResolverParams&& params) { auto result = getIsDeprecated(service::FieldParams(params, std::move(params.fieldDirectives))); @@ -474,6 +717,15 @@ std::future __EnumValue::resolveIsDeprecated(service::ResolverP return service::ModifiedResult::convert(std::move(result), std::move(params)); } +std::future> __EnumValue::getDeprecationReason(service::FieldParams&&) const +{ + std::promise> promise; + + promise.set_exception(std::make_exception_ptr(std::runtime_error(R"ex(__EnumValue::getDeprecationReason is not implemented)ex"))); + + return promise.get_future(); +} + std::future __EnumValue::resolveDeprecationReason(service::ResolverParams&& params) { auto result = getDeprecationReason(service::FieldParams(params, std::move(params.fieldDirectives))); @@ -503,6 +755,15 @@ __Directive::__Directive() { } +std::future __Directive::getName(service::FieldParams&&) const +{ + std::promise promise; + + promise.set_exception(std::make_exception_ptr(std::runtime_error(R"ex(__Directive::getName is not implemented)ex"))); + + return promise.get_future(); +} + std::future __Directive::resolveName(service::ResolverParams&& params) { auto result = getName(service::FieldParams(params, std::move(params.fieldDirectives))); @@ -510,6 +771,15 @@ std::future __Directive::resolveName(service::ResolverParams&& return service::ModifiedResult::convert(std::move(result), std::move(params)); } +std::future> __Directive::getDescription(service::FieldParams&&) const +{ + std::promise> promise; + + promise.set_exception(std::make_exception_ptr(std::runtime_error(R"ex(__Directive::getDescription is not implemented)ex"))); + + return promise.get_future(); +} + std::future __Directive::resolveDescription(service::ResolverParams&& params) { auto result = getDescription(service::FieldParams(params, std::move(params.fieldDirectives))); @@ -517,6 +787,15 @@ std::future __Directive::resolveDescription(service::ResolverPa return service::ModifiedResult::convert(std::move(result), std::move(params)); } +std::future> __Directive::getLocations(service::FieldParams&&) const +{ + std::promise> promise; + + promise.set_exception(std::make_exception_ptr(std::runtime_error(R"ex(__Directive::getLocations is not implemented)ex"))); + + return promise.get_future(); +} + std::future __Directive::resolveLocations(service::ResolverParams&& params) { auto result = getLocations(service::FieldParams(params, std::move(params.fieldDirectives))); @@ -524,6 +803,15 @@ std::future __Directive::resolveLocations(service::ResolverPara return service::ModifiedResult<__DirectiveLocation>::convert(std::move(result), std::move(params)); } +std::future>> __Directive::getArgs(service::FieldParams&&) const +{ + std::promise>> promise; + + promise.set_exception(std::make_exception_ptr(std::runtime_error(R"ex(__Directive::getArgs is not implemented)ex"))); + + return promise.get_future(); +} + std::future __Directive::resolveArgs(service::ResolverParams&& params) { auto result = getArgs(service::FieldParams(params, std::move(params.fieldDirectives))); diff --git a/samples/IntrospectionSchema.h b/samples/IntrospectionSchema.h index a32c923c..2f18ead5 100644 --- a/samples/IntrospectionSchema.h +++ b/samples/IntrospectionSchema.h @@ -65,11 +65,11 @@ class __Schema __Schema(); public: - virtual std::future>> getTypes(service::FieldParams&& params) const = 0; - virtual std::future> getQueryType(service::FieldParams&& params) const = 0; - virtual std::future> getMutationType(service::FieldParams&& params) const = 0; - virtual std::future> getSubscriptionType(service::FieldParams&& params) const = 0; - virtual std::future>> getDirectives(service::FieldParams&& params) const = 0; + virtual std::future>> getTypes(service::FieldParams&& params) const; + virtual std::future> getQueryType(service::FieldParams&& params) const; + virtual std::future> getMutationType(service::FieldParams&& params) const; + virtual std::future> getSubscriptionType(service::FieldParams&& params) const; + virtual std::future>> getDirectives(service::FieldParams&& params) const; private: std::future resolveTypes(service::ResolverParams&& params); @@ -88,15 +88,15 @@ class __Type __Type(); public: - virtual std::future<__TypeKind> getKind(service::FieldParams&& params) const = 0; - virtual std::future> getName(service::FieldParams&& params) const = 0; - virtual std::future> getDescription(service::FieldParams&& params) const = 0; - virtual std::future>>> getFields(service::FieldParams&& params, std::unique_ptr&& includeDeprecatedArg) const = 0; - virtual std::future>>> getInterfaces(service::FieldParams&& params) const = 0; - virtual std::future>>> getPossibleTypes(service::FieldParams&& params) const = 0; - virtual std::future>>> getEnumValues(service::FieldParams&& params, std::unique_ptr&& includeDeprecatedArg) const = 0; - virtual std::future>>> getInputFields(service::FieldParams&& params) const = 0; - virtual std::future> getOfType(service::FieldParams&& params) const = 0; + virtual std::future<__TypeKind> getKind(service::FieldParams&& params) const; + virtual std::future> getName(service::FieldParams&& params) const; + virtual std::future> getDescription(service::FieldParams&& params) const; + virtual std::future>>> getFields(service::FieldParams&& params, std::unique_ptr&& includeDeprecatedArg) const; + virtual std::future>>> getInterfaces(service::FieldParams&& params) const; + virtual std::future>>> getPossibleTypes(service::FieldParams&& params) const; + virtual std::future>>> getEnumValues(service::FieldParams&& params, std::unique_ptr&& includeDeprecatedArg) const; + virtual std::future>>> getInputFields(service::FieldParams&& params) const; + virtual std::future> getOfType(service::FieldParams&& params) const; private: std::future resolveKind(service::ResolverParams&& params); @@ -119,12 +119,12 @@ class __Field __Field(); public: - virtual std::future getName(service::FieldParams&& params) const = 0; - virtual std::future> getDescription(service::FieldParams&& params) const = 0; - virtual std::future>> getArgs(service::FieldParams&& params) const = 0; - virtual std::future> getType(service::FieldParams&& params) const = 0; - virtual std::future getIsDeprecated(service::FieldParams&& params) const = 0; - virtual std::future> getDeprecationReason(service::FieldParams&& params) const = 0; + virtual std::future getName(service::FieldParams&& params) const; + virtual std::future> getDescription(service::FieldParams&& params) const; + virtual std::future>> getArgs(service::FieldParams&& params) const; + virtual std::future> getType(service::FieldParams&& params) const; + virtual std::future getIsDeprecated(service::FieldParams&& params) const; + virtual std::future> getDeprecationReason(service::FieldParams&& params) const; private: std::future resolveName(service::ResolverParams&& params); @@ -144,10 +144,10 @@ class __InputValue __InputValue(); public: - virtual std::future getName(service::FieldParams&& params) const = 0; - virtual std::future> getDescription(service::FieldParams&& params) const = 0; - virtual std::future> getType(service::FieldParams&& params) const = 0; - virtual std::future> getDefaultValue(service::FieldParams&& params) const = 0; + virtual std::future getName(service::FieldParams&& params) const; + virtual std::future> getDescription(service::FieldParams&& params) const; + virtual std::future> getType(service::FieldParams&& params) const; + virtual std::future> getDefaultValue(service::FieldParams&& params) const; private: std::future resolveName(service::ResolverParams&& params); @@ -165,10 +165,10 @@ class __EnumValue __EnumValue(); public: - virtual std::future getName(service::FieldParams&& params) const = 0; - virtual std::future> getDescription(service::FieldParams&& params) const = 0; - virtual std::future getIsDeprecated(service::FieldParams&& params) const = 0; - virtual std::future> getDeprecationReason(service::FieldParams&& params) const = 0; + virtual std::future getName(service::FieldParams&& params) const; + virtual std::future> getDescription(service::FieldParams&& params) const; + virtual std::future getIsDeprecated(service::FieldParams&& params) const; + virtual std::future> getDeprecationReason(service::FieldParams&& params) const; private: std::future resolveName(service::ResolverParams&& params); @@ -186,10 +186,10 @@ class __Directive __Directive(); public: - virtual std::future getName(service::FieldParams&& params) const = 0; - virtual std::future> getDescription(service::FieldParams&& params) const = 0; - virtual std::future> getLocations(service::FieldParams&& params) const = 0; - virtual std::future>> getArgs(service::FieldParams&& params) const = 0; + virtual std::future getName(service::FieldParams&& params) const; + virtual std::future> getDescription(service::FieldParams&& params) const; + virtual std::future> getLocations(service::FieldParams&& params) const; + virtual std::future>> getArgs(service::FieldParams&& params) const; private: std::future resolveName(service::ResolverParams&& params); diff --git a/samples/TodaySchema.cpp b/samples/TodaySchema.cpp index 3cc307b0..d6b0d04b 100644 --- a/samples/TodaySchema.cpp +++ b/samples/TodaySchema.cpp @@ -106,6 +106,7 @@ Query::Query() { "tasksById", [this](service::ResolverParams&& params) { return resolveTasksById(std::move(params)); } }, { "unreadCountsById", [this](service::ResolverParams&& params) { return resolveUnreadCountsById(std::move(params)); } }, { "nested", [this](service::ResolverParams&& params) { return resolveNested(std::move(params)); } }, + { "unimplemented", [this](service::ResolverParams&& params) { return resolveUnimplemented(std::move(params)); } }, { "__typename", [this](service::ResolverParams&& params) { return resolve__typename(std::move(params)); } }, { "__schema", [this](service::ResolverParams&& params) { return resolve__schema(std::move(params)); } }, { "__type", [this](service::ResolverParams&& params) { return resolve__type(std::move(params)); } } @@ -116,6 +117,15 @@ Query::Query() today::AddTypesToSchema(_schema); } +std::future> Query::getNode(service::FieldParams&&, std::vector&&) const +{ + std::promise> promise; + + promise.set_exception(std::make_exception_ptr(std::runtime_error(R"ex(Query::getNode is not implemented)ex"))); + + return promise.get_future(); +} + std::future Query::resolveNode(service::ResolverParams&& params) { auto argId = service::ModifiedArgument>::require("id", params.arguments); @@ -124,6 +134,15 @@ std::future Query::resolveNode(service::ResolverParams&& params return service::ModifiedResult::convert(std::move(result), std::move(params)); } +std::future> Query::getAppointments(service::FieldParams&&, std::unique_ptr&&, std::unique_ptr&&, std::unique_ptr&&, std::unique_ptr&&) const +{ + std::promise> promise; + + promise.set_exception(std::make_exception_ptr(std::runtime_error(R"ex(Query::getAppointments is not implemented)ex"))); + + return promise.get_future(); +} + std::future Query::resolveAppointments(service::ResolverParams&& params) { auto argFirst = service::ModifiedArgument::require("first", params.arguments); @@ -135,6 +154,15 @@ std::future Query::resolveAppointments(service::ResolverParams& return service::ModifiedResult::convert(std::move(result), std::move(params)); } +std::future> Query::getTasks(service::FieldParams&&, std::unique_ptr&&, std::unique_ptr&&, std::unique_ptr&&, std::unique_ptr&&) const +{ + std::promise> promise; + + promise.set_exception(std::make_exception_ptr(std::runtime_error(R"ex(Query::getTasks is not implemented)ex"))); + + return promise.get_future(); +} + std::future Query::resolveTasks(service::ResolverParams&& params) { auto argFirst = service::ModifiedArgument::require("first", params.arguments); @@ -146,6 +174,15 @@ std::future Query::resolveTasks(service::ResolverParams&& param return service::ModifiedResult::convert(std::move(result), std::move(params)); } +std::future> Query::getUnreadCounts(service::FieldParams&&, std::unique_ptr&&, std::unique_ptr&&, std::unique_ptr&&, std::unique_ptr&&) const +{ + std::promise> promise; + + promise.set_exception(std::make_exception_ptr(std::runtime_error(R"ex(Query::getUnreadCounts is not implemented)ex"))); + + return promise.get_future(); +} + std::future Query::resolveUnreadCounts(service::ResolverParams&& params) { auto argFirst = service::ModifiedArgument::require("first", params.arguments); @@ -157,6 +194,15 @@ std::future Query::resolveUnreadCounts(service::ResolverParams& return service::ModifiedResult::convert(std::move(result), std::move(params)); } +std::future>> Query::getAppointmentsById(service::FieldParams&&, std::vector>&&) const +{ + std::promise>> promise; + + promise.set_exception(std::make_exception_ptr(std::runtime_error(R"ex(Query::getAppointmentsById is not implemented)ex"))); + + return promise.get_future(); +} + std::future Query::resolveAppointmentsById(service::ResolverParams&& params) { const auto defaultArguments = []() @@ -187,6 +233,15 @@ std::future Query::resolveAppointmentsById(service::ResolverPar return service::ModifiedResult::convert(std::move(result), std::move(params)); } +std::future>> Query::getTasksById(service::FieldParams&&, std::vector>&&) const +{ + std::promise>> promise; + + promise.set_exception(std::make_exception_ptr(std::runtime_error(R"ex(Query::getTasksById is not implemented)ex"))); + + return promise.get_future(); +} + std::future Query::resolveTasksById(service::ResolverParams&& params) { auto argIds = service::ModifiedArgument>::require("ids", params.arguments); @@ -195,6 +250,15 @@ std::future Query::resolveTasksById(service::ResolverParams&& p return service::ModifiedResult::convert(std::move(result), std::move(params)); } +std::future>> Query::getUnreadCountsById(service::FieldParams&&, std::vector>&&) const +{ + std::promise>> promise; + + promise.set_exception(std::make_exception_ptr(std::runtime_error(R"ex(Query::getUnreadCountsById is not implemented)ex"))); + + return promise.get_future(); +} + std::future Query::resolveUnreadCountsById(service::ResolverParams&& params) { auto argIds = service::ModifiedArgument>::require("ids", params.arguments); @@ -203,6 +267,15 @@ std::future Query::resolveUnreadCountsById(service::ResolverPar return service::ModifiedResult::convert(std::move(result), std::move(params)); } +std::future> Query::getNested(service::FieldParams&&) const +{ + std::promise> promise; + + promise.set_exception(std::make_exception_ptr(std::runtime_error(R"ex(Query::getNested is not implemented)ex"))); + + return promise.get_future(); +} + std::future Query::resolveNested(service::ResolverParams&& params) { auto result = getNested(service::FieldParams(params, std::move(params.fieldDirectives))); @@ -210,6 +283,22 @@ std::future Query::resolveNested(service::ResolverParams&& para return service::ModifiedResult::convert(std::move(result), std::move(params)); } +std::future Query::getUnimplemented(service::FieldParams&&) const +{ + std::promise promise; + + promise.set_exception(std::make_exception_ptr(std::runtime_error(R"ex(Query::getUnimplemented is not implemented)ex"))); + + return promise.get_future(); +} + +std::future Query::resolveUnimplemented(service::ResolverParams&& params) +{ + auto result = getUnimplemented(service::FieldParams(params, std::move(params.fieldDirectives))); + + return service::ModifiedResult::convert(std::move(result), std::move(params)); +} + std::future Query::resolve__typename(service::ResolverParams&& params) { std::promise promise; @@ -249,6 +338,15 @@ PageInfo::PageInfo() { } +std::future PageInfo::getHasNextPage(service::FieldParams&&) const +{ + std::promise promise; + + promise.set_exception(std::make_exception_ptr(std::runtime_error(R"ex(PageInfo::getHasNextPage is not implemented)ex"))); + + return promise.get_future(); +} + std::future PageInfo::resolveHasNextPage(service::ResolverParams&& params) { auto result = getHasNextPage(service::FieldParams(params, std::move(params.fieldDirectives))); @@ -256,6 +354,15 @@ std::future PageInfo::resolveHasNextPage(service::ResolverParam return service::ModifiedResult::convert(std::move(result), std::move(params)); } +std::future PageInfo::getHasPreviousPage(service::FieldParams&&) const +{ + std::promise promise; + + promise.set_exception(std::make_exception_ptr(std::runtime_error(R"ex(PageInfo::getHasPreviousPage is not implemented)ex"))); + + return promise.get_future(); +} + std::future PageInfo::resolveHasPreviousPage(service::ResolverParams&& params) { auto result = getHasPreviousPage(service::FieldParams(params, std::move(params.fieldDirectives))); @@ -283,6 +390,15 @@ AppointmentEdge::AppointmentEdge() { } +std::future> AppointmentEdge::getNode(service::FieldParams&&) const +{ + std::promise> promise; + + promise.set_exception(std::make_exception_ptr(std::runtime_error(R"ex(AppointmentEdge::getNode is not implemented)ex"))); + + return promise.get_future(); +} + std::future AppointmentEdge::resolveNode(service::ResolverParams&& params) { auto result = getNode(service::FieldParams(params, std::move(params.fieldDirectives))); @@ -290,6 +406,15 @@ std::future AppointmentEdge::resolveNode(service::ResolverParam return service::ModifiedResult::convert(std::move(result), std::move(params)); } +std::future AppointmentEdge::getCursor(service::FieldParams&&) const +{ + std::promise promise; + + promise.set_exception(std::make_exception_ptr(std::runtime_error(R"ex(AppointmentEdge::getCursor is not implemented)ex"))); + + return promise.get_future(); +} + std::future AppointmentEdge::resolveCursor(service::ResolverParams&& params) { auto result = getCursor(service::FieldParams(params, std::move(params.fieldDirectives))); @@ -317,6 +442,15 @@ AppointmentConnection::AppointmentConnection() { } +std::future> AppointmentConnection::getPageInfo(service::FieldParams&&) const +{ + std::promise> promise; + + promise.set_exception(std::make_exception_ptr(std::runtime_error(R"ex(AppointmentConnection::getPageInfo is not implemented)ex"))); + + return promise.get_future(); +} + std::future AppointmentConnection::resolvePageInfo(service::ResolverParams&& params) { auto result = getPageInfo(service::FieldParams(params, std::move(params.fieldDirectives))); @@ -324,6 +458,15 @@ std::future AppointmentConnection::resolvePageInfo(service::Res return service::ModifiedResult::convert(std::move(result), std::move(params)); } +std::future>>> AppointmentConnection::getEdges(service::FieldParams&&) const +{ + std::promise>>> promise; + + promise.set_exception(std::make_exception_ptr(std::runtime_error(R"ex(AppointmentConnection::getEdges is not implemented)ex"))); + + return promise.get_future(); +} + std::future AppointmentConnection::resolveEdges(service::ResolverParams&& params) { auto result = getEdges(service::FieldParams(params, std::move(params.fieldDirectives))); @@ -351,6 +494,15 @@ TaskEdge::TaskEdge() { } +std::future> TaskEdge::getNode(service::FieldParams&&) const +{ + std::promise> promise; + + promise.set_exception(std::make_exception_ptr(std::runtime_error(R"ex(TaskEdge::getNode is not implemented)ex"))); + + return promise.get_future(); +} + std::future TaskEdge::resolveNode(service::ResolverParams&& params) { auto result = getNode(service::FieldParams(params, std::move(params.fieldDirectives))); @@ -358,6 +510,15 @@ std::future TaskEdge::resolveNode(service::ResolverParams&& par return service::ModifiedResult::convert(std::move(result), std::move(params)); } +std::future TaskEdge::getCursor(service::FieldParams&&) const +{ + std::promise promise; + + promise.set_exception(std::make_exception_ptr(std::runtime_error(R"ex(TaskEdge::getCursor is not implemented)ex"))); + + return promise.get_future(); +} + std::future TaskEdge::resolveCursor(service::ResolverParams&& params) { auto result = getCursor(service::FieldParams(params, std::move(params.fieldDirectives))); @@ -385,6 +546,15 @@ TaskConnection::TaskConnection() { } +std::future> TaskConnection::getPageInfo(service::FieldParams&&) const +{ + std::promise> promise; + + promise.set_exception(std::make_exception_ptr(std::runtime_error(R"ex(TaskConnection::getPageInfo is not implemented)ex"))); + + return promise.get_future(); +} + std::future TaskConnection::resolvePageInfo(service::ResolverParams&& params) { auto result = getPageInfo(service::FieldParams(params, std::move(params.fieldDirectives))); @@ -392,6 +562,15 @@ std::future TaskConnection::resolvePageInfo(service::ResolverPa return service::ModifiedResult::convert(std::move(result), std::move(params)); } +std::future>>> TaskConnection::getEdges(service::FieldParams&&) const +{ + std::promise>>> promise; + + promise.set_exception(std::make_exception_ptr(std::runtime_error(R"ex(TaskConnection::getEdges is not implemented)ex"))); + + return promise.get_future(); +} + std::future TaskConnection::resolveEdges(service::ResolverParams&& params) { auto result = getEdges(service::FieldParams(params, std::move(params.fieldDirectives))); @@ -419,6 +598,15 @@ FolderEdge::FolderEdge() { } +std::future> FolderEdge::getNode(service::FieldParams&&) const +{ + std::promise> promise; + + promise.set_exception(std::make_exception_ptr(std::runtime_error(R"ex(FolderEdge::getNode is not implemented)ex"))); + + return promise.get_future(); +} + std::future FolderEdge::resolveNode(service::ResolverParams&& params) { auto result = getNode(service::FieldParams(params, std::move(params.fieldDirectives))); @@ -426,6 +614,15 @@ std::future FolderEdge::resolveNode(service::ResolverParams&& p return service::ModifiedResult::convert(std::move(result), std::move(params)); } +std::future FolderEdge::getCursor(service::FieldParams&&) const +{ + std::promise promise; + + promise.set_exception(std::make_exception_ptr(std::runtime_error(R"ex(FolderEdge::getCursor is not implemented)ex"))); + + return promise.get_future(); +} + std::future FolderEdge::resolveCursor(service::ResolverParams&& params) { auto result = getCursor(service::FieldParams(params, std::move(params.fieldDirectives))); @@ -453,6 +650,15 @@ FolderConnection::FolderConnection() { } +std::future> FolderConnection::getPageInfo(service::FieldParams&&) const +{ + std::promise> promise; + + promise.set_exception(std::make_exception_ptr(std::runtime_error(R"ex(FolderConnection::getPageInfo is not implemented)ex"))); + + return promise.get_future(); +} + std::future FolderConnection::resolvePageInfo(service::ResolverParams&& params) { auto result = getPageInfo(service::FieldParams(params, std::move(params.fieldDirectives))); @@ -460,6 +666,15 @@ std::future FolderConnection::resolvePageInfo(service::Resolver return service::ModifiedResult::convert(std::move(result), std::move(params)); } +std::future>>> FolderConnection::getEdges(service::FieldParams&&) const +{ + std::promise>>> promise; + + promise.set_exception(std::make_exception_ptr(std::runtime_error(R"ex(FolderConnection::getEdges is not implemented)ex"))); + + return promise.get_future(); +} + std::future FolderConnection::resolveEdges(service::ResolverParams&& params) { auto result = getEdges(service::FieldParams(params, std::move(params.fieldDirectives))); @@ -487,6 +702,15 @@ CompleteTaskPayload::CompleteTaskPayload() { } +std::future> CompleteTaskPayload::getTask(service::FieldParams&&) const +{ + std::promise> promise; + + promise.set_exception(std::make_exception_ptr(std::runtime_error(R"ex(CompleteTaskPayload::getTask is not implemented)ex"))); + + return promise.get_future(); +} + std::future CompleteTaskPayload::resolveTask(service::ResolverParams&& params) { auto result = getTask(service::FieldParams(params, std::move(params.fieldDirectives))); @@ -494,6 +718,15 @@ std::future CompleteTaskPayload::resolveTask(service::ResolverP return service::ModifiedResult::convert(std::move(result), std::move(params)); } +std::future> CompleteTaskPayload::getClientMutationId(service::FieldParams&&) const +{ + std::promise> promise; + + promise.set_exception(std::make_exception_ptr(std::runtime_error(R"ex(CompleteTaskPayload::getClientMutationId is not implemented)ex"))); + + return promise.get_future(); +} + std::future CompleteTaskPayload::resolveClientMutationId(service::ResolverParams&& params) { auto result = getClientMutationId(service::FieldParams(params, std::move(params.fieldDirectives))); @@ -520,6 +753,15 @@ Mutation::Mutation() { } +std::future> Mutation::getCompleteTask(service::FieldParams&&, CompleteTaskInput&&) const +{ + std::promise> promise; + + promise.set_exception(std::make_exception_ptr(std::runtime_error(R"ex(Mutation::getCompleteTask is not implemented)ex"))); + + return promise.get_future(); +} + std::future Mutation::resolveCompleteTask(service::ResolverParams&& params) { auto argInput = service::ModifiedArgument::require("input", params.arguments); @@ -548,6 +790,15 @@ Subscription::Subscription() { } +std::future> Subscription::getNextAppointmentChange(service::FieldParams&&) const +{ + std::promise> promise; + + promise.set_exception(std::make_exception_ptr(std::runtime_error(R"ex(Subscription::getNextAppointmentChange is not implemented)ex"))); + + return promise.get_future(); +} + std::future Subscription::resolveNextAppointmentChange(service::ResolverParams&& params) { auto result = getNextAppointmentChange(service::FieldParams(params, std::move(params.fieldDirectives))); @@ -555,6 +806,15 @@ std::future Subscription::resolveNextAppointmentChange(service: return service::ModifiedResult::convert(std::move(result), std::move(params)); } +std::future> Subscription::getNodeChange(service::FieldParams&&, std::vector&&) const +{ + std::promise> promise; + + promise.set_exception(std::make_exception_ptr(std::runtime_error(R"ex(Subscription::getNodeChange is not implemented)ex"))); + + return promise.get_future(); +} + std::future Subscription::resolveNodeChange(service::ResolverParams&& params) { auto argId = service::ModifiedArgument>::require("id", params.arguments); @@ -586,6 +846,15 @@ Appointment::Appointment() { } +std::future> Appointment::getId(service::FieldParams&&) const +{ + std::promise> promise; + + promise.set_exception(std::make_exception_ptr(std::runtime_error(R"ex(Appointment::getId is not implemented)ex"))); + + return promise.get_future(); +} + std::future Appointment::resolveId(service::ResolverParams&& params) { auto result = getId(service::FieldParams(params, std::move(params.fieldDirectives))); @@ -593,6 +862,15 @@ std::future Appointment::resolveId(service::ResolverParams&& pa return service::ModifiedResult>::convert(std::move(result), std::move(params)); } +std::future> Appointment::getWhen(service::FieldParams&&) const +{ + std::promise> promise; + + promise.set_exception(std::make_exception_ptr(std::runtime_error(R"ex(Appointment::getWhen is not implemented)ex"))); + + return promise.get_future(); +} + std::future Appointment::resolveWhen(service::ResolverParams&& params) { auto result = getWhen(service::FieldParams(params, std::move(params.fieldDirectives))); @@ -600,6 +878,15 @@ std::future Appointment::resolveWhen(service::ResolverParams&& return service::ModifiedResult::convert(std::move(result), std::move(params)); } +std::future> Appointment::getSubject(service::FieldParams&&) const +{ + std::promise> promise; + + promise.set_exception(std::make_exception_ptr(std::runtime_error(R"ex(Appointment::getSubject is not implemented)ex"))); + + return promise.get_future(); +} + std::future Appointment::resolveSubject(service::ResolverParams&& params) { auto result = getSubject(service::FieldParams(params, std::move(params.fieldDirectives))); @@ -607,6 +894,15 @@ std::future Appointment::resolveSubject(service::ResolverParams return service::ModifiedResult::convert(std::move(result), std::move(params)); } +std::future Appointment::getIsNow(service::FieldParams&&) const +{ + std::promise promise; + + promise.set_exception(std::make_exception_ptr(std::runtime_error(R"ex(Appointment::getIsNow is not implemented)ex"))); + + return promise.get_future(); +} + std::future Appointment::resolveIsNow(service::ResolverParams&& params) { auto result = getIsNow(service::FieldParams(params, std::move(params.fieldDirectives))); @@ -636,6 +932,15 @@ Task::Task() { } +std::future> Task::getId(service::FieldParams&&) const +{ + std::promise> promise; + + promise.set_exception(std::make_exception_ptr(std::runtime_error(R"ex(Task::getId is not implemented)ex"))); + + return promise.get_future(); +} + std::future Task::resolveId(service::ResolverParams&& params) { auto result = getId(service::FieldParams(params, std::move(params.fieldDirectives))); @@ -643,6 +948,15 @@ std::future Task::resolveId(service::ResolverParams&& params) return service::ModifiedResult>::convert(std::move(result), std::move(params)); } +std::future> Task::getTitle(service::FieldParams&&) const +{ + std::promise> promise; + + promise.set_exception(std::make_exception_ptr(std::runtime_error(R"ex(Task::getTitle is not implemented)ex"))); + + return promise.get_future(); +} + std::future Task::resolveTitle(service::ResolverParams&& params) { auto result = getTitle(service::FieldParams(params, std::move(params.fieldDirectives))); @@ -650,6 +964,15 @@ std::future Task::resolveTitle(service::ResolverParams&& params return service::ModifiedResult::convert(std::move(result), std::move(params)); } +std::future Task::getIsComplete(service::FieldParams&&) const +{ + std::promise promise; + + promise.set_exception(std::make_exception_ptr(std::runtime_error(R"ex(Task::getIsComplete is not implemented)ex"))); + + return promise.get_future(); +} + std::future Task::resolveIsComplete(service::ResolverParams&& params) { auto result = getIsComplete(service::FieldParams(params, std::move(params.fieldDirectives))); @@ -679,6 +1002,15 @@ Folder::Folder() { } +std::future> Folder::getId(service::FieldParams&&) const +{ + std::promise> promise; + + promise.set_exception(std::make_exception_ptr(std::runtime_error(R"ex(Folder::getId is not implemented)ex"))); + + return promise.get_future(); +} + std::future Folder::resolveId(service::ResolverParams&& params) { auto result = getId(service::FieldParams(params, std::move(params.fieldDirectives))); @@ -686,6 +1018,15 @@ std::future Folder::resolveId(service::ResolverParams&& params) return service::ModifiedResult>::convert(std::move(result), std::move(params)); } +std::future> Folder::getName(service::FieldParams&&) const +{ + std::promise> promise; + + promise.set_exception(std::make_exception_ptr(std::runtime_error(R"ex(Folder::getName is not implemented)ex"))); + + return promise.get_future(); +} + std::future Folder::resolveName(service::ResolverParams&& params) { auto result = getName(service::FieldParams(params, std::move(params.fieldDirectives))); @@ -693,6 +1034,15 @@ std::future Folder::resolveName(service::ResolverParams&& param return service::ModifiedResult::convert(std::move(result), std::move(params)); } +std::future Folder::getUnreadCount(service::FieldParams&&) const +{ + std::promise promise; + + promise.set_exception(std::make_exception_ptr(std::runtime_error(R"ex(Folder::getUnreadCount is not implemented)ex"))); + + return promise.get_future(); +} + std::future Folder::resolveUnreadCount(service::ResolverParams&& params) { auto result = getUnreadCount(service::FieldParams(params, std::move(params.fieldDirectives))); @@ -720,6 +1070,15 @@ NestedType::NestedType() { } +std::future NestedType::getDepth(service::FieldParams&&) const +{ + std::promise promise; + + promise.set_exception(std::make_exception_ptr(std::runtime_error(R"ex(NestedType::getDepth is not implemented)ex"))); + + return promise.get_future(); +} + std::future NestedType::resolveDepth(service::ResolverParams&& params) { auto result = getDepth(service::FieldParams(params, std::move(params.fieldDirectives))); @@ -727,6 +1086,15 @@ std::future NestedType::resolveDepth(service::ResolverParams&& return service::ModifiedResult::convert(std::move(result), std::move(params)); } +std::future> NestedType::getNested(service::FieldParams&&) const +{ + std::promise> promise; + + promise.set_exception(std::make_exception_ptr(std::runtime_error(R"ex(NestedType::getNested is not implemented)ex"))); + + return promise.get_future(); +} + std::future NestedType::resolveNested(service::ResolverParams&& params) { auto result = getNested(service::FieldParams(params, std::move(params.fieldDirectives))); @@ -854,7 +1222,8 @@ void AddTypesToSchema(std::shared_ptr schema) std::make_shared("unreadCountsById", R"md()md", std::unique_ptr(nullptr), std::vector>({ std::make_shared("ids", R"md()md", schema->WrapType(introspection::__TypeKind::NON_NULL, schema->WrapType(introspection::__TypeKind::LIST, schema->WrapType(introspection::__TypeKind::NON_NULL, schema->LookupType("ID")))), R"gql()gql") }), schema->WrapType(introspection::__TypeKind::NON_NULL, schema->WrapType(introspection::__TypeKind::LIST, schema->LookupType("Folder")))), - std::make_shared("nested", R"md()md", std::unique_ptr(nullptr), std::vector>(), schema->WrapType(introspection::__TypeKind::NON_NULL, schema->LookupType("NestedType"))) + std::make_shared("nested", R"md()md", std::unique_ptr(nullptr), std::vector>(), schema->WrapType(introspection::__TypeKind::NON_NULL, schema->LookupType("NestedType"))), + std::make_shared("unimplemented", R"md()md", std::unique_ptr(nullptr), std::vector>(), schema->WrapType(introspection::__TypeKind::NON_NULL, schema->LookupType("String"))) }); typePageInfo->AddFields({ std::make_shared("hasNextPage", R"md()md", std::unique_ptr(nullptr), std::vector>(), schema->WrapType(introspection::__TypeKind::NON_NULL, schema->LookupType("Boolean"))), diff --git a/samples/TodaySchema.h b/samples/TodaySchema.h index ac061589..6a22be38 100644 --- a/samples/TodaySchema.h +++ b/samples/TodaySchema.h @@ -68,14 +68,15 @@ class Query Query(); public: - virtual std::future> getNode(service::FieldParams&& params, std::vector&& idArg) const = 0; - virtual std::future> getAppointments(service::FieldParams&& params, std::unique_ptr&& firstArg, std::unique_ptr&& afterArg, std::unique_ptr&& lastArg, std::unique_ptr&& beforeArg) const = 0; - virtual std::future> getTasks(service::FieldParams&& params, std::unique_ptr&& firstArg, std::unique_ptr&& afterArg, std::unique_ptr&& lastArg, std::unique_ptr&& beforeArg) const = 0; - virtual std::future> getUnreadCounts(service::FieldParams&& params, std::unique_ptr&& firstArg, std::unique_ptr&& afterArg, std::unique_ptr&& lastArg, std::unique_ptr&& beforeArg) const = 0; - virtual std::future>> getAppointmentsById(service::FieldParams&& params, std::vector>&& idsArg) const = 0; - virtual std::future>> getTasksById(service::FieldParams&& params, std::vector>&& idsArg) const = 0; - virtual std::future>> getUnreadCountsById(service::FieldParams&& params, std::vector>&& idsArg) const = 0; - virtual std::future> getNested(service::FieldParams&& params) const = 0; + virtual std::future> getNode(service::FieldParams&& params, std::vector&& idArg) const; + virtual std::future> getAppointments(service::FieldParams&& params, std::unique_ptr&& firstArg, std::unique_ptr&& afterArg, std::unique_ptr&& lastArg, std::unique_ptr&& beforeArg) const; + virtual std::future> getTasks(service::FieldParams&& params, std::unique_ptr&& firstArg, std::unique_ptr&& afterArg, std::unique_ptr&& lastArg, std::unique_ptr&& beforeArg) const; + virtual std::future> getUnreadCounts(service::FieldParams&& params, std::unique_ptr&& firstArg, std::unique_ptr&& afterArg, std::unique_ptr&& lastArg, std::unique_ptr&& beforeArg) const; + virtual std::future>> getAppointmentsById(service::FieldParams&& params, std::vector>&& idsArg) const; + virtual std::future>> getTasksById(service::FieldParams&& params, std::vector>&& idsArg) const; + virtual std::future>> getUnreadCountsById(service::FieldParams&& params, std::vector>&& idsArg) const; + virtual std::future> getNested(service::FieldParams&& params) const; + virtual std::future getUnimplemented(service::FieldParams&& params) const; private: std::future resolveNode(service::ResolverParams&& params); @@ -86,6 +87,7 @@ class Query std::future resolveTasksById(service::ResolverParams&& params); std::future resolveUnreadCountsById(service::ResolverParams&& params); std::future resolveNested(service::ResolverParams&& params); + std::future resolveUnimplemented(service::ResolverParams&& params); std::future resolve__typename(service::ResolverParams&& params); std::future resolve__schema(service::ResolverParams&& params); @@ -101,8 +103,8 @@ class PageInfo PageInfo(); public: - virtual std::future getHasNextPage(service::FieldParams&& params) const = 0; - virtual std::future getHasPreviousPage(service::FieldParams&& params) const = 0; + virtual std::future getHasNextPage(service::FieldParams&& params) const; + virtual std::future getHasPreviousPage(service::FieldParams&& params) const; private: std::future resolveHasNextPage(service::ResolverParams&& params); @@ -118,8 +120,8 @@ class AppointmentEdge AppointmentEdge(); public: - virtual std::future> getNode(service::FieldParams&& params) const = 0; - virtual std::future getCursor(service::FieldParams&& params) const = 0; + virtual std::future> getNode(service::FieldParams&& params) const; + virtual std::future getCursor(service::FieldParams&& params) const; private: std::future resolveNode(service::ResolverParams&& params); @@ -135,8 +137,8 @@ class AppointmentConnection AppointmentConnection(); public: - virtual std::future> getPageInfo(service::FieldParams&& params) const = 0; - virtual std::future>>> getEdges(service::FieldParams&& params) const = 0; + virtual std::future> getPageInfo(service::FieldParams&& params) const; + virtual std::future>>> getEdges(service::FieldParams&& params) const; private: std::future resolvePageInfo(service::ResolverParams&& params); @@ -152,8 +154,8 @@ class TaskEdge TaskEdge(); public: - virtual std::future> getNode(service::FieldParams&& params) const = 0; - virtual std::future getCursor(service::FieldParams&& params) const = 0; + virtual std::future> getNode(service::FieldParams&& params) const; + virtual std::future getCursor(service::FieldParams&& params) const; private: std::future resolveNode(service::ResolverParams&& params); @@ -169,8 +171,8 @@ class TaskConnection TaskConnection(); public: - virtual std::future> getPageInfo(service::FieldParams&& params) const = 0; - virtual std::future>>> getEdges(service::FieldParams&& params) const = 0; + virtual std::future> getPageInfo(service::FieldParams&& params) const; + virtual std::future>>> getEdges(service::FieldParams&& params) const; private: std::future resolvePageInfo(service::ResolverParams&& params); @@ -186,8 +188,8 @@ class FolderEdge FolderEdge(); public: - virtual std::future> getNode(service::FieldParams&& params) const = 0; - virtual std::future getCursor(service::FieldParams&& params) const = 0; + virtual std::future> getNode(service::FieldParams&& params) const; + virtual std::future getCursor(service::FieldParams&& params) const; private: std::future resolveNode(service::ResolverParams&& params); @@ -203,8 +205,8 @@ class FolderConnection FolderConnection(); public: - virtual std::future> getPageInfo(service::FieldParams&& params) const = 0; - virtual std::future>>> getEdges(service::FieldParams&& params) const = 0; + virtual std::future> getPageInfo(service::FieldParams&& params) const; + virtual std::future>>> getEdges(service::FieldParams&& params) const; private: std::future resolvePageInfo(service::ResolverParams&& params); @@ -220,8 +222,8 @@ class CompleteTaskPayload CompleteTaskPayload(); public: - virtual std::future> getTask(service::FieldParams&& params) const = 0; - virtual std::future> getClientMutationId(service::FieldParams&& params) const = 0; + virtual std::future> getTask(service::FieldParams&& params) const; + virtual std::future> getClientMutationId(service::FieldParams&& params) const; private: std::future resolveTask(service::ResolverParams&& params); @@ -237,7 +239,7 @@ class Mutation Mutation(); public: - virtual std::future> getCompleteTask(service::FieldParams&& params, CompleteTaskInput&& inputArg) const = 0; + virtual std::future> getCompleteTask(service::FieldParams&& params, CompleteTaskInput&& inputArg) const; private: std::future resolveCompleteTask(service::ResolverParams&& params); @@ -252,8 +254,8 @@ class Subscription Subscription(); public: - virtual std::future> getNextAppointmentChange(service::FieldParams&& params) const = 0; - virtual std::future> getNodeChange(service::FieldParams&& params, std::vector&& idArg) const = 0; + virtual std::future> getNextAppointmentChange(service::FieldParams&& params) const; + virtual std::future> getNodeChange(service::FieldParams&& params, std::vector&& idArg) const; private: std::future resolveNextAppointmentChange(service::ResolverParams&& params); @@ -270,9 +272,10 @@ class Appointment Appointment(); public: - virtual std::future> getWhen(service::FieldParams&& params) const = 0; - virtual std::future> getSubject(service::FieldParams&& params) const = 0; - virtual std::future getIsNow(service::FieldParams&& params) const = 0; + virtual std::future> getId(service::FieldParams&& params) const override; + virtual std::future> getWhen(service::FieldParams&& params) const; + virtual std::future> getSubject(service::FieldParams&& params) const; + virtual std::future getIsNow(service::FieldParams&& params) const; private: std::future resolveId(service::ResolverParams&& params); @@ -291,8 +294,9 @@ class Task Task(); public: - virtual std::future> getTitle(service::FieldParams&& params) const = 0; - virtual std::future getIsComplete(service::FieldParams&& params) const = 0; + virtual std::future> getId(service::FieldParams&& params) const override; + virtual std::future> getTitle(service::FieldParams&& params) const; + virtual std::future getIsComplete(service::FieldParams&& params) const; private: std::future resolveId(service::ResolverParams&& params); @@ -310,8 +314,9 @@ class Folder Folder(); public: - virtual std::future> getName(service::FieldParams&& params) const = 0; - virtual std::future getUnreadCount(service::FieldParams&& params) const = 0; + virtual std::future> getId(service::FieldParams&& params) const override; + virtual std::future> getName(service::FieldParams&& params) const; + virtual std::future getUnreadCount(service::FieldParams&& params) const; private: std::future resolveId(service::ResolverParams&& params); @@ -328,8 +333,8 @@ class NestedType NestedType(); public: - virtual std::future getDepth(service::FieldParams&& params) const = 0; - virtual std::future> getNested(service::FieldParams&& params) const = 0; + virtual std::future getDepth(service::FieldParams&& params) const; + virtual std::future> getNested(service::FieldParams&& params) const; private: std::future resolveDepth(service::ResolverParams&& params); diff --git a/samples/schema.today.graphql b/samples/schema.today.graphql index 63e5f1f2..2954c170 100644 --- a/samples/schema.today.graphql +++ b/samples/schema.today.graphql @@ -26,6 +26,8 @@ type Query { unreadCountsById(ids: [ID!]!): [Folder]! nested: NestedType! + + unimplemented: String! } "Node interface for Relay support" diff --git a/tests.cpp b/tests.cpp index 16978328..e2d51402 100644 --- a/tests.cpp +++ b/tests.cpp @@ -838,6 +838,30 @@ TEST_F(TodayServiceCase, QueryAppointmentsById) } } +TEST_F(TodayServiceCase, UnimplementedFieldError) +{ + auto ast = R"(query { + unimplemented + })"_graphql; + response::Value variables(response::Type::Map); + auto result = _service->resolve(nullptr, *ast.root, "", std::move(variables)).get(); + + try + { + ASSERT_TRUE(result.type() == response::Type::Map); + const auto& errors = result["errors"]; + ASSERT_TRUE(errors.type() == response::Type::List); + ASSERT_EQ(size_t(1), errors.size()); + const auto& message = errors[0]; + ASSERT_TRUE(message.type() == response::Type::String); + ASSERT_EQ(R"e(Field name: unimplemented unknown error: Query::getUnimplemented is not implemented)e", message.get()); + } + catch (const service::schema_exception& ex) + { + FAIL() << response::toJSON(response::Value(ex.getErrors())); + } +} + TEST_F(TodayServiceCase, SubscribeNodeChangeMatchingId) { auto ast = peg::parseString(R"(subscription TestSubscription {