Skip to content

Commit

Permalink
refactor: migrate codebase on typescript (#59)
Browse files Browse the repository at this point in the history
* refactor: migrate codebase on typescript

BREAKING CHANGE: removed flowtype definitions; min supported nodejs version is 8

* chore: update prettier
  • Loading branch information
nodkz authored Aug 17, 2020
1 parent 814dc28 commit abe1409
Show file tree
Hide file tree
Showing 55 changed files with 1,644 additions and 8,950 deletions.
46 changes: 0 additions & 46 deletions .babelrc

This file was deleted.

41 changes: 0 additions & 41 deletions .eslintrc

This file was deleted.

50 changes: 50 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
const path = require('path');

module.exports = {
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint', 'prettier'],
extends: [
'plugin:@typescript-eslint/recommended',
'prettier/@typescript-eslint',
'plugin:prettier/recommended',
],
parserOptions: {
sourceType: 'module',
useJSXTextNode: true,
project: [path.resolve(__dirname, 'tsconfig.json')],
},
rules: {
'no-underscore-dangle': 0,
'arrow-body-style': 0,
'no-unused-expressions': 0,
'no-plusplus': 0,
'no-console': 0,
'func-names': 0,
'comma-dangle': [
'error',
{
arrays: 'always-multiline',
objects: 'always-multiline',
imports: 'always-multiline',
exports: 'always-multiline',
functions: 'ignore',
},
],
'no-prototype-builtins': 0,
'prefer-destructuring': 0,
'no-else-return': 0,
'lines-between-class-members': ['error', 'always', { exceptAfterSingleLine: true }],
'@typescript-eslint/explicit-member-accessibility': 0,
'@typescript-eslint/no-explicit-any': 0,
'@typescript-eslint/no-inferrable-types': 0,
'@typescript-eslint/explicit-function-return-type': 0,
'@typescript-eslint/no-use-before-define': 0,
'@typescript-eslint/no-empty-function': 0,
'@typescript-eslint/camelcase': 0,
'@typescript-eslint/ban-ts-comment': 0,
},
env: {
jasmine: true,
jest: true,
},
};
48 changes: 0 additions & 48 deletions .flowconfig

This file was deleted.

8 changes: 3 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,10 @@ notifications:
node_js:
- "10"
- "12"
before_install: yarn global add greenkeeper-lockfile@1
before_script: greenkeeper-lockfile-update
after_script: greenkeeper-lockfile-upload
- "14"
script:
- yarn run test
- yarn run build
- yarn test
- yarn build
after_success:
- 'curl -Lo travis_after_all.py https://git.io/travis_after_all'
- python travis_after_all.py
Expand Down
1 change: 0 additions & 1 deletion AUTHORS

This file was deleted.

41 changes: 2 additions & 39 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,40 +1,3 @@
## master
## 0.0.0-semantically-released

## 0.0.0-semantically-released (September 12, 2016)
This package publishing automated by [semantic-release](https://github.com/semantic-release/semantic-release).
[Changelog](https://github.com/nodkz/graphql-compose/releases) is generated automatically and can be found here: https://github.com/nodkz/graphql-compose/releases

## 1.0.8 (September 6, 2016)
- Update dependencies
- Flowtype 0.32
- Fix code style issues

## 1.0.7 (August 15, 2016)
- fix: babel build via the workaround https://phabricator.babeljs.io/T2877#78089 Huh, it's too tricky to use Map/Set in ES5.

## 1.0.6 (August 13, 2016)
- fix: babel build process

## 1.0.5 (August 10, 2016)
- 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).

## 1.0.4 (August 9, 2016)
- Add `ofType` property to `Connection` and `Edge` types.
Connection type is some kind of wrapper under GraphQLNamedType.
This behavior needed for `graphql-compose` module in `projection` helper, otherwise, it incorrectly constructs projectionMapper for tricky fields.

## 1.0.3 (July 22, 2016)
- If `first` or `last` args not provided, then get first 20 records by default.

## 1.0.2 (July 20, 2016)
- fix: return non-empty PageInfo if records not found

## 1.0.1 (July 18, 2016)
* Add fallback to `sort` arg, due [unexpected behavior](https://github.com/graphql/graphql-js/issues/435#issuecomment-233297537) of defaultValue for enum field
* Move `graphql-compose` module to peerDependencies.

## 1.0.0 (July 15, 2016)
* Production ready version

## 0.0.1 (July 10, 2016)
* Initial commit
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
41 changes: 21 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,33 @@

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

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

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

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

Besides standard connection arguments `first`, `last`, `before` and `after`, also added significant arguments:
* `filter` arg - for filtering records
* `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).

- `filter` arg - for filtering records
- `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).

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

Installation
============
```
## Installation

```bash
npm install graphql graphql-compose graphql-compose-connection --save
```

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.

## Example

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

// Constructing `rawQuery` for connection `after` argument.
// ----- [record] ----- sorted dataset
// ^^^^^ `rawQuery` should filter this set
// ^^^^^ `rawQuery` should filter this set
afterCursorQuery: (rawQuery, cursorData, resolveParams) => {
if (!rawQuery._id) rawQuery._id = {};
rawQuery._id.$gt = cursorData._id;
Expand Down Expand Up @@ -105,19 +105,20 @@ composeWithConnection(userTC, {
},
});
```

<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">

Requirements
============
## Requirements

Types should have following resolvers:
* `count` - for counting records
* `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.

Used in plugins
===============
- `count` - for counting records
- `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.

## Used in plugins

[graphql-compose-mongoose](https://github.com/graphql-compose/graphql-compose-mongoose) - converts mongoose models to graphql types

## License

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

0 comments on commit abe1409

Please sign in to comment.