DEV Community

loading...
Cover image for What's the recommended Nest.js, GraphQL, Mongo/Mongoose folder structure?

What's the recommended Nest.js, GraphQL, Mongo/Mongoose folder structure?

ugglr profile image Carl-W ・1 min read

I've been investing quite a lot of hours into figuring out the recommended folder structure for a Nest.js + MongoDB/Mongoose + GraphQL

And while I think I've come to a structure that will match with the docs, I'm not sure? Anyone who have a good grasp of scaling a nest project with this particular stack?

I've raised an issue at the project github: nest/graphql

This is the structure I've landed on 👇

root
    | src
        | main.ts
        | app.module.ts 
        | app.service.ts
        | constants.ta
        | database
            | database.module.ts
            | database.provider.ts
        | users
            | users.module.ts
            | users.resolver.ts
            | users.service.ts
            | users.provider.ts
            | interfaces
                user.interface.ts
            | schemas
                user.schema.ts
            | inputs
                | create-user.input.ts
                | delete-user.input.ts
                | update-user.input.ts
                | ...
            | dto
                | get-user.dto.ts
                | get-users.dto.ts
                | ...
Enter fullscreen mode Exit fullscreen mode

Is this the recommended structure? or how is it supposed to look?

I've been looking at the docs and the following repositories:

Discussion (0)

pic
Editor guide