Skip to content

Commit 59bde4e

Browse files
authored
fix(apollo): Fix using Apollo to connect to AppSync in China (#2947)
1 parent 7199b84 commit 59bde4e

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

apollo/apollo-appsync/src/main/java/com/amplifyframework/apollo/appsync/AppSyncEndpoint.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import java.net.URL
2121
import okhttp3.HttpUrl.Companion.toHttpUrlOrNull
2222

2323
private val standardEndpointRegex =
24-
"^https://\\w{26}\\.appsync-api\\.\\w{2}(?:-\\w{2,})+-\\d\\.amazonaws.com/graphql$".toRegex()
24+
"^https://\\w{26}\\.appsync-api\\.\\w{2}(?:-\\w{2,})+-\\d\\.amazonaws.com(?:\\.cn)?/graphql$".toRegex()
2525

2626
/**
2727
* Class representing the AppSync endpoint. There are multiple URLs associated with each AppSync endpoint: the

apollo/apollo-appsync/src/test/java/com/amplifyframework/apollo/appsync/AppSyncEndpointTest.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ import org.junit.Test
2626

2727
class AppSyncEndpointTest {
2828
private val standardAppSyncUrl = "https://example1234567890123456789.appsync-api.us-east-1.amazonaws.com/graphql"
29+
private val standardAppSyncUrlChina =
30+
"https://example1234567890123456789.appsync-api.us-east-1.amazonaws.com.cn/graphql"
2931
private val customAppSyncUrl = "https://api.example.com/graphql"
3032

3133
@Test
@@ -48,6 +50,13 @@ class AppSyncEndpointTest {
4850
"https://example1234567890123456789.appsync-realtime-api.us-east-1.amazonaws.com/graphql/connect"
4951
}
5052

53+
@Test
54+
fun `uses expected realtime URL for standard endpoint in China`() {
55+
val endpoint = AppSyncEndpoint(standardAppSyncUrlChina)
56+
endpoint.websocketConnection.toString() shouldBe
57+
"https://example1234567890123456789.appsync-realtime-api.us-east-1.amazonaws.com.cn/graphql/connect"
58+
}
59+
5160
@Test
5261
fun `uses expected realtime URL for custom endpoint`() {
5362
val endpoint = AppSyncEndpoint(customAppSyncUrl)

0 commit comments

Comments
 (0)