function validateRequest()

in source/lambda/data-sources/machine-detail.ts [121:145]


function validateRequest(event: IAppSyncInput) {
    if (event.info.parentTypeName !== 'Query') {
        throw new Error(`Unexpected request type: ${event.info.parentTypeName}`);
    }

    if (event.info.fieldName !== 'getRealTimeMachineData') {
        throw new Error(`Unexpected Query type: ${event.info.fieldName}`);
    }

    if (!event.info.variables.startTimestamp || typeof event.info.variables.startTimestamp !== 'number') {
        throw new Error(`startTimestamp (${event.info.variables.startTimestamp}) must be a valid unix timestamp`);
    }

    if (!event.info.variables.endTimestamp || typeof event.info.variables.endTimestamp !== 'number') {
        throw new Error(`endTimestamp (${event.info.variables.endTimestamp}) must be a valid unix timestamp`);
    }

    if (!event.info.variables.id || event.info.variables.id.trim() === '') {
        throw new Error('id was not passed');
    }

    if (!event.info.variables.hasOwnProperty('incrementalRefresh')) {
        throw new Error('incrementalRefresh was not passed');
    }
}