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 Decorator to a class Resolver #620

Closed
muco-rolle opened this issue Apr 29, 2020 · 0 comments · Fixed by #1297
Closed

Custom Decorator to a class Resolver #620

muco-rolle opened this issue Apr 29, 2020 · 0 comments · Fixed by #1297
Labels
Community 👨‍👧 Something initiated by a community Enhancement 🆕 New feature or request
Projects
Milestone

Comments

@muco-rolle
Copy link

Is your feature request related to a problem? Please describe.
It would be good to have a way to create a resolver class decorator so that we would not have to repeat the decorator on each method of the resolver class

Describe the solution you'd like
Creation of a custom decorator

export function AuthGuard(): any {
    return createMethodDecorator(async ({ context }, next) => {
        // decorator business logic
    });
}

We should be able to decorate a class resolver
and every Query, Mutation in the resolver is executed after the decorator

@Resolver()
@AuthGuard()
export class RecipeResolver {  
      @Query(() => [Recipe])
      recipes() {
             return [{ id: "1", name: "test" }];
       }

       @Query(() => Project)
        recipe() {
              return { id: 1, name: "test" };
        }
}

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

@MichalLytek MichalLytek added Community 👨‍👧 Something initiated by a community Enhancement 🆕 New feature or request labels Apr 29, 2020
@MichalLytek MichalLytek added this to Backlog in Board via automation Apr 29, 2020
@MichalLytek MichalLytek added this to the 1.x versions milestone Apr 29, 2020
@MichalLytek MichalLytek moved this from Backlog to To Do in Board Aug 30, 2020
@MichalLytek MichalLytek moved this from To Do to In progress in Board May 30, 2024
@MichalLytek MichalLytek modified the milestones: 2.x versions, 2.0 release May 30, 2024
@MichalLytek MichalLytek linked a pull request May 30, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Community 👨‍👧 Something initiated by a community Enhancement 🆕 New feature or request
Projects
Board
  
In progress
Development

Successfully merging a pull request may close this issue.

2 participants