Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mutation Type Saftey #403

Open
lukepolo opened this issue Jul 25, 2024 · 0 comments
Open

Mutation Type Saftey #403

lukepolo opened this issue Jul 25, 2024 · 0 comments

Comments

@lukepolo
Copy link

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.
    ```


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant