FG
๐Ÿ’ป Software๐Ÿ—„๏ธ DatabasesVercel

Add way to exclude fields via query arguments or globally

Freshover 1 year ago
Mar 14, 20260 views
Confidence Score77%
77%

Problem

Problem Sometimes it is helpful to just remove some fields from the selection set like `password` so that we accidentally don't expose them to the frontend. Proposals Adding a `exclude` key in the arguments of the queries to easily exclude fields from the selectionSet just like `include` or `select`. [code block] Or [code block] Alternatives 1. Use query and list all the fields you want 1. Schema annotation 2. Manual omission via lodash or something !? Related - https://github.com/prisma/prisma/issues/2170 - https://github.com/prisma/prisma/issues/3246

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
High Confidence Fix
75% confidence92% success rate10 verificationsLast verified Mar 14, 2026

Solution: Add way to exclude fields via query arguments or globally

Low Risk

@thecodeah, @darioielardi, and @flybayer expressed concerns with this proposal. Each query you write needs to explicitly exclude private fields. They would prefer an "exclude-by-default" approach. To complicate matters, being able to somehow access excluded fields from the Prisma Client is important for tests. Any solution we decide on needs to have this feature. Solution A: add an attribute to

75

Trust Score

10 verifications

92% success
  1. 1

    @thecodeah, @darioielardi, and @flybayer expressed concerns with this proposal.

    @thecodeah, @darioielardi, and @flybayer expressed concerns with this proposal. Each query you write needs to explicitly exclude private fields. They would prefer an "exclude-by-default" approach.

  2. 2

    To complicate matters, being able to somehow access excluded fields from the Pri

    To complicate matters, being able to somehow access excluded fields from the Prisma Client is important for tests. Any solution we decide on needs to have this feature.

  3. 3

    Solution A: add an attribute to the schema

    Solution A: add an attribute to the schema

  4. 4

    One idea proposed by @darioielardi is to add an attribute in the schema that wil

    One idea proposed by @darioielardi is to add an attribute in the schema that will exclude a field. @flybayer suggested that if you want to include an excluded-by-default field (for tests) you could select that field explicitly.

Validation

Resolved in prisma/prisma GitHub issue #5042. Community reactions: 182 upvotes.

Verification Summary

Worked: 10
Partial: 2
Failed: 1
Last verified Mar 14, 2026

Sign in to verify this fix

Environment

Submitted by

AC

Alex Chen

2450 rep

Tags

prismaormpostgresqlkind/featuretopic:-client-apitopic:-extend-clienttopic:-exclude