Skip to content

Commit

Permalink
Merge pull request #1420 from dchohfi/dchohfi/prevent-headers-lost
Browse files Browse the repository at this point in the history
Prevent request headers from getting lost
  • Loading branch information
designatednerd authored Sep 29, 2020
2 parents 334ba29 + 3d28961 commit 0f2eb0f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Sources/Apollo/JSONRequest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ open class JSONRequest<Operation: GraphQLOperation>: HTTPRequest<Operation> {
case .GET:
let transformer = GraphQLGETTransformer(body: body, url: self.graphQLEndpoint)
if let urlForGet = transformer.createGetURL() {
request = URLRequest(url: urlForGet)
request.url = urlForGet
request.httpMethod = GraphQLHTTPMethod.GET.rawValue
} else {
throw GraphQLHTTPRequestError.serializedQueryParamsMessageError
Expand Down
2 changes: 2 additions & 0 deletions Tests/ApolloTests/AutomaticPersistedQueriesTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,7 @@ class AutomaticPersistedQueriesTests: XCTestCase {
let provider = LegacyInterceptorProvider(client: mockClient)
let network = RequestChainNetworkTransport(interceptorProvider: provider,
endpointURL: self.endpoint,
additionalHeaders: ["Authentication": "Bearer 1234"],
useGETForQueries: true)

let expectation = self.expectation(description: "Query sent")
Expand All @@ -403,6 +404,7 @@ class AutomaticPersistedQueriesTests: XCTestCase {

XCTAssertEqual(request.url?.host, network.endpointURL.host)
XCTAssertEqual(request.httpMethod, "GET")
XCTAssertEqual(request.allHTTPHeaderFields!["Authentication"], "Bearer 1234")

try self.validateUrlParams(with: request,
query: query,
Expand Down

0 comments on commit 0f2eb0f

Please sign in to comment.