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.

Query never receives result (stuck in loading state) when id is not specified on nested type three-levels deep

See original GitHub issue

See reproduction for example

Intended outcome: When querying similar data throughout an app, it should be possible to exclude the id field on nested queries. E.g. ({ people { id, name, pets { name } }).

Actual outcome: However, if you have two similar queries in your app, one that includes the nested id and the other that excludes it, the mounting either component leaves it stuck in the loading state.

See these two components:

const ConnectedComponentOnPage1 = graphql(gql`{
  people {
    id,
    name,
    pets {
      id,
      name,
      belonging {
        id, # id is queried
        name,
      }
   }
 }
}`,
{ options: { fetchPolicy: 'cache-and-network' }))(ComponentOnPage1); // the cache-and-network policy is allow essential to reproduce

// Notice the component is on a different page. The important aspect is that is is unmounted. It seems that the error is only triggered when mounting/unmounting components.
const ConnectedComponentOnPage2 = graphql(gql`{
  people {
    id,
    name,
    pets {
      id,
      name,
      belonging {
        name, # no id queried here fails
      }
   }
 }
}`,
{ options: { fetchPolicy: 'cache-and-network' })(ComponentOnPage2);

The second components, when mounted, never gets refreshed with the data from the server, even if it completes successfully. It looks like this could be a similar issue to #1389, #1186, and other issues in react-apollo like this one. Included/excluding the id in both places fixes the issue. Seems like the cache is having a problem looking up the nested object when there are queries with an id and without an id.

How to reproduce the issue: Handy dandy reproduction in error template

Thanks all! Let me know how I can help.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
cesarsolorzanocommented, Apr 3, 2017

@derek-duncan yes, I’m working on it! 🙂

0reactions
derek-duncancommented, Apr 5, 2017

@cesarsolorzano yep looks like it – I’ve never seen that error because it’s being swallowed.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Mysql nested query scope - Stack Overflow
i know mysql doesn't allow you to "see" a variable reference in queries deeper than 1, but i'm not finding workaround. select f.id...
Read more >
SSRS Report Stuck on loading - TechNet - Microsoft
I have this SSRS project and all the reports run smoothly except one report. The one report just gets stuck on the is...
Read more >
Error and Transaction Handling in SQL Server Part Two
If you have started a transaction through TransactionScope and you have BEGIN and COMMIT TRANSACTION in your stored procedure, this is exactly like...
Read more >
Oracle® WebLogic Server
Server automatically compiles JSPs if the servlet class file is not ... Add nested create, delete, get, set, and query elements to configure...
Read more >
SQL Performance Diagnosis on IBM DB2 Universal Database ...
DB2 Universal Database for iSeries provides a comprehensive set of tools that help technical analysts tune SQL queries. The SQL Performance Monitors are....
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