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

Better guard ergonomics #536

Closed
meh opened this issue Jun 5, 2021 · 6 comments
Closed

Better guard ergonomics #536

meh opened this issue Jun 5, 2021 · 6 comments
Labels
enhancement New feature or request

Comments

@meh
Copy link
Contributor

meh commented Jun 5, 2021

I've started using guards in my codebase and it would be nice if they could be a little more flexible.

Things I found a bit annoying so far:

  1. Taking a path instead of an ident so I can fully/partially scope guards instead of having to import them.
  2. Having to provide empty parentheses when the guard does not take any parameter.

What I'm going for is something like this:

#[graphql(guard(guard::Session))]

Instead of:

#[graphql(guard(SessionGuard()))]

Thanks!

@meh meh added the enhancement New feature or request label Jun 5, 2021
@meh
Copy link
Contributor Author

meh commented Jun 5, 2021

Oh also having to import async_graphql::guard::Guard for the proc macro to work is kind of annoying.

@sunli829
Copy link
Collaborator

sunli829 commented Jun 6, 2021

I've started using guards in my codebase and it would be nice if they could be a little more flexible.

Things I found a bit annoying so far:

  1. Taking a path instead of an ident so I can fully/partially scope guards instead of having to import them.
  2. Having to provide empty parentheses when the guard does not take any parameter.

What I'm going for is something like this:

#[graphql(guard(guard::Session))]

Instead of:

#[graphql(guard(SessionGuard()))]

Thanks!

Because of the limitation of procedural macros, I haven't thought of a better way to remove this annoying empty parentheses. 🙂

@meh
Copy link
Contributor Author

meh commented Jun 8, 2021

Ah, damn, that's understandable then, what about supporting paths instead of just an ident tho? 🐼

@sunli829
Copy link
Collaborator

sunli829 commented Jun 8, 2021

It should work, I am trying.

@sunli829
Copy link
Collaborator

sunli829 commented Jun 8, 2021

I have implemented it on the master branch. 🙂

@meh
Copy link
Contributor Author

meh commented Jun 8, 2021

You're the best! Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants