Add idempotency (#6748)
* added idempotency router and middleware * added idempotency rules for routes classes, functions, jobs, installaions, users * fixed typo * ignore requests without header * removed unused var * enabled feature only for MongoDB * changed code comment * fixed inconsistend storage adapter specification * Trigger notification * Travis CI trigger * Travis CI trigger * Travis CI trigger * rebuilt option definitions * fixed incorrect import path * added new request ID header to allowed headers * fixed typescript typos * add new system class to spec helper * fixed typescript typos * re-added postgres conn parameter * removed postgres conn parameter * fixed incorrect schema for index creation * temporarily disabling index creation to fix postgres issue * temporarily disabling index creation to fix postgres issue * temporarily disabling index creation to fix postgres issue * temporarily disabling index creation to fix postgres issue * temporarily disabling index creation to fix postgres issue * temporarily disabling index creation to fix postgres issue * temporarily disabling index creation to fix postgres issue * trying to fix postgres issue * fixed incorrect auth when writing to _Idempotency * trying to fix postgres issue * Travis CI trigger * added test cases * removed number grouping * fixed test description * trying to fix postgres issue * added Github readme docs * added change log * refactored tests; fixed some typos * fixed test case * fixed default TTL value * Travis CI Trigger * Travis CI Trigger * Travis CI Trigger * added test case to increase coverage * Trigger Travis CI * changed configuration syntax to use regex; added test cases * removed unused vars * removed IdempotencyRouter * Trigger Travis CI * updated docs * updated docs * updated docs * updated docs * update docs * Trigger Travis CI * fixed coverage * removed code comments
This commit is contained in:
@@ -692,7 +692,7 @@ export class MongoStorageAdapter implements StorageAdapter {
|
||||
fieldNames: string[],
|
||||
indexName: ?string,
|
||||
caseInsensitive: boolean = false,
|
||||
indexType: any = 1
|
||||
options?: Object = {},
|
||||
): Promise<any> {
|
||||
schema = convertParseSchemaToMongoSchema(schema);
|
||||
const indexCreationRequest = {};
|
||||
@@ -700,11 +700,12 @@ export class MongoStorageAdapter implements StorageAdapter {
|
||||
transformKey(className, fieldName, schema)
|
||||
);
|
||||
mongoFieldNames.forEach((fieldName) => {
|
||||
indexCreationRequest[fieldName] = indexType;
|
||||
indexCreationRequest[fieldName] = options.indexType !== undefined ? options.indexType : 1;
|
||||
});
|
||||
|
||||
const defaultOptions: Object = { background: true, sparse: true };
|
||||
const indexNameOptions: Object = indexName ? { name: indexName } : {};
|
||||
const ttlOptions: Object = options.ttl !== undefined ? { expireAfterSeconds: options.ttl } : {};
|
||||
const caseInsensitiveOptions: Object = caseInsensitive
|
||||
? { collation: MongoCollection.caseInsensitiveCollation() }
|
||||
: {};
|
||||
@@ -712,6 +713,7 @@ export class MongoStorageAdapter implements StorageAdapter {
|
||||
...defaultOptions,
|
||||
...caseInsensitiveOptions,
|
||||
...indexNameOptions,
|
||||
...ttlOptions,
|
||||
};
|
||||
|
||||
return this._adaptiveCollection(className)
|
||||
|
||||
@@ -1209,6 +1209,7 @@ export class PostgresStorageAdapter implements StorageAdapter {
|
||||
'_GlobalConfig',
|
||||
'_GraphQLConfig',
|
||||
'_Audience',
|
||||
'_Idempotency',
|
||||
...results.map((result) => result.className),
|
||||
...joins,
|
||||
];
|
||||
@@ -2576,9 +2577,9 @@ export class PostgresStorageAdapter implements StorageAdapter {
|
||||
fieldNames: string[],
|
||||
indexName: ?string,
|
||||
caseInsensitive: boolean = false,
|
||||
conn: ?any = null
|
||||
options?: Object = {},
|
||||
): Promise<any> {
|
||||
conn = conn != null ? conn : this._client;
|
||||
const conn = options.conn !== undefined ? options.conn : this._client;
|
||||
const defaultIndexName = `parse_default_${fieldNames.sort().join('_')}`;
|
||||
const indexNameOptions: Object =
|
||||
indexName != null ? { name: indexName } : { name: defaultIndexName };
|
||||
|
||||
@@ -93,7 +93,7 @@ export interface StorageAdapter {
|
||||
fieldNames: string[],
|
||||
indexName?: string,
|
||||
caseSensitive?: boolean,
|
||||
indexType?: any
|
||||
options?: Object,
|
||||
): Promise<any>;
|
||||
ensureUniqueness(
|
||||
className: string,
|
||||
|
||||
Reference in New Issue
Block a user