-
Notifications
You must be signed in to change notification settings - Fork 3.9k
[No QA] update API.md with more general rules #9536
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
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
4156d61
use Create/Delete and Add/Remove verbs
marcochavezf dc33374
avoid word Page or View and instructions for deep links
marcochavezf 096644d
creating data needs to be flawlessly fast
marcochavezf 5a766d0
add point about random string IDs for new objects
marcochavezf 5e8376c
add FAQ section
marcochavezf 69cef10
add another point to the Philosophy section
marcochavezf 328e566
remove outdated guidance
marcochavezf b6a227c
update point about creating data optimistically
marcochavezf 02ca396
add supplementary comment to random ID point
marcochavezf c39ff82
use another heading level for FAQ
marcochavezf 654aa87
removing point
marcochavezf e880e04
add suggestions
marcochavezf 0e46186
fix typo
marcochavezf f0813b4
add "onyxData." for consistency
marcochavezf File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,6 +6,10 @@ These are best practices related to the current API used for App. This does not | |
| - There should be no client-side handling that is unique to any API call. | ||
| - Data is pushed to the client and put straight into Onyx by low-level libraries. | ||
| - Clients should be kept up-to-date with many small incremental changes to data. | ||
| - Creating data needs to be optimistic on every connection (offline, slow 3G, etc), eg. `RequestMoney` or `SplitBill` should work without waiting for a server response. | ||
| - For new objects created from the client (reports, reportActions, policies) we're going to generate a random string ID immediately on the client, rather than needing to wait for the server to give us an ID for the created object. | ||
|
marcochavezf marked this conversation as resolved.
|
||
| - This client-generated ID will become the primary key for that record in the database. This will provide more offline functionality than was previously possible. | ||
|
|
||
| ## Response Handling | ||
| When the web server responds to an API call the response is sent to the server in one of two ways. | ||
| 1. **HTTPS Response** - Data that is returned with the HTTPS response is only sent to the client that initiated the request. | ||
|
|
@@ -50,4 +54,18 @@ For example: Accessing the data for a chat report will return the data if the re | |
| - Verbs should be unique and indicate the user's action (as perceived by the user). eg. `Request`, `Open`, `Accept`, `Pay` | ||
| - If a unique verb cannot be used, then use only the standard verbs: `Update`, `Add`, `Delete` | ||
| - Names must NOT include names of parameters eg. Bad: `SignInWithPasswordOr2FA` Good: `SignIn` | ||
| - Names must NOT include the word Page or View, eg. Bad: `OpenReportPage` Good: `OpenReport` | ||
| - Names must NOT reveal backend implementation details that the user does not know about eg. `AddVBBA` (users don't know what a VBBA is - verified business bank account) Good: `AddBankAccount` | ||
| - For deep links like `StartAppWhileSignedInAndOpenWorkspace`, create separate commands for each specific scenario like `StartAppWhileSignedIn` and `OpenWorkspace`, where both requests will be triggered in parallel. | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
|
||
| ## FAQ | ||
|
|
||
| ### How should error messages be persisted to Onyx? | ||
|
|
||
| - The API layer Pusher onyxData should set specific error messages. | ||
| - In cases where the API does not set an error, a generic error message can be set in the API.write parameter `onyxData.failureData`. | ||
| - Previous errors should be cleared in the `onyxData.optimisticData` when a new request is made. | ||
|
|
||
| ### How should we remove local data from the store if the data no longer exist in the server? eg. local policy data for policies the user is no longer a member of. | ||
|
|
||
| Use `Onyx.set(key, null)` for each data (eg. policy) not found in the server. | ||
|
aldo-expensify marked this conversation as resolved.
|
||
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.
Uh oh!
There was an error while loading. Please reload this page.