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

Can't set output name to $return #523

Open
alex88 opened this issue Mar 8, 2021 · 2 comments
Open

Can't set output name to $return #523

alex88 opened this issue Mar 8, 2021 · 2 comments

Comments

@alex88
Copy link

alex88 commented Mar 8, 2021

This is a Bug Report

Description

  • What went wrong?

I'm trying to set the output binding name to $return to use the async function return type, using the code seen in #308 (comment) (because I couldn't find any documentation of the possible values) it throws an error

  • What did you expect should have happened?

It should've changed the out binding name to $return

  • What was the config you used?
  api-xml:
    handler: api.getPost
    events:
      - http: true
        route: api/xml
        x-azure-settings:
          direction: out
          name: $return
  • What stacktrace or error message from your provider did you see?
  Error: Binding not supported
      at Function.<anonymous> (/home/alex/backend/node_modules/serverless-azure-functions/lib/shared/utils.js:113:39)
      at step (/home/alex/backend/node_modules/serverless-azure-functions/lib/shared/utils.js:43:23)
      at Object.next (/home/alex/backend/node_modules/serverless-azure-functions/lib/shared/utils.js:24:53)
      at fulfilled (/home/alex/backend/node_modules/serverless-azure-functions/lib/shared/utils.js:15:58)
      at processTicksAndRejections (internal/process/task_queues.js:93:5)
 
     For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable.z

Additional Data

  • Serverless Framework Version you're using: 2.28.7
  • Serverless Azure Plugin Version you're using: 2.1.0
  • Operating System: Ubuntu

It seems that here https://github.com/serverless/serverless-azure-functions/blob/master/src/shared/bindings.ts#L49 displayName is $httptriggerout_displayname while the closest available options are:

  '$httptrigger_displayname',
  '$httpout_displayname',
@alex88
Copy link
Author

alex88 commented Mar 8, 2021

Trying with:

  api-xml:
    handler: api.getPost
    events:
      - http: true
        route: api/xml
        name: $return

logs

Serverless: Finished building offline service
Serverless: Spawning process 'func host start'

Azure Functions Core Tools
Core Tools Version:       3.0.3331 Commit hash: 0b57b1647c5a385beb8f7d64fa0e534ad4c7555d 
Function Runtime Version: 3.0.15371.0

[2021-03-08T05:06:59.764Z] The 'api-xml' function is in error: $return bindings must specify a direction of 'out'.
[2021-03-08T05:06:59.824Z] Worker process started and initialized.

which seems to set $return also into the in binding, the temp function folder function.json shows

{
  "disabled": false,
  "bindings": [
    {
      "type": "httpTrigger",
      "direction": "in",
      "name": "$return",
      "route": "api/xml",
      "authLevel": "function"
    },
    {
      "type": "http",
      "direction": "out",
      "name": "res"
    }
  ],
  "entryPoint": "getPost",
  "scriptFile": "../api.js"
}

@john-landgrave
Copy link

For anyone else who finds this (possibly related to Apollo server) this comment solves this problem, too. For reference, the solution is:

graphql
  handler: api.graphql
  events:
    - http: true
      methods:
        - GET
        - POST
        - OPTIONS
      authLevel: function
    - http: true
      direction: out
      name: '$return'

@alex88 , if you hadn't figured this out already, there you go.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants