MichalLytek / MichalLytek/typegraphql-prisma

Increase CrudResolvers granularity (only queries, mutations, etc.)

Open
#194 0 comments 9 reactions 0 assignees View on GitHub
enhancement priority:high
Dominant language
TypeScript
Stars
918
Forks
130
PR merge metrics
No merged PRs in 30d

Description

Is there an easy way to import all crudResolvers of a certain type for all models without having to import them individually each model? If not, can we add that as a new feature?

For example, I want to import all crudResolvers that are only queries (findOne, findMany, findUnique, etc.) for all of my models, but I want to exclude mutations (create, update, upsert, delete). I also want to import them for all of my models in one object, like with `crudResolvers`, and not have to import them individually for each model. That way if I add more models later to my schema, I don't have to worry about updating my imports as well.

Right now, I don't see an easy way to do this. I've tried some hacky solutions like deleting the mutation resolver methods from the `crudResolvers` prototype object, but the decorator metadata still remains so they still show up in the graphQL schema (though the functionality no longer works). Maybe a dynamic import solution would work, but that can get messy.

Can we add this in as a feature? Maybe it could be similar to how the `emitOnly` field works in the generator--we could specify to emit only queries, mutations, or specific crud operations. Let me know what you think.

Thanks!

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by tracing how `crudResolvers` are assembled and how the generator's `emitOnly` option selects operations. Define how a single aggregate of query-only, mutation-only, or selected CRUD resolvers should be exposed for all models, including how newly generated models are included; done means the resulting GraphQL schema contains only the requested operations without individual model imports.

Written by the indexing model from the issue text.

Assessment

Tech stack
graphql, typescript
Domain
api, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.