rootToken injected in function context should be configurable #289
Description
Issue by sorenbs
Wednesday Oct 18, 2017 at 08:52 GMT
Originally opened as https://github.com/graphcool/prisma/issues/879
All functions get a rootToken injected int the context::
{
graphcool: {
rootToken
}
}
By default, rootToken
contains a Temporary Root Token
that is valid for 5 minutes.
See prisma/prisma1#740 for token terminology
For a given function it should be possible to configure a named Root Token
to be injected instead of a Temporary Root Token
. It should also be possible to not inject a Root Token
at all:
Inject named Root Token
This configuration injects the Root Token
with the name authenticate
:
functions:
authenticteCustomer:
handler:
code:
src: ./code/authenticate.js
context:
rootToken: authenticate
type: schemaExtension
schema: ./code/authenticate.graphql
rootTokens:
- authenticate
Note: In the future it will be possible to control the scope of a Root Token. This feature will make it more relevant to use a named Root Token
No Root Token
This configuration disables Root Token injection:
functions:
authenticteCustomer:
handler:
code:
src: ./code/authenticate.js
context:
rootToken: null
type: schemaExtension
schema: ./code/authenticate.graphql
rootTokens:
- authenticate
When no Root Token is injected, the rootToken
field will be omitted from the context.
Note: In the future we might make it possible to configure the default behaviour for root token injection.