apollo-angular icon indicating copy to clipboard operation
apollo-angular copied to clipboard

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

Open chriswoodie opened this issue 1 year ago • 1 comments

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/[email protected] ├── @angular/[email protected] ├── @apollo/[email protected] ├── [email protected] ├── [email protected] └── [email protected]

Additional context

None

chriswoodie avatar Jul 03 '23 12:07 chriswoodie

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.

Kaemmelot avatar Jul 19 '23 21:07 Kaemmelot