Skip to content

Commit

Permalink
create .hydra folder if missing
Browse files Browse the repository at this point in the history
  • Loading branch information
dbrrt committed Dec 20, 2023
1 parent 2cf13b5 commit 77d746e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/green-planets-kick.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@authdog/hydra-cli": patch
---

create .hydra folder if missing
6 changes: 5 additions & 1 deletion packages/cli/src/utils/introspectSchemas.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import fetch from "node-fetch";
import { getIntrospectionQuery, buildClientSchema, printSchema } from "graphql";
import { initSpinner, stopSpinner } from "./spinners";
// import { spawn } from "node:child_process";
import fs from "fs";

export async function introspectRemoteSchema(endpointUrl: string) {
Expand Down Expand Up @@ -76,6 +75,11 @@ export const buildSchemaIntrospection = async (
introspected: s.introspected,
}));

// create a .hydra directory if it doesn't exist
if (!fs.existsSync(".hydra")) {
fs.mkdirSync(".hydra");
}

// generate a schemaRaw file (.hydra/schemaRaw.js) module.exports = <fileContent>
fs.writeFileSync(
outputPath,
Expand Down

0 comments on commit 77d746e

Please sign in to comment.