News for hackers. Stuff that matters.
Re:GraphQL Performance Monitoring Is Hard by tjpnz on Saturday July 27, 2019 @03:52AM (#20540920)
>1. Fewer API round trips compared to REST. 2. Clients only download the data they need. No more REST silly patterns like BFF trying to support multiple client needs.

In most cases a thoughtfully designed REST API built according to HATEOAS shouldn't exhibit these problems. I've seen too many teams with a flawed understanding of both viewing GraphQL as some kind of silver bullet. Instead of stopping to consider their architecture they just rush out and implement GraphQL only to find themselves having significantly worse performance issues than they were having before.

Re:GraphQL Performance Monitoring Is Hard by strken on Saturday July 27, 2019 @04:32AM (#20541055)
My understanding of the advantage of GraphQL is that it allows you to load a structure like

    user {
      groups(first: 10) {
        posts(first 1) {
          content
          author {
            name
            address {
              state
            }
          }
        }
      }
    }
and have all the round-trips take place within a datacentre, instead of needing to query

    /user 
    /user/12/groups?limit=10
    /groups/34/posts?limit=1
    /posts/56
    /users/78
    /users/78/address
and without having to write a separate

    /top_posts_view
endpoint.

I don't understand from the description "a thoughtfully designed REST API built according to HATEOAS" what your proposal to solve this problem is.

Re:GraphQL Performance Monitoring Is Hard by JoachimSchipper on Saturday July 27, 2019 @05:23AM (#20541171)
A quick search suggests that GraphQL should usually cause one client -> server -> SQL-server query - i.e. only one network round trip. No?
Re:GraphQL Performance Monitoring Is Hard by biggestdecision on Saturday July 27, 2019 @05:51AM (#20541234)
Client-API round trips matter, because the latency is very high. API-DB latency will be much lower, so the number of round trips there is less important. GraphQL allows you to query any nested structure in one Client-API round trip, but there may be many API-DB round trips per query.
Re:GraphQL Performance Monitoring Is Hard by jeremyjh on Saturday July 27, 2019 @10:06AM (#20542087)
It is better to have the resolver aggregate data, than to have multiple calls from the client to do it. The earliest uses of GraphQL was as a service aggregater. I'd be curious to know where you are seeing this "advice".
Re:GraphQL Performance Monitoring Is Hard by strken on Saturday July 27, 2019 @05:46AM (#20541223)
I've only used it to aggregate backend services rather than as an SQL query builder, and this is also how it's used at Facebook.

I'd have concerns about writing business logic in resolvers. If I was using it with a single SQL db I'd probably write a separate non-GraphQL layer for business logic and keep the resolvers thin.

Re:GraphQL Performance Monitoring Is Hard by vmasto on Saturday July 27, 2019 @08:29AM (#20541719)
Can you expound on the concerns?
Re:GraphQL Performance Monitoring Is Hard by true_religion on Saturday July 27, 2019 @05:12AM (#20541138)
REST works, but it forces you to use a single endpoint at a time.

For example, let's say you have have two endpoints /albums/1/ and /users/2/ and want to query them both at the same time.

They're unrelated data, so following REST best practices would make them separate endpoints.

With GraphQL, they're seperate resolvers but you can write

   {
     albums { get(id: 1) { .... } }
     users { get(id: 2) { .... } }
   }

And combine them those two calls into a single query. Maybe this is also possible via REST, but I haven't seen it.
Re:GraphQL Performance Monitoring Is Hard by toast0 on Saturday July 27, 2019 @10:30AM (#20542178)
If the endpoints are unrelated and you know them both before querying either, you can certainly query them concurrently from nearly any client language.

GraphQL can do it, but I don't think that's a big strength, compared to the dependent queries it can do. Using the results from one query to drive a further query without going back to the client will save a bunch of time if the client is far from the server.

Re:GraphQL Performance Monitoring Is Hard by true_religion on Saturday July 27, 2019 @01:58PM (#20543205)
Sure you can make two queries concurrently, but does the server know you are doing that? With GeaphQL the server sees both queries at once, and can potentially optimize over that once someone notices that in their logs. And it expresses itself as a single network connection.

I do agree though with your point about dependent queries, though I have only used GraphQL for internal apis so my experience doesn’t include that sort of problem.

Re:GraphQL Performance Monitoring Is Hard by Aeolun on Saturday July 27, 2019 @08:05AM (#20541625)
Oh! This is interesting. I didn’t know I could do this too. That’s a bit nicer even than only the combining of nested calls that I was aware of.