mirror of
https://github.com/wasp-lang/wasp.git
synced 2024-12-24 17:44:21 +03:00
Final polishing of first version of RWA.
This commit is contained in:
parent
e9f4af07d7
commit
ec015c1357
@ -53,3 +53,4 @@ Thoughts while implementing the RWA:
|
||||
- Pagination, although so common, demanded non-trivial effort and attention. Since pagination is full-stack feature, I am pretty sure we could offer some support here through Wasp and simplify it / provide something out of the box. There are two types of pagination we should take into consideration: skip+take and cursor-based.
|
||||
- I had a situation where I had the operation dealing with entity E2 but E2 did not have to be provided under "entities" in Wasp becuause through Prisma nesting it was accessed through E1. However, I still wanted cache invalidation to work on frontend so I added E2 under "entities". Situation could also be opposite: we might need to provide E2 under "entities" to do some operation, although we know it does not affect cache invalidation. It might be interesting in the future to give more attention to this and make sure Wasp does its best to provide smooth experience in these situations -> maybe by some special support.
|
||||
- Wasp file ended up really big and hard to navigate! Even if we don't have a real module support, just splitting it into multiple files that are then merged together might be a good start (and it might work since order is not important so far).
|
||||
- Would be cool if not each action had to be imported as a separate import statement, but maybe all in one statement.
|
||||
|
@ -13,7 +13,7 @@ const Navbar = () => {
|
||||
<Link to='/'> Home </Link>
|
||||
<Link to='/editor'> New Article </Link>
|
||||
<Link to='/settings'> Settings </Link>
|
||||
<a href={`/@${user.username}`}> { user.username } </a>
|
||||
<Link to={`/@${user.username}`}> { user.username } </Link>
|
||||
</div>
|
||||
)
|
||||
} else {
|
||||
|
@ -5,7 +5,7 @@ import { userPublicSelection } from '../user/queries.js'
|
||||
// TODO: I extracted this articleInclude and articleSetFavoritedFields to enable
|
||||
// reusing of logic that shapes articles as they come out of the server,
|
||||
// but I wonder if there is a more elegant way - here there are a lot of assumptions,
|
||||
// and it is easy to not use where it should be used or use it in wrong setting.
|
||||
// and it is easy to not use where it should be used or use it in a wrong setting.
|
||||
|
||||
const articleInclude = {
|
||||
user: {
|
||||
|
@ -1,8 +1,8 @@
|
||||
import React, { useState } from 'react'
|
||||
import { useHistory } from 'react-router-dom'
|
||||
|
||||
import login from '@wasp/auth/login.js'
|
||||
import signup from '@wasp/actions/signup'
|
||||
import login from '@wasp/auth/login'
|
||||
import signup from '@wasp/auth/signup'
|
||||
|
||||
export default () => {
|
||||
const history = useHistory()
|
||||
|
@ -1,21 +1,5 @@
|
||||
import HttpError from '@wasp/core/HttpError.js'
|
||||
|
||||
export const signup = async ({ username, email, password }, context) => {
|
||||
try {
|
||||
console.log(username, email, password)
|
||||
return await context.entities.User.create({
|
||||
data: { username, email, password }
|
||||
})
|
||||
} catch (err) {
|
||||
// TODO: I wish I didn't have to do this, I would love this to be in some
|
||||
// degree done automatically.
|
||||
if (err.code == 'P2002') {
|
||||
throw new HttpError(400, err.meta.target + " must be unique.")
|
||||
}
|
||||
throw err
|
||||
}
|
||||
}
|
||||
|
||||
export const updateUser = async ({ email, username, bio, profilePictureUrl, newPassword }, context) => {
|
||||
if (!context.user) { throw new HttpError(403) }
|
||||
|
||||
|
@ -2,6 +2,13 @@ app Conduit {
|
||||
title: "Conduit"
|
||||
}
|
||||
|
||||
auth {
|
||||
userEntity: User,
|
||||
methods: [ EmailAndPassword ]
|
||||
}
|
||||
|
||||
// ----------------- Pages ------------------ //
|
||||
|
||||
route "/" -> page Main
|
||||
page Main {
|
||||
component: import Main from "@ext/MainPage.js"
|
||||
@ -41,6 +48,8 @@ page ArticleView {
|
||||
component: import ArticleView from "@ext/article/components/ArticleViewPage.js"
|
||||
}
|
||||
|
||||
// ----------------- Entities ------------------ //
|
||||
|
||||
entity User {=psl
|
||||
id Int @id @default(autoincrement())
|
||||
username String @unique
|
||||
@ -89,21 +98,13 @@ entity ArticleTag {=psl
|
||||
articles Article[]
|
||||
psl=}
|
||||
|
||||
auth {
|
||||
userEntity: User,
|
||||
methods: [ EmailAndPassword ]
|
||||
}
|
||||
// ----------------- User operations ------------------ //
|
||||
|
||||
query getUser {
|
||||
fn: import { getUser } from "@ext/user/queries.js",
|
||||
entities: [User]
|
||||
}
|
||||
|
||||
action signup {
|
||||
fn: import { signup } from "@ext/user/actions.js",
|
||||
entities: [User]
|
||||
}
|
||||
|
||||
action updateUser {
|
||||
fn: import { updateUser } from "@ext/user/actions.js",
|
||||
entities: [User]
|
||||
@ -114,6 +115,8 @@ action followUser {
|
||||
entities: [User]
|
||||
}
|
||||
|
||||
// ----------------- Article operations ------------------ //
|
||||
|
||||
query getArticlesByUser {
|
||||
fn: import { getArticlesByUser } from "@ext/article/queries.js",
|
||||
entities: [Article]
|
||||
@ -179,6 +182,8 @@ query getTags {
|
||||
entities: [ArticleTag, Article]
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
|
||||
dependencies {=json
|
||||
"prop-types": "15.7.2",
|
||||
"react-markdown": "5.0.3",
|
||||
|
Loading…
Reference in New Issue
Block a user