graphql-code-generator-community
graphql-code-generator-community copied to clipboard
[near-operation-file-preset] Ability to customize file name pattern
I'm working on integrating near-operation-file-preset for a SvelteKit project. In SvelteKit's filesystem-based router, file names starting with +
are reserver for +page.ts
and +page.svelte
files, which have special meaning.
My goal is that I can use gql
tags in +page.ts
and +page.svelte
files, and have the respective types be generated in an adjacent __generated__
folder. The issue: If I configure the near-operation-file-preset to set an extension
like .generated.ts
, it creates files named like +page.generated.ts
. This causes an error in SvelteKit complaining about +
being a reserved character.
If I set filename
in the plugin config, I can create a single generated file, but when there are multiple different files with gql
tags in the same directory, it only creates a single types file with only one of the original file's operations contained within. It looks like during the generation process, it generates types for all the files in the directory, but overwrites the output each time, resulting in only having type definitions for one of the source files.
What I'm looking for is some way to customize the file name of generated files beyond extension
. Either a prefix
key, or perhaps even the ability to set a custom JS function for transforming names akin to namingConvention
would do.
Or maybe I'm just missing an existing way around this issue?