dotansimha / dotansimha/graphql-code-generator-community
option to generate only one file using near-operation-file
- Dominant language
- TypeScript
- Stars
- 137
- Forks
- 195
- Avg merge
- 6h 20m
- Merged PRs (30d)
- 16
Description
We have a monorepo project structure with react code in a separate package and `client state` in a separate package.
```
packages
client-react/
src/
generated-model.tsx
client-state/
src/
generated-model.ts
```
So we would like to generate `.tsx` types in `react package` and rest in `client state`. And we want to add the baseTypes generated in `client state` as follows in the generated `.tsx` file in react package.
```
/* tslint:disable */
import { AddCounterStateMutation, AddCounterStateMutationVariables, AddCounterMutation,
AddCounterMutationVariables, CounterStateQuery, CounterStateQueryVariables,CounterQueryQueryVariables,
CounterQueryQuery, OnCounterUpdatedSubscription, OnCounterUpdatedSubscriptionVariables,
} from '@project/client-state'
```
The feature request is almost close to `near-operation-file` preset but instead of generated files for each `operation`, we want only one file generated in the `client-react` package and import any required types from `client-state` based on baseType location (or package import).
Right now we manually update `add` section when generating `.tsx` file react package as follows
```
overwrite: true
schema: "./servers/backend-server/generated-schema.graphql"
generates:
typings/graphql.d.ts:
plugins:
- typescript-graphql-files-modules
packages/client-state/src/generated-models.ts:
schema: "packages/client-state/src/**/*.graphql"
documents: "packages/client-state/src/**/*.gql"
config:
noNamespaces: true
contextType: ./interfaces/context#MyContext
withMutationFn: false
withHOC: false
withComponent: false
plugins:
- add: |
/* tslint:disable */
- typescript
- typescript-operations
- typescript-resolvers
- typescript-react-apollo
packages/client-react/src/generated-model.tsx:
schema: "packages/client-state/src/**/*.graphql"
documents: "packages/client-state/src/**/*.gql"
config:
withMutationFn: true
withHOC: true
withComponent: true
plugins:
- add: |
/* tslint:disable */
import { AddCounterStateMutation, AddCounterStateMutationVariables, AddCounterMutation,
AddCounterMutationVariables, CounterStateQuery, CounterStateQueryVariables,CounterQueryQueryVariables,
CounterQueryQuery, OnCounterUpdatedSubscription, OnCounterUpdatedSubscriptionVariables,
} from '@project/client-state'
- typescript-react-apollo
```
Let me know if this something you would like to add a feature?
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.