Skip to content

Commit f0ec48b

Browse files
committed
feat: Migrate on graphql-compose 2.9.0
1 parent fea7737 commit f0ec48b

File tree

17 files changed

+1002
-386
lines changed

17 files changed

+1002
-386
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ cache:
77
notifications:
88
email: true
99
node_js:
10+
- "8"
1011
- "7"
1112
- "6"
12-
- "5"
1313
- "4"
1414
before_install: yarn global add greenkeeper-lockfile@1
1515
before_script: greenkeeper-lockfile-update

package.json

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -22,39 +22,39 @@
2222
},
2323
"homepage": "https://github.com/nodkz/graphql-compose-elasticsearch#readme",
2424
"dependencies": {
25-
"babel-runtime": "^6.25.0",
25+
"babel-runtime": "^6.26.0",
2626
"dox": "^0.9.0"
2727
},
2828
"peerDependencies": {
2929
"elasticsearch": ">=12.0.0 || >=13.0.0",
30-
"graphql-compose": ">=1.20.4 || >=2.0.0"
30+
"graphql-compose": ">=2.9.0"
3131
},
3232
"devDependencies": {
33-
"babel-cli": "^6.24.1",
33+
"babel-cli": "^6.26.0",
3434
"babel-eslint": "^7.2.3",
35-
"babel-jest": "^20.0.3",
35+
"babel-jest": "^21.0.0",
3636
"babel-plugin-transform-flow-strip-types": "^6.22.0",
37-
"babel-plugin-transform-object-rest-spread": "^6.22.0",
37+
"babel-plugin-transform-object-rest-spread": "^6.26.0",
3838
"babel-plugin-transform-runtime": "^6.23.0",
3939
"babel-preset-env": "^1.6.0",
4040
"cz-conventional-changelog": "^2.0.0",
41-
"elasticsearch": "^13.2.0",
42-
"eslint": "^4.4.1",
43-
"eslint-config-airbnb-base": "^11.3.1",
44-
"eslint-config-prettier": "^2.3.0",
45-
"eslint-plugin-flowtype": "^2.35.0",
41+
"elasticsearch": "^13.3.1",
42+
"eslint": "^4.6.1",
43+
"eslint-config-airbnb-base": "^12.0.0",
44+
"eslint-config-prettier": "^2.4.0",
45+
"eslint-plugin-flowtype": "^2.35.1",
4646
"eslint-plugin-import": "^2.7.0",
47-
"eslint-plugin-prettier": "^2.1.2",
47+
"eslint-plugin-prettier": "^2.2.0",
4848
"express": "^4.15.4",
49-
"express-graphql": "^0.6.7",
50-
"flow-bin": "^0.52.0",
51-
"graphql": "^0.10.5",
52-
"graphql-compose": "^2.2.0",
53-
"jest": "^20.0.4",
54-
"npm-run-all": "^4.0.1",
55-
"prettier": "^1.5.3",
49+
"express-graphql": "^0.6.11",
50+
"flow-bin": "^0.54.1",
51+
"graphql": "^0.11.3",
52+
"graphql-compose": "^2.9.0",
53+
"jest": "^21.0.1",
54+
"npm-run-all": "^4.1.1",
55+
"prettier": "^1.6.1",
5656
"rimraf": "^2.5.4",
57-
"semantic-release": "^6.3.2"
57+
"semantic-release": "^7.0.2"
5858
},
5959
"config": {
6060
"commitizen": {

src/ElasticApiParser.js

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,23 @@
44
import dox from 'dox';
55
import fs from 'fs';
66
import path from 'path';
7-
import { GraphQLJSON, upperFirst, TypeComposer, graphql } from 'graphql-compose';
8-
import { reorderKeys } from './utils';
9-
10-
import type {
11-
GraphQLArgumentConfig,
12-
GraphQLFieldConfig,
13-
GraphQLFieldConfigMap,
14-
GraphQLFieldConfigArgumentMap,
15-
GraphQLInputType,
16-
} from 'graphql-compose/lib/definition'; // eslint-disable-line
17-
18-
const {
7+
import { GraphQLJSON, upperFirst, TypeComposer } from 'graphql-compose';
8+
import {
199
GraphQLString,
2010
GraphQLFloat,
2111
GraphQLBoolean,
2212
GraphQLObjectType,
2313
GraphQLEnumType,
2414
GraphQLNonNull,
25-
} = graphql;
15+
} from 'graphql-compose/lib/graphql';
16+
import type {
17+
GraphQLArgumentConfig,
18+
GraphQLFieldConfig,
19+
GraphQLFieldConfigMap,
20+
GraphQLFieldConfigArgumentMap,
21+
GraphQLInputType,
22+
} from 'graphql-compose/lib/graphql';
23+
import { reorderKeys } from './utils';
2624

2725
export type ElasticParamConfigT = {
2826
type: string,

src/__tests__/ElasticApiParser-test.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,16 @@
33
// import fs from 'fs';
44
import dox from 'dox';
55
import path from 'path';
6-
import { GraphQLJSON, TypeComposer, graphql } from 'graphql-compose';
7-
import ElasticApiParser from '../ElasticApiParser';
8-
9-
const {
6+
import { GraphQLJSON, TypeComposer } from 'graphql-compose';
7+
import {
108
GraphQLString,
119
GraphQLFloat,
1210
GraphQLBoolean,
1311
GraphQLObjectType,
1412
GraphQLEnumType,
1513
GraphQLNonNull,
16-
} = graphql;
14+
} from 'graphql-compose/lib/graphql';
15+
import ElasticApiParser from '../ElasticApiParser';
1716

1817
const apiPartialPath = path.resolve(__dirname, '../__mocks__/apiPartial.js');
1918

@@ -44,7 +43,7 @@ describe('ElasticApiParser', () => {
4443

4544
describe('findApiVersionFile()', () => {
4645
it('should find proper version in elasticsearch 12.x', () => {
47-
const loadApiListFile = ElasticApiParser.loadApiListFile;
46+
const { loadApiListFile } = ElasticApiParser;
4847
// $FlowFixMe
4948
ElasticApiParser.loadApiListFile = () =>
5049
`
@@ -82,7 +81,7 @@ describe('ElasticApiParser', () => {
8281
});
8382

8483
it('should find proper version in elasticsearch 13.x', () => {
85-
const loadApiListFile = ElasticApiParser.loadApiListFile;
84+
const { loadApiListFile } = ElasticApiParser;
8685
// $FlowFixMe
8786
ElasticApiParser.loadApiListFile = () =>
8887
`

src/__tests__/mappingConverter-test.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
/* @flow */
22

3-
import { TypeComposer, GraphQLJSON, graphql, GQC } from 'graphql-compose';
3+
import { TypeComposer, GraphQLJSON, GQC } from 'graphql-compose';
44
import {
5-
convertToSourceTC,
6-
propertyToSourceGraphQLType,
7-
inputPropertiesToGraphQLTypes,
8-
getSubFields,
9-
} from '../mappingConverter';
10-
11-
const {
125
GraphQLString,
136
GraphQLInt,
147
GraphQLFloat,
158
GraphQLBoolean,
169
GraphQLList,
1710
GraphQLObjectType,
18-
} = graphql;
11+
graphql,
12+
} from 'graphql-compose/lib/graphql';
13+
import {
14+
convertToSourceTC,
15+
propertyToSourceGraphQLType,
16+
inputPropertiesToGraphQLTypes,
17+
getSubFields,
18+
} from '../mappingConverter';
1919

2020
const mapping = {
2121
properties: {
@@ -261,7 +261,7 @@ describe('PropertiesConverter', () => {
261261

262262
it('should use Elastic field names from source', async () => {
263263
GQC.rootQuery().addFields({ userES: tc9 });
264-
const result = await graphql.graphql(
264+
const result = await graphql(
265265
GQC.buildSchema(),
266266
`query { userES { _id, lastName, email, _passwordHash } }`,
267267
{

src/elasticApiFieldConfig.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
/* @flow */
22
/* eslint-disable no-param-reassign */
33

4-
import { graphql } from 'graphql-compose';
5-
import type { GraphQLFieldConfig } from 'graphql-compose/lib/definition';
4+
import {
5+
GraphQLObjectType,
6+
GraphQLString,
7+
type GraphQLFieldConfig,
8+
} from 'graphql-compose/lib/graphql';
69
import elasticsearch from 'elasticsearch';
710
import ElasticApiParser from './ElasticApiParser';
811

9-
const { GraphQLObjectType, GraphQLString } = graphql;
10-
1112
const DEFAULT_ELASTIC_API_VERSION = '_default';
1213

1314
export function elasticApiFieldConfig(esClientOrOpts: Object): GraphQLFieldConfig<*, *> {
@@ -47,7 +48,7 @@ function contextElasticClient(elasticConfig: Object): GraphQLFieldConfig<*, *> {
4748
if (!elasticConfig.apiVersion) {
4849
elasticConfig.apiVersion = DEFAULT_ELASTIC_API_VERSION;
4950
}
50-
const apiVersion = elasticConfig.apiVersion;
51+
const { apiVersion } = elasticConfig;
5152
const prefix = `ElasticAPI${apiVersion.replace('.', '')}`;
5253

5354
const apiParser = new ElasticApiParser({

src/elasticDSL/Aggs/__tests__/Aggs-test.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
/* @flow */
22

3-
import { TypeMapper, graphql } from 'graphql-compose';
3+
import { TypeMapper } from 'graphql-compose';
4+
import {
5+
printSchema,
6+
GraphQLSchema,
7+
GraphQLObjectType,
8+
GraphQLInt,
9+
} from 'graphql-compose/lib/graphql';
410
import { getAggsITC, prepareAggsInResolve, convertAggsBlocks, convertAggsRules } from '../Aggs';
511

6-
const { printSchema, GraphQLSchema, GraphQLObjectType, GraphQLInt } = graphql;
7-
812
describe('AGGS args converter', () => {
913
it('Aggs DSL', () => {
1014
const schema = new GraphQLSchema({

src/elasticDSL/Commons/FieldNames.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
/* @flow */
22
/* eslint-disable no-param-reassign */
33

4-
import { upperFirst, graphql } from 'graphql-compose';
4+
import { upperFirst } from 'graphql-compose';
5+
import { GraphQLEnumType } from 'graphql-compose/lib/graphql';
56
import type {
67
GraphQLEnumValueConfigMap,
78
GraphQLInputFieldConfigMap,
8-
} from 'graphql-compose/lib/definition';
9+
} from 'graphql-compose/lib/graphql';
910
import { getTypeName, getOrSetType, desc } from '../../utils';
1011

11-
const { GraphQLEnumType } = graphql;
12-
1312
export type ElasticDataType = string;
1413

1514
export function getStringFields(opts: mixed) {

src/elasticDSL/Commons/Geo.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
/* @flow */
22
/* eslint-disable no-unused-vars */
33

4-
import { InputTypeComposer, graphql } from 'graphql-compose';
4+
import { InputTypeComposer } from 'graphql-compose';
5+
import { GraphQLScalarType, Kind } from 'graphql-compose/lib/graphql';
56
import { getTypeName, getOrSetType, desc } from '../../utils';
67

7-
const { GraphQLScalarType, Kind } = graphql;
8-
98
export const ElasticGeoPointType = new GraphQLScalarType({
109
name: 'ElasticGeoPointType',
1110
description: desc(

src/elasticDSL/Commons/__tests__/FieldNames-test.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
/* @flow */
22

3-
import { graphql } from 'graphql-compose';
3+
import { GraphQLEnumType } from 'graphql-compose/lib/graphql';
44
import * as FieldNames from '../FieldNames';
55

6-
const { GraphQLEnumType } = graphql;
7-
86
const fieldMap = {
97
_all: {
108
text1: {},

src/elasticDSL/Query/__tests__/Query-test.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
/* @flow */
22

3-
import { TypeMapper, graphql } from 'graphql-compose';
3+
import { TypeMapper } from 'graphql-compose';
4+
import {
5+
printSchema,
6+
GraphQLSchema,
7+
GraphQLObjectType,
8+
GraphQLInt,
9+
} from 'graphql-compose/lib/graphql';
410
import { getQueryITC } from '../Query';
511

6-
const { printSchema, GraphQLSchema, GraphQLObjectType, GraphQLInt } = graphql;
7-
812
describe('AGGS args converter', () => {
913
it('Query DSL', () => {
1014
const schema = new GraphQLSchema({

src/elasticDSL/Sort.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
/* @flow */
22

3-
import { graphql } from 'graphql-compose';
3+
import { GraphQLEnumType } from 'graphql-compose/lib/graphql';
44
import { getTypeName, getOrSetType } from '../utils';
55
import { getFieldNamesByElasticType } from './Commons/FieldNames';
66

7-
const { GraphQLEnumType } = graphql;
8-
97
const sortableTypes = [
108
'byte',
119
'short',

src/mappingConverter.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,18 @@ import {
88
GraphQLBuffer,
99
upperFirst,
1010
isObject,
11-
graphql,
1211
} from 'graphql-compose';
13-
import type { GraphQLScalarType, GraphQLInputType } from 'graphql-compose/lib/definition';
14-
15-
import { ElasticGeoPointType } from './elasticDSL/Commons/Geo';
16-
17-
const {
12+
import {
1813
GraphQLString,
1914
GraphQLInt,
2015
GraphQLFloat,
2116
GraphQLBoolean,
2217
GraphQLList,
2318
GraphQLObjectType,
24-
} = graphql;
19+
} from 'graphql-compose/lib/graphql';
20+
import type { GraphQLScalarType, GraphQLInputType } from 'graphql-compose/lib/graphql';
21+
22+
import { ElasticGeoPointType } from './elasticDSL/Commons/Geo';
2523

2624
export type ElasticMappingT = {
2725
properties: ElasticMappingPropertiesT,

src/resolvers/search.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/* eslint-disable no-param-reassign */
33

44
import { Resolver, TypeComposer, InputTypeComposer, isObject } from 'graphql-compose';
5-
import type { ResolveParams, ProjectionType } from 'graphql-compose/lib/definition';
5+
import type { ResolveParams, ProjectionType } from 'graphql-compose';
66
import type { FieldsMapByElasticType } from '../mappingConverter';
77
import ElasticApiParser from '../ElasticApiParser';
88
import { getSearchBodyITC, prepareBodyInResolve } from '../elasticDSL/SearchBody';

src/resolvers/searchConnection.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,11 +156,11 @@ function getPageInfoTC(opts: mixed = {}): TypeComposer {
156156
}
157157

158158
export function base64(i: string): string {
159-
return new Buffer(i, 'ascii').toString('base64');
159+
return Buffer.from(i, 'ascii').toString('base64');
160160
}
161161

162162
export function unbase64(i: string): string {
163-
return new Buffer(i, 'base64').toString('ascii');
163+
return Buffer.from(i, 'base64').toString('ascii');
164164
}
165165

166166
export function cursorToData(cursor: string): mixed {

src/typeStorage.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import { isFunction } from 'graphql-compose';
44

5-
class TypeStorage extends Map {
5+
class TypeStorage extends Map<string, any> {
66
// this `create` hack due TypeError:
77
// Constructor Map requires 'new' at TypeStorage.Map (native)
88
static create(array?: any[]): TypeStorage {

0 commit comments

Comments
 (0)