MichalLytek / MichalLytek/typegraphql-prisma

Don't select the whole table

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

Description

**Is your feature request related to a problem? Please describe.**
The following query pulls the whole posts table in memory:
`
query{
posts{
id
}
}
`
If there are a large number of posts with large content, this can be an issue.

**Describe the solution you'd like**
Transform the selected graphql fields into prisma select and pass it to the prisma client.

**Additional context**
https://github.com/paljs/prisma-tools/blob/main/packages/plugins/src/select.ts

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reading the GraphQL selection handling and Prisma client calls in the resolver or generated CRUD code, then compare the approach in packages/plugins/src/select.ts from the linked paljs/prisma-tools project. Trace the sample posts query and determine how its selected fields reach Prisma. Done means large fields are not loaded when they are absent from the GraphQL selection, with relevant tests covering the behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
graphql, typescript
Domain
backend-api-design, databases
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.