Name: graphcool-lib
Owner: Prisma
Description: A convenient tool to use in Graphcool functions to make requests against your Graphcool API
Created: 2017-06-23 12:26:58.0
Updated: 2018-05-09 11:56:29.0
Pushed: 2017-10-23 08:43:31.0
Size: 57
Language: TypeScript
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
add graphcool-lib
.api()
rt { fromEvent, default as Graphcool, FunctionEvent } from 'graphcool-lib'
rface User {
: string
rt default async (event: FunctionEvent) => {
nst lib: Graphcool = fromEvent(event)
nst client = lib.api('simple/v1')
nst {allUsers} = await client.request<{allUsers: User[]}>(`{allUsers{id}}`)
turn {
data: {
event: allUsers
}
rt { fromEvent } from 'graphcool-lib'
rt default async event => {
nst lib = fromEvent(event)
nst client = lib.api('simple/v1')
nst {allUsers} = await client.request(`{allUsers{id}}`)
turn {
data: {
event: allUsers
}
.generateNodeToken(nodeId, modelName)
Using .generateNodeToken
you can act on behalf of a User:
rt { fromEvent } from 'graphcool-lib'
rt default async event => {
nst client = fromEvent(event)
nst onbehalfToken = await client.generateAuthToken('cj8a9rex1i5eg0170k116mfme', 'User')
nst api = client.api('simple/v1', {token: onbehalfToken})
nst result = await api.request(`{allUsers{id}}`)
turn {
data: {
message: {
result,
}
}