Skip to content

Commit 3431612

Browse files
committed
refactor(graphql-server): use buildConnectionString in schema SDL builder
1 parent e3a90d7 commit 3431612

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

graphql/server/src/schema.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { printSchema, getIntrospectionQuery, buildClientSchema } from 'graphql'
22
import { ConstructivePreset, makePgService } from 'graphile-settings'
33
import { makeSchema } from 'graphile-build'
4-
import { getPgPool } from 'pg-cache'
4+
import { buildConnectionString, getPgPool } from 'pg-cache'
55
import type { GraphileConfig } from 'graphile-config'
66
import * as http from 'node:http'
77
import * as https from 'node:https'
@@ -20,7 +20,13 @@ export async function buildSchemaSDL(opts: BuildSchemaOptions): Promise<string>
2020
// Get pool config for connection string
2121
const pool = getPgPool({ database })
2222
const poolConfig = (pool as any).options || {}
23-
const connectionString = `postgres://${poolConfig.user || 'postgres'}:${poolConfig.password || ''}@${poolConfig.host || 'localhost'}:${poolConfig.port || 5432}/${database}`
23+
const connectionString = buildConnectionString(
24+
poolConfig.user || 'postgres',
25+
poolConfig.password || '',
26+
poolConfig.host || 'localhost',
27+
poolConfig.port || 5432,
28+
database,
29+
)
2430

2531
// Build v5 preset
2632
const preset: GraphileConfig.Preset = {

0 commit comments

Comments
 (0)