Comments (3)
They can also import action directly, from its file. In which case they have to construct the context
completely on their own, while allegedly, if they import it via wasp/server/operations
, they don't have to construct it completely on their own, but need to pass just user
to the context and rest will be added.
We should confirm this and decide if we want to document "raw" import approach also or not.
from wasp.
@Martinsos I'm not sure I follow how to call queries without the useQuery
hook.
From the docs I had initially understood that wasp would magically add the context, even when calling the function without the hook. Per your last comment, that is not the case, though, and I'm still confused on how to actually do it.
It seems that to directly call the query I must pass the query cache key, plus the user (as context). The advanced usage section for actions says we can get the queryCacheKey
from the "operation" itself, but that doesn't work:
import { getTasks } from 'wasp/client/operations';
// ...
const { data: tasks } = await getTasks(getTasks.queryCacheKey, { user });
I would suggest adding to the docs an example of how to call queries with entities without the useQuery
hook. I would also say the concepts valid for both queries and actions could be in a separate section that appears before queries and actions, perhaps directly in Overview.
edit: opened a question in discord too.
from wasp.
@leoschet As mentioned on Discord, this issue deals with calling Operations from the server, so it's not really applicable to your situation.
However, the advanced usage docs you linked do talk about calling Operations from client, and you've successfully caught two mistakes. I've created an issue for fixing the docs and improving the API: #1923
Thanks!
from wasp.
Related Issues (20)
- Document our environment variables HOT 1
- Drop mention of `nvm` from "Quick Start" docs
- Improve error message when root component takes no arguments
- Add "SEO" section in our docs HOT 2
- Document passing of client env vars to `wasp deploy fly deploy`?
- resource exhausted (Too many open files) HOT 6
- Reinclude lost TypeScript documentation
- Fix docs for directly calling Operations from the client HOT 1
- Add docs on how to connect to production database (e.g. with Prisma studio)
- Move our docs from Github Pages to Cloudflare Pages HOT 2
- Make email verification and password tokens one-time use only HOT 1
- Dig deeper into Vite's HMR problems
- Use `strict: true` for TS for the SDK package
- Add support for Python backend
- Docs: explain what to expect from each auth method
- SDK build failed with exit code: 2 HOT 3
- Teach Wasp AI to use Wasp starter templates (or parts of them) HOT 8
- Provide better direct support for static content in Wasp
- Auth docs: better explain `userSignupFields` and SignupForm `additionalFields` and their relationship HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wasp.