prismagraphql/graphcool-lib

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

Homepage:

Size: 57

Language: TypeScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

graphcool-lib

Install
 add graphcool-lib
Usage
.api()
Typescript
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
}


Javascript
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,
  }
}



This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.