{"id":22489463,"url":"https://github.com/apollo-server-integrations/apollo-server-integration-h3","last_synced_at":"2025-07-04T10:07:05.225Z","repository":{"id":61510028,"uuid":"551656888","full_name":"apollo-server-integrations/apollo-server-integration-h3","owner":"apollo-server-integrations","description":"An Apollo Server integration for use with h3 and nuxt","archived":false,"fork":false,"pushed_at":"2025-07-01T07:03:59.000Z","size":1064,"stargazers_count":28,"open_issues_count":4,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-07-01T08:23:56.185Z","etag":null,"topics":["apollo","apollo-server","graphql","h3","nuxt"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/apollo-server-integrations.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"github":["tobiasdiez"]}},"created_at":"2022-10-14T20:41:14.000Z","updated_at":"2025-07-01T07:03:23.000Z","dependencies_parsed_at":"2023-10-16T09:06:30.127Z","dependency_job_id":"2f0051d6-17c1-4d4f-8a9f-bf65a95c0926","html_url":"https://github.com/apollo-server-integrations/apollo-server-integration-h3","commit_stats":{"total_commits":49,"total_committers":3,"mean_commits":"16.333333333333332","dds":"0.26530612244897955","last_synced_commit":"ba669c5c169b696ba357942b79c923431f0c4ec5"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":"unjs/template","purl":"pkg:github/apollo-server-integrations/apollo-server-integration-h3","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apollo-server-integrations%2Fapollo-server-integration-h3","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apollo-server-integrations%2Fapollo-server-integration-h3/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apollo-server-integrations%2Fapollo-server-integration-h3/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apollo-server-integrations%2Fapollo-server-integration-h3/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/apollo-server-integrations","download_url":"https://codeload.github.com/apollo-server-integrations/apollo-server-integration-h3/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apollo-server-integrations%2Fapollo-server-integration-h3/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262926685,"owners_count":23385832,"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":["apollo","apollo-server","graphql","h3","nuxt"],"created_at":"2024-12-06T17:19:55.388Z","updated_at":"2025-07-04T10:07:05.204Z","avatar_url":"https://github.com/apollo-server-integrations.png","language":"TypeScript","funding_links":["https://github.com/sponsors/tobiasdiez"],"categories":["TypeScript"],"sub_categories":[],"readme":"# Apollo Server integration for h3 and nuxt\n\n[![npm version][npm-version-src]][npm-version-href]\n[![npm downloads][npm-downloads-src]][npm-downloads-href]\n[![Github Actions][github-actions-src]][github-actions-href]\n[![Codecov][codecov-src]][codecov-href]\n\nThis package allows you to easily integrate [Apollo Server](https://www.apollographql.com/docs/apollo-server/) with your [h3](https://github.com/unjs/h3) or [Nuxt 3](v3.nuxtjs.org) application.\n\n\u003e For defining a GraphQL server in Nuxt 3, you may want to have a look at the [GraphQL server toolkit Nuxt module](https://github.com/tobiasdiez/nuxt-graphql-server).\n\n## Installation\n\n```sh\n# npm\nnpm install @apollo/server graphql @as-integrations/h3\n\n# yarn\nyarn add @apollo/server graphql @as-integrations/h3\n\n# pnpm\npnpm add @apollo/server graphql @as-integrations/h3\n```\n\n## Usage with Nuxt v3\n\nCreate a [Server API Route](https://v3.nuxtjs.org/guide/directory-structure/server#api-routes) that configures an instance of Apollo Server as described in the [documentation](https://www.apollographql.com/docs/apollo-server/getting-started#step-6-create-an-instance-of-apolloserver) and then exports it as the event handler:\n\n```js\nimport { ApolloServer } from '@apollo/server'\nimport { startServerAndCreateH3Handler } from '@as-integrations/h3'\n\nconst apollo = new ApolloServer({\n  // Specify server options like schema and resolvers here\n})\n\nexport default startServerAndCreateH3Handler(apollo, {\n  // Optional: Specify context\n  context: (event) =\u003e {\n    /*...*/\n  },\n})\n```\n\n## Usage with h3\n\nCreate and configure an instance of Apollo Server as described in the [documentation](https://www.apollographql.com/docs/apollo-server/getting-started#step-6-create-an-instance-of-apolloserver) and then register it as a route handler in your `h3` application.\n\n```js\nimport { createApp } from 'h3'\nimport { ApolloServer } from '@apollo/server'\nimport { startServerAndCreateH3Handler } from '@as-integrations/h3'\n\nconst apollo = new ApolloServer({\n  // Specify server options like schema and resolvers here\n})\n\nexport const app = createApp()\napp.use(\n  '/api',\n  startServerAndCreateH3Handler(apollo, {\n    // Optional: Specify context\n    context: (event) =\u003e {\n      /*...*/\n    },\n  }),\n)\n```\n\nThen run your h3 server as usual, e.g. with `npx --yes listhen -w --open ./app.ts`.\nVisit http://localhost:3000/api in your browser to access the Apollo Sandbox.\n\n## Subscriptions with WebSockets\n\nThis package also supports subscriptions over WebSockets. To enable this feature, you need to install the `graphql-ws` package:\n\n```sh\n# npm\nnpm install graphql-ws\n\n# yarn\nyarn add graphql-ws\n\n# pnpm\npnpm add graphql-ws\n```\n\nThen you can add a WebSocket handler to your `h3` app using the `defineGraphqlWebSocketHandler` or `defineGraphqlWebSocket` functions from this package. Here is an example that combines the HTTP and WebSocket handlers in a single app.\n\n```js\nimport { createApp } from 'h3'\nimport { ApolloServer } from '@apollo/server'\nimport { startServerAndCreateH3Handler } from '@as-integrations/h3'\nimport { defineGraphqlWebSocketHandler } from '@as-integrations/h3/websocket'\nimport { makeExecutableSchema } from '@graphql-tools/schema'\n\n// Define your schema and resolvers\nconst typeDefs = `...`\nconst resolvers = {\n  /*...*/\n}\nconst schema = makeExecutableSchema({ typeDefs, resolvers })\n\nconst apollo = new ApolloServer({ schema })\n\nexport const app = createApp()\napp.use(\n  '/api',\n  startServerAndCreateH3Handler(apollo, {\n    websocket: defineGraphqlWebSocketHandler({ schema }),\n  }),\n)\n```\n\nThen you can connect to the WebSocket endpoint using the Apollo Sandbox or any other client that supports the `graphql-ws` protocol.\n\nSee the [WebSocket example](./examples/websocket.ts) for a complete example.\n\n## 💻 Development\n\n- Clone this repository\n- Enable [Corepack](https://github.com/nodejs/corepack) using `corepack enable` (use `npm i -g corepack` for Node.js \u003c 16.10).\n- Install dependencies using `pnpm install`.\n- Run tests using `pnpm test` and integration tests via `pnpm test:integration`.\n\n## License\n\nMade with 💛\n\nPublished under [MIT License](./LICENSE).\n\n\u003c!-- Badges --\u003e\n\n[npm-version-src]: https://img.shields.io/npm/v/@as-integrations/h3?style=flat-square\n[npm-version-href]: https://npmjs.com/package/@as-integrations/h3\n[npm-downloads-src]: https://img.shields.io/npm/dm/@as-integrations/h3?style=flat-square\n[npm-downloads-href]: https://npmjs.com/package/@as-integrations/h3\n[github-actions-src]: https://img.shields.io/github/workflow/status/apollo-server-integrations/apollo-server-integration-h3/ci/main?style=flat-square\n[github-actions-href]: https://github.com/apollo-server-integrations/apollo-server-integration-h3/actions?query=workflow%3Aci\n[codecov-src]: https://img.shields.io/codecov/c/gh/apollo-server-integrations/apollo-server-integration-h3/main?style=flat-square\n[codecov-href]: https://codecov.io/gh/apollo-server-integrations/apollo-server-integration-h3\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapollo-server-integrations%2Fapollo-server-integration-h3","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fapollo-server-integrations%2Fapollo-server-integration-h3","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapollo-server-integrations%2Fapollo-server-integration-h3/lists"}