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

Created on 12 May 2020  Â·  9Comments  Â·  Source: apollographql/apollo-tooling

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
TypeError: context.getErrors is not a function 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

Most helpful comment

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

All 9 comments

@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.

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

@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

PR #1908 fixes this 🙂

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

@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!

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.

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.

"apollo": "^2.29.0" works

Was this page helpful?
0 / 5 - 0 ratings