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
I could not get to http://localhost:3000/api/hello because hello.js was missing under ../pages/api folder.
So, I created hello.js page. Then, I found that I have to pass a query string called sayHello.
I did that as well. Now, I can get correct result at
I thought I would share my findings with you so that you can commit the changes if you want to make this article in sync with git repo. One minor typo - Vie should read as Via in the paragraph titled Configuring .env variables.
Thanks,
Sunil
The text was updated successfully, but these errors were encountered:
That's awesome! Thanks for sharing and your contribution 👍 I think you're right something is off there, glad that you found a way to solve it. I'll revisit it when I'll have time. The typo should be fixed now. Thanks for pointing that out! 🙂
Hi Alexander,
I cloned this git repo and tried to run the app. I was following your article at https://levelup.gitconnected.com/setting-up-graphql-api-with-mongodb-and-apollo-server-for-a-nextjs-app-cec7a9baedbf
I could not get to http://localhost:3000/api/hello because hello.js was missing under ../pages/api folder.
So, I created hello.js page. Then, I found that I have to pass a query string called sayHello.
I did that as well. Now, I can get correct result at
http://localhost:3000/api/hello?{query=sayHello} as
{"data":{"sayHello":"Hello World!"}}
hello.js code I used is as follows:
`import { ApolloServer, gql } from 'apollo-server-micro'
const typeDefs = gql
type Query { sayHello: String }
const resolvers = {
Query: {
sayHello(parent, args, context) {
return 'Hello World!'
},
},
}
export const config = {
api: {
bodyParser: false,
},
}
const apolloServer = new ApolloServer({ typeDefs, resolvers })
export default apolloServer.createHandler({ path: '/api/hello' })`
I thought I would share my findings with you so that you can commit the changes if you want to make this article in sync with git repo. One minor typo - Vie should read as Via in the paragraph titled Configuring .env variables.
Thanks,
Sunil
The text was updated successfully, but these errors were encountered: