Skip to content

Commit 541dcd7

Browse files
committed
refactor: migrate codebase from Flow to Typescript
BREAKING CHANGE: remove mjs build, Flow definitions
1 parent 38599c8 commit 541dcd7

File tree

180 files changed

+3151
-14338
lines changed

Some content is hidden

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

180 files changed

+3151
-14338
lines changed

.babelrc

-61
This file was deleted.

.eslintrc

-41
This file was deleted.

.eslintrc.js

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

.flowconfig

-49
This file was deleted.

.github/FUNDING.yml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# These are supported funding model platforms
2+
3+
github: [nodkz]
4+
patreon: # Replace with a single Patreon username
5+
open_collective: graphql-compose
6+
ko_fi: # Replace with a single Ko-fi username
7+
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8+
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9+
liberapay: # Replace with a single Liberapay username
10+
issuehunt: # Replace with a single IssueHunt username
11+
otechie: # Replace with a single Otechie username
12+
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']

.github/workflows/nodejs.yml

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
3+
4+
name: Node.js CI
5+
6+
on: [push, pull_request]
7+
8+
jobs:
9+
tests:
10+
runs-on: ubuntu-latest
11+
strategy:
12+
matrix:
13+
node-version: [12.x, 14.x, 16.x]
14+
steps:
15+
- uses: actions/checkout@v2
16+
- name: Use Node.js ${{ matrix.node-version }}
17+
uses: actions/setup-node@v1
18+
with:
19+
node-version: ${{ matrix.node-version }}
20+
- name: Install node_modules
21+
run: yarn
22+
- name: Test & lint
23+
run: yarn test
24+
env:
25+
CI: true
26+
- name: Send codecov.io stats
27+
if: matrix.node-version == '12.x'
28+
run: bash <(curl -s https://codecov.io/bash) || echo ''
29+
30+
publish:
31+
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/alpha' || github.ref == 'refs/heads/beta'
32+
needs: [tests]
33+
runs-on: ubuntu-latest
34+
steps:
35+
- uses: actions/checkout@v2
36+
- name: Use Node.js 12
37+
uses: actions/setup-node@v1
38+
with:
39+
node-version: 12.x
40+
- name: Install node_modules
41+
run: yarn install
42+
- name: Build
43+
run: yarn build
44+
- name: Semantic Release (publish to npm)
45+
run: yarn semantic-release
46+
env:
47+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
48+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
49+

README.md

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
[![npm](https://img.shields.io/npm/v/graphql-compose-elasticsearch.svg)](https://www.npmjs.com/package/graphql-compose-elasticsearch)
44
[![trends](https://img.shields.io/npm/dt/graphql-compose-elasticsearch.svg)](http://www.npmtrends.com/graphql-compose-elasticsearch)
5-
[![Travis](https://img.shields.io/travis/graphql-compose/graphql-compose-elasticsearch.svg?maxAge=2592000)](https://travis-ci.org/graphql-compose/graphql-compose-elasticsearch)
65
[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)
76
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
87

examples/differentVersions/index.js examples/differentVersions/index.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,21 @@ const generatedSchema = new GraphQLSchema({
1111
query: new GraphQLObjectType({
1212
name: 'Query',
1313
fields: {
14-
elastic50: elasticApiFieldConfig({
14+
elastic56: elasticApiFieldConfig({
1515
host: 'http://user:pass@localhost:9200',
16-
apiVersion: '5.0',
16+
apiVersion: '5.6',
1717
// log: 'trace',
1818
}),
1919

20-
elastic24: elasticApiFieldConfig({
20+
elastic68: elasticApiFieldConfig({
2121
host: 'http://user:pass@localhost:9200',
22-
apiVersion: '2.4',
22+
apiVersion: '6.8',
2323
// log: 'trace',
2424
}),
2525

26-
elastic17: elasticApiFieldConfig({
26+
elastic77: elasticApiFieldConfig({
2727
host: 'http://user:pass@localhost:9200',
28-
apiVersion: '1.7',
28+
apiVersion: '7.7',
2929
// log: 'trace',
3030
}),
3131
},

examples/elastic50/index.js examples/elastic56/index.ts

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* @flow */
21
/* eslint-disable no-console */
32

43
import express from 'express';
@@ -10,14 +9,14 @@ const expressPort = process.env.port || process.env.PORT || 9201;
109
const server = express();
1110
server.use(
1211
'/',
13-
(graphqlHTTP({
14-
schema: (schema: any),
12+
graphqlHTTP({
13+
schema,
1514
graphiql: true,
16-
customFormatErrorFn: error => ({
15+
customFormatErrorFn: (error: any) => ({
1716
message: error.message,
1817
stack: error.stack.split('\n'),
1918
}),
20-
}): any)
19+
})
2120
);
2221

2322
server.listen(expressPort, () => {

examples/elastic50/schema.js examples/elastic56/schema.ts

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* @flow */
2-
31
import elasticsearch from 'elasticsearch';
42
import { graphql, ObjectTypeComposer } from 'graphql-compose';
53
import { composeWithElastic, elasticApiFieldConfig } from '../../src'; // from 'graphql-compose-elasticsearch';
@@ -110,13 +108,13 @@ ProxyTC.addResolver({
110108
source: 'JSON',
111109
},
112110
type: 'ProxyDebugType',
113-
resolve: ({ args }) => args,
111+
resolve: ({ args }: any) => args,
114112
});
115113

116114
UserEsTC.addRelation('showRelationArguments', {
117115
resolver: () => ProxyTC.getResolver('showArgs'),
118116
prepareArgs: {
119-
source: source => source,
117+
source: (source) => source,
120118
},
121119
projection: {
122120
name: true,
File renamed without changes.

examples/elastic50/seedData.js examples/elastic56/seedData.ts

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* @flow */
2-
31
import elasticsearch from 'elasticsearch';
42
import seedData from './seedData.json';
53

@@ -8,8 +6,8 @@ const client = new elasticsearch.Client({
86
log: 'trace',
97
});
108

11-
const body = [];
12-
seedData.forEach(row => {
9+
const body = [] as any[];
10+
seedData.forEach((row) => {
1311
const { id, ...restData } = row;
1412
body.push({ index: { _index: 'demo_user', _type: 'demo_user', _id: id } }, restData);
1513
});

0 commit comments

Comments
 (0)