next.js example hot reloading bug
See original GitHub issueI love this loader! Great work!!
Unfortunately, I believe I’ve found a bug in the next.js example. The bug is that the new types that are generated by graphql-let
as part of the next-js hot reload action seem to be ignored by the typechecker.
Reproduction steps
npm run dev
- Make a change to the schema (e.g. Add a field
isActive: Boolean
to the User type in the schema). Save the file. - Add this new field to the Viewer query. Save the file.
- Add a reference to this new field after the query hook on the index view. Save the file. e.g.:
import withApollo from '../lib/with-apollo'
import Link from 'next/link'
import { useViewerQuery } from '../lib/viewer.graphql'
const Index = () => {
const { data } = useViewerQuery()
if (data && data.viewer && data.viewer.isActive) {
const { viewer } = data
return (
<div>
You're signed in as {viewer.name} and you're {viewer.status} goto{' '}
<Link href="/about">
<a>static</a>
</Link>{' '}
page.
</div>
)
}
return <div>...</div>
}
export default withApollo(Index)
- In a browser, navigate to
localhost:3000
Actual Behavior
New types are ignored: type error reported according to the types initially generated at app start: Killing the next.js process and starting it again seems to provide the correct types until another change to the schema occurs i.e. it seems that this bug only occurs during the next.js hot reload action.
Expected Behavior
During the next.js hot reload action, graphql-let
properly replaces the generated types with the latest and this is reflected properly by the typechecker.
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
NextJS Hot Reload · Issue #30791 · vercel/next.js - GitHub
Describe the Bug. NextJS keeps refreshing when code is updated, the log below shows what happens. I've read about the warning in other ......
Read more >Fast Reliable/Hot Reloading in Next.js - Coding Ninjas
The following article discusses the concepts of Hot Reloading in a Next.JS project in detail along with its working and some Debugging ...
Read more >Hot module reload is not working on my nextjs app
Got help from @felixmosh. There was issue because of my folders were case was not matching route case. Fixed the issues by changing...
Read more >How to fix the NextJS HMR(hot reload) not working error on ...
When working on NextJS applications inside WSL2, there seems to be an issue with HMR (Hot Reload) not detecting changes to your code...
Read more >Blog - Next.js 12.3
Improved Fast Refresh: .env , jsconfig.json , and tsconfig.json files now hot reload. ; TypeScript Auto-Install: Add a .ts file to automatically ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@deanslamajr Amazing work. I put
"*"
without consideration, perhaps I might have thought it would respect other deps’sglobby
and would save a number of total deps or something. I really appreciate your deep investigation and the PR, andslash
too, which may make another issue in the future.Let me close this issue now thanks to your PR. Please let me know if you notice something about graphql-let in your project.
I think I’ve found the cause of this bug:
The major version of
globby
is not “locked” in package.json. Consequently, if another package has a dependency on a major version ofglobby
that is too old forgraphql-let
,graphql-let
will use the incorrect version and function incorrectly.To verify this, there are two different paths to initialize the the next.js example. The first will install a major version of
globby
(globby@11.0.0
) that supportsgraphql-let
correct functionality:The second path will install a much older major version of
globby
(globby@^6.1.0
) that seems to breakgraphql-let
’s stale asset removal:I was able to verify that by locking the major version of
globby
to the latest major version (11.0.0
), this bug can be avoided. I have created a PR to implement this change.