I've been using this set-up for a few weeks now, does your gateway application crash when nodemon restarts one of your services?
Apollo throws this error "This data graph is missing a valid configuration. Couldn't load service definitions for "accounts" at localhost:4001: request to localhost:4001/ failed, reason: connect ECONNREFUSED 127.0.0.1:4001" when ever nodemon restarts one of my servers.
I'm not confused as to why this is happening as obviously the gateway server is dependant on the services. Have you encountered this and if so do you have a work around?
Automatic reloading of the gateway can be an issue, even with wait-on in place. You may want to look at some experimental features of Apollo Gateway (github.com/apollographql/federatio...) to help facilitate this, or look into managed federation instead.
importwaitOnfrom'wait-on'importappfrom'./config/app'importserverfrom'./config/apollo'constport=process.env.PORTconstoptions={resources:['tcp:4001'],}waitOn(options).then(()=>{server.applyMiddleware({app})app.listen({port},()=>{console.log(`Server ready at http://localhost:${port}${server.graphqlPath}`)})}).catch((err)=>{console.error('ERR:',err)})
Give this a try!
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Hi Mandi,
I've been using this set-up for a few weeks now, does your gateway application crash when nodemon restarts one of your services?
Apollo throws this error "This data graph is missing a valid configuration. Couldn't load service definitions for "accounts" at localhost:4001: request to localhost:4001/ failed, reason: connect ECONNREFUSED 127.0.0.1:4001" when ever nodemon restarts one of my servers.
I'm not confused as to why this is happening as obviously the gateway server is dependant on the services. Have you encountered this and if so do you have a work around?
Automatic reloading of the gateway can be an issue, even with wait-on in place. You may want to look at some experimental features of Apollo Gateway (github.com/apollographql/federatio...) to help facilitate this, or look into managed federation instead.
Easy solution to the development problem I referenced is to use wait-on in index.js before building the gateway rather than in the command line.
This way when nodemon restarts the gateway server it waits for the other services on every restart, not just the first time we run the command.
Thought I'd mention this for anyone who ran into the same problem.
Hi, can you give an example on how you solved this? I'm facing the same issue but can't make it work.
Give this a try!