You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First, thank you so much for this wonderful project! It's extremely impressive and I've been very happy with it overall.
I did run into one small issue for a query with no variables, e.g.
constQUERY=gql` query Users { users { id name } }`
For this query, the generated type of the UsersVariables would be:
exporttypeUsersVariables={};
Unfortunately, TypeScript is a bit overly permissive with the {} literal value and will allow any object to be assigned:
typeUsersVariables={}// The following is incorrect as the query takes no variables,// but the typing allows itconstvariables: UsersVariables={name: 'hello'}// Using a more restrictive type, we can prevent this:typeUsersVariablesNever={[index: string]: never};// This line will now properly highlight the `name` value// as an error since the query doesn't accept any variablesconstneverVariables: UsersVariablesNever={name: 'hello'}
That is certainly an option and would fix the correctness issue. In my case I was hoping to rely on the graphql query as the source of truth and then be able to use the generated types to constrain my system. My hope was to be able to always wire up the variables and have them correctly give me feedback.
First, thank you so much for this wonderful project! It's extremely impressive and I've been very happy with it overall.
I did run into one small issue for a query with no variables, e.g.
For this query, the generated type of the
UsersVariables
would be:Unfortunately, TypeScript is a bit overly permissive with the
{}
literal value and will allow any object to be assigned:TypeScript playground with this example
My suggestion would be to use the more restrictive
{ [index: string]: never }
instead of{}
for empty variable type definitions.The text was updated successfully, but these errors were encountered: