mirror of
https://github.com/MetaFam/TheGame.git
synced 2026-01-25 22:28:00 -05:00
24 lines
612 B
TypeScript
24 lines
612 B
TypeScript
import gql from 'fake-tag';
|
|
|
|
import { GetGuildQuery, GetGuildQueryVariables } from './autogen/types';
|
|
import { client } from './client';
|
|
import { GuildFragment } from './fragments';
|
|
|
|
const guildQuery = gql`
|
|
query GetGuild($guildname: String!) {
|
|
guild(where: { guildname: { _eq: $guildname } }) {
|
|
...GuildFragment
|
|
}
|
|
}
|
|
${GuildFragment}
|
|
`;
|
|
|
|
export const getGuild = async (guildname: string | undefined) => {
|
|
if (!guildname) return null;
|
|
const { data } = await client
|
|
.query<GetGuildQuery, GetGuildQueryVariables>(guildQuery, { guildname })
|
|
.toPromise();
|
|
|
|
return data?.guild[0];
|
|
};
|