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

must-colocate-fragment-spreads fails on sibling index.js imports #105

Open
JonathanUsername opened this issue Oct 27, 2020 · 0 comments
Open

Comments

@JonathanUsername
Copy link

I've described it in some detail in the PR that fixes this issue here #104, but I'm opening an issue to track it. If that's not the right way to do this, then feel free to close this issue.

The problem code:

        import MyComponent from './';

        graphql`fragment foo on Page {
          ...MyComponent_foo
        }`

Currently throws the error:

This spreads the fragment MyComponent_foo but this module does not use it directly. If a different module needs this information, that module should directly define a fragment querying for that data, colocated next to where the data is used.

Which is highly confusing, as it is imported.

I believe this is an edge-case surfaced by our pattern of importing relative components in the same directory, so I've tried to tweak the module parser to handle this by checking the name of the parent directory in my PR.

Another option would be to operate on the variable name but that seems far worse and too much like the strict horrors of Relay compat.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant