facebook / relay

Relay is a JavaScript framework for building data-driven React applications.
https://relay.dev
MIT License
18.24k stars 1.8k forks source link

Add code action to create missing fragment argument #4681

Open tobias-tengler opened 1 month ago

tobias-tengler commented 1 month ago

Depends on #4680

This renames the GlobalVariables error to ExpectedOperationVariableToBeDefined and emits the error for each problematic variable identifier, instead of a single error for multiple infringements. Also extends the error to include the variable name and type in the diagnostic data. Using this data we create a code action that appends the missing argument with the correct type to the fragment arguments (only using @argumentDefinitions for now). No diagnostic is emitted for orphan fragments that aren't referenced in an operation. I plan on supporting this case and add a refactor for global variables in a later PR.