diff --git a/.changeset/forty-ears-rule.md b/.changeset/forty-ears-rule.md new file mode 100644 index 000000000000..4369914db3ee --- /dev/null +++ b/.changeset/forty-ears-rule.md @@ -0,0 +1,5 @@ +--- +'@graphql-codegen/schema-ast': minor +--- + +Allow .graphqls as extension diff --git a/packages/plugins/other/schema-ast/src/index.ts b/packages/plugins/other/schema-ast/src/index.ts index c696f954f2d8..2f593ce06e53 100644 --- a/packages/plugins/other/schema-ast/src/index.ts +++ b/packages/plugins/other/schema-ast/src/index.ts @@ -130,7 +130,7 @@ export const validate: PluginValidateFn = async ( ) => { const singlePlugin = allPlugins.length === 1; - const allowedExtensions = ['.graphql', '.gql']; + const allowedExtensions = ['.graphql', '.gql', '.graphqls']; const isAllowedExtension = allowedExtensions.includes(extname(outputFile)); if (singlePlugin && !isAllowedExtension) { diff --git a/packages/plugins/other/schema-ast/tests/schema-ast.spec.ts b/packages/plugins/other/schema-ast/tests/schema-ast.spec.ts index 51637da84bcd..36e8e97631d7 100644 --- a/packages/plugins/other/schema-ast/tests/schema-ast.spec.ts +++ b/packages/plugins/other/schema-ast/tests/schema-ast.spec.ts @@ -22,7 +22,7 @@ describe('Schema AST', () => { throw new Error(SHOULD_THROW_ERROR); } catch (e) { expect(e.message).not.toBe(SHOULD_THROW_ERROR); - expect(e.message).toBe('Plugin "schema-ast" requires extension to be ".graphql" or ".gql"!'); + expect(e.message).toBe('Plugin "schema-ast" requires extension to be ".graphql" or ".gql" or ".graphqls"!'); } }); @@ -73,6 +73,21 @@ describe('Schema AST', () => { expect(true).toBeFalsy(); } }); + + it('Should allow .graphqls extension when its the only plugin', async () => { + const fileName = 'output.graphqls'; + const plugins: Types.ConfiguredPlugin[] = [ + { + 'schema-ast': {}, + }, + ]; + + try { + await validate(null, null, null, fileName, plugins); + } catch (e) { + expect(true).toBeFalsy(); + } + }); }); describe('Output', () => { const typeDefs = /* GraphQL */ `