---
title: "How to Build a GraphQL Server with Deno"
description: "A GraphQL API server can be built in Deno with the std HTTP Server, the gql middleware, graphql_tools' makeExecutableSchema and graphql_tag."
url: "https://swe.quest/articles/how-to-build-a-graphql-server-with-deno-b4bf15abf8edf07f"
canonical: "https://deno.com/blog/build-a-graphql-server-with-deno"
source: "Deno"
published: "2023-01-11"
difficulty: "medium"
kind: "How-to"
reading_minutes: 7
tags: ["graphql","typescript","postgres","api-design"]
---

# How to Build a GraphQL Server with Deno

A post on [Deno](https://swe.quest/sources/deno.md), published 2023-01-11, 7 min read, How-to. Original: [https://deno.com/blog/build-a-graphql-server-with-deno](https://deno.com/blog/build-a-graphql-server-with-deno)

## Summary

A GraphQL API server can be built in Deno with the std HTTP Server, the gql middleware, graphql\_tools' makeExecutableSchema and graphql\_tag. The walkthrough starts with a "Hello, World!" query served at /graphql with GraphiQL enabled, then refactors into separate type definition and resolver files. The expanded version adds Postgres-backed queries (allDinosaurs, oneDinosaur) and an addDinosaur mutation using deno-postgres connection pools and tagged-template SQL. It runs with the --allow-net and --allow-env permission flags.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [GraphQL](https://swe.quest/tags/graphql.md) (Backend & APIs)
- [TypeScript](https://swe.quest/tags/typescript.md) (Languages)
- [PostgreSQL](https://swe.quest/tags/postgres.md) (Data & databases)
- [API design](https://swe.quest/tags/api-design.md) (Backend & APIs)

## Prerequisites

- GraphQL basics ([easy posts on GraphQL](https://swe.quest/tags/graphql.md?difficulty=easy))
- TypeScript ([easy posts on TypeScript](https://swe.quest/tags/typescript.md?difficulty=easy))
- SQL basics ([easy posts on SQL](https://swe.quest/tags/sql.md?difficulty=easy))

## Keywords

Deno, GraphQL, GraphiQL, PostgreSQL, graphql\_tools, deno-postgres, Supabase

## Related posts

- [Persist Data in Deno with npm using Prisma, Mongoose, Apollo, and more.](https://swe.quest/articles/persist-data-in-deno-with-npm-using-prisma-mongoose-apollo-and-more-93a981bba3f6dd39.md): Deno · 2022-11-15 · Medium · 7 min read · JavaScript, TypeScript, Databases, GraphQL
  Deno's npm: specifiers let you use popular data-layer packages directly, with Deno's opt-in permission flags limiting what a possibly compromised dependency can reach, such as environment variables holding database credentials.
- [pg\_graphql: A GraphQL extension for PostgreSQL](https://swe.quest/articles/pg-graphql-a-graphql-extension-for-postgresql-3a34efbe6d730fc2.md): Supabase · 2021-12-03 · Medium · 4 min read · GraphQL, PostgreSQL, API design
  pg\_graphql is an open-source PostgreSQL extension, written in C and SQL, that reflects a GraphQL schema from existing tables and resolves queries entirely inside the database.
- [How pg\_graphql works](https://swe.quest/articles/how-pg-graphql-works-70dff1dd9d5a0c27.md): Supabase · 2024-01-24 · Medium · 9 min read · GraphQL, PostgreSQL, Rust, Compilers
  pg\_graphql is a Rust-based Postgres extension that reflects the SQL schema as a GraphQL schema and serves queries through a \`graphql.resolve\` SQL function, with no separate server.
- [Build a Database App with Drizzle ORM and Deno](https://swe.quest/articles/build-a-database-app-with-drizzle-orm-and-deno-692f9df52f193839.md): Deno · 2024-11-13 · Medium · 7 min read · TypeScript, PostgreSQL, JavaScript, Schema migrations
  Drizzle ORM can be used from Deno via npm compatibility to get type-safe CRUD access to PostgreSQL.
- [Build a Typesafe API with tRPC and Deno](https://swe.quest/articles/build-a-typesafe-api-with-trpc-and-deno-9411ac01cbda8497.md): Deno · 2024-11-19 · Medium · 7 min read · TypeScript, RPC & gRPC, API design, JavaScript
  tRPC lets a Deno server and client share types through an exported router type, with no schema declarations or code generation.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
