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

Add more field decorator options inside the prisma schema #21

Closed
JohannesKlauss opened this issue Oct 22, 2020 · 9 comments
Closed

Add more field decorator options inside the prisma schema #21

JohannesKlauss opened this issue Oct 22, 2020 · 9 comments
Labels
enhancement New feature or request

Comments

@JohannesKlauss
Copy link

JohannesKlauss commented Oct 22, 2020

It would be awesome to have a bit more control over how the CRUD resolvers are generated. For example there could be more options to the field decorator to include authorization like so:

model User {
  id     Int     @default(autoincrement()) @id
  /// @TypeGraphQL.field(name: "emailAddress")
  email  String  @unique
  /// @TypeGraphQL.field(authorized: ["User", "Admin"])
  posts  Post[]
}

Is this something you consider as a feature? I think this would greatly increase development speed.

@MichalLytek
Copy link
Owner

Duplicate of #11 🔒

@MichalLytek MichalLytek added the duplicate This issue or pull request already exists label Oct 22, 2020
@MichalLytek
Copy link
Owner

Actually, it's not a duplicate 😅

#11 refers to crud resolvers methods, however fields or relations also might need to set up authorization or other custom decorators.

Reopening to implement the same enhance map pattern but for model fields, as well as for input types (class-validator validation?) 😉

@MichalLytek MichalLytek reopened this Nov 11, 2020
@MichalLytek MichalLytek added enhancement New feature or request and removed duplicate This issue or pull request already exists labels Nov 11, 2020
@MichalLytek
Copy link
Owner

First iteration done in v0.9.1:
https://github.com/MichalLytek/typegraphql-prisma/releases/tag/v0.9.1

Next release will focus on enhancing other output types and gonna allow to put decorators on the class itself, not only on its fields.

@MichalLytek
Copy link
Owner

Second iteration is also done in v0.9.2 🚀 You can now add decorators for both model class itself as well as its fields:

const modelsEnhanceMap: ModelsEnhanceMap = {
  Director: {
    class: [Extensions({ isDirector: true })],
    fields: {
      movies: [Authorized()],
    },
  },
};
applyModelsEnhanceMap(modelsEnhanceMap);

Third iteration will allow to decorate other object types like the aggregate ones.

@CarlosBalladares
Copy link

Are there any plans for a applyInputTypesEnhanceMap

@MichalLytek
Copy link
Owner

@CarlosBalladares

Reopening to implement the same enhance map pattern but for model fields, as well as for input types

@MichalLytek
Copy link
Owner

MichalLytek commented Feb 23, 2021

Quick update - we now have support for adding decorators to:

  • crud resolvers
  • output types (like AggregateClient)
  • model types
  • input types
  • args types

The last part to do is adding decorators to relation resolvers 👀

@CarlosBalladares
Copy link

awesome!!! 💯

@MichalLytek
Copy link
Owner

MichalLytek commented Mar 3, 2021

Relation resolvers support has been added in 0dcc0f9, so closing this one 🔒

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

3 participants