Do I need a Appollo server setup in my project? I have a collection in a Account in Mongodb?

I don’t understand if I need to have an Apollo server setup in my React project? when I am able to execute realm queries with a realm endpoint using Apollo Client in my project?.. I don’t understand why do I need to have an Apollo server in my React App which is supposed to be a Client side ( front end)?.. I am new to using Apollo I am not so sure if I have a full understanding on this…As for now I only have Apollo Client setup in my project… Any help would be welcome!

Hey there. Apollo Server is a Node.js GraphQL server meant to run as a layer over your backend in the same way you might run a REST API.

React is for web apps, where you’re writing code to run in the browser. You’d use Apollo Client in your React project which is useful for sending queries to your backend (a GraphQL server).

Thanks for the answer. I am still a bit confused because…I am a bit new to this . Sorry if my questions sound silly.

  1. Why do we need to write the code for the Apollo Server along with the React Js ( Client Code )?
  2. Is the Apollo Server a communicator between the Client code and the GraphQL?
  3. Why do we need to use the Apollo Server ( Are there any benefits)? When I can directly make calls to the GraphQL server using Apollo Client?

No need to apologize! We were all new to this once :slight_smile:

#1) When you set up your React app to make a GraphQL request, you’re sending that request to some GraphQL server (which could be built with Apollo Server, or a different tool), which knows how to get the data you asked for and send it back to the client. There needs to be a GraphQL server built somewhere, so that your client requests get sent to an actual server that can respond with data, but that server doesn’t have to be inside your client code.

If you’re working through the Lift-off courses on Odyssey, we have you build out the server and the client so that you can get a sense of how all the pieces fit together. But in a real-world project, if you’re working on a big team, you might have some devs that only work on the client side React stuff, while other devs only work on the back-end Apollo Server stuff.

#2) The Apollo Server is the GraphQL side of things. It’s what listens for incoming GraphQL operations from clients & uses the GraphQL schema and resolver functions to get all the requested data and send it back to the client. The Journey of a GraphQL query lesson (in the Lift-off II course on Odyssey) explains the process in more detail. (We also have it in blog-post form, if you’d prefer!)

#3) This answer is similar to #1. If you don’t have a GraphQL server built somewhere, then the requests you send from Apollo Client don’t have anywhere to go. If you use Apollo Server to build your GraphQL server, you get benefits like built-in classes for connecting to different types of data sources (like REST APIs or databases).

But if you already have an existing GraphQL server built out, then you would configure Apollo Client to send your GraphQL requests there instead (and you wouldn’t need to build out another GraphQL server with Apollo Server).

Hope that helps!