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

Custom Directives #344

Open
t1 opened this issue Nov 11, 2020 · 6 comments
Open

Custom Directives #344

t1 opened this issue Nov 11, 2020 · 6 comments

Comments

@t1
Copy link
Contributor

t1 commented Nov 11, 2020

I would like to be able to add Custom Directives to the generated schema. It would be convenient to add an @Directive annotation to my own annotation, i.e.:

@Directive(on = { FIELD, ARGUMENT })
public @interface Example {
    String value();
}

@Type
class SomeType {
    @Example("out")
    String field(@Example("in") int arg) { return null; }
}

...generates a schema:

type SomeType {
    field(arg: Int @example(value: "in")): String @example(value: "out")
}
@t1
Copy link
Contributor Author

t1 commented Nov 13, 2020

Some possible use-cases for Custom Directives:

  1. BeanValidation: firstName: String @size(max: 100) - this is already being checked in the server (at least in WildFly)
  2. Request Throttling: location: String @complexity(score: 30) - this could also be checked in the backend; see Support of a complexity evaluation mechanism to detect expensive operations #340
  3. RBAC: location: String @visibleFor(role: "HeroLocator") - this could also be checked in the backend some day

These directives would add a benefit for the client as "structured documentation".

@phillip-kruger
Copy link
Member

We already do 3 in the backend as well - what we can do is to make these available in the schema as directives, that would be cool...

@t1
Copy link
Contributor Author

t1 commented Nov 16, 2020

yeah, of course... I just forgot the @RolesAllowed annotation which already works, of course.

@KSmigielski
Copy link

Hi, I would like to help with this issue

@t1
Copy link
Contributor Author

t1 commented Mar 13, 2021

@KSmigielski : that would be great! If you need help, just ask!

@kito99
Copy link

kito99 commented Nov 14, 2024

KSmigielski still interested three years later?

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

No branches or pull requests

4 participants