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.

Cached operations are not reset when source files change with eslint-plugin-webpack

See original GitHub issue

Issue workflow progress

Progress of the issue based on the Contributor Workflow

  • 1. The issue provides a reproduction available on GitHub, Stackblitz or CodeSandbox

Please make sure the graphql-eslint version under package.json matches yours.

  • 2. A failing test has been provided
  • 3. A local solution has been provided
  • 4. A pull request is pending review

Describe the bug

When eslint is used to watch changes to files (like via eslint-plugin-webpack, or when using create-react-app), rules that rely on the operationsCache fail to update their status after the source file changes. This specifically affects fragments used in those files. For example, if a file looks like this:

// index.ts
import gql from 'graphql-tag';

const fragment = gql`
	  fragment Test on User {
		  name
	  }
`

const query = gql`
	query LoggedInUser {
		user {
			...Test
		}
	}
	${fragment}
`

The rule will show a require-id-when-available error on the fragment initially, but if the id field is added, the error will persist until the eslint process is restarted.

To Reproduce Steps to reproduce the behavior:

Here’s a codesandbox set up to demonstrate the error: https://codesandbox.io/s/graphql-eslint-issue-6nskdj?file=/src/App.js

Running yarn client will initially show an error, but when that error is fixed, it doesn’t go away.

Expected behavior

The rules should handle changes to files during a single eslint process and resolve errors without requiring rerunning.

Environment:

  • OS: MacOS / Linux
  • @graphql-eslint/eslint-plugin: 3.10.6
  • Node.js: 16.13.2 / 18.6.0

Additional context

I’ve included a PR with a proposed fix for the issue: https://github.com/ghmeier/graphql-eslint/pull/1

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:3
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
B2o5Tcommented, Nov 1, 2022
1reaction
ghmeiercommented, Oct 12, 2022
Read more comments on GitHub >

github_iconTop Results From Across the Web

ESLintPlugin not working consistently with cache ... - GitHub
With webpack cache turned on and set to 'filesystem' ESLintPlugin reports errors only after first build. If files are unchanged and build is ......
Read more >
Adding eslint-webpack-plugin into project to provide ...
My solution was to use the extensions setting instead of files . Try this: ... I solved it by using override config inside...
Read more >
Caching - webpack
This guide focuses on the configuration needed to ensure files produced by webpack compilation can remain cached unless their content has changed.
Read more >
Changelog - Cypress Documentation
Cypress will now restart on changes to the blockHosts configuration entry. ... for failed specs when the cypress config file is not the...
Read more >
Caching Dependencies - CircleCI
Automatic dependency caching is not available in CircleCI, so it is important ... If this file changed in your commit, CircleCI would see...
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