hasura / hasura/graphql-engine

server: Nullable field omitted from action response when omitted in the webhook response

Open
#9,191 0 comments 0 reactions 0 assignees View on GitHub
k/bug
Dominant language
TypeScript
Stars
32.1k
Forks
3k
PR merge metrics
PR metrics pending

Description

### Version Information

Server Version: v2.15
CLI Version (for CLI related issue):

### Environment

OSS

### What is the current behaviour?

If a nullable field is not included in the response of an action from the webhook then it also doesn't get included in the GraphQL query response.

For example, consider the following action types:

```graphql
type User {
id: ID!
name: Name!
}

type Name {
first_name: String!
middle_name: String
last_name: String!
}

type Query {
get_users: [User]!
}
```

Let's say the following query is made:

```graphql
query {
get_users {
name {
first_name
middle_name
last_name
}
}
}
```

If the action webhook returns the following data,

```json
[
{
"name": {
"first_name": "GenericFirstName",
"last_name": "GenericLastName"
}
}
]
```

The response returned to the GraphQL request is:

```json
{
"data": {
"get_users": [
{
"name": {
"first_name": "GenericFirstName",
"last_name": "GenericLastName"
}
}
]
}
}
```

### What is the expected behaviour?

The response should include the nullable fields in the response with the corresponding value as `null`.

The expected response corresponding to the above example should be,

```json
{
"data": {
"get_users": [
{
"name": {
"first_name": "GenericFirstName",
"middle_name": null,
"last_name": "GenericLastName"
}
}
]
}
}
```

### How to reproduce the issue?

1. Create an action that contains a nullable field.
2. Omit the nullable field from the response of the webhook.
3. Make a GraphQL query that queries the nullable field and notice the nullable field not included in the response.

### Screenshots or Screencast

### Please provide any traces or logs that could help here.

### Any possible solutions/workarounds you're aware of?

### Keywords

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the issue with an action containing a nullable field: omit that field from the webhook response, then query it through GraphQL. Trace how the action webhook payload becomes the GraphQL response and verify that omitted nullable fields are emitted as null. Done means the expected response includes middle_name: null, with regression coverage for this case.

Written by the indexing model from the issue text.

Assessment

Tech stack
graphql
Domain
api, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.