facebook / relay

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

Prevent name collision between derived refetchable query and fragment name #4663

Closed captbaritone closed 2 months ago

captbaritone commented 2 months ago

As identified in #4654 it's possible to use an existing fragment name as the queryName argument of @refetchable and end up with a collision. The result is that we end up importing the fragment's artifact when we expect to import the queries. It's possible we even overwrite that same path with two artifacts.

~One thing I noticed is that for regular queries we require that the name end with Query but it looks like we don't for queries generated with queryName. Perhaps we need to enforce the same convention with these queries?~

This PR now includes additional validations to prevent this error.

facebook-github-bot commented 2 months ago

@captbaritone has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

facebook-github-bot commented 2 months ago

@captbaritone merged this pull request in facebook/relay@a370da6ec43fcc251433eb9cc21245e25ba75b4e.