Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query strange behavior - unlimited loading state after success mutation with react-apollo #1039

Closed
ARMGAMES opened this issue Dec 14, 2016 · 9 comments
Labels

Comments

@ARMGAMES
Copy link

ARMGAMES commented Dec 14, 2016

Created issue at react-apollo, but there guys suggested that this apollo bug. This is issue link -apollographql/react-apollo#368

@helfer
Copy link
Contributor

helfer commented Dec 16, 2016

@SachaG mentioned in the other issue that he has tracked this down to partial data being provided to the reducer. I think we currently throw an error if there's partial data outside a fragment, but we don't do so when partial data is inside a fragment due to how we detect fragments.

I think a refactor will be needed to make sure that we can catch missing data in fragments as well.

@donedgardo
Copy link

I thought #980 fixed this. I'm having trouble with this too.
In my case my render method has a if statement that renders if the this.props.data.loading is false otherwise loads a spinner.
I console.log the data and it logs correctly:

{"variables":{},"loading":false,"networkStatus":7,"foodtrucks":[{"name":"FoodTruck #1","__typename":"FoodTruck"},{"name":"FoodTruck #2","__typename":"FoodTruck"}]}

but my app crashes with an odd error.

Error in observer.next 

@helfer
Copy link
Contributor

helfer commented Dec 21, 2016

@donedgardo #980 was a fix for a different issue. I'm not sure your error is related since it indicates loading: false. It's a bit hard to tell what your error is, because it doesn't include a stack trace. Did you forget to paste it, or is there just no stack trace?

@donedgardo
Copy link

donedgardo commented Dec 21, 2016 via email

@scf4
Copy link

scf4 commented Dec 21, 2016

Ran into a similar (or same) bug recently and was planning to open an issue.

If I use $unshift it works fine (prepends item to list) but $push (to append) has me stuck in loading state.

@scf4
Copy link

scf4 commented Dec 21, 2016

Okay yes I believe my issue is related to the partial result bug.

I have this query:

thread: {
  posts: {
    edges: {
      node: {
        id
        content
      }
    }
  }
}

and the mutation only returns { id, content } of course.

So mutations can't work with Apollo if we want to use edges?

@helfer
Copy link
Contributor

helfer commented Dec 23, 2016

@scf I'm sorry, I can't really tell what your issue/question is. From experience, it seems that unlimited loading state is often the result of a updateQuery function not returning all data.

If it's indeed the case that the only difference is $unshift vs. $push, then it would be great if you could make a PR with a failing test. Just find the current test most relevant to your issue, copy, rename and adapt it to fail when using $push, but pass when using $unshift.

@helfer
Copy link
Contributor

helfer commented Mar 28, 2017

Is anyone still encountering this issue? If yes, please let me know and I'll reopen the issue.

@helfer helfer closed this as completed Mar 28, 2017
@c10b10
Copy link

c10b10 commented May 18, 2017

Checked Network tab, and response from the server is correct, but networkStatus stuck at 2, and loading stuck to true.

This happens the third time I load a component that gets a query.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 17, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

5 participants