apollographql / apollographql/apollo-tooling

client:download-schema and client:codegen broken

Open
#2,422 4 comments 1 reaction 0 assignees View on GitHub
Dominant language
TypeScript
Stars
3k
Forks
460
PR merge metrics
No merged PRs in 30d

Description

Command:
```bash
./node_modules/apollo/bin/run client:download-schema \
--header "Authorization: JWT $1" \
--endpoint http://localhost:8080/graphql \
schema.json
```

Outcome:
```bash
✔ Loading Apollo Project
✖ Saving schema to schema.json
→ spurious results.
Error: Cannot use GraphQLSchema "[object GraphQLSchema]" from another module or realm.

Ensure that there is only one instance of "graphql" in the node_modules
directory. If different versions of "graphql" are the dependencies of other
relied on modules, use "resolutions" to ensure only one version is installed.

https://yarnpkg.com/en/docs/selective-version-resolutions

Duplicate "graphql" modules cannot be used at the same time since different
versions may have different capabilities and behavior. The data from one
version used in the function from another could produce confusing and
spurious results.
```

Command:
```bash
./node_modules/apollo/bin/run client:codegen \
--includes src/gql/index.tsx \
--endpoint http://localhost:8080/graphql \
--header "Authorization: JWT $1" \
--target typescript \
--outputFlat src/types/gen
```

Outcome:
```bash
✔ Loading Apollo Project
✖ Generating query files with 'typescript' target
→ spurious results.
Error: Cannot use GraphQLObjectType "Query" from another module or realm.

Ensure that there is only one instance of "graphql" in the node_modules
directory. If different versions of "graphql" are the dependencies of other
relied on modules, use "resolutions" to ensure only one version is installed.

https://yarnpkg.com/en/docs/selective-version-resolutions

Duplicate "graphql" modules cannot be used at the same time since different
versions may have different capabilities and behavior. The data from one
version used in the function from another could produce confusing and
spurious results.
```

`package.json`
```js
{
...
"dependencies": {
"@apollo/client": "3.4.8",
"@babel/runtime": "^7.15.3",
"@hot-loader/react-dom": "^16.8.0",
"@material-ui/core": "^4.12.3",
"@material-ui/icons": "^4.11.2",
"@material-ui/lab": "^4.0.0-alpha.60",
"@material-ui/types": "^5.1.0",
"apollo3-cache-persist": "^0.12.1",
"axios": "^0.21.1",
"clean": "^4.0.2",
"fast-deep-equal": "^3.1.3",
"fuse.js": "^6.4.6",
"google-libphonenumber": "^3.2.22",
"graphiql": "^1.4.2",
"graphql": "^15.5.0",
"graphql-tag": "^2.12.5",
"history": "^5.0.1",
"material-ui-phone-number": "^2.2.6",
"react": "^16.8.0",
"react-copy-to-clipboard": "^5.0.4",
"react-dom": "^16.8.0",
"react-dropzone": "^11.3.4",
"react-hot-loader": "^4.13.0",
"react-markdown": "^7.0.0",
"react-router-dom": "^5.2.0",
"react-syntax-highlighter": "^15.4.4",
"typeface-roboto": "1.1.13",
"uuid": "^8.3.2"
},
"devDependencies": {
"@babel/core": "^7.15.0",
"@babel/plugin-proposal-class-properties": "^7.14.5",
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
"@babel/plugin-transform-runtime": "^7.15.0",
"@babel/preset-env": "^7.15.0",
"@babel/preset-react": "^7.14.5",
"@babel/preset-typescript": "^7.15.0",
"@types/google-libphonenumber": "^7.4.21",
"@types/graphql": "^14.5.0",
"@types/jest": "^27.0.1",
"@types/react": "^17.0.19",
"@types/react-copy-to-clipboard": "^5.0.1",
"@types/react-dom": "^17.0.9",
"@types/react-router-dom": "^5.1.8",
"@types/react-syntax-highlighter": "^13.5.2",
"@types/uuid": "^8.3.1",
"@typescript-eslint/eslint-plugin": "^4.29.2",
"@typescript-eslint/parser": "^4.29.2",
"apollo": "^2.33.6",
"assert": "^2.0.0",
"babel-loader": "^8.2.2",
"babel-plugin-graphql-tag": "^3.3.0",
"babel-plugin-styled-components": "^1.13.2",
"clean-webpack-plugin": "^3.0.0",
"css-loader": "^6.2.0",
"eslint": "^7.32.0",
"eslint-config-airbnb-typescript": "^12.3.1",
"eslint-import-resolver-webpack": "^0.13.1",
"eslint-plugin-graphql": "^4.0.0",
"eslint-plugin-import": "^2.24.0",
"eslint-plugin-jsx-a11y": "^6.4.1",
"eslint-plugin-react": "^7.24.0",
"eslint-plugin-react-hooks": "^4.2.0",
"file-loader": "^6.2.0",
"fork-ts-checker-webpack-plugin": "^6.3.2",
"html-webpack-plugin": "^5.3.2",
"mini-css-extract-plugin": "^2.2.0",
"npm-check-updates": "^11.8.3",
"process": "^0.11.10",
"raw-loader": "^4.0.2",
"terser-webpack-plugin": "^5.1.4",
"ts-protoc-gen": "^0.15.0",
"typescript": "^4.3.5",
"webpack": "^5.51.1",
"webpack-bundle-analyzer": "^4.4.2",
"webpack-cli": "^4.8.0",
"webpack-dev-server": "^4.0.0"
},
"resolutions": {
"graphql": "^15.5.0"
}
}
```
Checking for conflicts:
```bash
λ npm ls --depth=10 | grep 'graphql@'
│ │ └── graphql@15.5.0 deduped
│ ├── graphql@15.5.0 deduped
│ │ ├── graphql@15.5.0 deduped
├─┬ @types/graphql@14.5.0
│ └── graphql@15.5.0 deduped
│ ├─┬ apollo-graphql@0.9.3
│ │ ├── graphql@15.5.0 deduped
│ │ │ ├── apollo-graphql@0.9.3 deduped
│ │ │ ├── graphql@15.5.0 deduped
│ │ │ │ └── graphql@14.7.0 deduped
│ │ │ │ └── graphql@14.7.0 deduped
│ │ │ │ └── graphql@14.7.0 deduped
│ │ │ └── graphql@14.7.0 deduped
│ │ ├── apollo-graphql@0.9.3 deduped
│ │ │ │ ├── graphql@15.5.0 deduped
│ │ │ ├── graphql@15.5.0 deduped
│ │ │ │ ├── graphql@15.5.0 deduped
│ │ │ ├── graphql@15.5.0 deduped
│ │ │ └── graphql@15.5.0 deduped
│ │ ├─┬ graphql@14.7.0
│ │ ├── graphql@15.5.0 deduped
│ ├── graphql@15.5.0 deduped
├─┬ eslint-plugin-graphql@4.0.0
│ │ │ │ ├── graphql@15.5.0 deduped
│ │ │ ├── graphql@15.5.0 deduped
│ │ │ ├── graphql@15.5.0 deduped
│ │ │ ├── graphql@15.5.0 deduped
│ │ │ │ ├── graphql@15.5.0 deduped
│ │ │ ├── graphql@15.5.0 deduped
│ │ │ │ │ ├── graphql@15.5.0 deduped
│ │ │ │ ├── graphql@15.5.0 deduped
│ │ │ │ ├── graphql@15.5.0 deduped
│ │ │ ├── graphql@15.5.0 deduped
│ │ │ ├── graphql@15.5.0 deduped
│ │ ├── graphql@15.5.0 deduped
│ ├── graphql@15.5.0 deduped
│ │ │ └── graphql@15.5.0 deduped
│ │ ├── graphql@15.5.0 deduped
│ ├─┬ codemirror-graphql@1.0.2
│ │ │ │ ├── graphql@15.5.0 deduped
│ │ │ ├── graphql@15.5.0 deduped
│ │ │ └── graphql@15.5.0 deduped
│ │ └── graphql@15.5.0 deduped
│ │ │ └── graphql@15.5.0 deduped
│ │ └── graphql@15.5.0 deduped
│ ├── graphql@15.5.0 deduped
│ ├── graphql@15.5.0 deduped
├── graphql@15.5.0
```

There are no other versions other than those seemingly required by apollo.

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the reported client:download-schema and client:codegen commands, then inspect their CLI entry points and the dependency tree shown by npm ls. Done means both commands complete without the duplicate GraphQL module or realm errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
graphql, typescript
Domain
cli, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.