Skip to content

Commit

Permalink
Merge pull request #4798 from alkem-io/authorization-lookup
Browse files Browse the repository at this point in the history
authorization resolver
  • Loading branch information
techsmyth authored Dec 20, 2024
2 parents 6dabcba + 0a85c98 commit 6c886d7
Show file tree
Hide file tree
Showing 4 changed files with 555 additions and 1 deletion.
17 changes: 17 additions & 0 deletions src/services/api/lookup/dto/lookup.query.my.privileges.results.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { ObjectType } from '@nestjs/graphql';
import { AuthorizationPrivilege } from '@common/enums/authorization.privilege';

@ObjectType()
export class LookupMyPrivilegesQueryResults {
// exposed through the field resolver
community!: AuthorizationPrivilege[];
collaboration!: AuthorizationPrivilege[];
context!: AuthorizationPrivilege[];
profile!: AuthorizationPrivilege[];
callout!: AuthorizationPrivilege[];
post!: AuthorizationPrivilege[];
room!: AuthorizationPrivilege[];
innovationFlow!: AuthorizationPrivilege[];
template!: AuthorizationPrivilege[];
whiteboard!: AuthorizationPrivilege[];
}
8 changes: 7 additions & 1 deletion src/services/api/lookup/lookup.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import { TemplatesSetModule } from '@domain/template/templates-set/templates.set
import { RoleSetModule } from '@domain/access/role-set/role.set.module';
import { TemplatesManagerModule } from '@domain/template/templates-manager/templates.manager.module';
import { LicenseModule } from '@domain/common/license/license.module';
import { LookupMyPrivilegesResolverFields } from './lookup.resolver.my.privileges.fields';

@Module({
imports: [
Expand Down Expand Up @@ -68,7 +69,12 @@ import { LicenseModule } from '@domain/common/license/license.module';
RoleSetModule,
LicenseModule,
],
providers: [LookupService, LookupResolverQueries, LookupResolverFields],
providers: [
LookupService,
LookupResolverQueries,
LookupResolverFields,
LookupMyPrivilegesResolverFields,
],
exports: [LookupService],
})
export class LookupModule {}
10 changes: 10 additions & 0 deletions src/services/api/lookup/lookup.resolver.fields.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ import { TemplatesManagerService } from '@domain/template/templates-manager/temp
import { ITemplatesManager } from '@domain/template/templates-manager/templates.manager.interface';
import { ILicense } from '@domain/common/license/license.interface';
import { LicenseService } from '@domain/common/license/license.service';
import { LookupMyPrivilegesQueryResults } from './dto/lookup.query.my.privileges.results';

@Resolver(() => LookupQueryResults)
export class LookupResolverFields {
Expand Down Expand Up @@ -145,6 +146,15 @@ export class LookupResolverFields {
return account;
}

@UseGuards(GraphqlGuard)
@ResolveField(() => LookupMyPrivilegesQueryResults, {
nullable: true,
description: 'Lookup myPrivileges on the specified entity.',
})
myPrivileges(): LookupMyPrivilegesQueryResults {
return {} as LookupMyPrivilegesQueryResults;
}

@UseGuards(GraphqlGuard)
@ResolveField(() => IRoleSet, {
nullable: true,
Expand Down
Loading

0 comments on commit 6c886d7

Please sign in to comment.