3 ms·
> there's no way to receive a GraphQL response without the ability to dynamically allocate memory You can allocate a fixed amount of memory for a particular Gr
by paulddraper 10y ago
> there's no way to receive a GraphQL response without the ability to dynamically allocate memory
You can allocate a fixed amount of memory for a particular GraphQL response.
You can allocate a fixed amount of memory for a particular REST resource.
You cannot allocate a fixed amount of memory for an arbitrary GraphQL query.
You cannot allocate a fixed amount of memory for an arbitrary set of REST resources.
So...I agree with what you are saying. At the the level of a single HTTP request, there is more dynamism in GraphQL. But that's not a deep distinction; REST just presents that dynamism at a level above a single HTTP request.
---
Note: it is common for people to define sets of REST requests with function calls, but write GraphQL queries in a string. If you defined your set of REST requests in a string and wrote your GraphQL queries with function calls, you'd see many observations reversed.
- derefr 10y agoTo be clearer, what I was saying is that you can't predict how much memory you'll need to allocate for a GraphQL response given the particular query you've made, because there's no way to get the server to give you a guarantee that all the field types are scalars or length-limited strings (or arrays of known-typed maps whose members are all scalars or length-limited strings, etc.) In REST, you can, by Accept-ing only media-types that guarantee such a condition. But there's no way to annotate the "function calls" [field-accessors-with-attributes] that appear within a GraphQL request, to force the GraphQL backend to act in a similar way to a web server with regards to media types of associated fields. You can't say "for this response field, I only Accept these types", and then have the GraphQL backend realize that its response would be unwanted and throw away its work, sending back a 406 error instead.