@graphql-yoga/render-apollo-sandbox 0.3.0 → 0.3.1-alpha-20260116132831-dc9fc0ad2f1ad6ee99bc438c173cf8496ae505a7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs ADDED
@@ -0,0 +1,41 @@
1
+
2
+ //#region src/index.ts
3
+ function renderApolloSandbox(sandboxOpts) {
4
+ return function renderApolloSandbox$1(graphiqlOpts) {
5
+ const includeCookies = graphiqlOpts.credentials === "include" || graphiqlOpts.credentials === "same-origin";
6
+ const initialState = {
7
+ document: graphiqlOpts.defaultQuery,
8
+ headers: graphiqlOpts.headers,
9
+ sharedHeaders: graphiqlOpts.additionalHeaders,
10
+ includeCookies,
11
+ ...sandboxOpts?.initialState
12
+ };
13
+ const endpoint = graphiqlOpts.endpoint ? JSON.stringify(graphiqlOpts.endpoint) : "location.pathname";
14
+ const finalOpts = {
15
+ includeCookies,
16
+ ...sandboxOpts,
17
+ initialState
18
+ };
19
+ return `
20
+ <!DOCTYPE html>
21
+ <html style="height: 100%;" lang="en">
22
+ <head>
23
+ <title>Apollo Sandbox</title>
24
+ </head>
25
+ <body style="margin: 0;height: 100%;">
26
+ <div style="width: 100%; height: 100%;" id="embedded-sandbox"></div>
27
+ <script src="https://embeddable-sandbox.cdn.apollographql.com/_latest/embeddable-sandbox.umd.production.min.js"><\/script>
28
+ <script>
29
+ const opts = ${JSON.stringify(finalOpts)};
30
+ opts.initialEndpoint ||= new URL(${endpoint}, location.href).toString();
31
+ opts.target ||= '#embedded-sandbox';
32
+ new window.EmbeddedSandbox(opts);
33
+ <\/script>
34
+ </body>
35
+ </html>
36
+ `;
37
+ };
38
+ }
39
+
40
+ //#endregion
41
+ exports.renderApolloSandbox = renderApolloSandbox;
@@ -0,0 +1,115 @@
1
+ import { GraphiQLRenderer } from "graphql-yoga";
2
+
3
+ //#region src/index.d.ts
4
+ interface ApolloSandboxOptions {
5
+ /**
6
+ * The URL of the GraphQL endpoint that Sandbox introspects on initial load. Sandbox populates its pages using the schema obtained from this endpoint.
7
+ * The default value is `http://localhost:4000`.
8
+ * You should only pass non-production endpoints to Sandbox. Sandbox is powered by schema introspection, and we recommend [disabling introspection in production](https://www.apollographql.com/blog/graphql/security/why-you-should-disable-graphql-introspection-in-production/).
9
+ * To provide a "Sandbox-like" experience for production endpoints, we recommend using either a [public variant](https://www.apollographql.com/docs/graphos/platform/graph-management/variants#public-variants) or the [embedded Explorer](https://www.apollographql.com/docs/graphos/platform/explorer/embed).
10
+ */
11
+ initialEndpoint?: string;
12
+ /**
13
+ * By default, the embedded Sandbox does not show the **Include cookies** toggle in its connection settings.Set `hideCookieToggle` to `false` to enable users of your embedded Sandbox instance to toggle the **Include cookies** setting.
14
+ */
15
+ hideCookieToggle?: boolean;
16
+ /**
17
+ * By default, the embedded Sandbox has a URL input box that is editable by users.Set endpointIsEditable to false to prevent users of your embedded Sandbox instance from changing the endpoint URL.
18
+ */
19
+ endpointIsEditable?: boolean;
20
+ /**
21
+ * You can set `includeCookies` to `true` if you instead want Sandbox to pass `{ credentials: 'include' }` for its requests.If you pass the `handleRequest` option, this option is ignored.Read more about the `fetch` API and credentials [here](https://developer.mozilla.org/en-US/docs/Web/API/fetch#credentials).This config option is deprecated in favor of using the connection settings cookie toggle in Sandbox and setting the default value via `initialState.includeCookies`.
22
+ */
23
+ includeCookies?: boolean;
24
+ /**
25
+ * An object containing additional options related to the state of the embedded Sandbox on page load.
26
+ */
27
+ initialState?: InitialState;
28
+ /**
29
+ * Target HTML element
30
+ */
31
+ target?: string;
32
+ }
33
+ interface InitialState {
34
+ /**
35
+ * Set this value to `true` if you want Sandbox to pass `{ credentials: 'include' }` for its requests by default.If you set `hideCookieToggle` to `false`, users can override this default setting with the **Include cookies** toggle. (By default, the embedded Sandbox does not show the **Include cookies** toggle in its connection settings.)If you also pass the `handleRequest` option, this option is ignored.Read more about the `fetch` API and credentials [here](https://developer.mozilla.org/en-US/docs/Web/API/fetch#credentials).
36
+ */
37
+ includeCookies?: boolean;
38
+ /**
39
+ * A URI-encoded operation to populate in Sandbox's editor on load.If you omit this, Sandbox initially loads an example query based on your schema.Example:
40
+ * ```js
41
+ * initialState: {
42
+ * document: `
43
+ * query ExampleQuery {
44
+ * books {
45
+ * title
46
+ * }
47
+ * }
48
+ * `
49
+ * }
50
+ * ```
51
+ */
52
+ document?: string;
53
+ /**
54
+ * A URI-encoded, serialized object containing initial variable values to populate in Sandbox on load.If provided, these variables should apply to the initial query you provide for [`document`](https://www.apollographql.com/docs/apollo-sandbox#document).Example:
55
+ *
56
+ * ```js
57
+ * initialState: {
58
+ * variables: {
59
+ * userID: "abc123"
60
+ * },
61
+ * }
62
+ * ```
63
+ */
64
+ variables?: string;
65
+ /**
66
+ * A URI-encoded, serialized object containing initial HTTP header values to populate in Sandbox on load.Example:
67
+ *
68
+ *
69
+ * ```js
70
+ * initialState: {
71
+ * headers: {
72
+ * authorization: "Bearer abc123";
73
+ * }
74
+ * }
75
+ * ```
76
+ */
77
+ headers?: string;
78
+ /**
79
+ * The ID of a collection, paired with an operation ID to populate in Sandbox on load. You can find these values from a registered graph in Studio by clicking the **...** menu next to an operation in the Explorer of that graph and selecting **View operation details**.Example:
80
+ *
81
+ * ```js
82
+ * initialState: {
83
+ * collectionId: 'abc1234',
84
+ * operationId: 'xyz1234'
85
+ * }
86
+ * ```
87
+ */
88
+ collectionId?: string;
89
+ operationId?: string;
90
+ /**
91
+ * If `true`, the embedded Sandbox periodically polls your `initialEndpoint` for schema updates.The default value is `true`.Example:
92
+ *
93
+ * ```js
94
+ * initialState: {
95
+ * pollForSchemaUpdates: false;
96
+ * }
97
+ * ```
98
+ */
99
+ pollForSchemaUpdates?: boolean;
100
+ /**
101
+ * Headers that are applied by default to every operation executed by the embedded Sandbox. Users can turn off the application of these headers, but they can't modify their values.The embedded Sandbox always includes these headers in its introspection queries to your `initialEndpoint`.Example:
102
+ *
103
+ * ```js
104
+ * initialState: {
105
+ * sharedHeaders: {
106
+ * authorization: "Bearer abc123";
107
+ * }
108
+ * }
109
+ * ```
110
+ */
111
+ sharedHeaders?: Record<string, string>;
112
+ }
113
+ declare function renderApolloSandbox(sandboxOpts?: ApolloSandboxOptions): GraphiQLRenderer;
114
+ //#endregion
115
+ export { ApolloSandboxOptions, renderApolloSandbox };
@@ -0,0 +1,115 @@
1
+ import { GraphiQLRenderer } from "graphql-yoga";
2
+
3
+ //#region src/index.d.ts
4
+ interface ApolloSandboxOptions {
5
+ /**
6
+ * The URL of the GraphQL endpoint that Sandbox introspects on initial load. Sandbox populates its pages using the schema obtained from this endpoint.
7
+ * The default value is `http://localhost:4000`.
8
+ * You should only pass non-production endpoints to Sandbox. Sandbox is powered by schema introspection, and we recommend [disabling introspection in production](https://www.apollographql.com/blog/graphql/security/why-you-should-disable-graphql-introspection-in-production/).
9
+ * To provide a "Sandbox-like" experience for production endpoints, we recommend using either a [public variant](https://www.apollographql.com/docs/graphos/platform/graph-management/variants#public-variants) or the [embedded Explorer](https://www.apollographql.com/docs/graphos/platform/explorer/embed).
10
+ */
11
+ initialEndpoint?: string;
12
+ /**
13
+ * By default, the embedded Sandbox does not show the **Include cookies** toggle in its connection settings.Set `hideCookieToggle` to `false` to enable users of your embedded Sandbox instance to toggle the **Include cookies** setting.
14
+ */
15
+ hideCookieToggle?: boolean;
16
+ /**
17
+ * By default, the embedded Sandbox has a URL input box that is editable by users.Set endpointIsEditable to false to prevent users of your embedded Sandbox instance from changing the endpoint URL.
18
+ */
19
+ endpointIsEditable?: boolean;
20
+ /**
21
+ * You can set `includeCookies` to `true` if you instead want Sandbox to pass `{ credentials: 'include' }` for its requests.If you pass the `handleRequest` option, this option is ignored.Read more about the `fetch` API and credentials [here](https://developer.mozilla.org/en-US/docs/Web/API/fetch#credentials).This config option is deprecated in favor of using the connection settings cookie toggle in Sandbox and setting the default value via `initialState.includeCookies`.
22
+ */
23
+ includeCookies?: boolean;
24
+ /**
25
+ * An object containing additional options related to the state of the embedded Sandbox on page load.
26
+ */
27
+ initialState?: InitialState;
28
+ /**
29
+ * Target HTML element
30
+ */
31
+ target?: string;
32
+ }
33
+ interface InitialState {
34
+ /**
35
+ * Set this value to `true` if you want Sandbox to pass `{ credentials: 'include' }` for its requests by default.If you set `hideCookieToggle` to `false`, users can override this default setting with the **Include cookies** toggle. (By default, the embedded Sandbox does not show the **Include cookies** toggle in its connection settings.)If you also pass the `handleRequest` option, this option is ignored.Read more about the `fetch` API and credentials [here](https://developer.mozilla.org/en-US/docs/Web/API/fetch#credentials).
36
+ */
37
+ includeCookies?: boolean;
38
+ /**
39
+ * A URI-encoded operation to populate in Sandbox's editor on load.If you omit this, Sandbox initially loads an example query based on your schema.Example:
40
+ * ```js
41
+ * initialState: {
42
+ * document: `
43
+ * query ExampleQuery {
44
+ * books {
45
+ * title
46
+ * }
47
+ * }
48
+ * `
49
+ * }
50
+ * ```
51
+ */
52
+ document?: string;
53
+ /**
54
+ * A URI-encoded, serialized object containing initial variable values to populate in Sandbox on load.If provided, these variables should apply to the initial query you provide for [`document`](https://www.apollographql.com/docs/apollo-sandbox#document).Example:
55
+ *
56
+ * ```js
57
+ * initialState: {
58
+ * variables: {
59
+ * userID: "abc123"
60
+ * },
61
+ * }
62
+ * ```
63
+ */
64
+ variables?: string;
65
+ /**
66
+ * A URI-encoded, serialized object containing initial HTTP header values to populate in Sandbox on load.Example:
67
+ *
68
+ *
69
+ * ```js
70
+ * initialState: {
71
+ * headers: {
72
+ * authorization: "Bearer abc123";
73
+ * }
74
+ * }
75
+ * ```
76
+ */
77
+ headers?: string;
78
+ /**
79
+ * The ID of a collection, paired with an operation ID to populate in Sandbox on load. You can find these values from a registered graph in Studio by clicking the **...** menu next to an operation in the Explorer of that graph and selecting **View operation details**.Example:
80
+ *
81
+ * ```js
82
+ * initialState: {
83
+ * collectionId: 'abc1234',
84
+ * operationId: 'xyz1234'
85
+ * }
86
+ * ```
87
+ */
88
+ collectionId?: string;
89
+ operationId?: string;
90
+ /**
91
+ * If `true`, the embedded Sandbox periodically polls your `initialEndpoint` for schema updates.The default value is `true`.Example:
92
+ *
93
+ * ```js
94
+ * initialState: {
95
+ * pollForSchemaUpdates: false;
96
+ * }
97
+ * ```
98
+ */
99
+ pollForSchemaUpdates?: boolean;
100
+ /**
101
+ * Headers that are applied by default to every operation executed by the embedded Sandbox. Users can turn off the application of these headers, but they can't modify their values.The embedded Sandbox always includes these headers in its introspection queries to your `initialEndpoint`.Example:
102
+ *
103
+ * ```js
104
+ * initialState: {
105
+ * sharedHeaders: {
106
+ * authorization: "Bearer abc123";
107
+ * }
108
+ * }
109
+ * ```
110
+ */
111
+ sharedHeaders?: Record<string, string>;
112
+ }
113
+ declare function renderApolloSandbox(sandboxOpts?: ApolloSandboxOptions): GraphiQLRenderer;
114
+ //#endregion
115
+ export { ApolloSandboxOptions, renderApolloSandbox };
package/dist/index.mjs ADDED
@@ -0,0 +1,40 @@
1
+ //#region src/index.ts
2
+ function renderApolloSandbox(sandboxOpts) {
3
+ return function renderApolloSandbox$1(graphiqlOpts) {
4
+ const includeCookies = graphiqlOpts.credentials === "include" || graphiqlOpts.credentials === "same-origin";
5
+ const initialState = {
6
+ document: graphiqlOpts.defaultQuery,
7
+ headers: graphiqlOpts.headers,
8
+ sharedHeaders: graphiqlOpts.additionalHeaders,
9
+ includeCookies,
10
+ ...sandboxOpts?.initialState
11
+ };
12
+ const endpoint = graphiqlOpts.endpoint ? JSON.stringify(graphiqlOpts.endpoint) : "location.pathname";
13
+ const finalOpts = {
14
+ includeCookies,
15
+ ...sandboxOpts,
16
+ initialState
17
+ };
18
+ return `
19
+ <!DOCTYPE html>
20
+ <html style="height: 100%;" lang="en">
21
+ <head>
22
+ <title>Apollo Sandbox</title>
23
+ </head>
24
+ <body style="margin: 0;height: 100%;">
25
+ <div style="width: 100%; height: 100%;" id="embedded-sandbox"></div>
26
+ <script src="https://embeddable-sandbox.cdn.apollographql.com/_latest/embeddable-sandbox.umd.production.min.js"><\/script>
27
+ <script>
28
+ const opts = ${JSON.stringify(finalOpts)};
29
+ opts.initialEndpoint ||= new URL(${endpoint}, location.href).toString();
30
+ opts.target ||= '#embedded-sandbox';
31
+ new window.EmbeddedSandbox(opts);
32
+ <\/script>
33
+ </body>
34
+ </html>
35
+ `;
36
+ };
37
+ }
38
+
39
+ //#endregion
40
+ export { renderApolloSandbox };
package/package.json CHANGED
@@ -1,14 +1,7 @@
1
1
  {
2
2
  "name": "@graphql-yoga/render-apollo-sandbox",
3
- "version": "0.3.0",
4
- "sideEffects": false,
5
- "peerDependencies": {
6
- "graphql": "^14.0.0 || ^15.0.0 || ^16.0.0",
7
- "graphql-yoga": "^5.18.0"
8
- },
9
- "dependencies": {
10
- "tslib": "^2.5.0"
11
- },
3
+ "version": "0.3.1-alpha-20260116132831-dc9fc0ad2f1ad6ee99bc438c173cf8496ae505a7",
4
+ "type": "module",
12
5
  "repository": {
13
6
  "type": "git",
14
7
  "url": "https://github.com/graphql-hive/graphql-yoga.git",
@@ -19,42 +12,67 @@
19
12
  "engines": {
20
13
  "node": ">=18.0.0"
21
14
  },
22
- "main": "cjs/index.js",
23
- "module": "esm/index.js",
24
- "typings": "typings/index.d.ts",
25
- "typescript": {
26
- "definition": "typings/index.d.ts"
27
- },
28
- "type": "module",
15
+ "main": "dist/index.cjs",
16
+ "typings": "dist/index.d.mts",
17
+ "module": "dist/index.mjs",
29
18
  "exports": {
30
19
  ".": {
31
20
  "require": {
32
- "types": "./typings/index.d.cts",
33
- "default": "./cjs/index.js"
21
+ "types": "./dist/index.d.cts",
22
+ "default": "./dist/index.cjs"
34
23
  },
35
24
  "import": {
36
- "types": "./typings/index.d.ts",
37
- "default": "./esm/index.js"
25
+ "types": "./dist/index.d.mts",
26
+ "default": "./dist/index.mjs"
38
27
  },
39
28
  "default": {
40
- "types": "./typings/index.d.ts",
41
- "default": "./esm/index.js"
29
+ "types": "./dist/index.d.mts",
30
+ "default": "./dist/index.mjs"
42
31
  }
43
32
  },
44
33
  "./*": {
45
34
  "require": {
46
- "types": "./typings/*.d.cts",
47
- "default": "./cjs/*.js"
35
+ "types": "./dist/*.d.cts",
36
+ "default": "./dist/*.cjs"
48
37
  },
49
38
  "import": {
50
- "types": "./typings/*.d.ts",
51
- "default": "./esm/*.js"
39
+ "types": "./dist/*.d.mts",
40
+ "default": "./dist/*.mjs"
52
41
  },
53
42
  "default": {
54
- "types": "./typings/*.d.ts",
55
- "default": "./esm/*.js"
43
+ "types": "./dist/*.d.mts",
44
+ "default": "./dist/*.mjs"
56
45
  }
57
46
  },
58
47
  "./package.json": "./package.json"
48
+ },
49
+ "files": [
50
+ "dist"
51
+ ],
52
+ "scripts": {
53
+ "build": "tsdown",
54
+ "check": "tsc --pretty --noEmit"
55
+ },
56
+ "peerDependencies": {
57
+ "graphql": "^14.0.0 || ^15.0.0 || ^16.0.0",
58
+ "graphql-yoga": "workspace:^"
59
+ },
60
+ "dependencies": {
61
+ "tslib": "^2.5.0"
62
+ },
63
+ "devDependencies": {
64
+ "graphql": "16.12.0",
65
+ "graphql-yoga": "workspace:^",
66
+ "tsdown": "^0.20.0-beta.1"
67
+ },
68
+ "publishConfig": {
69
+ "access": "public"
70
+ },
71
+ "sideEffects": false,
72
+ "buildOptions": {
73
+ "input": "./src/index.ts"
74
+ },
75
+ "typescript": {
76
+ "definition": "dist/index.d.mts"
59
77
  }
60
- }
78
+ }
package/LICENSE DELETED
@@ -1,23 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2018-2020 Graphcool
4
- Copyright (c) 2020-2021 Prisma
5
- Copyright (c) 2021- The Guild
6
-
7
- Permission is hereby granted, free of charge, to any person obtaining a copy
8
- of this software and associated documentation files (the "Software"), to deal
9
- in the Software without restriction, including without limitation the rights
10
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
- copies of the Software, and to permit persons to whom the Software is
12
- furnished to do so, subject to the following conditions:
13
-
14
- The above copyright notice and this permission notice shall be included in all
15
- copies or substantial portions of the Software.
16
-
17
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
- SOFTWARE.
package/cjs/index.js DELETED
@@ -1,41 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.renderApolloSandbox = renderApolloSandbox;
4
- function renderApolloSandbox(sandboxOpts) {
5
- return function renderApolloSandbox(graphiqlOpts) {
6
- const includeCookies = graphiqlOpts.credentials === 'include' || graphiqlOpts.credentials === 'same-origin';
7
- const initialState = {
8
- document: graphiqlOpts.defaultQuery,
9
- headers: graphiqlOpts.headers,
10
- sharedHeaders: graphiqlOpts.additionalHeaders,
11
- includeCookies,
12
- ...sandboxOpts?.initialState,
13
- };
14
- const endpoint = graphiqlOpts.endpoint
15
- ? JSON.stringify(graphiqlOpts.endpoint)
16
- : 'location.pathname';
17
- const finalOpts = {
18
- includeCookies,
19
- ...sandboxOpts,
20
- initialState,
21
- };
22
- return /* HTML */ `
23
- <!DOCTYPE html>
24
- <html style="height: 100%;" lang="en">
25
- <head>
26
- <title>Apollo Sandbox</title>
27
- </head>
28
- <body style="margin: 0;height: 100%;">
29
- <div style="width: 100%; height: 100%;" id="embedded-sandbox"></div>
30
- <script src="https://embeddable-sandbox.cdn.apollographql.com/_latest/embeddable-sandbox.umd.production.min.js"></script>
31
- <script>
32
- const opts = ${JSON.stringify(finalOpts)};
33
- opts.initialEndpoint ||= new URL(${endpoint}, location.href).toString();
34
- opts.target ||= '#embedded-sandbox';
35
- new window.EmbeddedSandbox(opts);
36
- </script>
37
- </body>
38
- </html>
39
- `;
40
- };
41
- }
package/cjs/package.json DELETED
@@ -1 +0,0 @@
1
- {"type":"commonjs"}
package/esm/index.js DELETED
@@ -1,38 +0,0 @@
1
- export function renderApolloSandbox(sandboxOpts) {
2
- return function renderApolloSandbox(graphiqlOpts) {
3
- const includeCookies = graphiqlOpts.credentials === 'include' || graphiqlOpts.credentials === 'same-origin';
4
- const initialState = {
5
- document: graphiqlOpts.defaultQuery,
6
- headers: graphiqlOpts.headers,
7
- sharedHeaders: graphiqlOpts.additionalHeaders,
8
- includeCookies,
9
- ...sandboxOpts?.initialState,
10
- };
11
- const endpoint = graphiqlOpts.endpoint
12
- ? JSON.stringify(graphiqlOpts.endpoint)
13
- : 'location.pathname';
14
- const finalOpts = {
15
- includeCookies,
16
- ...sandboxOpts,
17
- initialState,
18
- };
19
- return /* HTML */ `
20
- <!DOCTYPE html>
21
- <html style="height: 100%;" lang="en">
22
- <head>
23
- <title>Apollo Sandbox</title>
24
- </head>
25
- <body style="margin: 0;height: 100%;">
26
- <div style="width: 100%; height: 100%;" id="embedded-sandbox"></div>
27
- <script src="https://embeddable-sandbox.cdn.apollographql.com/_latest/embeddable-sandbox.umd.production.min.js"></script>
28
- <script>
29
- const opts = ${JSON.stringify(finalOpts)};
30
- opts.initialEndpoint ||= new URL(${endpoint}, location.href).toString();
31
- opts.target ||= '#embedded-sandbox';
32
- new window.EmbeddedSandbox(opts);
33
- </script>
34
- </body>
35
- </html>
36
- `;
37
- };
38
- }
@@ -1,112 +0,0 @@
1
- import type { GraphiQLRenderer } from 'graphql-yoga';
2
- export interface ApolloSandboxOptions {
3
- /**
4
- * The URL of the GraphQL endpoint that Sandbox introspects on initial load. Sandbox populates its pages using the schema obtained from this endpoint.
5
- * The default value is `http://localhost:4000`.
6
- * You should only pass non-production endpoints to Sandbox. Sandbox is powered by schema introspection, and we recommend [disabling introspection in production](https://www.apollographql.com/blog/graphql/security/why-you-should-disable-graphql-introspection-in-production/).
7
- * To provide a "Sandbox-like" experience for production endpoints, we recommend using either a [public variant](https://www.apollographql.com/docs/graphos/platform/graph-management/variants#public-variants) or the [embedded Explorer](https://www.apollographql.com/docs/graphos/platform/explorer/embed).
8
- */
9
- initialEndpoint?: string;
10
- /**
11
- * By default, the embedded Sandbox does not show the **Include cookies** toggle in its connection settings.Set `hideCookieToggle` to `false` to enable users of your embedded Sandbox instance to toggle the **Include cookies** setting.
12
- */
13
- hideCookieToggle?: boolean;
14
- /**
15
- * By default, the embedded Sandbox has a URL input box that is editable by users.Set endpointIsEditable to false to prevent users of your embedded Sandbox instance from changing the endpoint URL.
16
- */
17
- endpointIsEditable?: boolean;
18
- /**
19
- * You can set `includeCookies` to `true` if you instead want Sandbox to pass `{ credentials: 'include' }` for its requests.If you pass the `handleRequest` option, this option is ignored.Read more about the `fetch` API and credentials [here](https://developer.mozilla.org/en-US/docs/Web/API/fetch#credentials).This config option is deprecated in favor of using the connection settings cookie toggle in Sandbox and setting the default value via `initialState.includeCookies`.
20
- */
21
- includeCookies?: boolean;
22
- /**
23
- * An object containing additional options related to the state of the embedded Sandbox on page load.
24
- */
25
- initialState?: InitialState;
26
- /**
27
- * Target HTML element
28
- */
29
- target?: string;
30
- }
31
- interface InitialState {
32
- /**
33
- * Set this value to `true` if you want Sandbox to pass `{ credentials: 'include' }` for its requests by default.If you set `hideCookieToggle` to `false`, users can override this default setting with the **Include cookies** toggle. (By default, the embedded Sandbox does not show the **Include cookies** toggle in its connection settings.)If you also pass the `handleRequest` option, this option is ignored.Read more about the `fetch` API and credentials [here](https://developer.mozilla.org/en-US/docs/Web/API/fetch#credentials).
34
- */
35
- includeCookies?: boolean;
36
- /**
37
- * A URI-encoded operation to populate in Sandbox's editor on load.If you omit this, Sandbox initially loads an example query based on your schema.Example:
38
- * ```js
39
- * initialState: {
40
- * document: `
41
- * query ExampleQuery {
42
- * books {
43
- * title
44
- * }
45
- * }
46
- * `
47
- * }
48
- * ```
49
- */
50
- document?: string;
51
- /**
52
- * A URI-encoded, serialized object containing initial variable values to populate in Sandbox on load.If provided, these variables should apply to the initial query you provide for [`document`](https://www.apollographql.com/docs/apollo-sandbox#document).Example:
53
- *
54
- * ```js
55
- * initialState: {
56
- * variables: {
57
- * userID: "abc123"
58
- * },
59
- * }
60
- * ```
61
- */
62
- variables?: string;
63
- /**
64
- * A URI-encoded, serialized object containing initial HTTP header values to populate in Sandbox on load.Example:
65
- *
66
- *
67
- * ```js
68
- * initialState: {
69
- * headers: {
70
- * authorization: "Bearer abc123";
71
- * }
72
- * }
73
- * ```
74
- */
75
- headers?: string;
76
- /**
77
- * The ID of a collection, paired with an operation ID to populate in Sandbox on load. You can find these values from a registered graph in Studio by clicking the **...** menu next to an operation in the Explorer of that graph and selecting **View operation details**.Example:
78
- *
79
- * ```js
80
- * initialState: {
81
- * collectionId: 'abc1234',
82
- * operationId: 'xyz1234'
83
- * }
84
- * ```
85
- */
86
- collectionId?: string;
87
- operationId?: string;
88
- /**
89
- * If `true`, the embedded Sandbox periodically polls your `initialEndpoint` for schema updates.The default value is `true`.Example:
90
- *
91
- * ```js
92
- * initialState: {
93
- * pollForSchemaUpdates: false;
94
- * }
95
- * ```
96
- */
97
- pollForSchemaUpdates?: boolean;
98
- /**
99
- * Headers that are applied by default to every operation executed by the embedded Sandbox. Users can turn off the application of these headers, but they can't modify their values.The embedded Sandbox always includes these headers in its introspection queries to your `initialEndpoint`.Example:
100
- *
101
- * ```js
102
- * initialState: {
103
- * sharedHeaders: {
104
- * authorization: "Bearer abc123";
105
- * }
106
- * }
107
- * ```
108
- */
109
- sharedHeaders?: Record<string, string>;
110
- }
111
- export declare function renderApolloSandbox(sandboxOpts?: ApolloSandboxOptions): GraphiQLRenderer;
112
- export {};
@@ -1,112 +0,0 @@
1
- import type { GraphiQLRenderer } from 'graphql-yoga';
2
- export interface ApolloSandboxOptions {
3
- /**
4
- * The URL of the GraphQL endpoint that Sandbox introspects on initial load. Sandbox populates its pages using the schema obtained from this endpoint.
5
- * The default value is `http://localhost:4000`.
6
- * You should only pass non-production endpoints to Sandbox. Sandbox is powered by schema introspection, and we recommend [disabling introspection in production](https://www.apollographql.com/blog/graphql/security/why-you-should-disable-graphql-introspection-in-production/).
7
- * To provide a "Sandbox-like" experience for production endpoints, we recommend using either a [public variant](https://www.apollographql.com/docs/graphos/platform/graph-management/variants#public-variants) or the [embedded Explorer](https://www.apollographql.com/docs/graphos/platform/explorer/embed).
8
- */
9
- initialEndpoint?: string;
10
- /**
11
- * By default, the embedded Sandbox does not show the **Include cookies** toggle in its connection settings.Set `hideCookieToggle` to `false` to enable users of your embedded Sandbox instance to toggle the **Include cookies** setting.
12
- */
13
- hideCookieToggle?: boolean;
14
- /**
15
- * By default, the embedded Sandbox has a URL input box that is editable by users.Set endpointIsEditable to false to prevent users of your embedded Sandbox instance from changing the endpoint URL.
16
- */
17
- endpointIsEditable?: boolean;
18
- /**
19
- * You can set `includeCookies` to `true` if you instead want Sandbox to pass `{ credentials: 'include' }` for its requests.If you pass the `handleRequest` option, this option is ignored.Read more about the `fetch` API and credentials [here](https://developer.mozilla.org/en-US/docs/Web/API/fetch#credentials).This config option is deprecated in favor of using the connection settings cookie toggle in Sandbox and setting the default value via `initialState.includeCookies`.
20
- */
21
- includeCookies?: boolean;
22
- /**
23
- * An object containing additional options related to the state of the embedded Sandbox on page load.
24
- */
25
- initialState?: InitialState;
26
- /**
27
- * Target HTML element
28
- */
29
- target?: string;
30
- }
31
- interface InitialState {
32
- /**
33
- * Set this value to `true` if you want Sandbox to pass `{ credentials: 'include' }` for its requests by default.If you set `hideCookieToggle` to `false`, users can override this default setting with the **Include cookies** toggle. (By default, the embedded Sandbox does not show the **Include cookies** toggle in its connection settings.)If you also pass the `handleRequest` option, this option is ignored.Read more about the `fetch` API and credentials [here](https://developer.mozilla.org/en-US/docs/Web/API/fetch#credentials).
34
- */
35
- includeCookies?: boolean;
36
- /**
37
- * A URI-encoded operation to populate in Sandbox's editor on load.If you omit this, Sandbox initially loads an example query based on your schema.Example:
38
- * ```js
39
- * initialState: {
40
- * document: `
41
- * query ExampleQuery {
42
- * books {
43
- * title
44
- * }
45
- * }
46
- * `
47
- * }
48
- * ```
49
- */
50
- document?: string;
51
- /**
52
- * A URI-encoded, serialized object containing initial variable values to populate in Sandbox on load.If provided, these variables should apply to the initial query you provide for [`document`](https://www.apollographql.com/docs/apollo-sandbox#document).Example:
53
- *
54
- * ```js
55
- * initialState: {
56
- * variables: {
57
- * userID: "abc123"
58
- * },
59
- * }
60
- * ```
61
- */
62
- variables?: string;
63
- /**
64
- * A URI-encoded, serialized object containing initial HTTP header values to populate in Sandbox on load.Example:
65
- *
66
- *
67
- * ```js
68
- * initialState: {
69
- * headers: {
70
- * authorization: "Bearer abc123";
71
- * }
72
- * }
73
- * ```
74
- */
75
- headers?: string;
76
- /**
77
- * The ID of a collection, paired with an operation ID to populate in Sandbox on load. You can find these values from a registered graph in Studio by clicking the **...** menu next to an operation in the Explorer of that graph and selecting **View operation details**.Example:
78
- *
79
- * ```js
80
- * initialState: {
81
- * collectionId: 'abc1234',
82
- * operationId: 'xyz1234'
83
- * }
84
- * ```
85
- */
86
- collectionId?: string;
87
- operationId?: string;
88
- /**
89
- * If `true`, the embedded Sandbox periodically polls your `initialEndpoint` for schema updates.The default value is `true`.Example:
90
- *
91
- * ```js
92
- * initialState: {
93
- * pollForSchemaUpdates: false;
94
- * }
95
- * ```
96
- */
97
- pollForSchemaUpdates?: boolean;
98
- /**
99
- * Headers that are applied by default to every operation executed by the embedded Sandbox. Users can turn off the application of these headers, but they can't modify their values.The embedded Sandbox always includes these headers in its introspection queries to your `initialEndpoint`.Example:
100
- *
101
- * ```js
102
- * initialState: {
103
- * sharedHeaders: {
104
- * authorization: "Bearer abc123";
105
- * }
106
- * }
107
- * ```
108
- */
109
- sharedHeaders?: Record<string, string>;
110
- }
111
- export declare function renderApolloSandbox(sandboxOpts?: ApolloSandboxOptions): GraphiQLRenderer;
112
- export {};