-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update resolveFields and query behaviour in the Items API #5456
Conversation
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/keystonejs/keystone-next-docs/6L3eE3JLrw1uV7NTUfa3qskqnqJV |
🦋 Changeset detectedLatest commit: b46c2bd The changes in this PR will be included in the next version bump. This PR includes changesets to release 18 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Note I've updated the changeset from #5451 so the release notes are clearer, rather than adding a new one |
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit b46c2bd:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this. It makes the API a lot clearer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just want to explicitly block this on further discussion
Another change after more discussion:
The updated changelog: With the goal of making the Lists API (i.e (1) You can specify a string of fields to return with the new For example, to query a Post you would now write: const [post] = await context.lists.Post.findMany({
where: { slug },
query: `
title
content
image {
src
width
height
}`,
}); (2) Alternatively, there is a new set of APIs on For example, to query for the raw data stored in the database, you would write: const [post] = await context.db.lists.Post.findMany({
where: { slug }
}); |
This reverts commit f9d02cf.
…eystonejs/keystone into update-items-api-resolvefields
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 LGTM
Followup to #5451 after further discussion
NOTE: This has been changed again, see comment below. Leaving this previous description for context.
I think this is even clearer, and the API now "does what it says"
You have two options:
(1) Query specific fields by passing the
query
option, as a string:(2) Return the raw data stored in the database, by passing
resolveFields: false
For backwards compatibility the types and logic still accept a string value to
resolveFields
, I propose we leave it like that for now and narrow it to only acceptfalse
in a future release.