Skip to content

Improve @throwOnFieldError error on mutations to suggest @catch#5203

Open
captbaritone wants to merge 2 commits intofacebook:mainfrom
captbaritone:catch-on-fragment
Open

Improve @throwOnFieldError error on mutations to suggest @catch#5203
captbaritone wants to merge 2 commits intofacebook:mainfrom
captbaritone:catch-on-fragment

Conversation

@captbaritone
Copy link
Copy Markdown
Contributor

Summary

  • When users add @throwOnFieldError to a mutation, they now get a helpful error recommending @catch(to: RESULT) instead of the generic "not supported in this location" message.
  • Moves the validation from the IR build phase to the disallow_readtime_features_in_mutations validation pass, alongside similar mutation-specific checks for @required and resolvers.

Test plan

  • Added new test fixture mutation_with_throw_on_field_error.invalid in the disallow_readtime_features_in_mutations test suite
  • Removed the old codegen test fixture that tested the generic error
  • All existing tests pass: cargo test -p relay-transforms --test graphql_disallowreadtime_features_in_mutations_test and cargo test -p relay-codegen --test relay_codegen_throw_on_field_error_directive_codegen_test

…ESULT)

Previously, using @throwOnFieldError on a mutation produced a generic
"not supported in this location" error. This updates the error to
specifically recommend using @catch(to: RESULT) instead, which is the
supported alternative for mutations.
@meta-cla meta-cla Bot added the CLA Signed label Mar 6, 2026
@meta-codesync
Copy link
Copy Markdown
Contributor

meta-codesync Bot commented Mar 6, 2026

@captbaritone has imported this pull request. If you are a Meta employee, you can view this in D95583355.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant