externalize the graphql query

This commit is contained in:
Ulf Gebhardt 2023-05-04 01:55:14 +02:00
parent 81552e51dd
commit 1fa3396396
Signed by: ulfgebhardt
GPG Key ID: DA6B843E748679C9
2 changed files with 15 additions and 10 deletions

View File

@ -1,6 +1,7 @@
import { Community as DbCommunity } from '@entity/Community'
import { GraphQLClient, gql } from 'graphql-request'
import { GraphQLClient } from 'graphql-request'
import { getPublicKey } from '@/federation/query/getPublicKey'
import { LogError } from '@/server/LogError'
import { backendLogger as logger } from '@/server/logger'
@ -27,19 +28,14 @@ export class Client_1_0 {
getPublicKey = async (): Promise<string | undefined> => {
logger.info(`requestGetPublicKey with endpoint='${this.endpoint}'...`)
const query = gql`
query {
getPublicKey {
publicKey
}
}
`
const variables = {}
try {
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
const { data, errors, headers, status } = await this.client.rawRequest(query, variables)
const { data, errors, headers, status } = await this.client.rawRequest(
getPublicKey,
variables,
)
logger.debug(`Response-Data:`, data, errors, headers, status)
if (data) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access

View File

@ -0,0 +1,9 @@
import { gql } from 'graphql-request'
export const getPublicKey = gql`
query {
getPublicKey {
publicKey
}
}
`