diff --git a/packages/parser/src/schemas/appsync.ts b/packages/parser/src/schemas/appsync.ts index 0ef16a295..c3f5daece 100644 --- a/packages/parser/src/schemas/appsync.ts +++ b/packages/parser/src/schemas/appsync.ts @@ -110,6 +110,7 @@ const AppSyncResolverSchema = z.object({ identity: z.optional(AppSyncIdentity), source: z.record(z.any()).nullable(), request: z.object({ + domainName: z.string().nullable(), headers: z.record(z.string()), }), info: z.object({ diff --git a/packages/parser/tests/events/appsync/cognito-identity-group.json b/packages/parser/tests/events/appsync/cognito-identity-group.json index 5d5f91d9b..ec2b94d34 100644 --- a/packages/parser/tests/events/appsync/cognito-identity-group.json +++ b/packages/parser/tests/events/appsync/cognito-identity-group.json @@ -33,6 +33,7 @@ "username": "jdoe" }, "request": { + "domainName": null, "headers": { "x-forwarded-for": "1.1.1.1, 2.2.2.2", "cloudfront-viewer-country": "US", diff --git a/packages/parser/tests/events/appsync/cognito-identity-null-group.json b/packages/parser/tests/events/appsync/cognito-identity-null-group.json index 38012a7ed..b6e68142d 100644 --- a/packages/parser/tests/events/appsync/cognito-identity-null-group.json +++ b/packages/parser/tests/events/appsync/cognito-identity-null-group.json @@ -33,6 +33,7 @@ "username": "jdoe" }, "request": { + "domainName": null, "headers": { "x-forwarded-for": "1.1.1.1, 2.2.2.2", "cloudfront-viewer-country": "US", diff --git a/packages/parser/tests/events/appsync/custom-domain-name.json b/packages/parser/tests/events/appsync/custom-domain-name.json new file mode 100644 index 000000000..3b020994c --- /dev/null +++ b/packages/parser/tests/events/appsync/custom-domain-name.json @@ -0,0 +1,56 @@ +{ + "arguments": { + "id": "my identifier" + }, + "source": { + "name": "Value", + "nested": { + "name": "value", + "list": [] + } + }, + "request": { + "domainName": "mycustomdomain.example.com", + "headers": { + "x-forwarded-for": "1.1.1.1, 2.2.2.2", + "cloudfront-viewer-country": "US", + "cloudfront-is-tablet-viewer": "false", + "via": "2.0 xxxxxxxxxxxxxxxx.cloudfront.net (CloudFront)", + "cloudfront-forwarded-proto": "https", + "origin": "https://us-west-1.console.aws.amazon.com", + "content-length": "217", + "accept-language": "en-US,en;q=0.9", + "host": "xxxxxxxxxxxxxxxx.appsync-api.us-west-1.amazonaws.com", + "x-forwarded-proto": "https", + "user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36", + "accept": "*/*", + "cloudfront-is-mobile-viewer": "false", + "cloudfront-is-smarttv-viewer": "false", + "accept-encoding": "gzip, deflate, br", + "referer": "https://us-west-1.console.aws.amazon.com/appsync/home?region=us-west-1", + "content-type": "application/json", + "sec-fetch-mode": "cors", + "x-amz-cf-id": "3aykhqlUwQeANU-HGY7E_guV5EkNeMMtwyOgiA==", + "x-amzn-trace-id": "Root=1-5f512f51-fac632066c5e848ae714", + "authorization": "eyJraWQiOiJScWFCSlJqYVJlM0hrSnBTUFpIcVRXazNOW...", + "sec-fetch-dest": "empty", + "x-amz-user-agent": "AWS-Console-AppSync/", + "cloudfront-is-desktop-viewer": "true", + "sec-fetch-site": "cross-site", + "x-forwarded-port": "443" + } + }, + "prev": { + "result": { + "field1": "value1" + } + }, + "info": { + "selectionSetList": ["id", "field1", "field2"], + "selectionSetGraphQL": "{\n id\n field1\n field2\n}", + "parentTypeName": "Mutation", + "fieldName": "createSomething", + "variables": {} + }, + "stash": {} +} diff --git a/packages/parser/tests/events/appsync/iam-identity-cognito.json b/packages/parser/tests/events/appsync/iam-identity-cognito.json index 7433bd5fb..1f37cc38d 100644 --- a/packages/parser/tests/events/appsync/iam-identity-cognito.json +++ b/packages/parser/tests/events/appsync/iam-identity-cognito.json @@ -20,6 +20,7 @@ "username": "AROAXYKJUOW6FHGUSK5FA:username" }, "request": { + "domainName": null, "headers": { "x-forwarded-for": "1.1.1.1, 2.2.2.2", "cloudfront-viewer-country": "US", diff --git a/packages/parser/tests/events/appsync/iam-identity-no-cognito.json b/packages/parser/tests/events/appsync/iam-identity-no-cognito.json index be729066d..5d141b050 100644 --- a/packages/parser/tests/events/appsync/iam-identity-no-cognito.json +++ b/packages/parser/tests/events/appsync/iam-identity-no-cognito.json @@ -20,6 +20,7 @@ "username": "AROAXYKJUOW6FHGUSK5FA:username" }, "request": { + "domainName": null, "headers": { "x-forwarded-for": "1.1.1.1, 2.2.2.2", "cloudfront-viewer-country": "US", diff --git a/packages/parser/tests/events/appsync/lambda-identity.json b/packages/parser/tests/events/appsync/lambda-identity.json index 7a3574208..0e7c92841 100644 --- a/packages/parser/tests/events/appsync/lambda-identity.json +++ b/packages/parser/tests/events/appsync/lambda-identity.json @@ -15,6 +15,7 @@ } }, "request": { + "domainName": null, "headers": { "x-forwarded-for": "1.1.1.1, 2.2.2.2", "cloudfront-viewer-country": "US", diff --git a/packages/parser/tests/events/appsync/no-identity.json b/packages/parser/tests/events/appsync/no-identity.json index 1162ae6d4..253128a21 100644 --- a/packages/parser/tests/events/appsync/no-identity.json +++ b/packages/parser/tests/events/appsync/no-identity.json @@ -10,6 +10,7 @@ } }, "request": { + "domainName": null, "headers": { "x-forwarded-for": "1.1.1.1, 2.2.2.2", "cloudfront-viewer-country": "US", diff --git a/packages/parser/tests/events/appsync/null-prev.json b/packages/parser/tests/events/appsync/null-prev.json index 22a4b8117..ecaa3e6af 100644 --- a/packages/parser/tests/events/appsync/null-prev.json +++ b/packages/parser/tests/events/appsync/null-prev.json @@ -10,6 +10,7 @@ } }, "request": { + "domainName": null, "headers": { "x-forwarded-for": "1.1.1.1, 2.2.2.2", "cloudfront-viewer-country": "US", diff --git a/packages/parser/tests/events/appsync/null-source.json b/packages/parser/tests/events/appsync/null-source.json index 13c86664c..eb8d06f04 100644 --- a/packages/parser/tests/events/appsync/null-source.json +++ b/packages/parser/tests/events/appsync/null-source.json @@ -4,6 +4,7 @@ }, "source": null, "request": { + "domainName": null, "headers": { "x-forwarded-for": "1.1.1.1, 2.2.2.2", "cloudfront-viewer-country": "US", diff --git a/packages/parser/tests/events/appsync/oidc-identity.json b/packages/parser/tests/events/appsync/oidc-identity.json index 8ec326485..74fc9b026 100644 --- a/packages/parser/tests/events/appsync/oidc-identity.json +++ b/packages/parser/tests/events/appsync/oidc-identity.json @@ -17,6 +17,7 @@ "sub": "sub" }, "request": { + "domainName": null, "headers": { "x-forwarded-for": "1.1.1.1, 2.2.2.2", "cloudfront-viewer-country": "US", diff --git a/packages/parser/tests/unit/schema/appsync.test.ts b/packages/parser/tests/unit/schema/appsync.test.ts index 91970e691..4330e42f1 100644 --- a/packages/parser/tests/unit/schema/appsync.test.ts +++ b/packages/parser/tests/unit/schema/appsync.test.ts @@ -33,6 +33,10 @@ describe('AppSync Resolver Schemas', () => { name: 'should parse resolver event with null prev', filename: 'null-prev', }, + { + name: 'should parse resolver event with custom domain name', + filename: 'custom-domain-name', + }, { name: 'should parse resolver event with cognito identity and rbac groups', filename: 'cognito-identity-group',