generate multiple graphql.services based on documents array

Viewed 11

I have an angular app and would like to use the near-operation-file plugin to generate a graphql.service.ts in every folder where there is a .graphql file

This is my current codegen.yaml file

what it does is it goes through all the subdirectories that have a .graphql and generates a massive graphql.service.ts with all the mutations and types (current behaviour)

overwrite: true
# Where to get schema data
schema:
  - ./src/app/dependencies/graphQL/schema.json
# Where to output the services and the list of plugins
generates:
  ./src/app/base/services/graphql.service.ts:
    documents:
      - ./src/app/**/*.graphql
    plugins:
      - typescript-apollo-angular
      - typescript-operations
      - typescript

I've read the documentation and I know I'm supposed to do something like this using the near-operation-file plugin:

  src/types.ts:
    - typescript
  src/:
    preset: near-operation-file
    presetConfig:
      extension: .generated.tsx
      baseTypesPath: types.ts

but what would it be in my case? I don't understand what this does and how to implement it in my case.

src/types.ts:
  - typescript

I tried simply adding

src/:
    preset: near-operation-file
    presetConfig:
      extension: .generated.tsx
      baseTypesPath: types.ts

to my codegen.yaml file but it threw an error saying Unable to validate GraphQL document! does anyone have any ideas?

0 Answers
Related