Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/build-from-scratch/sdk/step-01/src/db/task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ export const task = db
projectId: db
.uuid()
.description("ID of the project the task belongs to")
.relation({ type: "n-1", toward: { type: project } }),
.relation({ type: "n-1", toward: { table: project } }),
assigneeId: db
.uuid({ optional: true })
.description("ID of the user assigned to the task")
.relation({ type: "n-1", toward: { type: user } }),
.relation({ type: "n-1", toward: { table: user } }),
status: db.enum([
{ value: "TODO", description: "To Do status" },
{ value: "IN_PROGRESS", description: "In Progress status" },
Expand Down
4 changes: 2 additions & 2 deletions docs/build-from-scratch/sdk/step-02/src/db/task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ export const task = db
projectId: db
.uuid()
.description("ID of the project the task belongs to")
.relation({ type: "n-1", toward: { type: project } }),
.relation({ type: "n-1", toward: { table: project } }),
assigneeId: db
.uuid({ optional: true })
.description("ID of the user assigned to the task")
.relation({ type: "n-1", toward: { type: user } }),
.relation({ type: "n-1", toward: { table: user } }),
status: db.enum([
{ value: "TODO", description: "To Do status" },
{ value: "IN_PROGRESS", description: "In Progress status" },
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type {
PermissionCondition,
ResolverPermission,
TailorTypeGqlPermission,
TailorTypePermission,
} from "@tailor-platform/sdk";
Expand Down Expand Up @@ -30,3 +31,11 @@ export const gqlPermissionLoggedIn = [
permit: true,
},
] as const satisfies TailorTypeGqlPermission;

// Any logged-in user can call the resolver.
export const resolverPermissionLoggedIn = [
{
conditions: [loggedIn],
permit: true,
},
] as const satisfies ResolverPermission;
4 changes: 2 additions & 2 deletions docs/build-from-scratch/sdk/step-03/src/db/task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ export const task = db
projectId: db
.uuid()
.description("ID of the project the task belongs to")
.relation({ type: "n-1", toward: { type: project } }),
.relation({ type: "n-1", toward: { table: project } }),
assigneeId: db
.uuid({ optional: true })
.description("ID of the user assigned to the task")
.relation({ type: "n-1", toward: { type: user } }),
.relation({ type: "n-1", toward: { table: user } }),
status: db.enum([
{ value: "TODO", description: "To Do status" },
{ value: "IN_PROGRESS", description: "In Progress status" },
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { createResolver, t } from "@tailor-platform/sdk";
import { resolverPermissionLoggedIn } from "../common/permission";
import { getDB } from "../generated/tailordb";

export default createResolver({
name: "closeProject",
operation: "mutation",
permission: resolverPermissionLoggedIn,
input: {
id: t.string(),
},
Expand All @@ -21,7 +23,7 @@ export default createResolver({
throw new Error(`Project not found, expected:1 got:0`);
}

if (project.status === "CANCELED") {
if (project.status === "CLOSED") {
return { result: "Project is already closed." };
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type {
PermissionCondition,
ResolverPermission,
TailorTypeGqlPermission,
TailorTypePermission,
} from "@tailor-platform/sdk";
Expand Down Expand Up @@ -30,3 +31,11 @@ export const gqlPermissionLoggedIn = [
permit: true,
},
] as const satisfies TailorTypeGqlPermission;

// Any logged-in user can call the resolver.
export const resolverPermissionLoggedIn = [
{
conditions: [loggedIn],
permit: true,
},
] as const satisfies ResolverPermission;
4 changes: 2 additions & 2 deletions docs/build-from-scratch/sdk/step-04/src/db/task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ export const task = db
projectId: db
.uuid()
.description("ID of the project the task belongs to")
.relation({ type: "n-1", toward: { type: project } }),
.relation({ type: "n-1", toward: { table: project } }),
assigneeId: db
.uuid({ optional: true })
.description("ID of the user assigned to the task")
.relation({ type: "n-1", toward: { type: user } }),
.relation({ type: "n-1", toward: { table: user } }),
status: db.enum([
{ value: "TODO", description: "To Do status" },
{ value: "IN_PROGRESS", description: "In Progress status" },
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { createResolver, t } from "@tailor-platform/sdk";
import { resolverPermissionLoggedIn } from "../common/permission";
import { getDB } from "../generated/tailordb";

export default createResolver({
name: "closeProject",
operation: "mutation",
permission: resolverPermissionLoggedIn,
input: {
id: t.string(),
},
Expand All @@ -21,7 +23,7 @@ export default createResolver({
throw new Error(`Project not found, expected:1 got:0`);
}

if (project.status === "CANCELED") {
if (project.status === "CLOSED") {
return { result: "Project is already closed." };
}

Expand Down
Loading