Coder Social home page Coder Social logo

Comments (3)

mfeckie avatar mfeckie commented on August 28, 2024 1

Thanks so much for this. I'll give it a try.

from ember-orbit.

dgeb avatar dgeb commented on August 28, 2024

Currently, the query builders used in ember-orbit are the same as in orbit, which confusingly means that they are unaware of ember-orbit models. Thus, when using store.update or store.query directly, you can't pass in models as arguments when identities are expected.

I believe that your issue will be resolved with the following change:

  forkUpdate = async () => {
    const fork = this.store.fork();
    await fork.update((q) =>
-      q.replaceAttribute(this.args.userProfile, 'firstName', 'new name')
+      q.replaceAttribute(this.args.userProfile.identity, 'firstName', 'new name')
    );

    this.store.merge(fork);
  };

Thus, the transform operation will just reference { type, id } instead of the whole model, which orbit was attempting to clone (unsuccessfully).

This kind of defensive coding soon won't be needed. I'm adding the concept of "record normalizers" which interact with builders (see the WIP at orbitjs/orbit#835) which will translate records + identities from a dev-friendly form into one understandable by orbit. And then I'll create a custom normalizer for ember-orbit that will be fully model-aware. I expect this to be released in the next beta of v0.17.

from ember-orbit.

dgeb avatar dgeb commented on August 28, 2024

As mentioned above, this has been addressed in recent betas through the introduction of a model-aware normalizer. You can freely use models when building queries and transforms and their identities will be extracted.

from ember-orbit.

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.