Skip to content

Commit e019590

Browse files
committed
refactor: migrate code to [email protected]
BREAKING CHANGE: required [email protected]
1 parent 9f42807 commit e019590

File tree

5 files changed

+22
-29
lines changed

5 files changed

+22
-29
lines changed

src/AwsParam.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import {
55
ObjectTypeComposer,
66
InputTypeComposer,
77
upperFirst,
8-
type ComposeOutputType,
9-
type ComposeInputType,
8+
type ComposeOutputTypeDefinition,
9+
type ComposeInputTypeDefinition,
1010
} from 'graphql-compose';
1111

1212
type ParamsMap = {
@@ -156,7 +156,7 @@ export class AwsParam<TContext = any> {
156156
name: string,
157157
isInput?: boolean,
158158
shapes?: AwsShapes
159-
): ComposeOutputType<any, TContext> | ComposeInputType {
159+
): ComposeOutputTypeDefinition<TContext> | ComposeInputTypeDefinition {
160160
if (param.type) {
161161
switch (param.type) {
162162
case 'boolean':
@@ -199,7 +199,7 @@ export class AwsParam<TContext = any> {
199199
param: ParamShape,
200200
isInput?: boolean,
201201
shapes?: AwsShapes
202-
): ComposeOutputType<any, TContext> | ComposeInputType {
202+
): ComposeOutputTypeDefinition<TContext> | ComposeInputTypeDefinition {
203203
if (shapes) {
204204
return isInput ? shapes.getInputShape(param.shape) : shapes.getOutputShape(param.shape);
205205
}

src/AwsShapes.js

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

3-
import { type ComposeOutputType, type ComposeInputType } from 'graphql-compose';
3+
import { type ComposeOutputTypeDefinition, type ComposeInputTypeDefinition } from 'graphql-compose';
44
import { AwsParam, type Param } from './AwsParam';
55

66
export type ShapesMap = {
@@ -10,8 +10,8 @@ export type ShapesMap = {
1010
export class AwsShapes<TContext> {
1111
shapes: ShapesMap;
1212
prefix: string;
13-
shapesInput: { [name: string]: ComposeInputType };
14-
shapesOutput: { [name: string]: ComposeOutputType<any, TContext> };
13+
shapesInput: { [name: string]: ComposeInputTypeDefinition };
14+
shapesOutput: { [name: string]: ComposeOutputTypeDefinition<TContext> };
1515

1616
constructor(shapes: ShapesMap, prefix: string) {
1717
this.shapes = shapes;
@@ -20,7 +20,7 @@ export class AwsShapes<TContext> {
2020
this.shapesOutput = {};
2121
}
2222

23-
getInputShape(name: string): ComposeInputType {
23+
getInputShape(name: string): ComposeInputTypeDefinition {
2424
if (!this.shapesInput[name]) {
2525
if (!this.shapes[name]) {
2626
throw new Error(`Shape with name '${name}' not found in service config ${this.prefix}`);
@@ -39,7 +39,7 @@ export class AwsShapes<TContext> {
3939
return this.shapesInput[name];
4040
}
4141

42-
getOutputShape(name: string): ComposeOutputType<any, TContext> {
42+
getOutputShape(name: string): ComposeOutputTypeDefinition<TContext> {
4343
if (!this.shapesOutput[name]) {
4444
if (!this.shapes[name]) {
4545
throw new Error(`Shape with name '${name}' not found in service config ${this.prefix}`);

src/__tests__/AwsParam-test.js

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

33
import { ObjectTypeComposer, InputTypeComposer } from 'graphql-compose';
4-
import { GraphQLNonNull, GraphQLString } from 'graphql-compose/lib/graphql';
54
import { AwsParam } from '../AwsParam';
65

76
describe('AwsParam', () => {
@@ -84,9 +83,8 @@ describe('AwsParam', () => {
8483
const itc = AwsParam.convertInputStructure(param, 'AwsS3Bucket');
8584
expect(itc).toBeInstanceOf(InputTypeComposer);
8685
expect(itc.getTypeName()).toBe('AwsS3BucketInput');
87-
expect(itc.getFieldType('Bucket')).toBeInstanceOf(GraphQLNonNull);
88-
expect((itc.getFieldType('Bucket'): any).ofType).toBe(GraphQLString);
89-
expect(itc.getFieldType('Delimiter')).toBe(GraphQLString);
86+
expect(itc.getFieldTypeName('Bucket')).toBe('String!');
87+
expect(itc.getFieldTypeName('Delimiter')).toBe('String');
9088
});
9189

9290
it('static convertOutputStructure()', () => {
@@ -108,8 +106,7 @@ describe('AwsParam', () => {
108106
const tc = AwsParam.convertOutputStructure(param, 'AwsS3Bucket');
109107
expect(tc).toBeInstanceOf(ObjectTypeComposer);
110108
expect(tc.getTypeName()).toBe('AwsS3Bucket');
111-
expect(tc.getFieldType('Bucket')).toBeInstanceOf(GraphQLNonNull);
112-
expect((tc.getFieldType('Bucket'): any).ofType).toBe(GraphQLString);
113-
expect(tc.getFieldType('Delimiter')).toBe(GraphQLString);
109+
expect(tc.getFieldTypeName('Bucket')).toBe('String!');
110+
expect(tc.getFieldTypeName('Delimiter')).toBe('String');
114111
});
115112
});

src/__tests__/AwsServiceOperation-test.js

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
/* @flow */
22
/* eslint-disable class-methods-use-this */
33

4-
import {
5-
GraphQLInputObjectType,
6-
GraphQLObjectType,
7-
GraphQLNonNull,
8-
isOutputType,
9-
} from 'graphql-compose/lib/graphql';
4+
import { NonNullComposer, InputTypeComposer } from 'graphql-compose';
5+
import { GraphQLObjectType } from 'graphql';
106
import { AwsServiceOperation } from '../AwsServiceOperation';
117
import AwsConfigITC from '../types/AwsConfigITC';
128

@@ -96,16 +92,16 @@ describe('AwsJsonParserOperation', () => {
9692

9793
it('getType()', () => {
9894
const tc = oper.getType();
99-
expect(isOutputType(tc)).toBeTruthy();
95+
expect(tc).toBeInstanceOf(GraphQLObjectType);
10096
});
10197

10298
it('getArgs()', () => {
10399
const args: any = oper.getArgs();
104100
expect(args.input).toBeDefined();
105-
// input arg has required fields, so it wrapped by GraphQLNonNull
106-
expect(args.input.type).toBeInstanceOf(GraphQLNonNull);
107-
expect(args.input.type.ofType).toBeInstanceOf(GraphQLInputObjectType);
108-
expect(args.input.type.ofType.name).toBe('AWSS3CreateBucketInput');
101+
// input arg has required fields, so it wrapped by NonNullComposer
102+
expect(args.input.type).toBeInstanceOf(NonNullComposer);
103+
expect(args.input.type.ofType).toBeInstanceOf(InputTypeComposer);
104+
expect(args.input.type.ofType.getTypeName()).toBe('AWSS3CreateBucketInput');
109105
});
110106

111107
describe('getResolve()', () => {

src/__tests__/AwsShapes-test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ describe('AwsShapes', () => {
1616
});
1717

1818
it('getInputShape() from cache', () => {
19-
shapes.shapesInput.cachedS1 = 'Cached';
19+
(shapes: any).shapesInput.cachedS1 = 'Cached';
2020
expect(shapes.getInputShape('cachedS1')).toBe('Cached');
2121
});
2222

@@ -25,7 +25,7 @@ describe('AwsShapes', () => {
2525
});
2626

2727
it('getOutputShape() from cache', () => {
28-
shapes.shapesOutput.cachedS2 = 'Cached';
28+
(shapes: any).shapesOutput.cachedS2 = 'Cached';
2929
expect(shapes.getOutputShape('cachedS2')).toBe('Cached');
3030
});
3131
});

0 commit comments

Comments
 (0)