Skip to content

Commit 75adf20

Browse files
committed
Apply incidental style tweaks
I kept these separate from the parent commit for clarity: - Prefer trailing commas everywhere. - Sort exported types alphabetically within groups. - Use object short notation. - Prefer idiomatic `== null` check over explicit `=== null` and `=== undefined. - (Subjective) use a ternary in one place where it doesn't harm readability.
1 parent 238d724 commit 75adf20

File tree

2 files changed

+9
-13
lines changed

2 files changed

+9
-13
lines changed

src/connection/arrayconnection.js

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111
import type {
1212
Connection,
1313
ConnectionArguments,
14-
ConnectionCursor
14+
ConnectionCursor,
1515
} from './connectiontypes';
1616

1717
import {
1818
base64,
19-
unbase64
19+
unbase64,
2020
} from '../utils/base64.js';
2121

2222
type ArraySliceMetaInfo = {
@@ -116,7 +116,7 @@ export function connectionFromArraySlice<T>(
116116
const lowerBound = after ? (afterOffset + 1) : 0;
117117
const upperBound = before ? beforeOffset : arrayLength;
118118
return {
119-
edges: [],
119+
edges,
120120
pageInfo: {
121121
startCursor: firstEdge ? firstEdge.cursor : null,
122122
endCursor: lastEdge ? lastEdge.cursor : null,
@@ -176,13 +176,9 @@ export function cursorForObjectInConnection<T>(
176176
* otherwise it will be the default.
177177
*/
178178
function getOffset(cursor?: ?ConnectionCursor, defaultOffset: number): number {
179-
if (cursor === undefined || cursor === null) {
179+
if (cursor == null) {
180180
return defaultOffset;
181181
}
182182
var offset = cursorToOffset(cursor);
183-
if (isNaN(offset)) {
184-
return defaultOffset;
185-
}
186-
return offset;
183+
return isNaN(offset) ? defaultOffset : offset;
187184
}
188-

src/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
// Helpers for creating connection types in the schema
1111
export {
1212
connectionArgs,
13-
connectionDefinitions
13+
connectionDefinitions,
1414
} from './connection/connection.js';
1515

1616
// Helpers for creating connections from arrays
@@ -23,17 +23,17 @@ export {
2323

2424
// Helper for creating mutations with client mutation IDs
2525
export {
26-
mutationWithClientMutationId
26+
mutationWithClientMutationId,
2727
} from './mutation/mutation.js';
2828

2929
// Helper for creating node definitions
3030
export {
31-
nodeDefinitions
31+
nodeDefinitions,
3232
} from './node/node.js';
3333

3434
// Utilities for creating global IDs in systems that don't have them.
3535
export {
3636
fromGlobalId,
37+
globalIdField,
3738
toGlobalId,
38-
globalIdField
3939
} from './node/node.js';

0 commit comments

Comments
 (0)