Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(preset/near-operation-file): accept skipDocumentsValidat #414

Merged
merged 2 commits into from
Sep 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading