Skip to content

Commit e71aa6f

Browse files
committed
fixes
1 parent 11d26b8 commit e71aa6f

File tree

9 files changed

+544
-27
lines changed

9 files changed

+544
-27
lines changed

README.md

+520-13
Large diffs are not rendered by default.

resources/gitpublish.sh

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ node -e "var package = require('./package.json'); \
1919
cp README.md npm/
2020
cp LICENSE npm/
2121
cp -r docs npm/
22+
cp src/schema/requiredTypes.graphql npm/schema/
2223
cp src/schema/requiredTypes.conf npm/schema/
2324

2425
cd npm

src/__tests__/end-to-end/testing.md

-8
This file was deleted.

src/__tests__/end-to-end/index-test-cases.js renamed to src/index-test-cases.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { describe, before, it, Test } from 'mocha';
55
import { expect } from 'chai';
66

77
// dynamically define the test cases based on our test case registry
8-
const suite = describe('end-to-end test', () => {
8+
export const suite = describe('end-to-end test', () => {
99
before(done => {
1010
testCases.forEach(testCase => {
1111
suite.addTest(

src/index.js

+4
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,7 @@ export { prepareQueries } from './model';
1717
// provides a string with required types
1818
// clones a given inputSchema and enhance it with query arguments
1919
export { buildRequiredTypes, enhanceSchemaWithQueryArguments } from './schema';
20+
21+
// to provide the testCases to be used in create-graphql-server
22+
export { testCases } from './test-cases';
23+
export { suite } from './index-test-cases';

src/model/buildBaseQuery.js

+18
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,23 @@ export function buildBaseQuery(args: any): any {
2424
query = merge(query, buildFilterQuery(args.filter));
2525
}
2626

27+
// for pagination
28+
// default
29+
let lastCreatedAt = 0;
30+
31+
// if there was sent a lastCreatedAt with the args, then use that instead
32+
if (
33+
args.lastCreatedAt &&
34+
(args.lastCreatedAt !== '' && typeof args.lastCreatedAt !== 'object')
35+
) {
36+
lastCreatedAt = args.lastCreatedAt;
37+
}
38+
39+
// check if the user entered a different filter criteria for "createdAt"
40+
// if so, take the one from the user, otherwise use the default for pagination
41+
if (!query['createdAt']) {
42+
query['createdAt'] = { $gt: lastCreatedAt };
43+
}
44+
2745
return query;
2846
}

src/model/buildFilterQuery.js

-5
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,6 @@ import isObject from 'lodash.isobject';
1010
export function buildFilterQuery(args: any): any {
1111
const query = {};
1212

13-
// on no argument return empty query
14-
// if (!args) {
15-
// return query;
16-
// }
17-
1813
// on primitive types, just return the data as leaf values in the recursion
1914
switch (typeof args) {
2015
case 'boolean':
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)