{"id":50745054,"url":"https://github.com/GraphQLSwift/graphql-vapor","last_synced_at":"2026-06-27T23:00:46.356Z","repository":{"id":333373600,"uuid":"1137060978","full_name":"GraphQLSwift/graphql-vapor","owner":"GraphQLSwift","description":"Easily expose GraphQL APIs in Vapor","archived":false,"fork":false,"pushed_at":"2026-05-17T23:54:30.000Z","size":115,"stargazers_count":13,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-05-18T01:46:49.005Z","etag":null,"topics":["graphql","server","swift","vapor"],"latest_commit_sha":null,"homepage":"https://swiftpackageindex.com/GraphQLSwift/graphql-vapor","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,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-01-18T20:56:57.000Z","updated_at":"2026-05-17T23:49:37.000Z","dependencies_parsed_at":"2026-01-19T07:05:45.555Z","dependency_job_id":null,"html_url":"https://github.com/GraphQLSwift/graphql-vapor","commit_stats":null,"previous_names":["needleinajaystack/graphql-vapor","graphqlswift/graphql-vapor"],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/GraphQLSwift/graphql-vapor","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GraphQLSwift%2Fgraphql-vapor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GraphQLSwift%2Fgraphql-vapor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GraphQLSwift%2Fgraphql-vapor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GraphQLSwift%2Fgraphql-vapor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GraphQLSwift","download_url":"https://codeload.github.com/GraphQLSwift/graphql-vapor/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GraphQLSwift%2Fgraphql-vapor/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34870654,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-27T02:00:06.362Z","response_time":126,"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":["graphql","server","swift","vapor"],"created_at":"2026-06-10T20:00:38.587Z","updated_at":"2026-06-27T23:00:46.351Z","avatar_url":"https://github.com/GraphQLSwift.png","language":"Swift","funding_links":[],"categories":["Swift"],"sub_categories":[],"readme":"# GraphQLVapor\n\n[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2FGraphQLSwift%2Fgraphql-vapor%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/GraphQLSwift/graphql-vapor)\n[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2FGraphQLSwift%2Fgraphql-vapor%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/GraphQLSwift/graphql-vapor)\n\nA Swift library for integrating [GraphQL](https://github.com/GraphQLSwift/GraphQL) with [Vapor](https://github.com/vapor/vapor), enabling you to easily expose GraphQL APIs in your Vapor applications.\n\n## Features\n\n- Simple integration of GraphQL schemas with Vapor routing\n- Compatibility with the [GraphQL over HTTP spec](https://github.com/graphql/graphql-over-http/blob/main/spec/GraphQLOverHTTP.md)\n- Subscription support using WebSockets, with support for [`graphql-transport-ws`](https://github.com/GraphQLSwift/GraphQLTransportWS) and [`graphql-ws`](https://github.com/apollographql/subscriptions-transport-ws/blob/master/PROTOCOL.md) subprotocols\n- Built-in [GraphiQL](https://github.com/graphql/graphiql) IDE\n\n## Installation\n\nAdd GraphQLVapor as a dependency in your `Package.swift`:\n\n```swift\ndependencies: [\n    .package(url: \"https://github.com/NeedleInAJayStack/graphql-vapor.git\", from: \"1.0.0\"),\n]\n```\n\nThen add it to your target:\n\n```swift\n.target(\n    name: \"YourTarget\",\n    dependencies: [\n        .product(name: \"GraphQLVapor\", package: \"graphql-vapor\"),\n    ]\n)\n```\n\n## Usage\n\nTo use this package, you must already have a GraphQL schema. You can use [graphql-generator](https://github.com/GraphQLSwift/graphql-generator), [Graphiti](https://github.com/GraphQLSwift/Graphiti), or [GraphQL](https://github.com/GraphQLSwift/GraphQL) to construct one.\n\nSee [the HelloWorld project](https://github.com/GraphQLSwift/graphql-vapor/tree/main/Examples/HelloWorld) for a full working example.\n\n### Basic Example\n\n```swift\nimport GraphQL\nimport GraphQLVapor\nimport Vapor\n\n// Define your GraphQL schema\nlet schema = try GraphQLSchema(\n    query: GraphQLObjectType(\n        name: \"Query\",\n        fields: [\n            \"hello\": GraphQLField(\n                type: GraphQLString,\n                resolve: { _, _, _, _ in\n                    \"World\"\n                }\n            )\n        ]\n    )\n)\n\n// Define your Context\nstruct GraphQLContext: Sendable {}\n\n// Register GraphQL to the Vapor Application\napp.graphql(schema: schema) { _ in\n    return GraphQLContext()\n}\n```\n\nNow just run the application! You can view the GraphiQL IDE at `/graphql`, or query directly using `GET` or `POST`:\n\n```bash\ncurl -X POST http://localhost:8080/graphql \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"query\": \"{ hello }\"}'\n```\n\nResponse:\n```json\n{\n  \"data\": {\n    \"hello\": \"World\"\n  }\n}\n```\n\nSee the `RouteBuilder.graphql` function documentation for advanced configuration options.\n\n### Computing GraphQL Context\n\nThe required closure in the `graphql` function is used to compute the `GraphQLContext` object, which is injected into each GraphQL resolver. The `inputs` argument passes in data from the request so that the Context can be created dynamically:\n\n```swift\napp.graphql(schema: schema) { inputs in\n    return GraphQLContext(\n        userID: inputs.vaporRequest.auth.userID,\n        logger: inputs.vaporRequest.logger,\n        debug: inputs.vaporRequest.headers[.init(\"debug\")!] != nil,\n        operationName: inputs.graphQLRequest.operationName\n    )\n}\n```\n\n### WebSockets\n\nSubscription support via WebSockets is provided, and can be enabled by in the `subscriptionProtocols` configuration:\n\n```swift\napp.graphql(schema: schema, config: .init(subscriptionProtocols: [.websocket])) { _ in\n    GraphQLContext()\n}\n```\n\n[`graphql-ws`](https://github.com/apollographql/subscriptions-transport-ws/blob/master/PROTOCOL.md) and [`graphql-transport-ws`](https://github.com/enisdenjo/graphql-ws/blob/master/PROTOCOL.md) subprotocols are supported.\n\n### Graphiti\n\nIf using Graphiti to build your GraphQL schema, you must provide an instance of the `Resolver` to the `rootValue` argument. For example:\n\n```swift\nlet graphqlSchema: Graphiti.Schema\u003cResolver, Context\u003e = try graphqlSchema()\napp.graphql(\n    schema: graphqlSchema.schema,\n    rootValue: Resolver() // This must be included\n) { _ in\n    Context()\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FGraphQLSwift%2Fgraphql-vapor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FGraphQLSwift%2Fgraphql-vapor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FGraphQLSwift%2Fgraphql-vapor/lists"}