FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
cppgraphqlgen/samples/validation/schema/MessageObject.h at main · gitmodimo/cppgraphqlgen · GitHub
gitmodimo
cppgraphqlgen
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
cppgraphqlgen
/
samples
/
validation
/
schema
/
MessageObject.h
Copy path
More file actions
More file actions
Latest commit
History
History
History
160 lines (129 loc) · 4.37 KB
Breadcrumbs
cppgraphqlgen
/
samples
/
validation
/
schema
/
MessageObject.h
Copy path
File metadata and controls
160 lines (129 loc) · 4.37 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
//
Copyright (c) Microsoft Corporation. All rights reserved.
//
Licensed under the MIT License.
//
WARNING! Do not edit this file manually, your changes will be overwritten.
#
pragma
once
#
ifndef
MESSAGEOBJECT_H
#
define
MESSAGEOBJECT_H
#
include
"
ValidationSchema.h
"
namespace
graphql
::validation::object {
namespace
methods
::MessageHas {
template
<
class
TImpl
>
concept
getBodyWithParams =
requires
(TImpl impl, service::FieldParams params)
{
{ service::AwaitableScalar<std::optional<std::string>> { impl.
getBody
(
std::move
(params)) } };
};
template
<
class
TImpl
>
concept
getBody =
requires
(TImpl impl)
{
{ service::AwaitableScalar<std::optional<std::string>> { impl.
getBody
() } };
};
template
<
class
TImpl
>
concept
getSenderWithParams =
requires
(TImpl impl, service::FieldParams params)
{
{ service::AwaitableScalar<response::IdType> { impl.
getSender
(
std::move
(params)) } };
};
template
<
class
TImpl
>
concept
getSender =
requires
(TImpl impl)
{
{ service::AwaitableScalar<response::IdType> { impl.
getSender
() } };
};
template
<
class
TImpl
>
concept
beginSelectionSet =
requires
(TImpl impl,
const
service::SelectionSetParams params)
{
{ impl.
beginSelectionSet
(params) };
};
template
<
class
TImpl
>
concept
endSelectionSet =
requires
(TImpl impl,
const
service::SelectionSetParams params)
{
{ impl.
endSelectionSet
(params) };
};
}
//
namespace methods::MessageHas
class
[[nodiscard]]
Message
final
: public service::Object
{
private:
[[nodiscard]]
service::AwaitableResolver
resolveBody
(service::ResolverParams&& params)
const
;
[[nodiscard]]
service::AwaitableResolver
resolveSender
(service::ResolverParams&& params)
const
;
[[nodiscard]]
service::AwaitableResolver
resolve_typename
(service::ResolverParams&& params)
const
;
struct
[[nodiscard]]
Concept
{
virtual
~Concept
() =
default
;
virtual
void
beginSelectionSet
(
const
service::SelectionSetParams& params)
const
=
0
;
virtual
void
endSelectionSet
(
const
service::SelectionSetParams& params)
const
=
0
;
[[nodiscard]]
virtual
service::AwaitableScalar<std::optional<std::string>>
getBody
(service::FieldParams&& params)
const
=
0
;
[[nodiscard]]
virtual
service::AwaitableScalar<response::IdType>
getSender
(service::FieldParams&& params)
const
=
0
;
};
template
<
class
T
>
struct
[[nodiscard]]
Model
: Concept
{
Model
(std::shared_ptr<T>&& pimpl)
noexcept
: _pimpl {
std::move
(pimpl) }
{
}
[[nodiscard]]
service::AwaitableScalar<std::optional<std::string>>
getBody
(service::FieldParams&& params)
const
final
{
if
constexpr
(methods::MessageHas::getBodyWithParams<T>)
{
return
{ _pimpl->
getBody
(
std::move
(params)) };
}
else
if
constexpr
(methods::MessageHas::getBody<T>)
{
return
{ _pimpl->
getBody
() };
}
else
{
throw
std::runtime_error
(
R"ex(
Message::getBody is not implemented
)ex"
);
}
}
[[nodiscard]]
service::AwaitableScalar<response::IdType>
getSender
(service::FieldParams&& params)
const
final
{
if
constexpr
(methods::MessageHas::getSenderWithParams<T>)
{
return
{ _pimpl->
getSender
(
std::move
(params)) };
}
else
if
constexpr
(methods::MessageHas::getSender<T>)
{
return
{ _pimpl->
getSender
() };
}
else
{
throw
std::runtime_error
(
R"ex(
Message::getSender is not implemented
)ex"
);
}
}
void
beginSelectionSet
(
const
service::SelectionSetParams& params)
const
final
{
if
constexpr
(methods::MessageHas::beginSelectionSet<T>)
{
_pimpl->
beginSelectionSet
(params);
}
}
void
endSelectionSet
(
const
service::SelectionSetParams& params)
const
final
{
if
constexpr
(methods::MessageHas::endSelectionSet<T>)
{
_pimpl->
endSelectionSet
(params);
}
}
private:
const
std::shared_ptr<T> _pimpl;
};
Message
(std::unique_ptr<
const
Concept>&& pimpl)
noexcept
;
[[nodiscard]]
service::TypeNames
getTypeNames
()
const
noexcept
;
[[nodiscard]]
service::ResolverMap
getResolvers
()
const
noexcept
;
void
beginSelectionSet
(
const
service::SelectionSetParams& params)
const
final
;
void
endSelectionSet
(
const
service::SelectionSetParams& params)
const
final
;
const
std::unique_ptr<
const
Concept> _pimpl;
public:
template
<
class
T
>
Message
(std::shared_ptr<T> pimpl)
noexcept
: Message { std::unique_ptr<
const
Concept> { std::make_unique<Model<T>>(
std::move
(pimpl)) } }
{
}
[[nodiscard]]
static
constexpr
std::string_view
getObjectType
()
noexcept
{
return
{
R"gql(
Message
)gql"
};
}
};
}
//
namespace graphql::validation::object
#
endif
//
MESSAGEOBJECT_H
Back
|
FazBrowse Home
|
New Git URL