В настоящее время у меня есть свой преобразователь как лямбда-функция:
import boto3
from boto3.dynamodb.conditions import Key
def lambda_handler(event, context):
list = []
for device in event['source']['devices'] :
dynamodb = boto3.resource('dynamodb')
readings = dynamodb.Table('readings')
response = readings.query(
KeyConditionExpression=Key('device').eq(device['device'])
)
items = response['Items']
list.extend(items)
return list
Я хотел бы иметь это как преобразователь VTL на Dynamodb. Моя проблема в том, что в моей таблице есть ключ сортировки
Это означает, что я не могу использовать пакетный преобразователь для запроса кучи идентификаторов, потому что мне также нужно будет предоставить ключ сортировки, а мне просто нужны все результаты по ключу первичного раздела.
Как вы запрашиваете набор идентификаторов с помощью VTL, в основном реплицируя мою лямбда-функцию в VTL. Это вообще возможно?
Схема добавлена, извините за беспорядок, это работа в стадии разработки, и я пытаюсь многое сделать. Все еще очень новичок в graphQL
type Device {
id: String
device: String!
}
input DeviceInput {
id: String
device: String!
}
type DeviceReadings {
devices: [Device]
}
type Mutation {
createDevice(input: DeviceInput): Device
}
type PaginatedDevices {
devices: [Device]
readings: [Reading]
cows: [cow]
nextToken: String
}
type Query {
getAllUserDevices(nextToken: String, count: Int): PaginatedDevices
getAllDeviceReadings: DeviceReadings
getAllUserReadings: DeviceReadings
getAllReadings(deviceId: String!): Readings
getCowReadings(cowId: String!): UserCowReadings
}
type Reading {
device: String
time: Int
cow: Int
battery: String
}
type Readings {
items: [Reading]
}
type UserCowReadings {
devices: [Device]
readings: [Reading]
}
type cow {
id: Int
device: String
nait: String
}
schema {
query: Query
mutation: Mutation
}