
Security News
Socket Releases Free Certified Patches for Critical vm2 Sandbox Escape
A critical vm2 sandbox escape can allow untrusted JavaScript to break isolation and execute commands on the host Node.js process.
@as-integrations/cloudflare-workers
Advanced tools
An integration to use Cloudflare Workers as a hosting service with Apollo Server v4
An integration to use Cloudflare Workers as a hosting service with Apollo Server.
npm add @apollo/server @as-integrations/cloudflare-workers graphql
You must enable Node.js compatibility feature by adding the following flag in the file wrangler.toml:
compatibility_flags = ["nodejs_compat"] # wrangler v4
# node_compat = true # or wrangler v3
import { ApolloServer } from '@apollo/server';
import { startServerAndCreateCloudflareWorkersHandler } from '@as-integrations/cloudflare-workers';
import { ApolloServerPluginLandingPageLocalDefault } from '@apollo/server/plugin/landingPage/default';
const typeDefs = `#graphql
type Query {
example: String!
}
`;
const resolvers = {
Query: {
example: () => {
return 'Hello universe!';
},
}
}
interface Context {
token: string
}
const server = new ApolloServer<Context>({
typeDefs,
resolvers,
introspection: true,
plugins: [
ApolloServerPluginLandingPageLocalDefault({ footer: false }),
],
});
export interface Env {
// ...
}
export default {
fetch: startServerAndCreateCloudflareWorkersHandler<Env, Context>(server, {
context: async ({ env, request, ctx }) => {
return { token: 'secret' };
},
}),
};
If you’re looking for an alternative boilerplate, Cloudflare offers an official implementation built with Hono. You can explore it at cloudflare/workers-graphql-server.
This example works with Deno because it follows Web API standards and supports fetch. With Deno’s built-in Deno.serve, you can run it with minimal changes.
Important Notes:
deno.json or use the npm: prefix.# instead of:
import { ApolloServer } from '@apollo/server';
# we use:
import { ApolloServer } from 'npm:@apollo/server';
type Env = {};
type Context = { token: string };
const handler = startServerAndCreateCloudflareWorkersHandler<Env, Context>(server, {
context: async () => ({ token: 'secret' }),
});
Deno.serve({ port: 3000 }, (req) => handler(req, {} satisfies Env, { token: '' } satisfies Context));
FAQs
An integration to use Cloudflare Workers as a hosting service with Apollo Server v4
The npm package @as-integrations/cloudflare-workers receives a total of 1,296 weekly downloads. As such, @as-integrations/cloudflare-workers popularity was classified as popular.
We found that @as-integrations/cloudflare-workers demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
A critical vm2 sandbox escape can allow untrusted JavaScript to break isolation and execute commands on the host Node.js process.

Research
Five malicious NuGet packages impersonate Chinese .NET libraries to deploy a stealer targeting browser credentials, crypto wallets, SSH keys, and local files.

Security News
pnpm 11 turns on a 1-day Minimum Release Age and blocks exotic subdeps by default, adding safeguards against fast-moving supply chain attacks.