Skip to content

Commit

Permalink
feat: move user query to a separate file
Browse files Browse the repository at this point in the history
  • Loading branch information
ruslan-sh-r committed May 29, 2024
1 parent 5227075 commit 03710a4
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 24 deletions.
1 change: 1 addition & 0 deletions src/gql/query/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@ export * from "./spotPools"
export * from "./spotPoolSwap"
export * from "./staking"
export * from "./stats"
export * from "./user"
export * from "./users"
export * from "./wasm"
33 changes: 33 additions & 0 deletions src/gql/query/user.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import {
convertObjectToPropertiesString,
doGqlQuery,
gqlQuery,
GQLQuery,
GQLUser,
DeepPartial,
GQLQueryGqlUserArgs,
} from ".."

export interface GqlOutUser {
user?: GQLQuery["user"]
}

export const userQueryString = (
args: GQLQueryGqlUserArgs,
excludeParentObject: boolean,
fields: DeepPartial<GQLUser>
) => {
return gqlQuery(
"user",
args,
convertObjectToPropertiesString(fields),
excludeParentObject
)
}

export const user = async (
args: GQLQueryGqlUserArgs,
endpt: string,
fields: DeepPartial<GQLUser>
): Promise<GqlOutUser> =>
doGqlQuery(userQueryString(args, false, fields), endpt)
24 changes: 0 additions & 24 deletions src/gql/query/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,12 @@ import {
GQLUser,
GQLUserOrder,
DeepPartial,
GQLQueryGqlUserArgs,
} from ".."

export interface GqlOutUser {
user?: GQLQuery["user"]
}
export interface GqlOutUsers {
users?: GQLQuery["users"]
}

export const userQueryString = (
args: GQLQueryGqlUserArgs,
excludeParentObject: boolean,
fields: DeepPartial<GQLUser>
) => {
return gqlQuery(
"user",
args,
convertObjectToPropertiesString(fields),
excludeParentObject
)
}

export const usersQueryString = (
args: GQLQueryGqlUsersArgs,
excludeParentObject: boolean,
Expand All @@ -47,13 +30,6 @@ export const usersQueryString = (
)
}

export const user = async (
args: GQLQueryGqlUserArgs,
endpt: string,
fields: DeepPartial<GQLUser>
): Promise<GqlOutUser> =>
doGqlQuery(userQueryString(args, false, fields), endpt)

export const users = async (
args: GQLQueryGqlUsersArgs,
endpt: string,
Expand Down

0 comments on commit 03710a4

Please sign in to comment.