mirror of
https://github.com/MetaFam/TheGame.git
synced 2026-04-24 03:00:09 -04:00
feat: search queries added
This commit is contained in:
38
packages/web/graphql/getGuilds.ts
Normal file
38
packages/web/graphql/getGuilds.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
import gql from 'fake-tag';
|
||||
import { Client } from 'urql';
|
||||
|
||||
import {
|
||||
GetGuildsByTextSearchDocument,
|
||||
GetGuildsByTextSearchQuery,
|
||||
GetGuildsByTextSearchQueryVariables,
|
||||
} from './autogen/types';
|
||||
import { client as defaultClient } from './client';
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
|
||||
gql`
|
||||
query getGuildsByTextSearch($text: String) {
|
||||
search_guilds(args: { search: $text }, limit: 3) {
|
||||
id
|
||||
guildname
|
||||
logo
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
export const getGuildsByText = async (
|
||||
text: string,
|
||||
client: Client = defaultClient,
|
||||
) => {
|
||||
const { data, error } = await client
|
||||
.query<GetGuildsByTextSearchQuery, GetGuildsByTextSearchQueryVariables>(
|
||||
GetGuildsByTextSearchDocument,
|
||||
{
|
||||
text,
|
||||
},
|
||||
)
|
||||
.toPromise();
|
||||
|
||||
return {
|
||||
guilds: data?.search_guilds || [],
|
||||
error,
|
||||
};
|
||||
};
|
||||
@@ -5,6 +5,9 @@ import {
|
||||
GetPlayerFiltersDocument,
|
||||
GetPlayerFiltersQuery,
|
||||
GetPlayerFiltersQueryVariables,
|
||||
GetPlayersByTextSearchDocument,
|
||||
GetPlayersByTextSearchQuery,
|
||||
GetPlayersByTextSearchQueryVariables,
|
||||
GetPlayersDocument,
|
||||
GetPlayersQuery,
|
||||
GetPlayersQueryVariables,
|
||||
@@ -194,3 +197,33 @@ export const getPlayerFilters = async (client: Client = defaultClient) => {
|
||||
|
||||
return data;
|
||||
};
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
|
||||
gql`
|
||||
query getPlayersByTextSearch($text:String,$forLoginDisplay: Boolean! = false){
|
||||
search_players(args:{search: $text},limit:3){
|
||||
...PlayerFragment
|
||||
}
|
||||
${PlayerFragment}
|
||||
}
|
||||
`;
|
||||
|
||||
export const getPlayersByText = async (
|
||||
text: string,
|
||||
client: Client = defaultClient,
|
||||
) => {
|
||||
const { data, error } = await client
|
||||
.query<GetPlayersByTextSearchQuery, GetPlayersByTextSearchQueryVariables>(
|
||||
GetPlayersByTextSearchDocument,
|
||||
{
|
||||
text,
|
||||
},
|
||||
)
|
||||
.toPromise();
|
||||
|
||||
return {
|
||||
players: data?.search_players || [],
|
||||
// count: data?.player_aggregate.aggregate?.count || 0,
|
||||
error,
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user