Skip to content

Instantly share code, notes, and snippets.

@shaykav
Last active March 26, 2021 03:58
Show Gist options
  • Save shaykav/c0a3bf55d7f089c316d56af4f1022604 to your computer and use it in GitHub Desktop.
Save shaykav/c0a3bf55d7f089c316d56af4f1022604 to your computer and use it in GitHub Desktop.
import { attribute, hashKey, rangeKey } from '@aws/dynamodb-data-mapper-annotations';
import { APIGatewayEventRequestContext } from 'aws-lambda';
@table('SUBSCRIPTION_TABLE')
export class Subscription {
/*
* Combination of connectionId and subscriptionId
* `${connectionId}|${subscriptionId}`
*/
@hashKey({ type: 'String' })
id: string;
@rangeKey({
type: 'String',
indexKeyConfigurations: { TopicIndex: 'HASH' },
})
topic: string;
@attribute({
type: 'String',
indexKeyConfigurations: { ConnectionIndex: 'HASH' },
})
connectionId: string;
@attribute({ defaultProvider: () => new Date() })
createdAt: Date;
@attribute()
requestContext: APIGatewayEventRequestContext;
/* Reference to connection_init payload */
@attribute()
connectionRef: object;
@attribute()
subscription: {
id: string;
query: string;
/** Actual value of variables for given field */
variables?: any;
/** Value of variables for user provided subscription */
variableValues?: any;
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment