Skip to content

Commit

Permalink
refactor: prevent mutating function args
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesgeorge007 authored and JoelJacobStephen committed Mar 13, 2024
1 parent 81262e6 commit fd51d73
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/hoppscotch-sh-admin/src/composables/usePagedQuery.ts
Expand Up @@ -10,7 +10,7 @@ export function usePagedQuery<
query: string | TypedDocumentNode<Result, Vars> | DocumentNode,
getList: (result: Result) => ListItem[],
itemsPerPage: number,
variables: Vars,
baseVariables: Vars,
getCursor?: (value: ListItem) => string
) {
const { client } = useClientHandle();
Expand All @@ -21,6 +21,8 @@ export function usePagedQuery<
const hasNextPage = ref(true);

const fetchNextPage = async (additionalVariables?: Vars) => {
let variables = { ...baseVariables };

fetching.value = true;

// Cursor based pagination
Expand All @@ -36,7 +38,7 @@ export function usePagedQuery<
variables = { ...variables, ...additionalVariables };
}

const result = await client.query(query, { ...variables }).toPromise();
const result = await client.query(query, variables).toPromise();
if (result.error) {
error.value = true;
fetching.value = false;
Expand Down

0 comments on commit fd51d73

Please sign in to comment.