Skip to content

Commit

Permalink
Allow .graphqls as extension for schema-ast
Browse files Browse the repository at this point in the history
  • Loading branch information
eddeee888 committed Jun 29, 2024
1 parent 61b6a94 commit cefdd1a
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/forty-ears-rule.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@graphql-codegen/schema-ast': minor
---

Allow .graphqls as extension
2 changes: 1 addition & 1 deletion packages/plugins/other/schema-ast/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ export const validate: PluginValidateFn<any> = async (
) => {
const singlePlugin = allPlugins.length === 1;

const allowedExtensions = ['.graphql', '.gql'];
const allowedExtensions = ['.graphql', '.gql', '.graphqls'];
const isAllowedExtension = allowedExtensions.includes(extname(outputFile));

if (singlePlugin && !isAllowedExtension) {
Expand Down
17 changes: 16 additions & 1 deletion packages/plugins/other/schema-ast/tests/schema-ast.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"!');
}
});

Expand Down Expand Up @@ -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 */ `
Expand Down

0 comments on commit cefdd1a

Please sign in to comment.