Skip to content

Commit 8f864ef

Browse files
authored
Allow .graphqls as extension for schema-ast (#10023)
1 parent 61b6a94 commit 8f864ef

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

.changeset/forty-ears-rule.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@graphql-codegen/schema-ast': minor
3+
---
4+
5+
Allow .graphqls as schema extension

packages/plugins/other/schema-ast/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ export const validate: PluginValidateFn<any> = async (
130130
) => {
131131
const singlePlugin = allPlugins.length === 1;
132132

133-
const allowedExtensions = ['.graphql', '.gql'];
133+
const allowedExtensions = ['.graphql', '.gql', '.graphqls'];
134134
const isAllowedExtension = allowedExtensions.includes(extname(outputFile));
135135

136136
if (singlePlugin && !isAllowedExtension) {

packages/plugins/other/schema-ast/tests/schema-ast.spec.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ describe('Schema AST', () => {
2222
throw new Error(SHOULD_THROW_ERROR);
2323
} catch (e) {
2424
expect(e.message).not.toBe(SHOULD_THROW_ERROR);
25-
expect(e.message).toBe('Plugin "schema-ast" requires extension to be ".graphql" or ".gql"!');
25+
expect(e.message).toBe('Plugin "schema-ast" requires extension to be ".graphql" or ".gql" or ".graphqls"!');
2626
}
2727
});
2828

@@ -73,6 +73,21 @@ describe('Schema AST', () => {
7373
expect(true).toBeFalsy();
7474
}
7575
});
76+
77+
it('Should allow .graphqls extension when its the only plugin', async () => {
78+
const fileName = 'output.graphqls';
79+
const plugins: Types.ConfiguredPlugin[] = [
80+
{
81+
'schema-ast': {},
82+
},
83+
];
84+
85+
try {
86+
await validate(null, null, null, fileName, plugins);
87+
} catch (e) {
88+
expect(true).toBeFalsy();
89+
}
90+
});
7691
});
7792
describe('Output', () => {
7893
const typeDefs = /* GraphQL */ `

0 commit comments

Comments
 (0)