Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion packages/amplify-data-construct/.jsii
Original file line number Diff line number Diff line change
Expand Up @@ -1375,6 +1375,19 @@
}
}
},
"aws-cdk-lib.aws_dsql": {
"targets": {
"dotnet": {
"package": "Amazon.CDK.AWS.DSQL"
},
"java": {
"package": "software.amazon.awscdk.services.dsql"
},
"python": {
"module": "aws_cdk.aws_dsql"
}
}
},
"aws-cdk-lib.aws_dynamodb": {
"targets": {
"dotnet": {
Expand Down Expand Up @@ -4109,5 +4122,5 @@
},
"types": {},
"version": "1.16.1",
"fingerprint": "RmejNooIcfMZHBiK6PXB+e2XH6v5bdARzogf0gvsW9Q="
"fingerprint": "/ibLSIPW39LJ28MtSyskiOwCoijSx8eBTWO+BhuVXwE="
}
15 changes: 14 additions & 1 deletion packages/amplify-graphql-api-construct/.jsii
Original file line number Diff line number Diff line change
Expand Up @@ -1367,6 +1367,19 @@
}
}
},
"aws-cdk-lib.aws_dsql": {
"targets": {
"dotnet": {
"package": "Amazon.CDK.AWS.DSQL"
},
"java": {
"package": "software.amazon.awscdk.services.dsql"
},
"python": {
"module": "aws_cdk.aws_dsql"
}
}
},
"aws-cdk-lib.aws_dynamodb": {
"targets": {
"dotnet": {
Expand Down Expand Up @@ -9513,5 +9526,5 @@
}
},
"version": "1.20.1",
"fingerprint": "+StR3FqEAlc1IFZPMqvjS5CUe5YnkTLZS2rMNf1BHPA="
"fingerprint": "oNtoWovWTY04XL/toJV/tRugU0fwH6LEnKJEbslPXlM="
}
Original file line number Diff line number Diff line change
Expand Up @@ -186,5 +186,31 @@ describe('Transformer Core Util Tests', () => {
expect(newArgs.timestamps.createdAt).toEqual('createdOn');
expect(newArgs.timestamps.updatedAt).toEqual('updatedOn');
});

it(': Should skip location when deep cloning', () => {
// Cloning token locations is expensive and not useful (they're read only).
// Some transformers are passing AST nodes to 'getArguments'
// Assert that we don't clone them.
const parsedDoc = parse(schema);
const objNode = parsedDoc?.definitions?.[0] as ObjectTypeDefinitionNode;
const modelDir = objNode?.directives?.[0] as DirectiveNode;
const wrappedDir = new DirectiveWrapper(modelDir);

const argsWithASTNodes = {
// add some args that are AST nodes.
objNode,
modelDir,
// include common args to trigger deep merging.
...cloneDeep(defaultArgs),
};

const newArgs = wrappedDir.getArguments(argsWithASTNodes, { deepMergeArguments: true });
// Assert that args were cloned.
expect(newArgs.objNode === objNode).toBeFalsy();
expect(newArgs.modelDir === modelDir).toBeFalsy();
// Assert that locations were not cloned.
expect(newArgs.objNode.loc === objNode.loc).toBeTruthy();
expect(newArgs.modelDir.loc === modelDir.loc).toBeTruthy();
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,24 @@ export class DirectiveWrapper {
{},
);
if (options?.deepMergeArguments && needsDeepMerge(defaultValue, argValues)) {
return _.merge(_.cloneDeep(defaultValue), argValues);
return _.merge(
_.cloneDeepWith(defaultValue, (value) => {
if (value instanceof Location) {
// Skip cloning for 'Locations'
// Some transformers are using AST nodes as arguments.
// These AST nodes contain 'loc: Location' property which contains information
// about where tokens were found in the schema during parsing.
// This is a deeply nested structure for large schemas and cloning it may
// hit recursive call limits.
// Location is typed as read-only and doesn't change in post processing after parsing.
// Therefore, is safe to keep original values.
return value;
}
// Returning undefined let's Lodash know to use it's algorithm to clone.
return undefined;
}),
argValues,
);
}
return Object.assign(defaultValue, argValues);
};
Expand Down
31 changes: 3 additions & 28 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -17022,16 +17022,7 @@ string-length@^4.0.1:
char-regex "^1.0.2"
strip-ansi "^6.0.0"

"string-width-cjs@npm:string-width@^4.2.0":
version "4.2.3"
resolved "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
dependencies:
emoji-regex "^8.0.0"
is-fullwidth-code-point "^3.0.0"
strip-ansi "^6.0.1"

"string-width@^1.0.2 || 2 || 3 || 4", string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
"string-width-cjs@npm:string-width@^4.2.0", "string-width@^1.0.2 || 2 || 3 || 4", string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
version "4.2.3"
resolved "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
Expand Down Expand Up @@ -17153,7 +17144,7 @@ string_decoder@~1.1.1:
dependencies:
safe-buffer "~5.1.0"

"strip-ansi-cjs@npm:strip-ansi@^6.0.1":
"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1:
version "6.0.1"
resolved "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
Expand All @@ -17174,13 +17165,6 @@ strip-ansi@^5.1.0, strip-ansi@^5.2.0:
dependencies:
ansi-regex "^4.1.0"

strip-ansi@^6.0.0, strip-ansi@^6.0.1:
version "6.0.1"
resolved "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
dependencies:
ansi-regex "^5.0.1"

strip-ansi@^7.0.1, strip-ansi@^7.1.0:
version "7.1.0"
resolved "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.0.tgz#d5b6568ca689d8561370b0707685d22434faff45"
Expand Down Expand Up @@ -18188,7 +18172,7 @@ workerpool@^6.5.1:
resolved "https://registry.npmjs.org/workerpool/-/workerpool-6.5.1.tgz#060f73b39d0caf97c6db64da004cd01b4c099544"
integrity sha512-Fs4dNYcsdpYSAfVxhnl1L5zTksjvOJxtC5hzMNl+1t9B8hTJTdKDyZ5ju7ztgPy+ft9tBFXoOlDNiOT9WUXZlA==

"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0":
"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0:
version "7.0.0"
resolved "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
Expand All @@ -18206,15 +18190,6 @@ wrap-ansi@^6.0.1, wrap-ansi@^6.2.0:
string-width "^4.1.0"
strip-ansi "^6.0.0"

wrap-ansi@^7.0.0:
version "7.0.0"
resolved "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
dependencies:
ansi-styles "^4.0.0"
string-width "^4.1.0"
strip-ansi "^6.0.0"

wrap-ansi@^8.1.0:
version "8.1.0"
resolved "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-8.1.0.tgz#56dc22368ee570face1b49819975d9b9a5ead214"
Expand Down
Loading