mirror of
https://github.com/MetaFam/TheGame.git
synced 2026-02-08 21:15:05 -05:00
24 lines
619 B
TypeScript
24 lines
619 B
TypeScript
import gql from 'fake-tag';
|
|
|
|
import { GetPlayerQuery, GetPlayerQueryVariables } from './autogen/types';
|
|
import { client } from './client';
|
|
import { PlayerFragment } from './fragments';
|
|
|
|
const playerQuery = gql`
|
|
query GetPlayer($username: String!) {
|
|
player(where: { username: { _eq: $username } }) {
|
|
...PlayerFragment
|
|
}
|
|
}
|
|
${PlayerFragment}
|
|
`;
|
|
|
|
export const getPlayer = async (username: string | undefined) => {
|
|
if (!username) return null;
|
|
const { data } = await client
|
|
.query<GetPlayerQuery, GetPlayerQueryVariables>(playerQuery, { username })
|
|
.toPromise();
|
|
|
|
return data?.player[0];
|
|
};
|