Skip to content

Commit

Permalink
return fake data
Browse files Browse the repository at this point in the history
  • Loading branch information
tsirysndr committed May 3, 2024
1 parent 08ecc6c commit bc7846c
Show file tree
Hide file tree
Showing 8 changed files with 580 additions and 17 deletions.
6 changes: 5 additions & 1 deletion src/server/graphql/objects/job.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
import { Log } from "./log.ts";

export class Job {
id: string;
projectId: string;
name: string;
status: string;
createdAt: string;
logs?: Log;

constructor({ id, projectId, name, status, createdAt }: Job) {
constructor({ id, projectId, name, status, createdAt, logs }: Job) {
this.id = id;
this.projectId = projectId;
this.name = name;
this.status = status;
this.createdAt = createdAt;
this.logs = logs;
}
}
6 changes: 5 additions & 1 deletion src/server/graphql/objects/project.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
import { Log } from "./log.ts";

export class Project {
id: string;
path: string;
name: string;
createdAt: string;
logs?: Log;

constructor({ id, path, name, createdAt }: Project) {
constructor({ id, path, name, createdAt, logs }: Project) {
this.id = id;
this.path = path;
this.name = name;
this.createdAt = createdAt;
this.logs = logs;
}
}
40 changes: 37 additions & 3 deletions src/server/graphql/resolvers/job/queries.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { Context } from "../../context.ts";
import { Job } from "../../objects/job.ts";
import { Log } from "../../objects/log.ts";
import { logs } from "../log/mock.ts";

export async function getJobs(
root: any,
Expand All @@ -9,20 +11,52 @@ export async function getJobs(
return [
new Job({
id: "1",
projectId: "1",
projectId: "stupefied_kalam",
status: "running",
name: "build",
createdAt: new Date().toISOString(),
logs: new Log({
id: "1",
jobId: "2",
message: logs,
createdAt: new Date().toISOString(),
}),
}),
new Job({
id: "2",
projectId: "stupefied_kalam",
status: "pending",
name: "test",
createdAt: new Date().toISOString(),
}),
new Job({
id: "3",
projectId: "stupefied_kalam",
status: "pending",
name: "deploy",
createdAt: new Date().toISOString(),
logs: new Log({
id: "1",
jobId: "3",
message: logs,
createdAt: new Date().toISOString(),
}),
}),
];
}

export async function getJob(root: any, args: any, ctx: Context): Promise<Job> {
return new Job({
id: "1",
projectId: "1",
projectId: "stupefied_kalam",
status: "running",
name: "deploy",
name: "build",
createdAt: new Date().toISOString(),
logs: new Log({
id: "1",
jobId: "3",
message: logs,
createdAt: new Date().toISOString(),
}),
});
}
492 changes: 492 additions & 0 deletions src/server/graphql/resolvers/log/mock.ts

Large diffs are not rendered by default.

9 changes: 5 additions & 4 deletions src/server/graphql/resolvers/log/queries.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Context } from "../../context.ts";
import { Log } from "../../objects/log.ts";
import { logs } from "./mock.ts";

export async function getLogs(
root: any,
Expand All @@ -9,8 +10,8 @@ export async function getLogs(
return [
new Log({
id: "1",
jobId: "1",
message: "message",
jobId: "2",
message: logs,
createdAt: new Date().toISOString(),
}),
];
Expand All @@ -19,8 +20,8 @@ export async function getLogs(
export async function getLog(root: any, args: any, ctx: Context): Promise<Log> {
return new Log({
id: "1",
jobId: "1",
message: "message",
jobId: "2",
message: logs,
createdAt: new Date().toISOString(),
});
}
8 changes: 4 additions & 4 deletions src/server/graphql/resolvers/project/mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ export async function createProject(
): Promise<Project> {
return new Project({
id: "1",
path: "path",
name: "name",
path: "/home/tsirysndr/Documents/github/fluentci",
name: "fluentci",
createdAt: new Date().toISOString(),
});
}
Expand All @@ -21,8 +21,8 @@ export async function runPipeline(
): Promise<Project> {
return new Project({
id: "1",
path: "path",
name: "name",
path: "/home/tsirysndr/Documents/github/gleam_pipeline/example",
name: "gleam_example",
createdAt: new Date().toISOString(),
});
}
22 changes: 18 additions & 4 deletions src/server/graphql/resolvers/project/queries.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { Context } from "../../context.ts";
import { Log } from "../../objects/log.ts";
import { Project } from "../../objects/project.ts";
import { logs } from "../log/mock.ts";

export async function getProjects(
root: any,
Expand All @@ -9,9 +11,15 @@ export async function getProjects(
return [
new Project({
id: "1",
path: "path",
name: "name",
path: "/home/tsirysndr/Documents/github/gleam",
name: "gleam",
createdAt: new Date().toISOString(),
logs: new Log({
id: "1",
jobId: "3",
message: logs,
createdAt: new Date().toISOString(),
}),
}),
];
}
Expand All @@ -23,8 +31,14 @@ export async function getProject(
): Promise<Project> {
return new Project({
id: "1",
path: "path",
name: "name",
path: "/home/tsirysndr/Documents/github/fluentci",
name: "fluentci",
createdAt: new Date().toISOString(),
logs: new Log({
id: "1",
jobId: "3",
message: logs,
createdAt: new Date().toISOString(),
}),
});
}
14 changes: 14 additions & 0 deletions src/server/graphql/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ builder.objectType(Job, {
name: t.exposeString("name"),
status: t.exposeString("status"),
createdAt: t.exposeString("createdAt"),
logs: t.field({
type: Log,
nullable: true,
resolve: (root) => root.logs,
}),
}),
});

Expand All @@ -41,6 +46,11 @@ builder.objectType(Project, {
path: t.exposeString("path"),
name: t.exposeString("name"),
createdAt: t.exposeString("createdAt"),
logs: t.field({
type: Log,
nullable: true,
resolve: (root) => root.logs,
}),
}),
});

Expand Down Expand Up @@ -77,6 +87,10 @@ builder.queryType({
}),
logs: t.field({
type: [Log],
args: {
jobId: t.arg.id(),
projectId: t.arg.id(),
},
resolve: getLogs,
}),
}),
Expand Down

0 comments on commit bc7846c

Please sign in to comment.