Skip to content

Commit ee5290d

Browse files
committed
fix: apply serde annotations and generic types to align with existing conventions
1 parent 582ddec commit ee5290d

File tree

1 file changed

+38
-14
lines changed
  • lambda-events/src/event/appsync

1 file changed

+38
-14
lines changed

lambda-events/src/event/appsync/mod.rs

Lines changed: 38 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -130,23 +130,33 @@ where
130130
/// See also:
131131
/// - [AppSync resolver mapping template context reference](https://docs.aws.amazon.com/appsync/latest/devguide/resolver-context-reference.html)
132132
#[derive(Debug, Clone, Eq, PartialEq, Deserialize, Serialize)]
133-
pub struct AppSyncResolverEvent<TArguments = Option<Value>, TSource = Option<Value>> {
134-
pub arguments: TArguments,
133+
pub struct AppSyncResolverEvent<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>,
135141
pub identity: Option<AppSyncIdentity>,
136-
pub source: TSource,
142+
#[serde(bound = "")]
143+
pub source: Option<TSource>,
137144
pub request: AppSyncRequest,
138145
pub info: AppSyncInfo,
139146
#[serde(default)]
140147
pub prev: Option<AppSyncPrevResult>,
141-
pub stash: HashMap<String, Value>,
148+
#[serde(bound = "")]
149+
pub stash: TStash,
142150
}
143151

144152
/// `AppSyncRequest` contains request-related metadata for a resolver invocation,
145153
/// including client-sent headers and optional custom domain name.
146154
#[derive(Debug, Clone, Eq, PartialEq, Deserialize, Serialize)]
147155
#[serde(rename_all = "camelCase")]
148156
pub struct AppSyncRequest {
157+
#[serde(deserialize_with = "deserialize_lambda_map")]
149158
#[serde(default)]
159+
#[serde(bound = "")]
150160
pub headers: HashMap<String, Option<String>>,
151161
#[serde(default)]
152162
pub domain_name: Option<String>,
@@ -155,22 +165,28 @@ pub struct AppSyncRequest {
155165
/// `AppSyncInfo` contains metadata about the current GraphQL field being resolved.
156166
#[derive(Debug, Clone, Eq, PartialEq, Deserialize, Serialize)]
157167
#[serde(rename_all = "camelCase")]
158-
pub struct AppSyncInfo {
168+
pub struct AppSyncInfo<T = Value>
169+
where
170+
T: Serialize + DeserializeOwned,
171+
{
159172
#[serde(default)]
160173
pub selection_set_list: Vec<String>,
161174
#[serde(rename = "selectionSetGraphQL")]
162175
pub selection_set_graphql: String,
163176
pub parent_type_name: String,
164177
pub field_name: String,
165-
#[serde(default)]
166-
pub variables: HashMap<String, Value>,
178+
#[serde(bound = "")]
179+
pub variables: T,
167180
}
168181

169182
/// `AppSyncPrevResult` contains the result of the previous step in a pipeline resolver.
170183
#[derive(Debug, Clone, Eq, PartialEq, Deserialize, Serialize)]
171-
pub struct AppSyncPrevResult {
172-
#[serde(default)]
173-
pub result: HashMap<String, Value>,
184+
pub struct AppSyncPrevResult<T = Value>
185+
where
186+
T: Serialize + DeserializeOwned,
187+
{
188+
#[serde(bound = "")]
189+
pub result: T,
174190
}
175191

176192
/// `AppSyncIdentity` represents the identity of the caller as determined by the
@@ -186,17 +202,25 @@ pub enum AppSyncIdentity {
186202

187203
/// `AppSyncIdentityOIDC` represents identity information when using OIDC-based authorization.
188204
#[derive(Debug, Clone, Eq, PartialEq, Deserialize, Serialize)]
189-
pub struct AppSyncIdentityOIDC {
190-
pub claims: Value,
205+
pub struct AppSyncIdentityOIDC<T = Value>
206+
where
207+
T: Serialize + DeserializeOwned,
208+
{
209+
#[serde(bound = "")]
210+
pub claims: T,
191211
pub issuer: String,
192212
pub sub: String,
193213
}
194214

195215
/// `AppSyncIdentityLambda` represents identity information when using AWS Lambda
196216
#[derive(Debug, Clone, Eq, PartialEq, Deserialize, Serialize)]
197217
#[serde(rename_all = "camelCase")]
198-
pub struct AppSyncIdentityLambda {
199-
pub resolver_context: Value,
218+
pub struct AppSyncIdentityLambda<T = Value>
219+
where
220+
T: Serialize + DeserializeOwned,
221+
{
222+
#[serde(bound = "")]
223+
pub resolver_context: T,
200224
}
201225

202226
#[cfg(test)]

0 commit comments

Comments
 (0)