facebook / facebook/relay

Namespacing support

Open
#2,722 2 comments 3 reactions 0 assignees View on GitHub
wontfix
Dominant language
Rust
Stars
19k
Forks
1.9k
PR merge metrics
No merged PRs in 30d

Description

Currently relay-compiler enforces a very strict naming convention:

`Parse error: Error: RelayFindGraphQLTags: Container fragment names must be _`.

Which makes sense in small apps or apps where every component easily can have a unique name, but in bigger apps that is not realistic - which is why namespaces were invented. Imagine having two UserDetails components, one for the public part of the site and one for the Manager/logged-in part of the site - with relay you would be forced to call them something different.

**My old workaround, that doesn´t work with the latest relay**

I used to be able to append an ugly namespace component to the query/mutation/fragment names:

`fragment UserDetailsMain...`

But now that also doesn´t work anymore.

**How would I solve this?**

Simple relaxing the naming of queries, mutations and fragments to prefix the module name with something _including_ underscores and/or dots would allow for easy namespacing support:

`Manager.UserDetails` / `Main.UserDetails`

Making this automatic in the future would be even better.

Contributor guide

Open the contributing guide

Research direction

Start by reading relay-compiler's naming validation and its existing tests, then compare the current restrictions with the proposed Manager.UserDetails and Main.UserDetails forms. Done means the compiler accepts the intended names without breaking query, mutation, or fragment validation, with tests covering namespaced and invalid forms.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react
Domain
frontend, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.