7 ms·
Apollo Server 1.0 – GraphQL Server for Node.js Frameworks
- throwaway2016a 9y agoI never quite understood Apollo. I've written GraphQL servers using just the Node.js GraphQL implementation and they haven't been much code. Barely more boilerplate than the Apollo example given. I'll have to dive into the code myself when I have some free time but can anyone explain to me what value this adds specifically? I am assuming it does add value and I'm just not seeing it.
- djmashko2 9y agoHey, I'm on the Apollo team! As mentioned in the blog post, this is just a thin wrapper around the regular GraphQL.js implementation, with a few small bells and whistles added! The intention of this library isn't to change a lot about how GraphQL servers are written, it's just a stable, community focused library to bind your GraphQL server to a schema.
- throwaway2016a 9y agoHi djmashko2, thank you for your reply and keep up the good work. I'm not sure that answers my question though. I'd like to know which things it makes easier. Maybe a side by side with the "traditional way" vs "the Appolo way" Looking at the website, it looks like it makes the benefit of Apollo client relatively clear, I'm still not sure about the server piece.
- djmashko2 9y agoThis is a great answer: https://news.ycombinator.com/item?id=14816423 https://news.ycombinator.com/item?id=14816423
- batmansmk 9y agoFrom the doc: Comparison with express-graphql - express-graphql works with Express and Connect, Apollo Server supports Express, Connect, Hapi, Koa and Restify. - Compared to express-graphql, Apollo Server has a simpler interface and supports exactly one way of passing queries. - Apollo Server separates serving GraphiQL (an in-browser IDE for exploring GraphQL) from responding to GraphQL requests. - express-graphql contains code for parsing HTTP request bodies, Apollo Server leaves that to standard packages like body-parser. - Apollo Server includes an OperationStore to easily manage whitelisting. - Apollo Server is built with TypeScript.
- throwaway2016a 9y agoThank you for digging that up. You don't need to use express-graphql to use graphql on a server so that comparison is only meaningful if you already use a wrapper... I'm was curious why a wrapper is even needed. The base GraphQL.js library is not complicated. The Apollo team member himself even said the wrapper is "thin."
- danr4 9y agoCouldn't find if Apollo solves the database round trips issue with GraphQL (the joins/n+1 problem). Can anybody shed a light on it?
- tylerbainbridge 9y agoIt does not-- we've been using graphql intensively with relationship-heavy graph data and join-monster seems handle this gracefully. join-monster.readthedocs.io
- throwaway2016a 9y agoWow! Thank you, I have been looking for something like this. I use mostly NoSQL which typically doesn't do joins (unless it is a graph database) but this looks really usefully for when I do have a SQL database to work with.
- obi1kenobi 9y agoIf you use a graph database, something like the GraphQL compiler project might be useful: https://github.com/kensho-technologies/graphql-compiler https://github.com/kensho-technologies/graphql-compiler Primer on how to use it: https://blog.kensho.com/compiled-graphql-as-a-database-query-language-72e106844282 https://blog.kensho.com/compiled-graphql-as-a-database-query... I work at Kensho and we use it with queries that are 10+ levels of nesting with no problems.
- johnymontana 9y agoInteresting approach for using GraphQL with a graph database. There is also an integration for Neo4j [1] that works similarly (it translates GraphQL to Cypher), however it also exposes Cypher in GraphQL through a @cypher directive, which maps complex graph traversals/aggregations to a single GraphQL field. [1] https://www.npmjs.com/package/neo4j-graphql-cli https://www.npmjs.com/package/neo4j-graphql-cli
- ruslan_talpa 9y ago
- aarohmankad 9y agoIs this a direct replacement for graphql-server-express? I've been using it while following along the backend JS tutorial at howtographql.com and was wondering if it's now outdated and what the migration would look like.
- djmashko2 9y agoIt's exactly the same thing but renamed - we're going to make both names work for a few weeks and then deprecate the graphql-server name after all the resources are updated. It's exactly the same, just change your import to "apollo-server-express"
- aarohmankad 9y agoAwesome! I would suggest updating your documentation, as there are some places where the graphql-* variant is mentioned.
- djmashko2 9y agoJust did it, thanks so much!
- cutler 9y agoSo we now have React/Webpack + Redux + Apollo + GraphQL + Node + Pogstgres where once we had Rails/PHP/Django + Postgres. Someone hit me over the head because I don't get how all this is progress. There's no way I can teach web development to a beginner if there are so many layers between request and response.
- Blackstone4 9y agoyou're right there is a lot of tooling/layers if it helps, Apollo has Redux built into it so you don't need a store. With this I reduced the size of my small app quite significantly by removing reducers, actions and the store files. I've been using React + Apollo + GraphQL on the frontend and Graph.cool as a BaaS which has been great so far.... admittedly I'm a beginner (starting from my experience as a Java developer 7 years ago)
- cle 9y agoI don't really understand this criticism. If your web app is simple/static enough, then by all means use Rails. Everything will be simpler. But there are an entire class of applications that can't be built with that stack.
- parasubvert 9y agoThat's a very bold statement: "can't be built with that stack". A large portion of apps aren't built with Node or React, they're built with, say, Rails, Java/Spring or .NET backends and a front end framework like Angular. I get the theory behind React, the reality is that it is often a complete mess.
- cutler 9y agoSince when was Rails limited to "simple/static" sites? I see the opposite all over the place these days - React + entourage for the most basic dynamic sites.
- toomim 9y agoI totally agree! We keep adding more layers to the web stack. Even Django and Rails themselves were added complexity! I've actually built a solution to this problem called Statebus: https://stateb.us https://stateb.us It takes a unique approach to the problem — instead of building more layers in the web stack, it builds support for change directly into HTTP itself! It turns out that if HTTP supports changing pages, and keeping things synchronized, you don't need web frameworks at all anymore.
- pier25 9y agoThe image is pretty misleading. It looks as if GraphQL server connects you to REST and SQL. In fact you simply have functions called resolvers where you write your logic to get data from wherever you want. SQL, NoSQL, API, filesystem, etc.
- djmashko2 9y agoYeah the diagram is intended to represent where GraphQL usually sits in your architecture.
- joesb 9y agoI think the idea is that you shouldn't want to have GraphQL server code containing business logic code in it. GraphQL should just be proxy layer between actual client and the actual, multiple, APIs.
- pier25 9y agoBut then why connect it to SQL and Redis?