New to GraphQl @apollo/server. Need help related to architecture of scalable product development!

I am trying to create an express js server using apollo/server package to get the leverage of the GraphQl ecosystem. I am very new to graphQL. I have certain queries related to architecture modifications in the express server :

  1. First of all, I want to separate the business logic of my application in the service layer which will be responsible for the data.

  2. I want to separate the resolver and graphQl schemas into different files such as userResolver.ts, ticketResolver.ts, and userSchema, etc which will use the corresponding services for data manipulation. How can combine all the resolvers and schemas to provide apollo server. Note: I am not separating only the particular type such as query mutation in resolver but the whole resolver specific to service.

  3. As express js provides middlewares that can intercept between the req and res cycle on to route level and app level. But as graphQl works on single route ‘/graphql’ so how can create the middlewares for different services or routes. Lets say I dont want to authenticate all pages in my client.

If someone can create an empty architecture repo or a small coded todo app using of these requirements will be very helpful.
@lizhennessy @MichelleMabuyo

Hey there @Ashish_Sharma ! I checked with the team and we’ve got an example that might fit what you’re looking for. Unfortunately it’s not a boilerplate repo, but hopefully it helps you get an idea of how you might structure your own application.

  1. In the client directory, you can see how the logic is separated there.

  2. In the resolvers directory, you can see how the resolvers are separated into different files. resolvers/index.ts brings them all together.

  3. For middleware, you can check out the utils/server.ts file, with plugin examples for Sentry logging.

I hope that helps. If you have any other questions, feel free to drop by our Discord group. Folks who worked on this demo project might be better equipped to answer your questions!

Thanks for response @MichelleMabuyo , But as I said to you I am very beginner in GraphQl and this much heavy complex repo is not suitable for those who wanted to use GraphQl apollo in very first. I want a simple express app which contains above defined requirements. Well I figureout the above 2 points but not implemented. And the third point in which I wanted differenet middlewares of express working on based on request of user. Although this is impressive query language tool but its complexity or lacks of examples for different codebases are making it less useable for the beginners here.

Got it! I agree the codebase I linked is quite large and can be overwhelming.

Our current content on Odyssey is beginner-friendly, however it does not use Express middleware. If that’s ok with you to get started with GraphQL and Apollo, then I recommend taking the Lift-off series.

Then, the Apollo documentation should have a code snippet of how to make Apollo Server work with Express.

You can also use this JavaScript template to get an idea of how the resolvers can be structured to fit what you’re looking for.