{"id":16758946,"url":"https://github.com/ilia3546/graphus","last_synced_at":"2025-04-10T17:14:30.214Z","repository":{"id":56912960,"uuid":"180352979","full_name":"ilia3546/Graphus","owner":"ilia3546","description":"🚀 Powerful and strongly-typed, pure-Swift GraphQL client for iOS","archived":false,"fork":false,"pushed_at":"2021-01-25T12:54:15.000Z","size":209,"stargazers_count":7,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-19T11:41:39.271Z","etag":null,"topics":["api","api-client","graphql","graphql-client","swift","swift5"],"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/ilia3546.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":"2019-04-09T11:34:15.000Z","updated_at":"2021-01-25T12:53:46.000Z","dependencies_parsed_at":"2022-08-21T03:20:32.060Z","dependency_job_id":null,"html_url":"https://github.com/ilia3546/Graphus","commit_stats":null,"previous_names":[],"tags_count":57,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ilia3546%2FGraphus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ilia3546%2FGraphus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ilia3546%2FGraphus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ilia3546%2FGraphus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ilia3546","download_url":"https://codeload.github.com/ilia3546/Graphus/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248261916,"owners_count":21074225,"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":["api","api-client","graphql","graphql-client","swift","swift5"],"created_at":"2024-10-13T04:06:48.146Z","updated_at":"2025-04-10T17:14:30.193Z","avatar_url":"https://github.com/ilia3546.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/ilia3546/Graphus/master/Images/logo.png\" alt=\"Graphus\" title=\"Graphus\" width=\"305\"/\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n\u003ca href=\"https://travis-ci.org/ilia3546/Graphus\"\u003e\u003cimg src=\"https://travis-ci.com/ilia3546/Graphus.svg?branch=0.1.6\"\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/Carthage/Carthage/\"\u003e\u003cimg src=\"https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat\"\u003e\u003c/a\u003e\n\u003ca href=\"http://onevcat.github.io/Graphus/\"\u003e\u003cimg src=\"https://img.shields.io/cocoapods/v/Graphus.svg?style=flat\"\u003e\u003c/a\u003e\n\u003ca href=\"https://raw.githubusercontent.com/ilia3546/Graphus/master/LICENSE\"\u003e\u003cimg src=\"https://img.shields.io/cocoapods/l/Graphus.svg?style=flat\"\u003e\u003c/a\u003e\n\u003ca href=\"http://onevcat.github.io/Graphus/\"\u003e\u003cimg src=\"https://img.shields.io/cocoapods/p/Graphus.svg?style=flat\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\nGraphus is a powerful and strongly-typed, pure-Swift GraphQL client for iOS. It allows you to build GraphQL requests based on your models. If you like the project, do not forget to put **star ★**\n\n# `Documentation in a writing process`\n\nIf you have a question you can message me at ilia3546@me.com or via telegram.\n\n## Navigate\n\n- [Quick example](#quick-example)\n- [Features](#features)\n- [Requirements](#requirements)\n- [Installation](#installation)\n- [Usage](#usage)\n\t- [The Basics](#the-basics)\n\t- [Adding child models](#adding-child-models)\n\t- [Creating Query object](#creating-query-object)\n\t- [Creating a client](#creating-a-client)\n\t- [Sending requests to a server](#sending-requests-to-a-server)\n\t- [Arguments](#arguments)\n- [License](#license)\n- [Contact](#contact)\n\n## Quick example\n\n```swift\n\n// Make simple model\nstruct Author: Decodable, Queryable {\n\n    var firstName: String\n    var secondName: String\n    \n    static func buildQuery(with builder: QueryBuilder) {\n        let query = builder.query(keyedBy: CodingKeys.self)\n        query.addField(.firstName)\n        query.addField(.secondName)\n    }\n    \n}\n\n// Create query for retriving authors list\nlet authorsQuery = Query(\"authors\", model: Author.self)\n\n// Send request to the server \u0026 map response\nself.client.request(authorsQuery).send(mapToDecodable: [Author].self) { (result) in\n\tswitch result {\n\tcase .success(let response):\n\t\tprint(\"Authors\", response.data)\n\t\tprint(\"GraphQL errors\", response.errors)\n\tcase .failure(let error):\n\t\tprint(\"Job failed: \\(error.localizedDescription)\")\n\t}\n}\n\n```\n\n\n## Features\n- [x] Building GraphQL requests based on your models.\n- [x] Add any arguments to each field.\n- [x] Mutation requests\n- [x] GraphQL pagination support\n- [x] Response mapping using **Codable** protocol\n- [ ] [TODO] [ObjectMapper](https://github.com/tristanhimmelman/ObjectMapper) support\n\n\n## Requirements\n\nSwift 4.2 or **5.0**. Ready for use on iOS 10+\n\n\n## Installation\n\n### CocoaPods:\n\n[CocoaPods](https://cocoapods.org) is a dependency manager for Cocoa projects. For usage and installation instructions, visit their website. To integrate `Graphus` into your Xcode project using CocoaPods, specify it in your `Podfile`:\n\n```ruby\npod 'Graphus' # Without mapping\npod 'Graphus/Codable' # Codable mapping support (recommended)\n```\n\n### Carthage\n\n[Carthage](https://github.com/Carthage/Carthage) is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks. To integrate `Graphus` into your Xcode project using Carthage, specify it in your `Cartfile`:\n\n```ogdl\ngithub \"ilia3546/Graphus\"\n```\n\n### Manually\n\nIf you prefer not to use any of the aforementioned dependency managers, you can integrate `Graphus` into your project manually. Put `Source` folder in your Xcode project. Make sure to enable `Copy items if needed` and `Create groups`.\n\n## Usage\n\n### The Basics\n\nTo build requests which are based on your class or struct just needs to implement the **Queryable** protocol which includes the following static function:\n\n```swift\nstatic func buildQuery(with builder: QueryBuilder)\n```\n\nGraphus use `QueryBuilder` object to add fields and child models:\n\n```swift\nstruct Book: Queryable {\n    \n    var title: String\n    var isbn: String\n    \n    static func buildQuery(with builder: QueryBuilder) {\n        let query = builder.query()\n        query.addField(\"title\")\n        query.addField(\"isbn\")\n    }\n    \n}\n```\n\nAlso you can create query keyed by CodingKeys if your model is implemented **Decodable** protocol and you use Codable intergration:\n\n```swift\nstatic func buildQuery(with builder: QueryBuilder) {\n\tlet query = builder.query(keyedBy: CodingKeys.self)\n\tquery.addField(.title)\n\tquery.addField(.isbn)\n}\n```\n\nThe above example will generate following GraphQL request model:\n\n```\n{\n\ttitle, \n\tisbn\n}\n```\n\n### Adding child models\n\nYou can add child models to the GraqhQL request:\n\n```swift\nstruct Author: Decodable, Queryable {\n    \n    var firstName: String\n    var secondName: String\n    var books: [Book]\n    \n    static func buildQuery(with builder: QueryBuilder) {\n        let query = builder.query(keyedBy: CodingKeys.self)\n        query.addField(.firstName)\n        query.addField(.secondName)\n        query.addChild(Book.self, forKey: .books)\n    }\n    \n}\n\n```\n\nThe above example will generate following GraphQL request model:\n\n```\n{\n\tfirstName,\n\tsecondName,\n\tbooks {\n\t\ttitle,\n\t\tisbn\n\t}\n}\n```\n\n\n### Creating `Query` object\n\nAfter you've created `GraphusClient` and models you could make your first `Query` object:\n\n```swift\nlet authorsQuery = Query(\"authors\", model: Author.self)\n```\n\nAlso you can add some arguments (see [arguments](#arguments) section):\n\n```swift\nlet authorArguments: Arguments = [\n\t\t\"filter\": [\n\t\t\t\"age\": 24\n\t\t]\n\t]\n\t\nlet authorsQuery = Query(\"authors\", arguments: authorArguments, model: Author.self)\n```\n\nAlso if you do not want you can use `[Field]` array:\n\n```\nlet fields: [Field] = [\"firstName\", \"secondName\"]\nlet authorsQuery = Query(\"authors\", fields: fields)\n```\n\n### Creating a client\n\nIn most cases, you'll want to create a single shared instance of `GraphusClient` and point it at your GraphQL server. The easiest way to do this is to define a global variable:\n\n```swift\nvar client: GraphusClient = {\n\tlet configuration = URLSessionConfiguration.default\n\t// Add additional headers as needed\n\tconfiguration.httpAdditionalHeaders = [\"Authorization\": \"Bearer \u003ctoken\u003e\"] // Replace `\u003ctoken\u003e`\n\tlet url = URL(string: \"http://localhost:8080/graphql\")!\n\treturn GraphusClient(url: url, configuration: configuration)\n}()\n\n```\n\n\n### Sending requests to a server\n*TODO*\n\n\n### Arguments\n*TODO*\n\n## License\n`Graphus` is released under the MIT license. Check `LICENSE.md` for details.\n\n## Contact\nIf you need any application or UI to be developed, message me at ilia3546@me.com or via [telegram](https://t.me/bluetech_team). I develop iOS apps and designs. I use `swift` for development. To request more functionality, you should create a new issue.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Filia3546%2Fgraphus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Filia3546%2Fgraphus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Filia3546%2Fgraphus/lists"}