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

Actions do not support returning scalar types #7805

Closed
samuela opened this issue Nov 12, 2021 · 4 comments
Closed

Actions do not support returning scalar types #7805

samuela opened this issue Nov 12, 2021 · 4 comments
Assignees
Labels
c/actions Related to actions c/server Related to server k/bug Something isn't working

Comments

@samuela
Copy link
Contributor

samuela commented Nov 12, 2021

Version Information

Server Version: v2.0.10
CLI Version (for CLI related issue): n/a

Environment

macOS 11.6

What is the expected behaviour?

Creating an Action like

type Mutation {
  StartCuddlefishSession2(github_access_token: String!): String!
}

to work.

Keywords

Actions, graphql, scalar types, custom types

What is the current behaviour?

I'm getting an error:

{
    "internal": [
        {
            "definition": {
                "definition": {
                    "kind": "synchronous",
                    "output_type": "String!",
                    "arguments": [
                        {
                            "name": "github_access_token",
                            "type": "String!",
                            "description": null
                        }
                    ],
                    "headers": [
                        {
                            "name": "x-api-secret",
                            "value_from_env": "API_SECRET"
                        }
                    ],
                    "handler": "http://{{NEXT_HOST}}:{{NEXT_PORT}}/api/start_cuddlefish_session",
                    "type": "mutation",
                    "timeout": 30,
                    "forward_client_headers": false
                },
                "name": "StartCuddlefishSession2",
                "comment": "Start a new Cuddlefish session provided a GitHub auth token"
            },
            "reason": "Inconsistent object: in action \"StartCuddlefishSession2\"; the type: \"String\" is not an object type defined in custom types",
            "name": "action StartCuddlefishSession2",
            "type": "action"
        }
    ],
    "path": "$.args[1].args",
    "error": "Inconsistent object: in action \"StartCuddlefishSession2\"; the type: \"String\" is not an object type defined in custom types",
    "code": "invalid-configuration"
}

How to reproduce the issue?

  1. Try to create an action with a mutation type, returning a base scalar type like String
  2. Empty out the "New types definition" text box.
  3. Click "Create"

Screenshots or Screencast

Screen Shot 2021-11-11 at 7 34 00 PM

Please provide any traces or logs that could help here.

n/a

Any possible solutions?

Having to create custom types for every action

Can you identify the location in the source code where the problem exists?

n/a

If the bug is confirmed, would you be willing to submit a PR?

yes

@samuela samuela added the k/bug Something isn't working label Nov 12, 2021
@sytabaresa
Copy link

makes sense: if an action can have a null response (see #4405 ), also can respond with a string like "Accepted" or "OK" or another scalar type like a counter number etc.

with the actual version (2.1.0 and 2.1.1) continue the issue

@samuela samuela changed the title Actions do not support return scalar types Actions do not support returning scalar types Dec 29, 2021
@ivelin
Copy link

ivelin commented Jan 19, 2022

Here is a related scenario to consider

https://discord.com/channels/407792526867693568/535727661167673364/933298267737964564

the workaround is to implement a custom action which adds more indirection to the flow. It would be great if Hasura allows simple scalar and json response transform that complements the action request transform functionality.

@rikinsk rikinsk added c/actions Related to actions c/server Related to server labels Jan 20, 2022
@pranshi06 pranshi06 self-assigned this Jan 21, 2022
@sordina
Copy link
Contributor

sordina commented Jan 25, 2022

@0x777 is there any issue with implementing this feature?

@pranshi06
Copy link
Contributor

Closed via 582d781

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c/actions Related to actions c/server Related to server k/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants