Repository: trpc/trpc
File: packages/react-query/src/shared/hooks/createHooksInternal.tsx (TypeScript)

Code before:
        queryFn: isInputSkipToken
          ? input
          : async (queryFunctionContext) => {
              const actualOpts = {
                ...ssrOpts,
                trpc: {
                  ...ssrOpts?.trpc,
                  ...(shouldAbortOnUnmount
                    ? { signal: queryFunctionContext.signal }
                    : {}),
                },
              };

              const result = await client.query(
                ...getClientArgs(queryKey, actualOpts),
              );

              if (isAsyncIterable(result)) {
                const queryHash = hashKey(queryKey);

                const queryCache = queryClient.getQueryCache();

                const query = queryCache.build(queryClient, {
                  queryKey,
                  queryHash,
                });

                query.setState({
                  data: [],
                  status: 'pending',
                });

                const aggregate: unknown[] = [];
                for await (const value of result) {
                  aggregate.push(value);

                  query.setState({
                    data: [...aggregate],
                  });
                }
                return aggregate;
              }
              return result;
            },
      },
      queryClient,
    ) as UseTRPCQueryResult<unknown, TError>;

    hook.trpc = useHookResult({
      path,
    });

Review comment (performance):
i've never used the `.build()` method, but for all the methods I've used, I think I never needed both the `queryHash` *and* the `queryKey`. 

Does this still work with only the `queryHash`?
```suggestion
                const query = queryCache.build(queryClient, {
                  queryHash,
                });
```

Code after:
        queryFn: isInputSkipToken
          ? input
          : async (queryFunctionContext) => {
              const actualOpts = {
                ...ssrOpts,
                trpc: {
                  ...ssrOpts?.trpc,
                  ...(shouldAbortOnUnmount
                    ? { signal: queryFunctionContext.signal }
                    : {}),
                },
              };

              const result = await client.query(
                ...getClientArgs(queryKey, actualOpts),
              );

              if (isAsyncIterable(result)) {
                const queryCache = queryClient.getQueryCache();

                const query = queryCache.build(queryFunctionContext.queryKey, {
                  queryKey,
                });

                query.setState({
                  data: [],
                  status: 'success',
                });

                const aggregate: unknown[] = [];
                for await (const value of result) {
                  aggregate.push(value);

                  query.setState({
                    data: [...aggregate],
                  });
                }
                return aggregate;
              }
              return result;
            },
      },
      queryClient,
    ) as UseTRPCQueryResult<unknown, TError>;

    hook.trpc = useHookResult({
      path,
    });

    return hook;
  }