Skip to content

Commit

Permalink
Merge pull request #40 from NicholasBellucci/updates/cursor-pagination
Browse files Browse the repository at this point in the history
Updates/cursor pagination
  • Loading branch information
NicholasBellucci authored Sep 9, 2020
2 parents 07841b6 + f086ba8 commit 37041b2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -552,8 +552,8 @@ Weave(.query) {
```graphql
{
comments(first: 2) {
cursor
edges {
cursor
node {
id
author
Expand Down Expand Up @@ -589,8 +589,8 @@ Weave(.query) {
```graphql
{
comments(first: 2) {
cursor
edges {
cursor
node {
id
author
Expand Down
4 changes: 2 additions & 2 deletions Sources/SociableWeaver/Extensions/String+Utils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ extension String {
*/
func withSubfields(_ fields: String, paginationType: PaginationType? = nil, pageInfo: PageInfoModel? = nil) -> String {
if let pageInfo = pageInfo, paginationType == .cursor {
return "\(self) { cursor edges { node { \(fields) } } \(String(describing: pageInfo.type)) { \(pageInfo.keys.joined(separator: " ")) } }"
return "\(self) { edges { cursor node { \(fields) } } \(String(describing: pageInfo.type)) { \(pageInfo.keys.joined(separator: " ")) } }"
} else if paginationType == .cursor {
return "\(self) { cursor edges { node { \(fields) } } }"
return "\(self) { edges { cursor node { \(fields) } } }"
} else {
return "\(self) { \(fields) }"
}
Expand Down
6 changes: 3 additions & 3 deletions Tests/SociableWeaverTests/SociableWeaverBuilderTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ final class SociableWeaverBuilderTests: XCTestCase {
.paginationType(.cursor)
}

let expected = "query { comments(first: 2) { cursor edges { node { id author content } } } }"
let expected = "query { comments(first: 2) { edges { cursor node { id author content } } } }"
XCTAssertEqual(String(describing: query), expected)
}

Expand Down Expand Up @@ -212,7 +212,7 @@ final class SociableWeaverBuilderTests: XCTestCase {
PageInfo.CodingKeys.hasNextPage)
}

let expected = "query { comments(first: 2) { cursor edges { node { id author content } } pageInfo { startCursor endCursor hasNextPage } } }"
let expected = "query { comments(first: 2) { edges { cursor node { id author content } } pageInfo { startCursor endCursor hasNextPage } } }"
XCTAssertEqual(String(describing: query), expected)
}

Expand All @@ -231,7 +231,7 @@ final class SociableWeaverBuilderTests: XCTestCase {
"hasNextPage")
}

let expected = "query { comments(first: 2) { cursor edges { node { id author content } } pageInfo { startCursor endCursor hasNextPage } } }"
let expected = "query { comments(first: 2) { edges { cursor node { id author content } } pageInfo { startCursor endCursor hasNextPage } } }"
XCTAssertEqual(String(describing: query), expected)
}

Expand Down

0 comments on commit 37041b2

Please sign in to comment.