@apollo/sandbox

中文文档
2.7.4发布于 2026/01/09MITTypeScriptESM + CJS近 30 天下载 14.9万

This repo hosts the source for Apollo Studio's Embeddable Sandbox

原始使用文档
文档目录6 节
  1. Using the @apollo/sandbox npm package
  2. React
  3. Vanilla JS
  4. Examples from the raw cdn hosted umd file
  5. Developing embedded Sandbox
  6. Developing embedded Sandbox with the React example

Apollo Studio Embeddable Sandbox

This repo hosts the source for Apollo Studio's Embeddable Sandbox

See docs for usage details

Using the @apollo/sandbox npm package

You can download the @apollo/sandbox npm package with npm install @apollo/sandbox. Then, you can import the ApolloSandbox class or ApolloSandbox React component like so:

import { ApolloSandbox } from '@apollo/sandbox';
import { ApolloSandbox } from '@apollo/sandbox/react';

When you call the EmbeddedSandbox constructor with a target of an html div you have in your app, the Sandbox will show up in an iframe in that element. Check out all the configuration options for your graph.

React

import { ApolloSandbox } from '@apollo/sandbox/react';

function App() {

  return (
    <ApolloSandbox />
  );
}

Vanilla JS

import { ApolloSandbox } from '@apollo/sandbox';

function App() {

  ...
  new ApolloSandbox({
      target: '#embeddableSandbox',
  })
  ...

}
...
// style the iframe for your site
<style>
  iframe {
    height: 100%;
    width: 100%;
    border: none;
  }
</style>
<div id="embeddableSandbox" />

Examples from the raw cdn hosted umd file

Developing embedded Sandbox

run npm run build:umd to build umd files where EmbeddedSandbox is exposed on window.

Open examples/localDevelopmentExample.html to test your changes. (if origin is not set, run localDevelopmentExample.html from Live Server)

Install the Live Server extension on VSCode, then go to localDevelopmentExample.html and click 'Go Live' Screen Shot 2022-04-27 at 4 34 53 PM

Developing embedded Sandbox with the React example

run npm run build:cjs-esm to build cjs & esm files where ApolloSandbox & ApolloSandbox React are named exports.

We have a React example app that uses our ApolloSandbox React component to render the embedded Sandbox located in src/examples/react-example. To run this example, npm run build and npm run start in react-example. Make sure you delete the .parcel-cache folder before you rebuild for new changes. (TODO remove parcel caching)

版本与发布记录

@apollo/sandbox 共发布 24 个版本,首次发布于 2022/07/01;过去 12 个月发布了 1 个版本。

版本发布日期距今
2.7.4latest2026/01/099 个月前
2.7.32025/10/011.1 年前
2.7.22025/09/191.1 年前
2.7.12025/03/111.7 年前
2.7.02024/09/112 年前
2.6.02024/05/302 年前

其他发布通道:beta → 0.1.0-beta.0。

关于 @apollo/sandbox 的常见问题

@apollo/sandbox 是什么?

This repo hosts the source for Apollo Studio's Embeddable Sandbox

如何安装 @apollo/sandbox?

在项目目录运行 npm install @apollo/sandbox,或使用 pnpm add / yarn add / bun add。

@apollo/sandbox 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@apollo/sandbox 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@apollo/sandbox 可以商用吗?

@apollo/sandbox 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@apollo/sandbox 的下载量有多少?

根据 npm 官方下载统计,@apollo/sandbox 在 2026/10/07 – 2026/11/05 这 30 天内被下载 148,963 次,日均约 4,965 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@apollo/sandbox 还在维护吗?

最新版本 2.7.4 发布于 2026/01/09(9 个月前);至今共发布 24 个版本,其中过去 12 个月发布了 1 个;首次发布于 2022/07/01。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。