-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes CRUD feature to work with SDK #1656
Conversation
-- We are dropping extensions here because of the way the "exports" field works in package.json. | ||
-- If we left the extension, it would resolve the import e.g. ext-src/foo.js to ext-src/foo.js.js, | ||
-- which is not what we want. | ||
importPathWithoutExtension = dropExtensionFromImportPath (SP.castRel extImportPath) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please take at look at this piece and the comment.
cruds = getCruds spec | ||
areThereAnyCruds = not $ null cruds | ||
|
||
genCrudOperations :: AppSpec -> [(String, AS.Crud.Crud)] -> Generator [FileDraft] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved from WebAppGenerator
tmplData = getCrudOperationJson name crud idField | ||
idField = getIdFieldFromCrudEntity spec crud | ||
|
||
genCrudServerOperations :: AppSpec -> [(String, AS.Crud.Crud)] -> Generator [FileDraft] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved from ServerGenerator
and adjusted to generated types for full-stack types
@@ -0,0 +1,4 @@ | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since I have formatting turned on save, this makes my life much easier 😂
@@ -0,0 +1,105 @@ | |||
{{={= =}=}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We generate server crud types in the SDK so they can be used for full-stack type safety.
{=/ isAuthEnabled =} | ||
import type { GetAllQuery, GetQuery, CreateAction, UpdateAction, DeleteAction } from "{= crudTypesImportPath =}"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are importing the CRUD types from the SDK
waspc/src/Wasp/Generator/Crud.hs
Outdated
@@ -52,6 +53,9 @@ getCrudOperationJson crudOperationName crud idField = | |||
getCrudFilePath :: String -> String -> Path' (Rel r) File' | |||
getCrudFilePath crudName ext = fromJust (SP.parseRelFile (crudName ++ "." ++ ext)) | |||
|
|||
getCrudTypesImportPath :: String -> String | |||
getCrudTypesImportPath name = "wasp/server/crud/" ++ name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please make this consistent with the other stuff (location and implementation): 59c0b6c#r1464996193
I'll handle it
Moved some server and client pieces to the SDK.
Made sure the exports work and had to make sure that
ext-src
imports had no extensions.