Open evsar3 opened 3 years ago
This could totally work. @kamilkisiela what do you think?
With mapperPatternExclude
, yes, looks good.
I would be interested in implementing this feature, but I would like a pointer or two before getting started.
I'm thinking it would make sense to add the check for mapperPattern
after the check for mappers
, around here
https://github.com/dotansimha/graphql-code-generator/blob/cf408868c119c6e2e6b7b79c845353da08547420/packages/plugins/other/visitor-plugin-common/src/base-resolvers-visitor.ts#L556-L559
Would that make sense?
(If you would rather discuss this over an actual PR, let me know and I will open one so we can discuss an actual implementation :) )
Is your feature request related to a problem? Please describe.
Not related to a problem. I'm using Mongoose and in order it to work properly I have to map the Mongoose Document interface of my models to the generated resolvers Types. The case it that the map list is getting quite big, once I have to manually add every new Mongoose model to the map list.
Describe the solution you'd like A pattern that can be set for the mappers to resolve would be very handy. Example:
The above expression would resolve for each Type of the schema and produce a result like: (Let's assume
TypeName
as equal toUser
)../mongoose/models/UserModel#UserDocument
For the expressions that could not be resolved to a real reference, the default behavior can be assumed. The maps explicitly set on
mappers
option, overrides the pattern one.An additional option
mapperPatternExclude
as a list of Types names, can be used to exclude some Types to be parsed by the pattern expression.Describe alternatives you've considered A plugin that implements such behavior.
Additional context Imagine a project with dozens or even hundreds of Types that have to be mapped.