Skip to content

[In Progress] Apollo iOS 2.0 - Base #645

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

Closed
wants to merge 23 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
979e217
chore(deps): update dependency ts-jest to v29.3.4 (apollographql/apol…
svc-secops May 21, 2025
79346cc
chore(deps): update dependency rollup to v4.41.0 (apollographql/apoll…
svc-secops May 23, 2025
d93570e
WIP: Migrating Apollo and ApolloAPI to strict concurrency
AnthonyMDev Jan 30, 2025
a252b30
Websocket strict concurrency
AnthonyMDev Jan 30, 2025
b40d0f3
WIP: More strict concurrency updates
AnthonyMDev Jan 30, 2025
3d44214
Fix Pagination Coordinator to continue using AnyHashable
AnthonyMDev Jan 30, 2025
c7714fb
Unit tests converted to use new JSONValue
AnthonyMDev Jan 30, 2025
c8de023
Fix casting errors for JSON deserialization
AnthonyMDev Jan 31, 2025
cafa48d
More test fixes
AnthonyMDev Feb 11, 2025
c849e40
Websocket Sendable fixes after rebase on main
AnthonyMDev Feb 21, 2025
29d60b9
WIP: Recursive Nil check
AnthonyMDev Feb 27, 2025
16ae14c
recursivelyUnwrapped()
AnthonyMDev Mar 3, 2025
cb36ad8
Change recursivelyUnwrapped to Optional.asNullable
AnthonyMDev Mar 4, 2025
e61dadf
Fix Integer casting bug
AnthonyMDev Mar 4, 2025
9c24497
Test fix
AnthonyMDev Mar 4, 2025
d36b83c
Get final tests passing with AnyHashable solution
AnthonyMDev Mar 4, 2025
e97c260
Improvement to deferredSelectionSetType function
AnthonyMDev Mar 5, 2025
a424086
Remove AnyHashableCanBeCoerced
AnthonyMDev Mar 5, 2025
ec39dd1
Clean up
AnthonyMDev Mar 5, 2025
9c9554a
Remove SelectionSetMapper
AnthonyMDev Mar 5, 2025
5ba628e
Fix datadict hashable
AnthonyMDev Mar 5, 2025
62505dc
Add SwiftAtomics & update Nimble
AnthonyMDev Mar 17, 2025
e52c49d
Create ReaderWriter
AnthonyMDev Mar 17, 2025
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
29 changes: 19 additions & 10 deletions .package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/mattgallagher/CwlCatchException.git",
"state" : {
"revision" : "3ef6999c73b6938cc0da422f2c912d0158abb0a0",
"version" : "2.2.0"
"revision" : "07b2ba21d361c223e25e3c1e924288742923f08c",
"version" : "2.2.1"
}
},
{
"identity" : "cwlpreconditiontesting",
"kind" : "remoteSourceControl",
"location" : "https://github.com/mattgallagher/CwlPreconditionTesting.git",
"state" : {
"revision" : "2ef56b2caf25f55fa7eef8784c30d5a767550f54",
"version" : "2.2.1"
"revision" : "0139c665ebb45e6a9fbdb68aabfd7c39f3fe0071",
"version" : "2.2.2"
}
},
{
Expand All @@ -32,26 +32,35 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/Quick/Nimble.git",
"state" : {
"revision" : "1c49fc1243018f81a7ea99cb5e0985b00096e9f4",
"version" : "13.3.0"
"revision" : "7795df4fff1a9cd231fe4867ae54f4dc5f5734f9",
"version" : "13.7.1"
}
},
{
"identity" : "swift-argument-parser",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-argument-parser.git",
"state" : {
"revision" : "0fbc8848e389af3bb55c182bc19ca9d5dc2f255b",
"version" : "1.4.0"
"revision" : "41982a3656a71c768319979febd796c6fd111d5c",
"version" : "1.5.0"
}
},
{
"identity" : "swift-atomics",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-atomics",
"state" : {
"revision" : "cd142fd2f64be2100422d658e7411e39489da985",
"version" : "1.2.0"
}
},
{
"identity" : "swift-collections",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-collections",
"state" : {
"revision" : "ee97538f5b81ae89698fd95938896dec5217b148",
"version" : "1.1.1"
"revision" : "671108c96644956dddcd89dd59c203dcdb36cec7",
"version" : "1.1.4"
}
}
],
Expand Down
14 changes: 7 additions & 7 deletions Tests/ApolloInternalTestHelpers/InterceptorTester.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class InterceptorTester {
public func intercept<Operation>(
request: Apollo.HTTPRequest<Operation>,
response: Apollo.HTTPResponse<Operation>? = nil,
completion: @escaping (Result<HTTPResponse<Operation>?, any Error>) -> Void
completion: @escaping @Sendable (Result<HTTPResponse<Operation>?, any Error>) -> Void
) {
let requestChain = ResponseCaptureRequestChain<Operation>({ result in
completion(result)
Expand All @@ -38,13 +38,13 @@ fileprivate class ResponseCaptureRequestChain<T: GraphQLOperation>: RequestChain

func kickoff<Operation>(
request: Apollo.HTTPRequest<Operation>,
completion: @escaping (Result<Apollo.GraphQLResult<Operation.Data>, any Error>) -> Void
completion: @escaping GraphQLResultHandler<Operation.Data>
) {}

func proceedAsync<Operation>(
request: Apollo.HTTPRequest<Operation>,
response: Apollo.HTTPResponse<Operation>?,
completion: @escaping (Result<Apollo.GraphQLResult<Operation.Data>, any Error>) -> Void
completion: @escaping GraphQLResultHandler<Operation.Data>
) {
self.completion(.success(response as? HTTPResponse<T>))
}
Expand All @@ -53,7 +53,7 @@ fileprivate class ResponseCaptureRequestChain<T: GraphQLOperation>: RequestChain
request: HTTPRequest<Operation>,
response: HTTPResponse<Operation>?,
interceptor: any ApolloInterceptor,
completion: @escaping (Result<GraphQLResult<Operation.Data>, any Error>) -> Void
completion: @escaping GraphQLResultHandler<Operation.Data>
) {
self.completion(.success(response as? HTTPResponse<T>))
}
Expand All @@ -62,21 +62,21 @@ fileprivate class ResponseCaptureRequestChain<T: GraphQLOperation>: RequestChain

func retry<Operation>(
request: Apollo.HTTPRequest<Operation>,
completion: @escaping (Result<Apollo.GraphQLResult<Operation.Data>, any Error>) -> Void
completion: @escaping GraphQLResultHandler<Operation.Data>
) {}

func handleErrorAsync<Operation>(
_ error: any Error,
request: Apollo.HTTPRequest<Operation>,
response: Apollo.HTTPResponse<Operation>?,
completion: @escaping (Result<Apollo.GraphQLResult<Operation.Data>, any Error>) -> Void
completion: @escaping GraphQLResultHandler<Operation.Data>
) {
self.completion(.failure(error))
}

func returnValueAsync<Operation>(
for request: Apollo.HTTPRequest<Operation>,
value: Apollo.GraphQLResult<Operation.Data>,
completion: @escaping (Result<Apollo.GraphQLResult<Operation.Data>, any Error>) -> Void
completion: @escaping GraphQLResultHandler<Operation.Data>
) {}
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import ApolloAPI
import Apollo
import Foundation

public extension SelectionSet {

var _rawData: [String: AnyHashable] { self.__data._data }
var _rawData: [String: DataDict.FieldValue] { self.__data._data }

func hasNullValue(forKey key: String) -> Bool {
guard let value = self.__data._data[key] else {
return false
}
return value == DataDict._NullValue
return value is NSNull
}

}
2 changes: 1 addition & 1 deletion Tests/ApolloPaginationTests/ForwardPaginationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ final class ForwardPaginationTests: XCTestCase, CacheDependentTesting {
"after": "Y3Vyc29yMg==",
]

let expectedVariables = Set(nextQuery.__variables?.values.compactMap { $0._jsonEncodableValue?._jsonValue } ?? [])
let expectedVariables = Set(nextQuery.__variables?.underlyingJsonValues ?? [])
let actualVariables = try await XCTUnwrapping(await pager.nextPageVarMap.keys.first)

XCTAssertEqual(expectedVariables.count, actualVariables.count)
Expand Down
4 changes: 2 additions & 2 deletions Tests/ApolloTests/ApolloClientOperationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ final class ApolloClientOperationTests: XCTestCase {
"__typename": "Review",
"stars": 3,
"commentary": ""
]
]
] as JSONValue
] as JSONValue
]

func test__performMutation_givenPublishResultToStore_true_publishResultsToStore() throws {
Expand Down
39 changes: 22 additions & 17 deletions Tests/ApolloTests/AutomaticPersistedQueriesTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,18 @@ class AutomaticPersistedQueriesTests: XCTestCase {
operation: O,
queryDocument: Bool = false,
persistedQuery: Bool = false,
fileID: String = #fileID,
file: Nimble.FileString = #filePath,
line: UInt = #line
line: UInt = #line,
column: UInt = #column
) throws {

let location = SourceLocation(fileID: fileID, filePath: file, line: line, column: column)
guard
let httpBody = request.httpBody,
let jsonBody = try? JSONSerializationFormat.deserialize(data: httpBody) as? JSONObject else {
let jsonBody = try? JSONSerializationFormat.deserialize(data: httpBody) as JSONObject else {
fail(
"httpBody invalid",
location: SourceLocation(file: file, line: line)
location: location
)
return
}
Expand All @@ -102,7 +104,7 @@ class AutomaticPersistedQueriesTests: XCTestCase {
} else {
fail(
"variables should not be nil",
location: SourceLocation(file: file, line: line)
location: location
)
}
}
Expand All @@ -112,31 +114,31 @@ class AutomaticPersistedQueriesTests: XCTestCase {
guard let ext = ext else {
fail(
"extensions json data should not be nil",
location: SourceLocation(file: file, line: line)
location: location
)
return
}

guard let persistedQuery = ext["persistedQuery"] as? JSONObject else {
fail(
"persistedQuery is missing",
location: SourceLocation(file: file, line: line)
location: location
)
return
}

guard let version = persistedQuery["version"] as? Int else {
fail(
"version is missing",
location: SourceLocation(file: file, line: line)
location: location
)
return
}

guard let sha256Hash = persistedQuery["sha256Hash"] as? String else {
fail(
"sha256Hash is missing",
location: SourceLocation(file: file, line: line)
location: location
)
return
}
Expand All @@ -153,13 +155,16 @@ class AutomaticPersistedQueriesTests: XCTestCase {
query: MockHeroNameQuery,
queryDocument: Bool = false,
persistedQuery: Bool = false,
fileID: String = #fileID,
file: Nimble.FileString = #filePath,
line: UInt = #line
line: UInt = #line,
column: UInt = #column
) throws {
let location = SourceLocation(fileID: fileID, filePath: file, line: line, column: column)
guard let url = request.url else {
fail(
"URL not valid",
location: SourceLocation(file: file, line: line)
location: location
)
return
}
Expand Down Expand Up @@ -190,7 +195,7 @@ class AutomaticPersistedQueriesTests: XCTestCase {
} else {
fail(
"variables should not be nil",
location: SourceLocation(file: file, line: line)
location: location
)
}

Expand All @@ -199,35 +204,35 @@ class AutomaticPersistedQueriesTests: XCTestCase {
guard
let ext = ext,
let data = ext.data(using: .utf8),
let jsonBody = try? JSONSerializationFormat.deserialize(data: data) as? JSONObject
let jsonBody = try? JSONSerializationFormat.deserialize(data: data) as JSONObject
else {
fail(
"extensions json data should not be nil",
location: SourceLocation(file: file, line: line)
location: location
)
return
}

guard let persistedQuery = jsonBody["persistedQuery"] as? JSONObject else {
fail(
"persistedQuery is missing",
location: SourceLocation(file: file, line: line)
location: location
)
return
}

guard let sha256Hash = persistedQuery["sha256Hash"] as? String else {
fail(
"sha256Hash is missing",
location: SourceLocation(file: file, line: line)
location: location
)
return
}

guard let version = persistedQuery["version"] as? Int else {
fail(
"version is missing",
location: SourceLocation(file: file, line: line)
location: location
)
return
}
Expand Down
4 changes: 2 additions & 2 deletions Tests/ApolloTests/Cache/FetchQueryTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ class FetchQueryTests: XCTestCase, CacheDependentTesting {
"appearsIn": ["NEWHOPE", "EMPIRE", "JEDI"],
"__typename": "Droid"
]
]
] as JSONValue
]
}

Expand Down Expand Up @@ -411,7 +411,7 @@ class FetchQueryTests: XCTestCase, CacheDependentTesting {
let query = MockQuery.mock()

let serverRequestExpectation = server.expect(MockQuery<MockSelectionSet>.self) { request in
["data": [:]]
["data": [:] as JSONValue]
}

let resultObserver = makeResultObserver(for: query)
Expand Down
2 changes: 1 addition & 1 deletion Tests/ApolloTests/Cache/LoadQueryFromStoreTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ class LoadQueryFromStoreTests: XCTestCase, CacheDependentTesting, StoreLoading {
CacheReference("1003")
]
],
"1000": ["__typename": "Human", "name": ["dictionary": "badValues", "nested bad val": ["subdictionary": "some value"] ]
"1000": ["__typename": "Human", "name": ["dictionary": "badValues", "nested bad val": ["subdictionary": "some value"] ] as JSONValue
],
"1002": ["__typename": "Human", "name": "Han Solo"],
"1003": ["__typename": "Human", "name": "Leia Organa"],
Expand Down
10 changes: 5 additions & 5 deletions Tests/ApolloTests/Cache/ReadWriteFromStoreTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1816,11 +1816,11 @@ class ReadWriteFromStoreTests: XCTestCase, CacheDependentTesting, StoreLoading {
override class var __selections: [Selection] {[
.field("name", String.self),
.include(if: !"c", .field("friend", Friend.self)),
.include(if: !"d", .field("other", String.self))
.include(if: !"d", .field("other", String?.self))
]}
var name: String { __data["name"] }
var friend: Friend? { __data["friend"] }
var other: String? { __data["name"] }
var other: String? { __data["other"] }

convenience init(
name: String,
Expand Down Expand Up @@ -2686,13 +2686,13 @@ class ReadWriteFromStoreTests: XCTestCase, CacheDependentTesting, StoreLoading {
]
],
"1101": [
"__typename": "Human", "name": "Luke Skywalker", "id": "1101", "friends": []
"__typename": "Human", "name": "Luke Skywalker", "id": "1101", "friends": [] as JSONValue
],
"1002": [
"__typename": "Human", "name": "Han Solo", "id": "1002", "friends": []
"__typename": "Human", "name": "Han Solo", "id": "1002", "friends": [] as JSONValue
],
"1003": [
"__typename": "Human", "name": "Leia Organa", "id": "1003", "friends": []
"__typename": "Human", "name": "Leia Organa", "id": "1003", "friends": [] as JSONValue
],
])

Expand Down
4 changes: 2 additions & 2 deletions Tests/ApolloTests/Cache/StoreConcurrencyTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ class StoreConcurrencyTests: XCTestCase, CacheDependentTesting {
"name": "R2-D2",
"id": "2001",
"__typename": "Droid",
"friends": []
"friends": [] as JSONValue
]
])

Expand Down Expand Up @@ -331,7 +331,7 @@ class StoreConcurrencyTests: XCTestCase, CacheDependentTesting {
"name": "R2-D2",
"id": "2001",
"__typename": "Droid",
"friends": []
"friends": [] as JSONValue
]
])

Expand Down
Loading
Loading