{"id":15313351,"url":"https://github.com/johanatan/speako","last_synced_at":"2025-08-18T20:36:11.599Z","repository":{"id":57367126,"uuid":"73659094","full_name":"johanatan/speako","owner":"johanatan","description":"A compiler for GraphQL schema language (written in ClojureScript)","archived":false,"fork":false,"pushed_at":"2017-04-01T18:04:54.000Z","size":87,"stargazers_count":10,"open_issues_count":1,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-25T21:36:28.227Z","etag":null,"topics":["clojurescript","graphql","graphql-schema-language","nodejs"],"latest_commit_sha":null,"homepage":null,"language":"Clojure","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/johanatan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-11-14T02:26:45.000Z","updated_at":"2024-07-07T23:16:31.000Z","dependencies_parsed_at":"2022-08-23T20:11:05.544Z","dependency_job_id":null,"html_url":"https://github.com/johanatan/speako","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johanatan%2Fspeako","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johanatan%2Fspeako/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johanatan%2Fspeako/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johanatan%2Fspeako/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/johanatan","download_url":"https://codeload.github.com/johanatan/speako/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250482536,"owners_count":21437892,"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":["clojurescript","graphql","graphql-schema-language","nodejs"],"created_at":"2024-10-01T08:41:26.486Z","updated_at":"2025-04-23T17:41:34.564Z","avatar_url":"https://github.com/johanatan.png","language":"Clojure","funding_links":[],"categories":["Libraries","graphql"],"sub_categories":["ClojureScript Libraries"],"readme":"# speako\n\n### A simpler interface to GraphQL\n\n#### Install\n\n* NPM - `npm install speako`\n\n#### Motivation\n\nGraphQL normally requires a `GraphQLSchema` object passed along with each query\nyou give it to validate, interpret \u0026 execute. Typically this schema is constructed\nby hand-crafting some verbose \u0026 noisy JavaScript.\n\nSee: [starWarsSchema.js](https://github.com/graphql/graphql-js/blob/master/src/__tests__/starWarsSchema.js).\n\nThe equivalent schema in GraphQL Schema Language is much more concise:\n```\nenum Episode { NEWHOPE, EMPIRE, JEDI }\n\ntype Human {\n  id: ID!\n  name: String\n  friends: [Character]\n  appearsIn: [Episode]\n  homePlanet: String\n}\n\ntype Droid {\n  id: ID!\n  name: String\n  friends: [Character]\n  appearsIn: [Episode]\n  primaryFunction: String\n}\n\nunion Character = Human | Droid\n```\n\nGiven a specification of a data model in GraphQL Schema Language, speako automatically\ngenerates the `GraphQLSchema` instance that GraphQL requires and binds its `resolve` methods\nto a specified set of functions for querying (i.e., selecting) and mutating (i.e., insert,\nupdate and delete mutations).\n\n#### Example\n\n```javascript\n$ node --harmony-destructuring\n\u003e var speako = require('speako');\n\u003e var gql = require('graphql');\n\u003e var _ = require('lodash');\n\u003e var labels = [\n... {'id': 1, 'name': 'Apple Records', 'founded': '1968'},\n... {'id': 2, 'name': 'Harvest Records', 'founded': '1969'}];\n\u003e var albums = [\n... {'id': 1, 'name': 'Dark Side Of The Moon', 'releaseDate': 'March 1, 1973',\n...  'artist': 'Pink Floyd', 'label': labels[1]},\n... {'id': 2, 'name': 'The Beatles', 'releaseDate': 'November 22, 1968',\n...  'artist': 'The Beatles', 'label': labels[0]},\n... {'id': 3, 'name': 'The Wall', 'releaseDate': 'August 1, 1982',\n...  'artist': 'Pink Floyd', 'label': labels[1]}];\n\u003e var dataResolver = {\"query\":  function (typename, predicate) {\n...   console.assert(typename == \"Album\");\n...   var parsed = JSON.parse(predicate);\n...   if (_.isEqual(parsed, {\"all\": true})) return albums;\n...   else {\n...     var pairs = _.toPairs(parsed);\n...     var filters = pairs.map(function (p) {\n...       var [field, value] = p;\n...       if (typeof value === \"object\") {\n...         console.assert(field == \"label\");\n...         return function(elem) {\n...           var innerKey = _.first(_.keys(value));\n...           return elem[field][innerKey] == value[innerKey]; };\n...       }\n...       return function(elem) { return elem[field] == value; };\n...     });\n...     return albums.filter(function(elem) { return filters.every(function(f) { return f(elem); }); });\n...   }\n... }, \"create\": function (typename, inputs) {\n...   inputs.id = albums.length + 1;\n...   albums.push(inputs);\n...   return inputs;\n... }};\n\u003e var schema = speako.getSchema(dataResolver,\n... \"type Album { id: ID! name: String releaseDate: String artist: String }\");\n\u003e var schema =\n... speako.getSchema(dataResolver,\n...               [\"type Label { id: ID! name: String founded: String album: Album } \",\n...                \"type Album { id: ID! name: String releaseDate: String artist: String label: Label }\"].join(\" \"));\n\u003e var printer = function(res) { console.log(JSON.stringify(res, null, 2)); };\n\u003e gql.graphql(schema,\n...  \"{ Album(artist: \\\"Pink Floyd\\\", label: { name: \\\"Harvest Records\\\" }) { name artist releaseDate } }\") .then(printer);\n\n{\n  \"data\": {\n    \"Album\": [\n      {\n        \"name\": \"Dark Side Of The Moon\",\n        \"artist\": \"Pink Floyd\",\n        \"releaseDate\": \"March 1, 1973\"\n      },\n      {\n        \"name\": \"The Wall\",\n        \"artist\": \"Pink Floyd\",\n        \"releaseDate\": \"August 1, 1982\"\n      }\n    ]\n  }\n}\n\n\u003e gql.graphql(schema, \"{ Album(artist: \\\"Pink Floyd\\\") { name artist releaseDate } }\").then(printer);\n\n{\n  \"data\": {\n    \"Album\": [\n      {\n        \"name\": \"Dark Side Of The Moon\",\n        \"artist\": \"Pink Floyd\",\n        \"releaseDate\": \"March 1, 1973\"\n      },\n      {\n        \"name\": \"The Wall\",\n        \"artist\": \"Pink Floyd\",\n        \"releaseDate\": \"August 1, 1982\"\n      }\n    ]\n  }\n}\n\n\u003e gql.graphql(schema, \"{ Album(artist: \\\"Pink Floyd\\\", name: \\\"The Wall\\\") { name artist releaseDate } }\").then(printer);\n\n{\n  \"data\": {\n    \"Album\": [\n      {\n        \"name\": \"The Wall\",\n        \"artist\": \"Pink Floyd\",\n        \"releaseDate\": \"August 1, 1982\"\n      }\n    ]\n  }\n}\n\n\u003e gql.graphql(schema, \"{ Album(id: 2) { name artist releaseDate } }\").then(printer);\n\n{\n  \"data\": {\n    \"Album\": [\n      {\n        \"name\": \"The Beatles\",\n        \"artist\": \"The Beatles\",\n        \"releaseDate\": \"November 22, 1968\"\n      }\n    ]\n  }\n}\n\n\u003e gql.graphql(schema, \"{ Albums { name artist releaseDate } }\").then(printer);\n\n{\n  \"data\": {\n    \"Albums\": [\n      {\n        \"name\": \"Dark Side Of The Moon\",\n        \"artist\": \"Pink Floyd\",\n        \"releaseDate\": \"March 1, 1973\"\n      },\n      {\n        \"name\": \"The Beatles\",\n        \"artist\": \"The Beatles\",\n        \"releaseDate\": \"November 22, 1968\"\n      },\n      {\n        \"name\": \"The Wall\",\n        \"artist\": \"Pink Floyd\",\n        \"releaseDate\": \"Auguest 1, 1982\"\n      }\n    ]\n  }\n}\n\n\u003e gql.graphql(schema, \"mutation m { createAlbum(name:\\\"The Division Bell\\\", releaseDate: \\\"March 28, 1994\\\", artist:\\\"Pink Floyd\\\") { id name } }\").then(printer);\n\n{\n  \"data\": {\n    \"createAlbum\": {\n      \"id\": \"4\",\n      \"name\": \"The Division Bell\"\n    }\n  }\n}\n\n```\n\nCopyright (c) 2015 Jonathan L. Leonard\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohanatan%2Fspeako","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjohanatan%2Fspeako","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohanatan%2Fspeako/lists"}