diff --git a/packages/cli/src/commands/generate-schema.ts b/packages/cli/src/commands/generate-schema.ts index c75ba63..d5e76bd 100644 --- a/packages/cli/src/commands/generate-schema.ts +++ b/packages/cli/src/commands/generate-schema.ts @@ -20,29 +20,22 @@ export const generateSchemaAction = async ({ const outputPath = path.resolve(rootPath, hydraSchemaRawPath); // Construct absolute path for output try { - // Compiler options (optional) const tsConfig = { target: ts.ScriptTarget.ESNext, module: ts.ModuleKind.CommonJS, }; - // Create TypeScript compiler host and program const compilerHost = ts.createCompilerHost({}); const program = ts.createProgram([configPath], tsConfig, compilerHost); - // Get the source file const sourceFile = program.getSourceFile(configPath); - if (!sourceFile) { return logError(`Config [${config}] not found`); } - // Emit the transpiled code const { outputText } = ts.transpileModule(sourceFile.getText(), { compilerOptions: tsConfig, }); - - // // Evaluate the transpiled code const module_ = eval(outputText); const demoConfig = module_.default || module_; const validatedConfig = validateConfig(demoConfig); @@ -50,11 +43,10 @@ export const generateSchemaAction = async ({ if (!validatedConfig) { return logError(`Invalid config [${config}]`); } - try { await buildSchemaIntrospection(validatedConfig.schemas, outputPath); - } catch (error) { - return logError("Error generating schema"); + } catch (error: any) { + return logError(error.message); } logSuccess("Schema generated successfully"); diff --git a/packages/core/src/handlers/graphql.ts b/packages/core/src/handlers/graphql.ts index 6e18b47..9173ee5 100644 --- a/packages/core/src/handlers/graphql.ts +++ b/packages/core/src/handlers/graphql.ts @@ -1,7 +1,11 @@ import { createYoga } from "graphql-yoga"; import { schema } from "../schema"; -export const GraphQLHandler = async (req: Request, env: any, ctx: any): Promise => { +export const GraphQLHandler = async ( + req: Request, + env: any, + ctx: any, +): Promise => { const yoga = createYoga({ schema, context: async (event) => {