DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’» is a community of 967,611 amazing developers

We're a place where coders share, stay up-to-date and grow their careers.

Create account Log in

Discussion on: Building A GraphQL Server With Next.js API Routes

Collapse
 
lyonwj profile image
William Lyon Author

Hi Pako - what issues did you run into?

Yes, you can use whatever file strucutre makes sense and import as modules as necessary, and still leverage Next.js's file-based router convention (so in pages/api/foobar.js just import as modules any lib type code that you want to use).

Collapse
 
pakman198 profile image
Pako

So my first thought was:
Vercel basically allows you to deploy compiled frontend apps, so maybe I would need to compile the playground to present it as my frontend app and all my routes move them to lambdas.
But I didn't know in what direction to go so I just went with Heroku.

2 years ago I took Wes Bos' advanced react course with graphql and I was able to deploy the app in vercel, but that was before they added the new /api file structure.

Anyways, I'll try to update my code and upload it to vercel and if I have some problems deploying I might reach out for help :P

Thread Thread
 
lyonwj profile image
William Lyon Author

Gotcha. You can serve GraphQL Playground from a Next.js API Route. In Apollo Server 3 you'll just need to enable it via a plugin: apollographql.com/docs/apollo-serv...