relay icon indicating copy to clipboard operation
relay copied to clipboard

More assertions for usage pattern

Open cometkim opened this issue 9 months ago • 2 comments

context: I'm maintaining https://github.com/cometkim/vite-plugin-relay-lite

Specifically, It would be nice to move this assertion to the compiler, not the Babel plugin. https://github.com/facebook/relay/blob/b22d53f/packages/babel-plugin-relay/compileGraphQLTag.js#L50-L54

I recently got a user report that vite-plugin-relay-lite has an unintended feature. He showed me that it was locating fragment definitions right next to a query, which was clearly not recommended in Relay.

I immediately asked, "Shouldn't that be banned?", but the assertion only exists at the Babel plugin, not the compiler. I often find cases where I opt into Relay but still end up breaking out of it, and I wish the compiler had more guardrails.

cometkim avatar Feb 26 '25 17:02 cometkim

Yeah, this should be enforced by the compiler. Maybe somewhere around here? Would you like to work on a PR?

captbaritone avatar Feb 26 '25 22:02 captbaritone

Yes. I'll make the PR

cometkim avatar Feb 27 '25 06:02 cometkim