Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/tailor-platform/sdk/llms.txt

Use this file to discover all available pages before exploring further.

Get started in minutes

This quickstart will guide you through creating, deploying, and querying your first Tailor Platform application. You’ll have a working GraphQL API running in the cloud in under 5 minutes.

Prerequisites

1

Install Node.js

The SDK requires Node.js 22 or later. Install Node.js via your package manager by following the official Node.js instructions.Verify your installation:
node --version
# Should output v22.0.0 or higher
2

Get a Tailor Platform account

You’ll need a Tailor Platform account to deploy your application. Request access here to get started.

Create your first application

1

Create a new project

Use the create command to scaffold a new project with the hello-world template:
npm create @tailor-platform/sdk -- --template hello-world my-app
This creates a new directory called my-app with:
  • A simple “hello” query resolver
  • TypeScript configuration
  • Database schema with a User type
  • All necessary dependencies
2

Navigate to your project

cd my-app
3

Login to Tailor Platform

Authenticate with the Tailor Platform:
npx tailor-sdk login
This will open your browser to complete the authentication flow.
4

Create a workspace

Every application needs a workspace. Create one with the following command:
npx tailor-sdk workspace create --name my-workspace --region us-east-1
Available regions: us-east-1, eu-west-1, ap-northeast-1
List your workspaces to get the workspace ID:
npx tailor-sdk workspace list
Alternatively, create a workspace using the Tailor Platform Console.
5

Deploy your application

Deploy your application to your workspace:
npm run deploy -- --workspace-id <your-workspace-id>
Save your workspace ID in an .env file:
TAILOR_PLATFORM_WORKSPACE_ID=your-workspace-id
Then you can run npm run deploy without the --workspace-id flag.
The deployment process will:
  • Build your TypeScript configuration
  • Generate type definitions
  • Deploy your database schema
  • Deploy your resolver
  • Output a GraphQL endpoint URL

Query your API

1

Open GraphQL Playground

After deployment, you’ll receive a GraphQL endpoint URL. Open the GraphQL Playground in your browser.
2

Execute your first query

Run the hello query with a name parameter:
query {
  hello(name: "sdk") {
    message
  }
}
You should see the response:
{
  "data": {
    "hello": {
      "message": "Hello, sdk!"
    }
  }
}

Understanding the code

Let’s look at what you just deployed. The hello-world template includes:

Configuration file

The tailor.config.ts file defines your application:
tailor.config.ts
import { defineConfig, definePlugins } from "@tailor-platform/sdk";
import { kyselyTypePlugin } from "@tailor-platform/sdk/plugin/kysely-type";

export default defineConfig({
  name: "hello-world",
  db: { "main-db": { files: [`./src/db/*.ts`] } },
  resolver: { "main-resolver": { files: [`./src/resolvers/**/*.ts`] } },
});

export const plugins = definePlugins(
  kyselyTypePlugin({ distPath: `./src/generated/kysely-tailordb.ts` }),
);

Database schema

The src/db/user.ts file defines a User type:
src/db/user.ts
import {
  db,
  unsafeAllowAllGqlPermission,
  unsafeAllowAllTypePermission,
} from "@tailor-platform/sdk";

export const user = db
  .type("User", {
    name: db.string().description("Name of the user"),
    email: db.string().unique().description("Email address of the user"),
    role: db.enum(["MANAGER", "STAFF"]),
    ...db.fields.timestamps(),
  })
  .features({
    gqlOperations: "query",
  })
  .permission(unsafeAllowAllTypePermission)
  .gqlPermission(unsafeAllowAllGqlPermission);

Resolver

The src/resolvers/hello.ts file defines a custom GraphQL query:
src/resolvers/hello.ts
import { createResolver, t } from "@tailor-platform/sdk";

export default createResolver({
  name: "hello",
  operation: "query",
  input: {
    name: t.string().description("Name to greet"),
  },
  body: (context) => {
    return {
      message: `Hello, ${context.input.name}!`,
    };
  },
  output: t
    .object({
      message: t.string().description("Greeting message"),
    })
    .description("Greeting response"),
});

Make your first change

1

Edit the resolver

Open src/resolvers/hello.ts and change the message:
src/resolvers/hello.ts
export default createResolver({
  name: "hello",
  operation: "query",
  input: {
    name: t.string().description("Name to greet"),
  },
  body: (context) => {
    return {
      message: `Welcome to Tailor Platform, ${context.input.name}!`,
    };
  },
  output: t
    .object({
      message: t.string().description("Greeting message"),
    })
    .description("Greeting response"),
});
2

Deploy your changes

npm run deploy
3

Test the updated query

Run the same GraphQL query and see the updated response:
query {
  hello(name: "sdk") {
    message
  }
}
{
  "data": {
    "hello": {
      "message": "Welcome to Tailor Platform, sdk!"
    }
  }
}

Next steps

Congratulations! You’ve created, deployed, and modified your first Tailor Platform application.

Learn about TailorDB

Define complex database schemas with relationships and permissions

Create custom resolvers

Build GraphQL resolvers with business logic and database access

Set up executors

React to events like database changes and webhooks

Explore templates

Check out the inventory-management and testing templates for more examples

Build docs developers (and LLMs) love