Git Product home page Git Product logo

Comments (3)

Martinsos avatar Martinsos commented on May 24, 2024

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.

leoschet avatar leoschet commented on May 24, 2024

@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.

sodic avatar sodic commented on May 24, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.