├── .github ├── FUNDING.yml └── workflows │ ├── ci.yml │ └── release.yml ├── .release-please-manifest.json ├── .prettierrc ├── .gitignore ├── jest.config.cjs ├── tsconfig.json ├── eslint.config.mjs ├── .editorconfig ├── tsconfig.eslint.json ├── release-please-config.json ├── .devcontainer └── devcontainer.json ├── examples ├── README.md ├── simple.ts └── websocket.ts ├── LICENSE ├── renovate.json5 ├── test └── integration.test.ts ├── package.json ├── src ├── index.ts └── websocket.ts ├── README.md └── CHANGELOG.md /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: [tobiasdiez] 2 | -------------------------------------------------------------------------------- /.release-please-manifest.json: -------------------------------------------------------------------------------- 1 | { ".": "2.0.0" } 2 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "semi": false, 3 | "singleQuote": true, 4 | "singleAttributePerLine": true 5 | } 6 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | coverage 3 | dist 4 | .vscode 5 | .DS_Store 6 | .eslintcache 7 | *.log* 8 | *.env* 9 | -------------------------------------------------------------------------------- /jest.config.cjs: -------------------------------------------------------------------------------- 1 | /** @type {import('ts-jest').JestConfigWithTsJest} */ 2 | module.exports = { 3 | preset: 'ts-jest', 4 | testEnvironment: 'node', 5 | } 6 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ESNext", 4 | "module": "ESNext", 5 | "moduleResolution": "Node", 6 | "esModuleInterop": true, 7 | "strict": true, 8 | "strictNullChecks": true 9 | }, 10 | "include": ["src"] 11 | } 12 | -------------------------------------------------------------------------------- /eslint.config.mjs: -------------------------------------------------------------------------------- 1 | import unjs from 'eslint-config-unjs' 2 | import prettier from 'eslint-config-prettier' 3 | import unusedImports from 'eslint-plugin-unused-imports' 4 | 5 | export default unjs( 6 | { 7 | plugins: [unusedImports], 8 | }, 9 | prettier, 10 | ) 11 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | end_of_line = lf 5 | insert_final_newline = true 6 | trim_trailing_whitespace = true 7 | charset = utf-8 8 | 9 | [*.js] 10 | indent_style = space 11 | indent_size = 2 12 | 13 | [{package.json,*.yml,*.cjson}] 14 | indent_style = space 15 | indent_size = 2 16 | -------------------------------------------------------------------------------- /tsconfig.eslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | // ensure that nobody can accidentally use this config for a build 5 | "noEmit": true 6 | }, 7 | "include": [ 8 | // whatever paths you intend to lint 9 | "src", 10 | "test", 11 | "examples" 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /release-please-config.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://raw.githubusercontent.com/stainless-api/release-please/main/schemas/config.json", 3 | "packages": { 4 | ".": {} 5 | }, 6 | "release-type": "node", 7 | "include-component-in-tag": false, 8 | "changelog-sections": [ 9 | { "type": "feat", "section": "🔖 Features", "hidden": false }, 10 | { "type": "fix", "section": "🐛 Bug Fixes", "hidden": false }, 11 | { "type": "docs", "section": "📚 Documentation", "hidden": false }, 12 | { "type": "chore", "section": "🧹 Miscellaneous", "hidden": false } 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: ci 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | pull_request: 8 | branches: 9 | - main 10 | 11 | jobs: 12 | ci: 13 | runs-on: ubuntu-latest 14 | steps: 15 | - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 16 | - uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4.2.0 17 | - uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6.1.0 18 | with: 19 | node-version-file: package.json 20 | cache: 'pnpm' 21 | - run: pnpm install 22 | - run: pnpm lint 23 | - run: pnpm test:types 24 | - run: pnpm build 25 | #- run: pnpm vitest --coverage 26 | - run: pnpm test:integration 27 | - uses: codecov/codecov-action@5a1091511ad55cbe89839c7260b706298ca349f7 # v5.5.1 28 | -------------------------------------------------------------------------------- /.devcontainer/devcontainer.json: -------------------------------------------------------------------------------- 1 | // For format details, see https://aka.ms/devcontainer.json. For config options, see the README at: 2 | // https://github.com/microsoft/vscode-dev-containers/tree/v0.245.2/containers/ubuntu 3 | { 4 | "name": "Ubuntu", 5 | "image": "mcr.microsoft.com/vscode/devcontainers/base:2-ubuntu-22.04", 6 | 7 | "onCreateCommand": "corepack enable && pnpm install", 8 | 9 | "remoteUser": "vscode", 10 | "features": { 11 | // For config options, see https://github.com/devcontainers/features/tree/main/src/node 12 | "ghcr.io/devcontainers/features/node:1.6.1": "18" 13 | }, 14 | "customizations": { 15 | "vscode": { 16 | "extensions": [ 17 | "dbaeumer.vscode-eslint", 18 | "esbenp.prettier-vscode", 19 | "ZixuanChen.vitest-explorer", 20 | "streetsidesoftware.code-spell-checker", 21 | "github.vscode-pull-request-github" 22 | ] 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /examples/README.md: -------------------------------------------------------------------------------- 1 | # WebSocket 2 | 3 | This example demonstrates how to use the `graphql-ws` package to enable WebSockets in Apollo Server via `h3`. 4 | It is based on the [Apollo Server WebSocket example](https://www.apollographql.com/docs/apollo-server/data/subscriptions#basic-runnable-example). 5 | 6 | Run the following command to start the server and open the Apollo Sandbox in the browser: 7 | 8 | ```sh 9 | pnpm example:websocket 10 | ``` 11 | 12 | The server is configured to listen for WebSocket connections on the `/ws` path and to serve the Apollo Sandbox (and the GraphQL http endpoint) on the `/ws` path. (It is currently not possible to serve both the WebSocket and the HTTP endpoint on the root path, see [this h3 issue](https://github.com/unjs/h3/issues/719).) 13 | 14 | Then test the WebSocket connection by running the following query: 15 | 16 | ```graphql 17 | subscription Subscription { 18 | numberIncremented 19 | } 20 | ``` 21 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 - Tobias Diez 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /examples/simple.ts: -------------------------------------------------------------------------------- 1 | import { createApp } from 'h3' 2 | import { ApolloServer } from '@apollo/server' 3 | import { startServerAndCreateH3Handler } from '../src' 4 | 5 | const typeDefs = `#graphql 6 | # This "Book" type defines the queryable fields for every book in our data source. 7 | type Book { 8 | title: String 9 | author: String 10 | } 11 | 12 | # The "Query" type is special: it lists all of the available queries that 13 | # clients can execute, along with the return type for each. In this 14 | # case, the "books" query returns an array of zero or more Books (defined above). 15 | type Query { 16 | books: [Book] 17 | } 18 | ` 19 | 20 | // Resolvers define how to fetch the types defined in your schema. 21 | // This resolver returns simply a static list of books 22 | const resolvers = { 23 | Query: { 24 | books: () => [ 25 | { 26 | title: 'The Awakening', 27 | author: 'Kate Chopin', 28 | }, 29 | { 30 | title: 'City of Glass', 31 | author: 'Paul Auster', 32 | }, 33 | ], 34 | }, 35 | } 36 | 37 | const apollo = new ApolloServer({ 38 | typeDefs, 39 | resolvers, 40 | }) 41 | 42 | export const app = createApp() 43 | app.use('.', startServerAndCreateH3Handler(apollo, {})) 44 | -------------------------------------------------------------------------------- /renovate.json5: -------------------------------------------------------------------------------- 1 | { 2 | extends: [ 3 | 'config:best-practices', 4 | ':semanticCommitTypeAll(chore)', 5 | // Update lock files: https://docs.renovatebot.com/presets-default/#maintainlockfilesmonthly 6 | ':maintainLockFilesMonthly', 7 | // Automerge all updates once they pass tests: https://docs.renovatebot.com/presets-default/#automergeall 8 | ':automergeAll', 9 | // Always widen peer dependency constraints: https://docs.renovatebot.com/presets-default/#widenpeerdependencies 10 | ':widenPeerDependencies', 11 | // Disable dashboard: https://docs.renovatebot.com/key-concepts/dashboard/ 12 | ':disableDependencyDashboard', 13 | // Pin Github Actions versions: https://docs.renovatebot.com/presets-helpers/#helperspingithubactiondigeststosemver 14 | 'helpers:pinGitHubActionDigestsToSemver', 15 | ], 16 | schedule: [ 17 | // Monthly, but give a 3-day window (due to throttling not all PRs may be created on the same day): https://docs.renovatebot.com/configuration-options/#schedule 18 | 'on the 2nd through 5th day of the month', 19 | ], 20 | // Always squash PRs: https://docs.renovatebot.com/configuration-options/#automergestrategy 21 | automergeStrategy: 'squash', 22 | // Pin all dependencies: https://docs.renovatebot.com/dependency-pinning/ 23 | rangeStrategy: 'pin', 24 | } 25 | -------------------------------------------------------------------------------- /test/integration.test.ts: -------------------------------------------------------------------------------- 1 | import { 2 | CreateServerForIntegrationTestsOptions, 3 | defineIntegrationTestSuite, 4 | } from '@apollo/server-integration-testsuite' 5 | import { createApp, toNodeListener } from 'h3' 6 | import { ApolloServer, ApolloServerOptions, BaseContext } from '@apollo/server' 7 | import { startServerAndCreateH3Handler } from '../src' 8 | import { createServer, Server } from 'node:http' 9 | import { AddressInfo } from 'node:net' 10 | import { format } from 'node:url' 11 | import { describe, it, expect } from '@jest/globals' 12 | 13 | describe('integration:apollo-server-h3', () => { 14 | it('says hello', () => { 15 | expect(1).toBe(1) 16 | }) 17 | }) 18 | defineIntegrationTestSuite( 19 | async ( 20 | serverOptions: ApolloServerOptions, 21 | testOptions?: CreateServerForIntegrationTestsOptions, 22 | ) => { 23 | const app = createApp() 24 | const apollo = new ApolloServer({ 25 | ...serverOptions, 26 | }) 27 | app.use( 28 | '/', 29 | startServerAndCreateH3Handler(apollo, { 30 | context: testOptions?.context, 31 | }), 32 | ) 33 | 34 | const httpServer = createServer(toNodeListener(app)) 35 | await new Promise((resolve) => { 36 | httpServer.listen({ port: 0 }, resolve) 37 | }) 38 | 39 | return { 40 | server: apollo, 41 | url: urlForHttpServer(httpServer), 42 | async extraCleanup() { 43 | await new Promise((resolve) => { 44 | httpServer.close(() => resolve()) 45 | }) 46 | }, 47 | } 48 | }, 49 | { 50 | serverIsStartedInBackground: true, 51 | noIncrementalDelivery: true, 52 | }, 53 | ) 54 | 55 | // Stolen from apollo server integration tests 56 | export function urlForHttpServer(httpServer: Server): string { 57 | const { address, port } = httpServer.address() as AddressInfo 58 | 59 | // Convert IPs which mean "any address" (IPv4 or IPv6) into localhost 60 | // corresponding loopback ip. Note that the url field we're setting is 61 | // primarily for consumption by our test suite. If this heuristic is wrong for 62 | // your use case, explicitly specify a frontend host (in the `host` option 63 | // when listening). 64 | const hostname = address === '' || address === '::' ? 'localhost' : address 65 | 66 | return format({ 67 | protocol: 'http', 68 | hostname, 69 | port, 70 | pathname: '/', 71 | }) 72 | } 73 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@as-integrations/h3", 3 | "version": "2.0.0", 4 | "description": "An Apollo Server integration for use with h3 or Nuxt", 5 | "repository": "github:apollo-server-integrations/apollo-server-integration-h3", 6 | "license": "MIT", 7 | "sideEffects": false, 8 | "type": "module", 9 | "exports": { 10 | ".": { 11 | "types": "./dist/index.d.ts", 12 | "import": "./dist/index.mjs", 13 | "require": "./dist/index.cjs" 14 | }, 15 | "./websocket": { 16 | "types": "./dist/websocket.d.ts", 17 | "import": "./dist/websocket.mjs", 18 | "require": "./dist/websocket.cjs" 19 | } 20 | }, 21 | "main": "./dist/index.cjs", 22 | "module": "./dist/index.mjs", 23 | "types": "./dist/index.d.ts", 24 | "files": [ 25 | "dist" 26 | ], 27 | "scripts": { 28 | "dev:prepare": "unbuild --stub", 29 | "build": "unbuild", 30 | "test": "vitest dev", 31 | "test:integration": "jest", 32 | "test:types": "tsc --noEmit --skipLibCheck", 33 | "lint": "pnpm lint:eslint && pnpm lint:prettier", 34 | "lint:eslint": "eslint --report-unused-disable-directives .", 35 | "lint:prettier": "prettier --check --ignore-path .gitignore . '!pnpm-lock.yaml'", 36 | "example:simple": "listhen -w --open ./examples/simple.ts", 37 | "example:websocket": "listhen -w --ws --open ./examples/websocket.ts", 38 | "prepack": "unbuild", 39 | "release": "pnpm test && standard-version && git push --follow-tags && pnpm publish" 40 | }, 41 | "peerDependencies": { 42 | "@apollo/server": "^4.1.1 || ^5.0.0", 43 | "crossws": "^0.3.0", 44 | "graphql": "^16.0.0", 45 | "graphql-ws": "^5.0.0 || ^6.0.0", 46 | "h3": "^1.11.0" 47 | }, 48 | "peerDependenciesMeta": { 49 | "graphql-ws": { 50 | "optional": true 51 | } 52 | }, 53 | "dependencies": { 54 | "@apollo/utils.withrequired": "3.0.0" 55 | }, 56 | "devDependencies": { 57 | "@apollo/server": "5.2.0", 58 | "@apollo/server-integration-testsuite": "5.2.0", 59 | "@graphql-tools/schema": "10.0.30", 60 | "@jest/globals": "30.2.0", 61 | "@typescript-eslint/parser": "8.48.1", 62 | "@vitest/coverage-v8": "4.0.15", 63 | "commit-and-tag-version": "12.6.1", 64 | "crossws": "0.3.5", 65 | "eslint": "9.39.1", 66 | "eslint-config-prettier": "10.1.8", 67 | "eslint-config-unjs": "0.5.0", 68 | "eslint-plugin-unused-imports": "4.3.0", 69 | "graphql": "16.12.0", 70 | "graphql-subscriptions": "3.0.0", 71 | "graphql-ws": "6.0.6", 72 | "h3": "1.15.4", 73 | "jest": "30.2.0", 74 | "listhen": "1.9.0", 75 | "prettier": "3.7.3", 76 | "ts-jest": "29.4.6", 77 | "typescript": "5.9.3", 78 | "unbuild": "3.6.1", 79 | "vitest": "4.0.15" 80 | }, 81 | "packageManager": "pnpm@10.24.0", 82 | "engines": { 83 | "node": "24.11.1" 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | on: 2 | push: 3 | branches: 4 | - main 5 | name: release 6 | permissions: 7 | contents: write 8 | pull-requests: write 9 | jobs: 10 | release-pr: 11 | runs-on: ubuntu-latest 12 | outputs: 13 | release_created: ${{ steps.release.outputs.release_created }} 14 | steps: 15 | - uses: googleapis/release-please-action@16a9c90856f42705d54a6fda1823352bdc62cf38 # v4.4.0 16 | id: release 17 | with: 18 | token: ${{ secrets.RELEASE_PR_TOKEN }} 19 | 20 | # Format changelog, workaround for https://github.com/google-github-actions/release-please-action/issues/542 21 | # Taken from https://github.com/remarkablemark/release-please-extra-files-demo/blob/master/.github/workflows/release-please.yml 22 | - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 23 | if: ${{ steps.release.outputs.pr }} 24 | with: 25 | token: ${{ secrets.RELEASE_PR_TOKEN }} 26 | fetch-depth: 0 27 | ref: ${{ fromJson(steps.release.outputs.pr).headBranchName }} 28 | 29 | - name: Configure Git user 30 | if: ${{ steps.release.outputs.pr }} 31 | run: | 32 | git config --global user.name 'github-actions[bot]' 33 | git config --global user.email 'github-actions[bot]@users.noreply.github.com' 34 | git --no-pager show --name-only 35 | 36 | - name: Format CHANGELOG.md 37 | if: ${{ steps.release.outputs.pr }} 38 | run: npx prettier --write CHANGELOG.md .release-please-manifest.json 39 | 40 | - name: Commit 41 | if: ${{ steps.release.outputs.pr }} 42 | run: | 43 | git add CHANGELOG.md .release-please-manifest.json 44 | git commit -m 'chore: Format CHANGELOG.md with Prettier' --no-verify 45 | 46 | - name: Push changes 47 | if: ${{ steps.release.outputs.pr }} 48 | uses: ad-m/github-push-action@master 49 | with: 50 | github_token: ${{ secrets.RELEASE_PR_TOKEN }} 51 | branch: ${{ fromJson(steps.release.outputs.pr).headBranchName }} 52 | 53 | publish_npm: 54 | name: Publish to npm 55 | runs-on: ubuntu-latest 56 | needs: [release-pr] 57 | if: needs.release-pr.outputs.release_created 58 | steps: 59 | - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 60 | - run: corepack enable 61 | - uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6.1.0 62 | with: 63 | node-version-file: package.json 64 | cache: 'pnpm' 65 | - name: Install dependencies 66 | run: pnpm install 67 | - name: Config npm 68 | run: echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > .npmrc 69 | env: 70 | NPM_TOKEN: ${{ secrets.NPM_TOKEN }} 71 | - name: Publish to npm 72 | run: pnpm publish --access public --no-git-checks 73 | -------------------------------------------------------------------------------- /examples/websocket.ts: -------------------------------------------------------------------------------- 1 | // This is an adaption of the "official" example of how to use subscriptions with Apollo server 2 | // https://github.com/apollographql/docs-examples/tree/main/apollo-server/v4/subscriptions-graphql-ws 3 | import { ApolloServer } from '@apollo/server' 4 | import { PubSub } from 'graphql-subscriptions' 5 | import { createApp, defineWebSocketHandler } from 'h3' 6 | import { startServerAndCreateH3Handler } from '../src' 7 | import { defineGraphqlWebSocket } from '../src/websocket' 8 | import { makeExecutableSchema } from '@graphql-tools/schema' 9 | import { ApolloServerPluginLandingPageLocalDefault } from '@apollo/server/plugin/landingPage/default' 10 | 11 | const pubsub = new PubSub() 12 | 13 | // A number that we'll increment over time to simulate subscription events 14 | let currentNumber = 0 15 | 16 | // Schema definition 17 | const typeDefs = `#graphql 18 | type Query { 19 | currentNumber: Int 20 | } 21 | 22 | type Subscription { 23 | numberIncremented: Int 24 | } 25 | ` 26 | 27 | // Resolver map 28 | const resolvers = { 29 | Query: { 30 | currentNumber() { 31 | return currentNumber 32 | }, 33 | }, 34 | Subscription: { 35 | numberIncremented: { 36 | subscribe: () => pubsub.asyncIterableIterator(['NUMBER_INCREMENTED']), 37 | }, 38 | }, 39 | } 40 | 41 | // Create schema, which will be used separately by ApolloServer and 42 | // the WebSocket server. 43 | const schema = makeExecutableSchema({ typeDefs, resolvers }) 44 | 45 | // Create an h3 app; we will attach the WebSocket 46 | // server and the ApolloServer to it. 47 | export const app = createApp() 48 | 49 | // Set up ApolloServer. 50 | const apollo = new ApolloServer({ 51 | schema, 52 | plugins: [ 53 | ApolloServerPluginLandingPageLocalDefault({ 54 | // This is needed to be able to change the ws endpoint 55 | embed: { endpointIsEditable: true }, 56 | }), 57 | ], 58 | }) 59 | 60 | //app.use('/', startServerAndCreateH3Handler(apollo)) 61 | app.use( 62 | // TODO: For some reason it doesn't work with the root path 63 | // see discussion at https://github.com/unjs/h3/issues/719 64 | '/ws', 65 | startServerAndCreateH3Handler(apollo, { 66 | websocket: { 67 | ...defineGraphqlWebSocket({ schema }), 68 | error(peer, error) { 69 | console.error('[ws] error', peer, error) 70 | // In a real app, you would want to properly log this error 71 | }, 72 | // For debugging: 73 | // message(peer, message) { 74 | // console.error('[ws] message', peer, message) 75 | // }, 76 | // open(peer) { 77 | // console.error('[ws] open', peer) 78 | // }, 79 | // upgrade(req) { 80 | // console.error('[ws] upgrade', req) 81 | // }, 82 | // close(peer, details) { 83 | // console.error('[ws] close', peer, details) 84 | // } 85 | }, 86 | }), 87 | ) 88 | 89 | // Alternatively, you can use the following to define only the WebSocket server without ApolloServer. 90 | app.use( 91 | '/_ws', 92 | defineWebSocketHandler({ 93 | ...defineGraphqlWebSocket({ schema }), 94 | error(peer, error) { 95 | console.log('[ws] error', peer, error) 96 | }, 97 | }), 98 | ) 99 | 100 | // In the background, increment a number every second and notify subscribers when it changes. 101 | function incrementNumber() { 102 | currentNumber++ 103 | pubsub 104 | .publish('NUMBER_INCREMENTED', { numberIncremented: currentNumber }) 105 | .catch(console.error) 106 | setTimeout(incrementNumber, 1000) 107 | } 108 | 109 | // Start incrementing 110 | incrementNumber() 111 | -------------------------------------------------------------------------------- /src/index.ts: -------------------------------------------------------------------------------- 1 | import type { 2 | ApolloServer, 3 | BaseContext, 4 | ContextFunction, 5 | HTTPGraphQLRequest, 6 | } from '@apollo/server' 7 | import { HeaderMap } from '@apollo/server' 8 | import { Hooks } from 'crossws' 9 | import { 10 | eventHandler, 11 | EventHandler, 12 | getHeaders, 13 | H3Event, 14 | HTTPMethod, 15 | isMethod, 16 | setHeaders, 17 | readBody, 18 | RequestHeaders, 19 | } from 'h3' 20 | import type { WithRequired } from '@apollo/utils.withrequired' 21 | 22 | export interface H3ContextFunctionArgument { 23 | event: H3Event 24 | } 25 | 26 | export interface H3HandlerOptions { 27 | context?: ContextFunction<[H3ContextFunctionArgument], TContext> 28 | websocket?: Partial 29 | } 30 | 31 | export function startServerAndCreateH3Handler( 32 | server: ApolloServer, 33 | options?: H3HandlerOptions, 34 | ): EventHandler 35 | export function startServerAndCreateH3Handler( 36 | server: ApolloServer, 37 | options: WithRequired, 'context'>, 38 | ): EventHandler 39 | export function startServerAndCreateH3Handler( 40 | server: ApolloServer, 41 | options?: H3HandlerOptions, 42 | ): EventHandler { 43 | server.startInBackgroundHandlingStartupErrorsByLoggingAndFailingAllRequests() 44 | 45 | const defaultContext: ContextFunction< 46 | [H3ContextFunctionArgument], 47 | any 48 | > = () => Promise.resolve({}) 49 | 50 | const contextFunction: ContextFunction< 51 | [H3ContextFunctionArgument], 52 | TContext 53 | > = options?.context ?? defaultContext 54 | 55 | return eventHandler({ 56 | async handler(event) { 57 | // Apollo-server doesn't handle OPTIONS calls, so we have to do this on our own 58 | // https://github.com/apollographql/apollo-server/blob/fa82c1d5299c4803f9ef8ae7fa2e367eadd8c0e6/packages/server/src/runHttpQuery.ts#L182-L192 59 | if (isMethod(event, 'OPTIONS')) { 60 | // send 204 response 61 | // eslint-disable-next-line unicorn/no-null 62 | return null 63 | } 64 | 65 | try { 66 | const graphqlRequest = await toGraphqlRequest(event) 67 | const { body, headers, status } = 68 | await server.executeHTTPGraphQLRequest({ 69 | httpGraphQLRequest: graphqlRequest, 70 | context: () => contextFunction({ event }), 71 | }) 72 | 73 | if (body.kind === 'chunked') { 74 | throw new Error('Incremental delivery not implemented') 75 | } 76 | 77 | setHeaders(event, Object.fromEntries(headers)) 78 | event.res.statusCode = status || 200 79 | return body.string 80 | } catch (error) { 81 | if (error instanceof SyntaxError) { 82 | // This is what the apollo test suite expects 83 | event.res.statusCode = 400 84 | return error.message 85 | } else { 86 | throw error 87 | } 88 | } 89 | }, 90 | websocket: options?.websocket, 91 | }) 92 | } 93 | 94 | async function toGraphqlRequest(event: H3Event): Promise { 95 | return { 96 | method: event.req.method || 'POST', 97 | headers: normalizeHeaders(getHeaders(event)), 98 | search: normalizeQueryString(event.req.url), 99 | body: await normalizeBody(event), 100 | } 101 | } 102 | 103 | function normalizeHeaders(headers: RequestHeaders): HeaderMap { 104 | const headerMap = new HeaderMap() 105 | for (const [key, value] of Object.entries(headers)) { 106 | if (Array.isArray(value)) { 107 | headerMap.set(key, value.join(',')) 108 | } else if (value) { 109 | headerMap.set(key, value) 110 | } 111 | } 112 | return headerMap 113 | } 114 | 115 | function normalizeQueryString(url: string | undefined): string { 116 | if (!url) { 117 | return '' 118 | } 119 | return url.split('?')[1] || '' 120 | } 121 | 122 | async function normalizeBody(event: H3Event): Promise { 123 | const PayloadMethods: HTTPMethod[] = ['PATCH', 'POST', 'PUT', 'DELETE'] 124 | if (isMethod(event, PayloadMethods)) { 125 | return await readBody(event) 126 | } 127 | } 128 | -------------------------------------------------------------------------------- /src/websocket.ts: -------------------------------------------------------------------------------- 1 | import { 2 | makeServer, 3 | DEPRECATED_GRAPHQL_WS_PROTOCOL, 4 | CloseCode, 5 | ServerOptions, 6 | ConnectionInitMessage, 7 | } from 'graphql-ws' 8 | import { 9 | defineWebSocket, 10 | defineWebSocketHandler, 11 | EventHandler, 12 | EventHandlerRequest, 13 | } from 'h3' 14 | // TODO: Import from h3 once it's exposed there 15 | // Then also remove the explicit reference to crossws as a dependency in package.json 16 | // https://github.com/unjs/h3/issues/716 17 | import type { Hooks, Peer } from 'crossws' 18 | 19 | /** 20 | * The extra that will be put in the `Context`. 21 | * 22 | * @category Server/h3 23 | */ 24 | export interface Extra { 25 | /** 26 | * The underlying WebSocket peer. 27 | */ 28 | readonly peer: Peer 29 | } 30 | 31 | /** 32 | * Graphql-ws interface is designed to work well for the case where the WebSocket server 33 | * exposes hooks per connection, but h3 only exposes hooks per server. 34 | * This is a workaround to make it work with h3. 35 | */ 36 | interface Client { 37 | handleMessage: (data: string) => Promise 38 | closed: (code?: number, reason?: string) => Promise 39 | } 40 | 41 | /** 42 | * Create the WebSocket hooks to be used with [h3](https://h3.unjs.io/). 43 | * 44 | * Use this over {@link defineGraphqlWebSocketHandler} if you need more control over the WebSocket server or 45 | * if you want to add custom hooks (e.g. for authentication or logging). 46 | */ 47 | export function defineGraphqlWebSocket< 48 | P extends ConnectionInitMessage['payload'] = ConnectionInitMessage['payload'], 49 | E extends Record = Record, 50 | >(options: ServerOptions>): Partial { 51 | const server = makeServer(options) 52 | const peers = new WeakMap() 53 | return defineWebSocket({ 54 | open(peer) { 55 | const client: Client = { 56 | handleMessage: () => { 57 | throw new Error('Message received before handler was registered') 58 | }, 59 | closed: () => { 60 | throw new Error('Closed before handler was registered') 61 | }, 62 | } 63 | 64 | client.closed = server.opened( 65 | { 66 | protocol: peer.request.headers?.get('Sec-WebSocket-Protocol') ?? '', 67 | send: (message) => { 68 | // The peer might have been destroyed in the meantime, send only if exists 69 | if (peers.has(peer)) { 70 | peer.send(message) 71 | } 72 | }, 73 | close: (code, reason) => { 74 | if (peers.has(peer)) { 75 | peer.close(code, reason) 76 | } 77 | }, 78 | onMessage: (cb) => (client.handleMessage = cb), 79 | }, 80 | { peer } as Extra & Partial, 81 | ) 82 | peers.set(peer, client) 83 | }, 84 | message(peer, message) { 85 | const client = peers.get(peer) 86 | if (!client) throw new Error('Message received for a missing client') 87 | return client.handleMessage(message.text()) 88 | }, 89 | close(peer, details) { 90 | const client = peers.get(peer) 91 | if (!client) throw new Error('Closing a missing client') 92 | const upgradeProtocol = peer.request.headers?.get( 93 | 'Sec-WebSocket-Protocol', 94 | ) 95 | if ( 96 | details.code === CloseCode.SubprotocolNotAcceptable && 97 | upgradeProtocol === DEPRECATED_GRAPHQL_WS_PROTOCOL 98 | ) 99 | console.warn( 100 | `Client provided the unsupported and deprecated subprotocol "${upgradeProtocol}" used by subscriptions-transport-ws.` + 101 | 'Please see https://www.apollographql.com/docs/apollo-server/data/subscriptions/#switching-from-subscriptions-transport-ws.', 102 | ) 103 | return client.closed(details.code, details.reason) 104 | }, 105 | }) 106 | } 107 | /** 108 | * Create a event handler to be used with [h3](https://h3.unjs.io/). 109 | * 110 | * @category Server/h3 111 | */ 112 | export async function defineGraphqlWebSocketHandler< 113 | P extends ConnectionInitMessage['payload'] = ConnectionInitMessage['payload'], 114 | E extends Record = Record, 115 | >( 116 | options: ServerOptions>, 117 | ): Promise> { 118 | return defineWebSocketHandler(defineGraphqlWebSocket(options)) 119 | } 120 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Apollo Server integration for h3 and nuxt 2 | 3 | [![npm version][npm-version-src]][npm-version-href] 4 | [![npm downloads][npm-downloads-src]][npm-downloads-href] 5 | [![Github Actions][github-actions-src]][github-actions-href] 6 | [![Codecov][codecov-src]][codecov-href] 7 | 8 | This 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. 9 | 10 | > 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). 11 | 12 | ## Installation 13 | 14 | ```sh 15 | # npm 16 | npm install @apollo/server graphql @as-integrations/h3 17 | 18 | # yarn 19 | yarn add @apollo/server graphql @as-integrations/h3 20 | 21 | # pnpm 22 | pnpm add @apollo/server graphql @as-integrations/h3 23 | ``` 24 | 25 | ## Usage with Nuxt v3 26 | 27 | Create 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: 28 | 29 | ```js 30 | import { ApolloServer } from '@apollo/server' 31 | import { startServerAndCreateH3Handler } from '@as-integrations/h3' 32 | 33 | const apollo = new ApolloServer({ 34 | // Specify server options like schema and resolvers here 35 | }) 36 | 37 | export default startServerAndCreateH3Handler(apollo, { 38 | // Optional: Specify context 39 | context: (event) => { 40 | /*...*/ 41 | }, 42 | }) 43 | ``` 44 | 45 | ## Usage with h3 46 | 47 | Create 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. 48 | 49 | ```js 50 | import { createApp } from 'h3' 51 | import { ApolloServer } from '@apollo/server' 52 | import { startServerAndCreateH3Handler } from '@as-integrations/h3' 53 | 54 | const apollo = new ApolloServer({ 55 | // Specify server options like schema and resolvers here 56 | }) 57 | 58 | export const app = createApp() 59 | app.use( 60 | '/api', 61 | startServerAndCreateH3Handler(apollo, { 62 | // Optional: Specify context 63 | context: (event) => { 64 | /*...*/ 65 | }, 66 | }), 67 | ) 68 | ``` 69 | 70 | Then run your h3 server as usual, e.g. with `npx --yes listhen -w --open ./app.ts`. 71 | Visit http://localhost:3000/api in your browser to access the Apollo Sandbox. 72 | 73 | ## Subscriptions with WebSockets 74 | 75 | This package also supports subscriptions over WebSockets. To enable this feature, you need to install the `graphql-ws` package: 76 | 77 | ```sh 78 | # npm 79 | npm install graphql-ws 80 | 81 | # yarn 82 | yarn add graphql-ws 83 | 84 | # pnpm 85 | pnpm add graphql-ws 86 | ``` 87 | 88 | Then 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. 89 | 90 | ```js 91 | import { createApp } from 'h3' 92 | import { ApolloServer } from '@apollo/server' 93 | import { startServerAndCreateH3Handler } from '@as-integrations/h3' 94 | import { defineGraphqlWebSocketHandler } from '@as-integrations/h3/websocket' 95 | import { makeExecutableSchema } from '@graphql-tools/schema' 96 | 97 | // Define your schema and resolvers 98 | const typeDefs = `...` 99 | const resolvers = { 100 | /*...*/ 101 | } 102 | const schema = makeExecutableSchema({ typeDefs, resolvers }) 103 | 104 | const apollo = new ApolloServer({ schema }) 105 | 106 | export const app = createApp() 107 | app.use( 108 | '/api', 109 | startServerAndCreateH3Handler(apollo, { 110 | websocket: defineGraphqlWebSocketHandler({ schema }), 111 | }), 112 | ) 113 | ``` 114 | 115 | Then you can connect to the WebSocket endpoint using the Apollo Sandbox or any other client that supports the `graphql-ws` protocol. 116 | 117 | See the [WebSocket example](./examples/websocket.ts) for a complete example. 118 | 119 | ## 💻 Development 120 | 121 | - Clone this repository 122 | - Enable [Corepack](https://github.com/nodejs/corepack) using `corepack enable` (use `npm i -g corepack` for Node.js < 16.10). 123 | - Install dependencies using `pnpm install`. 124 | - Run tests using `pnpm test` and integration tests via `pnpm test:integration`. 125 | 126 | ## License 127 | 128 | Made with 💛 129 | 130 | Published under [MIT License](./LICENSE). 131 | 132 | 133 | 134 | [npm-version-src]: https://img.shields.io/npm/v/@as-integrations/h3?style=flat-square 135 | [npm-version-href]: https://npmjs.com/package/@as-integrations/h3 136 | [npm-downloads-src]: https://img.shields.io/npm/dm/@as-integrations/h3?style=flat-square 137 | [npm-downloads-href]: https://npmjs.com/package/@as-integrations/h3 138 | [github-actions-src]: https://img.shields.io/github/workflow/status/apollo-server-integrations/apollo-server-integration-h3/ci/main?style=flat-square 139 | [github-actions-href]: https://github.com/apollo-server-integrations/apollo-server-integration-h3/actions?query=workflow%3Aci 140 | [codecov-src]: https://img.shields.io/codecov/c/gh/apollo-server-integrations/apollo-server-integration-h3/main?style=flat-square 141 | [codecov-href]: https://codecov.io/gh/apollo-server-integrations/apollo-server-integration-h3 142 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## [2.0.0](https://github.com/apollo-server-integrations/apollo-server-integration-h3/compare/v1.2.1...v2.0.0) (2025-03-19) 4 | 5 | ### ⚠ BREAKING CHANGES 6 | 7 | - exclude websocket features from main entry file ([#125](https://github.com/apollo-server-integrations/apollo-server-integration-h3/issues/125)) 8 | 9 | ### 🔖 Features 10 | 11 | - improve ws protocol and closure handling ([#123](https://github.com/apollo-server-integrations/apollo-server-integration-h3/issues/123)) ([f79bf78](https://github.com/apollo-server-integrations/apollo-server-integration-h3/commit/f79bf78347460042365b55cb222371ce34813ee3)) 12 | - use `WithRequired` from `@apollo/utils.withrequired` ([#12](https://github.com/apollo-server-integrations/apollo-server-integration-h3/issues/12)) ([7a83402](https://github.com/apollo-server-integrations/apollo-server-integration-h3/commit/7a83402a8bc19a82f73b920d75a9359f46c3b23f)) 13 | 14 | ### 🐛 Bug Fixes 15 | 16 | - don't fail if graphql-ws is not installed ([#79](https://github.com/apollo-server-integrations/apollo-server-integration-h3/issues/79)) ([6907a36](https://github.com/apollo-server-integrations/apollo-server-integration-h3/commit/6907a3632f965151c8fd002b2b64dd9a056e7600)) 17 | - exclude websocket features from main entry file ([#125](https://github.com/apollo-server-integrations/apollo-server-integration-h3/issues/125)) ([62a2088](https://github.com/apollo-server-integrations/apollo-server-integration-h3/commit/62a2088ed1cf50eaf8fadce46ac9b216aa232f0b)) 18 | - make code and reason for ws close event optional ([#85](https://github.com/apollo-server-integrations/apollo-server-integration-h3/issues/85)) ([d2ccc86](https://github.com/apollo-server-integrations/apollo-server-integration-h3/commit/d2ccc86fb4259aaba1e36cf9f505a802babdb058)) 19 | 20 | ### 🧹 Miscellaneous 21 | 22 | - **deps:** lock file maintenance ([#110](https://github.com/apollo-server-integrations/apollo-server-integration-h3/issues/110)) ([406f9ec](https://github.com/apollo-server-integrations/apollo-server-integration-h3/commit/406f9ec6a421dd472f92dccc46382e56f492827b)) 23 | - **deps:** pin dependencies ([#113](https://github.com/apollo-server-integrations/apollo-server-integration-h3/issues/113)) ([190bc14](https://github.com/apollo-server-integrations/apollo-server-integration-h3/commit/190bc144e3296e1284aeb41af4d4a93ad683622c)) 24 | - **deps:** pin dependencies ([#114](https://github.com/apollo-server-integrations/apollo-server-integration-h3/issues/114)) ([ef1eeda](https://github.com/apollo-server-integrations/apollo-server-integration-h3/commit/ef1eeda7ac012f9ceb5ce4df2842d23bc557f3fb)) 25 | - **deps:** pin node.js to 23.9.0 ([#115](https://github.com/apollo-server-integrations/apollo-server-integration-h3/issues/115)) ([279d0cb](https://github.com/apollo-server-integrations/apollo-server-integration-h3/commit/279d0cb59849935b983e64bebe2544d585c8a185)) 26 | - **deps:** replace dependency standard-version with commit-and-tag-version 9.5.0 ([#112](https://github.com/apollo-server-integrations/apollo-server-integration-h3/issues/112)) ([64247c8](https://github.com/apollo-server-integrations/apollo-server-integration-h3/commit/64247c8d6754ce2b8c5e67a57b0babfd667e296a)) 27 | - **deps:** update all non-major dependencies ([1138b13](https://github.com/apollo-server-integrations/apollo-server-integration-h3/commit/1138b13cece33e4be6224d880143839f6023583f)) 28 | - **deps:** update all non-major dependencies ([4a6689e](https://github.com/apollo-server-integrations/apollo-server-integration-h3/commit/4a6689e45dfd59295162748deeeeebcae5f97a3b)) 29 | - **deps:** update all non-major dependencies ([ff07953](https://github.com/apollo-server-integrations/apollo-server-integration-h3/commit/ff079534c43bd7cee926fcf38ebf0e437fcf6b40)) 30 | - **deps:** update all non-major dependencies ([c2c912d](https://github.com/apollo-server-integrations/apollo-server-integration-h3/commit/c2c912db7f070fe674738aef4c2b3baad9c15a56)) 31 | - **deps:** update all non-major dependencies ([#100](https://github.com/apollo-server-integrations/apollo-server-integration-h3/issues/100)) ([29741f0](https://github.com/apollo-server-integrations/apollo-server-integration-h3/commit/29741f04fcf243a2e573aa1c1e0d0d82b464ad2e)) 32 | - **deps:** update all non-major dependencies ([#101](https://github.com/apollo-server-integrations/apollo-server-integration-h3/issues/101)) ([3c4c4ed](https://github.com/apollo-server-integrations/apollo-server-integration-h3/commit/3c4c4ed35e730c1086d414f1c88a35f60c295f49)) 33 | - **deps:** update all non-major dependencies ([#105](https://github.com/apollo-server-integrations/apollo-server-integration-h3/issues/105)) ([e9e9fb6](https://github.com/apollo-server-integrations/apollo-server-integration-h3/commit/e9e9fb60464cd89dc9772a3eab46cd710403f8fd)) 34 | - **deps:** update all non-major dependencies ([#84](https://github.com/apollo-server-integrations/apollo-server-integration-h3/issues/84)) ([09bdae4](https://github.com/apollo-server-integrations/apollo-server-integration-h3/commit/09bdae4c330cf5e83080f9c16989f1638d997a6c)) 35 | - **deps:** update all non-major dependencies ([#86](https://github.com/apollo-server-integrations/apollo-server-integration-h3/issues/86)) ([36f47c7](https://github.com/apollo-server-integrations/apollo-server-integration-h3/commit/36f47c7e76a86cbdc8a3f840c14e079f7a520eb4)) 36 | - **deps:** update all non-major dependencies ([#88](https://github.com/apollo-server-integrations/apollo-server-integration-h3/issues/88)) ([d526715](https://github.com/apollo-server-integrations/apollo-server-integration-h3/commit/d5267151143295e6619ea522bc76d1d6d0452b31)) 37 | - **deps:** update all non-major dependencies ([#91](https://github.com/apollo-server-integrations/apollo-server-integration-h3/issues/91)) ([ce8f24f](https://github.com/apollo-server-integrations/apollo-server-integration-h3/commit/ce8f24f1dbc5adced3d51599b63cc52b96a5f207)) 38 | - **deps:** update all non-major dependencies ([#93](https://github.com/apollo-server-integrations/apollo-server-integration-h3/issues/93)) ([55e9dcd](https://github.com/apollo-server-integrations/apollo-server-integration-h3/commit/55e9dcd4d3445133fafef40123a7b58742d0356f)) 39 | - **deps:** update all non-major dependencies ([#95](https://github.com/apollo-server-integrations/apollo-server-integration-h3/issues/95)) ([f8e60e6](https://github.com/apollo-server-integrations/apollo-server-integration-h3/commit/f8e60e636f4c831e6f9b506bf50a584d8b43447d)) 40 | - **deps:** update all non-major dependencies ([#97](https://github.com/apollo-server-integrations/apollo-server-integration-h3/issues/97)) ([30a0b66](https://github.com/apollo-server-integrations/apollo-server-integration-h3/commit/30a0b66f91b23a79787a8b7ff20488f5fbab3d7c)) 41 | - **deps:** update all non-major dependencies ([#98](https://github.com/apollo-server-integrations/apollo-server-integration-h3/issues/98)) ([6346800](https://github.com/apollo-server-integrations/apollo-server-integration-h3/commit/6346800205df99420c6bf26725c4d61d801c7987)) 42 | - **deps:** update codecov/codecov-action action to v5 ([#94](https://github.com/apollo-server-integrations/apollo-server-integration-h3/issues/94)) ([1f37e41](https://github.com/apollo-server-integrations/apollo-server-integration-h3/commit/1f37e41c4dfb55180f464b269b93c571a21bede3)) 43 | - **deps:** update codecov/codecov-action digest to 0565863 ([#116](https://github.com/apollo-server-integrations/apollo-server-integration-h3/issues/116)) ([db07269](https://github.com/apollo-server-integrations/apollo-server-integration-h3/commit/db072697cfbb71fe6765df82d8edc51ee8040adc)) 44 | - **deps:** update dependency @graphql-tools/schema to v10.0.21 ([#122](https://github.com/apollo-server-integrations/apollo-server-integration-h3/issues/122)) ([f429fb3](https://github.com/apollo-server-integrations/apollo-server-integration-h3/commit/f429fb33dfb0d3c7b24fd984e2287079338e35bb)) 45 | - **deps:** update dependency @typescript-eslint/parser to v8.26.0 ([#121](https://github.com/apollo-server-integrations/apollo-server-integration-h3/issues/121)) ([25f980b](https://github.com/apollo-server-integrations/apollo-server-integration-h3/commit/25f980b37a13d5ca009530972a42d3d3f864d892)) 46 | - **deps:** update dependency commit-and-tag-version to v12 ([#119](https://github.com/apollo-server-integrations/apollo-server-integration-h3/issues/119)) ([31761c2](https://github.com/apollo-server-integrations/apollo-server-integration-h3/commit/31761c27776e8afe9ad2b778f6819d730f5f5828)) 47 | - **deps:** update dependency commit-and-tag-version to v9.6.0 ([#118](https://github.com/apollo-server-integrations/apollo-server-integration-h3/issues/118)) ([bbc8369](https://github.com/apollo-server-integrations/apollo-server-integration-h3/commit/bbc83699c07e0629bd8941f0a6e7100f66bf7598)) 48 | - **deps:** update dependency eslint-config-prettier to v10 ([#102](https://github.com/apollo-server-integrations/apollo-server-integration-h3/issues/102)) ([dfa97a0](https://github.com/apollo-server-integrations/apollo-server-integration-h3/commit/dfa97a0abc3aaac5549fd457e070b496cb58d369)) 49 | - **deps:** update dependency graphql-subscriptions to v3 ([#92](https://github.com/apollo-server-integrations/apollo-server-integration-h3/issues/92)) ([b789bea](https://github.com/apollo-server-integrations/apollo-server-integration-h3/commit/b789bea9ed4355838ea716ef916cdcee75b6a39d)) 50 | - **deps:** update dependency graphql-ws to v6 ([#103](https://github.com/apollo-server-integrations/apollo-server-integration-h3/issues/103)) ([7182753](https://github.com/apollo-server-integrations/apollo-server-integration-h3/commit/718275312ddacb1e3c744aab0e7d9e6d0c30676d)) 51 | - **deps:** update dependency prettier to v3.5.3 ([#120](https://github.com/apollo-server-integrations/apollo-server-integration-h3/issues/120)) ([e32b158](https://github.com/apollo-server-integrations/apollo-server-integration-h3/commit/e32b158ea5b14d6c98520d57cf77fe382c5a8e86)) 52 | - **deps:** update dependency unbuild to v3 ([#99](https://github.com/apollo-server-integrations/apollo-server-integration-h3/issues/99)) ([c789f70](https://github.com/apollo-server-integrations/apollo-server-integration-h3/commit/c789f703d2ef683dedc92556b6a7a938bf29075d)) 53 | - **deps:** update devdependency @typescript-eslint/parser to v8 ([#83](https://github.com/apollo-server-integrations/apollo-server-integration-h3/issues/83)) ([071519f](https://github.com/apollo-server-integrations/apollo-server-integration-h3/commit/071519ffaa11aef56ec82d1857b4039ca9fabae6)) 54 | - **deps:** update devdependency eslint to ^9.13.0 ([389d2e0](https://github.com/apollo-server-integrations/apollo-server-integration-h3/commit/389d2e02fac9a1372026e50bd383359451357de6)) 55 | - **deps:** update pnpm to v10 ([#106](https://github.com/apollo-server-integrations/apollo-server-integration-h3/issues/106)) ([9547cf2](https://github.com/apollo-server-integrations/apollo-server-integration-h3/commit/9547cf2b52a1f487d673c3aa1383a14fe284a08b)) 56 | - **deps:** update pnpm to v10.5.2 ([#117](https://github.com/apollo-server-integrations/apollo-server-integration-h3/issues/117)) ([6962a96](https://github.com/apollo-server-integrations/apollo-server-integration-h3/commit/6962a96550bbe4026c91eeea728e5f90e6cc70a6)) 57 | - **deps:** update vitest monorepo to v3 ([#104](https://github.com/apollo-server-integrations/apollo-server-integration-h3/issues/104)) ([726eeaa](https://github.com/apollo-server-integrations/apollo-server-integration-h3/commit/726eeaafd3c2b90b5eac02cd50fd7ffc3a49d5f1)) 58 | - fix CI by using `pnpm/action-setup` in place of corepack ([#108](https://github.com/apollo-server-integrations/apollo-server-integration-h3/issues/108)) ([894ae6c](https://github.com/apollo-server-integrations/apollo-server-integration-h3/commit/894ae6c7c3f3f7ea5da70ab84a923bd27c785bba)) 59 | - update renovate config ([#109](https://github.com/apollo-server-integrations/apollo-server-integration-h3/issues/109)) ([8d9e75f](https://github.com/apollo-server-integrations/apollo-server-integration-h3/commit/8d9e75f9d195536ea4c35c8a5f227a98ad61389e)) 60 | 61 | ## [1.2.1](https://github.com/apollo-server-integrations/apollo-server-integration-h3/compare/v1.2.0...v1.2.1) (2024-07-09) 62 | 63 | ### 🧹 Miscellaneous 64 | 65 | - rename prepare to dev:prepare in package.json to fix publish process ([#77](https://github.com/apollo-server-integrations/apollo-server-integration-h3/issues/77)) ([b9fb1ee](https://github.com/apollo-server-integrations/apollo-server-integration-h3/commit/b9fb1eee893975282782a6e0a4edf2bc9ac9516c)) 66 | 67 | ## [1.2.0](https://github.com/apollo-server-integrations/apollo-server-integration-h3/compare/v1.1.6...v1.2.0) (2024-07-09) 68 | 69 | ### 🔖 Features 70 | 71 | - add websocket support for subscriptions via crossws ([#65](https://github.com/apollo-server-integrations/apollo-server-integration-h3/issues/65)) ([6a7b9c2](https://github.com/apollo-server-integrations/apollo-server-integration-h3/commit/6a7b9c228699302676910df4eaffc356fc192c98)) 72 | 73 | ### 📚 Documentation 74 | 75 | - add a simple h3 example ([#59](https://github.com/apollo-server-integrations/apollo-server-integration-h3/issues/59)) ([31935e1](https://github.com/apollo-server-integrations/apollo-server-integration-h3/commit/31935e1c2910e002528d038ea5de1a1c10626abd)) 76 | 77 | ### 🧹 Miscellaneous 78 | 79 | - add documentation section to changelog ([#60](https://github.com/apollo-server-integrations/apollo-server-integration-h3/issues/60)) ([707ec29](https://github.com/apollo-server-integrations/apollo-server-integration-h3/commit/707ec292ab6c0d0213a0889dca19fbe67dac6f8e)) 80 | - add release please manifest ([#56](https://github.com/apollo-server-integrations/apollo-server-integration-h3/issues/56)) ([4d26ce4](https://github.com/apollo-server-integrations/apollo-server-integration-h3/commit/4d26ce4c6e79ee860ff91f1c22b468a03ba014af)) 81 | - **deps:** update actions/checkout action to v4 ([#41](https://github.com/apollo-server-integrations/apollo-server-integration-h3/issues/41)) ([78887f8](https://github.com/apollo-server-integrations/apollo-server-integration-h3/commit/78887f8af88935ac027a41deb2cfc213e27d4e95)) 82 | - **deps:** update actions/checkout digest to 8ade135 ([#47](https://github.com/apollo-server-integrations/apollo-server-integration-h3/issues/47)) ([487a914](https://github.com/apollo-server-integrations/apollo-server-integration-h3/commit/487a9140017f01c4926f992b20e7e31100fc3843)) 83 | - **deps:** update actions/setup-node action to v4 ([#48](https://github.com/apollo-server-integrations/apollo-server-integration-h3/issues/48)) ([efc80f5](https://github.com/apollo-server-integrations/apollo-server-integration-h3/commit/efc80f5da318c92e0b04e6afd8ceca542e25199f)) 84 | - **deps:** update all non-major dependencies ([#40](https://github.com/apollo-server-integrations/apollo-server-integration-h3/issues/40)) ([dcb6958](https://github.com/apollo-server-integrations/apollo-server-integration-h3/commit/dcb6958b89df05d987f13bc19ef507ed17bfcd70)) 85 | - **deps:** update all non-major dependencies ([#61](https://github.com/apollo-server-integrations/apollo-server-integration-h3/issues/61)) ([042b09c](https://github.com/apollo-server-integrations/apollo-server-integration-h3/commit/042b09c16f6badd49ff799bd6373c1deaef57191)) 86 | - **deps:** update all non-major dependencies ([#67](https://github.com/apollo-server-integrations/apollo-server-integration-h3/issues/67)) ([c71c9b2](https://github.com/apollo-server-integrations/apollo-server-integration-h3/commit/c71c9b27229c88d4072c074f866d42a25202a6a3)) 87 | - **deps:** update codecov/codecov-action action to v4 ([#51](https://github.com/apollo-server-integrations/apollo-server-integration-h3/issues/51)) ([0a0c0fa](https://github.com/apollo-server-integrations/apollo-server-integration-h3/commit/0a0c0fa1f00e7d3aade0419ae7b3267bd572b50d)) 88 | - **deps:** update devdependency eslint to v9 ([#70](https://github.com/apollo-server-integrations/apollo-server-integration-h3/issues/70)) ([0f5ead5](https://github.com/apollo-server-integrations/apollo-server-integration-h3/commit/0f5ead5cbdbc84dc061647d7d127dab6ead07738)) 89 | - **deps:** update devdependency eslint-config-unjs to ^0.3.2 ([#75](https://github.com/apollo-server-integrations/apollo-server-integration-h3/issues/75)) ([30af89a](https://github.com/apollo-server-integrations/apollo-server-integration-h3/commit/30af89afa2b811020d3b5364c5fa01550e1235c0)) 90 | - **deps:** update devdependency eslint-plugin-unused-imports to v4 ([#72](https://github.com/apollo-server-integrations/apollo-server-integration-h3/issues/72)) ([5bf90a6](https://github.com/apollo-server-integrations/apollo-server-integration-h3/commit/5bf90a6286ca86e2d8ff589099e893e247de4637)) 91 | - **deps:** update devdependency vitest to v1 ([#50](https://github.com/apollo-server-integrations/apollo-server-integration-h3/issues/50)) ([377463b](https://github.com/apollo-server-integrations/apollo-server-integration-h3/commit/377463bbe6f2e2288b2c620cf315943eb8bb1c09)) 92 | - **deps:** update google-github-actions/release-please-action action to v4 ([#49](https://github.com/apollo-server-integrations/apollo-server-integration-h3/issues/49)) ([0b26309](https://github.com/apollo-server-integrations/apollo-server-integration-h3/commit/0b26309e260f61ec1dd56bee59b52eefd5668434)) 93 | - **deps:** update mcr.microsoft.com/vscode/devcontainers/base docker tag to v1 ([#71](https://github.com/apollo-server-integrations/apollo-server-integration-h3/issues/71)) ([6d1ecf1](https://github.com/apollo-server-integrations/apollo-server-integration-h3/commit/6d1ecf1fd20a9435daf98c8085a6ee65ba3b6fb9)) 94 | - **deps:** update pnpm to v9 ([#69](https://github.com/apollo-server-integrations/apollo-server-integration-h3/issues/69)) ([b86ce31](https://github.com/apollo-server-integrations/apollo-server-integration-h3/commit/b86ce31d58848944c2533f3332d7e1a1c351c402)) 95 | - **deps:** update typescript-eslint monorepo to v7 ([#52](https://github.com/apollo-server-integrations/apollo-server-integration-h3/issues/52)) ([e7e70a3](https://github.com/apollo-server-integrations/apollo-server-integration-h3/commit/e7e70a3d14f73d226cf30cc3a39cfb0d54b6225b)) 96 | - **deps:** update vitest monorepo to v2 ([#73](https://github.com/apollo-server-integrations/apollo-server-integration-h3/issues/73)) ([810d1b6](https://github.com/apollo-server-integrations/apollo-server-integration-h3/commit/810d1b6f9844c3c33d87987da252925457dcc7ff)) 97 | - format .release-please-manifest.json with Prettier ([#57](https://github.com/apollo-server-integrations/apollo-server-integration-h3/issues/57)) ([55c6454](https://github.com/apollo-server-integrations/apollo-server-integration-h3/commit/55c64541bbd06ae5878524f8865f42d691a0805a)) 98 | - move please-release config to config file ([97ef2f7](https://github.com/apollo-server-integrations/apollo-server-integration-h3/commit/97ef2f79099c0ced39edf9f9148f6689d64e1f98)) 99 | - only try to push changes when release PR is created ([79ccbe5](https://github.com/apollo-server-integrations/apollo-server-integration-h3/commit/79ccbe5fb6b3a5b59a610d082b90871ea0377a5c)) 100 | - update @vitest/coverage-c8 to @vitest/coverage-v8 ([#66](https://github.com/apollo-server-integrations/apollo-server-integration-h3/issues/66)) ([1da98de](https://github.com/apollo-server-integrations/apollo-server-integration-h3/commit/1da98de5118b9414ddfb48ba24d217feb3196c1f)) 101 | - update CI workflow to include running type tests (and other minor improvements from unjs/template) ([#76](https://github.com/apollo-server-integrations/apollo-server-integration-h3/issues/76)) ([bc62b2b](https://github.com/apollo-server-integrations/apollo-server-integration-h3/commit/bc62b2b5d0a5f780ed5d3db2604dff7ed1f43b1b)) 102 | - update Node.js version to 16.10.0 or >=18.0.0 in package.json ([#74](https://github.com/apollo-server-integrations/apollo-server-integration-h3/issues/74)) ([ce8958c](https://github.com/apollo-server-integrations/apollo-server-integration-h3/commit/ce8958c8470868049dc4c0bcbb809cd745fa76a1)) 103 | - update release-please config to exclude component in tag ([#58](https://github.com/apollo-server-integrations/apollo-server-integration-h3/issues/58)) ([3553907](https://github.com/apollo-server-integrations/apollo-server-integration-h3/commit/3553907d8fe0628468b9ac5972cbc97934afb8b5)) 104 | 105 | ## [1.1.6](https://github.com/apollo-server-integrations/apollo-server-integration-h3/compare/v1.1.5...v1.1.6) (2023-08-23) 106 | 107 | ### 🐛 Bug Fixes 108 | 109 | - improve request body parsing ([#39](https://github.com/apollo-server-integrations/apollo-server-integration-h3/issues/39)) ([01c7834](https://github.com/apollo-server-integrations/apollo-server-integration-h3/commit/01c783499fb992a5ff3f04852c9f09b72805ef4d)) 110 | 111 | ### 🧹 Miscellaneous 112 | 113 | - **deps:** update all non-major dependencies ([#25](https://github.com/apollo-server-integrations/apollo-server-integration-h3/issues/25)) ([f84bd81](https://github.com/apollo-server-integrations/apollo-server-integration-h3/commit/f84bd810cb7e898a73d481064f1b948edc61bb0b)) 114 | - **deps:** update all non-major dependencies ([#27](https://github.com/apollo-server-integrations/apollo-server-integration-h3/issues/27)) ([d56b97a](https://github.com/apollo-server-integrations/apollo-server-integration-h3/commit/d56b97a698cc02e5f19f0a19936ccca3e3d6f52b)) 115 | - **deps:** update all non-major dependencies ([#29](https://github.com/apollo-server-integrations/apollo-server-integration-h3/issues/29)) ([608fca2](https://github.com/apollo-server-integrations/apollo-server-integration-h3/commit/608fca2ddaaa5f0c92feda6e167e3e5be5205f61)) 116 | - **deps:** update all non-major dependencies ([#36](https://github.com/apollo-server-integrations/apollo-server-integration-h3/issues/36)) ([fd9e66e](https://github.com/apollo-server-integrations/apollo-server-integration-h3/commit/fd9e66ec035c60a208005119f57373346c1d177f)) 117 | - **deps:** update devdependency @apollo/utils.withrequired to v3 ([#32](https://github.com/apollo-server-integrations/apollo-server-integration-h3/issues/32)) ([d6a38aa](https://github.com/apollo-server-integrations/apollo-server-integration-h3/commit/d6a38aa016263977a41758c4b8f7c52f01d2f173)) 118 | - **deps:** update devdependency eslint-config-prettier to v9 ([#37](https://github.com/apollo-server-integrations/apollo-server-integration-h3/issues/37)) ([d65787c](https://github.com/apollo-server-integrations/apollo-server-integration-h3/commit/d65787ced1f6e6a3e3ce89fd308240e9c8464735)) 119 | - **deps:** update devdependency eslint-plugin-unused-imports to v3 ([#35](https://github.com/apollo-server-integrations/apollo-server-integration-h3/issues/35)) ([4bf76f0](https://github.com/apollo-server-integrations/apollo-server-integration-h3/commit/4bf76f090e067f71237b1062bd6890ecddcf1fa7)) 120 | - **deps:** update devdependency prettier to v3 ([#33](https://github.com/apollo-server-integrations/apollo-server-integration-h3/issues/33)) ([e4b6d52](https://github.com/apollo-server-integrations/apollo-server-integration-h3/commit/e4b6d52d46325dcbc723a930ab686228dc6793f1)) 121 | - **deps:** update devdependency typescript to v5 ([#30](https://github.com/apollo-server-integrations/apollo-server-integration-h3/issues/30)) ([aaa80fb](https://github.com/apollo-server-integrations/apollo-server-integration-h3/commit/aaa80fb05bba53c568047b279ff8485bb1b51559)) 122 | - **deps:** update devdependency unbuild to v2 ([80894a0](https://github.com/apollo-server-integrations/apollo-server-integration-h3/commit/80894a0dac52bf2b04048eb12ecc3822707c68b8)) 123 | - **deps:** update pnpm to v7.29.0 ([#28](https://github.com/apollo-server-integrations/apollo-server-integration-h3/issues/28)) ([ba669c5](https://github.com/apollo-server-integrations/apollo-server-integration-h3/commit/ba669c5c169b696ba357942b79c923431f0c4ec5)) 124 | - **deps:** update pnpm to v8 ([#31](https://github.com/apollo-server-integrations/apollo-server-integration-h3/issues/31)) ([ef38ad7](https://github.com/apollo-server-integrations/apollo-server-integration-h3/commit/ef38ad7f0e159834886dc0d16d0ed9999bb2019c)) 125 | - **deps:** update typescript-eslint monorepo to v6 ([#34](https://github.com/apollo-server-integrations/apollo-server-integration-h3/issues/34)) ([e963517](https://github.com/apollo-server-integrations/apollo-server-integration-h3/commit/e963517f0223b760a7fe8845fe6ebc8f452a61b1)) 126 | - remove problematic types export and instead bundle type definitions for esm and cjs ([8e99791](https://github.com/apollo-server-integrations/apollo-server-integration-h3/commit/8e99791406815b5008fcf655dfe685f05322a93a)) 127 | 128 | ## [1.1.5](https://github.com/apollo-server-integrations/apollo-server-integration-h3/compare/v1.1.4...v1.1.5) (2023-02-01) 129 | 130 | ### 🧹 Miscellaneous 131 | 132 | - **deps:** update all non-major dependencies ([#18](https://github.com/apollo-server-integrations/apollo-server-integration-h3/issues/18)) ([a4dbc4d](https://github.com/apollo-server-integrations/apollo-server-integration-h3/commit/a4dbc4d319235e3959cdb0ac45ec46fad5f8e3df)) 133 | 134 | ## [1.1.4](https://github.com/apollo-server-integrations/apollo-server-integration-h3/compare/v1.1.3...v1.1.4) (2022-11-20) 135 | 136 | ### 🧹 Miscellaneous 137 | 138 | - **deps:** update devdependency @apollo/utils.withrequired to v2 ([#23](https://github.com/apollo-server-integrations/apollo-server-integration-h3/issues/23)) ([6a8df13](https://github.com/apollo-server-integrations/apollo-server-integration-h3/commit/6a8df1392aa5f3c0bc475babb0a494f6d4fa1c70)) 139 | - **deps:** update devdependency @nuxtjs/eslint-config-typescript to v12 ([#22](https://github.com/apollo-server-integrations/apollo-server-integration-h3/issues/22)) ([079544c](https://github.com/apollo-server-integrations/apollo-server-integration-h3/commit/079544c8ffd96618a6cac81090ec924ed7580895)) 140 | - **deps:** update devdependency unbuild to v1 ([#21](https://github.com/apollo-server-integrations/apollo-server-integration-h3/issues/21)) ([67b271f](https://github.com/apollo-server-integrations/apollo-server-integration-h3/commit/67b271f7db44f52404d16faac112d585afb2e37d)) 141 | - **deps:** update peerdependency h3 to v1 ([#19](https://github.com/apollo-server-integrations/apollo-server-integration-h3/issues/19)) ([6581693](https://github.com/apollo-server-integrations/apollo-server-integration-h3/commit/6581693f17e7d1fddc41ea568136f1045f7cad13)) 142 | - **deps:** widen admissable version range for h3 ([0ce0ce4](https://github.com/apollo-server-integrations/apollo-server-integration-h3/commit/0ce0ce4dfb88abff4d9cb431e0c073c7272552e4)) 143 | - use renovate widenPeerDependencies preset ([97694bf](https://github.com/apollo-server-integrations/apollo-server-integration-h3/commit/97694bf7f0edf667064a924d7596a742e0abbe2f)) 144 | 145 | ## [1.1.3](https://github.com/apollo-server-integrations/apollo-server-integration-h3/compare/v1.1.2...v1.1.3) (2022-11-07) 146 | 147 | ### 🧹 Miscellaneous 148 | 149 | - provide npm auth token via npmrc ([ef0833b](https://github.com/apollo-server-integrations/apollo-server-integration-h3/commit/ef0833b9030525dd166522e100d3ff396cbcee05)) 150 | - specify correct repo in package.json ([1554e4a](https://github.com/apollo-server-integrations/apollo-server-integration-h3/commit/1554e4adbcbc9cf87397e9b86a37e7c7ae32d51d)) 151 | 152 | ## [1.1.2](https://github.com/apollo-server-integrations/apollo-server-integration-h3/compare/v1.1.1...v1.1.2) (2022-11-07) 153 | 154 | Only changes to build infrastructure. 155 | 156 | ## [1.1.1](https://github.com/apollo-server-integrations/apollo-server-integration-h3/compare/v1.1.0...v1.1.1) (2022-11-07) 157 | 158 | ### 🧹 Miscellaneous 159 | 160 | - change owner in license from unjs to Tobias Diez ([b5bcf4a](https://github.com/apollo-server-integrations/apollo-server-integration-h3/commit/b5bcf4ae7ecbf990d4336e80e80f6f72cc231fa5)) 161 | - **deps:** update all non-major dependencies ([#10](https://github.com/apollo-server-integrations/apollo-server-integration-h3/issues/10)) ([cb2fb2a](https://github.com/apollo-server-integrations/apollo-server-integration-h3/commit/cb2fb2acbe4e5da913e60f39cca72b04eb3ba116)) ([#13](https://github.com/apollo-server-integrations/apollo-server-integration-h3/issues/13)) ([3462b74](https://github.com/apollo-server-integrations/apollo-server-integration-h3/commit/3462b7422358793defd1a706873e037f10df8994)) ([#15](https://github.com/apollo-server-integrations/apollo-server-integration-h3/issues/15)) ([21d536f](https://github.com/apollo-server-integrations/apollo-server-integration-h3/commit/21d536f4993f88a958e41b9e3bebd52e5c952021)) 162 | 163 | ## [1.1.0](https://github.com/apollo-server-integrations/apollo-server-integration-h3/compare/v1.0.0...v1.1.0) (2022-10-17) 164 | 165 | ### 🧹 Miscellaneous 166 | 167 | - **deps:** update all non-major dependencies ([#8](https://github.com/apollo-server-integrations/apollo-server-integration-h3/issues/8)) ([1f01f30](https://github.com/apollo-server-integrations/apollo-server-integration-h3/commit/1f01f309849bb4fac5aa9de7b0cd23170912886f)) 168 | 169 | ## 1.0.0 (2022-10-15) 170 | 171 | Initial release. 172 | --------------------------------------------------------------------------------