hasura / graphql-engine

Blazing fast, instant realtime GraphQL APIs on your DB with fine grained access control, also trigger webhooks on database events.

Home Page:https://hasura.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unexpected empty update_many mutation response

namoscato opened this issue · comments

Version Information

Server Version: v2.35.1

Environment

OSS and EE

What is the current behaviour?

The update_<table>_many mutation response returns an object when the updates argument is an empty array

What is the expected behaviour?

It should always return an array as described by the GraphQL schema for consistency, i.e.

{
  "data": {
    "update_users_many": [
      {
        "affected_rows": 0
      }
    ]
  }
}

How to reproduce the issue?

  1. Invoke an update_<table>_many mutation, passing an empty array argument:

    mutation {
      update_users_many(updates:[]) {
        affected_rows
      }
    }
  2. See that it unexpectedly returns an object:

    {
      "data": {
        "update_users_many": {
          "affected_rows": 0
        }
      }
    }

Any possible solutions/workarounds you're aware of?

The current state requires awkward conditional logic in GraphQL client implementations

Keywords

multiple updates, mutation, update_many