question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Doesn't start up on 'npm run start-services' [Solved in Pull Req #74]

See original GitHub issue

Environment: MacOS Node Version 14.17.6

Full error log:

> federation-demo@ start-services /Users/home/@DEV/federation-demo
> concurrently "npm:start-service-*"

[start-service-accounts] 
[start-service-accounts] > federation-demo@ start-service-accounts /Users/home/@DEV/federation-demo
[start-service-accounts] > nodemon services/accounts/index.js
[start-service-accounts] 
[start-service-products] 
[start-service-products] > federation-demo@ start-service-products /Users/home/@DEV/federation-demo
[start-service-products] > nodemon services/products/index.js
[start-service-products] 
[start-service-reviews] 
[start-service-reviews] > federation-demo@ start-service-reviews /Users/home/@DEV/federation-demo
[start-service-reviews] > nodemon services/reviews/index.js
[start-service-reviews] 
[start-service-inventory] 
[start-service-inventory] > federation-demo@ start-service-inventory /Users/home/@DEV/federation-demo
[start-service-inventory] > nodemon services/inventory/index.js
[start-service-inventory] 
[start-service-accounts] [nodemon] 2.0.15
[start-service-accounts] [nodemon] to restart at any time, enter `rs`
[start-service-accounts] [nodemon] watching path(s): *.*
[start-service-accounts] [nodemon] watching extensions: js,mjs,json
[start-service-accounts] [nodemon] starting `node services/accounts/index.js`
[start-service-products] [nodemon] 2.0.15
[start-service-reviews] [nodemon] 2.0.15
[start-service-products] [nodemon] to restart at any time, enter `rs`
[start-service-products] [nodemon] watching path(s): *.*
[start-service-products] [nodemon] watching extensions: js,mjs,json
[start-service-reviews] [nodemon] to restart at any time, enter `rs`
[start-service-products] [nodemon] starting `node services/products/index.js`
[start-service-reviews] [nodemon] watching path(s): *.*
[start-service-reviews] [nodemon] watching extensions: js,mjs,json
[start-service-reviews] [nodemon] starting `node services/reviews/index.js`
[start-service-inventory] [nodemon] 2.0.15
[start-service-inventory] [nodemon] to restart at any time, enter `rs`
[start-service-inventory] [nodemon] watching path(s): *.*
[start-service-inventory] [nodemon] watching extensions: js,mjs,json
[start-service-inventory] [nodemon] starting `node services/inventory/index.js`
[start-service-reviews] /Users/home/@DEV/federation-demo/services/reviews/node_modules/apollo-graphql/lib/schema/buildSchemaFromSDL.js:50
[start-service-reviews]         throw new GraphQLSchemaValidationError_1.GraphQLSchemaValidationError(errors);
[start-service-reviews]         ^
[start-service-reviews] 
[start-service-reviews] GraphQLSchemaValidationError: Cannot extend type "User" because it is not defined.
[start-service-reviews] 
[start-service-reviews] Cannot extend type "Product" because it is not defined.
[start-service-reviews]     at buildSchemaFromSDL (/Users/home/@DEV/federation-demo/services/reviews/node_modules/apollo-graphql/lib/schema/buildSchemaFromSDL.js:50:15)
[start-service-reviews]     at buildSubgraphSchema (/Users/home/@DEV/federation-demo/services/reviews/node_modules/@apollo/subgraph/dist/buildSubgraphSchema.js:26:58)
[start-service-reviews]     at deprecated (internal/util.js:96:15)
[start-service-reviews]     at Object.<anonymous> (/Users/home/@DEV/federation-demo/services/reviews/index.js:50:11)
[start-service-reviews]     at Module._compile (internal/modules/cjs/loader.js:1072:14)
[start-service-reviews]     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10)
[start-service-reviews]     at Module.load (internal/modules/cjs/loader.js:937:32)
[start-service-reviews]     at Function.Module._load (internal/modules/cjs/loader.js:778:12)
[start-service-reviews]     at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)
[start-service-reviews]     at internal/main/run_main_module.js:17:47 {
[start-service-reviews]   errors: [
[start-service-reviews]     GraphQLError: Cannot extend type "User" because it is not defined.
[start-service-reviews]         at Object.checkExtension (/Users/home/@DEV/federation-demo/services/reviews/node_modules/graphql/validation/rules/PossibleTypeExtensionsRule.js:83:9)
[start-service-reviews]         at Object.enter (/Users/home/@DEV/federation-demo/services/reviews/node_modules/graphql/language/visitor.js:303:32)
[start-service-reviews]         at visit (/Users/home/@DEV/federation-demo/services/reviews/node_modules/graphql/language/visitor.js:200:21)
[start-service-reviews]         at Object.validateSDL (/Users/home/@DEV/federation-demo/services/reviews/node_modules/graphql/validation/validate.js:121:22)
[start-service-reviews]         at buildSchemaFromSDL (/Users/home/@DEV/federation-demo/services/reviews/node_modules/apollo-graphql/lib/schema/buildSchemaFromSDL.js:48:31)
[start-service-reviews]         at buildSubgraphSchema (/Users/home/@DEV/federation-demo/services/reviews/node_modules/@apollo/subgraph/dist/buildSubgraphSchema.js:26:58)
[start-service-reviews]         at deprecated (internal/util.js:96:15)
[start-service-reviews]         at Object.<anonymous> (/Users/home/@DEV/federation-demo/services/reviews/index.js:50:11)
[start-service-reviews]         at Module._compile (internal/modules/cjs/loader.js:1072:14)
[start-service-reviews]         at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10) {
[start-service-reviews]       path: undefined,
[start-service-reviews]       locations: undefined,
[start-service-reviews]       extensions: [Object: null prototype] {}
[start-service-reviews]     },
[start-service-reviews]     GraphQLError: Cannot extend type "Product" because it is not defined.
[start-service-reviews]         at Object.checkExtension (/Users/home/@DEV/federation-demo/services/reviews/node_modules/graphql/validation/rules/PossibleTypeExtensionsRule.js:83:9)
[start-service-reviews]         at Object.enter (/Users/home/@DEV/federation-demo/services/reviews/node_modules/graphql/language/visitor.js:303:32)
[start-service-reviews]         at visit (/Users/home/@DEV/federation-demo/services/reviews/node_modules/graphql/language/visitor.js:200:21)
[start-service-reviews]         at Object.validateSDL (/Users/home/@DEV/federation-demo/services/reviews/node_modules/graphql/validation/validate.js:121:22)
[start-service-reviews]         at buildSchemaFromSDL (/Users/home/@DEV/federation-demo/services/reviews/node_modules/apollo-graphql/lib/schema/buildSchemaFromSDL.js:48:31)
[start-service-reviews]         at buildSubgraphSchema (/Users/home/@DEV/federation-demo/services/reviews/node_modules/@apollo/subgraph/dist/buildSubgraphSchema.js:26:58)
[start-service-reviews]         at deprecated (internal/util.js:96:15)
[start-service-reviews]         at Object.<anonymous> (/Users/home/@DEV/federation-demo/services/reviews/index.js:50:11)
[start-service-reviews]         at Module._compile (internal/modules/cjs/loader.js:1072:14)
[start-service-reviews]         at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10) {
[start-service-reviews]       path: undefined,
[start-service-reviews]       locations: undefined,
[start-service-reviews]       extensions: [Object: null prototype] {}
[start-service-reviews]     }
[start-service-reviews]   ]
[start-service-reviews] }
[start-service-accounts] /Users/home/@DEV/federation-demo/services/accounts/node_modules/apollo-graphql/lib/schema/buildSchemaFromSDL.js:50
[start-service-accounts]         throw new GraphQLSchemaValidationError_1.GraphQLSchemaValidationError(errors);
[start-service-accounts]         ^
[start-service-accounts] 
[start-service-accounts] GraphQLSchemaValidationError: Cannot extend type "Query" because it is not defined. Did you mean "User"?
[start-service-accounts]     at buildSchemaFromSDL (/Users/home/@DEV/federation-demo/services/accounts/node_modules/apollo-graphql/lib/schema/buildSchemaFromSDL.js:50:15)
[start-service-accounts]     at buildSubgraphSchema (/Users/home/@DEV/federation-demo/services/accounts/node_modules/@apollo/subgraph/dist/buildSubgraphSchema.js:26:58)
[start-service-accounts]     at deprecated (internal/util.js:96:15)
[start-service-accounts]     at Object.<anonymous> (/Users/home/@DEV/federation-demo/services/accounts/index.js:30:11)
[start-service-accounts]     at Module._compile (internal/modules/cjs/loader.js:1072:14)
[start-service-accounts]     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10)
[start-service-accounts]     at Module.load (internal/modules/cjs/loader.js:937:32)
[start-service-accounts]     at Function.Module._load (internal/modules/cjs/loader.js:778:12)
[start-service-accounts]     at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)
[start-service-accounts]     at internal/main/run_main_module.js:17:47 {
[start-service-accounts]   errors: [
[start-service-accounts]     GraphQLError: Cannot extend type "Query" because it is not defined. Did you mean "User"?
[start-service-accounts]         at Object.checkExtension (/Users/home/@DEV/federation-demo/services/accounts/node_modules/graphql/validation/rules/PossibleTypeExtensionsRule.js:83:9)
[start-service-accounts]         at Object.enter (/Users/home/@DEV/federation-demo/services/accounts/node_modules/graphql/language/visitor.js:303:32)
[start-service-accounts]         at visit (/Users/home/@DEV/federation-demo/services/accounts/node_modules/graphql/language/visitor.js:200:21)
[start-service-accounts]         at Object.validateSDL (/Users/home/@DEV/federation-demo/services/accounts/node_modules/graphql/validation/validate.js:121:22)
[start-service-accounts]         at buildSchemaFromSDL (/Users/home/@DEV/federation-demo/services/accounts/node_modules/apollo-graphql/lib/schema/buildSchemaFromSDL.js:48:31)
[start-service-accounts]         at buildSubgraphSchema (/Users/home/@DEV/federation-demo/services/accounts/node_modules/@apollo/subgraph/dist/buildSubgraphSchema.js:26:58)
[start-service-accounts]         at deprecated (internal/util.js:96:15)
[start-service-accounts]         at Object.<anonymous> (/Users/home/@DEV/federation-demo/services/accounts/index.js:30:11)
[start-service-accounts]         at Module._compile (internal/modules/cjs/loader.js:1072:14)
[start-service-accounts]         at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10) {
[start-service-accounts]       path: undefined,
[start-service-accounts]       locations: undefined,
[start-service-accounts]       extensions: [Object: null prototype] {}
[start-service-accounts]     }
[start-service-accounts]   ]
[start-service-accounts] }
[start-service-reviews] [nodemon] app crashed - waiting for file changes before starting...
[start-service-products] /Users/home/@DEV/federation-demo/services/products/node_modules/apollo-graphql/lib/schema/buildSchemaFromSDL.js:50
[start-service-products]         throw new GraphQLSchemaValidationError_1.GraphQLSchemaValidationError(errors);
[start-service-products]         ^
[start-service-products] 
[start-service-products] GraphQLSchemaValidationError: Cannot extend type "Query" because it is not defined.
[start-service-products]     at buildSchemaFromSDL (/Users/home/@DEV/federation-demo/services/products/node_modules/apollo-graphql/lib/schema/buildSchemaFromSDL.js:50:15)
[start-service-products]     at buildSubgraphSchema (/Users/home/@DEV/federation-demo/services/products/node_modules/@apollo/subgraph/dist/buildSubgraphSchema.js:26:58)
[start-service-products]     at deprecated (internal/util.js:96:15)
[start-service-products]     at Object.<anonymous> (/Users/home/@DEV/federation-demo/services/products/index.js:31:11)
[start-service-products]     at Module._compile (internal/modules/cjs/loader.js:1072:14)
[start-service-products]     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10)
[start-service-products]     at Module.load (internal/modules/cjs/loader.js:937:32)
[start-service-products]     at Function.Module._load (internal/modules/cjs/loader.js:778:12)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)
[start-service-products]     at internal/main/run_main_module.js:17:47 {
[start-service-products]   errors: [
[start-service-products]     GraphQLError: Cannot extend type "Query" because it is not defined.
[start-service-products]         at Object.checkExtension (/Users/home/@DEV/federation-demo/services/products/node_modules/graphql/validation/rules/PossibleTypeExtensionsRule.js:83:9)
[start-service-products]         at Object.enter (/Users/home/@DEV/federation-demo/services/products/node_modules/graphql/language/visitor.js:303:32)
[start-service-products]         at visit (/Users/home/@DEV/federation-demo/services/products/node_modules/graphql/language/visitor.js:200:21)
[start-service-products]         at Object.validateSDL (/Users/home/@DEV/federation-demo/services/products/node_modules/graphql/validation/validate.js:121:22)
[start-service-products]         at buildSchemaFromSDL (/Users/home/@DEV/federation-demo/services/products/node_modules/apollo-graphql/lib/schema/buildSchemaFromSDL.js:48:31)
[start-service-products]         at buildSubgraphSchema (/Users/home/@DEV/federation-demo/services/products/node_modules/@apollo/subgraph/dist/buildSubgraphSchema.js:26:58)
[start-service-products]         at deprecated (internal/util.js:96:15)
[start-service-products]         at Object.<anonymous> (/Users/home/@DEV/federation-demo/services/products/index.js:31:11)
[start-service-products]         at Module._compile (internal/modules/cjs/loader.js:1072:14)
[start-service-products]         at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10) {
[start-service-products]       path: undefined,
[start-service-products]       locations: undefined,
[start-service-products]       extensions: [Object: null prototype] {}
[start-service-products]     }
[start-service-products]   ]
[start-service-products] }
[start-service-accounts] [nodemon] app crashed - waiting for file changes before starting...
[start-service-products] [nodemon] app crashed - waiting for file changes before starting...
[start-service-inventory] /Users/home/@DEV/federation-demo/services/inventory/node_modules/apollo-graphql/lib/schema/buildSchemaFromSDL.js:50
[start-service-inventory]         throw new GraphQLSchemaValidationError_1.GraphQLSchemaValidationError(errors);
[start-service-inventory]         ^
[start-service-inventory] 
[start-service-inventory] GraphQLSchemaValidationError: Cannot extend type "Product" because it is not defined.
[start-service-inventory]     at buildSchemaFromSDL (/Users/home/@DEV/federation-demo/services/inventory/node_modules/apollo-graphql/lib/schema/buildSchemaFromSDL.js:50:15)
[start-service-inventory]     at buildSubgraphSchema (/Users/home/@DEV/federation-demo/services/inventory/node_modules/@apollo/subgraph/dist/buildSubgraphSchema.js:26:58)
[start-service-inventory]     at deprecated (internal/util.js:96:15)
[start-service-inventory]     at Object.<anonymous> (/Users/home/@DEV/federation-demo/services/inventory/index.js:32:11)
[start-service-inventory]     at Module._compile (internal/modules/cjs/loader.js:1072:14)
[start-service-inventory]     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10)
[start-service-inventory]     at Module.load (internal/modules/cjs/loader.js:937:32)
[start-service-inventory]     at Function.Module._load (internal/modules/cjs/loader.js:778:12)
[start-service-inventory]     at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)
[start-service-inventory]     at internal/main/run_main_module.js:17:47 {
[start-service-inventory]   errors: [
[start-service-inventory]     GraphQLError: Cannot extend type "Product" because it is not defined.
[start-service-inventory]         at Object.checkExtension (/Users/home/@DEV/federation-demo/services/inventory/node_modules/graphql/validation/rules/PossibleTypeExtensionsRule.js:83:9)
[start-service-inventory]         at Object.enter (/Users/home/@DEV/federation-demo/services/inventory/node_modules/graphql/language/visitor.js:303:32)
[start-service-inventory]         at visit (/Users/home/@DEV/federation-demo/services/inventory/node_modules/graphql/language/visitor.js:200:21)
[start-service-inventory]         at Object.validateSDL (/Users/home/@DEV/federation-demo/services/inventory/node_modules/graphql/validation/validate.js:121:22)
[start-service-inventory]         at buildSchemaFromSDL (/Users/home/@DEV/federation-demo/services/inventory/node_modules/apollo-graphql/lib/schema/buildSchemaFromSDL.js:48:31)
[start-service-inventory]         at buildSubgraphSchema (/Users/home/@DEV/federation-demo/services/inventory/node_modules/@apollo/subgraph/dist/buildSubgraphSchema.js:26:58)
[start-service-inventory]         at deprecated (internal/util.js:96:15)
[start-service-inventory]         at Object.<anonymous> (/Users/home/@DEV/federation-demo/services/inventory/index.js:32:11)
[start-service-inventory]         at Module._compile (internal/modules/cjs/loader.js:1072:14)
[start-service-inventory]         at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10) {
[start-service-inventory]       path: undefined,
[start-service-inventory]       locations: undefined,
[start-service-inventory]       extensions: [Object: null prototype] {}
[start-service-inventory]     }
[start-service-inventory]   ]
[start-service-inventory] }
[start-service-inventory] [nodemon] app crashed - waiting for file changes before starting...
^C[start-service-accounts] npm run start-service-accounts exited with code 0
[start-service-inventory] npm run start-service-inventory exited with code 0
[start-service-reviews] npm run start-service-reviews exited with code 0
[start-service-products] npm run start-service-products exited with code 0

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
kyle-bannercommented, Jan 15, 2022

For anyone that doesn’t want to change the code use the below versions in the parent-level package.json:

  "dependencies": {
    "@apollo/gateway": "^0.28.1",
    "apollo-server": "^2.24.1",
    "graphql": "^15.5.0"
  }

and the below in each of the services’ package.json:

  "dependencies": {
    "@apollo/federation": "^0.25.0",
    "apollo-server": "^2.24.1",
    "graphql": "^15.5.0"
  }

I’m assuming the above errors are thrown because the package.jsons are using “latest” when they should be locked down to v1 when this demo was written. Federation v2 was just released and I’m assuming these package.jsons are pulling down v2. My versions aren’t the latest for v1 but will at least make their code functional.

1reaction
Maxwell2022commented, Dec 2, 2021

extend type .... is not working (anymore?) you need to use the @extends directive. This is really badly documented.

extend type User @key(fields: "id") {
    id: ID! @external
    username: String @external
    reviews: [Review]
  }

becomes

type User @extend @key(fields: "id") {
    id: ID! @external
    username: String @external
    reviews: [Review]
  }

it looks like extend is a reserved keyword to extend type from the same schema definition file

Read more comments on GitHub >

github_iconTop Results From Across the Web

Issues · apollographql/federation-demo - GitHub
Doesn't start up on 'npm run start-services' [Solved in Pull Req #74] ... How to write resolver which need access to additional data...
Read more >
Start script missing error when running npm start
It looks like you might not have defined a start script in your package.json file or your project does not contain a server.js...
Read more >
Common errors | npm Docs
Some strange issues can be resolved by simply running npm cache clean and trying again. If you are having trouble with npm install...
Read more >
How to Use Forked NPM Dependencies in React | Pluralsight
While you wait for a pull request to get merged, you can use the ... When using open-source software in your project, odds...
Read more >
You should never ever run directly against Node.js in ...
The development problem is that when we change the code, we have to stop and start the application to get our changes picked...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found