All Projects → graphql-editor → stucco-js

graphql-editor / stucco-js

Licence: MIT License
GraphQL server. JavaScript runtime for stucco - GraphQL as a Service

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to stucco-js

instl
💻 A crossplatform installer for GitHub projects that just works!
Stars: ✭ 45 (+104.55%)
Mutual labels:  service
qqmusic
qqmusic,简洁版qq音乐
Stars: ✭ 38 (+72.73%)
Mutual labels:  service
deckmaster
An application to control your Elgato Stream Deck on Linux
Stars: ✭ 106 (+381.82%)
Mutual labels:  service
android-textoverlay
Provides a simple service that allows to display arbitrary text as a system-window overlay.
Stars: ✭ 20 (-9.09%)
Mutual labels:  service
mnemosyne
Session management service with RPC API based on protobuf.
Stars: ✭ 15 (-31.82%)
Mutual labels:  service
server-action-service
Generic and reusable Lightning service component that calls server-side actions
Stars: ✭ 19 (-13.64%)
Mutual labels:  service
Driver.NET
Lightweight and flexible library to load and communicate with kernel drivers on Windows.
Stars: ✭ 59 (+168.18%)
Mutual labels:  service
Cronical
.NET-based cron daemon. Can replace Windows Services and Scheduled Tasks, typically for running service-like processes as part of an application suite - or just by itself.
Stars: ✭ 42 (+90.91%)
Mutual labels:  service
BaseIotUtils
🔥🔥串口工具,屏幕适配,通知工具类,多文件断点下载,xls,xlsx操作,文件处理,crash控制,音视频播放,usb设备检测,adb工具等...
Stars: ✭ 44 (+100%)
Mutual labels:  service
cyborg
Acceleration Management. Mirror of code maintained at opendev.org.
Stars: ✭ 47 (+113.64%)
Mutual labels:  service
httpbun
A simple HTTP server with responses tuned to be useful in testing HTTP clients. Heavily inspired by httpbin, but doesn't intend to be a perfect clone.
Stars: ✭ 14 (-36.36%)
Mutual labels:  service
Vutils
Vutils or Vic Utilities is an utility library written in Modern C++ and for Modern C++. It helps your programming go easier, faster, and simpler.
Stars: ✭ 16 (-27.27%)
Mutual labels:  service
comrade-dev
Comrade is a job scheduler&manager service.
Stars: ✭ 69 (+213.64%)
Mutual labels:  service
hls-live-thumbnails
A service which will generate thumbnails from a live HLS stream.
Stars: ✭ 49 (+122.73%)
Mutual labels:  service
Learn-ServiceMesh-Workshop
Labs for Kubecon NA Workshop on Service Mesh with Cloud PKS
Stars: ✭ 13 (-40.91%)
Mutual labels:  service
SSTMCSPGAAS
Stupidly Simple Tiny Minimal Coming Soon Page Generator As A Service
Stars: ✭ 23 (+4.55%)
Mutual labels:  service
netlicensing.io
Labs64 NetLicensing - Innovative License Management Solution
Stars: ✭ 13 (-40.91%)
Mutual labels:  service
prometheus-hetzner-sd
Prometheus Service Discovery for Hetzner
Stars: ✭ 15 (-31.82%)
Mutual labels:  service
mangium
(Needs contributors) Service/project manager for developers/small teams
Stars: ✭ 12 (-45.45%)
Mutual labels:  service
yurpc
high-performance RPC framework.
Stars: ✭ 59 (+168.18%)
Mutual labels:  service

Javascript runtime for Stucco

Build

About

Stucco-js is JavaScript/TypeScript runtime for Stucco. It can be used as a local development environment or as a base library for implementing FaaS runtime.

Configuration file

Stucco-js relies on Stucco library written in GoLang. Configuration file format is in JSON.

Resolvers

{
    "resolvers":{
        "RESOLVER_TYPE.RESOLVER_FIELD":{
            "resolve":{
                "name": "PATH_TO_RESOLVER"
            }
        }
    }
}

Custom Scalars

{
    "scalars":{
        "CUSTOM_SCALAR_NAME":{
            "parse":{
                "name": "PATH_TO_RESOLVER"
            },
            "serialize":{
                "name": "PATH_TO_RESOLVER"
            }
        }
    }
}

Handler

You can also return Promise from handler

Default export

module.exports = (input) => {
    return  "Hello world"
}

Handler export

module.exports.handler = (input) => {
    return "Hello world"
}

Named export

module.exports.someName = (input) => {
    return "Hello world"
}
{
    "resolvers":{
        "RESOLVER_TYPE.RESOLVER_FIELD":{
            "resolve":{
                "name": "PATH_TO_RESOLVER.someName"
            }
        }
    }
}

Passing arguments to another resolver

Resolver "Query.todoOperations"

type TodoOperations{
    getCreditCardNumber(id: String!): String
    showMeTehMoney: Int
}

type Query{
    todoOps: TodoOperations
}
{
    "resolvers":{
        "Query.todoOps":{
            "resolve":{
                "name": "lib/todoOps"
            }
        },
        "TopoOps.getCreditCardNumber":{
            "resolve":{
                "name": "lib/getCreditCardNumber"
            }
        }
    }
}

lib/todoOps.js

module.exports = (input) => {
    return {
        response:{
            creditCards:{
                dupa: "1234-1234-1234-1234",
                ddd: "1222-3332-3323-1233"
            }
        }
    }
}

lib/getCreditCardNumber.js

module.exports = (input) => {
    const { id } = input.arguments
    return {
        response: input.source.creditCards[id]
    }
}

Example

Basic

schema.graphql

type Query{
    hello: String
}
schema{
    query: Query
}

stucco.json

{
    "resolvers":{
        "Query.hello":{
            "resolve":{
                "name": "lib/hello"
            }
        }
    }
}

lib/hello.js

export function handler(input){
    return "Hello world"
}

Test query

{
    hello
}
{
    "hello": "Hello world"
}

This JSON defines resolver

Using TypeScript

So if you have your TypeScript files in src folder you should transpile them to the lib folder and stucco can run it from there.

Local development

To start local development you need stucco.json, schema.graphql, file with resolvers in the root folder and inside root folder. To fetch your schema from URL you can use tool like graphql-zeus

Add this script to your package json to test your backend

{
    "scripts":{
        "start": "stucco"
    }
}

Or run with npx

npx stucco
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].