Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(deps): use React v17 consistently #2397

Merged
merged 9 commits into from
May 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .changeset/hungry-colts-raise.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
'example-graphiql-webpack': patch
'example-monaco-graphql-webpack': patch
'graphiql': patch
'graphiql-2-rfc-context': patch
---

upgrade to React v17
7 changes: 3 additions & 4 deletions examples/graphiql-cdn/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@
-->
<script
crossorigin
src="https://unpkg.com/react@16/umd/react.development.js"
src="https://unpkg.com/react@17/umd/react.development.js"
></script>
<script
crossorigin
src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"
src="https://unpkg.com/react-dom@17/umd/react-dom.development.js"
></script>

<!--
Expand All @@ -51,11 +51,10 @@
src="https://unpkg.com/graphiql/graphiql.min.js"
type="application/javascript"
></script>
<script src="/renderExample.js" type="application/javascript"></script>
<script>
function graphQLFetcher(graphQLParams) {
return fetch(
'https://swapi-graphql.netlify.com/.netlify/functions/index',
'https://swapi-graphql.netlify.app/.netlify/functions/index',
{
method: 'post',
headers: {
Expand Down
6 changes: 3 additions & 3 deletions examples/graphiql-create-react-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
"dependencies": {
"graphiql": "file:../../packages/graphiql",
"graphql": "^16.4.0",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-scripts": "3.4.1"
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-scripts": "5.0.1"
},
"scripts": {
"start": "react-scripts start",
Expand Down
1 change: 1 addition & 0 deletions examples/graphiql-parcel/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.parcel-cache
6 changes: 3 additions & 3 deletions examples/graphiql-parcel/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@
"dependencies": {
"graphiql": "file:../../packages/graphiql",
"graphql": "^16.4.0",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"typescript": "^3.4.4"
},
"devDependencies": {
"parcel-bundler": "^1.12.4",
"parcel": "^2.5.0",
"worker-loader": "^2.0.0"
}
}
2 changes: 1 addition & 1 deletion examples/graphiql-parcel/src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@

<body>
<div id="root"></div>
<script src="./index.tsx"></script>
<script type="module" src="./index.tsx"></script>
</body>
</html>
2 changes: 1 addition & 1 deletion examples/graphiql-webpack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"cross-env": "^7.0.2",
"css-loader": "^3.5.1",
"html-webpack-plugin": "^4.2.0",
"react-dom": "^16.12.0",
"react-dom": "^17.0.2",
"style-loader": "^1.1.3",
"webpack": "^4.42.0",
"webpack-cli": "^3.3.11",
Expand Down
2 changes: 1 addition & 1 deletion examples/monaco-graphql-webpack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"file-loader": "6.2.0",
"html-webpack-plugin": "^4.2.0",
"monaco-editor-webpack-plugin": "^5.0.0",
"react-dom": "^16.12.0",
"react-dom": "^17.0.2",
"style-loader": "^1.1.3",
"typescript": "^4.1.3",
"webpack": "4.42.1",
Expand Down
1 change: 1 addition & 0 deletions packages/graphiql-2-rfc-context/.storybook/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/

module.exports = {
stories: ['../src/components/common/**/*.stories.tsx'],
webpackFinal: async config => {
config.module.rules.push({
test: /\.(ts|tsx)$/,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,8 @@
*
*/

import { configure, addDecorator } from '@storybook/react';
import { addDecorator } from '@storybook/react';
import React from 'react';
import requireContext from 'require-context.macro';
import ThemeProvider from '../src/components/common/themes/provider';

addDecorator(story => <ThemeProvider>{story()}</ThemeProvider>);

configure(
requireContext('../src/components/common', true, /\.stories\.tsx$/),
module,
);
12 changes: 6 additions & 6 deletions packages/graphiql-2-rfc-context/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@
"peerDependencies": {
"graphql": "^15.5.0 || ^16.0.0",
"prop-types": ">=15.5.0",
"react": "^16.8.0",
"react-dom": "^16.8.0"
"react": "^16.8.0 || ^17.0.0 || ^18.0.0",
"react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0"
},
"devDependencies": {
"@storybook/addon-storyshots": "^5.2.8",
"@storybook/react": "^5.2.8",
"@storybook/addon-storyshots": "6.1.21",
"@storybook/react": "6.1.21",
"@testing-library/jest-dom": "^5.4.0",
"@testing-library/react": "9.4.1",
"@types/markdown-it": "^0.0.9",
Expand All @@ -92,8 +92,8 @@
"postcss-loader": "^3.0.0",
"postcss-preset-env": "^6.7.0",
"prop-types": "15.7.2",
"react": "^16.12.0",
"react-dom": "^16.12.0",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-hot-loader": "^4.12.20",
"react-test-renderer": "^16.13.1",
"require-context.macro": "^1.2.2",
Expand Down
54 changes: 31 additions & 23 deletions packages/graphiql-2-rfc-context/resources/index.html.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -7,41 +7,49 @@
-->
<!DOCTYPE html>
<html>
<head>
<style>
body {
height: 100%;
margin: 0;
width: 100%;
overflow: hidden;
}

<head>
<style>
body {
height: 100%;
margin: 0;
width: 100%;
overflow: hidden;
}
#graphiql {
height: 100vh;
}
</style>

#graphiql {
height: 100vh;
}
</style>

<!--
<!--
This GraphiQL example depends on Promise and fetch, which are available in
modern browsers, but can be "polyfilled" for older browsers.
GraphiQL itself depends on React DOM.
If you do not want to rely on a CDN, you can host these files locally or
include them directly in your favored resource bunder.
-->
<script crossorigin src="https://unpkg.com/react@16/umd/react.development.js"></script>
<script crossorigin src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script>
<script
crossorigin
src="https://unpkg.com/react@17/umd/react.development.js"
></script>
<script
crossorigin
src="https://unpkg.com/react-dom@17/umd/react-dom.development.js"
></script>

<!--
<!--
These two files can be found in the npm module, however you may wish to
copy them directly into your environment, or perhaps include them in your
favored resource bundler.
-->
</head>

<body>
<div id="graphiql">Loading...</div>
<script defer src="resources/renderExample.js" type="application/javascript"></script>
</body>
</head>

<body>
<div id="graphiql">Loading...</div>
<script
defer
src="resources/renderExample.js"
type="application/javascript"
></script>
</body>
</html>
4 changes: 2 additions & 2 deletions packages/graphiql/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@
"postcss-loader": "^3.0.0",
"postcss-preset-env": "^6.7.0",
"prop-types": "15.7.2",
"react": "^16.12.0",
"react-dom": "^16.12.0",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-hot-loader": "^4.12.20",
"react-test-renderer": "^16.13.1",
"require-context.macro": "^1.2.2",
Expand Down
20 changes: 16 additions & 4 deletions packages/graphiql/resources/index.html.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,14 @@
If you do not want to rely on a CDN, you can host these files locally or
include them directly in your favored resource bunder.
-->
<script crossorigin src="https://unpkg.com/react@16/umd/react.development.js"></script>
<script crossorigin src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script>
<script
crossorigin
src="https://unpkg.com/react@17/umd/react.development.js"
></script>
<script
crossorigin
src="https://unpkg.com/react-dom@17/umd/react-dom.development.js"
></script>

<!--
These two files can be found in the npm module, however you may wish to
Expand All @@ -38,7 +44,13 @@
</head>
<body>
<div id="graphiql">Loading...</div>
<script type="application/javascript"> window.GraphQLVersion = <%= htmlWebpackPlugin.options.graphqlVersion %> </script>
<script defer src="/resources/renderExample.js" type="application/javascript"></script>
<script type="application/javascript">
window.GraphQLVersion = <%= htmlWebpackPlugin.options.graphqlVersion %>
</script>
<script
defer
src="/resources/renderExample.js"
type="application/javascript"
></script>
</body>
</html>
6 changes: 5 additions & 1 deletion packages/graphiql/src/utility/importCodeMirror.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ export async function importCodeMirror(
addons: Promise<any>[],
options?: { useCommonAddons?: boolean },
) {
const { default: CodeMirror } = await import('codemirror');
const CodeMirror = await import('codemirror').then(c =>
// Depending on bundler and settings the dynamic import either returns a
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great find!

// function (e.g. parcel) or an object containing a `default` property
typeof c === 'function' ? c : c.default,
);
const allAddons =
options?.useCommonAddons === false
? addons
Expand Down
3 changes: 2 additions & 1 deletion packages/graphiql/src/utility/onHasCompletion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
} from 'graphql';
import escapeHTML from 'escape-html';
import MD from 'markdown-it';
import { importCodeMirror } from './importCodeMirror';

const md = new MD();

Expand All @@ -26,7 +27,7 @@ export default function onHasCompletion(
data: CM.EditorChange | undefined,
onHintInformationRender: (el: HTMLDivElement) => void,
) {
import('codemirror').then(({ default: CodeMirror }) => {
importCodeMirror([], { useCommonAddons: false }).then(CodeMirror => {
let information: HTMLDivElement | null;
let deprecation: HTMLDivElement | null;
CodeMirror.on(
Expand Down
Loading