keystone
keystone copied to clipboard
Using the List Item API with context
Bug report
Please use this form for bug reports only. If you have a question, feature request or want to chat with us, please select the appropriate option here - https://github.com/keystonejs/keystone/issues/new/choose
Describe the bug
The next-lite example uses the List Item API to interact with Keystone
import { lists } from '.keystone/api';
const posts = await lists.Post.findMany({ resolveFields: 'slug title' });
But when I add auth to the schema and restrict access control to only show posts the user owns, the lists API still returns all the posts. The graphQL playground only returns the posts owned by the user.
How can I make the the List Item API respect access controls like the playground does? I saw one way was to use context.lists but how we access context on getStaticProps and getServerSideProps?
To Reproduce
Steps to reproduce the behaviour. Please provide code snippets or a repository:
- Clone and run locally: https://github.com/junaid33/next-lite
- Go to localhost:3000/signin and signin using: [email protected] and helloworld as password
- You will get redirected to localhost:3000 and see all the posts when Gerald only owns 1 post
Expected behaviour
Only "Gerald's post" should be showing since that's what the graphQL allPosts search shows.
It looks like there hasn't been any activity here in over 6 months. Sorry about that! We've flagged this issue for special attention. It wil be manually reviewed by maintainers, not automatically closed. If you have any additional information please leave us a comment. It really helps! Thank you for you contribution. :)
@junaid33 we cannot reproduce this, and your example is many major versions behind. Please open a new issue if you have can still replicate this problem.