From 2a21baf63f3bb342032ae8912a632016cc1ea10f Mon Sep 17 00:00:00 2001 From: Tobbe Lundberg Date: Fri, 12 Jan 2024 08:23:50 +0100 Subject: [PATCH 1/2] fragments: refactor->rename --- .../setup/graphql/features/fragments/fragmentsHandler.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/cli/src/commands/setup/graphql/features/fragments/fragmentsHandler.ts b/packages/cli/src/commands/setup/graphql/features/fragments/fragmentsHandler.ts index fb296f120b83..096fb1cb3b43 100644 --- a/packages/cli/src/commands/setup/graphql/features/fragments/fragmentsHandler.ts +++ b/packages/cli/src/commands/setup/graphql/features/fragments/fragmentsHandler.ts @@ -121,13 +121,13 @@ export async function handler({ force }: Args) { { title: 'Add possibleTypes to the GraphQL cache config', task: async () => { - const result = await runTransform({ + const transformResult = await runTransform({ transformPath: path.join(__dirname, 'appGqlConfigTransform.js'), targetPaths: [getPaths().web.app], }) - if (result.error) { - throw new Error(result.error) + if (transformResult.error) { + throw new Error(transformResult.error) } const appPath = getPaths().web.app From d37491acfe24b6a6d9ceb48fbebd74ca8d873bec Mon Sep 17 00:00:00 2001 From: Tobbe Lundberg Date: Fri, 12 Jan 2024 09:22:21 +0100 Subject: [PATCH 2/2] Fix extra newline --- .../features/fragments/__tests__/fragmentsHandler.test.ts | 2 +- .../setup/graphql/features/fragments/fragmentsHandler.ts | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/cli/src/commands/setup/graphql/features/fragments/__tests__/fragmentsHandler.test.ts b/packages/cli/src/commands/setup/graphql/features/fragments/__tests__/fragmentsHandler.test.ts index c60ea5f4100d..2e271612b4a4 100644 --- a/packages/cli/src/commands/setup/graphql/features/fragments/__tests__/fragmentsHandler.test.ts +++ b/packages/cli/src/commands/setup/graphql/features/fragments/__tests__/fragmentsHandler.test.ts @@ -138,7 +138,7 @@ test('redwood.toml is updated even if `fragments = true` exists for other sectio await handler({ force: false }) expect(vol.toJSON()[FIXTURE_PATH + '/redwood.toml']).toEqual( - toml + '\n\n[graphql]\n fragments = true' + toml + '\n[graphql]\n fragments = true' ) }) diff --git a/packages/cli/src/commands/setup/graphql/features/fragments/fragmentsHandler.ts b/packages/cli/src/commands/setup/graphql/features/fragments/fragmentsHandler.ts index 096fb1cb3b43..dc9b4937e2da 100644 --- a/packages/cli/src/commands/setup/graphql/features/fragments/fragmentsHandler.ts +++ b/packages/cli/src/commands/setup/graphql/features/fragments/fragmentsHandler.ts @@ -54,7 +54,8 @@ export async function handler({ force }: Args) { const hasExistingGraphqlSection = !!redwoodTomlObject?.graphql let newTomlContent = - originalTomlContent + '\n\n[graphql]\n fragments = true' + originalTomlContent.replace(/\n$/, '') + + '\n\n[graphql]\n fragments = true' if (hasExistingGraphqlSection) { const existingGraphqlSetting = Object.keys(