{"id":32151909,"url":"https://github.com/graphqlswift/graphiti","last_synced_at":"2026-02-07T09:01:48.346Z","repository":{"id":12623812,"uuid":"72381677","full_name":"GraphQLSwift/Graphiti","owner":"GraphQLSwift","description":"The Swift GraphQL Schema framework for macOS and Linux","archived":false,"fork":false,"pushed_at":"2025-08-21T19:30:20.000Z","size":695,"stargazers_count":552,"open_issues_count":19,"forks_count":67,"subscribers_count":15,"default_branch":"main","last_synced_at":"2025-10-21T10:55:47.326Z","etag":null,"topics":["graphiti","graphql","swift","swift-nio","swiftpm","vapor"],"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/GraphQLSwift.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,"zenodo":null}},"created_at":"2016-10-30T23:22:14.000Z","updated_at":"2025-10-07T02:32:05.000Z","dependencies_parsed_at":"2023-02-16T04:30:40.830Z","dependency_job_id":"175a6f4b-b59b-4a0c-bf90-5ee36cdfa22d","html_url":"https://github.com/GraphQLSwift/Graphiti","commit_stats":{"total_commits":342,"total_committers":27,"mean_commits":"12.666666666666666","dds":0.6695906432748537,"last_synced_commit":"3f154342c6cb00301084fc8012cc8afa9f09aa70"},"previous_names":[],"tags_count":72,"template":false,"template_full_name":null,"purl":"pkg:github/GraphQLSwift/Graphiti","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GraphQLSwift%2FGraphiti","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GraphQLSwift%2FGraphiti/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GraphQLSwift%2FGraphiti/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GraphQLSwift%2FGraphiti/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GraphQLSwift","download_url":"https://codeload.github.com/GraphQLSwift/Graphiti/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GraphQLSwift%2FGraphiti/sbom","scorecard":{"id":59099,"data":{"date":"2025-08-11","repo":{"name":"github.com/GraphQLSwift/Graphiti","commit":"d6f2bb17a9dad8d6a7f9a0628902d53195e46686"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":5.9,"checks":[{"name":"Code-Review","score":10,"reason":"all changesets reviewed","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Maintained","score":10,"reason":"15 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 10","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/test.yaml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: third-party GitHubAction not pinned by hash: .github/workflows/test.yaml:10: update your workflow using https://app.stepsecurity.io/secureworkflow/GraphQLSwift/Graphiti/test.yaml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/test.yaml:12: update your workflow using https://app.stepsecurity.io/secureworkflow/GraphQLSwift/Graphiti/test.yaml/main?enable=pin","Info:   0 out of   2 third-party GitHubAction dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 30 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-15T01:20:51.062Z","repository_id":12623812,"created_at":"2025-08-15T01:20:51.062Z","updated_at":"2025-08-15T01:20:51.062Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":280248570,"owners_count":26297925,"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","status":"online","status_checked_at":"2025-10-21T02:00:06.614Z","response_time":58,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["graphiti","graphql","swift","swift-nio","swiftpm","vapor"],"created_at":"2025-10-21T10:55:51.449Z","updated_at":"2026-02-07T09:01:48.333Z","avatar_url":"https://github.com/GraphQLSwift.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Graphiti\n\nGraphiti is a Swift library for building GraphQL schemas fast, safely and easily.\n\n[![Platforms][platforms-badge]][platforms-url]\n[![Versions][versions-badge]][versions-url]\n[![License][mit-badge]][mit-url]\n[![GitHub Actions][gh-actions-badge]][gh-actions-url]\n\nLooking for help? Find resources [from the community](http://graphql.org/community/).\n\n\n## Getting Started\n\nAn overview of GraphQL in general is available in the\n[README](https://github.com/facebook/graphql/blob/master/README.md) for the\n[Specification for GraphQL](https://github.com/facebook/graphql). That overview\ndescribes a simple set of GraphQL examples that exist as [tests](Tests/GraphitiTests/StarWarsTests/)\nin this repository. A good way to get started with this repository is to walk\nthrough that README and the corresponding tests in parallel.\n\n### Using Graphiti\n\nAdd Graphiti to your `Package.swift`\n\n```swift\nimport PackageDescription\n\nlet package = Package(\n    dependencies: [\n        .package(url: \"https://github.com/GraphQLSwift/Graphiti.git\", .upToNextMinor(from: \"0.20.1\")),\n    ]\n)\n```\n\nGraphiti provides two important capabilities: building a type schema, and\nserving queries against that type schema.\n\n#### Defining entities\n\nFirst, we declare our regular Swift entities.\n\n```swift\nstruct Message : Codable {\n    let content: String\n}\n```\n\n⭐️ One of the main design decisions behind Graphiti is **not** to polute your entities declarations. This way you can bring your entities to any other solution with ease.\n\n#### Defining the context\n\nSecond step is to create your application's **context**. The context will be passed to all of your field resolver functions. This allows you to apply dependency injection to your API. This is the place where you can put code that talks to a database or another service.\n\n```swift\nstruct Context {\n    func message() -\u003e Message {\n        Message(content: \"Hello, world!\")\n    }\n}\n```\n\n⭐️ Notice again that this step doesn't require Graphiti. It's purely business logic.\n\n#### Defining the GraphQL API resolver\n\nNow that we have our entities and context we can create the GraphQL API resolver.\n\n```swift\nimport Graphiti\n\nstruct Resolver {\n    func message(context: Context, arguments: NoArguments) -\u003e Message {\n        context.message()\n    }\n}\n```\n\n#### Defining the GraphQL API schema\n\nNow we can finally define the GraphQL API with its schema.\n\n```swift\nstruct MessageAPI : API {\n    let resolver: Resolver\n    let schema: Schema\u003cResolver, Context\u003e\n}\n\nlet api = MessageAPI(\n    resolver: Resolver()\n    schema: try! Schema\u003cResolver, Context\u003e {\n        Type(Message.self) {\n            Field(\"content\", at: \\.content)\n        }\n\n        Query {\n            Field(\"message\", at: Resolver.message)\n        }\n    }\n)\n```\n\nSchemas may also be created in a modular way using `SchemaBuilder`:\n\n\u003cblockquote\u003e\n\n\u003cdetails open=\"true\"\u003e\n\u003csummary\u003eSchemaBuilder API\u003c/summary\u003e\n\n```swift\nlet builder = SchemaBuilder(Resolver.self, Context.self)\nbuilder.add(\n    Type(Message.self) {\n        Field(\"content\", at: \\.content)\n    }\n)\nbuilder.query.add(\n    Field(\"message\", at: Resolver.message)\n)\nlet schema = try builder.build()\n\nlet api = MessageAPI(\n    resolver: Resolver()\n    schema: schema\n)\n```\n\n\u003c/details\u003e\n\u003cdetails\u003e\n\u003csummary\u003ePartialSchema implementation\u003c/summary\u003e\n\n```swift\nfinal class ChatSchema: PartialSchema\u003cResolver, Context\u003e {\n    @TypeDefinitions\n    public override var types: Types {\n        Type(Message.self) {\n            Field(\"content\", at: \\.content)\n        }\n    }\n\n    @FieldDefinitions\n    public override var query: Fields {\n        Field(\"message\", at: Resolver.message)\n    }\n}\nlet schema = try SchemaBuilder(Resolver.self, Context.self)\n    .use(partials: [ChatSchema(), ...])\n    .build()\n\nlet api = MessageAPI(\n    resolver: Resolver()\n    schema: schema\n)\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003ePartialSchema instance\u003c/summary\u003e\n\n```swift\nlet chatSchema = PartialSchema\u003cResolver, Context\u003e(\n    types:  {\n        Type(Message.self) {\n            Field(\"content\", at: \\.content)\n        }\n    },\n    query: {\n        Field(\"message\", at: Resolver.message)\n    }\n)\nlet schema = try SchemaBuilder(Resolver.self, Context.self)\n    .use(partials: [chatSchema, ...])\n    .build()\n\nlet api = MessageAPI(\n    resolver: Resolver()\n    schema: schema\n)\n```\n\n\u003c/details\u003e\n\n---\n\n\u003c/blockquote\u003e\n\n⭐️ Notice that `API` allows dependency injection. You could pass mocks of `resolver` and `context` when testing, for example.\n\n#### Querying\n\n```swift\nlet result = try await api.execute(\n    request: \"{ message { content } }\",\n    context: Context()\n)\nprint(result)\n```\n\nThe output will be:\n\n```json\n{\"data\":{\"message\":{\"content\":\"Hello, world!\"}}}\n```\n\n`API.execute` returns a `GraphQLResult` which adopts `Encodable`. You can use it with a `JSONEncoder` to send the response back to the client using JSON.\n\n#### Async resolvers\n\nResolver functions can also be `async`:\n\n```swift\nstruct Resolver {\n    func message(context: Context, arguments: NoArguments) async -\u003e Message {\n        await someAsyncMethodToGetMessage()\n    }\n}\n```\n\n#### Subscription\n\nThis library supports GraphQL subscriptions, and supports them through the Swift Concurrency `AsyncThrowingStream` type. See the [Usage Guide](UsageGuide.md#subscriptions) for details.\n\nIf you are unable to use Swift Concurrency, you must create a concrete subclass of the `EventStream` class that implements event streaming\nfunctionality. If you don't feel like creating a subclass yourself, you can use the [GraphQLRxSwift](https://github.com/GraphQLSwift/GraphQLRxSwift) repository\nto integrate [RxSwift](https://github.com/ReactiveX/RxSwift) observables out-of-the-box. Or you can use that repository as a reference to connect a different\nstream library like [ReactiveSwift](https://github.com/ReactiveCocoa/ReactiveSwift), [OpenCombine](https://github.com/OpenCombine/OpenCombine), or\none that you've created yourself.\n\n## Additional Examples\n\nFor a progressive walkthrough, see the [Usage Guide](UsageGuide.md). The [Star Wars API](Tests/GraphitiTests/StarWarsAPI/StarWarsAPI.swift) provides a fairly complete example.\n\n## Support\n\nThis package supports Swift versions in [alignment with Swift NIO](https://github.com/apple/swift-nio?tab=readme-ov-file#swift-versions).\n\n## Contributing\n\nThis repo uses [SwiftFormat](https://github.com/nicklockwood/SwiftFormat), and includes lint checks to enforce these formatting standards.\nTo format your code, install `swiftformat` and run:\n\n```bash\nswiftformat .\n```\n\n## License\n\nThis project is released under the MIT license. See [LICENSE](LICENSE) for details.\n\n[platforms-badge]: https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2FGraphQLSwift%2FGraphiti%2Fbadge%3Ftype%3Dplatforms\n[platforms-url]: https://swiftpackageindex.com/GraphQLSwift/Graphiti\n\n[versions-badge]: https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2FGraphQLSwift%2FGraphiti%2Fbadge%3Ftype%3Dswift-versions\n[versions-url]: https://swiftpackageindex.com/GraphQLSwift/Graphiti\n\n[swift-badge]: https://img.shields.io/badge/Swift-5.4-orange.svg?style=flat\n[swift-url]: https://swift.org\n\n[mit-badge]: https://img.shields.io/badge/License-MIT-blue.svg?style=flat\n[mit-url]: https://tldrlegal.com/license/mit-license\n\n[gh-actions-badge]: https://github.com/GraphQLSwift/Graphiti/workflows/Tests/badge.svg\n[gh-actions-url]: https://github.com/GraphQLSwift/Graphiti/actions?query=workflow%3ATests\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgraphqlswift%2Fgraphiti","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgraphqlswift%2Fgraphiti","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgraphqlswift%2Fgraphiti/lists"}