@chrisenglert/as-integrations-bun
v0.0.3
Published
An Apollo Server integration for use with Bun
Downloads
179
Readme
Apollo Server Integration for bun
Introduction
An Apollo Server integration for use with bun.
Usage
Exclusive
import { apolloIntegration } from "@chrisenglert/as-integrations-bun"
import { ApolloServer, BaseContext } from "@apollo/server"
// ...
const apolloServer = new ApolloServer<BaseContext>({
typeDefs,
resolvers,
})
await apolloServer.start()
const server = Bun.serve(
apolloIntegration({
apolloServer,
port,
}),
)
Combined
import { apolloRequest } from "@chrisenglert/as-integrations-bun"
import { ApolloServer, BaseContext } from "@apollo/server"
//..
const apolloServer = new ApolloServer<BaseContext>({
typeDefs,
resolvers,
})
await apolloServer.start()
const server = Bun.serve({
async fetch(req) {
const url = new URL(req.url)
if (url.pathname === "/") return new Response("Home page!")
if (url.pathname === "/graphql") return apolloRequest(req, apolloServer, async (req) => getContext(req))
return new Response("404!")
},
port,
})
``