News for hackers. Stuff that matters.
Re:Hacker News Clone Using GraphQL and React by altano on Sunday October 01, 2017 @10:57PM (#15381429)
Declaring what data your UI binds to is not a side effect, so co-locating GraphQL queries with your component doesn't necessarily introduce side effects. You don't have to co-locate GraphQL mutation queries to your component, you can just have your event handlers (or other mutation-creating events) handled elsewhere in your app.

> What happens when two components used in two totally different areas of a single page need common data? Relying on a cache feels like a hack.

When declaring what data you rely on is as simple as a GraphQL query, it's basically like declaring what data goes in your component. It's NOT like building ORM layers directly into your UI components.

Re:Hacker News Clone Using GraphQL and React by nevir on Monday October 02, 2017 @01:40AM (#15381906)
It certainly does introduce side effects (by default, for Apollo or Relay):

* A network request is kicked off if the cache doesn't contain the data the component declares a dependency on.

* other components that depend on any part of the requested subgraph will update when the response comes in

* query observers (which HoC'd components really are) will similarly fire, potentially triggering other side effects in your application

Re:Hacker News Clone Using GraphQL and React by altano on Tuesday October 03, 2017 @12:14AM (#15390095)
If you include enough in your definition of side effect, everything must have a side effect. Otherwise you wouldn’t be doing it. A pure function that adds two numbers and returns the result has left your system in a different state than it was in before it ran.

Data binding has side effects and the implementation of the thing doing the binding may cause things to happen, may cause some state to change. But I still wouldn’t consider the declarative data binding itself to have side effects.