Skip to content

Commit abe1409

Browse files
authored
refactor: migrate codebase on typescript (#59)
* refactor: migrate codebase on typescript BREAKING CHANGE: removed flowtype definitions; min supported nodejs version is 8 * chore: update prettier
1 parent 814dc28 commit abe1409

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+1644
-8950
lines changed

.babelrc

Lines changed: 0 additions & 46 deletions
This file was deleted.

.eslintrc

Lines changed: 0 additions & 41 deletions
This file was deleted.

.eslintrc.js

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
const path = require('path');
2+
3+
module.exports = {
4+
parser: '@typescript-eslint/parser',
5+
plugins: ['@typescript-eslint', 'prettier'],
6+
extends: [
7+
'plugin:@typescript-eslint/recommended',
8+
'prettier/@typescript-eslint',
9+
'plugin:prettier/recommended',
10+
],
11+
parserOptions: {
12+
sourceType: 'module',
13+
useJSXTextNode: true,
14+
project: [path.resolve(__dirname, 'tsconfig.json')],
15+
},
16+
rules: {
17+
'no-underscore-dangle': 0,
18+
'arrow-body-style': 0,
19+
'no-unused-expressions': 0,
20+
'no-plusplus': 0,
21+
'no-console': 0,
22+
'func-names': 0,
23+
'comma-dangle': [
24+
'error',
25+
{
26+
arrays: 'always-multiline',
27+
objects: 'always-multiline',
28+
imports: 'always-multiline',
29+
exports: 'always-multiline',
30+
functions: 'ignore',
31+
},
32+
],
33+
'no-prototype-builtins': 0,
34+
'prefer-destructuring': 0,
35+
'no-else-return': 0,
36+
'lines-between-class-members': ['error', 'always', { exceptAfterSingleLine: true }],
37+
'@typescript-eslint/explicit-member-accessibility': 0,
38+
'@typescript-eslint/no-explicit-any': 0,
39+
'@typescript-eslint/no-inferrable-types': 0,
40+
'@typescript-eslint/explicit-function-return-type': 0,
41+
'@typescript-eslint/no-use-before-define': 0,
42+
'@typescript-eslint/no-empty-function': 0,
43+
'@typescript-eslint/camelcase': 0,
44+
'@typescript-eslint/ban-ts-comment': 0,
45+
},
46+
env: {
47+
jasmine: true,
48+
jest: true,
49+
},
50+
};

.flowconfig

Lines changed: 0 additions & 48 deletions
This file was deleted.

.travis.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,10 @@ notifications:
99
node_js:
1010
- "10"
1111
- "12"
12-
before_install: yarn global add greenkeeper-lockfile@1
13-
before_script: greenkeeper-lockfile-update
14-
after_script: greenkeeper-lockfile-upload
12+
- "14"
1513
script:
16-
- yarn run test
17-
- yarn run build
14+
- yarn test
15+
- yarn build
1816
after_success:
1917
- 'curl -Lo travis_after_all.py https://git.io/travis_after_all'
2018
- python travis_after_all.py

AUTHORS

Lines changed: 0 additions & 1 deletion
This file was deleted.

CHANGELOG.md

Lines changed: 2 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,3 @@
1-
## master
1+
## 0.0.0-semantically-released
22

3-
## 0.0.0-semantically-released (September 12, 2016)
4-
This package publishing automated by [semantic-release](https://github.com/semantic-release/semantic-release).
5-
[Changelog](https://github.com/nodkz/graphql-compose/releases) is generated automatically and can be found here: https://github.com/nodkz/graphql-compose/releases
6-
7-
## 1.0.8 (September 6, 2016)
8-
- Update dependencies
9-
- Flowtype 0.32
10-
- Fix code style issues
11-
12-
## 1.0.7 (August 15, 2016)
13-
- fix: babel build via the workaround https://phabricator.babeljs.io/T2877#78089 Huh, it's too tricky to use Map/Set in ES5.
14-
15-
## 1.0.6 (August 13, 2016)
16-
- fix: babel build process
17-
18-
## 1.0.5 (August 10, 2016)
19-
- Update packages, add `babel-plugin-transform-runtime` for build process. Fix [issue](https://github.com/nodkz/graphql-compose-connection/issues/2) for vanilla node.js users without babel (thanks @jacobbubu).
20-
21-
## 1.0.4 (August 9, 2016)
22-
- Add `ofType` property to `Connection` and `Edge` types.
23-
Connection type is some kind of wrapper under GraphQLNamedType.
24-
This behavior needed for `graphql-compose` module in `projection` helper, otherwise, it incorrectly constructs projectionMapper for tricky fields.
25-
26-
## 1.0.3 (July 22, 2016)
27-
- If `first` or `last` args not provided, then get first 20 records by default.
28-
29-
## 1.0.2 (July 20, 2016)
30-
- fix: return non-empty PageInfo if records not found
31-
32-
## 1.0.1 (July 18, 2016)
33-
* Add fallback to `sort` arg, due [unexpected behavior](https://github.com/graphql/graphql-js/issues/435#issuecomment-233297537) of defaultValue for enum field
34-
* Move `graphql-compose` module to peerDependencies.
35-
36-
## 1.0.0 (July 15, 2016)
37-
* Production ready version
38-
39-
## 0.0.1 (July 10, 2016)
40-
* Initial commit
3+
This package publishing automated by [semantic-release](https://github.com/semantic-release/semantic-release). Changelog is generated automatically and can be found here: https://github.com/graphql-compose/graphql-compose-connection/releases

README.md

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,33 @@
22

33
[![travis build](https://img.shields.io/travis/graphql-compose/graphql-compose-connection.svg)](https://travis-ci.org/graphql-compose/graphql-compose-connection)
44
[![codecov coverage](https://img.shields.io/codecov/c/github/graphql-compose/graphql-compose-connection.svg)](https://codecov.io/github/graphql-compose/graphql-compose-connection)
5-
[![](https://img.shields.io/npm/v/graphql-compose-connection.svg)](https://www.npmjs.com/package/graphql-compose-connection)
6-
[![npm](https://img.shields.io/npm/dt/graphql-compose-connection.svg)](http://www.npmtrends.com/graphql-compose-connection)
5+
[![version](https://img.shields.io/npm/v/graphql-compose-connection.svg)](https://www.npmjs.com/package/graphql-compose-connection)
6+
[![downloads](https://img.shields.io/npm/dt/graphql-compose-connection.svg)](http://www.npmtrends.com/graphql-compose-connection)
77
[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)
88

99
This is a plugin for [graphql-compose](https://github.com/graphql-compose/graphql-compose) family, which adds to the ObjectTypeComposer `connection` resolver.
1010

1111
Live demo: [https://graphql-compose.herokuapp.com/](https://graphql-compose.herokuapp.com/)
1212

13-
This package completely follows to Relay Cursor Connections Specification (https://facebook.github.io/relay/graphql/connections.htm).
13+
This package completely follows to Relay Cursor Connections Specification (<https://relay.dev/graphql/connections.htm>).
1414

1515
Besides standard connection arguments `first`, `last`, `before` and `after`, also added significant arguments:
16-
* `filter` arg - for filtering records
17-
* `sort` arg - for sorting records. Build in mechanism allows sort by any unique indexes (not only by id). Also supported compound sorting (by several fields).
16+
17+
- `filter` arg - for filtering records
18+
- `sort` arg - for sorting records. Build in mechanism allows sort by any unique indexes (not only by id). Also supported compound sorting (by several fields).
1819

1920
[CHANGELOG](https://github.com/graphql-compose/graphql-compose-connection/blob/master/CHANGELOG.md)
2021

21-
Installation
22-
============
23-
```
22+
## Installation
23+
24+
```bash
2425
npm install graphql graphql-compose graphql-compose-connection --save
2526
```
2627

2728
Modules `graphql` and `graphql-compose` are in `peerDependencies`, so should be installed explicitly in your app. They should not installed as submodules, cause internally checks the classes instances.
2829

30+
## Example
2931

30-
Example
31-
=======
3232
```js
3333
import composeWithConnection from 'graphql-compose-connection';
3434
import userTC from './user.js';
@@ -56,15 +56,15 @@ composeWithConnection(userTC, {
5656
// Unpacked data from `cursor` will be available in (`cursorData`) argument.
5757
// PS. All other filter options provided via GraphQL query will be added automatically.
5858
// ----- [record] ----- sorted dataset, according to above option with `value` name
59-
// ^^^^^ `rawQuery` should filter this set
59+
// ^^^^^ `rawQuery` should filter this set
6060
beforeCursorQuery: (rawQuery, cursorData, resolveParams) => {
6161
if (!rawQuery._id) rawQuery._id = {};
6262
rawQuery._id.$lt = cursorData._id;
6363
},
6464

6565
// Constructing `rawQuery` for connection `after` argument.
6666
// ----- [record] ----- sorted dataset
67-
// ^^^^^ `rawQuery` should filter this set
67+
// ^^^^^ `rawQuery` should filter this set
6868
afterCursorQuery: (rawQuery, cursorData, resolveParams) => {
6969
if (!rawQuery._id) rawQuery._id = {};
7070
rawQuery._id.$gt = cursorData._id;
@@ -105,19 +105,20 @@ composeWithConnection(userTC, {
105105
},
106106
});
107107
```
108+
108109
<img width="1249" alt="screen shot 2016-07-20 at 12 20 08" src="https://cloud.githubusercontent.com/assets/1946920/16976899/67a5e0f8-4e74-11e6-87e5-fc4574deaaab.png">
109110

110-
Requirements
111-
============
111+
## Requirements
112+
112113
Types should have following resolvers:
113-
* `count` - for counting records
114-
* `findMany` - for filtering records. Also required that this resolver supports search with operators (lt, gt), which used in `directionFilter` option. Resolver `findMany` should have `filter` argument, which will be copied to connection. Also should have `limit` and `skip` args.
115114

116-
Used in plugins
117-
===============
115+
- `count` - for counting records
116+
- `findMany` - for filtering records. Also required that this resolver supports search with operators (lt, gt), which used in `directionFilter` option. Resolver `findMany` should have `filter` argument, which will be copied to connection. Also should have `limit` and `skip` args.
117+
118+
## Used in plugins
119+
118120
[graphql-compose-mongoose](https://github.com/graphql-compose/graphql-compose-mongoose) - converts mongoose models to graphql types
119121

122+
## License
120123

121-
License
122-
=======
123124
[MIT](https://github.com/graphql-compose/graphql-compose-connection/blob/master/LICENSE.md)

0 commit comments

Comments
 (0)