Skip to content

Commit

Permalink
fix(preset/near-operation-file): accept skipDocumentsValidat (#414)
Browse files Browse the repository at this point in the history
* Revert "Revert "fix(preset/near-operation-file): accept skipDocumentsValidation config parameter. Closes #214 (#383)" (#413)"

This reverts commit 5739a0e.

* fix(preset/near-operation-file): read skipDocumentsValidation from config (#409)

* fix(preset/near-operation-file): add skipDocumentsValidation presetConfig types

* Create brave-bulldogs-explode.md

* fix(preset/near-operation-file): read skipDocumentsValidation from config

* Update brave-bulldogs-explode.md

* Delete .changeset/brave-bulldogs-explode.md

---------

Co-authored-by: Herman Bilous <herman.belous@gmail.com>
  • Loading branch information
saihaj and HermanBilous authored Sep 25, 2023
1 parent 172084a commit 02d487c
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 2 deletions.
12 changes: 12 additions & 0 deletions .changeset/thirty-books-explode.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
'@graphql-codegen/near-operation-file-preset': major
---

accept skipDocumentsValidation config parameter

‼️ ‼️ ‼️ Please note ‼️ ‼️ ‼️:

This is a breaking change since previous versions skips all documents validation
and this could raise validation errors while generating types.


6 changes: 5 additions & 1 deletion packages/presets/near-operation-file/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -343,14 +343,18 @@ export const preset: Types.OutputPreset<NearOperationFileConfig> = {
}

artifacts.push({
...options,
filename,
documents: [combinedSource],
plugins,
pluginMap,
config,
schema: options.schema,
schemaAst: schemaObject,
skipDocumentsValidation: true,
skipDocumentsValidation:
typeof options.config.skipDocumentsValidation === 'undefined'
? { skipDuplicateValidation: true }
: options.config.skipDocumentsValidation,
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,47 @@ describe('near-operation-file preset', () => {
pluginMap: {},
});

expect(result[0].skipDocumentsValidation).toBeTruthy();
expect(result[0].skipDocumentsValidation).toEqual({ skipDuplicateValidation: true });
});

it('Should allow to customize the skip documents validation', async () => {
const result = await executePreset({
baseOutputDir: './src/',
config: {
skipDocumentsValidation: {
skipValidationAgainstSchema: true,
},
},
presetConfig: {
baseTypesPath: 'types.ts',
},
schema: schemaDocumentNode,
schemaAst: schemaNode,
documents: testDocuments,
plugins: [],
pluginMap: {},
});

expect(result[0].skipDocumentsValidation).toEqual({ skipValidationAgainstSchema: true });
});

it('Should allow to opt-out skipping documents validation', async () => {
const result = await executePreset({
baseOutputDir: './src/',
config: {
skipDocumentsValidation: false,
},
presetConfig: {
baseTypesPath: 'types.ts',
},
schema: schemaDocumentNode,
schemaAst: schemaNode,
documents: testDocuments,
plugins: [],
pluginMap: {},
});

expect(result[0].skipDocumentsValidation).toBe(false);
});

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

0 comments on commit 02d487c

Please sign in to comment.