Adding Application Endpoints
This tutorial shows how to add new services to your Tailor application using the SDK. Services provide different capabilities like database access, custom logic, authentication, and workflow orchestration.
- To follow along with this tutorial, first complete the SDK Quickstart. It provides the app template that we'll modify in the steps ahead.
How Services Work in the SDK
The SDK automatically creates application endpoints (subgraphs) based on the services you configure in tailor.config.ts. When you define a service configuration, the SDK:
- Reads your service files from the specified directories
- Validates the service definitions
- Generates the corresponding application endpoints
- Deploys them to your workspace
Available Services
You can configure the following services in your application:
- TailorDB (
db): Database schema and types - Resolver (
resolver): Custom GraphQL query and mutation resolvers - Executor (
executor): Event-driven handlers that respond to database changes - Workflow (
workflow): Job orchestration for background tasks - Auth (
auth): Authentication and authorization - IdP (
idp): Built-in identity provider - Static Website (
staticWebsites): Static file hosting
Adding a Service
To add a new service to your application, update your tailor.config.ts file with the service configuration. Each service requires you to specify glob patterns that match the files containing your service definitions.
Example: Adding TailorDB
import { defineConfig } from "@tailor-platform/sdk";
export default defineConfig({
name: "my-app",
db: {
"my-database": {
files: ["db/**/*.ts"],
},
},
});This configuration tells the SDK to:
- Create a TailorDB service named "my-database"
- Load all TypeScript files from the
db/directory
Example: Adding Resolvers
export default defineConfig({
name: "my-app",
resolver: {
"my-resolver": {
files: ["resolver/**/*.ts"],
},
},
});Example: Adding Multiple Services
You can configure multiple services in the same configuration file:
export default defineConfig({
name: "my-app",
db: {
"my-database": {
files: ["db/**/*.ts"],
},
},
resolver: {
"my-resolver": {
files: ["resolver/**/*.ts"],
},
},
executor: {
files: ["executors/**/*.ts"],
},
workflow: {
files: ["workflows/**/*.ts"],
},
});Deploying Changes
After updating your configuration, deploy the changes to your workspace:
npm run deploy -- --workspace-id <your-workspace-id>The SDK will:
- Load all service files matching your glob patterns
- Generate the application endpoints for each configured service
- Deploy them to your workspace
Your new service endpoints will be available in the GraphQL API after deployment completes.
Next Steps
Learn more about configuring specific services:
- TailorDB - Database schema definition
- Resolver - Custom GraphQL resolvers
- Executor - Event-driven handlers
- Workflow - Job orchestration
- Configuration - Complete configuration reference