Skip to content

Commit

Permalink
Removing some deps
Browse files Browse the repository at this point in the history
  • Loading branch information
cryptiklemur committed May 22, 2019
1 parent 1546c4c commit 4e4a1a6
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 27 deletions.
22 changes: 11 additions & 11 deletions src/Module/AppModule.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import {Module} from '@nestjs/common';
import {GraphQLModule} from '@nestjs/graphql';
import {TypeOrmModule} from '@nestjs/typeorm';
// import {TypeOrmModule} from '@nestjs/typeorm';
import {unlinkSync} from 'fs';
import {join} from 'path';

import IndexController from '../Controller/IndexController';
import TypeOrmConfigService from '../Database/TypeOrmConfigService';
import Organization from '../Entity/Organization';
import OrganizationUser from '../Entity/OrganizationUser';
// import TypeOrmConfigService from '../Database/TypeOrmConfigService';
// import Organization from '../Entity/Organization';
// import OrganizationUser from '../Entity/OrganizationUser';
import {OrganizationResolver} from '../Resolver/OrganizationResolver';
import Manager from '../Secret/Manager';
// import Manager from '../Secret/Manager';

/*
const stripeFactory = {
Expand All @@ -31,18 +31,18 @@ try {
}

@Module({
providers: [Manager, OrganizationResolver],
providers: [/*Manager, */OrganizationResolver],
imports: [
TypeOrmModule.forRootAsync({useClass: TypeOrmConfigService}),
TypeOrmModule.forFeature([Organization, OrganizationUser]),
//TypeOrmModule.forRootAsync({useClass: TypeOrmConfigService}),
//TypeOrmModule.forFeature([Organization, OrganizationUser]),
GraphQLModule.forRootAsync({
useFactory: async () => {
const manager = new Manager();
const engine: any = (await manager.getSecret('secretary/apollo/engine')).value;
//const manager = new Manager();
//const engine: any = (await manager.getSecret('secretary/apollo/engine')).value;

return {
autoSchemaFile: schema,
engine,
//engine,
};
},
}),
Expand Down
28 changes: 12 additions & 16 deletions src/Resolver/OrganizationResolver.ts
Original file line number Diff line number Diff line change
@@ -1,41 +1,37 @@
import {Args, Info, Mutation, Query, Resolver} from '@nestjs/graphql';
import {InjectRepository} from '@nestjs/typeorm';
//import {InjectRepository} from '@nestjs/typeorm';
import {ID} from 'type-graphql';
import {Repository} from 'typeorm';
//import {Repository} from 'typeorm';

import Organization from '../Entity/Organization';
import OrganizationUser from '../Entity/OrganizationUser';
//import OrganizationUser from '../Entity/OrganizationUser';

@Resolver(() => Organization)
export class OrganizationResolver {
public constructor(
@InjectRepository(Organization) private readonly organizationRepository: Repository<Organization>,
@InjectRepository(OrganizationUser) private readonly organizationUserRepository: Repository<OrganizationUser>,
//@InjectRepository(Organization) private readonly organizationRepository: Repository<Organization>,
//@InjectRepository(OrganizationUser) private readonly organizationUserRepository: Repository<OrganizationUser>,
) {
}

@Query(() => Organization, {name: 'organizationByOwner', nullable: true})
public async getOrganizationByOwner(@Args('owner') owner: string): Promise<Organization> {
const org = await this.organizationRepository.findOneOrFail({owner});
// const org = await this.organizationRepository.findOneOrFail({owner});

return org.enabled ? org : null;
// return org.enabled ? org : null;

return null;
}

@Query(() => Organization, {name: 'organization', nullable: true})
public async getOrganization(@Args({name: 'id', type: () => ID}) id: number): Promise<Organization> {
const org = await this.organizationRepository.findOneOrFail(id);
//const org = await this.organizationRepository.findOneOrFail(id);

return org.enabled ? org : null;
//return org.enabled ? org : null;
return null
}

@Mutation(() => Organization, {nullable: true})
public async createOrganization(@Info() context: any, @Args('name') name: string) {
// @ts-ignore
console.log(context);

const organization = this.organizationRepository.create();
organization.id = 1;

return organization;
}
}

1 comment on commit 4e4a1a6

@vercel
Copy link

@vercel vercel bot commented on 4e4a1a6 May 22, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.