{"id":15192534,"url":"https://github.com/spring-media/graphqlicious","last_synced_at":"2025-03-30T00:30:31.812Z","repository":{"id":56912962,"uuid":"55071790","full_name":"spring-media/GraphQLicious","owner":"spring-media","description":"A swift component with a DSL to declare GraphQL queries and to get string representations out of them","archived":true,"fork":false,"pushed_at":"2023-09-18T09:15:07.000Z","size":344,"stargazers_count":76,"open_issues_count":4,"forks_count":11,"subscribers_count":19,"default_branch":"master","last_synced_at":"2025-03-23T20:04:46.641Z","etag":null,"topics":["apps","dsl","graphql","graphql-query","swift"],"latest_commit_sha":null,"homepage":null,"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/spring-media.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}},"created_at":"2016-03-30T14:52:46.000Z","updated_at":"2024-08-02T10:02:24.000Z","dependencies_parsed_at":"2024-06-21T14:05:19.230Z","dependency_job_id":"e1d77c3f-a78a-49ac-a72a-60f17c356da4","html_url":"https://github.com/spring-media/GraphQLicious","commit_stats":null,"previous_names":["weltn24/graphqlicious"],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spring-media%2FGraphQLicious","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spring-media%2FGraphQLicious/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spring-media%2FGraphQLicious/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spring-media%2FGraphQLicious/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/spring-media","download_url":"https://codeload.github.com/spring-media/GraphQLicious/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246262490,"owners_count":20749170,"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":["apps","dsl","graphql","graphql-query","swift"],"created_at":"2024-09-27T21:41:33.329Z","updated_at":"2025-03-30T00:30:31.041Z","avatar_url":"https://github.com/spring-media.png","language":"Swift","readme":"# GraphQLicious\nGraphQLicious is a swift component that provides an intuitive and convenient way to build GraphQL queries and convert them easily to String representations.\n\n[![iOS 8] (https://img.shields.io/badge/iOS%208%2B%20%7C%20MacOS%20X%2B%20%7C%20TV%20OS%20%7C%20Watch%20OS%202%2B-Compatible-brightgreen.svg)] ()\n\n[![carthage](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg)](https://github.com/Carthage/Carthage)\n[![cocoapods](https://img.shields.io/cocoapods/v/GraphQLicious.svg)](http://cocoapods.org/pods/GraphQLicious)\n\n[![swift3](https://img.shields.io/badge/Swift-3.0-orange.svg?style=flat)](https://developer.apple.com/swift)\n[![license](https://img.shields.io/cocoapods/l/GraphQLicious.svg)](http://cocoapods.org/pods/GraphQLicious)\n\n[![travis](http://img.shields.io/travis/WeltN24/GraphQLicious.svg)](https://travis-ci.org/WeltN24/GraphQLicious)\n[![codebeat](https://codebeat.co/badges/44501d73-aea0-42ad-8206-0466c4bb26b3)](https://codebeat.co/projects/github-com-weltn24-graphqlicious)\n[![codecov](https://codecov.io/gh/WeltN24/GraphQLicious/branch/master/graph/badge.svg)](https://codecov.io/gh/WeltN24/GraphQLicious)\n\n\n# Contents\n- [Installation](#installation)\n- [Usage](#usage)\n- [Breaking changes](#breaking-changes)\n- [Authors](#authors)\n- [License](#license)\n\n## Installation\n### Carthage\n`GraphQLicious` supports Carthage. To install it, simply add the following line to your Cartfile\n\n```\ngithub \"WeltN24/GraphQLicious\"\n```\n\n### CocoaPods\n`GraphQLicious` is available through CocoaPods. To install it, simply add the following line to your Podfile\n\n```\npod \"GraphQLicious\"\n```\n\n### Submodule\nIf you don't use CocoaPods, you can still add `GraphQLicious` as a submodule, drag and drop `GraphQLicious.xcodeproj` into your project, and embed `GraphQLicious.framework` in your target.\n\n- Drag `GraphQLicious.xcodeproj` to your project\n- Select your app target\n- Click the + button on the Embedded binaries section\n- Add `GraphQLicious.framework`\n\n### Manual\nYou can directly drag and drop the needed files into your project, but keep in mind that this way you won't be able to automatically get all the latest features.  \nThe files are contained in the `Sources` folder and work for the `iOS` framework\n\n## Usage\n### Query\nLet's assume, we have the id of an article and we want to have the `headline`, `body` text and `opener image` of that article.\n\nOur graphQL query for that will look like this:\n\n```graphQL\nquery {\n\ttest: content(id: 153082687){\n\t\t...contentFields\n\t}\n}\nfragment contentFields on Content {\n\theadline,\n\tbody,\n\timage(role: \"opener\", enum: [this, that]){\n\t\t...imageContent\n\t}\n}\nfragment imageContent on Image {\n\tid\n\turl\n}\nfragment urlFragment on Image {\n\t url (ratio: 1, size: 200) \n}\n\n```\n\nFirst, let's create a `Fragment` to fetch the contents of an image, namely the image `id` and the image `url`\n\n```swift\nlet imageContent = Fragment(\n\twithAlias: \"imageContent\",\n\tname: \"Image\",\n\tfields: [\n\t\t\"id\",\n\t\t\"url\"\n\t]\n)\n```\n\nNext, let's embed the `Fragment` into a `Request` that gets the opener image.\t\n**Note:** `Argument` values that are of type `String` are automatically represented with quotes.\t\n**GraphQL** also gives us the possibility to have custom enums as argument values. All you have to do is letting your enum implement `ArgumentValue` and you're good to go.\n\n```swift\nenum customEnum: String, ArgumentValue {\n  case This = \"this\"\n  case That = \"that\"\n  \n  private var asGraphQLArgument: String {\n    return rawValue // without quotes\n  }\n}\n    \nlet customEnumArgument = Argument(\n  key: \"enum\",\n  values: [\n    customEnum.This,\n    customEnum.That\n  ]\n)\n```\t\n\n```swift\nlet imageContentRequest = Request(\n\tname: \"image\",\n\targuments: [\n\t\tArgument(key: \"role\", value: \"opener\"),\n\t\tcustomEnumArgument\n\t],\n\tfields: [\n\t\timageContent\n\t]\n)\n```  \n\nSo now we have a Request with an embedded Fragment. Let's go one step further.  \nIf we want to, we can imbed that Request into another Fragment. (We can also embed Fragments into Fragments)  \nAdditionally to the opener image with its id and url we also want the `headline` and `body` text of the article.\n\n```swift\nlet articleContent = Fragment(\n\twithAlias: \"contentFields\",\n\tname: \"Content\",\n\tfields: [\n\t\t\"headline\",\n\t\t\"body\",\n\t\timageContentRequest\n\t]\n)\n```\n\nFinally, we put everything together as a `Query`. A Query always has a top level Request to get everything started, and requires all the Fragments that are used inside.\n\n```swift\nlet query = Query(request: Request(\n\twithAlias: \"test\",\n\tname: \"content\",\n\targuments: [\n\t\tArgument(key: \"id\", values: [153082687])\n\t],\n\tfields: [\n\t\tarticleContent\n\t]),\n\tfragments: [articleContent, imageContent]\n)\n```  \n\nAll we have to do now is to call `create()` on our Query and we're good to go.\n\n``` \nprint(query.create())\n```\n### Mutation\nLet's assume, we want to change our username and our age in our backend and we want to have the new name and age back to make sure everything went right.\n\nLet's assume further, our server provides a mutating method `editMe` for exactly that purpose.\n\nOur graphQL query for that will look like this:\n\n```graphQL\nmutation myMutation {\n\teditMe(\n\t\tname: \"joe\",\n\t\tage: 99\n\t)\n\t{\n\t\tname,\n\t\tage\n\t}\n}\n```\nLet us first create the actual mutating function. We can use a `Request` for that. As `Argument` `values` we give information about which fields should be changed and what's the actual change\n\n```swift\nlet mutatingRequest = Request(\n      name: \"editMe\",\n      arguments: [\n      \tArgument(name: \"name\", value: \"joe\"),\n        Argument(name: \"age\", value: 99)\n      ],\n      fields: [\n        \"name\",\n        \"age\"\n      ]\n    )\n```\n\nFinally, we put everything together as a `Mutation`. \n\n`Mutation`s work just like `Queries`\n\n```swift\nlet mutation = Mutation(\n\twithAlias: \"myMutation\",\n\tmutatingRequest: mutatingRequest\n)\n```\n\nAfter we've done that we can create the request.\n\n```swift\nprint(mutation.create())\n```\n\n## Breaking changes\n\n### From `0.7` to `0.8` \n\n- `ReadingRequest` is now simply `Request`\n- `MutatingRequest` has been removed, you can use `Request` instead\n- `MutatingArgument` has been removed, you can use `Argument` instead\n- `MutatingValue` and `MutatingField` have been removed, you can use `Argument`, or `ObjectValue` and `ObjectKeyValuePair` instead\n\n\n## Authors\n`GraphQLicious` was made in-house by WeltN24\n\n### Contributors\nFelix Dietz, [fedietz@gmail.com](mailto:fedietz@gmail.com), [@podboq](https://github.com/podboq) (\u003cdel\u003e[@joemcbomb](https://github.com/joemcbomb)\u003c/del\u003e) on Github, [@joemcbomb](https://twitter.com/joemcbomb) on Twitter\n\nVittorio Monaco, [vittorio.monaco@weltn24.de](mailto:vittorio.monaco@weltn24.de), [@vittoriom](https://github.com/vittoriom) on Github, [@Vittorio_Monaco](https://twitter.com/Vittorio_Monaco) on Twitter\n\n## License\n`GraphQLicious` is available under the MIT license. See the LICENSE files for more info.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspring-media%2Fgraphqlicious","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fspring-media%2Fgraphqlicious","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspring-media%2Fgraphqlicious/lists"}