I’ve completed Connecting the dots in server-land.
And now that I try and run the app, I get
"exception": {
"message": "request to https://odyssey-lift-off-rest-api.herokuapp.com/tracks failed, reason: getaddrinfo ENOTFOUND odyssey-lift-off-rest-api.herokuapp.com",
"type": "system",
"errno": "ENOTFOUND",
"code": "ENOTFOUND",
...,
}
and the problem seems to be when I switch from the mocks to the resolvers and dataSources.
Any advice?
Hi @rudiwever!
Would you be able to share your code for the server file (or the whole repo)? There might be a typo or something there we’re not seeing with the way the pieces are connected together.
I also tried to access the endpoint directly (https://odyssey-lift-off-rest-api.herokuapp.com/tracks) and I can see the JSON data, so we can rule that one out as the cause of the issue.
Hope we can troubleshoot this together!
Hi Michelle,
I tried the endpoint as well, and yes it works.
Here is the code for the server…
/src/server/index.js
const { ApolloServer } = require(‘apollo-server’);
const typeDefs = require(‘./schema’);
const resolvers = require(‘./resolvers’);
const TrackAPI = require(‘./datasources/track-api’);
const mocks = {
Query: () => ({
tracksForHome: () => […new Array(9)],
}),
Track: () => ({
id: () => ‘track_01’,
title: () => ‘Astro Kitty, Space Explorer’,
author: () => {
return {
name: ‘Grumpy Cat’,
photo: ‘https://res.cloudinary.com/dety84pbu/image/upload/v1606816219/kitty-veyron-sm_mctf3c.jpg’,
};
},
thumbnail: () => ‘https://res.cloudinary.com/dety84pbu/image/upload/v1598465568/nebula_cat_djkt9r.jpg’,
length: () => 1210,
modulesCount: () => 6,
}),
};
//THIS SERVER WORKS
const server2 = new ApolloServer({
typeDefs,
mocks,
});
//THIS SERVER FAILS
const server = new ApolloServer({
typeDefs,
resolvers,
dataSources: () => {
return {
trackAPI: new TrackAPI(),
};
},
});
server.listen().then(() => {
console.log(`
Server is running!
Listening on port 4000
`);
});
Thanks for that info! Where are you seeing the error? Is it in the server console terminal? The client browser?