keystone icon indicating copy to clipboard operation
keystone copied to clipboard

Using the List Item API with context

Open junaid33 opened this issue 4 years ago • 1 comments

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:

  1. Clone and run locally: https://github.com/junaid33/next-lite
  2. Go to localhost:3000/signin and signin using: [email protected] and helloworld as password
  3. 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.

junaid33 avatar Apr 14 '21 22:04 junaid33

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. :)

stale[bot] avatar Sep 11 '21 00:09 stale[bot]

@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.

dcousens avatar Nov 14 '23 01:11 dcousens