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

Schema documentation and Client-side logic #112

Closed
frankdugan3 opened this issue Aug 2, 2018 · 6 comments
Closed

Schema documentation and Client-side logic #112

frankdugan3 opened this issue Aug 2, 2018 · 6 comments
Labels
kind/feature A request for a new feature.

Comments

@frankdugan3
Copy link

frankdugan3 commented Aug 2, 2018

This looks really awesome, especially with the new features coming in 3.0!

I'm currently using schema directives to enforce permissions based on Apollo's docs. I've added two features that really benefit my app:

  1. The directive appends the field description with a markdown-rich explanation of the permissions rules so you can see the requirements right in GraphiQL/Playground.
  2. It generates (hackishly, and only in dev environment) TS definitions and objects that contain information about permissions rules so the client can proactively exclude fields or disable queries/mutations it predicts may be unauthorized.

So, I have a couple questions. I'm also happy to contribute to any of these features if they seem possible and interesting.

  1. I'm not sure how the introspection query works under the hood, but would it be possible for this library to append information to the descriptions of fields based on permissions rules?
  2. Any thoughts on how to expose the permissions rules to client-side logic? Obviously some require data from the query itself, but at least simple access rules, like isAuthenticated and isAdmin etc. could be derived.
@maticzav
Copy link
Owner

Hey, I thought I already replied to this, sorry for the delay. I love your idea! Unfortunately, we entirely rely on graphql-middleware. I think it would be possible to do some auto-generation which could turn out really cool, but I am not so sure about the description idea. It is possible, but I think we should find a bit more use cases to add such functionality to grpahql-middleware.

@maticzav maticzav added the kind/feature A request for a new feature. label Aug 29, 2018
@stale
Copy link

stale bot commented Oct 13, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Oct 13, 2018
@stale stale bot closed this as completed Oct 23, 2018
@Victordmdb
Copy link

Hi, I'm curious if there's a simple way to determine if the user has permission for mutations from the client? Or would it require an introspection query?

@maticzav
Copy link
Owner

maticzav commented Jun 4, 2019

@Victordmdb I am not sure I understand your question. From what I know, neither of the two would give you that information. One way I can imagine obtaining such information would be by forwarding a role in user's session information. That, however, would have to be determined by the business logic of your application, not the schema.

@Victordmdb
Copy link

@maticzav I'm testing out CASL which fits well with graphql-shield to handle permissions at every level.

@veeramarni
Copy link

@Victordmdb Will you suggest to use CASL based on your testing?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature A request for a new feature.
Projects
None yet
Development

No branches or pull requests

4 participants