Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import styles from './index.module.css';

export default function Home() {
const hello = api.greet.hello.useQuery({ text: 'from tRPC' });
const posts = api.post.findMany.useQuery({ where: { published: true }, include: { author: true } });
const postsTransformed = api.post.findMany.useQuery(
const posts = api.post.post.findMany.useQuery({ where: { published: true }, include: { author: true } });
const postsTransformed = api.post.post.findMany.useQuery(
{},
{ select: (data) => data.map((p) => ({ id: p.id, title: p.name })) }
);
Expand All @@ -14,9 +14,7 @@ export default function Home() {
<main className={styles.main}>
{hello.data && <h1 className={styles.title}>{hello.data.greeting}</h1>}
{posts.data?.map((post) => (
<p key={post.id}>
{post.name} by {post.author.email}
</p>
<p key={post.id}>{post.name}</p>
))}
{postsTransformed.data?.map((post) => (
<p key={post.id}>{post.title}</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const getBaseUrl = () => {
};

/** A set of type-safe react-query hooks for your tRPC API. */
export const api = createTRPCNext<AppRouter>({
export const api = createTRPCNext<AppRouter, 'post'>({
config() {
return {
/**
Expand Down