apollographql / apollographql/apollo-tooling
Dependency resolution of apollo package(s)
- Dominant language
- TypeScript
- Stars
- 3k
- Forks
- 460
- PR merge metrics
- No merged PRs in 30d
Description
**Intended outcome:**
The gatsby-plugin-codegen tool uses the apollo package to generate a schema file as well as typescript definitions. This plugin is currently broken because of the graphql package dependency - GatsbyJS still uses the version ^14.6.0 and not yet ^15.3.0.
I've expected that downgrading the apollo package to a specific version is resolving my issue. Otherwise I've expceted that an upgrade of the graphql package should be done in a major release.
**Actual outcome:**
Multiple versions of graphql exists and an error is thrown while generating types. Downgrading/Fixing the apollo package resolves still to the newest apollo-language-server package which depends on graphql.
```javascript
// package.json
"dependencies": {
"apollo": "2.27.4"
}
```
```bash
yarn why v1.22.4
[1/4] Why do we have the module "graphql"...?
[2/4] Initialising dependency graph...
[3/4] Finding dependency...
[4/4] Calculating file sizes...
=> Found "graphql@14.7.0"
info Has been hoisted to "graphql"
info Reasons this module exists
- Hoisted from "gatsby#graphql"
- Hoisted from "gatsby-plugin-codegen#graphql"
- Hoisted from "gatsby-plugin-codegen#apollo-language-server#graphql"
- Hoisted from "gatsby-plugin-codegen#apollo#graphql"
- Hoisted from "gatsby-cli#gatsby-recipes#graphql"
info Disk size without dependencies: "3.11MB"
info Disk size with unique dependencies: "3.21MB"
info Disk size with transitive dependencies: "3.21MB"
info Number of shared dependencies: 1
=> Found "apollo-language-server#graphql@15.3.0"
info This module exists because "apollo-language-server" depends on it.
info Disk size without dependencies: "3.28MB"
info Disk size with unique dependencies: "3.28MB"
info Disk size with transitive dependencies: "3.28MB"
info Number of shared dependencies: 0
Done in 0.80s.
```
So where does apollo-language-server come from:
```bash
yarn why v1.22.4
[1/4] Why do we have the module "apollo-language-server"...?
[2/4] Initialising dependency graph...
[3/4] Finding dependency...
[4/4] Calculating file sizes...
=> Found "apollo-language-server@1.23.2"
info Has been hoisted to "apollo-language-server"
info Reasons this module exists
- Hoisted from "gatsby-plugin-codegen#apollo#apollo-language-server"
- Hoisted from "gatsby-plugin-codegen#apollo#apollo-codegen-core#apollo-language-server"
info Disk size without dependencies: "24.32MB"
info Disk size with unique dependencies: "45.36MB"
info Disk size with transitive dependencies: "57.51MB"
info Number of shared dependencies: 75
```
**How to reproduce the issue:**
Just clone one of the dependent repositories.
```bash
git clone git@github.com:JadeRoseMusic/website2020.git
yarn install
yarn start
```
For the specific downgraded version adapt package.json to
gatsby-plugin-codegen@1.3.0-alpha-16
The related issue is here https://github.com/daugsbi/gatsby-plugin-codegen/issues/12
**Versions**
The backward versions are also affected, like apollo 1.21.0. This is because it depends on the newest apollo-language-server.
Yarn version 1.22.4
GatsbyJS version: 2.24.7
Contributor guide
Research direction
Start with package.json and the dependency tree in the reproduction repository, then run yarn why graphql to trace the conflicting versions and apollo-language-server dependency. Reproduce with yarn install and yarn start using the listed Gatsby and gatsby-plugin-codegen versions. Done means type generation completes without the GraphQL dependency conflict.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- graphql, typescript
- Domain
- build-system, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100