2 ms·
I'd turn this question around. Why use it?
by edem 6y ago
I'd turn this question around. Why use it?
- Mountain_Skies 6y agoOne of the reasons why Facebook created GraphQL was to reduce the payload size of the results, which often include large amounts of data that the current task did not require. There are ways to address this with REST, mainly though creating additional endpoints, but that quickly grows out of control for complex applications and requires touching multiple application layers. With GraphQL, the consuming app specifies what it wants returned, and only that data is sent. For Facebook's mobile apps, this worked well because you might only want to retrieve a person's name and not care about the other 10,000 bits of personal data Facebook has accumulated about them.
- folmar 6y agoI've seen it adressed with and additional parameter ?field=list,of,those,you,want in a few big commercial applications. It did not file REST-way to me, but it is easy and works both server- and client-side.
- valenterry 6y agoSure. And then you also want to query subfields, you can extend your query parameter list with some specific scheme for that (e.g. `subfields=fieldX.subfieldX,fieldY.subfieldY` - and then you can enhance it with filters, mutations, recursion, introspection, types, documentation, deprecation features... and then you have built your own version of graphQL. At some point, it is better to leave the custom solution field and go for graphQL before rebuilding it.