Skip to content

Commit

Permalink
Allow custom suffix for generated query files
Browse files Browse the repository at this point in the history
  • Loading branch information
CarsonF committed Jul 27, 2023
1 parent 96ea17e commit 59be303
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/generate/src/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import type { Target } from "./genutil";
// generate per-file queries, then listen for changes and update
export async function generateQueryFiles(params: {
root: string | null;
options: CommandOptions;
options: CommandOptions & { suffix?: string };
client: Client;
}) {
if (params.options.file && params.options.watch) {
Expand Down Expand Up @@ -64,6 +64,7 @@ currently supported.`);
target: params.options.target!,
path,
types,
suffix: params.options.suffix,
});
for (const f of files) {
if (!filesByExtension[f.extension]) {
Expand Down Expand Up @@ -122,6 +123,7 @@ currently supported.`);
target: params.options.target!,
path,
types,
suffix: params.options.suffix,
});
for (const f of files) {
const prettyPath = "./" + adapter.path.posix.relative(root, f.path);
Expand Down Expand Up @@ -181,6 +183,7 @@ function generateFiles(params: {
target: Target;
path: string;
types: QueryType;
suffix?: string;
}): {
path: string;
contents: string;
Expand All @@ -192,7 +195,7 @@ function generateFiles(params: {
const outputDirname = adapter.path.dirname(params.path);
const outputBaseFileName = adapter.path.join(
outputDirname,
`${baseFileName}.query`
`${baseFileName}${params.suffix ?? '.query'}`
);

const method =
Expand Down

0 comments on commit 59be303

Please sign in to comment.