Skip to content

Commit e3b6bea

Browse files
authored
fix: Allow port to be a string
2 parents e020c5b + a68bf11 commit e3b6bea

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

src/index.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export class GraphQLServer {
3131
subscriptionServer: SubscriptionServer | null
3232
options: Options = {
3333
tracing: { mode: 'http-header' },
34-
port: process.env.PORT ? parseInt(process.env.PORT, 10) : 4000,
34+
port: process.env.PORT || 4000,
3535
endpoint: '/',
3636
subscriptions: '/',
3737
playground: '/',
@@ -298,11 +298,11 @@ function mergeTypeDefs(typeDefs: ITypeDefinitions): string {
298298
if (typeof typeDefs === 'string') {
299299
if (typeDefs.endsWith('graphql')) {
300300
const schemaPath = path.resolve(typeDefs)
301-
301+
302302
if (!fs.existsSync(schemaPath)) {
303303
throw new Error(`No schema found for path: ${schemaPath}`)
304304
}
305-
305+
306306
return importSchema(schemaPath)
307307
} else {
308308
return typeDefs
@@ -318,10 +318,15 @@ function mergeTypeDefs(typeDefs: ITypeDefinitions): string {
318318
}
319319

320320
if (Array.isArray(typeDefs)) {
321-
return typeDefs.reduce<string>((acc, t) => acc + '\n' + mergeTypeDefs(t), '')
321+
return typeDefs.reduce<string>(
322+
(acc, t) => acc + '\n' + mergeTypeDefs(t),
323+
'',
324+
)
322325
}
323326

324-
throw new Error('Typedef is not string, function, DocumentNode or array of previous')
327+
throw new Error(
328+
'Typedef is not string, function, DocumentNode or array of previous',
329+
)
325330
}
326331

327332
function isDocumentNode(node: any): node is DocumentNode {

src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export interface HttpsOptions {
6969
}
7070

7171
export interface Options extends ApolloServerOptions {
72-
port?: number
72+
port?: number | string
7373
cors?: CorsOptions | false
7474
uploads?: UploadOptions | false
7575
endpoint?: string

0 commit comments

Comments
 (0)