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 fb296f120b83..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( @@ -121,13 +122,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