r/Nestjs_framework • • Feb 26 '21

10 Things Every Nest.js Developer Should Know

https://js.plainenglish.io/10-things-every-nest-js-developer-should-know-911dec32f66a
38 Upvotes

11 comments sorted by

8

u/markus_h97 Feb 26 '21

Be really careful with this barren/index.ts imports. They can lead to circular dependencies and really buggy behaviour really fast

1

u/[deleted] Feb 28 '21

Can you provide an example? I never had a problem with circular dependencies this case

2

u/markus_h97 Feb 28 '21

https://docs.nestjs.com/fundamentals/circular-dependency even stated in the orange box in the official dependencies

1

u/[deleted] Mar 02 '21

thanks for pointing it out, never had a problem with the barrel imports

3

u/spacechimp Feb 27 '21

Never import from a barrel from a file that is in the same barrel. As long as you follow that rule you'll be fine most of the time.

4

u/zebbadee Feb 26 '21

Thanks for the @Exclude tip!

3

u/Pefii Feb 27 '21

If you apply logic to the object and want to apply something similar, you can take a look at Typescript's Omit Type

4

u/zoomzoomceilingfan Feb 26 '21

A lot of cool things in here. Thanks. Would love some more content like this.

5

u/Dan6erbond Feb 26 '21

Check out my blog post on GraphQL-Utils if you use NestJS for GraphQL projects!

3

u/Dan6erbond Feb 26 '21

I've been working with NestJS for quite some time now and agree with this article! For those using NestJS with GraphQL, I wanted to mention I'm the author of a package called GraphQL-Utils which can help you make more efficient queries to your database by introspecting the GraphQLResolveInfo beforehand. I wrote a short blog post on its usage and the nestjs-graphql-utils package which is found in the same repository wraps those utilities in NestJS decorators!

2

u/welterwerk Feb 28 '21

Yup NestJs is quite awesome, but as you said it’s still a very young framework and almost each day I realize that there’s lack of something. But still – it has huge potential and it’s really enjoyable at work.

Great article, looking forward for more!