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 309 forks source link

TypeError: Cannot read properties of undefined (reading 'architect') #2046

Closed chriswoodie closed 1 week ago

chriswoodie commented 1 year ago

Describe the bug Running nx g apollo-angular:ng-add results in the following error after providing graphql api url and graphql version:

TypeError: Cannot read properties of undefined (reading 'architect')
    at getMainPath (/Users/myuser/Documents/foo/node_modules/apollo-angular/schematics/utils/project.js:10:21)

To Reproduce

Steps to reproduce the behavior:

  1. Create a Nx project
  2. Create an angular application (not sure if this step is needed)
  3. Run npm install apollo-angular
  4. Run nx g apollo-angular:ng-add, fill in the questions that appear
  5. See error

Expected behavior

Not an error to be thrown.

Environment:

├── @angular/cli@16.0.6 ├── @angular/core@16.0.6 ├── @apollo/client@3.7.16 ├── apollo-angular@5.0.0 ├── graphql@16.7.1 └── typescript@5.0.4

Additional context

None

Kaemmelot commented 1 year ago

The problem seems to be in multi-project angular applications. In this line the defaultProject is undefined because it was deprecated quite some time ago and is now finally removed via migrations. So the default project should be determined based on the working directory and not based on the angular.json file.

PowerKiKi commented 1 week ago

I think it might have been fixed in the past months. Please re-open if still experienced with latest version.