Git Product home page Git Product logo

Comments (2)

Pancia avatar Pancia commented on July 16, 2024

Can you elaborate on why this wouldn't be solved by a follow on read?
Are you trying to mutate a non untangled server?

from untangled-client.

Pancia avatar Pancia commented on July 16, 2024

Copied from @awkay on slack:

The Om model is that mutations can remap tempids. There is no return value. The reason for this is that there is no query, so there is no way to merge that result into your database. Thus, the follow-on remote read.

This is a common misconception about the overall model.

The model is that the mutation is abstract. The UI and Server have no coupling. The server has no idea what you're showing, and the client has little idea (other than advertised keywords on the mutation...which isn't documented well, but is part of Om) what the server is really doing.

So, in order to fix this gap, the client specifically asks for reads on the data that it knows it is displaying that could have changed on the server.

E.g.
Say you have a mutation add-friend. The server could return all manner of information: the new friend count, a success code, the list of current friends.
Now you're tempted to make a mutaiton for every possible return value? Or just send it all back?
None of that is nearly as simple as the UI directly saying: do this, and then I need to know this other thing.

If you read the Om docs David mentions listing keys on a mutation. These are where you put advisory documentation on your mutation as to what data items the mutation affects, so that a UI programmer can read that (as documentation) and decide what to explicitly query.

I'd recommend documenting the affected keys in whatever way makes sense for your developers, because this is a point of difficulty (and maintenance), though in practical systems it is pretty obvious what things you might want to read because the mutation is an abstraction with general meaning.
E.g. in the add-friend case I can guess that my friend count just changed.
It is a subtle shift, and I understand the desire to want a "return value"...but they just don't make sense in the overall model.
(and I'd argue that David is right here...this is a simple/better approach to the problem of UI composition)

from untangled-client.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.