{"id":13726884,"url":"https://github.com/GetStream/TinyGraphQL","last_synced_at":"2025-05-07T22:30:34.975Z","repository":{"id":56924291,"uuid":"326832176","full_name":"GetStream/TinyGraphQL","owner":"GetStream","description":"🌸 Simple and lightweight GraphQL query builder for the Swift language - Made with 💘 by @GetStream","archived":false,"fork":false,"pushed_at":"2021-04-12T18:06:23.000Z","size":82,"stargazers_count":75,"open_issues_count":0,"forks_count":1,"subscribers_count":5,"default_branch":"main","last_synced_at":"2024-05-12T01:32:13.573Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Swift","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/GetStream.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":"2021-01-04T23:25:13.000Z","updated_at":"2023-10-02T07:24:22.000Z","dependencies_parsed_at":"2022-08-21T05:20:49.156Z","dependency_job_id":null,"html_url":"https://github.com/GetStream/TinyGraphQL","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GetStream%2FTinyGraphQL","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GetStream%2FTinyGraphQL/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GetStream%2FTinyGraphQL/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GetStream%2FTinyGraphQL/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GetStream","download_url":"https://codeload.github.com/GetStream/TinyGraphQL/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252965087,"owners_count":21832819,"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-03T01:03:29.837Z","updated_at":"2025-05-07T22:30:34.674Z","avatar_url":"https://github.com/GetStream.png","language":"Swift","funding_links":[],"categories":["Swift"],"sub_categories":[],"readme":"\u003cimg align=\"center\" src=\"https://i.imgur.com/RvHoYJO.jpg\" width=\"100%\" /\u003e\n\n[![Swift][swift-badge]][swift-url]\n[![CI Status][ci-badge]][ci-url]\n[![Cocoapods][cocoapods-badge]][cocoapods-url]\n![Cocoapods platforms](https://img.shields.io/cocoapods/p/Streamoji)\n![SPM \u0026 Carthage compatible][spm-carthage-badge]\n[![License][license-badge]][license-url]\n[![Twitter Follow][follow-badge]][follow-url]\n[![Twitter][tweet-badge]][tweet-url]\n\nTinyGraphQL is a simple and lightweight query builder for the Swift language with zero dependencies. It provides a syntax close to that of GraphQL while preventing you from making time-consuming syntax mistakes.\n\nMade with 💘 by the folks @ [Stream](https://getstream.io).\n\n\u003cimg align=\"right\" src=\"https://i.imgur.com/lZLvgFa.png\" width=\"60%\" /\u003e\n\n## Table of Contents\n\n- [Snippets](#snippets)\n  * [Initialization](#initialization)\n  * [Query](#query)\n    + [Raw GraphQL](#raw-graphql)\n    + [TinyGraphQL](#tinygraphql)\n  * [Mutation](#mutation)\n    + [Raw GraphQL](#raw-graphql-1)\n    + [TinyGraphQL](#tinygraphql-1)\n  * [Request](#request)\n    + [Raw GraphQL + URLSession](#raw-graphql---urlsession)\n    + [TinyGraphQL + URLSession](#tinygraphql---urlsession)\n- [Installation](#installation)\n  * [SPM](#spm)\n  * [CocoaPods](#cocoapods)\n  * [Carthage](#carthage)\n- [Adopters](#adopters)\n\n## Snippets\n\n### Initialization\n\nTinyGraphQL is also a container for pre-configuring your requests. In the initialization step, you should specify the URL for the GraphQL endpoint and any HTTP headers you'd need for the requests.\n\n```swift\nlet graphQL = TinyGraphQL(\n    url: URL(string: \"https://api.my.app/graphql\")!,\n    headers: [\"Content-Type\": \"application/json\", \"combase-organization\": \"5fd7ecb251b33b10c380977b\"]\n)\n```\n\n### Query\n\nSee below a comparison between a regular GraphQL query and how to generate a similar query using TinyGraphQL. Note that it's possible to have multiple levels of fields like in regular GraphQL.\n\n#### Raw GraphQL\n\n```graphql\nquery {\n    organizationById(_id: \"(id)\") {\n        name\n        stream {\n            key\n        }\n        agentCount\n    }\n}\n```\n\n#### TinyGraphQL\n\n```swift\nQuery(\"organizationById\", [\"_id\": id]) {\n    \"name\"\n    Field(\"stream\") {\n        \"key\"\n    }\n    \"agentCount\"\n}\n```\n\n### Mutation\n\nMutations work pretty much the same as queries, except behind the scenes where it becomes a `POST` request instead of `GET`.\n\n#### Raw GraphQL\n\n```graphql\nmutation {\n    getOrCreateUser(record: { name: \"(name)\", email: \"(email)\" }) {\n        _id\n        name\n        streamToken\n    }\n}\n```\n\n#### TinyGraphQL\n\n```swift\nMutation(\"getOrCreateUser\", [\"record\": [\"name\": name, \"email\": email]]) {\n    \"_id\"\n    \"name\"\n    \"streamToken\"\n}\n```\n\n### Request\n\nMaking a request without TinyGraphQL is quite tedious and error prone. With TinyGraphQL, it's safe and easy. Look below at a comparison between building the request yourself and having TinyGraphQL do it for you.\n\n#### Raw GraphQL + URLSession \n\n```swift\nvar urlRequest = URLRequest(url: url)\nurlRequest.httpMethod = \"POST\"\nurlRequest.setValue(\"5fd7ecb251b33b10c380977b\", forHTTPHeaderField: \"combase-organization\")\nurlRequest.setValue(\"application/json\", forHTTPHeaderField: \"Content-Type\")\nurlRequest.httpBody = \"\"\"\n{\n    \"query\": \"mutation { createTicket(message: \\\\\"\\(message)\\\\\", user: \\\\\"\\(userId)\\\\\") { _id }}\"\n}\n\"\"\".data(using: .utf8)\n\nURLSession.shared.dataTask(with: urlRequest, completionHandler: { data, response, error in\n    // handle response\n}\n```\n\n#### TinyGraphQL + URLSession\n\n```swift\nlet query = Query(\"organizationById\", [\"_id\": id]) {\n    \"name\"\n    Field(\"stream\") {\n        \"key\"\n    }\n    \"agentCount\"\n}\n\nlet urlRequest = graphQL.request(for: query)\n\nURLSession.shared.dataTask(with: urlRequest, completionHandler: { data, response, error in\n    // handle response\n}\n```\n\n## Installation\n\nTinyGraphQL supports all three major dependency managers (SPM, CocoaPods, and Carthage)\n\n### SPM\n\n```swift\n.package(name: \"TinyGraphQL\", url: \"https://github.com/getstream/TinyGraphQL\", from: \"0.0.2\")\n```\n\n### CocoaPods\n\n```ruby\npod 'TinyGraphQL', '~\u003e 1.0'\n```\n\n### Carthage\n\n```\ngithub \"getstream/TinyGraphQL\" ~\u003e 1.0\n```\n\n## Adopters\n\n- [Combase][combase-url]: Combase is an Open Source white-label chat solution that provides everything you need to instantly spin up a powerful, real-time customer support dashboard. TinyGraphQL is used by the [Combase Swift SDK][combase-swift-url].\n\n\u003ci\u003eIf you use TinyGraphQL, you can show your support by [opening a PR](https://github.com/GetStream/TinyGraphQL/edit/main/README.md) and including your project or company in this list!\u003c/i\u003e\n\n[swift-badge]: https://img.shields.io/badge/Swift-5.2-orange.svg?style=flat\n[swift-url]: https://swift.org\n\n[ci-badge]: https://img.shields.io/github/workflow/status/getstream/tinygraphql/CI\n[ci-url]: https://github.com/GetStream/TinyGraphQL/actions?query=workflow%3ACI\n\n[cocoapods-badge]: https://img.shields.io/cocoapods/v/TinyGraphQL\n[cocoapods-url]: https://cocoapods.org/pods/TinyGraphQL\n\n[spm-carthage-badge]: https://img.shields.io/badge/SPM%20%26%20Carthage-compatible-green\n\n[license-badge]: https://img.shields.io/badge/License-MIT-blue.svg?style=flat\n[license-url]: https://tldrlegal.com/license/mit-license\n\n[follow-badge]: https://img.shields.io/twitter/follow/getstream_io?style=social\n[follow-url]: https://twitter.com/intent/follow?screen_name=getstream_io\n\n[tweet-badge]: https://img.shields.io/twitter/url?url=https%3A%2F%2Fgithub.com%2FGetStream%2FStreamoji\n[tweet-url]: https://twitter.com/intent/tweet?text=Wow:\u0026url=https%3A%2F%2Fgithub.com%2FGetStream%2FTinyGraphQL\n\n[combase-url]: https://comba.se\n[combase-swift-url]: https://github.com/getstream/combase-swift\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FGetStream%2FTinyGraphQL","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FGetStream%2FTinyGraphQL","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FGetStream%2FTinyGraphQL/lists"}