Skip to content
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

Start migrating frontend #323

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions frontend/nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ export default defineNuxtConfig({
// URL to use when using websockets in GraphQL CCDscan API.
// (env NUXT_PUBLIC_WS_URL)
wsUrl: 'ws://localhost:5090/graphql',
// URL to use when sending GraphQL queries to the fungy CCDscan API.
// (env NUXT_PUBLIC_FUNGY_API_URL)
fungyApiUrl: 'http://localhost:8000/api/graphql',
// Settings for how to display the explorer.
explorer: {
// The name to display for the explorer.
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/molecules/GraphQLClient.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
import { SubscriptionClient } from 'subscriptions-transport-ws'

const {
public: { apiUrl, wsUrl, enableUrqlDevtools },
public: { apiUrl, wsUrl, fungyApiUrl, enableUrqlDevtools },
} = useRuntimeConfig()

const subscriptionClient = new SubscriptionClient(wsUrl, {
Expand All @@ -37,6 +37,6 @@ const client = createClient({
url: apiUrl,
exchanges,
})

provideClient(client)
provide('fungyApiUrl', fungyApiUrl)
</script>
3 changes: 3 additions & 0 deletions frontend/src/queries/useAccountListQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ const AccountsQuery = gql<AccountsListResponse>`

export const useAccountsListQuery = (variables: AccountListVariables) => {
const { data } = useQuery({
context: {
url: inject<string>('fungyApiUrl'),
},
query: AccountsQuery,
requestPolicy: 'cache-and-network',
variables,
Expand Down
17 changes: 3 additions & 14 deletions frontend/src/queries/useAccountQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,19 +150,6 @@ address {
}
amount
transactionCount
baker {
bakerId
state {
...on ActiveBakerState {
__typename
stakedAmount
}
...on RemovedBakerState {
__typename
removedAt
}
}
}
releaseSchedule {
totalAmount
schedule(
Expand Down Expand Up @@ -309,9 +296,11 @@ export const useAccountQuery = ({
}: QueryParams) => {
const query = id?.value ? AccountQuery : AccountQueryByAddress
const identifier = id?.value ? { id: id.value } : { address: address?.value }

const { data, fetching, error, executeQuery } = useQuery({
query,
context: {
url: inject<string>('fungyApiUrl'),
},
requestPolicy: 'network-only',
variables: {
...identifier,
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/queries/useAccountRewardMetricsQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ export const useAccountRewardMetricsQuery = (
period: Ref<MetricsPeriod>
) => {
const { data, fetching } = useQuery({
context: {
url: inject<string>('fungyApiUrl'),
},
query: AccountRewardMetricsQuery,
requestPolicy: 'cache-and-network',
variables: { accountId, period },
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/queries/useAccountsMetricsQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ const AccountsMetricsQuery = gql<AccountsMetricsQueryResponse>`

export const useAccountsMetricsQuery = (period: Ref<MetricsPeriod>) => {
const { data, fetching, executeQuery } = useQuery({
context: {
url: inject<string>('fungyApiUrl'),
},
query: AccountsMetricsQuery,
requestPolicy: 'cache-and-network',
variables: { period },
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/queries/useTransactionListQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ export const useTransactionsListQuery = (
variables: Partial<QueryVariables>
) => {
const { data, executeQuery } = useQuery({
context: {
url: inject<string>('fungyApiUrl'),
},
query: TransactionsQuery,
requestPolicy: 'cache-and-network',
variables,
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/queries/useTransactionMetrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ const TransactionMetricsQuery = gql<TransactionMetricsQueryResponse>`

export const useTransactionMetricsQuery = (period: Ref<MetricsPeriod>) => {
const { data, executeQuery, fetching } = useQuery({
context: {
url: inject<string>('fungyApiUrl'),
},
query: TransactionMetricsQuery,
requestPolicy: 'cache-and-network',
variables: { period },
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/queries/useTransactionQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -633,8 +633,10 @@ export const useTransactionQuery = ({
}: QueryParams) => {
const query = id?.value ? TransactionQuery : TransactionQueryByHash
const identifier = id?.value ? { id: id.value } : { hash: hash?.value }

const { data, fetching, error } = useQuery({
context: {
url: inject<string>('fungyApiUrl'),
},
query,
requestPolicy: 'cache-first',
variables: {
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/queries/useTransactionReleaseSchedule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ export const useTransactionReleaseSchedule = (
const { data } = useQuery({
query: TransactionReleaseScheduleQuery,
requestPolicy: 'cache-first',
context: {
url: inject<string>('fungyApiUrl'),
},
variables: {
hash,
...schedulePaging,
Expand Down
Loading