Skip to content

Commit deee62d

Browse files
committed
merge
2 parents 09fdd79 + 11ac6d0 commit deee62d

File tree

8 files changed

+197
-14
lines changed

8 files changed

+197
-14
lines changed

package.json

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@
55
"files": [
66
"lib",
77
"mjs",
8-
"README.md"
8+
"README.md",
9+
"types"
910
],
1011
"main": "lib/index.js",
1112
"module": "mjs/index.mjs",
13+
"types": "types/index.d.ts",
1214
"repository": {
1315
"type": "git",
1416
"url": "https://github.com/graphql-compose/graphql-compose-pagination.git"
@@ -36,6 +38,7 @@
3638
"@babel/plugin-transform-runtime": "^7.4.3",
3739
"@babel/preset-env": "^7.4.3",
3840
"@babel/preset-flow": "^7.0.0",
41+
"@types/graphql": "^14.0.7",
3942
"babel-core": "^7.0.0-bridge.0",
4043
"babel-eslint": "^10.0.1",
4144
"babel-jest": "^24.7.1",
@@ -52,7 +55,9 @@
5255
"jest": "^24.7.1",
5356
"prettier": "^1.16.4",
5457
"rimraf": "^2.6.3",
55-
"semantic-release": "^15.13.3"
58+
"semantic-release": "^15.13.3",
59+
"tslint": "^5.14.0",
60+
"typescript": "^3.3.4000"
5661
},
5762
"config": {
5863
"commitizen": {
@@ -73,8 +78,10 @@
7378
"watch": "jest --watch",
7479
"coverage": "jest --coverage",
7580
"lint": "eslint --ext .js ./src",
81+
"tslint": "tslint -p . \"types/**/*.d.ts\"",
82+
"check-ts": "tsc",
7683
"flow": "./node_modules/.bin/flow",
77-
"test": "npm run coverage && npm run lint && npm run flow",
84+
"test": "npm run coverage && npm run lint && npm run flow && npm run check-ts",
7885
"link": "yarn build && yarn link graphql-compose && yarn link",
7986
"unlink": "rimraf node_modules && yarn install",
8087
"semantic-release": "semantic-release"

tsconfig.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"compilerOptions": {
3+
"target": "es5",
4+
"module": "commonjs",
5+
"strict": true,
6+
"lib": [
7+
"es2017",
8+
"esnext.asynciterable"
9+
]
10+
},
11+
"include": [
12+
"types/**/*.d.ts"
13+
],
14+
"exclude": [
15+
"./node_modules"
16+
]
17+
}

tslint.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"defaultSeverity": "error",
3+
"extends": [
4+
"tslint:recommended"
5+
],
6+
"jsRules": {},
7+
"rules": {
8+
"quotemark": [true, "single"],
9+
"trailing-comma": [false],
10+
"ordered-imports": false,
11+
"member-ordering": [true, { "order": "fields-first" }],
12+
"variable-name": false,
13+
"interface-name": ["never-prefix"],
14+
"no-reference-import": false
15+
},
16+
"rulesDirectory": []
17+
}

types/composeWithPagination.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { ObjectTypeComposer } from 'graphql-compose';
2+
import { ComposeWithPaginationOpts } from './paginationResolver';
3+
export declare function composeWithPagination<TSource, TContext>(typeComposer: ObjectTypeComposer<TSource, TContext>, opts: ComposeWithPaginationOpts): ObjectTypeComposer<TSource, TContext>;

types/index.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { composeWithPagination } from './composeWithPagination';
2+
import { preparePaginationResolver } from './paginationResolver';
3+
export default composeWithPagination;
4+
export { composeWithPagination, preparePaginationResolver };
5+
export { ComposeWithPaginationOpts } from './paginationResolver';

types/paginationResolver.d.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import { ProjectionType, Resolver, ObjectTypeComposer } from 'graphql-compose';
2+
import { GraphQLResolveInfo } from 'graphql-compose/lib/graphql';
3+
export declare const DEFAULT_RESOLVER_NAME = "pagination";
4+
export declare const DEFAULT_PER_PAGE = 20;
5+
export interface ComposeWithPaginationOpts {
6+
paginationResolverName?: string;
7+
findResolverName: string;
8+
countResolverName: string;
9+
perPage?: number;
10+
}
11+
export interface PaginationResolveParams<TContext> {
12+
source: any;
13+
args: {
14+
page?: number;
15+
perPage?: number;
16+
sort?: any;
17+
filter?: {
18+
[fieldName: string]: any;
19+
};
20+
[argName: string]: any;
21+
};
22+
context: TContext;
23+
info: GraphQLResolveInfo;
24+
projection: ProjectionType;
25+
[opt: string]: any;
26+
}
27+
export interface PaginationType {
28+
count: number;
29+
items: any[];
30+
pageInfo: PaginationInfoType;
31+
}
32+
export interface PaginationInfoType {
33+
currentPage: number;
34+
perPage: number;
35+
itemCount: number;
36+
pageCount: number;
37+
hasPreviousPage: boolean;
38+
hasNextPage: boolean;
39+
}
40+
export declare function preparePaginationResolver<TSource, TContext>(tc: ObjectTypeComposer<TSource, TContext>, opts: ComposeWithPaginationOpts): Resolver<TSource, TContext>;

types/preparePaginationType.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { SchemaComposer, ObjectTypeComposer } from 'graphql-compose';
2+
export declare function preparePaginationInfoTC<TContext>(schemaComposer: SchemaComposer<TContext>): ObjectTypeComposer<any, TContext>;
3+
export declare function preparePaginationTC<TSource, TContext>(tc: ObjectTypeComposer<TSource, TContext>, resolverName?: string): ObjectTypeComposer<TSource, TContext>;

yarn.lock

Lines changed: 102 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1163,6 +1163,11 @@
11631163
"@types/minimatch" "*"
11641164
"@types/node" "*"
11651165

1166+
"@types/graphql@^14.0.7":
1167+
version "14.0.7"
1168+
resolved "https://registry.yarnpkg.com/@types/graphql/-/graphql-14.0.7.tgz#daa09397220a68ce1cbb3f76a315ff3cd92312f6"
1169+
integrity sha512-BoLDjdvLQsXPZLJux3lEZANwGr3Xag56Ngy0U3y8uoRSDdeLcn43H3oBcgZlnd++iOQElBpaRVDHPzEDekyvXQ==
1170+
11661171
"@types/istanbul-lib-coverage@^2.0.0":
11671172
version "2.0.0"
11681173
resolved "https://registry.yarnpkg.com/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.0.tgz#1eb8c033e98cf4e1a4cedcaf8bcafe8cb7591e85"
@@ -1330,6 +1335,11 @@ ansi-regex@^4.0.0, ansi-regex@^4.1.0:
13301335
resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-4.1.0.tgz#8b9f8f08cf1acb843756a839ca8c7e3168c51997"
13311336
integrity sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==
13321337

1338+
ansi-styles@^2.2.1:
1339+
version "2.2.1"
1340+
resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-2.2.1.tgz#b432dd3358b634cf75e1e4664368240533c1ddbe"
1341+
integrity sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=
1342+
13331343
ansi-styles@^3.1.0, ansi-styles@^3.2.0:
13341344
version "3.2.0"
13351345
resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-3.2.0.tgz#c159b8d5be0f9e5a6f346dab94f16ce022161b88"
@@ -1501,6 +1511,15 @@ aws4@^1.8.0:
15011511
version "1.8.0"
15021512
resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.8.0.tgz#f0e003d9ca9e7f59c7a508945d7b2ef9a04a542f"
15031513

1514+
babel-code-frame@^6.22.0:
1515+
version "6.26.0"
1516+
resolved "https://registry.yarnpkg.com/babel-code-frame/-/babel-code-frame-6.26.0.tgz#63fd43f7dc1e3bb7ce35947db8fe369a3f58c74b"
1517+
integrity sha1-Y/1D99weO7fONZR9uP42mj9Yx0s=
1518+
dependencies:
1519+
chalk "^1.1.3"
1520+
esutils "^2.0.2"
1521+
js-tokens "^3.0.2"
1522+
15041523
babel-core@^7.0.0-bridge.0:
15051524
version "7.0.0-bridge.0"
15061525
resolved "https://registry.yarnpkg.com/babel-core/-/babel-core-7.0.0-bridge.0.tgz#95a492ddd90f9b4e9a4a1da14eb335b87b634ece"
@@ -1711,7 +1730,7 @@ buffer-from@^1.0.0:
17111730
version "1.1.0"
17121731
resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.0.tgz#87fcaa3a298358e0ade6e442cfce840740d1ad04"
17131732

1714-
builtin-modules@^1.0.0:
1733+
builtin-modules@^1.0.0, builtin-modules@^1.1.1:
17151734
version "1.1.1"
17161735
resolved "https://registry.yarnpkg.com/builtin-modules/-/builtin-modules-1.1.1.tgz#270f076c5a72c02f5b65a47df94c5fe3a278892f"
17171736

@@ -1847,6 +1866,17 @@ center-align@^0.1.1:
18471866
align-text "^0.1.3"
18481867
lazy-cache "^1.0.3"
18491868

1869+
chalk@^1.1.3:
1870+
version "1.1.3"
1871+
resolved "https://registry.yarnpkg.com/chalk/-/chalk-1.1.3.tgz#a8115c55e4a702fe4d150abd3872822a7e09fc98"
1872+
integrity sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=
1873+
dependencies:
1874+
ansi-styles "^2.2.1"
1875+
escape-string-regexp "^1.0.2"
1876+
has-ansi "^2.0.0"
1877+
strip-ansi "^3.0.0"
1878+
supports-color "^2.0.0"
1879+
18501880
chalk@^2.0.0, chalk@^2.0.1, chalk@^2.1.0:
18511881
version "2.2.0"
18521882
resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.2.0.tgz#477b3bf2f9b8fd5ca9e429747e37f724ee7af240"
@@ -1855,18 +1885,18 @@ chalk@^2.0.0, chalk@^2.0.1, chalk@^2.1.0:
18551885
escape-string-regexp "^1.0.5"
18561886
supports-color "^4.0.0"
18571887

1858-
chalk@^2.3.2:
1859-
version "2.4.1"
1860-
resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.1.tgz#18c49ab16a037b6eb0152cc83e3471338215b66e"
1888+
chalk@^2.3.0, chalk@^2.4.1, chalk@^2.4.2:
1889+
version "2.4.2"
1890+
resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424"
1891+
integrity sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==
18611892
dependencies:
18621893
ansi-styles "^3.2.1"
18631894
escape-string-regexp "^1.0.5"
18641895
supports-color "^5.3.0"
18651896

1866-
chalk@^2.4.1, chalk@^2.4.2:
1867-
version "2.4.2"
1868-
resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424"
1869-
integrity sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==
1897+
chalk@^2.3.2:
1898+
version "2.4.1"
1899+
resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.1.tgz#18c49ab16a037b6eb0152cc83e3471338215b66e"
18701900
dependencies:
18711901
ansi-styles "^3.2.1"
18721902
escape-string-regexp "^1.0.5"
@@ -2053,6 +2083,11 @@ combined-stream@^1.0.5, combined-stream@~1.0.5:
20532083
dependencies:
20542084
delayed-stream "~1.0.0"
20552085

2086+
commander@^2.12.1:
2087+
version "2.19.0"
2088+
resolved "https://registry.yarnpkg.com/commander/-/commander-2.19.0.tgz#f6198aa84e5b83c46054b94ddedbfed5ee9ff12a"
2089+
integrity sha512-6tvAOO+D6OENvRAh524Dh9jcfKTYDQAqvqezbCW82xj5X0pSrcpxtvRKHLG0yBY6SD7PSDrJaj+0AiOcKVd1Xg==
2090+
20562091
commander@^2.8.1, commander@~2.17.1:
20572092
version "2.17.1"
20582093
resolved "https://registry.yarnpkg.com/commander/-/commander-2.17.1.tgz#bd77ab7de6de94205ceacc72f1716d29f20a77bf"
@@ -2432,6 +2467,11 @@ diff-sequences@^24.3.0:
24322467
resolved "https://registry.yarnpkg.com/diff-sequences/-/diff-sequences-24.3.0.tgz#0f20e8a1df1abddaf4d9c226680952e64118b975"
24332468
integrity sha512-xLqpez+Zj9GKSnPWS0WZw1igGocZ+uua8+y+5dDNTT934N3QuY1sp2LkHzwiaYQGz60hMq0pjAshdeXm5VUOEw==
24342469

2470+
diff@^3.2.0:
2471+
version "3.5.0"
2472+
resolved "https://registry.yarnpkg.com/diff/-/diff-3.5.0.tgz#800c0dd1e0a8bfbc95835c202ad220fe317e5a12"
2473+
integrity sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==
2474+
24352475
dir-glob@^2.0.0:
24362476
version "2.0.0"
24372477
resolved "https://registry.yarnpkg.com/dir-glob/-/dir-glob-2.0.0.tgz#0b205d2b6aef98238ca286598a8204d29d0a0034"
@@ -2595,7 +2635,7 @@ es6-promisify@^5.0.0:
25952635
dependencies:
25962636
es6-promise "^4.0.3"
25972637

2598-
escape-string-regexp@^1.0.5:
2638+
escape-string-regexp@^1.0.2, escape-string-regexp@^1.0.5:
25992639
version "1.0.5"
26002640
resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4"
26012641

@@ -3352,6 +3392,13 @@ har-validator@~5.1.0:
33523392
ajv "^5.3.0"
33533393
har-schema "^2.0.0"
33543394

3395+
has-ansi@^2.0.0:
3396+
version "2.0.0"
3397+
resolved "https://registry.yarnpkg.com/has-ansi/-/has-ansi-2.0.0.tgz#34f5049ce1ecdf2b0649af3ef24e45ed35416d91"
3398+
integrity sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=
3399+
dependencies:
3400+
ansi-regex "^2.0.0"
3401+
33553402
has-flag@^2.0.0:
33563403
version "2.0.0"
33573404
resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-2.0.0.tgz#e8207af1cc7b30d446cc70b734b5e8be18f88d51"
@@ -4323,7 +4370,7 @@ js-levenshtein@^1.1.3:
43234370
version "1.1.3"
43244371
resolved "https://registry.yarnpkg.com/js-levenshtein/-/js-levenshtein-1.1.3.tgz#3ef627df48ec8cf24bacf05c0f184ff30ef413c5"
43254372

4326-
js-tokens@^3.0.0:
4373+
js-tokens@^3.0.0, js-tokens@^3.0.2:
43274374
version "3.0.2"
43284375
resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.2.tgz#9866df395102130e38f7f996bceb65443209c25b"
43294376

@@ -4346,6 +4393,14 @@ js-yaml@^3.13.0:
43464393
argparse "^1.0.7"
43474394
esprima "^4.0.0"
43484395

4396+
js-yaml@^3.7.0:
4397+
version "3.13.0"
4398+
resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.13.0.tgz#38ee7178ac0eea2c97ff6d96fff4b18c7d8cf98e"
4399+
integrity sha512-pZZoSxcCYco+DIKBTimr67J6Hy+EYGZDY/HCWC+iAEA9h1ByhMXAIVUXMcMFpOCxQ/xjXmPI2MkDL5HRm5eFrQ==
4400+
dependencies:
4401+
argparse "^1.0.7"
4402+
esprima "^4.0.0"
4403+
43494404
js-yaml@^3.9.0:
43504405
version "3.10.0"
43514406
resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.10.0.tgz#2e78441646bd4682e963f22b6e92823c309c62dc"
@@ -6985,6 +7040,11 @@ strip-json-comments@^2.0.1, strip-json-comments@~2.0.1:
69857040
version "2.0.1"
69867041
resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a"
69877042

7043+
supports-color@^2.0.0:
7044+
version "2.0.0"
7045+
resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-2.0.0.tgz#535d045ce6b6363fa40117084629995e9df324c7"
7046+
integrity sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=
7047+
69887048
supports-color@^4.0.0:
69897049
version "4.5.0"
69907050
resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-4.5.0.tgz#be7a0de484dec5c5cddf8b3d59125044912f635b"
@@ -7177,10 +7237,36 @@ trim-right@^1.0.1:
71777237
version "1.0.1"
71787238
resolved "https://registry.yarnpkg.com/trim-right/-/trim-right-1.0.1.tgz#cb2e1203067e0c8de1f614094b9fe45704ea6003"
71797239

7180-
tslib@^1.9.0:
7240+
tslib@^1.8.0, tslib@^1.8.1, tslib@^1.9.0:
71817241
version "1.9.3"
71827242
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.9.3.tgz#d7e4dd79245d85428c4d7e4822a79917954ca286"
71837243

7244+
tslint@^5.14.0:
7245+
version "5.14.0"
7246+
resolved "https://registry.yarnpkg.com/tslint/-/tslint-5.14.0.tgz#be62637135ac244fc9b37ed6ea5252c9eba1616e"
7247+
integrity sha512-IUla/ieHVnB8Le7LdQFRGlVJid2T/gaJe5VkjzRVSRR6pA2ODYrnfR1hmxi+5+au9l50jBwpbBL34txgv4NnTQ==
7248+
dependencies:
7249+
babel-code-frame "^6.22.0"
7250+
builtin-modules "^1.1.1"
7251+
chalk "^2.3.0"
7252+
commander "^2.12.1"
7253+
diff "^3.2.0"
7254+
glob "^7.1.1"
7255+
js-yaml "^3.7.0"
7256+
minimatch "^3.0.4"
7257+
mkdirp "^0.5.1"
7258+
resolve "^1.3.2"
7259+
semver "^5.3.0"
7260+
tslib "^1.8.0"
7261+
tsutils "^2.29.0"
7262+
7263+
tsutils@^2.29.0:
7264+
version "2.29.0"
7265+
resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-2.29.0.tgz#32b488501467acbedd4b85498673a0812aca0b99"
7266+
integrity sha512-g5JVHCIJwzfISaXpXE1qvNalca5Jwob6FjI4AoPlqMusJ6ftFE7IkkFoMhVLRgK+4Kx3gkzb8UZK5t5yTTvEmA==
7267+
dependencies:
7268+
tslib "^1.8.1"
7269+
71847270
tunnel-agent@^0.6.0:
71857271
version "0.6.0"
71867272
resolved "https://registry.yarnpkg.com/tunnel-agent/-/tunnel-agent-0.6.0.tgz#27a5dea06b36b04a0a9966774b290868f0fc40fd"
@@ -7201,6 +7287,11 @@ typedarray@^0.0.6:
72017287
version "0.0.6"
72027288
resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"
72037289

7290+
typescript@^3.3.4000:
7291+
version "3.3.4000"
7292+
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.3.4000.tgz#76b0f89cfdbf97827e1112d64f283f1151d6adf0"
7293+
integrity sha512-jjOcCZvpkl2+z7JFn0yBOoLQyLoIkNZAs/fYJkUG6VKy6zLPHJGfQJYFHzibB6GJaF/8QrcECtlQ5cpvRHSMEA==
7294+
72047295
uglify-js@^2.6:
72057296
version "2.8.29"
72067297
resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-2.8.29.tgz#29c5733148057bb4e1f75df35b7a9cb72e6a59dd"

0 commit comments

Comments
 (0)