Getting Started
This guide will help you get started with GQLoom and create a simple GraphQL backend application.
Prerequisites
You only need a JavaScript/TypeScript runtime, such as Node.js, Bun, Deno, or Cloudflare Workers.
Initialize the project
Tip
If you already have a project, you can skip this step and jump straight to Installation.
First, create a new folder and initialize the project:
sh
mkdir gqloom-app # Create a new folder
cd ./gqloom-app # Enter the folder
npm init -y # Initialize an empty project
npm i -D typescript @types/node tsx # Install TypeScript and related dependencies
npx tsc --init # Initialize TypeScript configurationsh
mkdir gqloom-app # Create a new folder
cd ./gqloom-app # Enter the folder
yarn init -y # Initialize an empty project
yarn add -D typescript @types/node tsx # Install TypeScript and related dependencies
yarn dlx -q -p typescript tsc --init # Initialize TypeScript configurationsh
mkdir gqloom-app # Create a new folder
cd ./gqloom-app # Enter the folder
pnpm init # Initialize an empty project
pnpm add -D typescript @types/node tsx # Install TypeScript and related dependencies
pnpm exec tsc --init # Initialize TypeScript configurationsh
mkdir gqloom-app # Create a new folder
cd ./gqloom-app # Enter the folder
bun init # Initialize the projectsh
mkdir gqloom-app # Create a new folder
cd ./gqloom-app # Enter the folder
deno init # Initialize the projectInstallation
GQLoom supports multiple runtime types; choose your favorite ORM and validation library!
sh
npm i graphql @gqloom/core valibot @gqloom/valibotsh
pnpm add graphql @gqloom/core valibot @gqloom/valibotsh
yarn add graphql @gqloom/core valibot @gqloom/valibotsh
bun add graphql @gqloom/core valibot @gqloom/valibotsh
deno add npm:graphql npm:@gqloom/core npm:valibot npm:@gqloom/valibotIn addition, we need to choose an adapter to run our GraphQL server.
Here we choose the graphql-yoga adapter.
sh
npm i graphql-yogash
pnpm add graphql-yogash
yarn add graphql-yogash
bun add graphql-yogash
deno add npm:graphql-yogaHello, World
ts
import { createServer } from "node:http"
import { query, resolver, weave } from "@gqloom/core"
import { ValibotWeaver } from "@gqloom/valibot"
import { createYoga } from "graphql-yoga"
import * as v from "valibot"
const helloResolver = resolver({
hello: query(v.string())
.input({ name: v.nullish(v.string(), "World") })
.resolve(({ name }) => `Hello, ${name}!`),
})
const schema = weave(ValibotWeaver, helloResolver)
const yoga = createYoga({ schema })
const server = createServer(yoga)
server.listen(4000, () => {
console.info("Server is running on http://localhost:4000/graphql")
})Next steps
- Learn GQLoom's core concepts: Silk, Resolver, Weave;
- Learn common features: Context, DataLoader, Middleware
- Add a GraphQL client to your frontend project: gql.tada, Urql, Apollo Client, TanStack Query, Graffle