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

Hasura action return type defined as string, but returning an object #10206

Open
nizamani opened this issue Apr 16, 2024 · 0 comments
Open

Hasura action return type defined as string, but returning an object #10206

nizamani opened this issue Apr 16, 2024 · 0 comments
Labels
k/bug Something isn't working

Comments

@nizamani
Copy link

Version Information

Server Version:
v2.35.1

Environment

Hasura console, working on docker container

What is the current behaviour?

We have defined a Hasura action return type like this:

type MyReturnData {
  id: String!
  result: String!
}

As you can see that result is defined as a type String! but in our backend code which is in nestjs, we are returning result as an object. Hasura action instead of complaining of type mismatch or failing, it is return us result as an object. Even though we have clearly defined result as a string.
To clearify, what we receive back from Hasura is this:

{
    "data": {
        "my_action": {
            "mydata": {
                "id": "WzEsICJtYWluIiwgImFwcHRfZ3JvdXBfbGF5b3V0IiwgNzdd",
                "result": {
                    "d1": 2,
                    "d2": {
                        "d32": [],
                        "d4": [
                            {
                                "records": [],
                                "uuid": "4b862a88-aa4b-4c25-afe8-7067348fd30c"
                            },
                            {
                                "records": [],
                                "uuid": "ecbff9e3-02fc-4318-a761-b5ffdbfbf994"
                            }
                        ]
                    }
                }
            }
        }
    }
}

Instead of this:

{
    "data": {
        "my_action": {
            "mydata": {
                "id": "WzEsICJtYWluIiwgImFwcHRfZ3JvdXBfbGF5b3V0IiwgNzdd",
                "result": "{\"d1\":2,\"d2\":{\"d32\":[],\"d4\":[{\"records\":[],\"uuid\":\"4b862a88-aa4b-4c25-afe8-7067348fd30c\"},{\"records\":[],\"uuid\":\"ecbff9e3-02fc-4318-a761-b5ffdbfbf994\"}]}}"
            }
        }
    }
}

What is the expected behaviour?

In this case expected behavior would be one of the following things:

  • Either Hasura action don't return result node at all
  • Or hasura action returns result node as a stringify object

How to reproduce the issue?

  1. create a Hasura action that have a return type with a variable as a string
  2. from backend code preferably javascript backend, return result to Hasura as an object for variable which is defined as a string in Hasura action
  3. You will notice that Hasura action return type variable which was defined as a string is returning object as it received from backend

Any possible solutions/workarounds you're aware of?

We would like to know that is this expected behavior or this is just a bug. Because if this is a bug and we implement our code based on assumption that this is expected behavior. Then in future when this bug is fixed our entire codebase will break. If this is expected behavior then even though this is not right but this will work in our use-case so we may decide to go with this solution.

Keywords

Hasura action

@nizamani nizamani added the k/bug Something isn't working label Apr 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
k/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant