kamilkisiela / apollo-angular

A fully-featured, production ready caching GraphQL client for Angular and every GraphQL server 🎁
https://apollo-angular.com
MIT License
1.5k stars 311 forks source link

The URI in graphql.module.ts expects only the path, contrary to the documentation #1718

Closed tr32 closed 2 years ago

tr32 commented 3 years ago

Describe the bug

Contrary to the v2 documentation (https://apollo-angular.com/docs/get-started), the URI in graphql.module.ts does not work with a complete URL like const uri = 'http://localhost:8091/graphql' but works with const uri = '/graphql'.

With a complete URL, I get the following error, e. g.:

Error: Cannot read properties of undefined (reading 'message')
    at new ApolloError (index.js:29)
    at QueryManager.js:611
    at both (asyncMap.js:16)
    at asyncMap.js:9
    at new ZoneAwarePromise (zone.js:1387)
    at Object.then (asyncMap.js:9)
    at Object.error (asyncMap.js:17)
    at notifySubscription (module.js:137)
    at onNotify (module.js:176)
    at SubscriptionObserver.error (module.js:229)

To Reproduce Steps to reproduce the behavior:

Follow the documentation here https://apollo-angular.com/docs/get-started for version v2

Expected behavior

  1. Should not raise ApolloError if a complete URL (like http://localhost:8091/graphql) is used in HttpLink (apollo-angular/http).
  2. A complete POST request to the graphql endpoint and return the expected query result.

Environment:

- @angular-devkit/build-angular@12.2.8
- @angular/cli@12.2.8
- @angular/core@12.2.8
- @apollo/client@3.4.16
- apollo-angular@2.6.0
- graphql@15.6.0
- typescript@4.3.5

- node: v14.16.1

Additional context

kamilkisiela commented 2 years ago

It works, check the packages/demo or any other example