Skip to content
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

Relay 13: @no_inline directive doesn't work correctly for fragments in a different directory (non-Haste mode) #3742

Open
Tracked by #3749
mrtnzlml opened this issue Jan 11, 2022 · 2 comments
Labels
bug rust Related to the compiler written in Rust

Comments

@mrtnzlml
Copy link
Contributor

Hola 👋 , I discovered an issue with @no_inline directive. Basically, it works well when you use it on a simple fragment (it generates the *$normalization.graphql.js file and corresponding requires as expected). However, when the fragment is used somewhere further away (say in __tests__ or in some other distant location) it still generates the normalization file nearby the fragment but the requires are pointing to a non-existing file.

For example:

src/example-relay/src/Homepage/locations
├── Location.js
├── __generated__
│   ├── Location$normalization.graphql.js
│   ├── Location.graphql.js
│   └── ...
└── __tests__
    ├── LocationsPaginatedRefetch.test.js
    └── __generated__
        └── LocationsPaginatedRefetchTestQuery.graphql.js

The requires are correct under __generated__ but they are wrong under __tests__/__generated__ because the require looks like this:

{
  "args": null,
  "fragment": require('./Location$normalization.graphql'), // doesn't exist under `__tests__/__generated__`
  "kind": "FragmentSpread"
},

I hope it's understandable what I am trying to describe. 😬

@alunyov
Copy link
Contributor

alunyov commented Jan 11, 2022

I think this may only work now when using a single artifactsDirectory for all generated artifacts. Can you try this?

Internally, everything is working because we're using Haste requires (using just module name without a path).

@mrtnzlml
Copy link
Contributor Author

I can imagine how this would work with Haste or artifacts directory without any issues, yes. So this issue might be more like a feature request: to support @no_inline with the default Relay OSS configuration (CommonJS, no artifacts directory).

Personally, I do not want to use the artifacts directory but I can imagine having one directory for these normalization files to simplify the whole situation (so the files are not all over the place).

@josephsavona josephsavona changed the title Relay 13: @no_inline directive doesn't work correctly for distant fragments Relay 13: @no_inline directive doesn't work correctly for fragments in a different directory (non-Haste mode) Jan 12, 2022
@alunyov alunyov added bug rust Related to the compiler written in Rust labels Jan 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug rust Related to the compiler written in Rust
Projects
None yet
Development

No branches or pull requests

2 participants