Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
af0573b
Tutorial app from Markdown WIP
infomiho May 9, 2025
f30e545
Merge branch 'main' into miho-tutorial-app-from-docs
infomiho May 16, 2025
f25bca5
Cleanup
infomiho May 16, 2025
a7d35a6
Parse diffs
infomiho May 16, 2025
04287c7
Merge branch 'main' into miho-tutorial-app-from-docs
infomiho May 19, 2025
c29048e
Edit diff DX
infomiho May 19, 2025
373e563
Move patches outside of Markdown. Implement fixing broken diffs
infomiho May 19, 2025
8cf25a8
Cleanup
infomiho May 19, 2025
778602d
Merge branch 'main' into miho-tutorial-app-from-docs
infomiho Jul 16, 2025
72c0964
Cleanup
infomiho Jul 16, 2025
2a41ada
Named patches WIP
infomiho Jul 16, 2025
e7546b5
Merge branch 'main' into miho-tutorial-app-from-docs
infomiho Jul 17, 2025
10c1f1c
Update TutorialAction component
infomiho Jul 17, 2025
d00d7db
Update TutorialAction design
infomiho Jul 17, 2025
6a4a290
Stop using write action
infomiho Jul 17, 2025
0a2f90f
Cleanup
infomiho Jul 17, 2025
3ce2ca3
Cleanup
infomiho Jul 17, 2025
de1ad8a
Cleanup
infomiho Jul 17, 2025
1110026
Restructure
infomiho Jul 17, 2025
eee3f77
Refactor. Add edit step command.
infomiho Jul 17, 2025
3ea8530
Branded types, cleanup
infomiho Jul 17, 2025
c20ea08
Revert change to search-and-replace.ts
infomiho Jul 18, 2025
1348c89
Cleanup TutorialAction
infomiho Jul 18, 2025
69149ae
Cleanup
infomiho Jul 18, 2025
7ba6f4a
Merge branch 'main' into miho-tutorial-app-from-docs
infomiho Jul 18, 2025
d981153
Update styles
infomiho Jul 18, 2025
66b0fa8
Fixes patch fixing bug. Update patches.
infomiho Jul 31, 2025
8b3fe23
PR comments
infomiho Aug 4, 2025
5ad4372
Cleanup
infomiho Aug 5, 2025
f0d6ec3
Merge branch 'main' into miho-tutorial-app-from-docs
infomiho Aug 6, 2025
6522952
Formatting
infomiho Aug 6, 2025
80095ad
PR comments
infomiho Aug 6, 2025
f81a05d
Merge branch 'main' into miho-tutorial-app-from-docs
infomiho Aug 8, 2025
4e964f3
Refactor code
infomiho Aug 8, 2025
dc7fd21
Rename folder and update README
infomiho Aug 8, 2025
845e146
Merge branch 'main' into miho-tutorial-app-from-docs
infomiho Sep 12, 2025
4aa1173
PR comments
infomiho Sep 12, 2025
3af974a
Update naming
infomiho Sep 12, 2025
04f9ade
Move app init into a separate action
infomiho Sep 12, 2025
b3f9aae
PR comments
infomiho Sep 12, 2025
551679d
Merge branch 'main' into miho-tutorial-app-from-docs
infomiho Sep 15, 2025
1814a72
Update README
infomiho Sep 15, 2025
a2d043f
Merge branch 'main' into miho-tutorial-app-from-docs
infomiho Sep 29, 2025
ec4ec93
PR comments
infomiho Sep 29, 2025
fe58646
PR comments
infomiho Sep 29, 2025
6390e92
PR comments
infomiho Sep 29, 2025
939c066
Add unit tests
infomiho Sep 29, 2025
db7d68c
Merge branch 'main' into miho-tutorial-app-from-docs
infomiho Oct 6, 2025
aea3c6d
Update code block language
infomiho Oct 6, 2025
7c03e0c
Cleanup README
infomiho Oct 6, 2025
9ecdbd6
Wrap all steps with <TutorialAction> component
infomiho Oct 6, 2025
a28fa0c
Merge branch 'main' into miho-tutorial-app-from-docs
infomiho Oct 10, 2025
f78f56a
PR comments
infomiho Oct 10, 2025
19aec40
Update sort and filter fn names
infomiho Oct 10, 2025
85ff579
Extract example MDX files
infomiho Oct 10, 2025
f65fb22
Remove Git explanantion and update action name
infomiho Oct 10, 2025
7a1a3da
Update actions to action types
infomiho Oct 10, 2025
9dff3f1
Handle both md and mdx extensions
infomiho Oct 10, 2025
0ef5164
Update naming
infomiho Oct 10, 2025
6c3935d
Cleanup JSDoc
infomiho Oct 10, 2025
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
9 changes: 9 additions & 0 deletions web/docs/tutorial/03-pages.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import useBaseUrl from '@docusaurus/useBaseUrl';
import { ShowForTs } from '@site/src/components/TsJsHelpers';
import WaspStartNote from '../\_WaspStartNote.md'
import TypescriptServerNote from '../\_TypescriptServerNote.md'
import { TutorialAction } from '@site/src/components/TutorialAction';

In the default `main.wasp` file created by `wasp new`, there is a **page** and a **route** declaration:

Expand Down Expand Up @@ -98,12 +99,16 @@ Start by cleaning up the starter project and removing unnecessary code and files

First, remove most of the code from the `MainPage` component:

<TutorialAction step="1" action="write" path="src/MainPage.tsx">

```tsx title="src/MainPage.tsx" auto-js
export const MainPage = () => {
return <div>Hello world!</div>
}
```

</TutorialAction>

At this point, the main page should look like this:

<img alt="Todo App - Hello World" src={useBaseUrl('img/todo-app-hello-world.png')} style={{ border: "1px solid black" }} />
Expand All @@ -114,6 +119,8 @@ Since `src/HelloPage.{jsx,tsx}` no longer exists, remove its `route` and `page`

Your Wasp file should now look like this:

<TutorialAction step="2" action="write" path="main.wasp">

```wasp title="main.wasp"
app TodoApp {
wasp: {
Expand All @@ -128,6 +135,8 @@ page MainPage {
}
```

</TutorialAction>

Excellent work!

You now have a basic understanding of Wasp and are ready to start building your TodoApp.
Expand Down
24 changes: 24 additions & 0 deletions web/docs/tutorial/04-entities.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,36 @@ title: 4. Database Entities
---

import useBaseUrl from '@docusaurus/useBaseUrl';
import { TutorialAction } from '@site/src/components/TutorialAction';

Entities are one of the most important concepts in Wasp and are how you define what gets stored in the database.

Wasp uses Prisma to talk to the database, and you define Entities by defining Prisma models in the `schema.prisma` file.

Since our Todo app is all about tasks, we'll define a Task entity by adding a Task model in the `schema.prisma` file:

<TutorialAction step="3" action="diff">

```diff
diff --git a/schema.prisma b/schema.prisma
index 190e2a8..65d7d30 100644
--- a/schema.prisma
+++ b/schema.prisma
@@ -8,3 +8,9 @@ datasource db {
generator client {
provider = "prisma-client-js"
}
+
+model Task {
+ id Int @id @default(autoincrement())
+ description String
+ isDone Boolean @default(false)
+}

```

</TutorialAction>

```prisma title="schema.prisma"
// ...

Expand All @@ -26,6 +49,7 @@ Read more about how Wasp Entities work in the [Entities](../data-model/entities.

To update the database schema to include this entity, stop the `wasp start` process, if it's running, and run:

<TutorialAction step="4" action="migrate-db" />
```sh
wasp db migrate-dev
```
Expand Down
38 changes: 38 additions & 0 deletions web/docs/tutorial/05-queries.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ title: 5. Querying the Database

import useBaseUrl from '@docusaurus/useBaseUrl';
import { ShowForTs, ShowForJs } from '@site/src/components/TsJsHelpers';
import { TutorialAction } from '@site/src/components/TutorialAction';

We want to know which tasks we need to do, so let's list them!

Expand Down Expand Up @@ -42,6 +43,35 @@ We need to add a **query** declaration to `main.wasp` so that Wasp knows it exis
</TabItem>

<TabItem value="ts" label="TypeScript">
<TutorialAction step="5" action="diff">

```diff
diff --git a/main.wasp b/main.wasp
index 3a25ea9..ea22c79 100644
--- a/main.wasp
+++ b/main.wasp
@@ -8,4 +8,15 @@ app TodoApp {
route RootRoute { path: "/", to: MainPage }
page MainPage {
component: import { MainPage } from "@src/MainPage"
-}
\ No newline at end of file
+}
+
+query getTasks {
+ // Specifies where the implementation for the query function is.
+ // The path `@src/queries` resolves to `src/queries.ts`.
+ // No need to specify an extension.
+ fn: import { getTasks } from "@src/queries",
+ // Tell Wasp that this query reads from the `Task` entity. Wasp will
+ // automatically update the results of this query when tasks are modified.
+ entities: [Task]
+}
+

```

</TutorialAction>
```wasp title="main.wasp"
// ...

Expand Down Expand Up @@ -72,6 +102,8 @@ We need to add a **query** declaration to `main.wasp` so that Wasp knows it exis
Next, create a new file called `src/queries.ts` and define the TypeScript function we've just imported in our `query` declaration:
</ShowForTs>

<TutorialAction step="6" action="write" path="src/queries.ts">

```ts title="src/queries.ts" auto-js
import type { Task } from 'wasp/entities'
import type { GetTasks } from 'wasp/server/operations'
Expand All @@ -83,6 +115,8 @@ export const getTasks: GetTasks<void, Task[]> = async (args, context) => {
}
```

</TutorialAction>

<ShowForTs>
Wasp automatically generates the types `GetTasks` and `Task` based on the contents of `main.wasp`:

Expand Down Expand Up @@ -116,6 +150,8 @@ While we implement Queries on the server, Wasp generates client-side functions t

This makes it easy for us to use the `getTasks` Query we just created in our React component:

<TutorialAction step="7" action="write" path="src/MainPage.tsx">

```tsx title="src/MainPage.tsx" auto-js
import type { Task } from 'wasp/entities'
// highlight-next-line
Expand Down Expand Up @@ -160,6 +196,8 @@ const TasksList = ({ tasks }: { tasks: Task[] }) => {
// highlight-end
```

</TutorialAction>

Most of this code is regular React, the only exception being the <ShowForJs>two</ShowForJs><ShowForTs>three</ShowForTs> special `wasp` imports:

<ShowForJs>
Expand Down
Loading