Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(data): pass request options to custom header functions #12572

Merged
merged 61 commits into from
Dec 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
065c7f6
feat(data): add custom header support to data schema client
david-mcafee Nov 10, 2023
b48236b
Merge branch 'main' into tb-headers
david-mcafee Nov 10, 2023
0176020
add support for custom headers for individual requests
david-mcafee Nov 10, 2023
3b15680
update individual request headers; update comments; refactor utils an…
david-mcafee Nov 10, 2023
4fa8c45
Merge branch 'main' into tb-headers
david-mcafee Nov 10, 2023
2119013
cleanup
david-mcafee Nov 10, 2023
8355a5f
move 'CustomHeader' type to 'data-schema-types' package
david-mcafee Nov 10, 2023
4deafac
add unit tests
david-mcafee Nov 10, 2023
0439b07
Merge branch 'main' into tb-headers
david-mcafee Nov 10, 2023
83beba7
add comment
david-mcafee Nov 10, 2023
2945fb5
update comment
david-mcafee Nov 10, 2023
ef6a406
Merge branch 'main' into tb-headers
david-mcafee Nov 10, 2023
6c5a9c5
Merge branch 'main' into tb-headers
david-mcafee Nov 11, 2023
3b88039
Merge branch 'main' into tb-headers
david-mcafee Nov 11, 2023
5c029b2
update data-schema dependency
david-mcafee Nov 11, 2023
de5a0ca
custom header subscription tests
david-mcafee Nov 11, 2023
f0bbb18
ts strict mode updates
david-mcafee Nov 13, 2023
0a8c91e
Merge branch 'main' into tb-headers
david-mcafee Nov 13, 2023
0a62e0a
formatting
david-mcafee Nov 14, 2023
3cf2059
update tsconfig
david-mcafee Nov 14, 2023
18da01c
pull in type updates
david-mcafee Nov 14, 2023
0272dac
minor fix
david-mcafee Nov 14, 2023
73a34c6
Merge branch 'main' into tb-headers
david-mcafee Nov 14, 2023
63c4b5a
cleanup
david-mcafee Nov 14, 2023
d37dd15
test fix
david-mcafee Nov 14, 2023
a4f1769
custom header subscription fixes
david-mcafee Nov 14, 2023
08a5d44
AppSyncRealTimeProvider updates
david-mcafee Nov 15, 2023
1961e83
fix type for AWSAppSyncRealTimeProvider
david-mcafee Nov 15, 2023
1ec3a56
add comment
david-mcafee Nov 15, 2023
6a8651e
real time provider type updates
david-mcafee Nov 15, 2023
2a72796
real time provider fix
david-mcafee Nov 15, 2023
0af3e15
include auth token in functional headers
david-mcafee Nov 15, 2023
0c90418
Merge branch 'main' into fn-headers-args
david-mcafee Nov 15, 2023
cf1ea0e
checkpoint
david-mcafee Nov 16, 2023
698bd54
Merge branch 'main' into fn-headers-args
david-mcafee Nov 20, 2023
220a3a3
Merge branch 'main' into fn-headers-args
david-mcafee Nov 21, 2023
2590c6d
checkpoint
david-mcafee Nov 22, 2023
09a080a
update test
david-mcafee Nov 22, 2023
6ed4d72
update launch.json
david-mcafee Nov 22, 2023
165404d
update types
david-mcafee Nov 22, 2023
46da90b
Merge branch 'main' into fn-headers-args
david-mcafee Dec 7, 2023
2a441c2
cleanup
david-mcafee Dec 7, 2023
cfb55c8
update dependencies
david-mcafee Dec 8, 2023
6ef78e4
minor update to real time provider
david-mcafee Dec 8, 2023
bc1105f
update deps
david-mcafee Dec 8, 2023
b34877c
update yarn.lock
david-mcafee Dec 8, 2023
af44aeb
dep test
david-mcafee Dec 8, 2023
060b451
Revert "dep test"
david-mcafee Dec 8, 2023
e542596
regen yarn.lock
david-mcafee Dec 8, 2023
1151791
Revert "regen yarn.lock"
david-mcafee Dec 8, 2023
57b1f39
update yarn.lock
david-mcafee Dec 8, 2023
913c4a3
Merge branch 'main' into fn-headers-args
david-mcafee Dec 8, 2023
467faaf
fix lint error
david-mcafee Dec 8, 2023
8095221
update generateClient tests
david-mcafee Dec 11, 2023
01659ed
revert launch config
david-mcafee Dec 11, 2023
18fdd10
update deps
david-mcafee Dec 11, 2023
934d7d4
test fix
david-mcafee Dec 12, 2023
5db8c32
test fix
david-mcafee Dec 12, 2023
eef3b7e
cleanup
david-mcafee Dec 12, 2023
7d14675
update realtime provider test
david-mcafee Dec 12, 2023
55808f7
Merge branch 'main' into fn-headers-args
david-mcafee Dec 12, 2023
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
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"--inspect-brk",
"${workspaceRoot}/node_modules/.bin/jest",
// Optionally specify a single test file to run/debug:
"generateClient.test.ts",
"AWSAppSyncRealTimeProvider.test.ts",
"--runInBand",
"--testTimeout",
"600000", // 10 min timeout so jest doesn't error while we're stepping through code
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1104,6 +1104,33 @@ describe('AWSAppSyncRealTimeProvider', () => {
);
});

test('authenticating with AWS_LAMBDA/custom w/ custom header function that accepts request options', async () => {
expect.assertions(2);

provider
.subscribe({
appSyncGraphqlEndpoint: 'ws://localhost:8080',
authenticationType: 'none',
additionalHeaders: async requestOptions => {
expect(requestOptions).toEqual(
expect.objectContaining({
queryString: '',
url: 'ws://localhost:8080',
})
);
return { Authorization: 'test' };
},
})
.subscribe({ error: () => {} });

await fakeWebSocketInterface?.readyForUse;

expect(loggerSpy).toHaveBeenCalledWith(
'DEBUG',
'Authenticating with "none"'
);
});

test('authenticating with AWS_LAMBDA/custom without Authorization', async () => {
expect.assertions(1);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2772,6 +2772,63 @@ exports[`generateClient basic model operations - custom client and request heade
]
`;

exports[`generateClient basic model operations - custom client and request headers can create() - with custom client header functions that pass requestOptions 1`] = `
[
[
{
"abortController": AbortController {},
"options": {
"body": {
"query": "mutation ($input: CreateTodoInput!) {
createTodo(input: $input) {
id
name
description
status
tags
createdAt
updatedAt
todoMetaId
owner
}
}
",
"variables": {
"input": {
"description": "something something",
"name": "some name",
},
},
},
"headers": {
"X-Api-Key": "FAKE-KEY",
"rq-method": "POST",
"rq-qs": "mutation ($input: CreateTodoInput!) {
createTodo(input: $input) {
id
name
description
status
tags
createdAt
updatedAt
todoMetaId
owner
}
}
",
"rq-url": "https://localhost/graphql",
"x-amz-user-agent": "aws-amplify/latest api/latest framework/latest",
},
"signingServiceInfo": undefined,
"withCredentials": undefined,
},
"url": "https://localhost/graphql",
},
],
]
`;

exports[`generateClient basic model operations - custom client and request headers can create() - with custom client headers 1`] = `
[
[
Expand Down Expand Up @@ -2856,6 +2913,63 @@ exports[`generateClient basic model operations - custom client and request heade
]
`;

exports[`generateClient basic model operations - custom client and request headers can create() - with custom request header function that accept requestOptions 1`] = `
[
[
{
"abortController": AbortController {},
"options": {
"body": {
"query": "mutation ($input: CreateTodoInput!) {
createTodo(input: $input) {
id
name
description
status
tags
createdAt
updatedAt
todoMetaId
owner
}
}
",
"variables": {
"input": {
"description": "something something",
"name": "some name",
},
},
},
"headers": {
"X-Api-Key": "FAKE-KEY",
"rq-method": "POST",
"rq-qs": "mutation ($input: CreateTodoInput!) {
createTodo(input: $input) {
id
name
description
status
tags
createdAt
updatedAt
todoMetaId
owner
}
}
",
"rq-url": "https://localhost/graphql",
"x-amz-user-agent": "aws-amplify/latest api/latest framework/latest",
},
"signingServiceInfo": undefined,
"withCredentials": undefined,
},
"url": "https://localhost/graphql",
},
],
]
`;

exports[`generateClient basic model operations - custom client and request headers can create() - with custom request headers 1`] = `
[
[
Expand Down
Loading
Loading