Tuxer
Tuxer
TtRPC
Created by Tuxer on 11/20/2022 in #❓-help
query and mutate promise on next
Thanks @julius and @cje
10 replies
TtRPC
Created by Tuxer on 11/20/2022 in #❓-help
query and mutate promise on next
Okay, it worked as I needed it to. useContext must still be instantiated, direct access via the vanilla client would be even better, but it works via useContext(). Here is how to use it according to the docs:
const utils = trpc.useContext();

// use it (for example in an event handler)
const someResult = await utils.client.someRouter.someProcedure.query(/* args maybe */);
const utils = trpc.useContext();

// use it (for example in an event handler)
const someResult = await utils.client.someRouter.someProcedure.query(/* args maybe */);
10 replies
TtRPC
Created by Tuxer on 11/20/2022 in #❓-help
query and mutate promise on next
In some cases I think it's more convenient to use the vanilla client instead of hooks, because hooks can not be used everywhere.
10 replies
TtRPC
Created by Tuxer on 11/20/2022 in #❓-help
query and mutate promise on next
This looks very promising and exactly what I need. I'll try that.
10 replies
TtRPC
Created by Tuxer on 11/20/2022 in #❓-help
query and mutate promise on next
First instantiating mutate from useMutation every time seems to be quite inconvenient. I'm refering to this part of the docs https://trpc.io/docs/quickstart#querying--mutating. I'd like to call query and mutate like described:
const user = await trpc.userById.query('1');
const createdUser = await trpc.userCreate.mutate({ name: 'sachinraja' });
const user = await trpc.userById.query('1');
const createdUser = await trpc.userCreate.mutate({ name: 'sachinraja' });
10 replies