Add graphql schema (#18)
* Add graphql schema * Remove circular references in gql schema * Remove unnecessary todos --------- Co-authored-by: neeraj <neeraj.rtly@gmail.com>
This commit is contained in:
parent
f287929e94
commit
4d00cfb8f0
@ -30,11 +30,11 @@ export class Deployment {
|
|||||||
id!: number;
|
id!: number;
|
||||||
|
|
||||||
@ManyToOne(() => Project, { onDelete: 'CASCADE' })
|
@ManyToOne(() => Project, { onDelete: 'CASCADE' })
|
||||||
@JoinColumn({ name: 'projectID' })
|
@JoinColumn({ name: 'projectId' })
|
||||||
project!: Project;
|
project!: Project;
|
||||||
|
|
||||||
@OneToOne(() => Domain)
|
@OneToOne(() => Domain)
|
||||||
@JoinColumn({ name: 'domainID' })
|
@JoinColumn({ name: 'domainId' })
|
||||||
domain!: Domain;
|
domain!: Domain;
|
||||||
|
|
||||||
@Column('varchar')
|
@Column('varchar')
|
||||||
|
@ -17,11 +17,11 @@ export class Project {
|
|||||||
id!: string;
|
id!: string;
|
||||||
|
|
||||||
@ManyToOne(() => User)
|
@ManyToOne(() => User)
|
||||||
@JoinColumn({ name: 'ownerID' })
|
@JoinColumn({ name: 'ownerId' })
|
||||||
owner!: User;
|
owner!: User;
|
||||||
|
|
||||||
@ManyToOne(() => Organization, { nullable: true })
|
@ManyToOne(() => Organization, { nullable: true })
|
||||||
@JoinColumn({ name: 'organizationID' })
|
@JoinColumn({ name: 'organizationId' })
|
||||||
organization!: Organization | null;
|
organization!: Organization | null;
|
||||||
|
|
||||||
@Column('varchar')
|
@Column('varchar')
|
||||||
|
@ -23,11 +23,11 @@ export class ProjectMember {
|
|||||||
id!: number;
|
id!: number;
|
||||||
|
|
||||||
@ManyToOne(() => User, { onDelete: 'CASCADE' })
|
@ManyToOne(() => User, { onDelete: 'CASCADE' })
|
||||||
@JoinColumn({ name: 'userID' })
|
@JoinColumn({ name: 'userId' })
|
||||||
user!: User;
|
user!: User;
|
||||||
|
|
||||||
@ManyToOne(() => Project, { onDelete: 'CASCADE' })
|
@ManyToOne(() => Project, { onDelete: 'CASCADE' })
|
||||||
@JoinColumn({ name: 'projectID' })
|
@JoinColumn({ name: 'projectId' })
|
||||||
project!: Project;
|
project!: Project;
|
||||||
|
|
||||||
@Column({
|
@Column({
|
||||||
|
@ -23,11 +23,11 @@ export class UserOrganization {
|
|||||||
id!: number;
|
id!: number;
|
||||||
|
|
||||||
@ManyToOne(() => User, { onDelete: 'CASCADE' })
|
@ManyToOne(() => User, { onDelete: 'CASCADE' })
|
||||||
@JoinColumn({ name: 'userID' })
|
@JoinColumn({ name: 'userId' })
|
||||||
user!: User;
|
user!: User;
|
||||||
|
|
||||||
@ManyToOne(() => Organization, { onDelete: 'CASCADE' })
|
@ManyToOne(() => Organization, { onDelete: 'CASCADE' })
|
||||||
@JoinColumn({ name: 'organizationID' })
|
@JoinColumn({ name: 'organizationId' })
|
||||||
organization!: Organization;
|
organization!: Organization;
|
||||||
|
|
||||||
@Column({
|
@Column({
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
import 'reflect-metadata';
|
import 'reflect-metadata';
|
||||||
import debug from 'debug';
|
import debug from 'debug';
|
||||||
|
import fs from 'fs';
|
||||||
|
import path from 'path';
|
||||||
|
|
||||||
import { initializeDatabase } from './database';
|
import { initializeDatabase } from './database';
|
||||||
import { createAndStartServer } from './server';
|
import { createAndStartServer } from './server';
|
||||||
import { createResolvers } from './resolver';
|
import { createResolvers } from './resolvers';
|
||||||
import { typeDefs } from './schema';
|
|
||||||
import { getConfig } from './utils';
|
import { getConfig } from './utils';
|
||||||
import { Config } from './type';
|
import { Config } from './type';
|
||||||
|
|
||||||
@ -16,6 +17,7 @@ export const main = async (): Promise<void> => {
|
|||||||
const { server } = await getConfig<Config>(configFilePath);
|
const { server } = await getConfig<Config>(configFilePath);
|
||||||
|
|
||||||
await initializeDatabase();
|
await initializeDatabase();
|
||||||
|
const typeDefs = fs.readFileSync(path.join(__dirname, 'schema.gql')).toString();
|
||||||
await createAndStartServer(typeDefs, createResolvers, server);
|
await createAndStartServer(typeDefs, createResolvers, server);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ export const createResolvers = async (): Promise<any> => {
|
|||||||
return {
|
return {
|
||||||
Query: {
|
Query: {
|
||||||
// TODO: fetch user data from db
|
// TODO: fetch user data from db
|
||||||
getUser: () => user
|
user: () => user
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
118
packages/backend/src/schema.gql
Normal file
118
packages/backend/src/schema.gql
Normal file
@ -0,0 +1,118 @@
|
|||||||
|
enum Role {
|
||||||
|
Owner
|
||||||
|
Maintainer
|
||||||
|
Reader
|
||||||
|
}
|
||||||
|
|
||||||
|
enum Permission {
|
||||||
|
View
|
||||||
|
Edit
|
||||||
|
}
|
||||||
|
|
||||||
|
enum Environment {
|
||||||
|
Production
|
||||||
|
Preview
|
||||||
|
Development
|
||||||
|
}
|
||||||
|
|
||||||
|
enum DeploymentStatus {
|
||||||
|
Building
|
||||||
|
Ready
|
||||||
|
Error
|
||||||
|
}
|
||||||
|
|
||||||
|
enum DomainStatus {
|
||||||
|
Live
|
||||||
|
Pending
|
||||||
|
}
|
||||||
|
|
||||||
|
type User {
|
||||||
|
id: String!
|
||||||
|
name: String!
|
||||||
|
email: String!
|
||||||
|
organizations: [Organization!]
|
||||||
|
projects: [Project!]
|
||||||
|
createdAt: String!
|
||||||
|
updatedAt: String!
|
||||||
|
}
|
||||||
|
|
||||||
|
type Organization {
|
||||||
|
id: String!
|
||||||
|
name: String!
|
||||||
|
projects: [Project!]
|
||||||
|
createdAt: String!
|
||||||
|
updatedAt: String!
|
||||||
|
members: [OrganizationMember!]
|
||||||
|
}
|
||||||
|
|
||||||
|
type OrganizationMember {
|
||||||
|
id: String!
|
||||||
|
member: User!
|
||||||
|
role: Role!
|
||||||
|
createdAt: String!
|
||||||
|
updatedAt: String!
|
||||||
|
}
|
||||||
|
|
||||||
|
type Project {
|
||||||
|
id: String!
|
||||||
|
owner: User!
|
||||||
|
deployments: [Deployment!]
|
||||||
|
name: String!
|
||||||
|
repository: String!
|
||||||
|
prodBranch: String!
|
||||||
|
description: String
|
||||||
|
template: String
|
||||||
|
framework: String!
|
||||||
|
webhooks: [String!]
|
||||||
|
members: [ProjectMember!]
|
||||||
|
environmentVariables: [EnvironmentVariable!]
|
||||||
|
createdAt: String!
|
||||||
|
updatedAt: String!
|
||||||
|
}
|
||||||
|
|
||||||
|
type ProjectMember {
|
||||||
|
id: String!
|
||||||
|
member: User!
|
||||||
|
permissions: [Permission!]!
|
||||||
|
createdAt: String!
|
||||||
|
updatedAt: String!
|
||||||
|
}
|
||||||
|
|
||||||
|
type Deployment {
|
||||||
|
id: String!
|
||||||
|
domain: Domain
|
||||||
|
branch: String!
|
||||||
|
commitHash: String!
|
||||||
|
title: String!
|
||||||
|
environment: Environment!
|
||||||
|
isCurrent: Boolean!
|
||||||
|
status: DeploymentStatus!
|
||||||
|
createdAt: String!
|
||||||
|
updatedAt: String!
|
||||||
|
}
|
||||||
|
|
||||||
|
type Domain {
|
||||||
|
id: String!
|
||||||
|
branch: String!
|
||||||
|
name: String!
|
||||||
|
isRedirected: Boolean!
|
||||||
|
status: DomainStatus!
|
||||||
|
createdAt: String!
|
||||||
|
updatedAt: String!
|
||||||
|
}
|
||||||
|
|
||||||
|
type EnvironmentVariable {
|
||||||
|
id: String!
|
||||||
|
environments: [Environment!]!
|
||||||
|
key: String!
|
||||||
|
value: String!
|
||||||
|
createdAt: String!
|
||||||
|
updatedAt: String!
|
||||||
|
}
|
||||||
|
|
||||||
|
type Query {
|
||||||
|
user: User!
|
||||||
|
organizations: [Organization!]
|
||||||
|
projects: [Project!]
|
||||||
|
deployments(projectId: String!): [Deployment!]
|
||||||
|
}
|
@ -1,9 +0,0 @@
|
|||||||
export const typeDefs = /* GraphQL */ `
|
|
||||||
type User {
|
|
||||||
id: Int
|
|
||||||
}
|
|
||||||
|
|
||||||
type Query {
|
|
||||||
getUser: User
|
|
||||||
}
|
|
||||||
`;
|
|
Loading…
Reference in New Issue
Block a user