ottomated / trpc-svelte-query

66 stars 9 forks source link

Using 1.0.0 createContext is not awaited #5

Closed JonathonRP closed 1 year ago

JonathonRP commented 1 year ago

When attempting to access ctx without (await ctx) properties return undefined and typescript thinks it's an object instead of promise... Looking for help to resolve this.

repo

ottomated commented 1 year ago

Please post a minimal reproducible example using stackblitz or codesandbox.

JonathonRP commented 1 year ago

I just followed the example - import type { inferAsyncReturnType } from "@trpc/server";

export const createContext = async (event: RequestEvent) => { return { event } };

export type Context = inferAsyncReturnType;

Which if followed creates this issue, simply removing async fixes this. Also the example docs for creating server needs createContext line.

ottomated commented 1 year ago

A minimal reproducible example should contain all the code needed to reproduce the error and no more. You can create one here. Without that, I can't help you.

JonathonRP commented 1 year ago

@ottomated fyi working on reproduction repo from the provided link

ottomated commented 1 year ago

Okay, closing this issue until you post a non-working version 👍

JonathonRP commented 1 year ago

@ottomated - repo

ottomated commented 1 year ago

This is fixed in 1.0.1