Odyssey Voyage II - Monolith graph setup

Hello all!

I’m trying to get setup for Odyssey Voyage II, and it seems to be broken. I’m following the steps described on video/tutorial but it is failing over and over.

Steps to reproduce:
1 - clone the repo at git clone https://github.com/apollographql/odyssey-voyage-II-server
2 - navigate to monolith folder, and install its dependencies by running npm install
3 - yet in monolith folder, run npm run launch - as the tutorial said, it should start the application with all “subgraphs”
4 - Run an example query

On step 3, I’m getting this error:

If i ignore this error, and try to run the query, I get this error here:

 "data": {},
  "errors": [
    {
      "message": "request to http://localhost:4010/listing/amenities failed, reason: connect ECONNREFUSED 127.0.0.1:4010",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "path": [
        "listingAmenities"
      ],
      "extensions": {
        "code": "INTERNAL_SERVER_ERROR",
        "stacktrace": [
          "FetchError: request to http://localhost:4010/listing/amenities failed, reason: connect ECONNREFUSED 127.0.0.1:4010",
          "    at ClientRequest.<anonymous> (/home/rmogio/projects/learning/apollo-professional/odyssey-voyage-II-server/monolith/node_modules/node-fetch/lib/index.js:1491:11)",
          "    at ClientRequest.emit (node:events:513:28)",
          "    at Socket.socketErrorListener (node:_http_client:481:9)",
          "    at Socket.emit (node:events:513:28)",
          "    at emitErrorNT (node:internal/streams/destroy:157:8)",
          "    at emitErrorCloseNT (node:internal/streams/destroy:122:3)",
          "    at processTicksAndRejections (node:internal/process/task_queues:83:21)"
        ]
      }
    }
  ]

All steps can be found here: Monolith graph setup - GraphQL Tutorials

Does anyone have a clue why I’m getting these errors?

Hi there, @r_mogio ! Thanks for reaching out - and I’m sorry that you’re running into this error! Could you let me know which versions of Node and npm you’re currently running? I’ll take a deeper look and see if I can reproduce this error you’re seeing.

hello @lizhennessy !
Sure, they are:
node: v16.17.0
npm: 8.15.0

Thanks @r_mogio ! Looks like that’s probably not the issue.

I can see that the error is coming from the index.js file in services/listings/sequelize/models/index.js. There, we’re looking up some configuration details based on the Node environment (which should default to “development” when running locally). I’m curious to see what’s being generated here, as it appears to be coming back as undefined.

In the services/listings/sequelize/models/index.js file, would you add a console.log statement just below line 8, like so:

// start of the file....

const env = process.env.NODE_ENV || "development";
const config = require(__dirname + "/../config/config.json")[env];
console.log({ config, __dirname, env });

It looks like somewhere along the way we’re not properly accessing those config variables, and I think this will get us closer to uncovering why! With this line in place, you can then run npm run launch and see what kind of output we get in the console.

Looking forward to hearing back!

Liz

hello @lizhennessy , and thanks for your help!

This is what I’m getting on terminal by logging what you asked:

[listings]  CONFIG {
[listings]   config: undefined,
[listings]   __dirname: '/home/rmogio/projects/learning/odyssey-voyage-II-server/services/listings/sequelize/models',
[listings]   env: 'local'
[listings] }

image

Aha! Thank you - I think we may have found our issue. Right now the /../config/config.json file shown on line 8 is looking specifically for a NODE_ENV called “development”, and it’s not finding any config information for one called “local”. Would you jump into that file - specifically, its path is services/listings/sequelize/config/config.json - and update the JSON object to look up “local” rather than “development”, like so:

{
  "local": {
    "username": "root",
    "password": null,
    "database": "database_development",
    "dialect": "sqlite",
    "storage": "./listings.db"
  }
}

Then we can try it again and see if we have any luck getting those config options back!

Liz

hello @lizhennessy , so sorry for this long delay :smile:
good news, now it is working! Thanks again for your help

1 Like

sorry, put in in a wrong place