ConnectionProtocol
public protocol ConnectionProtocol : ConcreteResolvable, OutputResolvable
ConnectionProtocol
Describes an Object used for Cursor-Based Pagination. This API is modeled after standards set by Relay and GraphQL.
It relies on the usage of the arguments: first
, after
, last
and before
.
first
: Number of items that will be fetched at the start of the listafter
: Cursor of the last element in the page that comes before. Signals that all items in the requested page should be strictly after the element with that cursor. The element with the cursor should be excludedlast
: Number of items that will be fetched at the end of the listbefore
: Cursor of the first element in the page that comes after. Signals that all items in the requested page should be strictly before the element with that cursor. The element with the cursor should be excluded
Note
This is a bare bones implementation of Paging, and is not particularly efficient.
If you notice that your methods are all sharing a lot of logic together, perhaps you should take a look at ContextBasedConnection
insttead.
-
Type of Item in the List. Has to conform to
OutputResolvable
Declaration
Swift
associatedtype Node where Self.Node == Self.Edge.Node
-
Type of Edges in the List. Edges may contain additional information.
If no edge type is provided, it will default to the Standard Implementation.
Declaration
Swift
associatedtype Edge : EdgeProtocol = StandardEdge<Self.Node>
-
Computes the number of items in the list.
Declaration
Swift
func totalCount() -> EventLoopFuture<Int>
Return Value
A future with the computed count.
-
Computes information about the current page. This Information includes the start and end cursor and whether or not there’s adjacent pages.
Declaration
Swift
func pageInfo(first: Int?, after: String?, last: Int?, before: String?, eventLoop: EventLoopGroup) -> EventLoopFuture<PageInfo>
Parameters
first
Number of items that will be fetched at the start of the list
after
Cursor of the last element in the page that comes before. Signals that all items in the requested page should be strictly after the element with that cursor. The element with the cursor should be excluded
last
Number of items that will be fetched at the end of the list
before
Cursor of the first element in the page that comes after. Signals that all items in the requested page should be strictly before the element with that cursor. The element with the cursor should be excluded
eventLoop
Event Loop Group that can be used to create the futures
Return Value
A future with the computed Page Info
-
Computes the edges for the current page
Declaration
Swift
func edges(first: Int?, after: String?, last: Int?, before: String?, eventLoop: EventLoopGroup) -> EventLoopFuture<[Edge?]?>
Parameters
first
Number of items that will be fetched at the start of the list
after
Cursor of the last element in the page that comes before. Signals that all items in the requested page should be strictly after the element with that cursor. The element with the cursor should be excluded
last
Number of items that will be fetched at the end of the list
before
Cursor of the first element in the page that comes after. Signals that all items in the requested page should be strictly before the element with that cursor. The element with the cursor should be excluded
eventLoop
Event Loop Group that can be used to create the futures
Return Value
A future with an array of edges.
-
concreteTypeName
Extension methodDeclaration
Swift
public static var concreteTypeName: String { get }
-
additionalArguments
Extension methodWarning
default implementation fromGraphZahl
. Do not override unless you know exactly what you are doing.Declaration
Swift
public static var additionalArguments: [String : InputResolvable.Type] { get }
-
resolve(using:
Extension method) Warning
default implementation fromGraphZahl
. Do not override unless you know exactly what you are doing.Declaration
Swift
public static func resolve(using context: inout Resolution.Context) throws -> GraphQLOutputType
-
resolve(source:
Extension methodarguments: context: eventLoop: ) Warning
default implementation fromGraphZahl
. Do not override unless you know exactly what you are doing.Declaration
Swift
public func resolve(source: Any, arguments: [String : Map], context: MutableContext, eventLoop: EventLoopGroup) throws -> EventLoopFuture<Any?>