Skip to content

Commit

Permalink
handle nullable domainName field
Browse files Browse the repository at this point in the history
  • Loading branch information
svozza committed Nov 12, 2024
1 parent 5425f45 commit 23fd85c
Show file tree
Hide file tree
Showing 12 changed files with 70 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/parser/src/schemas/appsync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
56 changes: 56 additions & 0 deletions packages/parser/tests/events/appsync/custom-domain-name.json
Original file line number Diff line number Diff line change
@@ -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": {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions packages/parser/tests/events/appsync/lambda-identity.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
}
},
"request": {
"domainName": null,
"headers": {
"x-forwarded-for": "1.1.1.1, 2.2.2.2",
"cloudfront-viewer-country": "US",
Expand Down
1 change: 1 addition & 0 deletions packages/parser/tests/events/appsync/no-identity.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
}
},
"request": {
"domainName": null,
"headers": {
"x-forwarded-for": "1.1.1.1, 2.2.2.2",
"cloudfront-viewer-country": "US",
Expand Down
1 change: 1 addition & 0 deletions packages/parser/tests/events/appsync/null-prev.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
}
},
"request": {
"domainName": null,
"headers": {
"x-forwarded-for": "1.1.1.1, 2.2.2.2",
"cloudfront-viewer-country": "US",
Expand Down
1 change: 1 addition & 0 deletions packages/parser/tests/events/appsync/null-source.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions packages/parser/tests/events/appsync/oidc-identity.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 4 additions & 0 deletions packages/parser/tests/unit/schema/appsync.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit 23fd85c

Please sign in to comment.