Skip to content

Commit

Permalink
fix: frontend graphql queries
Browse files Browse the repository at this point in the history
  • Loading branch information
froid1911 committed Feb 13, 2024
1 parent f4860c4 commit 167eb83
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 18 deletions.
6 changes: 3 additions & 3 deletions frontend/composables/useAuth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import decode from 'jwt-decode'
import useWallet from './useWallet'

export declare interface User {
address: string;
address: string;
}

const user = ref(undefined as User | undefined)
Expand All @@ -22,11 +22,11 @@ const useAuth = function () {
const checkAuthValidity = async () => {
try {
const { data, error } = await useAsyncGql('me')
if (error.value || !data.value?.me) {
if (error.value || !data.value?.system?.auth?.me) {
user.value = undefined
return
}
user.value = data.value?.me
user.value = data.value?.system?.auth?.me
} finally {
isLoading.value = false
}
Expand Down
4 changes: 2 additions & 2 deletions frontend/containers/SessionContainer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ const getSessions = async () => {
try {
errorMessage.value = ''
const { data, error } = await useAsyncGql('getSessions')
if (error.value || !data.value?.sessions) {
if (error.value || !data.value?.system?.auth?.sessions) {
errorMessage.value = error.value?.gqlErrors?.[0]?.message ?? 'Unknown error'
}
sessions.value = data.value?.sessions as Session[]
sessions.value = data.value?.system?.auth?.sessions as Session[]
} finally {
areSessionsLoading.value = false
}
Expand Down
8 changes: 6 additions & 2 deletions frontend/graphql/me.gql
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
query me {
me {
address
system {
auth {
me {
address
}
}
}
}
24 changes: 14 additions & 10 deletions frontend/graphql/sessions.gql
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
query getSessions {
sessions {
id
createdAt
createdBy
referenceExpiryDate
referenceTokenId
isUserCreated
name
revokedAt
allowedOrigins
system {
auth {
sessions {
id
createdAt
createdBy
referenceExpiryDate
referenceTokenId
isUserCreated
name
revokedAt
allowedOrigins
}
}
}
}
2 changes: 1 addition & 1 deletion frontend/nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export default defineNuxtConfig({
clients: {
default: {
host: `${API_BASE}/drives`,
schema: '../api/src/generated/schema.graphql'
schema: '../api/src/graphql/generated/index/schema.graphql'
}
}
}
Expand Down

0 comments on commit 167eb83

Please sign in to comment.