From 0daade235e30577c2b1548a6a025c0f27c759862 Mon Sep 17 00:00:00 2001 From: Nico Schett Date: Thu, 11 Jul 2024 15:34:33 +0200 Subject: [PATCH] fix: generate client code for Pylon GraphQL API --- packages/pylon-cli/src/commands/develop.ts | 24 +++++++++++----------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/packages/pylon-cli/src/commands/develop.ts b/packages/pylon-cli/src/commands/develop.ts index 0c793f5..7480728 100644 --- a/packages/pylon-cli/src/commands/develop.ts +++ b/packages/pylon-cli/src/commands/develop.ts @@ -17,6 +17,8 @@ export default async (options: {port: string}) => { const binPath = stdout.toString().trim() + const packageJson = await import(path.resolve(process.cwd(), 'package.json')) + let currentProc: Subprocess | null = null let serve = async () => { @@ -34,22 +36,20 @@ export default async (options: {port: string}) => { NODE_ENV: 'development' } }) - } - const packageJson = await import(path.resolve(process.cwd(), 'package.json')) + const clientPath = packageJson.pylon?.gqty - const clientPath = packageJson.pylon?.gqty + if (clientPath) { + const endpoint = `http://localhost:${options.port}/graphql` - if (clientPath) { - const endpoint = `http://localhost:${options.port}/graphql` + const schema = await fetchSchema(endpoint) - const schema = await fetchSchema(endpoint) - - await generateClient(schema, { - endpoint, - destination: clientPath, - react: true - }) + await generateClient(schema, { + endpoint, + destination: clientPath, + react: true + }) + } } await build({