Creating A GraphQL Server With Deno

Our Deno dependencies

Oak**_ :_ **A middleware framework for Deno’s http server, including a router middleware.

Oak-GraphQL**_ :_ **A simple graphql middleware for oak deno framework.

GraphQL-Deno :This is a one-to-one port of graphql-js to Deno. It is working, fully adapted to Deno and exports both TS types and JS code.

First we are making the basic deno server with the oak framework and oak_graphql. We are creating a common dependency file for import packages.

import { Application } from "https://deno.land/x/oak/mod.ts";
	import { config } from "https://deno.land/x/dotenv/mod.ts";
	import { applyGraphQL, gql } from "https://deno.land/x/oak_graphql/mod.ts";
	import {
	    GraphQLScalarType,
	    Kind,
	  }  from "https://raw.githubusercontent.com/adelsz/graphql-deno/v15.0.0/mod.ts";

	export {
	    Application,
	    GraphQLScalarType,
	    Kind,
	    gql,
	    applyGraphQL,
	    config
	}

GraphQL Schema

A GraphQL schema is a description of the data clients can request from a GraphQL API. **It also defines the queries and mutation functions that the client can use to read and write data from the GraphQL server. **In other words, you specify your client or application UI data requirements in your GraphQL schema.

The schema is written using the GraphQL schema language (also called Schema Definition Language, SDL).

With it, you can define object types and fields to represent data that can be retrieved from the API as well as root types that define the group of operations that the API allows.

Object Types

Object Types

Root Types

The root types are the query type, mutation type, and subscription type, which are the three types of operations you can run request from a GraphQL server.

#typescript #schema #deno-mongodb #graphql #mongodb

GraphQL Server with Deno and Oak Framework
3.30 GEEK