Skip to content
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
eb614c3
feat: add Apollo Client
martakam Oct 4, 2026
9cca943
feat: add simple GraphQL demo to homepage
martakam Oct 4, 2026
2575599
Merge branch 'main' into feat/basic-apollo-client-setup
martakam Oct 7, 2026
7907c82
Merge remote-tracking branch 'origin/main' into feat/connect-frontend…
johahor Oct 9, 2026
f354af2
Merge branch 'feat/search-count-and-book-by-id' into feat/connect-fro…
johahor Oct 9, 2026
52bbbe2
fix: point Apollo Client to backend URL and use searchBooks in demo
johahor Oct 9, 2026
a09de48
feat: add useSearchBooks hook for our GraphQL API
johahor Oct 9, 2026
eecc319
feat: fetch books on the home page from our GraphQL API
johahor Oct 9, 2026
4a226c9
refactor: move toBook into its own file
johahor Oct 9, 2026
dd3cd2c
feat: fetch book details from our GraphQL API
johahor Oct 9, 2026
0582072
fix: use TypedDocumentNode for Apollo queries and remove unused filters
johahor Oct 9, 2026
51ca3df
Merge remote-tracking branch 'origin/main' into feat/connect-frontend…
johahor Oct 9, 2026
121f4ff
refactor: remove Open Library API and TanStack Query
johahor Oct 9, 2026
2a3279f
refactor: remove unnecessary pnpm exec in script
martakam Oct 9, 2026
e6b40d3
feat: add GraphQL codegen to frontend
martakam Oct 9, 2026
39e146b
chore: run GraphQL codegen
martakam Oct 9, 2026
733679f
build: eslint should not check .generated. files
martakam Oct 9, 2026
c4f3ad3
refactor: use generated GraphQL types in API hooks
martakam Oct 9, 2026
49bcc1a
refactor: move API types into api/types folder
martakam Oct 9, 2026
1acfa11
chore: run Prettier on frontend code
martakam Oct 9, 2026
5039a4e
build: ignore build and generated files in Prettier
martakam Oct 9, 2026
cf65d07
chore: remove leftover unused GraphQL schema
martakam Oct 10, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"description": "",
"main": "dist/index.js",
"scripts": {
"prestart": "pnpm exec graphql-codegen",
"prestart": "graphql-codegen",
"typecheck": "tsc",
"dev": "tsx src/index.ts",
"build": "esbuild src/index.ts --bundle --platform=node --format=esm --target=node24 --packages=external --outfile=dist/index.js",
Expand Down
161 changes: 0 additions & 161 deletions frontend/app/api/openLibrary.test.ts

This file was deleted.

98 changes: 0 additions & 98 deletions frontend/app/api/openLibrary.ts

This file was deleted.

31 changes: 31 additions & 0 deletions frontend/app/api/toBook.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import type { Book } from "~/api/types";
import type {
BookQuery,
SearchBooksQuery,
} from "~/api/types/graphql.generated";

// This complicated regex is to extract the year from the
// publishDate string from the dataset we used in Kaggle.
// It's not perfect, and we should probably decide later if
// we want to extract the year in the upload script itself,
// and turn publishedDate from a string into one integer 'year'
// to be able to sort/filter by year.
function yearFromPublishDate(publishDate: string | null): number | undefined {
const match = publishDate?.match(/\d{4}/);
return match ? Number(match[0]) : undefined;
}

// Converts a book from our GraphQL API to the Book type used by the components.
export function toBook(
book:
| NonNullable<BookQuery["book"]>
| NonNullable<SearchBooksQuery["searchBooks"]>["books"][number],
): Book {
return {
id: String(book.id),
title: book.title,
author: [book.author],
publishedYear: yearFromPublishDate(book.publishDate),
coverImage: book.coverImgUrl ?? undefined,
};
}
50 changes: 0 additions & 50 deletions frontend/app/api/types.ts

This file was deleted.

44 changes: 44 additions & 0 deletions frontend/app/api/types/graphql.generated.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/** Internal type. DO NOT USE DIRECTLY. */
type Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] };
/** Internal type. DO NOT USE DIRECTLY. */
export type Incremental<T> =
| T
| {
[P in keyof T]?: P extends " $fragmentName" | "__typename" ? T[P] : never;
};
export type BookQueryVariables = Exact<{
id: number;
}>;

export type BookQuery = {
book: {
__typename: "Book";
id: number;
title: string;
author: string;
publishDate: string | null;
coverImgUrl: string | null;
description: string | null;
} | null;
};

export type SearchBooksQueryVariables = Exact<{
title?: string | null | undefined;
limit?: number | null | undefined;
offset?: number | null | undefined;
}>;

export type SearchBooksQuery = {
searchBooks: {
__typename: "BookSearchResult";
totalCount: number;
books: Array<{
__typename: "Book";
id: number;
title: string;
author: string;
publishDate: string | null;
coverImgUrl: string | null;
}>;
};
};
Loading