diff --git a/src/graphql/types/Game.ts b/src/graphql/types/Game.ts index 92ad479..20b8205 100644 --- a/src/graphql/types/Game.ts +++ b/src/graphql/types/Game.ts @@ -21,7 +21,9 @@ builder.queryField('games', (t) => ( builder.queryField('game', (t) => ( t.prismaField({ type: 'Game', - args: { id: t.arg.string() }, + args: { + id: t.arg.id() + }, resolve: (q, _p, { id }) => { if(!id) return null; return database.game.findUnique({ where: { uuid: id } }) diff --git a/src/pages/games/index.tsx b/src/pages/games/index.tsx index 4644130..3f6feda 100644 --- a/src/pages/games/index.tsx +++ b/src/pages/games/index.tsx @@ -8,31 +8,32 @@ import { extendFragment, includeFragment } from '@/lib/fragment'; import { Paginated, paginationQuery } from '@/lib/page'; type PageProps = { - games:Paginated|null; + games:GameLight[]; } | Error500Props; -export const getServerSideProps: GetServerSideProps = async () => { +export const getServerSideProps:GetServerSideProps = async () => { try { const client = await apiClientGet(); - const res = await client.query<{ games:Paginated }>({ + const res = await client.query<{ games:GameLight[] }>({ variables: { after: null, }, query: gql` ${includeFragment(GameLightFragment)} + query getGames { - games(first: 100) { - ${paginationQuery(extendFragment(GameLightFragment))} + games { + ${extendFragment(GameLightFragment)} } } `, }); if(!res || !res.data || !res.data.games) { - return { props: { games:null } }; + return { props: { games:[] } }; } - return { props: { games: res.data.games } }; + return { props: { games: res.data.games } }; } catch (e) { console.error('Error', e); return { props: { code: 500 } }; @@ -54,11 +55,11 @@ export const Page: React.FC = props => {

Games

    - {games.edges.map(({ node }) => { + {games.map(node => { return (
  • - {node.name} ({node.system}) + {node.title} ({node.system})
  • );