@@ -117,6 +117,112 @@ where
117
117
pub ttl_override : Option < i64 > ,
118
118
}
119
119
120
+ /// `AppSyncDirectResolverEvent` represents the default payload structure sent by AWS AppSync
121
+ /// when using **Direct Lambda Resolvers** (i.e., when both request and response mapping
122
+ /// templates are disabled).
123
+ ///
124
+ /// This structure includes the full AppSync **Context object**, as described in the
125
+ /// [AppSync Direct Lambda resolver reference](https://docs.aws.amazon.com/appsync/latest/devguide/direct-lambda-reference.html).
126
+ ///
127
+ /// It is recommended when working without VTL templates and relying on the standard
128
+ /// AppSync-to-Lambda event format.
129
+ ///
130
+ /// See also:
131
+ /// - [AppSync resolver mapping template context reference](https://docs.aws.amazon.com/appsync/latest/devguide/resolver-context-reference.html)
132
+ #[ derive( Debug , Clone , Eq , PartialEq , Deserialize , Serialize ) ]
133
+ pub struct AppSyncDirectResolverEvent < TArguments = Value , TSource = Value , TStash = Value >
134
+ where
135
+ TArguments : Serialize + DeserializeOwned ,
136
+ TSource : Serialize + DeserializeOwned ,
137
+ TStash : Serialize + DeserializeOwned ,
138
+ {
139
+ #[ serde( bound = "" ) ]
140
+ pub arguments : Option < TArguments > ,
141
+ pub identity : Option < AppSyncIdentity > ,
142
+ #[ serde( bound = "" ) ]
143
+ pub source : Option < TSource > ,
144
+ pub request : AppSyncRequest ,
145
+ pub info : AppSyncInfo ,
146
+ #[ serde( default ) ]
147
+ pub prev : Option < AppSyncPrevResult > ,
148
+ #[ serde( bound = "" ) ]
149
+ pub stash : TStash ,
150
+ }
151
+
152
+ /// `AppSyncRequest` contains request-related metadata for a resolver invocation,
153
+ /// including client-sent headers and optional custom domain name.
154
+ #[ derive( Debug , Clone , Eq , PartialEq , Deserialize , Serialize ) ]
155
+ #[ serde( rename_all = "camelCase" ) ]
156
+ pub struct AppSyncRequest {
157
+ #[ serde( deserialize_with = "deserialize_lambda_map" ) ]
158
+ #[ serde( default ) ]
159
+ #[ serde( bound = "" ) ]
160
+ pub headers : HashMap < String , Option < String > > ,
161
+ #[ serde( default ) ]
162
+ pub domain_name : Option < String > ,
163
+ }
164
+
165
+ /// `AppSyncInfo` contains metadata about the current GraphQL field being resolved.
166
+ #[ derive( Debug , Clone , Eq , PartialEq , Deserialize , Serialize ) ]
167
+ #[ serde( rename_all = "camelCase" ) ]
168
+ pub struct AppSyncInfo < T = Value >
169
+ where
170
+ T : Serialize + DeserializeOwned ,
171
+ {
172
+ #[ serde( default ) ]
173
+ pub selection_set_list : Vec < String > ,
174
+ #[ serde( rename = "selectionSetGraphQL" ) ]
175
+ pub selection_set_graphql : String ,
176
+ pub parent_type_name : String ,
177
+ pub field_name : String ,
178
+ #[ serde( bound = "" ) ]
179
+ pub variables : T ,
180
+ }
181
+
182
+ /// `AppSyncPrevResult` contains the result of the previous step in a pipeline resolver.
183
+ #[ derive( Debug , Clone , Eq , PartialEq , Deserialize , Serialize ) ]
184
+ pub struct AppSyncPrevResult < T = Value >
185
+ where
186
+ T : Serialize + DeserializeOwned ,
187
+ {
188
+ #[ serde( bound = "" ) ]
189
+ pub result : T ,
190
+ }
191
+
192
+ /// `AppSyncIdentity` represents the identity of the caller as determined by the
193
+ /// configured AppSync authorization mechanism (IAM, Cognito, OIDC, or Lambda).
194
+ #[ derive( Debug , Clone , Eq , PartialEq , Deserialize , Serialize ) ]
195
+ #[ serde( untagged, rename_all = "camelCase" ) ]
196
+ pub enum AppSyncIdentity {
197
+ IAM ( AppSyncIamIdentity ) ,
198
+ Cognito ( AppSyncCognitoIdentity ) ,
199
+ OIDC ( AppSyncIdentityOIDC ) ,
200
+ Lambda ( AppSyncIdentityLambda ) ,
201
+ }
202
+
203
+ /// `AppSyncIdentityOIDC` represents identity information when using OIDC-based authorization.
204
+ #[ derive( Debug , Clone , Eq , PartialEq , Deserialize , Serialize ) ]
205
+ pub struct AppSyncIdentityOIDC < T = Value >
206
+ where
207
+ T : Serialize + DeserializeOwned ,
208
+ {
209
+ #[ serde( bound = "" ) ]
210
+ pub claims : T ,
211
+ pub issuer : String ,
212
+ pub sub : String ,
213
+ }
214
+
215
+ /// `AppSyncIdentityLambda` represents identity information when using AWS Lambda
216
+ #[ derive( Debug , Clone , Eq , PartialEq , Deserialize , Serialize ) ]
217
+ #[ serde( rename_all = "camelCase" ) ]
218
+ pub struct AppSyncIdentityLambda < T = Value >
219
+ where
220
+ T : Serialize + DeserializeOwned ,
221
+ {
222
+ #[ serde( bound = "" ) ]
223
+ pub resolver_context : T ,
224
+ }
225
+
120
226
#[ cfg( test) ]
121
227
mod test {
122
228
use super :: * ;
@@ -160,4 +266,14 @@ mod test {
160
266
let reparsed: AppSyncLambdaAuthorizerResponse = serde_json:: from_slice ( output. as_bytes ( ) ) . unwrap ( ) ;
161
267
assert_eq ! ( parsed, reparsed) ;
162
268
}
269
+
270
+ #[ test]
271
+ #[ cfg( feature = "appsync" ) ]
272
+ fn example_appsync_direct_resolver ( ) {
273
+ let data = include_bytes ! ( "../../fixtures/example-appsync-direct-resolver.json" ) ;
274
+ let parsed: AppSyncDirectResolverEvent = serde_json:: from_slice ( data) . unwrap ( ) ;
275
+ let output: String = serde_json:: to_string ( & parsed) . unwrap ( ) ;
276
+ let reparsed: AppSyncDirectResolverEvent = serde_json:: from_slice ( output. as_bytes ( ) ) . unwrap ( ) ;
277
+ assert_eq ! ( parsed, reparsed) ;
278
+ }
163
279
}
0 commit comments