You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Whenever I initiate any sort of request to the server, be it using the provided curl command, or by visiting http://localhost:4000/graphql in the browser, the request always stalls and provides nothing, not even an error.
I've gone through the project with a fine-tooth comb, and cannot find any deviations in my code from the tutorial.
Here's /index.ts:
import { ApolloServer, gql } from 'apollo-server-express';
import cors from 'cors';
import express from 'express';
import { chats } from './db';
import schema from './schema';
const app = express();
app.use(cors());
app.use(express.json);
app.get('/_ping', (req, res) => {
res.send('pong');
res.json(chats);
});
const server = new ApolloServer({
schema,
//playground: true,
//introspection: true,
});
server.applyMiddleware({ app, cors: true, path: '/graphql' });
const port = process.env.PORT || 4000;
//process.env.PLAYGROUND_URL = "http://localhost:4000";
app.listen(port, () => {
console.log(`Server is listening on port ${port}`);
//console.log(process.env.NODE_ENV);
})
The issue was two lines that I didn't notice were deleted in the tutorial (note: during that step in the tutorial, a different version of the file is being presented; added/deleted lines are not representing the sequential state of the tutorial app):
By removing app.use(cors()) and app.use(express.json), then ApolloServer can do its thing :-) A better description of this would be helpful, but this issue is now resolved.
amunrarara
changed the title
[Server Step 2.3] -- Server requests do nothing, 'hanging'
(SOLVED) [Server Step 2.3] -- Server requests do nothing, 'hanging'
Apr 15, 2020
Whenever I initiate any sort of request to the server, be it using the provided curl command, or by visiting http://localhost:4000/graphql in the browser, the request always stalls and provides nothing, not even an error.
I've gone through the project with a fine-tooth comb, and cannot find any deviations in my code from the tutorial.
Here's /index.ts:
Here is also /schema/resolvers.ts
I won't bother copying over /schema/index.ts, nor /schema/typeDefs.graphql, nor /db.ts, since they are identical to the tutorial.
The text was updated successfully, but these errors were encountered: