hasura / hasura/graphql-engine

Mutation responses should be required

Open
#9,402 0 comments 5 reactions 0 assignees View on GitHub
k/enhancement t/product-platform
Dominant language
TypeScript
Stars
32.1k
Forks
3k
PR merge metrics
PR metrics pending

Description

### Version Information

Server Version: v2.16.1

### Environment

Cloud and OSS

### What is the current behaviour?

Generated mutations have non-required output types.

For example:
![image](https://user-images.githubusercontent.com/2678610/214887032-0bfdec73-e06c-43ee-bc1a-75253c8fff7e.png)

### What is the expected behaviour?

I would expect instead to have:
```graphql
insert_users(objects: [users_insert_input!]!on_conflict: users_on_conflict): users_mutation_response!
```

Indeed, [the documentation ](https://hasura.io/docs/latest/api-reference/graphql-api/mutation/#insert-upsert-syntax) specifies that mutation responses are required:
![image](https://user-images.githubusercontent.com/2678610/214887514-764bd022-e52d-40ca-8c92-52f22e60d18d.png)

This might not seem important but when doing Typescript codegen, we end up with nullable response types which is a bit annoying.

### How to reproduce the issue?
1. check the Docs explorer of Hasura with any generated mutations

### Keywords

mutation response output types required non-nullable

Contributor guide

Open the contributing guide

Research direction

Start in the Hasura Docs explorer with a generated mutation and compare its output type with the documented insert/upsert syntax. Trace the schema generation path that defines mutation response nullability, then verify that generated mutation responses are non-nullable and that TypeScript codegen no longer produces nullable response types.

Written by the indexing model from the issue text.

Assessment

Tech stack
graphql, typescript
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.