Skip to content
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

Issue: Shield ACL rules not compatible with count query and nested operations (breaking proposal) #125

Closed
maoosi opened this issue Mar 15, 2023 · 5 comments
Assignees
Labels
is: bug Something isn't working package: client Client package
Milestone

Comments

@maoosi
Copy link
Owner

maoosi commented Mar 15, 2023

Problems

Base path not included in QueryParams.paths

query countPosts {
  countPosts
}
{
    "operation": "countPosts",
    "paths": [], # missing `/count/post`
}

Prisma reserved keywords like connect, connectOrCreate missing from QueryParams.paths

mutation createPost {
  createPost(
    data: {
      title: "Hello people"
      author: { connect: { id: 1 } }
    }
  ) {
    id
    title
  }
}
{
    "operation": "createPost",
    "paths": [
        "/create/post/author/id", # missing `/create/post/author/connect/id`
        "/create/post/title",
        "/get/post/id",
        "/get/post/title"
    ]
}

Proposed solution (breaking)

Update QueryParams.paths to:

  • Include base path such as [action][Model] (countPosts)
  • Include Prisma reserved keywords like connect, connectOrCreate, ...
  • Make the syntax closer to creating shield rules countPosts{,/**}
  • Allow to create more granular rules such as createPost/**/connect{,/**}

Example:

mutation createPost {
  createPost(
    data: {
      title: "Hello people"
      author: { connect: { id: 1 } }
    }
  ) {
    id
    title
  }
}

Before:

{
    "paths": [
        "/create/post/title",
        "/create/post/author/id",
        "/get/post/id",
        "/get/post/title"
    ]
}

After:

{
    "paths": [
        "createPost",
        "createPost/title",
        "createPost/author",
        "createPost/author/connect",
        "createPost/author/connect/id",
        "getPost",
        "getPost/id",
        "getPost/title"
    ]
}

Breaking changes:

Breaking for people using QueryParams.paths for custom business logic (most likely inside Hooks).

@maoosi maoosi added the is: bug Something isn't working label Mar 15, 2023
@maoosi maoosi self-assigned this Mar 15, 2023
@maoosi maoosi added the package: client Client package label Mar 15, 2023
@maoosi maoosi changed the title Issue: Shield ACL rules not compatible with count query and nested operations Issue: Shield ACL rules not compatible with count query and nested operations (breaking proposal) Mar 15, 2023
@maoosi maoosi moved this to Planned in Prisma-AppSync Roadmap Mar 15, 2023
@maoosi maoosi added this to the 1.0.0-rc.6 milestone Mar 15, 2023
@StephanDecker
Copy link

StephanDecker commented Mar 15, 2023

Thanks for considering these issues :-)

@cjjenkinson
Copy link
Contributor

This looks great thank you @maoosi

@maoosi
Copy link
Owner Author

maoosi commented Mar 27, 2023

Implementing the solution was a lot more changes and work than initially anticipated, but it is now ready and will be released as part of 1.0.0-rc.6.

@maoosi maoosi closed this as completed Mar 27, 2023
@cjjenkinson
Copy link
Contributor

@maoosi Great work here, when will this be released?

@maoosi
Copy link
Owner Author

maoosi commented Apr 17, 2023

@cjjenkinson thanks! A new version will be released this week.

@maoosi maoosi moved this from Planned to Released in Prisma-AppSync Roadmap Apr 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
is: bug Something isn't working package: client Client package
Projects
Status: Released
Development

No branches or pull requests

3 participants