Skip to content

Commit

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

This reverts commit 5739a0e.
  • Loading branch information
saihaj authored Sep 25, 2023
1 parent 5739a0e commit cc70f71
Show file tree
Hide file tree
Showing 3 changed files with 55 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.


5 changes: 4 additions & 1 deletion packages/presets/near-operation-file/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,10 @@ export const preset: Types.OutputPreset<NearOperationFileConfig> = {
config,
schema: options.schema,
schemaAst: schemaObject,
skipDocumentsValidation: true,
skipDocumentsValidation:
typeof options.skipDocumentsValidation === 'undefined'

Check failure on line 354 in packages/presets/near-operation-file/src/index.ts

View workflow job for this annotation

GitHub Actions / Testing exports integrity

Property 'skipDocumentsValidation' does not exist on type 'PresetFnArgs<NearOperationFileConfig, { [key: string]: any; }>'.

Check failure on line 354 in packages/presets/near-operation-file/src/index.ts

View workflow job for this annotation

GitHub Actions / release / snapshot

Property 'skipDocumentsValidation' does not exist on type 'PresetFnArgs<NearOperationFileConfig, { [key: string]: any; }>'.

Check failure on line 354 in packages/presets/near-operation-file/src/index.ts

View workflow job for this annotation

GitHub Actions / Validating dev-tests (cjs)

Property 'skipDocumentsValidation' does not exist on type 'PresetFnArgs<NearOperationFileConfig, { [key: string]: any; }>'.

Check failure on line 354 in packages/presets/near-operation-file/src/index.ts

View workflow job for this annotation

GitHub Actions / Validating dev-tests (esm)

Property 'skipDocumentsValidation' does not exist on type 'PresetFnArgs<NearOperationFileConfig, { [key: string]: any; }>'.
? { skipDuplicateValidation: true }
: options.skipDocumentsValidation,

Check failure on line 356 in packages/presets/near-operation-file/src/index.ts

View workflow job for this annotation

GitHub Actions / Testing exports integrity

Property 'skipDocumentsValidation' does not exist on type 'PresetFnArgs<NearOperationFileConfig, { [key: string]: any; }>'.

Check failure on line 356 in packages/presets/near-operation-file/src/index.ts

View workflow job for this annotation

GitHub Actions / release / snapshot

Property 'skipDocumentsValidation' does not exist on type 'PresetFnArgs<NearOperationFileConfig, { [key: string]: any; }>'.

Check failure on line 356 in packages/presets/near-operation-file/src/index.ts

View workflow job for this annotation

GitHub Actions / Validating dev-tests (cjs)

Property 'skipDocumentsValidation' does not exist on type 'PresetFnArgs<NearOperationFileConfig, { [key: string]: any; }>'.

Check failure on line 356 in packages/presets/near-operation-file/src/index.ts

View workflow job for this annotation

GitHub Actions / Validating dev-tests (esm)

Property 'skipDocumentsValidation' does not exist on type 'PresetFnArgs<NearOperationFileConfig, { [key: string]: any; }>'.
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,45 @@ 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: {},
presetConfig: {
baseTypesPath: 'types.ts',
},
schema: schemaDocumentNode,
schemaAst: schemaNode,
documents: testDocuments,
plugins: [],
pluginMap: {},
skipDocumentsValidation: {

Check failure on line 717 in packages/presets/near-operation-file/tests/near-operation-file.spec.ts

View workflow job for this annotation

GitHub Actions / Testing exports integrity

Argument of type '{ baseOutputDir: string; config: {}; presetConfig: { baseTypesPath: string; }; schema: DocumentNode; schemaAst: GraphQLSchema; documents: { location: string; document: DocumentNode; }[]; plugins: undefined[]; pluginMap: {}; skipDocumentsValidation: { ...; }; }' is not assignable to parameter of type 'PresetFnArgs<NearOperationFileConfig, { [key: string]: any; }>'.

Check failure on line 717 in packages/presets/near-operation-file/tests/near-operation-file.spec.ts

View workflow job for this annotation

GitHub Actions / release / snapshot

Argument of type '{ baseOutputDir: string; config: {}; presetConfig: { baseTypesPath: string; }; schema: DocumentNode; schemaAst: GraphQLSchema; documents: { location: string; document: DocumentNode; }[]; plugins: undefined[]; pluginMap: {}; skipDocumentsValidation: { ...; }; }' is not assignable to parameter of type 'PresetFnArgs<NearOperationFileConfig, { [key: string]: any; }>'.

Check failure on line 717 in packages/presets/near-operation-file/tests/near-operation-file.spec.ts

View workflow job for this annotation

GitHub Actions / Validating dev-tests (cjs)

Argument of type '{ baseOutputDir: string; config: {}; presetConfig: { baseTypesPath: string; }; schema: DocumentNode; schemaAst: GraphQLSchema; documents: { location: string; document: DocumentNode; }[]; plugins: undefined[]; pluginMap: {}; skipDocumentsValidation: { ...; }; }' is not assignable to parameter of type 'PresetFnArgs<NearOperationFileConfig, { [key: string]: any; }>'.

Check failure on line 717 in packages/presets/near-operation-file/tests/near-operation-file.spec.ts

View workflow job for this annotation

GitHub Actions / Validating dev-tests (esm)

Argument of type '{ baseOutputDir: string; config: {}; presetConfig: { baseTypesPath: string; }; schema: DocumentNode; schemaAst: GraphQLSchema; documents: { location: string; document: DocumentNode; }[]; plugins: undefined[]; pluginMap: {}; skipDocumentsValidation: { ...; }; }' is not assignable to parameter of type 'PresetFnArgs<NearOperationFileConfig, { [key: string]: any; }>'.
skipValidationAgainstSchema: true,
},
});

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

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

Check failure on line 737 in packages/presets/near-operation-file/tests/near-operation-file.spec.ts

View workflow job for this annotation

GitHub Actions / Testing exports integrity

Argument of type '{ baseOutputDir: string; config: {}; presetConfig: { baseTypesPath: string; }; schema: DocumentNode; schemaAst: GraphQLSchema; documents: { location: string; document: DocumentNode; }[]; plugins: undefined[]; pluginMap: {}; skipDocumentsValidation: boolean; }' is not assignable to parameter of type 'PresetFnArgs<NearOperationFileConfig, { [key: string]: any; }>'.

Check failure on line 737 in packages/presets/near-operation-file/tests/near-operation-file.spec.ts

View workflow job for this annotation

GitHub Actions / release / snapshot

Argument of type '{ baseOutputDir: string; config: {}; presetConfig: { baseTypesPath: string; }; schema: DocumentNode; schemaAst: GraphQLSchema; documents: { location: string; document: DocumentNode; }[]; plugins: undefined[]; pluginMap: {}; skipDocumentsValidation: boolean; }' is not assignable to parameter of type 'PresetFnArgs<NearOperationFileConfig, { [key: string]: any; }>'.

Check failure on line 737 in packages/presets/near-operation-file/tests/near-operation-file.spec.ts

View workflow job for this annotation

GitHub Actions / Validating dev-tests (cjs)

Argument of type '{ baseOutputDir: string; config: {}; presetConfig: { baseTypesPath: string; }; schema: DocumentNode; schemaAst: GraphQLSchema; documents: { location: string; document: DocumentNode; }[]; plugins: undefined[]; pluginMap: {}; skipDocumentsValidation: boolean; }' is not assignable to parameter of type 'PresetFnArgs<NearOperationFileConfig, { [key: string]: any; }>'.

Check failure on line 737 in packages/presets/near-operation-file/tests/near-operation-file.spec.ts

View workflow job for this annotation

GitHub Actions / Validating dev-tests (esm)

Argument of type '{ baseOutputDir: string; config: {}; presetConfig: { baseTypesPath: string; }; schema: DocumentNode; schemaAst: GraphQLSchema; documents: { location: string; document: DocumentNode; }[]; plugins: undefined[]; pluginMap: {}; skipDocumentsValidation: boolean; }' is not assignable to parameter of type 'PresetFnArgs<NearOperationFileConfig, { [key: string]: any; }>'.
});

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

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

0 comments on commit cc70f71

Please sign in to comment.