question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Sub queries returning the same data when they should be different

See original GitHub issue

I’m running in to an issue only in the Apollo client that I’m troubleshooting. If you could point me how I could best debug this I’d be very happy.

Intended & outcome: Below is the sample query, the GraphiQL results (which is the expected results), the apollo results (the actual outcome of the Apollo client, which is incorrect), and my node unit test as well. This exact query works fine in GraphiQL but is incorrect in Apollo.

You’ll notice the “sum” amount, with the Apollo results, is the same for all sub queries. Contrast that with the GraphiQL results (expected results) and you’ll notice they are all different. It seems like Apollo is getting the last sub query results for user.* and populating all of them with those last values.

I’ve verified this happens in the Apollo client in our Node app and in our React app. I’ve also verified that the GraphQL server is indeed returning the correct raw results.

Another interesting data point: If I set client.addTypename = false;, then it will properly return the results. Obviously I don’t want to do that as it will throw all sorts of warnings such as:

You're using fragments in your queries, but either don't have the addTypename: true option set in Apollo Client, or you are trying to write a fragment to the store without the __typename. Please turn on the addTypename option and include __typename when writing fragments so that Apollo Client can accurately match fragments. Could not find __typename on Fragment ContributionData

and DEPRECATION WARNING: using fragments without __typename is unsupported behavior and will be removed in future versions of Apollo client. You should fix this and set addTypename to true now.

https://gist.github.com/rblalock/e012a6a2096ead584f396bcf36584fdc

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
rblalockcommented, Jun 28, 2017

Ok my apologies, I had the option in the wrong spot (under the networkInterface options). dataIdFromObject: () => undefined, does indeed work under the top level options for the apollo client. Thanks for helping me with this.

0reactions
helfercommented, Jun 28, 2017

Ok, glad you figured it out! 🙂

Read more comments on GitHub >

github_iconTop Results From Across the Web

Writing Subqueries in SQL | Advanced SQL - Mode Analytics
This lesson of the SQL tutorial for data analysis covers using subqueries in SQL with aggregate functions, conditional logic, and joins.
Read more >
Creating a subquery to retrieve data from more than one table
A subquery in an UPDATE statement cannot retrieve data from the same table in which data is to be updated.
Read more >
SQL : Multiple Row and Column Subqueries - w3resource
Multiple row subquery returns one or more rows to the outer SQL statement. You may use the IN, ANY, or ALL operator in...
Read more >
2.9. Performing Multiple-Table Retrievals with Subqueries
Correlated subqueries work by passing values from the outer query to the subquery to see whether they match the conditions specified in the ......
Read more >
SQL Subqueries | LearnSQL.com
A subquery is a SELECT statement with another SQL statement, like in the example below. ... ); Want to know more about SQL...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found