-
Notifications
You must be signed in to change notification settings - Fork 645
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HTTP Headers: remove
X-APOLLO-OPERATION-NAME
, `X-APOLLO-OPERATION-I…
…D` and the multipart boundary (#5533) * use new router headers * remove X-APOLLO-OPERATION-NAME and X-APOLLO-OPERATION-ID * move docs to a separate PR * send apollo-require-preflight and add tests
- Loading branch information
1 parent
df8e352
commit d2112b2
Showing
10 changed files
with
137 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
plugins { | ||
id("org.jetbrains.kotlin.jvm") | ||
id("com.apollographql.apollo3") | ||
} | ||
|
||
apolloTest() | ||
|
||
dependencies { | ||
implementation(libs.apollo.runtime) | ||
implementation(libs.apollo.mockserver) | ||
testImplementation(libs.kotlin.test.junit) | ||
testImplementation(libs.apollo.testingsupport) | ||
} | ||
|
||
apollo { | ||
service("service") { | ||
packageName.set("httpheaders") | ||
mapScalarToUpload("Upload") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
query GetRandom { | ||
random | ||
} | ||
|
||
mutation Upload($upload: Upload) { | ||
upload(upload: $upload) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
type Query { | ||
random: Int! | ||
} | ||
|
||
type Mutation { | ||
upload(upload: Upload): String | ||
} | ||
|
||
scalar Upload |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
|
||
import com.apollographql.apollo3.api.DefaultUpload | ||
import com.apollographql.apollo3.api.Optional | ||
import com.apollographql.apollo3.mockserver.enqueueString | ||
import com.apollographql.apollo3.mockserver.headerValueOf | ||
import com.apollographql.apollo3.testing.mockServerTest | ||
import httpheaders.GetRandomQuery | ||
import httpheaders.UploadMutation | ||
import kotlin.test.Test | ||
import kotlin.test.assertEquals | ||
|
||
class HttpHeadersTest { | ||
@Test | ||
fun postRequestsDoNotSendPreflightHeader() = mockServerTest { | ||
|
||
mockServer.enqueueString("") | ||
apolloClient.query(GetRandomQuery()).execute() | ||
|
||
mockServer.takeRequest().apply { | ||
assertEquals(null, headers.headerValueOf("apollo-require-preflight")) | ||
} | ||
} | ||
|
||
@Test | ||
fun getRequestsSendPreflightHeader() = mockServerTest( | ||
clientBuilder = { autoPersistedQueries() } | ||
){ | ||
|
||
mockServer.enqueueString("") | ||
apolloClient.query(GetRandomQuery()).enableAutoPersistedQueries(true).execute() | ||
|
||
mockServer.takeRequest().apply { | ||
assertEquals("GET", method) | ||
assertEquals("true", headers.headerValueOf("apollo-require-preflight")) | ||
} | ||
} | ||
|
||
@Test | ||
fun uploadRequestsSendPreflightHeader() = mockServerTest { | ||
|
||
mockServer.enqueueString("") | ||
val upload = DefaultUpload.Builder() | ||
.content("hello") | ||
.contentLength(5) | ||
.contentType("text/plain") | ||
.fileName("hello") | ||
.build() | ||
|
||
apolloClient.mutation(UploadMutation(Optional.present(upload))).execute() | ||
|
||
mockServer.takeRequest().apply { | ||
assertEquals("POST", method) | ||
assertEquals("true", headers.headerValueOf("apollo-require-preflight")) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters