docs: Clarify how endpoint names map to client properties - #767
Open
Benzzick wants to merge 1 commit into
Open
Conversation
Comment on lines
107
to
+111
| `serverpod generate` will create bindings for the endpoint and register them in the server's `generated/protocol.dart` file. It will also generate the required client code so that you can call your new `generateRecipe` method from your app. | ||
|
|
||
| :::tip Endpoint names become client properties | ||
| In the next section you'll call `client.recipe.generateRecipe(...)` — not `client.recipeEndpoint.generateRecipe(...)` or `client.generateRecipe(...)`. That's not a typo: Serverpod derives the property name from your endpoint's class name by dropping the `Endpoint` suffix and lowercasing the first letter, so `RecipeEndpoint` becomes `client.recipe`. Every method you add inside the class shows up under that property, e.g. `client.recipe.generateRecipe(...)`. This mapping is generated automatically by `serverpod generate` above — there's nothing to configure by hand, but it's worth knowing the rule so the client code doesn't feel like it's coming out of nowhere. | ||
| ::: |
Contributor
There was a problem hiding this comment.
The tip covers a real gap: the 4.0 version of this page explains this mapping and the 3.4 page doesn't. Two things about the form though. It sits directly above an existing :::note, so the section runs prose, tip, note, heading, and callouts stacked like that compete rather than stand out. It also introduces the only em dash on this page.
The 4.0 page carries the same fact as one clause in a paragraph, which reads lighter here too:
Suggested change
| `serverpod generate` will create bindings for the endpoint and register them in the server's `generated/protocol.dart` file. It will also generate the required client code so that you can call your new `generateRecipe` method from your app. | |
| :::tip Endpoint names become client properties | |
| In the next section you'll call `client.recipe.generateRecipe(...)` — not `client.recipeEndpoint.generateRecipe(...)` or `client.generateRecipe(...)`. That's not a typo: Serverpod derives the property name from your endpoint's class name by dropping the `Endpoint` suffix and lowercasing the first letter, so `RecipeEndpoint` becomes `client.recipe`. Every method you add inside the class shows up under that property, e.g. `client.recipe.generateRecipe(...)`. This mapping is generated automatically by `serverpod generate` above — there's nothing to configure by hand, but it's worth knowing the rule so the client code doesn't feel like it's coming out of nowhere. | |
| ::: | |
| `serverpod generate` will create bindings for the endpoint and register them in the server's `generated/protocol.dart` file. It will also generate the required client code so that you can call your new `generateRecipe` method from your app. The class name's `Endpoint` suffix is dropped and the first letter lowercased, so `RecipeEndpoint` is called via `client.recipe`, and every method in the class appears under that property. |
| @@ -241,4 +245,4 @@ Try out the app by clicking the button to get a new recipe. The app will call th | |||
|
|
|||
| ## Next steps | |||
|
|
|||
Contributor
There was a problem hiding this comment.
This drops the trailing newline on a line the change doesn't otherwise touch. Restore it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a tip explaining how Serverpod endpoint class names map to
properties on the generated client.
For example:
RecipeEndpointclient.recipeThis helps clarify why endpoint methods are called through
client.recipe.generateRecipe(...)after code generation.