I’m in a situation where I have many duplicated queries, which simply access different endpoints but use the same variables.
export const MYQUERY = gql`
query MyQuery($var1: String, $var2: Int, $var3: Int) {
myQuery(var1: $var1, var2: $var2, var3: $var3)
}
`;
export const MYQUERYALT = gql`
query MyQueryAlt($var1: String, $var2: Int, $var3: Int) {
myQueryAlt(var1: $var1, var2: $var2, var3: $var3)
}
`;
Is there anyway I can define the input once and pass the individual props to each variable like below?
export const MYQUERY = gql`
input MyQueryInput {
var1: String
var2: Int
var3: Int
}
query MyQuery($input: MyQueryInput) {
myQuery(var1: $input.var1, var2: $input.var2, var3: $input.var3)
}
`;
Or is the only solution to change my endpoint to accommodate for the single object rather than individual parameters? The endpoints are using record types in C#, which if there’s a better way I’d love to know!
public record MyQueryInput(string Var1, int Var2, int Var3);