I'm trying to figure out how I can retrieve properties which are deeply nested in AppSync. I currently have defined the dailyEnergyUsage
to retrieve these levels in a lambda resolver.
Consider the following schema I'm currently using:
query SomeQuery {
me {
energy {
dailyEnergyUsage { // The resolver function is only attached to the following type
...
}
}
}
}
The me top level query/object is supposed to group authenticated queries altogether and the energy does the same but then for the related functions related to energy usage etc.
DailyEnergyUsageResolver:
Type: "AWS::AppSync::Resolver"
Properties:
ApiId: !GetAtt AppSyncApi.ApiId
FieldName: "dailyEnergyUsage"
TypeName: "Energy"
DataSourceName: !GetAtt "DailyEnergyUsageDataSource.Name"
Currently I only have the DailyEnergyUsageResolver
to retrieve the energy usage which works fine if I don't have the grouping in between. But now I wanted to introduce this kind of grouping and was expecting that this would be automatically handled by AppSync but unfortunately doesn't work and returns null at the me
field.
type Query {
me: AuthenticatedQuery
}
type AuthenticatedQuery {
energy: Energy
}
type Energy {
dailyEnergyUsage: [DataPoint]
}
Now my question is how can I get the grouping working within AppSync using direct Lambda resolvers or Lambda as data source?
I've tried to check the documentation of AWS and checked this Stackoverflow thread but I don't know if it is the solution and how to get it to working.