-
Notifications
You must be signed in to change notification settings - Fork 469
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 codegen:generate doesn't work in npm run-scripts #630
Comments
I get the same error running scripts with yarn. Currently using |
Same here on Windows 10... |
@kunchenguid is it because the version of |
@Dremora in my case, I attempted with the same version locally and globally, and met the same result. Failed on my local project (installed via Yarn) |
Same issue with yarn and apollo@1.9.2 |
@stevenpetryk I tried the workaround and the vNext Branch, but neither worked for me. |
@tbo The correct line for the "resolutions": {
"apollo/graphql": "^14.0.2"
} For the version number, just use whatever version your graphql dependency is; mine had the leading caret. In the case of yarn, you will know it worked correctly if the |
Doesn't work for me either |
Using resolutions doesn't work for me, have to manually remove |
@malimccalla thanks that worked for me as hacky as it is 😕 . Is it me or is the the Apollo project going through a phase of major change right now, a lot of their docs/examples seem out of date see:
Should probably ask this on slack but just trying to quickly gauge the situation. |
@malimccalla solution worked for me as well...for a few days. then I stared getting the same error again, so I tried upgrading to v2.0.5 with no joy. dowgraded back to v1.9.2 and ran again with yarn just for giggles and it magically worked ¯_(ツ)_/¯ |
This is what solved it for me in my project after lots of trial and error:
The key is to install For good measure (at least for the time being), I would also pin This is what $ npm ls graphql
your-project@1.0.0 /some-directory
+-- apollo@2.4.3
| +-- apollo-language-server@1.4.2
| | `-- graphql@14.0.2 deduped
| `-- graphql@14.0.2 deduped
`-- graphql@14.0.2 |
"graphql": "~14.0.2" |
In order to remove the oddly pinned dependencies in the Apollo CLI, and apparently another Apollo package, I resorted to using the following to nuking them all after an npm install occurs:
This will find any package named For those using npm or yarn users who don't want to use resolutions, the following addition to your package.json scripts section can automate this for you. Please note, this is not something to use if this is a distributed library, but is fine to use (imo) if this is just an application. {
"scripts": {
"postinstall": "find node_modules/ -type d ! -wholename \"node_modules/graphql\" ! -wholename \"node_modules/@types/graphql\" -name \"graphql\" -exec rm -rf {} +"
}
} |
Looks like the dependency on graphql was properly unpinned for a bit, but then repinned on PR #952. No idea what's going on with their build system, but why does |
We're using the I'm not really a fan of global installs either, it'll lead to outdated dependencies on developer machines over time. |
Thanks for unpinning graphql in #1010 |
@sh thanks for the quick feedback! Sorry about the trouble this was causing, honest mistake on my part. For those of you following along, |
* small README.md grammar change (#1675) * Upgrade all dependencies including Babel 7 (#1673) * Upgrade all dependencies including Babel 7 1. ncu --upgradeAll 4. Leave "graphql" to be "^13.2.0" that apollo packages depend on 2. Apply patch of "npx babel-upgrade" output 3. Leave only necessary babel plugins 4. Pass "yarn fix" by disabling stricter rules fixes #1654 #1626 #1607 * Also ignore babel config file from webpack.config.js * Resolve conflict and follow upstream/master * small README.md grammar change (#1675) * Upgrade all dependencies including Babel 7 (#1673) * Upgrade all dependencies including Babel 7 * update apollo packages * Use new local state management of Apollo Client 2.5 * Client Schema * Simplify cache and cache defaults * User in local state instead of context * bye apollo-link-state * mod: better suppressing flow error for .graphql import * fix: jest error by updating jest * Upgrade all dependencies fix 2 breaking changes: * css-loader no longer accepts 'minimize' option * isomorphic-style-loader uses new React Context now * refac: Use functional component for components * fix: resolve apollo and graphql versions problem ref. apollographql/apollo-tooling#630 (comment)
Ran into this issue today. I was getting this error after running: Solution was to remove both packages: Then install the same version of |
Yup, after updating the packages I ran into this error yet again. Setting |
@basicdays did you create a new issue? For people landing here from a google search these are the steps to fix right now:
|
Great! This worked for me as well. |
Fwiw I was seeing a CLIError that read:
when trying to run the codegen from a yarn script. Everything worked from a global apollo installation. Updating the |
npm install -g apollo |
* small README.md grammar change (#1675) * Upgrade all dependencies including Babel 7 (#1673) * Upgrade all dependencies including Babel 7 1. ncu --upgradeAll 4. Leave "graphql" to be "^13.2.0" that apollo packages depend on 2. Apply patch of "npx babel-upgrade" output 3. Leave only necessary babel plugins 4. Pass "yarn fix" by disabling stricter rules fixes #1654 #1626 #1607 * Also ignore babel config file from webpack.config.js * Resolve conflict and follow upstream/master * small README.md grammar change (#1675) * Upgrade all dependencies including Babel 7 (#1673) * Upgrade all dependencies including Babel 7 * update apollo packages * Use new local state management of Apollo Client 2.5 * Client Schema * Simplify cache and cache defaults * User in local state instead of context * bye apollo-link-state * mod: better suppressing flow error for .graphql import * fix: jest error by updating jest * Upgrade all dependencies fix 2 breaking changes: * css-loader no longer accepts 'minimize' option * isomorphic-style-loader uses new React Context now * refac: Use functional component for components * fix: resolve apollo and graphql versions problem ref. apollographql/apollo-tooling#630 (comment)
* small README.md grammar change (#1675) * Upgrade all dependencies including Babel 7 (#1673) * Upgrade all dependencies including Babel 7 1. ncu --upgradeAll 4. Leave "graphql" to be "^13.2.0" that apollo packages depend on 2. Apply patch of "npx babel-upgrade" output 3. Leave only necessary babel plugins 4. Pass "yarn fix" by disabling stricter rules fixes #1654 #1626 #1607 * Also ignore babel config file from webpack.config.js * Resolve conflict and follow upstream/master * small README.md grammar change (#1675) * Upgrade all dependencies including Babel 7 (#1673) * Upgrade all dependencies including Babel 7 * update apollo packages * Use new local state management of Apollo Client 2.5 * Client Schema * Simplify cache and cache defaults * User in local state instead of context * bye apollo-link-state * mod: better suppressing flow error for .graphql import * fix: jest error by updating jest * Upgrade all dependencies fix 2 breaking changes: * css-loader no longer accepts 'minimize' option * isomorphic-style-loader uses new React Context now * refac: Use functional component for components * fix: resolve apollo and graphql versions problem ref. apollographql/apollo-tooling#630 (comment)
on osx, running "apollo codegen:generate --target=typescript --addTypename" in terminal works but putting it in package.json scripts and use "npm run" to execute the exact same command will report an error as below:
✖ Generating query files with 'typescript' target
→ Cannot query field "xxx" on type "Query"
GraphQLError: Cannot query field "xxx" on type "Query"
at Compiler.compileSelection (
/node_modules/apollo-codegen-core/lib/compiler/index.js:120:27)/node_modules/apollo-codegen-core/lib/compiler/index.js:106:76)at selections.selectionSetNode.selections.map.selectionNode (
The text was updated successfully, but these errors were encountered: