Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hello route was missing and how I solved #3

Open
ssabat opened this issue Sep 27, 2020 · 1 comment
Open

Hello route was missing and how I solved #3

ssabat opened this issue Sep 27, 2020 · 1 comment

Comments

@ssabat
Copy link

ssabat commented Sep 27, 2020

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 = gqltype 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

@alexandr-g
Copy link
Owner

Hi Sunil @ssabat,

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! 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants