Giter VIP home page Giter VIP logo

Comments (16)

shtse8 avatar shtse8 commented on April 27, 2024 12

Any plans to support loadingKey for mutation?

from apollo.

siegy22 avatar siegy22 commented on April 27, 2024 5

I expected to at least have $apollo.loading set to true, but that doesn't get updated. :(
So the current way to do this, is just use the ApolloMutation component?

from apollo.

Akryum avatar Akryum commented on April 27, 2024 4

There is no loadingKey feature on mutations at the moment. You can implement it very easily yourself:

this.loading ++

this.$apollo.mutate({
  // Query
  mutation: gql`mutation ($label: String!) {
    addTag(label: $label) {
      id
      label
    }
  }`,
  // Parameters
  variables: {
    label: newTag,
  },
}).then((data) => {
  this.loading --
}).catch((error) => {
  this.loading --
});

from apollo.

gijo-varghese avatar gijo-varghese commented on April 27, 2024 2

Thank god, I left VueJS!

from apollo.

TkaczykAdam avatar TkaczykAdam commented on April 27, 2024 2

June 2021 and $apollo.loading not work with mutation 😞

from apollo.

Akryum avatar Akryum commented on April 27, 2024 1

Maybe you can use the <ApolloMutation> component?

from apollo.

yeusiukou avatar yeusiukou commented on April 27, 2024

I'm also having problems with loadingKey

from apollo.

enginkartal avatar enginkartal commented on April 27, 2024

+1

from apollo.

gijo-varghese avatar gijo-varghese commented on April 27, 2024

+1

from apollo.

PatrickJS avatar PatrickJS commented on April 27, 2024

+1

from apollo.

pschaub avatar pschaub commented on April 27, 2024

+1

from apollo.

bbugh avatar bbugh commented on April 27, 2024

Are there plans for this? We have a lot of cases where we do live updated forms, and want to have a "saving..." a la Google Docs. The amount of places we'd need to track variables for the mutation is doable but would be a lot easier if mutation just had a loadingKey instead of having to track variables in many different components.

I checked out the source code for adding this feature in a PR but at first look it seems more complex than I expected. mutate just seems to be a wrapper for apollo-client, and the query is tracked as part of smart-query via an observable in watchQuery and applyLoadingModifier. I didn't go any further because it seems like I'd need to deep-dive into apollo-client to follow it. Am I correct in this complexity or is it a simple matter of adding an observable to mutate the way watchQuery and subscribe have?

from apollo.

bbugh avatar bbugh commented on April 27, 2024

That looks plausible. In one case, we have a form with 10 fields. If the user changes a field, we send a mutation to the server with the update, and at the top of the form show "saving". When the migration is done, we show "saved" for a few seconds. It looks like if we wrap the whole form with the ApolloMutation component that it would work. I'll give it a shot, thanks!

from apollo.

bbugh avatar bbugh commented on April 27, 2024

ApolloMutation works great! We've started using the component operations and it makes the code so nice and easy. Thank you for the PROTIP!

from apollo.

chadwtaylor avatar chadwtaylor commented on April 27, 2024

+1

from apollo.

kieuminhcanh avatar kieuminhcanh commented on April 27, 2024

+1

from apollo.

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.