Skip to content

Commit

Permalink
fix(api-graphql): fix events url pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
iartemiev committed Oct 28, 2024
1 parent 5d549c3 commit fade122
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 18 deletions.
28 changes: 14 additions & 14 deletions .github/workflows/callable-e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,17 @@ jobs:
# timeout_minutes: ${{ matrix.integ-config.timeout_minutes || 35 }}
# retry_count: ${{ matrix.integ-config.retry_count || 3 }}

detox-e2e-test-runner:
name: E2E test runner
needs: e2e-prep
strategy:
matrix:
integ-config: ${{ fromJson(needs.e2e-prep.outputs.detox-integ-config) }}
fail-fast: false
secrets: inherit
uses: ./.github/workflows/callable-e2e-test-detox.yml
with:
test_name: ${{ matrix.integ-config.test_name }}
working_directory: ${{ matrix.integ-config.working_directory }}
timeout_minutes: ${{ matrix.integ-config.timeout_minutes || 45 }}
host_signout_page: ${{ matrix.integ-config.host_signout_page || false }}
# detox-e2e-test-runner:
# name: E2E test runner
# needs: e2e-prep
# strategy:
# matrix:
# integ-config: ${{ fromJson(needs.e2e-prep.outputs.detox-integ-config) }}
# fail-fast: false
# secrets: inherit
# uses: ./.github/workflows/callable-e2e-test-detox.yml
# with:
# test_name: ${{ matrix.integ-config.test_name }}
# working_directory: ${{ matrix.integ-config.working_directory }}
# timeout_minutes: ${{ matrix.integ-config.timeout_minutes || 45 }}
# host_signout_page: ${{ matrix.integ-config.host_signout_page || false }}
2 changes: 1 addition & 1 deletion .github/workflows/push-preid-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
push:
branches:
# Change this to your branch name where "example-preid" corresponds to the preid you want your changes released on
- feat/example-preid-branch/main
- feat/events/main

jobs:
e2e:
Expand Down
14 changes: 14 additions & 0 deletions packages/api-graphql/__tests__/appsyncUrl.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { getRealtimeEndpointUrl } from '../src/Providers/AWSWebSocketProvider/appsyncUrl';

describe('getRealtimeEndpointUrl', () => {
test('events', () => {
const httpUrl =
'https://abcdefghijklmnopqrstuvwxyz.appsync-api.us-east-1.amazonaws.com/event';

const res = getRealtimeEndpointUrl(httpUrl).toString();

expect(res).toEqual(
'wss://abcdefghijklmnopqrstuvwxyz.appsync-realtime-api.us-east-1.amazonaws.com/event/realtime',
);
});
});
3 changes: 2 additions & 1 deletion packages/api-graphql/__tests__/events.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { AppSyncEventProvider } from '../src/Providers/AWSAppSyncEventsProvider'

import { events } from '../src/';
import { appsyncRequest } from '../src/internals/events/appsyncRequest';

import { GraphQLAuthMode } from '@aws-amplify/core/internals/utils';

const abortController = new AbortController();
Expand Down Expand Up @@ -38,7 +39,7 @@ jest.mock('../src/internals/events/appsyncRequest', () => {
* so we're just sanity checking that the expected auth mode is passed to the provider in this test file.
*/

describe('Events', () => {
describe('Events client', () => {
afterAll(() => {
jest.resetAllMocks();
jest.clearAllMocks();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const protocol = 'wss://';
const standardDomainPattern =
/^https:\/\/\w{26}\.appsync-api\.\w{2}(?:(?:-\w{2,})+)-\d\.amazonaws.com(?:\.cn)?\/graphql$/i;
const eventDomainPattern =
/^https:\/\/\w{26}\.ddpg-api\.\w{2}(?:(?:-\w{2,})+)-\d\.amazonaws.com(?:\.cn)?\/event$/i;
/^https:\/\/\w{26}\.\w+-api\.\w{2}(?:(?:-\w{2,})+)-\d\.amazonaws.com(?:\.cn)?\/event$/i;
const customDomainPath = '/realtime';

export const isCustomDomain = (url: string): boolean => {
Expand All @@ -31,7 +31,8 @@ export const getRealtimeEndpointUrl = (
if (isEventDomain(realtimeEndpoint)) {
realtimeEndpoint = realtimeEndpoint
.concat(customDomainPath)
.replace('ddpg-api', 'grt-gamma');
.replace('ddpg-api', 'grt-gamma')
.replace('appsync-api', 'appsync-realtime-api');
} else if (isCustomDomain(realtimeEndpoint)) {
realtimeEndpoint = realtimeEndpoint.concat(customDomainPath);
} else {
Expand Down

0 comments on commit fade122

Please sign in to comment.