Hacker News new | ask | show | jobs
by scjody 2645 days ago
So instead of running

  curl 'https://api.sunrise-sunset.org/json?lat=36.7201600&lng=-4.4203400&date=today'
I can deploy a bunch of code and then run

  curl -X POST -H "Content-Type: application/json" --data '{ "query": "{ hello, sun(lat: 36.7201600, long: -4.4203400, date: \"today\") { sunrise, sunset } }" }' <script-url>
Can someone explain why this is useful?
2 comments

Part of the benefit of edge implementations of serverless is that the scripts are deployed globally over a managed network. So deploying on the edge distributes the gateway as close to the user as possible (in this case IXs in major metro areas) and manages all of the traffic routing and loadbalancing. Which _almost always_ improves performance compared to a more traditional cloud implementation
I assume it's because the first example doesn't add "Hello World" which is the proof of concept of having one query return information on multiple entities.

Which in turn is an example of how GraphQL can serve to turn what can be many requests in a REST situation into one call.