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

fix(apollo): Fix using Apollo to connect to AppSync in China #2947

Merged
merged 2 commits into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import java.net.URL
import okhttp3.HttpUrl.Companion.toHttpUrlOrNull

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

/**
* Class representing the AppSync endpoint. There are multiple URLs associated with each AppSync endpoint: the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import org.junit.Test

class AppSyncEndpointTest {
private val standardAppSyncUrl = "https://example1234567890123456789.appsync-api.us-east-1.amazonaws.com/graphql"
private val standardAppSyncUrlChina =
"https://example1234567890123456789.appsync-api.us-east-1.amazonaws.com.cn/graphql"
private val customAppSyncUrl = "https://api.example.com/graphql"

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

@Test
fun `uses expected realtime URL for standard endpoint in China`() {
val endpoint = AppSyncEndpoint(standardAppSyncUrlChina)
endpoint.websocketConnection.toString() shouldBe
"https://example1234567890123456789.appsync-realtime-api.us-east-1.amazonaws.com.cn/graphql/connect"
}

@Test
fun `uses expected realtime URL for custom endpoint`() {
val endpoint = AppSyncEndpoint(customAppSyncUrl)
Expand Down
Loading