Adrinalin4ik / Nestjs-Graphql-Tools

NestJS Graphql Tools is a flexible solution that provides a bunch of decorators for solving problems like n+1 request, filtering, sorting, pagination, polymorphic relation, graphql field extraction. It is fully based on decorators. To use it you can just add a decorator to your resolver.
GNU General Public License v3.0
80 stars 8 forks source link

Custom accessor in addition to foreign key #8

Closed dimamik closed 1 year ago

dimamik commented 1 year ago

It would be great to be able to do something like:

  @GraphqlLoader({
    accessor: (task: Task) => task.chunk.id,
  })
Adrinalin4ik commented 1 year ago

WoW, it looks good! Thank you for the suggestion, I'll take a look what I can do:)

It would be great to be able to do something like:

  @GraphqlLoader({
    accessor: (task: Task) => task.chunk.id,
  })

WoW, it looks good! Thank you for the suggestion, I'll take a look what I can do:)

dimamik commented 1 year ago

I've introduced it in this fork for our needs, so it should be pretty straightforward.

https://github.com/agh-kiwis/agh-kiwis/blob/82b7951493a407984ca6684e738f282a1405bc5d/libs/nestjs-graphql-tools/src/loader.ts#L211-L216

Adrinalin4ik commented 1 year ago

Btw, @Graphql has foreignKey parameter. Does it work for you?

dimamik commented 1 year ago

@Adrinalin4ik Nope, as I need to deal with nested relations.

Adrinalin4ik commented 1 year ago

Got it, will do that tomorrow.