From 8ff678a398a2e872a61599959200ecabf151daf0 Mon Sep 17 00:00:00 2001 From: Hesham Salman Date: Fri, 8 Mar 2024 19:56:24 -0500 Subject: [PATCH 1/5] Add completion callbacks to fetch and refetch in GraphQLQueryPager for API consistency --- .../ApolloPagination/GraphQLQueryPager.swift | 15 ++++++-- .../GraphQLQueryPagerCoordinator.swift | 37 +++++++++++++++---- 2 files changed, 40 insertions(+), 12 deletions(-) diff --git a/apollo-ios-pagination/Sources/ApolloPagination/GraphQLQueryPager.swift b/apollo-ios-pagination/Sources/ApolloPagination/GraphQLQueryPager.swift index 429b2b645..19006c7fe 100644 --- a/apollo-ios-pagination/Sources/ApolloPagination/GraphQLQueryPager.swift +++ b/apollo-ios-pagination/Sources/ApolloPagination/GraphQLQueryPager.swift @@ -229,13 +229,20 @@ public class GraphQLQueryPager: Publisher { /// Discards pagination state and fetches the first page from scratch. /// - Parameter cachePolicy: The apollo cache policy to trigger the first fetch with. Defaults to `fetchIgnoringCacheData`. - public func refetch(cachePolicy: CachePolicy = .fetchIgnoringCacheData) { - pager.refetch(cachePolicy: cachePolicy) + public func refetch( + cachePolicy: CachePolicy = .fetchIgnoringCacheData, + callbackQueue: DispatchQueue = .main, + completion: (() -> Void)? = nil + ) { + pager.refetch(cachePolicy: cachePolicy, callbackQueue: callbackQueue, completion: completion) } /// Fetches the first page. - public func fetch() { - pager.fetch() + public func fetch( + callbackQueue: DispatchQueue = .main, + completion: (() -> Void)? = nil + ) { + pager.fetch(callbackQueue: callbackQueue, completion: completion) } /// Resets pagination state and cancels in-flight updates from the pager. diff --git a/apollo-ios-pagination/Sources/ApolloPagination/GraphQLQueryPagerCoordinator.swift b/apollo-ios-pagination/Sources/ApolloPagination/GraphQLQueryPagerCoordinator.swift index fa314b948..50c348772 100644 --- a/apollo-ios-pagination/Sources/ApolloPagination/GraphQLQueryPagerCoordinator.swift +++ b/apollo-ios-pagination/Sources/ApolloPagination/GraphQLQueryPagerCoordinator.swift @@ -25,8 +25,15 @@ public protocol PagerType { callbackQueue: DispatchQueue, completion: ((PaginationError?) -> Void)? ) - func refetch(cachePolicy: CachePolicy) - func fetch() + func refetch( + cachePolicy: CachePolicy, + callbackQueue: DispatchQueue, + completion: (() -> Void)? + ) + func fetch( + callbackQueue: DispatchQueue, + completion: (() -> Void)? + ) } /// Handles pagination in the queue by managing multiple query watchers. @@ -151,9 +158,17 @@ class GraphQLQueryPagerCoordinator Void)? = nil + ) { + execute(callbackQueue: callbackQueue, completion: { _ in completion?() }) { [weak self] in + guard let self else { return } for completion in await self.completionManager.completions { completion.execute(error: PaginationError.cancellation) } @@ -162,9 +177,15 @@ class GraphQLQueryPagerCoordinator Void)? = nil + ) { + execute(callbackQueue: callbackQueue, completion: { _ in completion?() }) { [weak self] in + await self?.pager.fetch() } } From 3e771367478a795baf7907a84acdf62d32ae192c Mon Sep 17 00:00:00 2001 From: Hesham Salman Date: Fri, 8 Mar 2024 20:02:41 -0500 Subject: [PATCH 2/5] Add docs --- .../Sources/ApolloPagination/GraphQLQueryPager.swift | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/apollo-ios-pagination/Sources/ApolloPagination/GraphQLQueryPager.swift b/apollo-ios-pagination/Sources/ApolloPagination/GraphQLQueryPager.swift index 19006c7fe..3f3a131bd 100644 --- a/apollo-ios-pagination/Sources/ApolloPagination/GraphQLQueryPager.swift +++ b/apollo-ios-pagination/Sources/ApolloPagination/GraphQLQueryPager.swift @@ -228,7 +228,10 @@ public class GraphQLQueryPager: Publisher { } /// Discards pagination state and fetches the first page from scratch. - /// - Parameter cachePolicy: The apollo cache policy to trigger the first fetch with. Defaults to `fetchIgnoringCacheData`. + /// - Parameters: + /// - cachePolicy: The apollo cache policy to trigger the first fetch with. Defaults to `fetchIgnoringCacheData`. + /// - callbackQueue: The `DispatchQueue` that the `completion` fires on. Defaults to `main`. + /// - completion: A completion block that will always trigger after the execution of this operation. public func refetch( cachePolicy: CachePolicy = .fetchIgnoringCacheData, callbackQueue: DispatchQueue = .main, @@ -238,6 +241,9 @@ public class GraphQLQueryPager: Publisher { } /// Fetches the first page. + /// - Parameters: + /// - callbackQueue: The `DispatchQueue` that the `completion` fires on. Defaults to `main`. + /// - completion: A completion block that will always trigger after the execution of this operation. public func fetch( callbackQueue: DispatchQueue = .main, completion: (() -> Void)? = nil From c44024d8a38aac11b3e304f53f129e9ea6ad94b0 Mon Sep 17 00:00:00 2001 From: Hesham Salman Date: Mon, 25 Mar 2024 13:39:07 -0400 Subject: [PATCH 3/5] Regenerate ApolloPagination DocC --- .../apollopagination/graphqlquerypager.json | 92 +++- .../graphqlquerypager/fetch().json | 184 -------- ... => fetch(callbackqueue:completion:).json} | 137 ++++-- ...achepolicy:callbackqueue:completion:).json | 416 ++++++++++++++++++ .../apollopagination/pagertype.json | 92 +++- .../apollopagination/pagertype/fetch().json | 174 -------- ... => fetch(callbackqueue:completion:).json} | 97 +++- ...achepolicy:callbackqueue:completion:).json | 327 ++++++++++++++ 8 files changed, 1086 insertions(+), 433 deletions(-) delete mode 100644 docs/docc/Apollo.doccarchive/data/documentation/apollopagination/graphqlquerypager/fetch().json rename docs/docc/Apollo.doccarchive/data/documentation/apollopagination/graphqlquerypager/{refetch(cachepolicy:).json => fetch(callbackqueue:completion:).json} (59%) create mode 100644 docs/docc/Apollo.doccarchive/data/documentation/apollopagination/graphqlquerypager/refetch(cachepolicy:callbackqueue:completion:).json delete mode 100644 docs/docc/Apollo.doccarchive/data/documentation/apollopagination/pagertype/fetch().json rename docs/docc/Apollo.doccarchive/data/documentation/apollopagination/pagertype/{refetch(cachepolicy:).json => fetch(callbackqueue:completion:).json} (63%) create mode 100644 docs/docc/Apollo.doccarchive/data/documentation/apollopagination/pagertype/refetch(cachepolicy:callbackqueue:completion:).json diff --git a/docs/docc/Apollo.doccarchive/data/documentation/apollopagination/graphqlquerypager.json b/docs/docc/Apollo.doccarchive/data/documentation/apollopagination/graphqlquerypager.json index f81084dde..f6f9a9df2 100644 --- a/docs/docc/Apollo.doccarchive/data/documentation/apollopagination/graphqlquerypager.json +++ b/docs/docc/Apollo.doccarchive/data/documentation/apollopagination/graphqlquerypager.json @@ -135,12 +135,12 @@ }, { "identifiers" : [ - "doc:\/\/ApolloPagination\/documentation\/ApolloPagination\/GraphQLQueryPager\/fetch()", + "doc:\/\/ApolloPagination\/documentation\/ApolloPagination\/GraphQLQueryPager\/fetch(callbackQueue:completion:)", "doc:\/\/ApolloPagination\/documentation\/ApolloPagination\/GraphQLQueryPager\/loadAll(fetchFromInitialPage:callbackQueue:completion:)", "doc:\/\/ApolloPagination\/documentation\/ApolloPagination\/GraphQLQueryPager\/loadNext(cachePolicy:callbackQueue:completion:)", "doc:\/\/ApolloPagination\/documentation\/ApolloPagination\/GraphQLQueryPager\/loadPrevious(cachePolicy:callbackQueue:completion:)", "doc:\/\/ApolloPagination\/documentation\/ApolloPagination\/GraphQLQueryPager\/receive(subscriber:)", - "doc:\/\/ApolloPagination\/documentation\/ApolloPagination\/GraphQLQueryPager\/refetch(cachePolicy:)", + "doc:\/\/ApolloPagination\/documentation\/ApolloPagination\/GraphQLQueryPager\/refetch(cachePolicy:callbackQueue:completion:)", "doc:\/\/ApolloPagination\/documentation\/ApolloPagination\/GraphQLQueryPager\/reset()", "doc:\/\/ApolloPagination\/documentation\/ApolloPagination\/GraphQLQueryPager\/subscribe(completion:)" ], @@ -430,7 +430,7 @@ "type" : "topic", "url" : "\/documentation\/apollopagination\/graphqlquerypager\/cancellables" }, -"doc://ApolloPagination/documentation/ApolloPagination/GraphQLQueryPager/fetch()": { +"doc://ApolloPagination/documentation/ApolloPagination/GraphQLQueryPager/fetch(callbackQueue:completion:)": { "abstract" : [ { "text" : "Fetches the first page.", @@ -452,15 +452,49 @@ }, { "kind" : "text", - "text" : "()" + "text" : "(" + }, + { + "kind" : "externalParam", + "text" : "callbackQueue" + }, + { + "kind" : "text", + "text" : ": " + }, + { + "kind" : "typeIdentifier", + "preciseIdentifier" : "c:objc(cs)OS_dispatch_queue", + "text" : "DispatchQueue" + }, + { + "kind" : "text", + "text" : ", " + }, + { + "kind" : "externalParam", + "text" : "completion" + }, + { + "kind" : "text", + "text" : ": (() -> " + }, + { + "kind" : "typeIdentifier", + "preciseIdentifier" : "s:s4Voida", + "text" : "Void" + }, + { + "kind" : "text", + "text" : ")?)" } ], - "identifier" : "doc:\/\/ApolloPagination\/documentation\/ApolloPagination\/GraphQLQueryPager\/fetch()", + "identifier" : "doc:\/\/ApolloPagination\/documentation\/ApolloPagination\/GraphQLQueryPager\/fetch(callbackQueue:completion:)", "kind" : "symbol", "role" : "symbol", - "title" : "fetch()", + "title" : "fetch(callbackQueue:completion:)", "type" : "topic", - "url" : "\/documentation\/apollopagination\/graphqlquerypager\/fetch()" + "url" : "\/documentation\/apollopagination\/graphqlquerypager\/fetch(callbackqueue:completion:)" }, "doc://ApolloPagination/documentation/ApolloPagination/GraphQLQueryPager/init(client:initialQuery:watcherDispatchQueue:extractInitialPageInfo:extractNextPageInfo:pageResolver:)": { "abstract" : [ @@ -2981,7 +3015,7 @@ "type" : "topic", "url" : "\/documentation\/apollopagination\/graphqlquerypager\/receive(subscriber:)" }, -"doc://ApolloPagination/documentation/ApolloPagination/GraphQLQueryPager/refetch(cachePolicy:)": { +"doc://ApolloPagination/documentation/ApolloPagination/GraphQLQueryPager/refetch(cachePolicy:callbackQueue:completion:)": { "abstract" : [ { "text" : "Discards pagination state and fetches the first page from scratch.", @@ -3020,15 +3054,49 @@ }, { "kind" : "text", - "text" : ")" + "text" : ", " + }, + { + "kind" : "externalParam", + "text" : "callbackQueue" + }, + { + "kind" : "text", + "text" : ": " + }, + { + "kind" : "typeIdentifier", + "preciseIdentifier" : "c:objc(cs)OS_dispatch_queue", + "text" : "DispatchQueue" + }, + { + "kind" : "text", + "text" : ", " + }, + { + "kind" : "externalParam", + "text" : "completion" + }, + { + "kind" : "text", + "text" : ": (() -> " + }, + { + "kind" : "typeIdentifier", + "preciseIdentifier" : "s:s4Voida", + "text" : "Void" + }, + { + "kind" : "text", + "text" : ")?)" } ], - "identifier" : "doc:\/\/ApolloPagination\/documentation\/ApolloPagination\/GraphQLQueryPager\/refetch(cachePolicy:)", + "identifier" : "doc:\/\/ApolloPagination\/documentation\/ApolloPagination\/GraphQLQueryPager\/refetch(cachePolicy:callbackQueue:completion:)", "kind" : "symbol", "role" : "symbol", - "title" : "refetch(cachePolicy:)", + "title" : "refetch(cachePolicy:callbackQueue:completion:)", "type" : "topic", - "url" : "\/documentation\/apollopagination\/graphqlquerypager\/refetch(cachepolicy:)" + "url" : "\/documentation\/apollopagination\/graphqlquerypager\/refetch(cachepolicy:callbackqueue:completion:)" }, "doc://ApolloPagination/documentation/ApolloPagination/GraphQLQueryPager/reset()": { "abstract" : [ diff --git a/docs/docc/Apollo.doccarchive/data/documentation/apollopagination/graphqlquerypager/fetch().json b/docs/docc/Apollo.doccarchive/data/documentation/apollopagination/graphqlquerypager/fetch().json deleted file mode 100644 index f17df8512..000000000 --- a/docs/docc/Apollo.doccarchive/data/documentation/apollopagination/graphqlquerypager/fetch().json +++ /dev/null @@ -1,184 +0,0 @@ -{ - "abstract" : [ - { - "text" : "Fetches the first page.", - "type" : "text" - } - ], - "hierarchy" : { - "paths" : [ - [ - "doc:\/\/ApolloPagination\/documentation\/ApolloPagination", - "doc:\/\/ApolloPagination\/documentation\/ApolloPagination\/GraphQLQueryPager" - ] - ] - }, - "identifier" : { - "interfaceLanguage" : "swift", - "url" : "doc:\/\/ApolloPagination\/documentation\/ApolloPagination\/GraphQLQueryPager\/fetch()" - }, - "kind" : "symbol", - "metadata" : { - "externalID" : "s:16ApolloPagination17GraphQLQueryPagerC5fetchyyF", - "fragments" : [ - { - "kind" : "keyword", - "text" : "func" - }, - { - "kind" : "text", - "text" : " " - }, - { - "kind" : "identifier", - "text" : "fetch" - }, - { - "kind" : "text", - "text" : "()" - } - ], - "modules" : [ - { - "name" : "ApolloPagination" - } - ], - "role" : "symbol", - "roleHeading" : "Instance Method", - "symbolKind" : "method", - "title" : "fetch()" - }, - "primaryContentSections" : [ - { - "declarations" : [ - { - "languages" : [ - "swift" - ], - "platforms" : [ - "macOS" - ], - "tokens" : [ - { - "kind" : "keyword", - "text" : "func" - }, - { - "kind" : "text", - "text" : " " - }, - { - "kind" : "identifier", - "text" : "fetch" - }, - { - "kind" : "text", - "text" : "()" - } - ] - } - ], - "kind" : "declarations" - } - ], - "schemaVersion" : { - "major" : 0, - "minor" : 3, - "patch" : 0 - }, - "sections" : [ - - ], - "variants" : [ - { - "paths" : [ - "\/documentation\/apollopagination\/graphqlquerypager\/fetch()" - ], - "traits" : [ - { - "interfaceLanguage" : "swift" - } - ] - } - ] -, -"references": { -"doc://ApolloPagination/documentation/ApolloPagination": { - "abstract" : [ - - ], - "identifier" : "doc:\/\/ApolloPagination\/documentation\/ApolloPagination", - "kind" : "symbol", - "role" : "collection", - "title" : "ApolloPagination", - "type" : "topic", - "url" : "\/documentation\/apollopagination" -}, -"doc://ApolloPagination/documentation/ApolloPagination/GraphQLQueryPager": { - "abstract" : [ - { - "text" : "Type-erases a query pager, transforming data from a generic type to a specific type, often a view model or array of view models.", - "type" : "text" - } - ], - "fragments" : [ - { - "kind" : "keyword", - "text" : "class" - }, - { - "kind" : "text", - "text" : " " - }, - { - "kind" : "identifier", - "text" : "GraphQLQueryPager" - } - ], - "identifier" : "doc:\/\/ApolloPagination\/documentation\/ApolloPagination\/GraphQLQueryPager", - "kind" : "symbol", - "navigatorTitle" : [ - { - "kind" : "identifier", - "text" : "GraphQLQueryPager" - } - ], - "role" : "symbol", - "title" : "GraphQLQueryPager", - "type" : "topic", - "url" : "\/documentation\/apollopagination\/graphqlquerypager" -}, -"doc://ApolloPagination/documentation/ApolloPagination/GraphQLQueryPager/fetch()": { - "abstract" : [ - { - "text" : "Fetches the first page.", - "type" : "text" - } - ], - "fragments" : [ - { - "kind" : "keyword", - "text" : "func" - }, - { - "kind" : "text", - "text" : " " - }, - { - "kind" : "identifier", - "text" : "fetch" - }, - { - "kind" : "text", - "text" : "()" - } - ], - "identifier" : "doc:\/\/ApolloPagination\/documentation\/ApolloPagination\/GraphQLQueryPager\/fetch()", - "kind" : "symbol", - "role" : "symbol", - "title" : "fetch()", - "type" : "topic", - "url" : "\/documentation\/apollopagination\/graphqlquerypager\/fetch()" -} -} -} \ No newline at end of file diff --git a/docs/docc/Apollo.doccarchive/data/documentation/apollopagination/graphqlquerypager/refetch(cachepolicy:).json b/docs/docc/Apollo.doccarchive/data/documentation/apollopagination/graphqlquerypager/fetch(callbackqueue:completion:).json similarity index 59% rename from docs/docc/Apollo.doccarchive/data/documentation/apollopagination/graphqlquerypager/refetch(cachepolicy:).json rename to docs/docc/Apollo.doccarchive/data/documentation/apollopagination/graphqlquerypager/fetch(callbackqueue:completion:).json index b063d333d..2e04b1bc6 100644 --- a/docs/docc/Apollo.doccarchive/data/documentation/apollopagination/graphqlquerypager/refetch(cachepolicy:).json +++ b/docs/docc/Apollo.doccarchive/data/documentation/apollopagination/graphqlquerypager/fetch(callbackqueue:completion:).json @@ -1,7 +1,7 @@ { "abstract" : [ { - "text" : "Discards pagination state and fetches the first page from scratch.", + "text" : "Fetches the first page.", "type" : "text" } ], @@ -15,11 +15,11 @@ }, "identifier" : { "interfaceLanguage" : "swift", - "url" : "doc:\/\/ApolloPagination\/documentation\/ApolloPagination\/GraphQLQueryPager\/refetch(cachePolicy:)" + "url" : "doc:\/\/ApolloPagination\/documentation\/ApolloPagination\/GraphQLQueryPager\/fetch(callbackQueue:completion:)" }, "kind" : "symbol", "metadata" : { - "externalID" : "s:16ApolloPagination17GraphQLQueryPagerC7refetch11cachePolicyy0A005CacheH0O_tF", + "externalID" : "s:16ApolloPagination17GraphQLQueryPagerC5fetch13callbackQueue10completionySo17OS_dispatch_queueC_yycSgtF", "fragments" : [ { "kind" : "keyword", @@ -31,7 +31,7 @@ }, { "kind" : "identifier", - "text" : "refetch" + "text" : "fetch" }, { "kind" : "text", @@ -39,7 +39,7 @@ }, { "kind" : "externalParam", - "text" : "cachePolicy" + "text" : "callbackQueue" }, { "kind" : "text", @@ -47,12 +47,29 @@ }, { "kind" : "typeIdentifier", - "preciseIdentifier" : "s:6Apollo11CachePolicyO", - "text" : "CachePolicy" + "preciseIdentifier" : "c:objc(cs)OS_dispatch_queue", + "text" : "DispatchQueue" }, { "kind" : "text", - "text" : ")" + "text" : ", " + }, + { + "kind" : "externalParam", + "text" : "completion" + }, + { + "kind" : "text", + "text" : ": (() -> " + }, + { + "kind" : "typeIdentifier", + "preciseIdentifier" : "s:s4Voida", + "text" : "Void" + }, + { + "kind" : "text", + "text" : ")?)" } ], "modules" : [ @@ -63,7 +80,7 @@ "role" : "symbol", "roleHeading" : "Instance Method", "symbolKind" : "method", - "title" : "refetch(cachePolicy:)" + "title" : "fetch(callbackQueue:completion:)" }, "primaryContentSections" : [ { @@ -86,7 +103,7 @@ }, { "kind" : "identifier", - "text" : "refetch" + "text" : "fetch" }, { "kind" : "text", @@ -94,7 +111,7 @@ }, { "kind" : "externalParam", - "text" : "cachePolicy" + "text" : "callbackQueue" }, { "kind" : "text", @@ -102,12 +119,29 @@ }, { "kind" : "typeIdentifier", - "preciseIdentifier" : "s:6Apollo11CachePolicyO", - "text" : "CachePolicy" + "preciseIdentifier" : "c:objc(cs)OS_dispatch_queue", + "text" : "DispatchQueue" + }, + { + "kind" : "text", + "text" : " = .main, " + }, + { + "kind" : "externalParam", + "text" : "completion" + }, + { + "kind" : "text", + "text" : ": (() -> " + }, + { + "kind" : "typeIdentifier", + "preciseIdentifier" : "s:s4Voida", + "text" : "Void" }, { "kind" : "text", - "text" : " = .fetchIgnoringCacheData)" + "text" : ")? = nil)" } ] } @@ -122,11 +156,27 @@ { "inlineContent" : [ { - "text" : "The apollo cache policy to trigger the first fetch with. Defaults to ", + "text" : "The ", + "type" : "text" + }, + { + "code" : "DispatchQueue", + "type" : "codeVoice" + }, + { + "text" : " that the ", "type" : "text" }, { - "code" : "fetchIgnoringCacheData", + "code" : "completion", + "type" : "codeVoice" + }, + { + "text" : " fires on. Defaults to ", + "type" : "text" + }, + { + "code" : "main", "type" : "codeVoice" }, { @@ -137,7 +187,21 @@ "type" : "paragraph" } ], - "name" : "cachePolicy" + "name" : "callbackQueue" + }, + { + "content" : [ + { + "inlineContent" : [ + { + "text" : "A completion block that will always trigger after the execution of this operation.", + "type" : "text" + } + ], + "type" : "paragraph" + } + ], + "name" : "completion" } ] } @@ -153,7 +217,7 @@ "variants" : [ { "paths" : [ - "\/documentation\/apollopagination\/graphqlquerypager\/refetch(cachepolicy:)" + "\/documentation\/apollopagination\/graphqlquerypager\/fetch(callbackqueue:completion:)" ], "traits" : [ { @@ -209,10 +273,10 @@ "type" : "topic", "url" : "\/documentation\/apollopagination\/graphqlquerypager" }, -"doc://ApolloPagination/documentation/ApolloPagination/GraphQLQueryPager/refetch(cachePolicy:)": { +"doc://ApolloPagination/documentation/ApolloPagination/GraphQLQueryPager/fetch(callbackQueue:completion:)": { "abstract" : [ { - "text" : "Discards pagination state and fetches the first page from scratch.", + "text" : "Fetches the first page.", "type" : "text" } ], @@ -227,7 +291,7 @@ }, { "kind" : "identifier", - "text" : "refetch" + "text" : "fetch" }, { "kind" : "text", @@ -235,7 +299,7 @@ }, { "kind" : "externalParam", - "text" : "cachePolicy" + "text" : "callbackQueue" }, { "kind" : "text", @@ -243,20 +307,37 @@ }, { "kind" : "typeIdentifier", - "preciseIdentifier" : "s:6Apollo11CachePolicyO", - "text" : "CachePolicy" + "preciseIdentifier" : "c:objc(cs)OS_dispatch_queue", + "text" : "DispatchQueue" + }, + { + "kind" : "text", + "text" : ", " + }, + { + "kind" : "externalParam", + "text" : "completion" + }, + { + "kind" : "text", + "text" : ": (() -> " + }, + { + "kind" : "typeIdentifier", + "preciseIdentifier" : "s:s4Voida", + "text" : "Void" }, { "kind" : "text", - "text" : ")" + "text" : ")?)" } ], - "identifier" : "doc:\/\/ApolloPagination\/documentation\/ApolloPagination\/GraphQLQueryPager\/refetch(cachePolicy:)", + "identifier" : "doc:\/\/ApolloPagination\/documentation\/ApolloPagination\/GraphQLQueryPager\/fetch(callbackQueue:completion:)", "kind" : "symbol", "role" : "symbol", - "title" : "refetch(cachePolicy:)", + "title" : "fetch(callbackQueue:completion:)", "type" : "topic", - "url" : "\/documentation\/apollopagination\/graphqlquerypager\/refetch(cachepolicy:)" + "url" : "\/documentation\/apollopagination\/graphqlquerypager\/fetch(callbackqueue:completion:)" } } } \ No newline at end of file diff --git a/docs/docc/Apollo.doccarchive/data/documentation/apollopagination/graphqlquerypager/refetch(cachepolicy:callbackqueue:completion:).json b/docs/docc/Apollo.doccarchive/data/documentation/apollopagination/graphqlquerypager/refetch(cachepolicy:callbackqueue:completion:).json new file mode 100644 index 000000000..651885e96 --- /dev/null +++ b/docs/docc/Apollo.doccarchive/data/documentation/apollopagination/graphqlquerypager/refetch(cachepolicy:callbackqueue:completion:).json @@ -0,0 +1,416 @@ +{ + "abstract" : [ + { + "text" : "Discards pagination state and fetches the first page from scratch.", + "type" : "text" + } + ], + "hierarchy" : { + "paths" : [ + [ + "doc:\/\/ApolloPagination\/documentation\/ApolloPagination", + "doc:\/\/ApolloPagination\/documentation\/ApolloPagination\/GraphQLQueryPager" + ] + ] + }, + "identifier" : { + "interfaceLanguage" : "swift", + "url" : "doc:\/\/ApolloPagination\/documentation\/ApolloPagination\/GraphQLQueryPager\/refetch(cachePolicy:callbackQueue:completion:)" + }, + "kind" : "symbol", + "metadata" : { + "externalID" : "s:16ApolloPagination17GraphQLQueryPagerC7refetch11cachePolicy13callbackQueue10completiony0A005CacheH0O_So17OS_dispatch_queueCyycSgtF", + "fragments" : [ + { + "kind" : "keyword", + "text" : "func" + }, + { + "kind" : "text", + "text" : " " + }, + { + "kind" : "identifier", + "text" : "refetch" + }, + { + "kind" : "text", + "text" : "(" + }, + { + "kind" : "externalParam", + "text" : "cachePolicy" + }, + { + "kind" : "text", + "text" : ": " + }, + { + "kind" : "typeIdentifier", + "preciseIdentifier" : "s:6Apollo11CachePolicyO", + "text" : "CachePolicy" + }, + { + "kind" : "text", + "text" : ", " + }, + { + "kind" : "externalParam", + "text" : "callbackQueue" + }, + { + "kind" : "text", + "text" : ": " + }, + { + "kind" : "typeIdentifier", + "preciseIdentifier" : "c:objc(cs)OS_dispatch_queue", + "text" : "DispatchQueue" + }, + { + "kind" : "text", + "text" : ", " + }, + { + "kind" : "externalParam", + "text" : "completion" + }, + { + "kind" : "text", + "text" : ": (() -> " + }, + { + "kind" : "typeIdentifier", + "preciseIdentifier" : "s:s4Voida", + "text" : "Void" + }, + { + "kind" : "text", + "text" : ")?)" + } + ], + "modules" : [ + { + "name" : "ApolloPagination" + } + ], + "role" : "symbol", + "roleHeading" : "Instance Method", + "symbolKind" : "method", + "title" : "refetch(cachePolicy:callbackQueue:completion:)" + }, + "primaryContentSections" : [ + { + "declarations" : [ + { + "languages" : [ + "swift" + ], + "platforms" : [ + "macOS" + ], + "tokens" : [ + { + "kind" : "keyword", + "text" : "func" + }, + { + "kind" : "text", + "text" : " " + }, + { + "kind" : "identifier", + "text" : "refetch" + }, + { + "kind" : "text", + "text" : "(" + }, + { + "kind" : "externalParam", + "text" : "cachePolicy" + }, + { + "kind" : "text", + "text" : ": " + }, + { + "kind" : "typeIdentifier", + "preciseIdentifier" : "s:6Apollo11CachePolicyO", + "text" : "CachePolicy" + }, + { + "kind" : "text", + "text" : " = .fetchIgnoringCacheData, " + }, + { + "kind" : "externalParam", + "text" : "callbackQueue" + }, + { + "kind" : "text", + "text" : ": " + }, + { + "kind" : "typeIdentifier", + "preciseIdentifier" : "c:objc(cs)OS_dispatch_queue", + "text" : "DispatchQueue" + }, + { + "kind" : "text", + "text" : " = .main, " + }, + { + "kind" : "externalParam", + "text" : "completion" + }, + { + "kind" : "text", + "text" : ": (() -> " + }, + { + "kind" : "typeIdentifier", + "preciseIdentifier" : "s:s4Voida", + "text" : "Void" + }, + { + "kind" : "text", + "text" : ")? = nil)" + } + ] + } + ], + "kind" : "declarations" + }, + { + "kind" : "parameters", + "parameters" : [ + { + "content" : [ + { + "inlineContent" : [ + { + "text" : "The apollo cache policy to trigger the first fetch with. Defaults to ", + "type" : "text" + }, + { + "code" : "fetchIgnoringCacheData", + "type" : "codeVoice" + }, + { + "text" : ".", + "type" : "text" + } + ], + "type" : "paragraph" + } + ], + "name" : "cachePolicy" + }, + { + "content" : [ + { + "inlineContent" : [ + { + "text" : "The ", + "type" : "text" + }, + { + "code" : "DispatchQueue", + "type" : "codeVoice" + }, + { + "text" : " that the ", + "type" : "text" + }, + { + "code" : "completion", + "type" : "codeVoice" + }, + { + "text" : " fires on. Defaults to ", + "type" : "text" + }, + { + "code" : "main", + "type" : "codeVoice" + }, + { + "text" : ".", + "type" : "text" + } + ], + "type" : "paragraph" + } + ], + "name" : "callbackQueue" + }, + { + "content" : [ + { + "inlineContent" : [ + { + "text" : "A completion block that will always trigger after the execution of this operation.", + "type" : "text" + } + ], + "type" : "paragraph" + } + ], + "name" : "completion" + } + ] + } + ], + "schemaVersion" : { + "major" : 0, + "minor" : 3, + "patch" : 0 + }, + "sections" : [ + + ], + "variants" : [ + { + "paths" : [ + "\/documentation\/apollopagination\/graphqlquerypager\/refetch(cachepolicy:callbackqueue:completion:)" + ], + "traits" : [ + { + "interfaceLanguage" : "swift" + } + ] + } + ] +, +"references": { +"doc://ApolloPagination/documentation/ApolloPagination": { + "abstract" : [ + + ], + "identifier" : "doc:\/\/ApolloPagination\/documentation\/ApolloPagination", + "kind" : "symbol", + "role" : "collection", + "title" : "ApolloPagination", + "type" : "topic", + "url" : "\/documentation\/apollopagination" +}, +"doc://ApolloPagination/documentation/ApolloPagination/GraphQLQueryPager": { + "abstract" : [ + { + "text" : "Type-erases a query pager, transforming data from a generic type to a specific type, often a view model or array of view models.", + "type" : "text" + } + ], + "fragments" : [ + { + "kind" : "keyword", + "text" : "class" + }, + { + "kind" : "text", + "text" : " " + }, + { + "kind" : "identifier", + "text" : "GraphQLQueryPager" + } + ], + "identifier" : "doc:\/\/ApolloPagination\/documentation\/ApolloPagination\/GraphQLQueryPager", + "kind" : "symbol", + "navigatorTitle" : [ + { + "kind" : "identifier", + "text" : "GraphQLQueryPager" + } + ], + "role" : "symbol", + "title" : "GraphQLQueryPager", + "type" : "topic", + "url" : "\/documentation\/apollopagination\/graphqlquerypager" +}, +"doc://ApolloPagination/documentation/ApolloPagination/GraphQLQueryPager/refetch(cachePolicy:callbackQueue:completion:)": { + "abstract" : [ + { + "text" : "Discards pagination state and fetches the first page from scratch.", + "type" : "text" + } + ], + "fragments" : [ + { + "kind" : "keyword", + "text" : "func" + }, + { + "kind" : "text", + "text" : " " + }, + { + "kind" : "identifier", + "text" : "refetch" + }, + { + "kind" : "text", + "text" : "(" + }, + { + "kind" : "externalParam", + "text" : "cachePolicy" + }, + { + "kind" : "text", + "text" : ": " + }, + { + "kind" : "typeIdentifier", + "preciseIdentifier" : "s:6Apollo11CachePolicyO", + "text" : "CachePolicy" + }, + { + "kind" : "text", + "text" : ", " + }, + { + "kind" : "externalParam", + "text" : "callbackQueue" + }, + { + "kind" : "text", + "text" : ": " + }, + { + "kind" : "typeIdentifier", + "preciseIdentifier" : "c:objc(cs)OS_dispatch_queue", + "text" : "DispatchQueue" + }, + { + "kind" : "text", + "text" : ", " + }, + { + "kind" : "externalParam", + "text" : "completion" + }, + { + "kind" : "text", + "text" : ": (() -> " + }, + { + "kind" : "typeIdentifier", + "preciseIdentifier" : "s:s4Voida", + "text" : "Void" + }, + { + "kind" : "text", + "text" : ")?)" + } + ], + "identifier" : "doc:\/\/ApolloPagination\/documentation\/ApolloPagination\/GraphQLQueryPager\/refetch(cachePolicy:callbackQueue:completion:)", + "kind" : "symbol", + "role" : "symbol", + "title" : "refetch(cachePolicy:callbackQueue:completion:)", + "type" : "topic", + "url" : "\/documentation\/apollopagination\/graphqlquerypager\/refetch(cachepolicy:callbackqueue:completion:)" +} +} +} \ No newline at end of file diff --git a/docs/docc/Apollo.doccarchive/data/documentation/apollopagination/pagertype.json b/docs/docc/Apollo.doccarchive/data/documentation/apollopagination/pagertype.json index fd3b3f228..1728a0362 100644 --- a/docs/docc/Apollo.doccarchive/data/documentation/apollopagination/pagertype.json +++ b/docs/docc/Apollo.doccarchive/data/documentation/apollopagination/pagertype.json @@ -97,11 +97,11 @@ }, { "identifiers" : [ - "doc:\/\/ApolloPagination\/documentation\/ApolloPagination\/PagerType\/fetch()", + "doc:\/\/ApolloPagination\/documentation\/ApolloPagination\/PagerType\/fetch(callbackQueue:completion:)", "doc:\/\/ApolloPagination\/documentation\/ApolloPagination\/PagerType\/loadAll(fetchFromInitialPage:callbackQueue:completion:)", "doc:\/\/ApolloPagination\/documentation\/ApolloPagination\/PagerType\/loadNext(cachePolicy:callbackQueue:completion:)", "doc:\/\/ApolloPagination\/documentation\/ApolloPagination\/PagerType\/loadPrevious(cachePolicy:callbackQueue:completion:)", - "doc:\/\/ApolloPagination\/documentation\/ApolloPagination\/PagerType\/refetch(cachePolicy:)", + "doc:\/\/ApolloPagination\/documentation\/ApolloPagination\/PagerType\/refetch(cachePolicy:callbackQueue:completion:)", "doc:\/\/ApolloPagination\/documentation\/ApolloPagination\/PagerType\/reset()" ], "title" : "Instance Methods" @@ -303,7 +303,7 @@ "type" : "topic", "url" : "\/documentation\/apollopagination\/pagertype\/canloadprevious" }, -"doc://ApolloPagination/documentation/ApolloPagination/PagerType/fetch()": { +"doc://ApolloPagination/documentation/ApolloPagination/PagerType/fetch(callbackQueue:completion:)": { "abstract" : [ ], @@ -322,16 +322,50 @@ }, { "kind" : "text", - "text" : "()" + "text" : "(" + }, + { + "kind" : "externalParam", + "text" : "callbackQueue" + }, + { + "kind" : "text", + "text" : ": " + }, + { + "kind" : "typeIdentifier", + "preciseIdentifier" : "c:objc(cs)OS_dispatch_queue", + "text" : "DispatchQueue" + }, + { + "kind" : "text", + "text" : ", " + }, + { + "kind" : "externalParam", + "text" : "completion" + }, + { + "kind" : "text", + "text" : ": (() -> " + }, + { + "kind" : "typeIdentifier", + "preciseIdentifier" : "s:s4Voida", + "text" : "Void" + }, + { + "kind" : "text", + "text" : ")?)" } ], - "identifier" : "doc:\/\/ApolloPagination\/documentation\/ApolloPagination\/PagerType\/fetch()", + "identifier" : "doc:\/\/ApolloPagination\/documentation\/ApolloPagination\/PagerType\/fetch(callbackQueue:completion:)", "kind" : "symbol", "required" : true, "role" : "symbol", - "title" : "fetch()", + "title" : "fetch(callbackQueue:completion:)", "type" : "topic", - "url" : "\/documentation\/apollopagination\/pagertype\/fetch()" + "url" : "\/documentation\/apollopagination\/pagertype\/fetch(callbackqueue:completion:)" }, "doc://ApolloPagination/documentation/ApolloPagination/PagerType/loadAll(fetchFromInitialPage:callbackQueue:completion:)": { "abstract" : [ @@ -603,7 +637,7 @@ "type" : "topic", "url" : "\/documentation\/apollopagination\/pagertype\/loadprevious(cachepolicy:callbackqueue:completion:)" }, -"doc://ApolloPagination/documentation/ApolloPagination/PagerType/refetch(cachePolicy:)": { +"doc://ApolloPagination/documentation/ApolloPagination/PagerType/refetch(cachePolicy:callbackQueue:completion:)": { "abstract" : [ ], @@ -639,16 +673,50 @@ }, { "kind" : "text", - "text" : ")" + "text" : ", " + }, + { + "kind" : "externalParam", + "text" : "callbackQueue" + }, + { + "kind" : "text", + "text" : ": " + }, + { + "kind" : "typeIdentifier", + "preciseIdentifier" : "c:objc(cs)OS_dispatch_queue", + "text" : "DispatchQueue" + }, + { + "kind" : "text", + "text" : ", " + }, + { + "kind" : "externalParam", + "text" : "completion" + }, + { + "kind" : "text", + "text" : ": (() -> " + }, + { + "kind" : "typeIdentifier", + "preciseIdentifier" : "s:s4Voida", + "text" : "Void" + }, + { + "kind" : "text", + "text" : ")?)" } ], - "identifier" : "doc:\/\/ApolloPagination\/documentation\/ApolloPagination\/PagerType\/refetch(cachePolicy:)", + "identifier" : "doc:\/\/ApolloPagination\/documentation\/ApolloPagination\/PagerType\/refetch(cachePolicy:callbackQueue:completion:)", "kind" : "symbol", "required" : true, "role" : "symbol", - "title" : "refetch(cachePolicy:)", + "title" : "refetch(cachePolicy:callbackQueue:completion:)", "type" : "topic", - "url" : "\/documentation\/apollopagination\/pagertype\/refetch(cachepolicy:)" + "url" : "\/documentation\/apollopagination\/pagertype\/refetch(cachepolicy:callbackqueue:completion:)" }, "doc://ApolloPagination/documentation/ApolloPagination/PagerType/reset()": { "abstract" : [ diff --git a/docs/docc/Apollo.doccarchive/data/documentation/apollopagination/pagertype/fetch().json b/docs/docc/Apollo.doccarchive/data/documentation/apollopagination/pagertype/fetch().json deleted file mode 100644 index 57001e279..000000000 --- a/docs/docc/Apollo.doccarchive/data/documentation/apollopagination/pagertype/fetch().json +++ /dev/null @@ -1,174 +0,0 @@ -{ - "hierarchy" : { - "paths" : [ - [ - "doc:\/\/ApolloPagination\/documentation\/ApolloPagination", - "doc:\/\/ApolloPagination\/documentation\/ApolloPagination\/PagerType" - ] - ] - }, - "identifier" : { - "interfaceLanguage" : "swift", - "url" : "doc:\/\/ApolloPagination\/documentation\/ApolloPagination\/PagerType\/fetch()" - }, - "kind" : "symbol", - "metadata" : { - "externalID" : "s:16ApolloPagination9PagerTypeP5fetchyyF", - "fragments" : [ - { - "kind" : "keyword", - "text" : "func" - }, - { - "kind" : "text", - "text" : " " - }, - { - "kind" : "identifier", - "text" : "fetch" - }, - { - "kind" : "text", - "text" : "()" - } - ], - "modules" : [ - { - "name" : "ApolloPagination" - } - ], - "required" : true, - "role" : "symbol", - "roleHeading" : "Instance Method", - "symbolKind" : "method", - "title" : "fetch()" - }, - "primaryContentSections" : [ - { - "declarations" : [ - { - "languages" : [ - "swift" - ], - "platforms" : [ - "macOS" - ], - "tokens" : [ - { - "kind" : "keyword", - "text" : "func" - }, - { - "kind" : "text", - "text" : " " - }, - { - "kind" : "identifier", - "text" : "fetch" - }, - { - "kind" : "text", - "text" : "()" - } - ] - } - ], - "kind" : "declarations" - } - ], - "schemaVersion" : { - "major" : 0, - "minor" : 3, - "patch" : 0 - }, - "sections" : [ - - ], - "variants" : [ - { - "paths" : [ - "\/documentation\/apollopagination\/pagertype\/fetch()" - ], - "traits" : [ - { - "interfaceLanguage" : "swift" - } - ] - } - ] -, -"references": { -"doc://ApolloPagination/documentation/ApolloPagination": { - "abstract" : [ - - ], - "identifier" : "doc:\/\/ApolloPagination\/documentation\/ApolloPagination", - "kind" : "symbol", - "role" : "collection", - "title" : "ApolloPagination", - "type" : "topic", - "url" : "\/documentation\/apollopagination" -}, -"doc://ApolloPagination/documentation/ApolloPagination/PagerType": { - "abstract" : [ - - ], - "fragments" : [ - { - "kind" : "keyword", - "text" : "protocol" - }, - { - "kind" : "text", - "text" : " " - }, - { - "kind" : "identifier", - "text" : "PagerType" - } - ], - "identifier" : "doc:\/\/ApolloPagination\/documentation\/ApolloPagination\/PagerType", - "kind" : "symbol", - "navigatorTitle" : [ - { - "kind" : "identifier", - "text" : "PagerType" - } - ], - "role" : "symbol", - "title" : "PagerType", - "type" : "topic", - "url" : "\/documentation\/apollopagination\/pagertype" -}, -"doc://ApolloPagination/documentation/ApolloPagination/PagerType/fetch()": { - "abstract" : [ - - ], - "fragments" : [ - { - "kind" : "keyword", - "text" : "func" - }, - { - "kind" : "text", - "text" : " " - }, - { - "kind" : "identifier", - "text" : "fetch" - }, - { - "kind" : "text", - "text" : "()" - } - ], - "identifier" : "doc:\/\/ApolloPagination\/documentation\/ApolloPagination\/PagerType\/fetch()", - "kind" : "symbol", - "required" : true, - "role" : "symbol", - "title" : "fetch()", - "type" : "topic", - "url" : "\/documentation\/apollopagination\/pagertype\/fetch()" -} -} -} \ No newline at end of file diff --git a/docs/docc/Apollo.doccarchive/data/documentation/apollopagination/pagertype/refetch(cachepolicy:).json b/docs/docc/Apollo.doccarchive/data/documentation/apollopagination/pagertype/fetch(callbackqueue:completion:).json similarity index 63% rename from docs/docc/Apollo.doccarchive/data/documentation/apollopagination/pagertype/refetch(cachepolicy:).json rename to docs/docc/Apollo.doccarchive/data/documentation/apollopagination/pagertype/fetch(callbackqueue:completion:).json index 69cd28d60..d017e30d3 100644 --- a/docs/docc/Apollo.doccarchive/data/documentation/apollopagination/pagertype/refetch(cachepolicy:).json +++ b/docs/docc/Apollo.doccarchive/data/documentation/apollopagination/pagertype/fetch(callbackqueue:completion:).json @@ -9,11 +9,11 @@ }, "identifier" : { "interfaceLanguage" : "swift", - "url" : "doc:\/\/ApolloPagination\/documentation\/ApolloPagination\/PagerType\/refetch(cachePolicy:)" + "url" : "doc:\/\/ApolloPagination\/documentation\/ApolloPagination\/PagerType\/fetch(callbackQueue:completion:)" }, "kind" : "symbol", "metadata" : { - "externalID" : "s:16ApolloPagination9PagerTypeP7refetch11cachePolicyy0A005CacheG0O_tF", + "externalID" : "s:16ApolloPagination9PagerTypeP5fetch13callbackQueue10completionySo17OS_dispatch_queueC_yycSgtF", "fragments" : [ { "kind" : "keyword", @@ -25,7 +25,7 @@ }, { "kind" : "identifier", - "text" : "refetch" + "text" : "fetch" }, { "kind" : "text", @@ -33,7 +33,7 @@ }, { "kind" : "externalParam", - "text" : "cachePolicy" + "text" : "callbackQueue" }, { "kind" : "text", @@ -41,12 +41,29 @@ }, { "kind" : "typeIdentifier", - "preciseIdentifier" : "s:6Apollo11CachePolicyO", - "text" : "CachePolicy" + "preciseIdentifier" : "c:objc(cs)OS_dispatch_queue", + "text" : "DispatchQueue" }, { "kind" : "text", - "text" : ")" + "text" : ", " + }, + { + "kind" : "externalParam", + "text" : "completion" + }, + { + "kind" : "text", + "text" : ": (() -> " + }, + { + "kind" : "typeIdentifier", + "preciseIdentifier" : "s:s4Voida", + "text" : "Void" + }, + { + "kind" : "text", + "text" : ")?)" } ], "modules" : [ @@ -58,7 +75,7 @@ "role" : "symbol", "roleHeading" : "Instance Method", "symbolKind" : "method", - "title" : "refetch(cachePolicy:)" + "title" : "fetch(callbackQueue:completion:)" }, "primaryContentSections" : [ { @@ -81,7 +98,7 @@ }, { "kind" : "identifier", - "text" : "refetch" + "text" : "fetch" }, { "kind" : "text", @@ -89,7 +106,7 @@ }, { "kind" : "externalParam", - "text" : "cachePolicy" + "text" : "callbackQueue" }, { "kind" : "text", @@ -97,12 +114,29 @@ }, { "kind" : "typeIdentifier", - "preciseIdentifier" : "s:6Apollo11CachePolicyO", - "text" : "CachePolicy" + "preciseIdentifier" : "c:objc(cs)OS_dispatch_queue", + "text" : "DispatchQueue" + }, + { + "kind" : "text", + "text" : ", " + }, + { + "kind" : "externalParam", + "text" : "completion" + }, + { + "kind" : "text", + "text" : ": (() -> " + }, + { + "kind" : "typeIdentifier", + "preciseIdentifier" : "s:s4Voida", + "text" : "Void" }, { "kind" : "text", - "text" : ")" + "text" : ")?)" } ] } @@ -121,7 +155,7 @@ "variants" : [ { "paths" : [ - "\/documentation\/apollopagination\/pagertype\/refetch(cachepolicy:)" + "\/documentation\/apollopagination\/pagertype\/fetch(callbackqueue:completion:)" ], "traits" : [ { @@ -174,7 +208,7 @@ "type" : "topic", "url" : "\/documentation\/apollopagination\/pagertype" }, -"doc://ApolloPagination/documentation/ApolloPagination/PagerType/refetch(cachePolicy:)": { +"doc://ApolloPagination/documentation/ApolloPagination/PagerType/fetch(callbackQueue:completion:)": { "abstract" : [ ], @@ -189,7 +223,7 @@ }, { "kind" : "identifier", - "text" : "refetch" + "text" : "fetch" }, { "kind" : "text", @@ -197,7 +231,7 @@ }, { "kind" : "externalParam", - "text" : "cachePolicy" + "text" : "callbackQueue" }, { "kind" : "text", @@ -205,21 +239,38 @@ }, { "kind" : "typeIdentifier", - "preciseIdentifier" : "s:6Apollo11CachePolicyO", - "text" : "CachePolicy" + "preciseIdentifier" : "c:objc(cs)OS_dispatch_queue", + "text" : "DispatchQueue" + }, + { + "kind" : "text", + "text" : ", " + }, + { + "kind" : "externalParam", + "text" : "completion" + }, + { + "kind" : "text", + "text" : ": (() -> " + }, + { + "kind" : "typeIdentifier", + "preciseIdentifier" : "s:s4Voida", + "text" : "Void" }, { "kind" : "text", - "text" : ")" + "text" : ")?)" } ], - "identifier" : "doc:\/\/ApolloPagination\/documentation\/ApolloPagination\/PagerType\/refetch(cachePolicy:)", + "identifier" : "doc:\/\/ApolloPagination\/documentation\/ApolloPagination\/PagerType\/fetch(callbackQueue:completion:)", "kind" : "symbol", "required" : true, "role" : "symbol", - "title" : "refetch(cachePolicy:)", + "title" : "fetch(callbackQueue:completion:)", "type" : "topic", - "url" : "\/documentation\/apollopagination\/pagertype\/refetch(cachepolicy:)" + "url" : "\/documentation\/apollopagination\/pagertype\/fetch(callbackqueue:completion:)" } } } \ No newline at end of file diff --git a/docs/docc/Apollo.doccarchive/data/documentation/apollopagination/pagertype/refetch(cachepolicy:callbackqueue:completion:).json b/docs/docc/Apollo.doccarchive/data/documentation/apollopagination/pagertype/refetch(cachepolicy:callbackqueue:completion:).json new file mode 100644 index 000000000..395708729 --- /dev/null +++ b/docs/docc/Apollo.doccarchive/data/documentation/apollopagination/pagertype/refetch(cachepolicy:callbackqueue:completion:).json @@ -0,0 +1,327 @@ +{ + "hierarchy" : { + "paths" : [ + [ + "doc:\/\/ApolloPagination\/documentation\/ApolloPagination", + "doc:\/\/ApolloPagination\/documentation\/ApolloPagination\/PagerType" + ] + ] + }, + "identifier" : { + "interfaceLanguage" : "swift", + "url" : "doc:\/\/ApolloPagination\/documentation\/ApolloPagination\/PagerType\/refetch(cachePolicy:callbackQueue:completion:)" + }, + "kind" : "symbol", + "metadata" : { + "externalID" : "s:16ApolloPagination9PagerTypeP7refetch11cachePolicy13callbackQueue10completiony0A005CacheG0O_So17OS_dispatch_queueCyycSgtF", + "fragments" : [ + { + "kind" : "keyword", + "text" : "func" + }, + { + "kind" : "text", + "text" : " " + }, + { + "kind" : "identifier", + "text" : "refetch" + }, + { + "kind" : "text", + "text" : "(" + }, + { + "kind" : "externalParam", + "text" : "cachePolicy" + }, + { + "kind" : "text", + "text" : ": " + }, + { + "kind" : "typeIdentifier", + "preciseIdentifier" : "s:6Apollo11CachePolicyO", + "text" : "CachePolicy" + }, + { + "kind" : "text", + "text" : ", " + }, + { + "kind" : "externalParam", + "text" : "callbackQueue" + }, + { + "kind" : "text", + "text" : ": " + }, + { + "kind" : "typeIdentifier", + "preciseIdentifier" : "c:objc(cs)OS_dispatch_queue", + "text" : "DispatchQueue" + }, + { + "kind" : "text", + "text" : ", " + }, + { + "kind" : "externalParam", + "text" : "completion" + }, + { + "kind" : "text", + "text" : ": (() -> " + }, + { + "kind" : "typeIdentifier", + "preciseIdentifier" : "s:s4Voida", + "text" : "Void" + }, + { + "kind" : "text", + "text" : ")?)" + } + ], + "modules" : [ + { + "name" : "ApolloPagination" + } + ], + "required" : true, + "role" : "symbol", + "roleHeading" : "Instance Method", + "symbolKind" : "method", + "title" : "refetch(cachePolicy:callbackQueue:completion:)" + }, + "primaryContentSections" : [ + { + "declarations" : [ + { + "languages" : [ + "swift" + ], + "platforms" : [ + "macOS" + ], + "tokens" : [ + { + "kind" : "keyword", + "text" : "func" + }, + { + "kind" : "text", + "text" : " " + }, + { + "kind" : "identifier", + "text" : "refetch" + }, + { + "kind" : "text", + "text" : "(" + }, + { + "kind" : "externalParam", + "text" : "cachePolicy" + }, + { + "kind" : "text", + "text" : ": " + }, + { + "kind" : "typeIdentifier", + "preciseIdentifier" : "s:6Apollo11CachePolicyO", + "text" : "CachePolicy" + }, + { + "kind" : "text", + "text" : ", " + }, + { + "kind" : "externalParam", + "text" : "callbackQueue" + }, + { + "kind" : "text", + "text" : ": " + }, + { + "kind" : "typeIdentifier", + "preciseIdentifier" : "c:objc(cs)OS_dispatch_queue", + "text" : "DispatchQueue" + }, + { + "kind" : "text", + "text" : ", " + }, + { + "kind" : "externalParam", + "text" : "completion" + }, + { + "kind" : "text", + "text" : ": (() -> " + }, + { + "kind" : "typeIdentifier", + "preciseIdentifier" : "s:s4Voida", + "text" : "Void" + }, + { + "kind" : "text", + "text" : ")?)" + } + ] + } + ], + "kind" : "declarations" + } + ], + "schemaVersion" : { + "major" : 0, + "minor" : 3, + "patch" : 0 + }, + "sections" : [ + + ], + "variants" : [ + { + "paths" : [ + "\/documentation\/apollopagination\/pagertype\/refetch(cachepolicy:callbackqueue:completion:)" + ], + "traits" : [ + { + "interfaceLanguage" : "swift" + } + ] + } + ] +, +"references": { +"doc://ApolloPagination/documentation/ApolloPagination": { + "abstract" : [ + + ], + "identifier" : "doc:\/\/ApolloPagination\/documentation\/ApolloPagination", + "kind" : "symbol", + "role" : "collection", + "title" : "ApolloPagination", + "type" : "topic", + "url" : "\/documentation\/apollopagination" +}, +"doc://ApolloPagination/documentation/ApolloPagination/PagerType": { + "abstract" : [ + + ], + "fragments" : [ + { + "kind" : "keyword", + "text" : "protocol" + }, + { + "kind" : "text", + "text" : " " + }, + { + "kind" : "identifier", + "text" : "PagerType" + } + ], + "identifier" : "doc:\/\/ApolloPagination\/documentation\/ApolloPagination\/PagerType", + "kind" : "symbol", + "navigatorTitle" : [ + { + "kind" : "identifier", + "text" : "PagerType" + } + ], + "role" : "symbol", + "title" : "PagerType", + "type" : "topic", + "url" : "\/documentation\/apollopagination\/pagertype" +}, +"doc://ApolloPagination/documentation/ApolloPagination/PagerType/refetch(cachePolicy:callbackQueue:completion:)": { + "abstract" : [ + + ], + "fragments" : [ + { + "kind" : "keyword", + "text" : "func" + }, + { + "kind" : "text", + "text" : " " + }, + { + "kind" : "identifier", + "text" : "refetch" + }, + { + "kind" : "text", + "text" : "(" + }, + { + "kind" : "externalParam", + "text" : "cachePolicy" + }, + { + "kind" : "text", + "text" : ": " + }, + { + "kind" : "typeIdentifier", + "preciseIdentifier" : "s:6Apollo11CachePolicyO", + "text" : "CachePolicy" + }, + { + "kind" : "text", + "text" : ", " + }, + { + "kind" : "externalParam", + "text" : "callbackQueue" + }, + { + "kind" : "text", + "text" : ": " + }, + { + "kind" : "typeIdentifier", + "preciseIdentifier" : "c:objc(cs)OS_dispatch_queue", + "text" : "DispatchQueue" + }, + { + "kind" : "text", + "text" : ", " + }, + { + "kind" : "externalParam", + "text" : "completion" + }, + { + "kind" : "text", + "text" : ": (() -> " + }, + { + "kind" : "typeIdentifier", + "preciseIdentifier" : "s:s4Voida", + "text" : "Void" + }, + { + "kind" : "text", + "text" : ")?)" + } + ], + "identifier" : "doc:\/\/ApolloPagination\/documentation\/ApolloPagination\/PagerType\/refetch(cachePolicy:callbackQueue:completion:)", + "kind" : "symbol", + "required" : true, + "role" : "symbol", + "title" : "refetch(cachePolicy:callbackQueue:completion:)", + "type" : "topic", + "url" : "\/documentation\/apollopagination\/pagertype\/refetch(cachepolicy:callbackqueue:completion:)" +} +} +} \ No newline at end of file From df9492a4933a4b74a028c2ad2121479506b29c1a Mon Sep 17 00:00:00 2001 From: Hesham Salman Date: Mon, 25 Mar 2024 13:50:59 -0400 Subject: [PATCH 4/5] Update usage guide --- docs/source/pagination/introduction.mdx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/source/pagination/introduction.mdx b/docs/source/pagination/introduction.mdx index c877973be..ff223bbe0 100644 --- a/docs/source/pagination/introduction.mdx +++ b/docs/source/pagination/introduction.mdx @@ -80,11 +80,11 @@ pager.sink { result in The `GraphQLQueryPager` class provides several methods to fetch paginated data: `fetch`, `refetch`, `loadNext`, `loadPrevious`, and `loadAll`. -- `fetch`: Fetches the first page of data. Must be called before `loadNext` or `loadPrevious` can be called. -- `refetch`: Cancels all in-flight fetch operations and resets the pager to its initial state. Fetches the first page of data. -- `loadNext`: Fetches the next page of data. Can only be called after `fetch` has been called. -- `loadPrevious`: Fetches the previous page of data. Can only be called after `fetch` has been called. -- `loadAll`: Fetches all pages of data. If no initial page is detected, it will first call `fetch` to fetch the first page of data. Will continue to fetch all pages until a `PageInfo` object indicates that there are no more pages to fetch. This function is compatible with forward, reverse, and bidirectional pagination. +- `fetch`: Fetches the first page of data. Must be called before `loadNext` or `loadPrevious` can be called. Provides a completion handler that allows the caller to be notified when the fetch operation is complete. +- `refetch`: Cancels all in-flight fetch operations and resets the pager to its initial state. Fetches the first page of data. Provides a completion handler that allows the caller to be notified when the fetch operation is complete. +- `loadNext`: Fetches the next page of data. Can only be called after `fetch` has been called. Provides a completion handler that allows the caller to be notified when the operation is complete, with an optional `Error?` parameter that contains any usage errors that may have occurred. +- `loadPrevious`: Fetches the previous page of data. Can only be called after `fetch` has been called. Provides a completion handler that allows the caller to be notified when the operation is complete, with an optional `Error?` parameter that contains any usage errors that may have occurred. +- `loadAll`: Fetches all pages of data. If no initial page is detected, it will first call `fetch` to fetch the first page of data. Will continue to fetch all pages until a `PageInfo` object indicates that there are no more pages to fetch. This function is compatible with forward, reverse, and bidirectional pagination. Provides a completion handler that allows the caller to be notified when the operation is complete, with an optional `Error?` parameter that contains any usage errors that may have occurred. ## Cancelling ongoing requests @@ -96,7 +96,7 @@ There are two broad categories of errors that the `GraphQLQueryPager` class can ### Usage errors in `GraphQLQueryPager` -The `fetch`, `refetch`, `loadNext`, `loadPrevious`, and `loadAll` methods all have a completion handler that is called with a `Result` type. This `Result` type can contain either the paginated data or a `PaginationError` type. Common pagination errors are attempting to fetch while there is already a load in progress, or attempting to fetch a previous or next page without first calling `fetch`. +The `loadNext`, `loadPrevious`, and `loadAll` methods all have a completion handler that is called with a `Result` type. This `Result` type can contain either the paginated data or a `PaginationError` type. Common pagination errors are attempting to fetch while there is already a load in progress, or attempting to fetch a previous or next page without first calling `fetch`. ```swift // Attempting to fetch a previous page without first calling `fetch` From 02b30f194693caf3eeae3488453099d5c3573b5b Mon Sep 17 00:00:00 2001 From: Hesham Salman Date: Wed, 27 Mar 2024 12:17:39 -0400 Subject: [PATCH 5/5] Add extra notes for AsyncGraphQLQueryPager --- docs/source/pagination/introduction.mdx | 40 +++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 3 deletions(-) diff --git a/docs/source/pagination/introduction.mdx b/docs/source/pagination/introduction.mdx index ff223bbe0..b296d7599 100644 --- a/docs/source/pagination/introduction.mdx +++ b/docs/source/pagination/introduction.mdx @@ -19,7 +19,7 @@ In this example, a `GraphQLQueryPager` is initialized that paginates a single qu ```swift let initialQuery = MyQuery(first: 10, after: nil) -let pager = GraphQLQueryPager.makeQueryPager( +let pager = GraphQLQueryPager( client: client, initialQuery: initialQuery, extractPageInfo: { data in @@ -46,9 +46,40 @@ Whenever the pager needs to load a new page, it will call the `extractPageInfo` We could similarly support forward offset-based pagination by supplying `OffsetPagination.Forward` instead of `CursorBasedPagination.Forward` to the `extractPageInfo` closure. +## Using an `AsyncGraphQLQueryPager` + +The `AsyncGraphQLQueryPager` class is similar to the `GraphQLQueryPager` class, but it supports `async`/`await` for use in asynchronous contexts. + +In this example, an `AsyncGraphQLQueryPager` is initialized that paginates a single query in the forward direction with cursor-based pagination: + +```swift +let initialQuery = MyQuery(first: 10, after: nil) +let pager = AsyncGraphQLQueryPager( + client: client, + initialQuery: initialQuery, + extractPageInfo: { data in + CursorBasedPagination.Forward( + hasNext: data.values.pageInfo.hasNextPage ?? false, + endCursor: data.values.pageInfo.endCursor + ) + }, + pageResolver: { page, paginationDirection in + // As we only want to support forward pagination, we can return `nil` for reverse pagination + switch paginationDirection { + case .next: + return MyQuery(first: 10, after: page.endCursor ?? .none) + case .previous: + return nil + } + } +) +``` + +Note that it is initialized in an identical manner to `GraphQLQueryPager`, with the same parameters. + ## Subscribing to results -The `GraphQLQueryPager` class can fetch data, but the caller must subscribe to the results in order to receive the data. A `subscribe` method is provided which takes a closure that is called whenever the pager fetches a new page of data. The `subscribe` method is a convenience method that ensures that the closure is called on the main thread. +The `GraphQLQueryPager` and `AsyncGraphQLQueryPager` classes can fetch data, but the caller must subscribe to the results in order to receive the data. A `subscribe` method is provided which takes a closure that is called whenever the pager fetches a new page of data. The `subscribe` method is a convenience method that ensures that the closure is called on the main thread. ```swift // Guaranteed to run on the main thread @@ -62,7 +93,7 @@ pager.subscribe { result in } ``` -The `GraphQLQueryPager` is also a Combine `Publisher`. As such, all `Publisher` methods are available, such as `sink`, `assign`, `map`, `filter`, and so on. +Both the `GraphQLQueryPager` and `AsyncGraphQLQueryPager` are also Combine `Publisher`s. As such, all `Publisher` methods are available, such as `sink`, `assign`, `map`, `filter`, and so on. ```swift // Can run on any thread @@ -86,6 +117,9 @@ The `GraphQLQueryPager` class provides several methods to fetch paginated data: - `loadPrevious`: Fetches the previous page of data. Can only be called after `fetch` has been called. Provides a completion handler that allows the caller to be notified when the operation is complete, with an optional `Error?` parameter that contains any usage errors that may have occurred. - `loadAll`: Fetches all pages of data. If no initial page is detected, it will first call `fetch` to fetch the first page of data. Will continue to fetch all pages until a `PageInfo` object indicates that there are no more pages to fetch. This function is compatible with forward, reverse, and bidirectional pagination. Provides a completion handler that allows the caller to be notified when the operation is complete, with an optional `Error?` parameter that contains any usage errors that may have occurred. + +The `AsyncGraphQLQueryPager` class provides the same methods as `async` functions, but without completion handlers, as they are not needed in an asynchronous context. + ## Cancelling ongoing requests The `GraphQLQueryPager` class provides a `reset` method, which can be used to cancel all in-flight fetch operations and stop watching for changes to cached data. This does not cancel subscriber's to the pager. Once the pager's state is reset, you can call `fetch` to being receiving updates again and existing subscribers will continue to receive updates.