{"id":13628049,"url":"https://github.com/benthepoet/mithril-graphql","last_synced_at":"2025-08-13T18:41:50.812Z","repository":{"id":48467569,"uuid":"92568554","full_name":"benthepoet/mithril-graphql","owner":"benthepoet","description":"A lightweight GraphQL client for the Mithril framework.","archived":false,"fork":false,"pushed_at":"2021-07-24T13:21:20.000Z","size":8,"stargazers_count":13,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-11T20:08:27.234Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"CoffeeScript","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/benthepoet.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}},"created_at":"2017-05-27T03:41:56.000Z","updated_at":"2023-06-15T20:52:01.000Z","dependencies_parsed_at":"2022-08-28T01:14:18.485Z","dependency_job_id":null,"html_url":"https://github.com/benthepoet/mithril-graphql","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benthepoet%2Fmithril-graphql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benthepoet%2Fmithril-graphql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benthepoet%2Fmithril-graphql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benthepoet%2Fmithril-graphql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/benthepoet","download_url":"https://codeload.github.com/benthepoet/mithril-graphql/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223150775,"owners_count":17095959,"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":[],"created_at":"2024-08-01T22:00:43.770Z","updated_at":"2024-11-05T10:08:16.151Z","avatar_url":"https://github.com/benthepoet.png","language":"CoffeeScript","funding_links":[],"categories":["Uncategorized"],"sub_categories":["Uncategorized"],"readme":"# mithril-graphql\nA lightweight GraphQL client for the Mithril framework.\n\n## Usage\nThis module is best utilized with Babel (ES2015+) or CoffeeScript as they both support multiline strings.\n\n### ES5\n```\nvar GraphClient = require('mithril-graphql');\n\nvar options = {\n    url: '/graphql'\n};\n\nvar query = 'query User($id: Int!) { user(id: $id) { id name } }';\n\nvar client = new GraphClient(options, queries);\n\nclient\n    .get(query, { id: 1 })\n    .then(function (response) {\n        console.log(reponse.data);\n    });\n```\n\n### Babel (ES2015+)\n```\nconst GraphClient = require('mithril-graphql');\n\nconst options = {\n    url: '/graphql'\n};\n\nconst query = `\n    query User($id: Int!) { \n        user(id: $id) { \n            id \n            name \n        }\n    }\n';\n\nconst client = new GraphClient(options, queries);\n\nclient\n    .get(query, { id: 1 })\n    .then(response =\u003e {\n        console.log(reponse.data);\n    });\n```\n\n### CoffeeScript\n```\nGraphClient = require('mithril-graphql')\n\noptions = {\n    url: '/graphql'\n}\n\nquery = \"\"\"\n    query User($id: Int!) { \n        user(id: $id) { \n            id \n            name \n        }\n    }\n\"\"\"\n\nclient = new GraphClient(options, queries)\n\nclient\n    .get(query, { id: 1 })\n    .then(response -\u003e\n        console.log(reponse.data)\n    )\n```\n\n## Additional notes\nFor optimal use, it is recommended that GraphQL queries utilize variables opposed to string interpolation. Before the client sends \nthe request it will try to minify the query. Minification will strip out any carriage returns that are followed immediately by tabs or spaces.\n\n### Good\n\n#### queries.js\n```\nconst queries = {\n    User: `\n        query User($id: Int!) { \n            user(id: $id) { \n                id \n                name \n            }\n        }\n    `\n};\n```\n\n#### graph.js\n```\nconst GraphClient = require('mithril-graphql');\nconst queries = require('./queries');\n\nconst options = {\n    url: '/graphql'\n};\n\nconst client = new GraphClient(options);\n\nclient\n    .get(queries.User, { id: 1 })\n    .then((response) =\u003e {\n        console.log(response.data);\n    });\n```\n\n### Bad\n\n#### graph.js\n```\nconst GraphClient = require('mithril-graphql');\n\nconst options = {\n    url: '/graphql'\n};\n\nconst id = 1;\n\nconst query = `\n    query { \n        user(id: ${id}) { \n            id \n            name \n        }\n    }\n';\n\nconst client = new GraphClient(options, queries);\n\nclient\n    .get(query)\n    .then(response =\u003e {\n        console.log(reponse.data);\n    });\n```\n\n## GraphClient\n\n### constructor(options)\nCreates a new GraphClient.\n\n### get(query, [variables])\nSends a GraphQL query using the HTTP GET method.\n\n### post(query, [variables])\nSends a GraphQL query using the HTTP POST method.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenthepoet%2Fmithril-graphql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbenthepoet%2Fmithril-graphql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenthepoet%2Fmithril-graphql/lists"}