Skip to content
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

Merged
merged 11 commits into from
Jan 25, 2024
Merged

Fixes CRUD feature to work with SDK #1656

merged 11 commits into from
Jan 25, 2024

Conversation

infomiho
Copy link
Contributor

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.

-- 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)
Copy link
Contributor Author

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]
Copy link
Contributor Author

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]
Copy link
Contributor Author

@infomiho infomiho Jan 23, 2024

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 @@
{
Copy link
Contributor Author

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 @@
{{={= =}=}}
Copy link
Contributor Author

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 =}";
Copy link
Contributor Author

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

@@ -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
Copy link
Contributor

@sodic sodic Jan 25, 2024

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

@sodic sodic merged commit b058eab into filip-sdk Jan 25, 2024
1 of 4 checks passed
@sodic sodic deleted the miho-crud-fixes branch January 25, 2024 14:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants