Skip to content

Commit cc70f71

Browse files
authored
Revert "Revert "fix(preset/near-operation-file): accept skipDocumentsValidation config parameter. Closes #214 (#383)" (#413)"
This reverts commit 5739a0e.
1 parent 5739a0e commit cc70f71

File tree

3 files changed

+55
-2
lines changed

3 files changed

+55
-2
lines changed

.changeset/thirty-books-explode.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
'@graphql-codegen/near-operation-file-preset': major
3+
---
4+
5+
accept skipDocumentsValidation config parameter
6+
7+
‼️ ‼️ ‼️ Please note ‼️ ‼️ ‼️:
8+
9+
This is a breaking change since previous versions skips all documents validation
10+
and this could raise validation errors while generating types.
11+
12+

packages/presets/near-operation-file/src/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,10 @@ export const preset: Types.OutputPreset<NearOperationFileConfig> = {
350350
config,
351351
schema: options.schema,
352352
schemaAst: schemaObject,
353-
skipDocumentsValidation: true,
353+
skipDocumentsValidation:
354+
typeof options.skipDocumentsValidation === 'undefined'
355+
? { skipDuplicateValidation: true }
356+
: options.skipDocumentsValidation,
354357
});
355358
}
356359

packages/presets/near-operation-file/tests/near-operation-file.spec.ts

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,45 @@ describe('near-operation-file preset', () => {
699699
pluginMap: {},
700700
});
701701

702-
expect(result[0].skipDocumentsValidation).toBeTruthy();
702+
expect(result[0].skipDocumentsValidation).toEqual({ skipDuplicateValidation: true });
703+
});
704+
705+
it('Should allow to customize the skip documents validation', async () => {
706+
const result = await executePreset({
707+
baseOutputDir: './src/',
708+
config: {},
709+
presetConfig: {
710+
baseTypesPath: 'types.ts',
711+
},
712+
schema: schemaDocumentNode,
713+
schemaAst: schemaNode,
714+
documents: testDocuments,
715+
plugins: [],
716+
pluginMap: {},
717+
skipDocumentsValidation: {
718+
skipValidationAgainstSchema: true,
719+
},
720+
});
721+
722+
expect(result[0].skipDocumentsValidation).toEqual({ skipValidationAgainstSchema: true });
723+
});
724+
725+
it('Should allow to opt-out skipping documents validation', async () => {
726+
const result = await executePreset({
727+
baseOutputDir: './src/',
728+
config: {},
729+
presetConfig: {
730+
baseTypesPath: 'types.ts',
731+
},
732+
schema: schemaDocumentNode,
733+
schemaAst: schemaNode,
734+
documents: testDocuments,
735+
plugins: [],
736+
pluginMap: {},
737+
skipDocumentsValidation: false,
738+
});
739+
740+
expect(result[0].skipDocumentsValidation).toBe(false);
703741
});
704742

705743
it('Should allow to customize output extension', async () => {

0 commit comments

Comments
 (0)