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;
|
||||
|
||||
@ManyToOne(() => Project, { onDelete: 'CASCADE' })
|
||||
@JoinColumn({ name: 'projectID' })
|
||||
@JoinColumn({ name: 'projectId' })
|
||||
project!: Project;
|
||||
|
||||
@OneToOne(() => Domain)
|
||||
@JoinColumn({ name: 'domainID' })
|
||||
@JoinColumn({ name: 'domainId' })
|
||||
domain!: Domain;
|
||||
|
||||
@Column('varchar')
|
||||
|
@ -17,11 +17,11 @@ export class Project {
|
||||
id!: string;
|
||||
|
||||
@ManyToOne(() => User)
|
||||
@JoinColumn({ name: 'ownerID' })
|
||||
@JoinColumn({ name: 'ownerId' })
|
||||
owner!: User;
|
||||
|
||||
@ManyToOne(() => Organization, { nullable: true })
|
||||
@JoinColumn({ name: 'organizationID' })
|
||||
@JoinColumn({ name: 'organizationId' })
|
||||
organization!: Organization | null;
|
||||
|
||||
@Column('varchar')
|
||||
|
@ -23,11 +23,11 @@ export class ProjectMember {
|
||||
id!: number;
|
||||
|
||||
@ManyToOne(() => User, { onDelete: 'CASCADE' })
|
||||
@JoinColumn({ name: 'userID' })
|
||||
@JoinColumn({ name: 'userId' })
|
||||
user!: User;
|
||||
|
||||
@ManyToOne(() => Project, { onDelete: 'CASCADE' })
|
||||
@JoinColumn({ name: 'projectID' })
|
||||
@JoinColumn({ name: 'projectId' })
|
||||
project!: Project;
|
||||
|
||||
@Column({
|
||||
|
@ -23,11 +23,11 @@ export class UserOrganization {
|
||||
id!: number;
|
||||
|
||||
@ManyToOne(() => User, { onDelete: 'CASCADE' })
|
||||
@JoinColumn({ name: 'userID' })
|
||||
@JoinColumn({ name: 'userId' })
|
||||
user!: User;
|
||||
|
||||
@ManyToOne(() => Organization, { onDelete: 'CASCADE' })
|
||||
@JoinColumn({ name: 'organizationID' })
|
||||
@JoinColumn({ name: 'organizationId' })
|
||||
organization!: Organization;
|
||||
|
||||
@Column({
|
||||
|
@ -1,10 +1,11 @@
|
||||
import 'reflect-metadata';
|
||||
import debug from 'debug';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
import { initializeDatabase } from './database';
|
||||
import { createAndStartServer } from './server';
|
||||
import { createResolvers } from './resolver';
|
||||
import { typeDefs } from './schema';
|
||||
import { createResolvers } from './resolvers';
|
||||
import { getConfig } from './utils';
|
||||
import { Config } from './type';
|
||||
|
||||
@ -16,6 +17,7 @@ export const main = async (): Promise<void> => {
|
||||
const { server } = await getConfig<Config>(configFilePath);
|
||||
|
||||
await initializeDatabase();
|
||||
const typeDefs = fs.readFileSync(path.join(__dirname, 'schema.gql')).toString();
|
||||
await createAndStartServer(typeDefs, createResolvers, server);
|
||||
};
|
||||
|
||||
|
@ -6,7 +6,7 @@ export const createResolvers = async (): Promise<any> => {
|
||||
return {
|
||||
Query: {
|
||||
// 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