Writing function handler definitions can get very verbose as in the following example:
functions:
hello:
handler:
code:
src: ./src/hello.js
I'm proposing the following shortcuts:
codefunctions:
hello:
handler:
code: ./src/hello.js
functions:
hello:
handler: ./src/hello.js
Before implementing this, we should think through the implications of this for future additions or changes regarding function handlers.
What is the use case for 1) if we implement 2) ?
I would focus on not needing to manually add/edit to the graphcool.yml file, by exposing the proper generator functions from the cli. Then, it doesn't really matter how verbose this file is structured.
I think it is still a nice place to get an overview of your project. Especially if you get into the habit of using modules to break down the functionality into smaller self contained pieces.
I still have nightmares of editing ASP.NET project files by hand :-D
1 word: tooling.
1) is implemented and released.
2) might conflict with future handler types, so that is left out for now.
Just noticed that this shortcut doesn't work when you need to use environment variables:
functions:
sendEmail:
handler:
code:
src: ./src/sendEmail.js
environment:
MAILGUN_API_KEY: ${env:MAILGUN_API_KEY}
MAILGUN_DOMAIN: ${env:MAILGUN_DOMAIN}
@timsuchanek @sorenbs what do you think about that?
ok nevermind, environment needs to be a child of code, I thought pulling it up would work, but that's not needed!
In the same way that code can be abbreviated when there are no environment using:
handler:
code: ./src/hello.js
We could also do something similar for webhooks where we could accept the URL directly as the value for webhook if there are not headers:
handler:
webhook: http://example.org/myFunction
This is already possible @nikolasburk 馃帀
Slightly off topic: The type definition for the YAML file used to be part of the npm package, but it's left out in later versions. This breaks intellisense when editing the YAML, which in turn makes it hard to figure this syntax out.
please create a separate feature request for this