I'm not exactly sure that I understand you, but if I do, then how about this:
namespace Test {
export const Result = {
num: 3
}
export const Variables = {
str: "string"
}
}
interface MyNamespace<R, V> {
Result: R;
Variables: V;
}
function Gen<R, V>(namespace: MyNamespace<R, V>): void {}
Gen(Test);
(code in playground)
Edit
You can do something similar with the query function you want:
function query<R, V>(namespace: MyNamespace<R, V>, data: { query: any, variables?: V }): Array<R> {
return [];
}
// type of arr is { num: number; }[]
let arr = query(Test, { query: "query", variables: { str: "" } });
(code in playground)
gql-gento generate types. It generates a namespaces per query, and inside it addsResultandVariablestypes. I would like to use those in my generic type which uses bothResultandVariablesand was hoping to doCast<UpvotePostMutation>instead ofCast<UpvotePostMutation.Result, UpvotePostMutation.Variables>. Too bad it's not possible, but thanks for clarifying :).