Skip to content

Mutation Type Saftey #403

Open
Open
@lukepolo

Description

@lukepolo

ran into an odd problem that im actively debugging

If i use

 Chain(`${this.config.endpoint}/v1/graphql`, {
      headers: {
        "Content-Type": "application/json",
        "x-hasura-admin-secret": this.config.secret,
      },
    })("mutation", {
      scalars,
    })({
      insert_matches_one: [
        {
            object: {
              bad1: 123,
  
            }
        },
        {
          id: true,
        },
      ],
    });

i get the proper type error

rc/hasura/hasura.service.ts:57:15 - error TS2353: Object literal may only specify known properties, and 'bad1' does not exist in type '{ created_at?: unknown; e_match_status?: { data: { description?: string | Variable<any, string>; matches?: { data: Variable<any, string> | ...[]; on_conflict?: { constraint: matches_constraint | Variable<...>; update_columns: Variable<...> | matches_update_column[]; where?: { ...; } | Variable<...>; } | Variable<......'.

57               bad1: 123,
                 ~~~~

  generated/zeus/index.ts:5997:2
    5997  object: ValueTypes["matches_insert_input"] | Variable<any, string>, /** upsert condition */
          ~~~~~~
    The expected type comes from property 'object' which is declared here on type '{ object: { created_at?: unknown; e_match_status?: { data: { description?: string | Variable<any, string>; matches?: { data: Variable<any, string> | ...[]; on_conflict?: { ...; } | Variable<...>; } | Variable<...>; value?: string | Variable<...>; } | Variable<...>; on_conflict?: { ...; } | Variable<...>; } | Variabl...'

but if i add a single valid item , the error goes away

Chain(`${this.config.endpoint}/v1/graphql`, {
      headers: {
        "Content-Type": "application/json",
        "x-hasura-admin-secret": this.config.secret,
      },
    })("mutation", {
      scalars,
    })({
      insert_matches_one: [
        {
            object: {
              bad1: 123,
              server_id: 123,
            }
        },
        {
          id: true,
        },
      ],
    });
    ```
    
    ```
    [2:43:00 AM] Found 0 errors. Watching for file changes.
    ```


Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions