{"id":19011610,"url":"https://github.com/graphql-editor/stucco-js","last_synced_at":"2025-04-22T23:27:23.722Z","repository":{"id":40731259,"uuid":"224838773","full_name":"graphql-editor/stucco-js","owner":"graphql-editor","description":"GraphQL server. JavaScript runtime for stucco - GraphQL backend","archived":false,"fork":false,"pushed_at":"2024-01-16T08:39:01.000Z","size":1738,"stargazers_count":26,"open_issues_count":2,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-17T16:03:18.105Z","etag":null,"topics":["backend","graphql","server"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/graphql-editor.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2019-11-29T11:12:21.000Z","updated_at":"2024-05-08T14:01:34.000Z","dependencies_parsed_at":"2024-01-16T10:20:02.292Z","dependency_job_id":"44046fa2-03e7-4f82-a31a-4beec59602a3","html_url":"https://github.com/graphql-editor/stucco-js","commit_stats":null,"previous_names":[],"tags_count":61,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graphql-editor%2Fstucco-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graphql-editor%2Fstucco-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graphql-editor%2Fstucco-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/graphql-editor%2Fstucco-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/graphql-editor","download_url":"https://codeload.github.com/graphql-editor/stucco-js/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250339391,"owners_count":21414353,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["backend","graphql","server"],"created_at":"2024-11-08T19:14:59.395Z","updated_at":"2025-04-22T23:27:23.696Z","avatar_url":"https://github.com/graphql-editor.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"![image](https://user-images.githubusercontent.com/779748/217842393-67c3d172-8039-490d-b315-e208a68f89ae.png)\n\n# Javascript runtime for Stucco\n![Build](https://github.com/graphql-editor/stucco-js/workflows/build/badge.svg)\n\n- [Javascript runtime for Stucco](#javascript-runtime-for-stucco)\n- [About](#about)\n  - [Configuration file](#configuration-file)\n    - [Resolvers](#resolvers)\n    - [Custom Scalars](#custom-scalars)\n  - [Handler](#handler)\n    - [Default export](#default-export)\n    - [Handler export](#handler-export)\n    - [Named export](#named-export)\n    - [Passing arguments to another resolver](#passing-arguments-to-another-resolver)\n      - [Resolver \"Query.todoOperations\"](#resolver-%22querytodooperations%22)\n  - [Example](#example)\n      - [Basic](#basic)\n      - [Using TypeScript](#using-typescript)\n  - [Local development](#local-development)\n\n# About\n\nStucco-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.\n\n## Configuration file\n\n`Stucco-js` relies on [Stucco](https://github.com/graphql-editor/stucco) library written in GoLang. Configuration file format is in JSON.\n\n### Resolvers\n\n```json\n{\n    \"resolvers\":{\n        \"RESOLVER_TYPE.RESOLVER_FIELD\":{\n            \"resolve\":{\n                \"name\": \"PATH_TO_RESOLVER\"\n            }\n        }\n    }\n}\n```\n\n### Custom Scalars\n\n```json\n{\n    \"scalars\":{\n        \"CUSTOM_SCALAR_NAME\":{\n            \"parse\":{\n                \"name\": \"PATH_TO_RESOLVER\"\n            },\n            \"serialize\":{\n                \"name\": \"PATH_TO_RESOLVER\"\n            }\n        }\n    }\n}\n```\n\n## Handler\n\nYou can also return Promise from handler\n\n### Default export\n\n```js\nmodule.exports = (input) =\u003e {\n    return  \"Hello world\"\n}\n```\n\n### Handler export\n\n```js\nmodule.exports.handler = (input) =\u003e {\n    return \"Hello world\"\n}\n```\n\n### Named export\n\n```js\nmodule.exports.someName = (input) =\u003e {\n    return \"Hello world\"\n}\n```\n\n```json\n{\n    \"resolvers\":{\n        \"RESOLVER_TYPE.RESOLVER_FIELD\":{\n            \"resolve\":{\n                \"name\": \"PATH_TO_RESOLVER.someName\"\n            }\n        }\n    }\n}\n```\n\n### Passing arguments to another resolver\n\n#### Resolver \"Query.todoOperations\"\n\n```graphql\ntype TodoOperations{\n    getCreditCardNumber(id: String!): String\n    showMeTehMoney: Int\n}\n\ntype Query{\n    todoOps: TodoOperations\n}\n```\n\n```json\n{\n    \"resolvers\":{\n        \"Query.todoOps\":{\n            \"resolve\":{\n                \"name\": \"lib/todoOps\"\n            }\n        },\n        \"TopoOps.getCreditCardNumber\":{\n            \"resolve\":{\n                \"name\": \"lib/getCreditCardNumber\"\n            }\n        }\n    }\n}\n```\n\n`lib/todoOps.js`\n```js\nmodule.exports = (input) =\u003e {\n    return {\n        response:{\n            creditCards:{\n                dupa: \"1234-1234-1234-1234\",\n                ddd: \"1222-3332-3323-1233\"\n            }\n        }\n    }\n}\n```\n\n`lib/getCreditCardNumber.js`\n```js\nmodule.exports = (input) =\u003e {\n    const { id } = input.arguments\n    return {\n        response: input.source.creditCards[id]\n    }\n}\n```\n\n## Example\n\n#### Basic\n\n`schema.graphql`\n```graphql\ntype Query{\n    hello: String\n}\nschema{\n    query: Query\n}\n```\n\n`stucco.json`\n```json\n{\n    \"resolvers\":{\n        \"Query.hello\":{\n            \"resolve\":{\n                \"name\": \"lib/hello\"\n            }\n        }\n    }\n}\n```\n\n`lib/hello.js`\n```js\nexport function handler(input){\n    return \"Hello world\"\n}\n```\n\n`Test query`\n```gql\n{\n    hello\n}\n```\n```json\n{\n    \"hello\": \"Hello world\"\n}\n```\n\nThis JSON defines resolver\n\n#### Using TypeScript\n\nSo if you have your TypeScript  files in src folder you should transpile them to the lib folder and stucco can run it from there.\n\n## Local development\n\nTo 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](https://github.com/graphql-editor/graphql-zeus) \n\nAdd this script to your package json to test your backend\n```json\n{\n    \"scripts\":{\n        \"start\": \"stucco\"\n    }\n}\n```\n\nOr run with npx \n```sh\nnpx stucco\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgraphql-editor%2Fstucco-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgraphql-editor%2Fstucco-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgraphql-editor%2Fstucco-js/lists"}