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

Allow .graphqls as extension for schema-ast #10023

Merged
merged 1 commit into from
Jun 30, 2024
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
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 schema 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
Loading