Skip to content

Commit

Permalink
Prep apollo-ios subtree for release (#56)
Browse files Browse the repository at this point in the history
  • Loading branch information
BobaFetters authored and runner committed Oct 4, 2023
1 parent 75814cf commit f304227
Show file tree
Hide file tree
Showing 14 changed files with 122 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# https://help.github.com/articles/about-code-owners/
/docs/ @stephenbarlow
/docs/ @apollographql/docs
31 changes: 28 additions & 3 deletions .gitleaks.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
# This file exists primarily to influence scheduled scans that Apollo runs of all repos in Apollo-managed orgs.
# This is an Apollo-Internal link, but more information about these scans is available here:
# https://apollographql.atlassian.net/wiki/spaces/SecOps/pages/81330213/Everything+Static+Application+Security+Testing#Scheduled-Scans.1
#
# Apollo is using Gitleaks (https://github.com/gitleaks/gitleaks) to run these scans.
# However, this file is not something that Gitleaks natively consumes. This file is an
# Apollo-convention. Prior to scanning a repo, Apollo merges
# our standard Gitleaks configuration (which is largely just the Gitleaks-default config) with
# this file if it exists in a repo. The combined config is then used to scan a repo.
#
# We did this because the natively-supported allowlisting functionality in Gitleaks didn't do everything we wanted
# or wasn't as robust as we needed. For example, one of the allowlisting options offered by Gitleaks depends on the line number
# on which a false positive secret exists to allowlist it. (https://github.com/gitleaks/gitleaks#gitleaksignore).
# This creates a fairly fragile allowlisting mechanism. This file allows us to leverage the full capabilities of the Gitleaks rule syntax
# to create allowlisting functionality.

[[ rules ]]
id = "high-entropy-base64"
Expand All @@ -10,7 +25,17 @@
[[ rules ]]
id = "generic-api-key"
[ rules.allowlist ]
commits = [
"474554504e7e33cef2a71774f825d5b3947ff797",


paths = [
# Allowlists a false positive detection at
# https://github.com/apollographql/apollo-ios/blob/474554504e7e33cef2a71774f825d5b3947ff797/Tests/ApolloCodegenTests/TestHelpers/ASTMatchers.swift#L72
# This was previously allowlisted via commit hash, but updating that rule
# To support allowlisting false positive detections in the files below as well.
'''Tests/ApolloCodegenTests/TestHelpers/ASTMatchers.swift''',

# Allowlist the various high-entropy strings in xcscmblueprint files
'''Apollo.xcodeproj/project.xcworkspace/xcshareddata/Apollo.xcscmblueprint$''',
'''ApolloSQLite.xcodeproj/project.xcworkspace/xcshareddata/ApolloSQLite.xcscmblueprint$''',
'''Apollo.xcworkspace/xcshareddata/Apollo.xcscmblueprint$''',
]

19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
# Change Log

## v1.5.2

The purpose of this release is to provide a deprecation message to users of `ApolloCodegenLib` who are scripting their code generation in advance of an upcoming change to our libraries and repo structure. Beginning with the upcoming 1.6.0 release the code generation libraries will be their own SPM package in their own repo which will require you to add a new dependency to you project in order for your code generation scripting to compile. More information can be found in our [announcement](https://github.com/apollographql/apollo-ios/issues/3240) of this change.

**If you would like to avoid this deprecation warning in your builds feel free to stay on 1.5.1 or earlier, this warning will be gone in the 1.6.0 release**

PR containing deprecation warning for reference: [#3243](https://github.com/apollographql/apollo-ios/pull/3243).

## v1.5.1

### Improvement

- **Added `OutputOptions` property to codegen for marking generated classes as `final` ([#3189](https://github.com/apollographql/apollo-ios/pull/3189)):** _Thank you to [@Mordil](https://github.com/Mordil) for the contribution._

### Fixed

- **Codegen `itemsToGenerate` option for `.all` not generating an operation manifest ([#3215](https://github.com/apollographql/apollo-ios/pull/3215)):** _Thank you to [@TizianoCoroneo](https://github.com/TizianoCoroneo) for finding and fixing the issue._
- **Codegen operation manifest inadvertantly being generated twice ([#3225](https://github.com/apollographql/apollo-ios/pull/3225)):** _Thank you to [@jimisaacs](https://github.com/jimisaacs) for finding and fixing the issue._

## v1.5.0

### New
Expand Down
10 changes: 10 additions & 0 deletions Sources/Apollo/ApolloClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -80,22 +80,26 @@ extension ApolloClient: ApolloClientProtocol {
@discardableResult public func fetch<Query: GraphQLQuery>(query: Query,
cachePolicy: CachePolicy = .default,
contextIdentifier: UUID? = nil,
context: RequestContext? = nil,
queue: DispatchQueue = .main,
resultHandler: GraphQLResultHandler<Query.Data>? = nil) -> Cancellable {
return self.networkTransport.send(operation: query,
cachePolicy: cachePolicy,
contextIdentifier: contextIdentifier,
context: context,
callbackQueue: queue) { result in
resultHandler?(result)
}
}

public func watch<Query: GraphQLQuery>(query: Query,
cachePolicy: CachePolicy = .default,
context: RequestContext? = nil,
callbackQueue: DispatchQueue = .main,
resultHandler: @escaping GraphQLResultHandler<Query.Data>) -> GraphQLQueryWatcher<Query> {
let watcher = GraphQLQueryWatcher(client: self,
query: query,
context: context,
callbackQueue: callbackQueue,
resultHandler: resultHandler)
watcher.fetch(cachePolicy: cachePolicy)
Expand All @@ -105,12 +109,14 @@ extension ApolloClient: ApolloClientProtocol {
@discardableResult
public func perform<Mutation: GraphQLMutation>(mutation: Mutation,
publishResultToStore: Bool = true,
context: RequestContext? = nil,
queue: DispatchQueue = .main,
resultHandler: GraphQLResultHandler<Mutation.Data>? = nil) -> Cancellable {
return self.networkTransport.send(
operation: mutation,
cachePolicy: publishResultToStore ? .default : .fetchIgnoringCacheCompletely,
contextIdentifier: nil,
context: context,
callbackQueue: queue,
completionHandler: { result in
resultHandler?(result)
Expand All @@ -121,6 +127,7 @@ extension ApolloClient: ApolloClientProtocol {
@discardableResult
public func upload<Operation: GraphQLOperation>(operation: Operation,
files: [GraphQLFile],
context: RequestContext? = nil,
queue: DispatchQueue = .main,
resultHandler: GraphQLResultHandler<Operation.Data>? = nil) -> Cancellable {
guard let uploadingTransport = self.networkTransport as? UploadingNetworkTransport else {
Expand All @@ -133,17 +140,20 @@ extension ApolloClient: ApolloClientProtocol {

return uploadingTransport.upload(operation: operation,
files: files,
context: context,
callbackQueue: queue) { result in
resultHandler?(result)
}
}

public func subscribe<Subscription: GraphQLSubscription>(subscription: Subscription,
context: RequestContext? = nil,
queue: DispatchQueue = .main,
resultHandler: @escaping GraphQLResultHandler<Subscription.Data>) -> Cancellable {
return self.networkTransport.send(operation: subscription,
cachePolicy: .default,
contextIdentifier: nil,
context: context,
callbackQueue: queue,
completionHandler: resultHandler)
}
Expand Down
10 changes: 10 additions & 0 deletions Sources/Apollo/ApolloClientProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@ public protocol ApolloClientProtocol: AnyObject {
/// - cachePolicy: A cache policy that specifies when results should be fetched from the server and when data should be loaded from the local cache.
/// - queue: A dispatch queue on which the result handler will be called. Should default to the main queue.
/// - contextIdentifier: [optional] A unique identifier for this request, to help with deduping cache hits for watchers. Should default to `nil`.
/// - context: [optional] A context that is being passed through the request chain. Should default to `nil`.
/// - resultHandler: [optional] A closure that is called when query results are available or when an error occurs.
/// - Returns: An object that can be used to cancel an in progress fetch.
func fetch<Query: GraphQLQuery>(query: Query,
cachePolicy: CachePolicy,
contextIdentifier: UUID?,
context: RequestContext?,
queue: DispatchQueue,
resultHandler: GraphQLResultHandler<Query.Data>?) -> Cancellable

Expand All @@ -37,11 +39,13 @@ public protocol ApolloClientProtocol: AnyObject {
/// - Parameters:
/// - query: The query to fetch.
/// - cachePolicy: A cache policy that specifies when results should be fetched from the server or from the local cache.
/// - context: [optional] A context that is being passed through the request chain. Should default to `nil`.
/// - callbackQueue: A dispatch queue on which the result handler will be called. Should default to the main queue.
/// - resultHandler: [optional] A closure that is called when query results are available or when an error occurs.
/// - Returns: A query watcher object that can be used to control the watching behavior.
func watch<Query: GraphQLQuery>(query: Query,
cachePolicy: CachePolicy,
context: RequestContext?,
callbackQueue: DispatchQueue,
resultHandler: @escaping GraphQLResultHandler<Query.Data>) -> GraphQLQueryWatcher<Query>

Expand All @@ -50,11 +54,13 @@ public protocol ApolloClientProtocol: AnyObject {
/// - Parameters:
/// - mutation: The mutation to perform.
/// - publishResultToStore: If `true`, this will publish the result returned from the operation to the cache store. Default is `true`.
/// - context: [optional] A context that is being passed through the request chain. Should default to `nil`.
/// - queue: A dispatch queue on which the result handler will be called. Should default to the main queue.
/// - resultHandler: An optional closure that is called when mutation results are available or when an error occurs.
/// - Returns: An object that can be used to cancel an in progress mutation.
func perform<Mutation: GraphQLMutation>(mutation: Mutation,
publishResultToStore: Bool,
context: RequestContext?,
queue: DispatchQueue,
resultHandler: GraphQLResultHandler<Mutation.Data>?) -> Cancellable

Expand All @@ -63,23 +69,27 @@ public protocol ApolloClientProtocol: AnyObject {
/// - Parameters:
/// - operation: The operation to send
/// - files: An array of `GraphQLFile` objects to send.
/// - context: [optional] A context that is being passed through the request chain. Should default to `nil`.
/// - queue: A dispatch queue on which the result handler will be called. Should default to the main queue.
/// - completionHandler: The completion handler to execute when the request completes or errors. Note that an error will be returned If your `networkTransport` does not also conform to `UploadingNetworkTransport`.
/// - Returns: An object that can be used to cancel an in progress request.
func upload<Operation: GraphQLOperation>(operation: Operation,
files: [GraphQLFile],
context: RequestContext?,
queue: DispatchQueue,
resultHandler: GraphQLResultHandler<Operation.Data>?) -> Cancellable

/// Subscribe to a subscription
///
/// - Parameters:
/// - subscription: The subscription to subscribe to.
/// - context: [optional] A context that is being passed through the request chain. Should default to `nil`.
/// - fetchHTTPMethod: The HTTP Method to be used.
/// - queue: A dispatch queue on which the result handler will be called. Should default to the main queue.
/// - resultHandler: An optional closure that is called when mutation results are available or when an error occurs.
/// - Returns: An object that can be used to cancel an in progress subscription.
func subscribe<Subscription: GraphQLSubscription>(subscription: Subscription,
context: RequestContext?,
queue: DispatchQueue,
resultHandler: @escaping GraphQLResultHandler<Subscription.Data>) -> Cancellable
}
6 changes: 5 additions & 1 deletion Sources/Apollo/GraphQLQueryWatcher.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public final class GraphQLQueryWatcher<Query: GraphQLQuery>: Cancellable, Apollo
private let callbackQueue: DispatchQueue

private let contextIdentifier = UUID()
private let context: RequestContext?

private class WeakFetchTaskContainer {
weak var cancellable: Cancellable?
Expand All @@ -34,16 +35,19 @@ public final class GraphQLQueryWatcher<Query: GraphQLQuery>: Cancellable, Apollo
/// - Parameters:
/// - client: The client protocol to pass in.
/// - query: The query to watch.
/// - context: [optional] A context that is being passed through the request chain. Defaults to `nil`.
/// - callbackQueue: The queue for the result handler. Defaults to the main queue.
/// - resultHandler: The result handler to call with changes.
public init(client: ApolloClientProtocol,
query: Query,
context: RequestContext? = nil,
callbackQueue: DispatchQueue = .main,
resultHandler: @escaping GraphQLResultHandler<Query.Data>) {
self.client = client
self.query = query
self.resultHandler = resultHandler
self.callbackQueue = callbackQueue
self.context = context

client.store.subscribe(self)
}
Expand All @@ -58,7 +62,7 @@ public final class GraphQLQueryWatcher<Query: GraphQLQuery>: Cancellable, Apollo
// Cancel anything already in flight before starting a new fetch
$0.cancellable?.cancel()
$0.cachePolicy = cachePolicy
$0.cancellable = client?.fetch(query: query, cachePolicy: cachePolicy, contextIdentifier: self.contextIdentifier, queue: callbackQueue) { [weak self] result in
$0.cancellable = client?.fetch(query: query, cachePolicy: cachePolicy, contextIdentifier: self.contextIdentifier, context: self.context, queue: callbackQueue) { [weak self] result in
guard let self = self else { return }

switch result {
Expand Down
8 changes: 7 additions & 1 deletion Sources/Apollo/HTTPRequest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ open class HTTPRequest<Operation: GraphQLOperation>: Hashable {

/// [optional] A unique identifier for this request, to help with deduping cache hits for watchers.
public let contextIdentifier: UUID?

/// [optional] A context that is being passed through the request chain.
public let context: RequestContext?

/// Designated Initializer
///
Expand All @@ -32,19 +35,22 @@ open class HTTPRequest<Operation: GraphQLOperation>: Hashable {
/// - clientVersion: The version of the client to send with the `"apollographql-client-version"` header
/// - additionalHeaders: Any additional headers you wish to add by default to this request.
/// - cachePolicy: The `CachePolicy` to use for this request. Defaults to the `.default` policy
/// - context: [optional] A context that is being passed through the request chain. Defaults to `nil`.
public init(graphQLEndpoint: URL,
operation: Operation,
contextIdentifier: UUID? = nil,
contentType: String,
clientName: String,
clientVersion: String,
additionalHeaders: [String: String],
cachePolicy: CachePolicy = .default) {
cachePolicy: CachePolicy = .default,
context: RequestContext? = nil) {
self.graphQLEndpoint = graphQLEndpoint
self.operation = operation
self.contextIdentifier = contextIdentifier
self.additionalHeaders = additionalHeaders
self.cachePolicy = cachePolicy
self.context = context

self.addHeader(name: "Content-Type", value: contentType)
// Note: in addition to this being a generally useful header to send, Apollo
Expand Down
5 changes: 4 additions & 1 deletion Sources/Apollo/JSONRequest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ open class JSONRequest<Operation: GraphQLOperation>: HTTPRequest<Operation> {
/// - clientVersion: The version of the client to send with the `"apollographql-client-version"` header
/// - additionalHeaders: Any additional headers you wish to add by default to this request
/// - cachePolicy: The `CachePolicy` to use for this request.
/// - context: [optional] A context that is being passed through the request chain. Defaults to `nil`.
/// - autoPersistQueries: `true` if Auto-Persisted Queries should be used. Defaults to `false`.
/// - useGETForQueries: `true` if Queries should use `GET` instead of `POST` for HTTP requests. Defaults to `false`.
/// - useGETForPersistedQueryRetry: `true` if when an Auto-Persisted query is retried, it should use `GET` instead of `POST` to send the query. Defaults to `false`.
Expand All @@ -49,6 +50,7 @@ open class JSONRequest<Operation: GraphQLOperation>: HTTPRequest<Operation> {
clientVersion: String,
additionalHeaders: [String: String] = [:],
cachePolicy: CachePolicy = .default,
context: RequestContext? = nil,
autoPersistQueries: Bool = false,
useGETForQueries: Bool = false,
useGETForPersistedQueryRetry: Bool = false,
Expand All @@ -67,7 +69,8 @@ open class JSONRequest<Operation: GraphQLOperation>: HTTPRequest<Operation> {
clientName: clientName,
clientVersion: clientVersion,
additionalHeaders: additionalHeaders,
cachePolicy: cachePolicy
cachePolicy: cachePolicy,
context: context
)
}

Expand Down
Loading

0 comments on commit f304227

Please sign in to comment.