Skip to content

Commit

Permalink
queries in top level are not working, so use apollo default client in…
Browse files Browse the repository at this point in the history
…jection
  • Loading branch information
Mogge committed Apr 9, 2024
1 parent ef67a84 commit 0cff640
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
15 changes: 9 additions & 6 deletions frontend/src/pages/index/+Page.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,24 @@
</template>

<script lang="ts" setup>
import { useQuery } from '@vue/apollo-composable'
import { ApolloClient, InMemoryCache } from '@apollo/client/core'
import { DefaultApolloClient } from '@vue/apollo-composable'
import { inject } from 'vue'
import DefaultLayout from '#layouts/DefaultLayout.vue'
// eslint-disable-next-line import/no-relative-parent-imports
import { getRoomQuery } from '#queries/getRoomQuery'
const { result, refetch } = useQuery(getRoomQuery, null, { fetchPolicy: 'network-only' })
const apolloClient = inject<ApolloClient<InMemoryCache>>(DefaultApolloClient)
const enterRoom = async () => {
try {
refetch()
window.location.href = result.value.getRoom
} catch (error) {
const result = await apolloClient?.query({ query: getRoomQuery, fetchPolicy: 'network-only' })
window.location.href = result?.data?.getRoom
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} catch (error: any) {
// eslint-disable-next-line no-console
console.log('auth error', error)
console.log('auth error', error.message ? error.message : error)
}
}
</script>
2 changes: 1 addition & 1 deletion frontend/src/pages/index/Page.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ describe('IndexPage', () => {
})
})

describe.skip('with error', () => {
describe('with error', () => {
beforeEach(() => {
vi.clearAllMocks()
getRoomQueryMock.mockRejectedValue({ message: 'Aua!' })
Expand Down
4 changes: 2 additions & 2 deletions frontend/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ export default mergeConfig(
'src/stories/**/*',
],
thresholds: {
lines: 99,
lines: 100,
// functions: 20, // has problems see https://github.com/vitest-dev/vitest/issues/3607
branches: 98,
statements: 99,
statements: 100,
},
},
},
Expand Down

0 comments on commit 0cff640

Please sign in to comment.