graphql-codegen-vscode icon indicating copy to clipboard operation
graphql-codegen-vscode copied to clipboard

To be able to use custom config path

Open plevavas opened this issue 4 years ago • 3 comments

Thanks for this extension!

Graphql-codegen cli uses cosmiconfig to load config file. It would be great if we could set custom config path.

plevavas avatar Oct 12 '21 10:10 plevavas

+1 I prefer JSON config over YML and this extension doesn't seem to work with it.

patryk-smc avatar Oct 13 '21 11:10 patryk-smc

maybe a simple glob and support for multiple configs (mono repositories like nx)

import {sync} from 'fast-glob';

const configs = sync(`${firstWorkspaceDirectory()}/**/codegen.{yml,yaml}`)

Creating a Record<string, CodegenContext> where each codegen config holds their context.

for example:

{
  "apps/my-frontend/codegen.yml": {...},
  "libs/other/lib/codegen.yml": {...},
 ...
}

The codegen.yml could then use workspace relative paths:

# libs/other/lib/codegen.yml
generates:
  libs/invotheroice/lib/src/:
    preset: near-operation-file
    plugins:
      - typescript-operations
      - typescript-urql
# apps/my-frontend/codegen.yml
generates:
  apps/my-frontend/src/:
    preset: near-operation-file
    plugins:
      - typescript-operations
      - typescript-urql

lukasholzer avatar Oct 22 '21 17:10 lukasholzer

@patryk-smc this extension should now be able to load all extensions supported by codegen in version 0.9.6

I will add a config for custom path in 1.0.0

capaj avatar Nov 12 '21 15:11 capaj