remorses / genql

Type safe TypeScript client for any GraphQL API
https://genql.dev
MIT License
881 stars 37 forks source link

Invalid fields are not being caught as type errors #177

Open tastywheat opened 5 months ago

tastywheat commented 5 months ago

Adding an invalid field is not displaying an error indicator. My code:

Screen Shot 2024-06-01 at 5 35 03 PM

Graphql schema

type Query {
    article: Artcle
}
type Article {
    title: String
}
linear[bot] commented 5 months ago

GEN-32 Invalid fields are not being caught as type errors

lukepolo commented 2 months ago

this happens for me if a single valid things exists

 const data = await  createClient().query({
      matches: {
        asldkfasdf: true,
      }
    });
src/hasura/hasura.service.ts:29:9 - error TS2353: Object literal may only specify known properties, and 'asldkfasdf' does not exist in type 'matchesGenqlSelection & { __args?: { distinct_on?: matches_select_column[]; limit?: number; offset?: number; order_by?: matches_order_by[]; where?: matches_bool_exp; }; }'.

29         asldkfasdf: true,
           ~~~~~~~~~~

  generated/schema.ts:18019:5
    18019     matches?: (matchesGenqlSelection & { __args?: {
              ~~~~~~~
    The expected type comes from property 'matches' which is declared here on type 'query_rootGenqlSelection & { __name?: string; }'

but

     const data = await  createClient().query({
      matches: {
        id: true,
        asldkfasdf: true,
      }
    });

wont

image