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

apollo client:codegen --target typescript gives TypeError: context.getErrors is not a function #1947

Closed
anark opened this issue May 12, 2020 · 9 comments · Fixed by #2032
Closed
Assignees

Comments

@anark
Copy link

anark commented May 12, 2020

Intended outcome:

I am intending to export my graphql types to typescript types using
apollo client:codegen --target typescript
I expect to generate types in the generated folder
My Apollo client is running on @apollo/client v3.0.beta

Actual outcome:
I get the following error

    at getValidationErrors (node_modules/apollo-language-server/lib/errors/validation.js:25:20)
    at Object.validateQueryDocument node_modules/apollo-language-server/lib/errors/validation.js:30:34)
    at Object.generate [as default] (node_modules/apollo/lib/generate.js:23:18)
    at write node_modules/apollo/lib/commands/client/codegen.js:78:54)
    at Task.task (node_modules/apollo/lib/commands/client/codegen.js:98:46)

How to reproduce the issue:

Run apollo codegen against a react app using @apollo/client v3.0.beta

Versions
apollo cli 2.27.4
@apollo/client v3.0.beta

@juliovedovatto
Copy link

@anark I faced this issue when using graphl@15 dependency. I believe if you downgrade to version graphql@14, will sove the issue.

That did the trick in my case.

@anark
Copy link
Author

anark commented May 12, 2020

Downgrading to graphql@14 solved this. Is there anyway to fix this to make it compatible with graphql@15?

@juliovedovatto
Copy link

juliovedovatto commented May 20, 2020

@abernix I noticed your made a new release of apollo-language-server, but I'm still getting error when using codegen with typescript support, using [email protected]

This line: https://github.com/apollographql/apollo-tooling/blob/master/packages/apollo-language-server/src/errors/validation.ts#L63

TypeError: context.getErrors is not a function

Could you take a look, please?

PS: [email protected] works fine

@bensalilijames
Copy link

PR #1908 fixes this 🙂

@hamzahsn
Copy link

@benhjames unfortunately this PR is not yet merged so we cannot upgrade to it yet 😞

@abernix
Copy link
Member

abernix commented Jul 9, 2020

@anark @hamzahsn:

I'm copying and pasting the comments from @trevor-scheer on #1908 so you make sure you see them and can help test:

Update: The releases associated with this change can be found on the next dist-tag for the following packages.

[email protected]
[email protected]
[email protected]

To install the CLI from the next dist-tag, for example:
npm i -D apollo@next

I'll be closing this PR in favor of the previously mentioned PRs. Thanks again @benhjames for the help with this!

Please try them out and provide feedback on the release PR #2032. Barring any issues I'll release this officially before the end of the week.

Please try the next versions and report back with updates!

@juliovedovatto
Copy link

Just an update: I was following #1908 and now I'm using apollo@next package.

It is working with GraphQL 15 as expected for the project I'm working on.

@abernix abernix self-assigned this Jul 10, 2020
@trevor-scheer
Copy link
Member

Thanks for the update @juliovedovatto! I'm preparing the release to latest as we speak, so expect to see [email protected] in the next 10 minutes or so.

@rainysiu
Copy link

"apollo": "^2.29.0" works

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

Successfully merging a pull request may close this issue.

7 participants