Skip to content

Commit

Permalink
fix: debug url (#624)
Browse files Browse the repository at this point in the history
  • Loading branch information
matmut7 authored Jan 17, 2024
1 parent 5617c1d commit 00febe6
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
15 changes: 10 additions & 5 deletions src/hooks/use-users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
} from "@/queries/index"
import logAction from "@/utils/log-action"
import { getSession } from "next-auth/react"
import logger from "@/utils/logger"

interface UserMapping {
name: string
Expand Down Expand Up @@ -116,11 +117,15 @@ export const mergeUsers = async (
userToDrop: User
): Promise<User> => {
const session = await getSession()
logAction({
action: "merge",
user: session?.user.login,
parameters: JSON.stringify({ userToKeep, userToDrop }),
})
try {
await logAction({
action: "merge",
user: session?.user.login,
parameters: JSON.stringify({ userToKeep, userToDrop }),
})
} catch (e) {
logger.error({ e }, "error inserting log")
}

await graphQLFetcher({
query: mergeUsersQuery,
Expand Down
5 changes: 4 additions & 1 deletion src/utils/graphql-fetcher.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { GraphQLClient } from "graphql-request"
import { NEXT_PUBLIC_HASURA_URL } from "./env"
import logger from "./logger"

export interface GraphQLFetcherParams {
query: string
Expand Down Expand Up @@ -31,7 +32,9 @@ const graphQLFetcher = ({
}
}

const client = new GraphQLClient(url || NEXT_PUBLIC_HASURA_URL, options)
const using_url = url || NEXT_PUBLIC_HASURA_URL
const client = new GraphQLClient(using_url, options)
logger.info({ using_url })

return client.request(query, parameters)
}
Expand Down
2 changes: 1 addition & 1 deletion src/utils/log-action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const logAction = ({
parameters,
token,
}: LogActionParameters) => {
graphQLServiceFetcher({
return graphQLServiceFetcher({
query: insertLog,
...(token && { token, includeCookie: false }),
...(!token && { includeCookie: true }),
Expand Down

0 comments on commit 00febe6

Please sign in to comment.