Skip to content

Commit

Permalink
Merge pull request #335 from kazekyo/fix_multi_selections
Browse files Browse the repository at this point in the history
fix: Fix a bug that occurred when using presets in multiple sections
  • Loading branch information
kazekyo authored Jul 29, 2022
2 parents a0c316a + 6bb17e1 commit 5a5d85b
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
34 changes: 34 additions & 0 deletions packages/graphql-codegen-preset/src/__tests__/preset.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
});
2 changes: 1 addition & 1 deletion packages/graphql-codegen-preset/src/preset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export const preset: Types.OutputPreset<PresetConfig> = {
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;
Expand Down

1 comment on commit 5a5d85b

@vercel
Copy link

@vercel vercel bot commented on 5a5d85b Jul 29, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.