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

Typescript 3.7+ won't compile class generated by client:codegen when Mutation name is same #1970

Closed
rogersp opened this issue May 27, 2020 · 2 comments

Comments

@rogersp
Copy link

rogersp commented May 27, 2020

Intended outcome:

Typescript 3.7+ can compile classes generated with apollo client:codgen, regardless of how mutations are named.

Actual outcome:

An error occurs during compilation, if the name of the mutation matches the name of the exposed mutation.

For example, when the mutation looks like:

mutation UpdateBook($bookID: ID!, $input: UpdateBook!) {
        UpdateBook(bookID: $bookID, input: $input) {
            ID
            Title
            Author
        }        
    }

Compilation fails with: error TS2440: Import declaration conflicts with local declaration of 'UpdateBook'

However if the mutation name is changed to:

mutation UpdateBookMutation($bookID: ID!, $input: UpdateBook!) {
        UpdateBook(bookID: $bookID, input: $input) {
            ID
            Title
            Author
        }        
    }

The code compiles just fine. Unfortunately I have quite a few existing mutations I would prefer not to rename if possible. Can the generated typescript code use aliased imports?

How to reproduce the issue:

Reproduction case available here: https://github.com/rogersp/apollo-codegen-example

Versions

Typescript 3.7+ (see: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-7.html#local-and-imported-type-declarations-now-conflict)

Apollo 2.28.0

@rogersp
Copy link
Author

rogersp commented Nov 17, 2020

This is still an issue with apollo 2.31.1 and typescript 4.0.5. Short of renaming mutations as described above, any suggestions for a workaround?

@rogersp
Copy link
Author

rogersp commented Nov 18, 2020

Closing this issue for now, was able to migrate over to graphql-code-generator, thanks to #2053

@rogersp rogersp closed this as completed Nov 18, 2020
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