Cleanup game stuff before I redo pagination.
This commit is contained in:
@ -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 } })
|
||||
|
@ -8,28 +8,29 @@ import { extendFragment, includeFragment } from '@/lib/fragment';
|
||||
import { Paginated, paginationQuery } from '@/lib/page';
|
||||
|
||||
type PageProps = {
|
||||
games:Paginated<GameLight>|null;
|
||||
games:GameLight[];
|
||||
} | Error500Props;
|
||||
|
||||
export const getServerSideProps: GetServerSideProps<PageProps> = async () => {
|
||||
export const getServerSideProps:GetServerSideProps<PageProps> = async () => {
|
||||
try {
|
||||
const client = await apiClientGet();
|
||||
const res = await client.query<{ games:Paginated<GameLight> }>({
|
||||
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 } };
|
||||
@ -54,11 +55,11 @@ export const Page: React.FC<PageProps> = props => {
|
||||
<div>
|
||||
<h1>Games</h1>
|
||||
<ul>
|
||||
{games.edges.map(({ node }) => {
|
||||
{games.map(node => {
|
||||
return (
|
||||
<li key={node.id}>
|
||||
<Link href={`/games/${node.id}`}>
|
||||
{node.name} ({node.system})
|
||||
{node.title} ({node.system})
|
||||
</Link>
|
||||
</li>
|
||||
);
|
||||
|
Reference in New Issue
Block a user