-
Notifications
You must be signed in to change notification settings - Fork 997
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
Add snippets for Querying Cheatsheet #3939
base: main
Are you sure you want to change the base?
Conversation
- Gen 1 React - Gen 2 React
|
️✅ There are no secrets present in this pull request anymore.If these secrets were true positive and are still valid, we highly recommend you to revoke them. 🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request. |
View your CI Pipeline Execution ↗ for commit c8aa9e8.
☁️ Nx Cloud last updated this comment at |
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.
I am wondering if we need styles for querying cheatsheet docs.
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.
@bwreid The goal is to add only the bare minimum of things you will use in the docs. If you believe that any file that would not break your code or tests, you can safely remove it.
e420d92
to
a06c3e9
Compare
import { fetchOneEntry } from '@builder.io/sdk-react'; | ||
|
||
export const getProduct = async (options: { | ||
apiKey: string; | ||
[key: string]: unknown; | ||
}) => | ||
fetchOneEntry({ | ||
model: 'product', | ||
query: { 'data.price': { $gte: 700 } }, | ||
...options, | ||
}); |
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.
you should rely on GetContentOptions
instead of unknown
to let types flow from the SDK
import { fetchOneEntry } from '@builder.io/sdk-react'; | |
export const getProduct = async (options: { | |
apiKey: string; | |
[key: string]: unknown; | |
}) => | |
fetchOneEntry({ | |
model: 'product', | |
query: { 'data.price': { $gte: 700 } }, | |
...options, | |
}); | |
import { fetchOneEntry, GetContentOptions } from '@builder.io/sdk-react'; | |
const getProduct = async (options: GetContentOptions) => | |
fetchOneEntry({ | |
query: { 'data.price': { $gte: 700 } }, | |
...options, | |
}); |
same applies to gen1 SDK (remove unknown
). You'll have to rework the logic a bit to provide model
from the component for your tests
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.
Also, the async
are redundant here and can be removed. They are only useful if you use await
in the body.
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.
Thanks @samijaber. Those changes have been made -- please let me know if you have any other thoughts!
- Rely on GetContentOptions for Gen 2 React - Remove unnecessary `async` keywords
Description
Adds snippets to be used within the Querying Cheatsheet doc. The only files that will be linked within the docs are the ones within the
queries/
directory -- not thequerying-cheatsheet/index.tsx
file.As this if my first commit to this repo, please let me know if I've gotten anything wrong! 🙏