-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optimize metadata queries #7013
Changes from 2 commits
d752b45
c002280
998cb91
92cac7a
8215687
5cdd09b
9a740d6
3e5dbc0
304be2f
ec2a1d4
38944a5
b02d197
5388d94
e4c2f9d
294492d
9e735bf
fb0f214
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { | ||
GraphqlQueryRunnerException, | ||
GraphqlQueryRunnerExceptionCode, | ||
} from 'src/engine/api/graphql/graphql-query-runner/errors/graphql-query-runner.exception'; | ||
import { ObjectMetadataMapItem } from 'src/engine/metadata-modules/utils/generate-object-metadata-map.util'; | ||
|
||
export const getObjectMetadata = ( | ||
objectMetadataMap: Record<string, any>, | ||
objectName: string, | ||
): ObjectMetadataMapItem => { | ||
const objectMetadata = objectMetadataMap[objectName]; | ||
|
||
if (!objectMetadata) { | ||
throw new GraphqlQueryRunnerException( | ||
`Object metadata not found for ${objectName}`, | ||
GraphqlQueryRunnerExceptionCode.OBJECT_METADATA_NOT_FOUND, | ||
); | ||
} | ||
|
||
return objectMetadata; | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,15 +12,16 @@ import { User } from 'src/engine/core-modules/user/user.entity'; | |
import { Workspace } from 'src/engine/core-modules/workspace/workspace.entity'; | ||
import { AuthUser } from 'src/engine/decorators/auth/auth-user.decorator'; | ||
import { AuthWorkspace } from 'src/engine/decorators/auth/auth-workspace.decorator'; | ||
import { JwtAuthGuard } from 'src/engine/guards/jwt.auth.guard'; | ||
import { UserAuthGuard } from 'src/engine/guards/user-auth.guard copy'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. syntax: Typo in the import path. Remove 'copy' from the end. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
import { WorkspaceAuthGuard } from 'src/engine/guards/workspace-auth.guard'; | ||
|
||
@ArgsType() | ||
class GetAISQLQueryArgs { | ||
@Field(() => String) | ||
text: string; | ||
} | ||
|
||
@UseGuards(JwtAuthGuard) | ||
@UseGuards(WorkspaceAuthGuard, UserAuthGuard) | ||
@Resolver(() => AISQLQueryResult) | ||
export class AISQLQueryResolver { | ||
constructor( | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,13 +16,14 @@ import { UpdatePasswordViaResetTokenInput } from 'src/engine/core-modules/auth/d | |
import { ValidatePasswordResetToken } from 'src/engine/core-modules/auth/dto/validate-password-reset-token.entity'; | ||
import { ValidatePasswordResetTokenInput } from 'src/engine/core-modules/auth/dto/validate-password-reset-token.input'; | ||
import { AuthGraphqlApiExceptionFilter } from 'src/engine/core-modules/auth/filters/auth-graphql-api-exception.filter'; | ||
import { CaptchaGuard } from 'src/engine/core-modules/captcha/captcha.guard'; | ||
import { UserService } from 'src/engine/core-modules/user/services/user.service'; | ||
import { User } from 'src/engine/core-modules/user/user.entity'; | ||
import { Workspace } from 'src/engine/core-modules/workspace/workspace.entity'; | ||
import { AuthUser } from 'src/engine/decorators/auth/auth-user.decorator'; | ||
import { AuthWorkspace } from 'src/engine/decorators/auth/auth-workspace.decorator'; | ||
import { JwtAuthGuard } from 'src/engine/guards/jwt.auth.guard'; | ||
import { CaptchaGuard } from 'src/engine/core-modules/captcha/captcha.guard'; | ||
import { UserAuthGuard } from 'src/engine/guards/user-auth.guard copy'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. syntax: Typo in import path. Remove 'copy' from the end of the file name. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
import { WorkspaceAuthGuard } from 'src/engine/guards/workspace-auth.guard'; | ||
|
||
import { ChallengeInput } from './dto/challenge.input'; | ||
import { ImpersonateInput } from './dto/impersonate.input'; | ||
|
@@ -111,7 +112,7 @@ export class AuthResolver { | |
} | ||
|
||
@Mutation(() => TransientToken) | ||
@UseGuards(JwtAuthGuard) | ||
@UseGuards(WorkspaceAuthGuard, UserAuthGuard) | ||
async generateTransientToken( | ||
@AuthUser() user: User, | ||
): Promise<TransientToken | void> { | ||
|
@@ -141,7 +142,7 @@ export class AuthResolver { | |
} | ||
|
||
@Mutation(() => AuthorizeApp) | ||
@UseGuards(JwtAuthGuard) | ||
@UseGuards(WorkspaceAuthGuard, UserAuthGuard) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. logic: Similar guard change here. Verify that WorkspaceAuthGuard and UserAuthGuard provide the same level of security as JwtAuthGuard. |
||
async authorizeApp( | ||
@Args() authorizeAppInput: AuthorizeAppInput, | ||
@AuthUser() user: User, | ||
|
@@ -155,7 +156,7 @@ export class AuthResolver { | |
} | ||
|
||
@Mutation(() => AuthTokens) | ||
@UseGuards(JwtAuthGuard) | ||
@UseGuards(WorkspaceAuthGuard, UserAuthGuard) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. logic: Another instance of guard replacement. Test thoroughly to ensure all affected endpoints still function correctly. |
||
async generateJWT( | ||
@AuthUser() user: User, | ||
@Args() args: GenerateJwtInput, | ||
|
@@ -177,7 +178,7 @@ export class AuthResolver { | |
return { tokens: tokens }; | ||
} | ||
|
||
@UseGuards(JwtAuthGuard) | ||
@UseGuards(WorkspaceAuthGuard, UserAuthGuard) | ||
@Mutation(() => Verify) | ||
async impersonate( | ||
@Args() impersonateInput: ImpersonateInput, | ||
|
@@ -186,7 +187,7 @@ export class AuthResolver { | |
return await this.authService.impersonate(impersonateInput.userId, user); | ||
} | ||
|
||
@UseGuards(JwtAuthGuard) | ||
@UseGuards(WorkspaceAuthGuard) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. logic: Only WorkspaceAuthGuard is used here. Confirm if UserAuthGuard is intentionally omitted for this mutation. |
||
@Mutation(() => ApiKeyToken) | ||
async generateApiKeyToken( | ||
@Args() args: ApiKeyTokenInput, | ||
|
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.
OrThrow?