DEV Community

Cover image for GraphQL Server in under 5 minutes (TypeScript)
Tomek Poniatowicz for GraphQL Editor

Posted on • Updated on • Originally published at blog.graphqleditor.com

GraphQL Server in under 5 minutes (TypeScript)

If you think that setting up a GraphQL server is a difficult task, GraphQL Boilerplates Github repo will prove you that you're very wrong.

The best thing about GraphQL is that is can be used with any technology. Let's take a look at starter projects for most popular web technologies, provided by one of the finest GraphQL devs. Now first off, let's take a look at TypeScript.

TypeScript-graphql-server

TypeScript is a typed superset of JavaScript that compiles to plain JavaScript, which popularity constantly rising. The TypeScript Boilerplate repo contains two starter kits:

Both allowing to bootstrap your GraphQL server with TypeScript within seconds. No matter if you need a Basic option for a simple personal project or Advanced boilerplate with more features you are getting scalable, production-ready GraphQL server.

All projects are based on graphql-yoga, a GraphQL server library focused on providing the easiest possible setup.

Let's take a look at features available in those versions:

Basic Advanced
Scalable GraphQL server: The server uses graphql-yoga which is based on Apollo Server & Express ✔️ ✔️
Static type generation: TypeScript types for GraphQL queries & mutations are generated in a build step ✔️ ✔️
GraphQL database: Includes GraphQL database binding to Prisma (running on MySQL) ✔️ ✔️
Tooling: Out-of-the-box support for GraphQL Playground & query performance tracing ✔️ ✔️
Extensible: Simple and flexible data model – easy to adjust and extend ✔️ ✔️
No configuration overhead: Preconfigured graphql-config setup ✔️ ✔️
Realtime updates: Support for GraphQL subscriptions ✔️
Authentication: Signup and login workflows are ready to use for your users ✔️

The setup is the same for both versions:

graphql create my-app
Enter fullscreen mode Exit fullscreen mode

when prompted pick the desired boilerplate & deploy the Prisma service to a public cluster, then navigate into server directory of your new project and start it:

cd my-app/server

yarn dev
Enter fullscreen mode Exit fullscreen mode

and our project structure will look like this:

Project Structure

Source: Graphql-boilerplates

Top comments (2)

Collapse
 
vadorequest profile image
Vadorequest

Another open-source alternative is our recently published github.com/UnlyEd/next-right-now.

It's a boilerplate for quick getting started with a production-grade project featuring the Next.js framework, hosted on Zeit platform. It includes GraphCMS as built-in, and lots of tooling around GraphQL (GraphQL Schema, etc.)

Note that GraphCMS itself isn't open source, but a third party provider, which takes care of the GraphQL server (API), database and CMS.

Collapse
 
wtrocki profile image
Wojtek Trocki • Edited

As an alternative to the method in blog post, you can check graphback.dev. It will generate a vendor-independent GraphQL server with all logic in generated source code.