-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1546c4c
commit 4e4a1a6
Showing
2 changed files
with
23 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
4e4a1a6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully aliased the URL https://api-nptrsp9qu.now.sh to the following aliases.