-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Modern] relay-compiler does not support complex folder-structures #1670
Comments
This is not a folder complexity issue, but rather an issue with how you're naming your props on your component versus the fragment name. While there may be an issue with nested directories, it wouldn't manifest as this error. If you have a container:
it will throw. This is for a few reasons: in Compat mode, the fragment name is how we automatically create the prop key, and if you decide not to use an inner keyed object in your |
While on the subject, how are nested modules and components (where it may or may not be index.js) supposed to work? |
@mjmahone the exception is pertinent to the issue because it illustrates how Relay assumes module-names by filename (index.js -> index_fragment). Another symptom of the problem is how your project directories will be cluttered by __generated__ folders unless you use a single components/ or containers/ folder |
The wording of the error is a bit confusing, we should address that. The compiler requires that fragments be named I can see how this naming scheme could cause issues for applications that are using commonjs and particularly having lots of files named |
From the documentation of FragmentContainer
I thought the naming format would be optional once we moved to Modern. |
Looking at the source...
...you can pass a graphql fragment directly (without an object): // App.js
export default createFragmentContainer(props => <Foo {...props} />,
graphql`
fragment App on User {
...Foo
}
`
) This requires the use of the |
A fix was added for "index" files for this issue, otherwise take a look at #2093 |
relay-compiler assumes a single directory components/ where modulename == filename.
This enforces a de-facto layout standard for all Relay Modern projects, which may or may not suit developers.
what relay-compiler assumes:
example complex src folder:
example case & error for complex folders:
The text was updated successfully, but these errors were encountered: