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

[near-operations-file] Import of main types sometimes added to queries where it isn't needed #2729

Closed
mvestergaard opened this issue Oct 10, 2019 · 9 comments
Labels

Comments

@mvestergaard
Copy link
Contributor

mvestergaard commented Oct 10, 2019

Relates to #2137
This problem seems to be back in 1.8.1, or at least something related.

query {
  user {
    ...UserFragment
  }
}

Results in the Types import being added, even though it isn't used.

query {
  user {
    id
    ...UserFragment
  }
}

Also adds the Types import, but uses it.

This is problematic when typescript is configured to error on unused imports.

@SimenB
Copy link
Contributor

SimenB commented May 28, 2020

Would love to see this solved, as we cannot use this preset with noUnusedLocals: true in tsconfig.json. Removing preResolveTypes: true also works.

Workaround I landed on (inspired by OP) is to duplicate a field from the fragment that uses Types (something optional, meaning Types.Maybe is used).

@dotansimha
Copy link
Owner

It's a bit tricky because it effects other use-cases. We are trying to find the actual specific use-cases that causes that.
@SimenB @mvestergaard can you please share a reproduction?

@SimenB
Copy link
Contributor

SimenB commented Jun 18, 2020

This was "fixed" for us by #4194 injecting usage of Types.Exact

@SimenB
Copy link
Contributor

SimenB commented Nov 5, 2020

This resurfaced for us, btw. We're back to adding dummy queries to work around it. I'll try to put together a reproduction

@dotansimha
Copy link
Owner

@SimenB sure, waiting for a reproduction. Thanks!

@SimenB
Copy link
Contributor

SimenB commented Nov 5, 2020

@dotansimha https://github.com/SimenB/codegen-extra-imports. Might be possible to reduce even more, but this is at least somewhat minimal

@SimenB
Copy link
Contributor

SimenB commented Nov 9, 2020

@dotansimha reopen this, or should I file a new issue?

@dotansimha
Copy link
Owner

@dotansimha reopen this, or should I file a new issue?

New issue :)

@SimenB
Copy link
Contributor

SimenB commented Nov 17, 2020

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

No branches or pull requests

3 participants