Skip to content

Commit

Permalink
fix: add graceful yml parsing, add databaseType
Browse files Browse the repository at this point in the history
  • Loading branch information
timsuchanek committed Oct 31, 2018
1 parent 68dc251 commit 76b5539
Show file tree
Hide file tree
Showing 3 changed files with 657 additions and 58 deletions.
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@
"license": "Apache-2.0",
"dependencies": {
"graphql-config": "2.2.1",
"prisma-yml": "1.0.97"
"prisma-yml": "1.20.0-beta.18"
},
"devDependencies": {
"@types/graphql": "^14.0.0",
"@types/jest": "^23.3.2",
"@types/node": "10.9.4",
"@types/graphql": "^14.0.3",
"@types/jest": "^23.3.9",
"@types/node": "10.12.1",
"graphql": "^14.0.2",
"jest": "^23.6.0",
"ts-jest": "^23.1.4",
"ts-jest": "^23.10.4",
"ts-node": "7.0.1",
"typescript": "3.0.3"
"typescript": "3.1.4"
},
"scripts": {
"test": "jest",
Expand Down
20 changes: 17 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,26 @@ export function getCustomDirectives(version?: string) {
// of this project.
export async function patchEndpointsToConfig<
T extends GraphQLConfig | GraphQLProjectConfig
>(config: T, cwd?: string, envVars?: { [key: string]: any }): Promise<T> {
config.config = await patchEndpointsToConfigData(config.config, cwd, envVars)
>(
config: T,
cwd?: string,
envVars?: { [key: string]: any },
graceful?: boolean,
): Promise<T> {
config.config = await patchEndpointsToConfigData(
config.config,
cwd,
envVars,
graceful,
)
return config
}

export async function patchEndpointsToConfigData(
config: GraphQLConfigData,
cwd?: string,
envVars?: { [key: string]: any },
graceful?: boolean,
): Promise<GraphQLConfigData> {
// return early if no prisma extension found
const allExtensions = [
Expand All @@ -115,6 +126,7 @@ export async function patchEndpointsToConfigData(
newConfig.extensions.prisma,
cwd,
envVars,
graceful,
),
)
}
Expand All @@ -132,6 +144,7 @@ export async function patchEndpointsToConfigData(
project.extensions.prisma,
cwd,
envVars,
graceful,
),
)
}
Expand Down Expand Up @@ -210,10 +223,11 @@ async function getEndpointsFromPath(
ymlPath: string,
cwd?: string,
envVars?: { [key: string]: any },
graceful?: boolean,
): Promise<GraphQLConfigEnpointsData> {
const joinedYmlPath = cwd ? path.join(cwd, ymlPath) : ymlPath
const definition = new PrismaDefinitionClass(env, joinedYmlPath, envVars)
await definition.load({})
await definition.load({}, undefined, graceful)
const serviceName = definition.service!
const stage = definition.stage!
const clusterName = definition.cluster
Expand Down
Loading

0 comments on commit 76b5539

Please sign in to comment.