Skip to content
This repository was archived by the owner on May 10, 2018. It is now read-only.

Commit b0455d3

Browse files
schicklingkbrandwijk
authored andcommitted
chore: Replace Array<T> by T[] syntax (#19)
* chore: Replace Array<T> by T[] syntax * test: Adjusted tests
1 parent 6856e1e commit b0455d3

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

src/generators/graphcool-ts.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ function renderFieldType(type: GraphQLInputType | GraphQLOutputType) {
187187
return renderFieldType((type as GraphQLWrappingType).ofType)
188188
}
189189
if (isListType(type)) {
190-
return `Array<${renderFieldType((type as GraphQLWrappingType).ofType)}>`
190+
return `${renderFieldType((type as GraphQLWrappingType).ofType)}[]`
191191
}
192192
return `${(type as GraphQLNamedType).name}${(type as GraphQLNamedType).name === 'ID' ? '_Output' : ''}`
193193
}
@@ -197,9 +197,8 @@ function renderInputFieldType(type: GraphQLInputType | GraphQLOutputType) {
197197
return renderInputFieldType((type as GraphQLWrappingType).ofType)
198198
}
199199
if (isListType(type)) {
200-
return `Array<${renderInputFieldType(
201-
(type as GraphQLWrappingType).ofType
202-
)}> | ${renderInputFieldType((type as GraphQLWrappingType).ofType)}`
200+
const inputType = renderInputFieldType((type as GraphQLWrappingType).ofType)
201+
return `${inputType}[] | ${inputType}`
203202
}
204203
return `${(type as GraphQLNamedType).name}${(type as GraphQLNamedType).name === 'ID' ? '_Input' : ''}`
205204
}

test/features/graphcool-ts.feature

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Feature for Graphcool Typescript generator
3636
}
3737
3838
export type Query = {
39-
posts: (args: {}, info?: GraphQLResolveInfo | string) => Promise<Array<String> | null>
39+
posts: (args: {}, info?: GraphQLResolveInfo | string) => Promise<String[] | null>
4040
}
4141
4242
export class Graphcool extends BaseGraphcool {
@@ -46,7 +46,7 @@ Feature for Graphcool Typescript generator
4646
}
4747
4848
query: Query = {
49-
posts: (args, info): Promise<Array<String> | null> => super.delegate('query', 'posts', args, {}, info)
49+
posts: (args, info): Promise<String[] | null> => super.delegate('query', 'posts', args, {}, info)
5050
}
5151
}
52-
"""
52+
"""

0 commit comments

Comments
 (0)