Skip to content

Commit fb54030

Browse files
committed
Move converter export declarations to graphql::service
1 parent 5e45c3e commit fb54030

File tree

2 files changed

+72
-62
lines changed

2 files changed

+72
-62
lines changed

include/graphqlservice/introspection/IntrospectionSchema.h

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -68,22 +68,6 @@ enum class DirectiveLocation
6868
INPUT_FIELD_DEFINITION
6969
};
7070

71-
#ifdef GRAPHQL_DLLEXPORTS
72-
// Export all of the built-in converters
73-
template <>
74-
GRAPHQLSERVICE_EXPORT TypeKind service::ModifiedArgument<TypeKind>::convert(
75-
const response::Value& value);
76-
template <>
77-
GRAPHQLSERVICE_EXPORT std::future<service::ResolverResult> service::ModifiedResult<TypeKind>::convert(
78-
service::FieldResult<TypeKind>&& result, service::ResolverParams&& params);
79-
template <>
80-
GRAPHQLSERVICE_EXPORT DirectiveLocation service::ModifiedArgument<DirectiveLocation>::convert(
81-
const response::Value& value);
82-
template <>
83-
GRAPHQLSERVICE_EXPORT std::future<service::ResolverResult> service::ModifiedResult<DirectiveLocation>::convert(
84-
service::FieldResult<DirectiveLocation>&& result, service::ResolverParams&& params);
85-
#endif // GRAPHQL_DLLEXPORTS
86-
8771
namespace object {
8872

8973
class Schema;
@@ -240,6 +224,26 @@ class Directive
240224
GRAPHQLINTROSPECTION_EXPORT void AddTypesToSchema(const std::shared_ptr<schema::Schema>& schema);
241225

242226
} /* namespace introspection */
227+
228+
namespace service {
229+
230+
#ifdef GRAPHQL_DLLEXPORTS
231+
// Export all of the built-in converters
232+
template <>
233+
GRAPHQLSERVICE_EXPORT introspection::TypeKind ModifiedArgument<introspection::TypeKind>::convert(
234+
const response::Value& value);
235+
template <>
236+
GRAPHQLSERVICE_EXPORT std::future<ResolverResult> ModifiedResult<introspection::TypeKind>::convert(
237+
FieldResult<introspection::TypeKind>&& result, ResolverParams&& params);
238+
template <>
239+
GRAPHQLSERVICE_EXPORT introspection::DirectiveLocation ModifiedArgument<introspection::DirectiveLocation>::convert(
240+
const response::Value& value);
241+
template <>
242+
GRAPHQLSERVICE_EXPORT std::future<ResolverResult> ModifiedResult<introspection::DirectiveLocation>::convert(
243+
FieldResult<introspection::DirectiveLocation>&& result, ResolverParams&& params);
244+
#endif // GRAPHQL_DLLEXPORTS
245+
246+
} /* namespace service */
243247
} /* namespace graphql */
244248

245249
#endif // INTROSPECTIONSCHEMA_H

src/SchemaGenerator.cpp

Lines changed: 52 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1671,28 +1671,6 @@ static_assert(graphql::internal::MinorVersion == )cpp"
16711671
headerFile << R"cpp(
16721672
};
16731673
1674-
)cpp";
1675-
}
1676-
1677-
if (_isIntrospection)
1678-
{
1679-
headerFile << R"cpp(#ifdef GRAPHQL_DLLEXPORTS
1680-
// Export all of the built-in converters
1681-
)cpp";
1682-
1683-
for (const auto& enumType : _enumTypes)
1684-
{
1685-
headerFile << R"cpp(template <>
1686-
GRAPHQLSERVICE_EXPORT )cpp" << enumType.cppType << R"cpp( service::ModifiedArgument<)cpp" << enumType.cppType << R"cpp(>::convert(
1687-
const response::Value& value);
1688-
template <>
1689-
GRAPHQLSERVICE_EXPORT std::future<service::ResolverResult> service::ModifiedResult<)cpp" << enumType.cppType << R"cpp(>::convert(
1690-
service::FieldResult<)cpp" << enumType.cppType << R"cpp(>&& result, service::ResolverParams&& params);
1691-
)cpp";
1692-
}
1693-
1694-
headerFile << R"cpp(#endif // GRAPHQL_DLLEXPORTS
1695-
16961674
)cpp";
16971675
}
16981676
}
@@ -1726,25 +1704,6 @@ GRAPHQLSERVICE_EXPORT std::future<service::ResolverResult> service::ModifiedResu
17261704
}
17271705
headerFile << R"cpp(};
17281706
1729-
)cpp";
1730-
}
1731-
1732-
if (_isIntrospection)
1733-
{
1734-
headerFile << R"cpp(#ifdef GRAPHQL_DLLEXPORTS
1735-
// Export all of the built-in converters
1736-
)cpp";
1737-
1738-
for (const auto& inputType : _inputTypes)
1739-
{
1740-
headerFile << R"cpp(template <>
1741-
GRAPHQLSERVICE_EXPORT )cpp" << inputType.cppType << R"cpp( service::ModifiedArgument<)cpp" << inputType.cppType << R"cpp(>::convert(
1742-
const response::Value& value);
1743-
)cpp";
1744-
}
1745-
1746-
headerFile << R"cpp(#endif // GRAPHQL_DLLEXPORTS
1747-
17481707
)cpp";
17491708
}
17501709
}
@@ -1877,16 +1836,63 @@ GRAPHQLSERVICE_EXPORT )cpp" << inputType.cppType << R"cpp( service::ModifiedArgu
18771836
if (_isIntrospection)
18781837
{
18791838
headerFile
1880-
<< R"cpp(GRAPHQLINTROSPECTION_EXPORT void AddTypesToSchema(const std::shared_ptr<schema::Schema>& schema);)cpp";
1839+
<< R"cpp(GRAPHQLINTROSPECTION_EXPORT void AddTypesToSchema(const std::shared_ptr<schema::Schema>& schema);
1840+
1841+
)cpp";
1842+
1843+
if (!_enumTypes.empty() || !_inputTypes.empty())
1844+
{
1845+
if (schemaNamespace.exit())
1846+
{
1847+
headerFile << std::endl;
1848+
}
1849+
1850+
NamespaceScope serviceNamespace { headerFile, "service" };
1851+
1852+
headerFile << R"cpp(
1853+
#ifdef GRAPHQL_DLLEXPORTS
1854+
// Export all of the built-in converters
1855+
)cpp";
1856+
1857+
for (const auto& enumType : _enumTypes)
1858+
{
1859+
headerFile << R"cpp(template <>
1860+
GRAPHQLSERVICE_EXPORT )cpp" << _schemaNamespace
1861+
<< R"cpp(::)cpp" << enumType.cppType << R"cpp( ModifiedArgument<)cpp"
1862+
<< _schemaNamespace << R"cpp(::)cpp" << enumType.cppType
1863+
<< R"cpp(>::convert(
1864+
const response::Value& value);
1865+
template <>
1866+
GRAPHQLSERVICE_EXPORT std::future<ResolverResult> ModifiedResult<)cpp"
1867+
<< _schemaNamespace << R"cpp(::)cpp" << enumType.cppType
1868+
<< R"cpp(>::convert(
1869+
FieldResult<)cpp" << _schemaNamespace
1870+
<< R"cpp(::)cpp" << enumType.cppType
1871+
<< R"cpp(>&& result, ResolverParams&& params);
1872+
)cpp";
1873+
}
1874+
1875+
for (const auto& inputType : _inputTypes)
1876+
{
1877+
headerFile << R"cpp(template <>
1878+
GRAPHQLSERVICE_EXPORT )cpp" << _schemaNamespace
1879+
<< R"cpp(::)cpp" << inputType.cppType << R"cpp( ModifiedArgument<)cpp"
1880+
<< inputType.cppType << R"cpp(>::convert(
1881+
const response::Value& value);
1882+
)cpp";
1883+
}
1884+
1885+
headerFile << R"cpp(#endif // GRAPHQL_DLLEXPORTS
1886+
1887+
)cpp";
1888+
}
18811889
}
18821890
else
18831891
{
1884-
headerFile << R"cpp(std::shared_ptr<schema::Schema> GetSchema();)cpp";
1885-
}
1886-
1887-
headerFile << R"cpp(
1892+
headerFile << R"cpp(std::shared_ptr<schema::Schema> GetSchema();
18881893
18891894
)cpp";
1895+
}
18901896

18911897
return true;
18921898
}

0 commit comments

Comments
 (0)