Skip to content

apollo-link-http package is incompatible with latest graphql #28

@inkiltie

Description

@inkiltie

Recently I noticed that if you start from scratch with this boilerplate and run npm install or npm update there will be an incompatibility error, which also started bugging me during deployment on Netlify:

12:02:06 AM: npm ERR! code ERESOLVE
12:02:06 AM: npm ERR! ERESOLVE could not resolve
12:02:06 AM: npm ERR!
12:02:06 AM: npm ERR! While resolving: apollo-link-http@1.5.17
12:02:06 AM: Creating deploy upload records
12:02:06 AM: npm ERR! Found: graphql@16.0.1
12:02:06 AM: npm ERR! node_modules/graphql
12:02:06 AM: npm ERR!   graphql@"^16.0.1" from the root project
12:02:06 AM: npm ERR!   peer graphql@"^14.0.0 || ^15.0.0 || ^16.0.0" from @apollo/client@3.5.5
12:02:06 AM: npm ERR!   node_modules/@apollo/client
12:02:06 AM: Failed during stage 'building site': Build script returned non-zero exit code: 1 (https://ntl.fyi/exit-code-1)
12:02:06 AM: npm ERR!     @apollo/client@"^3.5.5" from the root project
12:02:06 AM: npm ERR!     peer @apollo/client@"^3.2.5" from apollo3-cache-persist@0.14.0
12:02:06 AM: npm ERR!     node_modules/apollo3-cache-persist
12:02:06 AM: npm ERR!       apollo3-cache-persist@"^0.14.0" from the root project
12:02:06 AM: npm ERR!   2 more (@graphql-typed-document-node/core, graphql-tag)
12:02:06 AM: npm ERR!
12:02:06 AM: npm ERR! Could not resolve dependency:
12:02:06 AM: npm ERR! peer graphql@"^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0" from apollo-link-http@1.5.17
12:02:06 AM: npm ERR! node_modules/apollo-link-http
12:02:06 AM: npm ERR!   apollo-link-http@"^1.5.17" from the root project
12:02:06 AM: npm ERR!
12:02:06 AM: npm ERR! Conflicting peer dependency: graphql@15.8.0
12:02:06 AM: npm ERR! node_modules/graphql
12:02:06 AM: npm ERR!   peer graphql@"^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0" from apollo-link-http@1.5.17
12:02:06 AM: npm ERR!   node_modules/apollo-link-http
12:02:06 AM: npm ERR!     apollo-link-http@"^1.5.17" from the root project
12:02:06 AM: npm ERR!
12:02:06 AM: npm ERR! Fix the upstream dependency conflict, or retry
12:02:06 AM: npm ERR! this command with --force, or --legacy-peer-deps
12:02:06 AM: npm ERR! to accept an incorrect (and potentially broken) dependency resolution.

Forcing it with --force doesn't make sense to me, while --legacy-peer-deps will downgrade graphql package to 15.8.

So I dag deeper and realized that apollo-link-http package is over 2 years old and it's practically not that important because all its functionality is already present in @apollo/client itself.

Solution:

  1. Uninstall apollo-link-http
  2. Change client.js with the following: import { ApolloClient, ApolloLink, HttpLink, InMemoryCache } from "@apollo/client";, where HttpLink added

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions