capaj / graphql-codegen-vscode

vscode extension which runs graphql-codegen whenever you save a query/mutation
https://marketplace.visualstudio.com/items?itemName=capaj.graphql-codegen-vscode
MIT License
68 stars 10 forks source link

To be able to use custom config path #6

Open plevavas opened 3 years ago

plevavas commented 3 years ago

Thanks for this extension!

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

patryk-smc commented 3 years ago

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

lukasholzer commented 3 years ago

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
capaj commented 2 years ago

@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