HN Theater @HNTheaterMonth

The best talks and videos of Hacker News.

Hacker News Comments on
GraphQL Tooling, Today & Tomorrow

Coding Tech · Youtube · 115 HN points · 0 HN comments
HN Theater has aggregated all Hacker News stories and comments that mention Coding Tech's video "GraphQL Tooling, Today & Tomorrow".
Youtube Summary
Sean Grove of OneGraph reviews the most used GraphQL tools available today and discusses what needs to be done in the future in order to educate and inspire GraphQL users.


EVENT:
API days 2019


SPEAKER:
Sean Grove


PUBLICATION PERMISSIONS:
Original video was published with the Creative Commons Attribution license (reuse allowed)


ATTRIBUTION CREDITS:
Original video source: https://www.youtube.com/watch?v=gAjQ1mg614o
HN Theater Rankings

Hacker News Stories and Comments

All the comments and stories posted to Hacker News that reference this video.
Mar 19, 2020 · 115 points, 25 comments · submitted by sgrove
nitinreddy88
We are in the process of debating ODATA Api vs GraphQL for data analytics. Anyone with extensive experience can share some light/guide us.
sgrove
One example that's fun is being able to bring in the data to e.g. Excel - here's an example of a proof of concept we did to give an idea of what's possible with GraphQL https://youtu.be/IHPaDvXQWyA

Building that kind of tooling ad-hoc is going to be so difficult. I suspect that GraphQL is just in the early days of building this tooling, and everyone will be able to re-use it without additional work on their own part.

(it's also in the linked talk at 33m22)

_92eu
With HTTP2, it's now almost always better to go with a RESTful API, especially if you need to do heavy calculations and display dashboards with a lot of data.

You will be able to fine tune your cache settings and monitor the performance of your endpoints (https://medium.com/@__xuorig__/why-graphql-performance-monit...)

You will be able to fetch resources in parallel and start displaying data faster (GraphQL Apollo is also able to do some king of streaming, but it relies heavily on non-standard network hacks).

You will be able to use Vulcain (https://vulcain.rocks/) which will allow you to fetch your whole resource graph at once using HTTP2 Server Push.

The only reason you may choose GraphQL is if you need to go fast and want to profit from the DX of the awesome React libraries available such as Relay or Apollo.

tomnipotent
> With HTTP2, it's now almost always better to go with a RESTful API

How do RESTful API's benefit from HTTP2 that GraphQL does not?

> You will be able to fetch resources in parallel and start displaying data faster

GraphQL can send multiple queries per request. Also, it's still HTTP - there's nothing that prevents you from having the same HTTP fetching strategy as a RESTful API.

> You will be able to use Vulcain [...] fetch your whole resource graph at once using HTTP2 Server Push

Nothing to do with REST, and nothing that can't be implemented for GraphQL.

strken
This is misleading and parts of it aren't true. Comparing GraphQL to REST is apples to oranges and misses most of the advantages.

GraphQL is a way to dynamically generate API endpoints[0] from A) a schema describing a graph, B) a query describing the endpoint, and C) functions which fetch objects from the graph defined in A.

Why would this be useful? Can't you just write endpoints or use a single RESTful endpoint per model? Well, on some large projects, you have a very large number of endpoints supporting a slightly different set of views that are all based on the same data, and most of those endpoints load more data than they need. GraphQL allows you to replace an entire suite of presentation layers with a declarative schema that's smaller and more easily reasoned about, and which only loads what you actually need.

You also get some other things for free - n+1 queries happen within the data centre and are therefore faster, you can avoid opening a lot of HTTP1 connections, etc. - but these things are only side benefits. The core benefit is making your big procedural presentation layer smaller and more declarative.

[0] This is not strictly true, a GraphQL query isn't an endpoint, but for me they occupy the same conceptual space.

deckard1
> Comparing GraphQL to REST is apples to oranges

Just because you say that, doesn't make it true.

> most of those endpoints load more data than they need

GraphQL proponents seem to forget query parameters exist. It has never been the case that REST has to return more than you need. Never. Not now, not ten years ago. Why people keep repeating this obviously false claim is bizarre.

The hoops you have to jump through to get GraphQL efficient as off-the-shelf REST are rather insane. Caching, both client and server side, have to be entirely reinvented. What Apollo does may be open source but it's also proprietary. And at this point, a single corporation controls the entire stack. Without Apollo, GraphQL is a terrible joke.

strken
> GraphQL proponents seem to forget query parameters exist. It has never been the case that REST has to return more than you need. Never. Not now, not ten years ago. Why people keep repeating this obviously false claim is bizarre.

You need to use something that does the same thing as GraphQL, e.g. allows you to define a graph of relationships and then query them, and can have many of the same tradeoffs, e.g. not being cacheable or not allowing you to stream the result. If you like the other thing better than GraphQL (I've used https://jsonapi.org/ and https://loopback.io/, among others), by all means use it.

This is what I mean when I say comparing GraphQL to REST is apples to oranges. REST is general and broad and GraphQL is narrow and specific, so the comparison isn't meaningful unless we start talking about specific libraries, frameworks, specs, or patterns that use REST to do the same thing GraphQL does.

digitaltrees
Check out Graphiti.dev it shows how a few common sense conventions in REST give most or all the power of GraphQL.

I think the phrase “comparing apples to oranges” is a bit misleading in this context because it is normally used to imply that such comparison is impossible or not useful (i.e. a fruitless exercise, sorry, I couldn’t help it). But here there is a lot to compare.

REST is built with the basic infrastructure of the web in mind so massive amounts of infrastructure like caching, error messaging do need to be rebuilt. GraphQL has some real benefits so a comprehensive comparison is worth it. Ultimately both are an api design to facilitate getting data. It’s sort of like comparing Postgres to MongoDB. Yes there are major differences but the expected use is to store data. Comparing is crucial.

Either way. Have fun building cool stuff.

rojobuffalo
Prisma provides a really solid approach for a GraphQL project. https://www.prisma.io/features/graphql-api/ . Graphile(https://www.graphile.org/) is another really nice library for a more advanced approach. IMO the big pay-off of a GraphQL service is the clarity of how the frontend describes data dependencies. To capture that full benefit, you've gotta go with Relay. Facebook designed Relay and GraphQL in tandem to work nicely together. Apollo and Redux are mediocre, but people argue they have a "more approachable learning curve".
dominotw
when i make a graphql request in chrome request is an unformatted string. Is there an extension someone would recommend that would make it easy to spot server interactions in a formatted way.
striking
https://chrome.google.com/webstore/detail/graphql-network/ig...
swyx
great talk! :)
nailer
As a JS/TypeScript dev: just give me typing, DB schema, and an API in one place.

Currently we have TypeORM, which does typing and DB schema but requires you to make a separate API. And we have Prisma, which is a DB schema and API, but still requires you to maintain types.

hjanssen
The successor of Prisma, Prisma2 [0] does aim to solve the typing issue. It generates a fully typed JS/TS client that you can then use e.g. with autocompletion in VS Code. It is currently in preview, but they aim to release the first "stable" version in Q1 of this year, so pretty soon. You can check the current status at [1]. However, you can try it out right now by installing the preview version via npm.

I am currently playing around with it and although it has some rough edges in corner cases, for 99% of my use cases it was a breeze to work with. Particulary the integration with nexus via the nexus-prisma plugin [2] is plain awesome, i have never had a fully functional graphql endpoint standing in a timeframe of 1 hour.

I am using it in conjunction with NextJS and the resulting developer experience is great, i cant recommend enough to try it out

(I am not affiliated with prisma labs, just a happy user)

[0] https://github.com/prisma/prisma2

[1] https://www.notion.so/Is-Prisma-2-Ready-8b3fba3eaf5b4bf3ab71...

[2] https://github.com/graphql-nexus/nexus-prisma

nikolasburk
Nikolas from the Prisma team here, thanks a lot for the shoutout!

For people who want to learn more about using Prisma together with Nexus (which enables exposing DB models via GraphQL), I also recommend checking the next iteration of Nexus that we're currently working on (which will turn into a fully-fledged GraphQL application framework with TypeScript as a first-class citizen): https://nexus-future.now.sh/#/

Let me know if you have any questions!

Lx1oG-AWb6h_ZG0
I’ve found graphql-codegen (https://graphql-code-generator.com/) to be very robust and easy to use. It takes in your schemas and can generate typings for your resolvers, queries, fragments etc. it can even generate helper hooks and HOCs for Apollo client or Relay.
goldcaddy77
I felt the same way and that’s why I built Warthog - https://warthog.dev. It’s a Node.js code-first GraphQL framework written in TypeScript that utilizes both TypeORM and TypeGraphQL under the hood. You add your resolvers and data models, add Warthog’s decorators and you get an auto-generates GraphQL schema complete with sorting, filtering and pagination. It’s also built to be flexible, as auto-generated GraphQL APIs typically limit your flexibility. Check it out - seems to check your boxes.
protonimitate
Curious, what do you do to maintain types? You can hack together a script or client to pull graphql schema from an endpoint and generate types using Apollos code gen (similar to [0]).

[0] - https://medium.com/open-graphql/automatically-generate-types...

nailer
Previously, I made something like TypeORM to re-use TypeScript types on a schema-less database. On my current project I'm using TypeORM itself.
ascagnel_
Ideally, GraphQL would sit between your DB/DB schema and APIs.

Also, the Relay compiler will emit Flow types in its compiled fragments by default, and can be configured to emit TypeScript types instead (AFAIK, you can't generate both types simultaneously).

https://relay.dev/docs/en/type-emission

aabbcc1241
My approach is to use code generation tool to handle the typing and API (server side routing and client side SDK) in one-step.

DB side is not handled by the tool because that's a blackbox the client don't need to know.

adamkl
I always hesitate to model an externally facing API to match the underlying database schema because you end up coupling consumers of the API to its internal implementation. Mind you, I'm coming from an enterprise background where systems live way longer than you expect them so, so you need that flexibility.

If that's not a concern, and you want speed/ease of development, take a look at TypeGraphQL [1]. They have a couple of examples [2][3] of how nicely it plays with TypeORM. You can create one set of domain object classes, annotate them with decorators for both TypeGraphQL and TypeORM, and then expose a GraphQL schema that matches the underlying database with a minimal amount of code (you could probably even get clever with some generic fucntions to cut down the code you'd need to write for the resolvers).

[1] https://typegraphql.com/ [2] https://github.com/MichalLytek/type-graphql/tree/v0.17.5/exa... [3] https://github.com/MichalLytek/type-graphql/tree/v0.17.5/exa...

k__
"I always hesitate to model an externally facing API to match the underlying database schema"

True.

Would be nice to have some kind of graphical tool, that would allow to model these things.

Add databases

Extract the schemas from these databases automatically, which should be trivial with SQL databases

Create GraphQL types manually

link the types up with the databases (the tricky part, especially with multiple different databases)

jayd16
Agreed. Api, business logic, and normalized DB all have different requirements. Smashing them together works great for prototyping but in the long run it leads to pain.
nailer
Business logic is seperate from typing, schemas and APIs. APIs and schemas are the same thing - the API is literally a query language for the DB.
adamkl

  the API is literally a query language for the DB
No, SQL is literally a query language for the DB.

The API is the contract you define for how people with interact with your application. While some people may choose to model this after their underlying database, conceptually, they are very different.

On small applications, maybe you can get away with treating them as one and the same, but for longer-lived applications which need to integrate and co-exist with other systems/services, that choice can come back to bite you.

I'm not saying you shouldn't/can't treat them as the same thing, just be sure you know the trade-offs and long-term repercussions.

HN Theater is an independent project and is not operated by Y Combinator or any of the video hosting platforms linked to on this site.
~ yaj@
;laksdfhjdhksalkfj more things
yahnd.com ~ Privacy Policy ~
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.