diff --git a/packages/graphql-codegen-preset/src/__tests__/preset.test.ts b/packages/graphql-codegen-preset/src/__tests__/preset.test.ts index b73aab68..33d53d46 100644 --- a/packages/graphql-codegen-preset/src/__tests__/preset.test.ts +++ b/packages/graphql-codegen-preset/src/__tests__/preset.test.ts @@ -136,4 +136,38 @@ describe('preset', () => { expect(result[0].content).toMatchSnapshot(); }); }); + + describe('Multiple Sections', () => { + it('works with no errors', async () => { + const input = { + schema: path.join(__dirname, '../utils/testing/example.graphql'), + generates: { + ['./generated.ts']: { + preset, + plugins: [], + presetConfig: { + generateTypeScriptCode: true, + }, + documents: path.join(__dirname, './fixtures/exampleFile.ts'), + }, + ['./generated2.ts']: { + preset, + plugins: [], + presetConfig: { + generateTypeScriptCode: true, + }, + documents: path.join(__dirname, './fixtures/exampleFile.ts'), + }, + ['./generated3.ts']: { + preset, + plugins: [], + documents: path.join(__dirname, './fixtures/exampleFile.ts'), + }, + }, + }; + + const result = await executeCodegen(input); + expect(result.length).toBe(3); + }); + }); }); diff --git a/packages/graphql-codegen-preset/src/preset.ts b/packages/graphql-codegen-preset/src/preset.ts index cd8f9621..48f1aa51 100644 --- a/packages/graphql-codegen-preset/src/preset.ts +++ b/packages/graphql-codegen-preset/src/preset.ts @@ -79,7 +79,7 @@ export const preset: Types.OutputPreset = { return validateGraphQlDocuments(schemaObject, options.documents, validationRules()).then((errors) => { checkValidationErrors(errors); - const transformedObject = transformDocuments({ documentFiles: options.documents }); + const transformedObject = transformDocuments({ documentFiles: cloneDeep(options.documents) }); let pluginMap = options.pluginMap; let plugins = options.plugins;