|
1 | 1 | # Upgrading `graphiql` from `3.x` to `4.0.0` |
2 | 2 |
|
3 | | -## `graphiql` changes |
4 | | - |
5 | | -- New looks of tabs |
6 | | -- Drop CommonJS build output |
7 | | -- Drop support React 16/17 |
8 | | -- Support React 19 |
9 | | -- Changed umd CDN paths, `dist/index.umd.js` and `dist/style.css` are minified |
10 | | - ```diff |
11 | | - -https://unpkg.com/graphiql/graphiql.js |
12 | | - -https://unpkg.com/graphiql/graphiql.min.js |
13 | | - +https://unpkg.com/graphiql/dist/index.umd.js |
14 | | - -https://unpkg.com/graphiql/graphiql.css |
15 | | - -https://unpkg.com/graphiql/graphiql.min.css |
16 | | - +https://unpkg.com/graphiql/dist/style.css |
17 | | - ``` |
18 | | -- ⚠️ UMD CDN build `index.umd.js` is deprecated. Migrate to ESM-based CDN |
19 | | -- Add support for `onPrettifyQuery` callback to enable customized query formatting |
20 | | -- Show tabs even there is only one tab |
21 | | -- Remove default export |
| 3 | +--- |
| 4 | + |
| 5 | +## `graphiql` |
| 6 | + |
| 7 | +- Dropped support for **React 16/17**, added support for **React 19** |
| 8 | +- Dropped **CommonJS** build output – now **ESM only** |
| 9 | +- Improved UI of tabs |
| 10 | + - Changed tabs behavior – tabs are always visible (even if only one) |
| 11 | + - Updated tabs tooltip usage – now use HTML `title` attribute |
| 12 | +- Removed **default export** |
| 13 | +- Removed `disableTabs` option |
| 14 | +- Improved Markdown handling – single newlines are ignored |
| 15 | +- Added `onPrettifyQuery` callback for custom formatting |
| 16 | +- ⚠️ Deprecate **UMD CDN build `index.umd.js`** |
| 17 | +- Changed **CDN paths** and **style import** |
| 18 | + |
| 19 | +> [!WARNING] |
| 20 | +> |
| 21 | +> ⚠️ **`index.umd.js` is deprecated**. Switch to the [ESM CDN example](../../examples/graphiql-cdn/index.html). |
| 22 | +
|
| 23 | +### UMD CDN path changes |
| 24 | + |
| 25 | +```diff |
| 26 | +-https://unpkg.com/graphiql/graphiql.js |
| 27 | +-https://unpkg.com/graphiql/graphiql.min.js |
| 28 | ++https://unpkg.com/graphiql/dist/index.umd.js // ⚠️ deprecated |
| 29 | + |
| 30 | +-https://unpkg.com/graphiql/graphiql.css |
| 31 | +-https://unpkg.com/graphiql/graphiql.min.css |
| 32 | ++https://unpkg.com/graphiql/dist/style.css |
| 33 | +``` |
| 34 | + |
| 35 | +### Default export removed |
| 36 | + |
| 37 | +```diff |
| 38 | +-import GraphiQL from 'graphiql' |
| 39 | ++import { GraphiQL } from 'graphiql' |
| 40 | +``` |
| 41 | + |
| 42 | +### Style import changed |
| 43 | + |
| 44 | +```diff |
| 45 | +-import 'graphiql/graphiql.css' |
| 46 | ++import 'graphiql/style.css' |
| 47 | +``` |
| 48 | + |
| 49 | +### Toolbar API migration |
| 50 | + |
| 51 | +#### `toolbar.additionalContent` → `<GraphiQL.Toolbar>` |
| 52 | + |
| 53 | +**Before:** |
| 54 | + |
| 55 | +```tsx |
| 56 | +<GraphiQL toolbar={{ additionalContent: <button>My button</button> }} /> |
| 57 | +``` |
| 58 | + |
| 59 | +**After:** |
| 60 | + |
| 61 | +```jsx |
| 62 | +<GraphiQL> |
| 63 | + <GraphiQL.Toolbar> |
| 64 | + {({ merge, prettify, copy }) => ( |
| 65 | + <> |
| 66 | + {prettify} |
| 67 | + {merge} |
| 68 | + {copy} |
| 69 | + <button>My button</button> |
| 70 | + </> |
| 71 | + )} |
| 72 | + </GraphiQL.Toolbar> |
| 73 | +</GraphiQL> |
| 74 | +``` |
| 75 | + |
| 76 | +--- |
| 77 | + |
| 78 | +#### `toolbar.additionalComponent` → `<GraphiQL.Toolbar>` |
| 79 | + |
| 80 | +**Before:** |
| 81 | + |
| 82 | +```jsx |
| 83 | +<GraphiQL |
| 84 | + toolbar={{ |
| 85 | + additionalComponent: function MyComponentWithAccessToContext() { |
| 86 | + return <button>My button</button>; |
| 87 | + }, |
| 88 | + }} |
| 89 | +/> |
| 90 | +``` |
| 91 | + |
| 92 | +**After:** |
| 93 | + |
| 94 | +```jsx |
| 95 | +<GraphiQL> |
| 96 | + <GraphiQL.Toolbar> |
| 97 | + {({ merge, prettify, copy }) => ( |
| 98 | + <> |
| 99 | + {prettify} |
| 100 | + {merge} |
| 101 | + {copy} |
| 102 | + <MyComponentWithAccessToContext /> |
| 103 | + </> |
| 104 | + )} |
| 105 | + </GraphiQL.Toolbar> |
| 106 | +</GraphiQL> |
| 107 | +``` |
| 108 | + |
| 109 | +--- |
| 110 | + |
| 111 | +#### Customizing default toolbar buttons |
| 112 | + |
| 113 | +You can reorder or remove default toolbar buttons: |
| 114 | + |
| 115 | +```tsx |
| 116 | +<GraphiQL> |
| 117 | + <GraphiQL.Toolbar> |
| 118 | + {({ prettify, copy }) => ( |
| 119 | + <> |
| 120 | + {copy} {/* Move copy button to the top */} |
| 121 | + {prettify} {/* Omit merge button */} |
| 122 | + </> |
| 123 | + )} |
| 124 | + </GraphiQL.Toolbar> |
| 125 | +</GraphiQL> |
| 126 | +``` |
| 127 | + |
| 128 | +--- |
| 129 | + |
| 130 | +## `@graphiql/react` |
| 131 | + |
| 132 | +- Dropped support for **React 16/17**, added support for **React 19** |
| 133 | +- Dropped **CommonJS** build output |
| 134 | +- Improved UI of tabs |
| 135 | +- Updated dependencies: `@radix-ui` and `@headlessui/react` |
| 136 | +- Added `onPrettifyQuery` callback for custom formatting |
| 137 | +- Improved Markdown handling (ignores single newlines) |
| 138 | +- Style import changed: |
22 | 139 | ```diff |
23 | | - -import GraphiQL from 'graphiql' |
24 | | - +import { GraphiQL } from 'graphiql' |
25 | | - ``` |
26 | | -- Remove `disableTabs` option |
27 | | -- Respect a Markdown format - ignore single newline |
28 | | -- Replace `Tooltip`s in tabs with html `title="..."` attribute |
29 | | -- Style import was changed |
30 | | - ```diff |
31 | | - -graphiql/graphiql.css |
32 | | - +graphiql/style.css |
33 | | - ``` |
34 | | -- Remove `toolbar.additionalContent` and `toolbar.additionalComponent` props in favor of `GraphiQL.Toolbar` render props |
35 | | - |
36 | | - ### Migration from `toolbar.additionalContent` |
37 | | - |
38 | | - #### Before |
39 | | - |
40 | | - ```jsx |
41 | | - <GraphiQL toolbar={{ additionalContent: <button>My button</button> }} /> |
42 | | - ``` |
43 | | - |
44 | | - #### After |
45 | | - |
46 | | - ```jsx |
47 | | - <GraphiQL> |
48 | | - <GraphiQL.Toolbar> |
49 | | - {({ merge, prettify, copy }) => ( |
50 | | - <> |
51 | | - {prettify} |
52 | | - {merge} |
53 | | - {copy} |
54 | | - <button>My button</button> |
55 | | - </> |
56 | | - )} |
57 | | - </GraphiQL.Toolbar> |
58 | | - </GraphiQL> |
| 140 | + -import '@graphiql/react/dist/style.css' |
| 141 | + +import '@graphiql/react/style.css' |
59 | 142 | ``` |
60 | 143 |
|
61 | | - ### Migration from `toolbar.additionalComponent` |
| 144 | +--- |
62 | 145 |
|
63 | | - #### Before |
| 146 | +## `@graphiql/plugin-code-exporter` |
64 | 147 |
|
65 | | - ```jsx |
66 | | - <GraphiQL |
67 | | - toolbar={{ |
68 | | - additionalComponent: function MyComponentWithAccessToContext() { |
69 | | - return <button>My button</button>; |
70 | | - }, |
71 | | - }} |
72 | | - /> |
73 | | - ``` |
74 | | - |
75 | | - #### After |
76 | | - |
77 | | - ```jsx |
78 | | - <GraphiQL> |
79 | | - <GraphiQL.Toolbar> |
80 | | - {({ merge, prettify, copy }) => ( |
81 | | - <> |
82 | | - {prettify} |
83 | | - {merge} |
84 | | - {copy} |
85 | | - <MyComponentWithAccessToContext /> |
86 | | - </> |
87 | | - )} |
88 | | - </GraphiQL.Toolbar> |
89 | | - </GraphiQL> |
90 | | - ``` |
91 | | - |
92 | | - *** |
93 | | - |
94 | | - Additionally, you can sort default toolbar buttons in different order or remove unneeded buttons for you: |
95 | | - |
96 | | - ```jsx |
97 | | - <GraphiQL> |
98 | | - <GraphiQL.Toolbar> |
99 | | - {({ prettify, copy }) => ( |
100 | | - <> |
101 | | - {copy /* Copy button will be first instead of default last */} |
102 | | - {/* Merge button is removed from toolbar */} |
103 | | - {prettify} |
104 | | - </> |
105 | | - )} |
106 | | - </GraphiQL.Toolbar> |
107 | | - </GraphiQL> |
108 | | - ``` |
109 | | - |
110 | | -## `@graphiql/react` changes |
111 | | - |
112 | | -- New looks of tabs |
113 | | -- Drop CommonJS build output |
114 | | -- Drop support React 16/17 |
115 | | -- Support React 19 |
116 | | -- Update `@radix-ui` and `@headlessui/react` dependencies |
117 | | -- Add support for `onPrettifyQuery` callback to enable customized query formatting |
118 | | -- `style.css` import was changed |
| 148 | +- Dropped support for **React 16/17**, added support for **React 19** |
| 149 | +- Dropped **CommonJS** build output |
| 150 | +- Updated ESM-based CDN example: |
| 151 | + [code-exporter ESM CDN example](../../packages/graphiql-plugin-code-exporter/example/index.html) |
| 152 | +- ⚠️ UMD build deprecated – migrate to ESM-based CDN |
| 153 | +- Style import changed: |
119 | 154 | ```diff |
120 | | - -import '@graphiql/react/dist/style.css'; |
121 | | - +import '@graphiql/react/style.css'; |
| 155 | + -import '@graphiql/plugin-code-exporter/dist/style.css' |
| 156 | + +import '@graphiql/plugin-code-exporter/style.css' |
122 | 157 | ``` |
123 | | -- Respect a Markdown format - ignore single newline |
124 | | - |
125 | | -## `@graphiql/plugin-code-exporter` changes |
126 | 158 |
|
127 | | -- Drop CommonJS build output |
128 | | -- Drop support React 16/17 |
129 | | -- Support React 19 |
130 | | -- ⚠️ UMD CDN build `index.umd.js` is deprecated. Migrate to ESM-based CDN |
131 | | -- [Updated CDN ESM-based example](../../packages/graphiql-plugin-code-exporter/example/index.html) |
132 | | -- `style.css` import was changed |
133 | | - ```diff |
134 | | - -import '@graphiql/plugin-code-exporter/dist/style.css'; |
135 | | - +import '@graphiql/plugin-code-exporter/style.css'; |
136 | | - ``` |
| 159 | +--- |
137 | 160 |
|
138 | | -## `@graphiql/plugin-explorer` changes |
| 161 | +## `@graphiql/plugin-explorer` |
139 | 162 |
|
140 | | -- Drop CommonJS build output |
141 | | -- Drop support React 16/17 |
142 | | -- Support React 19 |
143 | | -- ⚠️ UMD CDN build `index.umd.js` is deprecated. Migrate to ESM-based CDN |
144 | | -- [Updated CDN ESM-based example](../../packages/graphiql-plugin-explorer/example/index.html) |
145 | | -- Improve explorer styles |
146 | | -- `style.css` import was changed |
| 163 | +- Dropped support for **React 16/17**, added support for **React 19** |
| 164 | +- Dropped **CommonJS** build output |
| 165 | +- Improved styles for the explorer UI |
| 166 | +- Updated ESM-based CDN example: |
| 167 | + [explorer ESM CDN example](../../packages/graphiql-plugin-explorer/example/index.html) |
| 168 | +- ⚠️ UMD build deprecated – migrate to ESM-based CDN |
| 169 | +- Style import changed: |
147 | 170 | ```diff |
148 | | - -import '@graphiql/plugin-explorer/dist/style.css'; |
149 | | - +import '@graphiql/plugin-explorer/style.css'; |
| 171 | + -import '@graphiql/plugin-explorer/dist/style.css' |
| 172 | + +import '@graphiql/plugin-explorer/style.css' |
150 | 173 | ``` |
0 commit comments