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

[WIP] Migrate React Context to Zustand #3757

Draft
wants to merge 16 commits into
base: graphiql-v4
Choose a base branch
from
Draft
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"build-docs": "rimraf packages/graphiql/typedoc && typedoc packages",
"build:nontsc": "yarn wsrun:noexamples --exclude-missing --serial build",
"build:clean": "yarn tsc --clean",
"build:watch": "yarn tsc --watch",
"build:watch": "yarn wsrun:noexamples --done-criteria '\"Build success in|built in\"' -t dev",
"build-demo": "wsrun -m build-demo",
"watch": "yarn build:watch",
"watch-vscode": "yarn tsc && yarn workspace vscode-graphql compile",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
// vite.config.mts
import { createRequire } from "node:module";
import { defineConfig } from "file:///home/rikki/projects/graphiql/node_modules/vite/dist/node/index.js";
import react from "file:///home/rikki/projects/graphiql/node_modules/@vitejs/plugin-react/dist/index.mjs";
import svgr from "file:///home/rikki/projects/graphiql/node_modules/vite-plugin-svgr/dist/index.js";
import dts from "file:///home/rikki/projects/graphiql/node_modules/vite-plugin-dts/dist/index.mjs";

// package.json
var package_default = {
name: "@graphiql/plugin-explorer",
version: "4.0.0-alpha.2",
repository: {
type: "git",
url: "https://github.com/graphql/graphiql",
directory: "packages/graphiql-plugin-explorer"
},
main: "dist/index.js",
module: "dist/index.mjs",
types: "dist/index.d.ts",
license: "MIT",
keywords: [
"react",
"graphql",
"graphiql",
"plugin",
"explorer"
],
files: [
"dist"
],
exports: {
"./package.json": "./package.json",
"./style.css": "./dist/style.css",
".": {
import: "./dist/index.mjs",
require: "./dist/index.js",
types: "./dist/index.d.ts"
}
},
scripts: {
dev: "vite build --watch",
build: "vite build && UMD=true vite build",
postbuild: "cp src/graphiql-explorer.d.ts dist/graphiql-explorer.d.ts",
prebuild: "yarn types:check",
"types:check": "tsc --noEmit"
},
dependencies: {
"graphiql-explorer": "^0.9.0"
},
peerDependencies: {
"@graphiql/react": "^1.0.0-alpha.0",
graphql: "^15.5.0 || ^16.0.0 || ^17.0.0-alpha.2",
react: "^16.8.0 || ^17 || ^18",
"react-dom": "^16.8.0 || ^17 || ^18"
},
devDependencies: {
"@graphiql/react": "^1.0.0-alpha.3",
"@vitejs/plugin-react": "^4.3.1",
graphql: "^17.0.0-alpha.7",
react: "^18.2.0",
"react-dom": "^18.2.0",
typescript: "^4.6.3",
vite: "^5.4.0",
"vite-plugin-dts": "^4.0.1",
"vite-plugin-svgr": "^4.2.0"
}
};

// vite.config.mts
var __vite_injected_original_import_meta_url = "file:///home/rikki/projects/graphiql/packages/graphiql-plugin-explorer/vite.config.mts";
var IS_UMD = process.env.UMD === "true";
var vite_config_default = defineConfig({
plugins: [
react({ jsxRuntime: "classic" }),
svgr({
exportAsDefault: true,
svgrOptions: {
titleProp: true
}
}),
!IS_UMD && [dts({ rollupTypes: true }), htmlPlugin()]
],
build: {
minify: IS_UMD ? "terser" : false,
// avoid clean cjs/es builds
emptyOutDir: !IS_UMD,
lib: {
entry: "src/index.tsx",
fileName: "index",
name: "GraphiQLPluginExplorer",
formats: IS_UMD ? ["umd"] : ["cjs", "es"]
},
rollupOptions: {
external: [
// Exclude peer dependencies and dependencies from bundle
...Object.keys(package_default.peerDependencies),
...IS_UMD ? [] : Object.keys(package_default.dependencies)
],
output: {
chunkFileNames: "[name].[format].js",
globals: {
"@graphiql/react": "GraphiQL.React",
graphql: "GraphiQL.GraphQL",
react: "React",
"react-dom": "ReactDOM"
}
}
},
commonjsOptions: {
esmExternals: true,
requireReturnsDefault: "auto"
}
}
});
function htmlPlugin() {
const require2 = createRequire(__vite_injected_original_import_meta_url);
const graphiqlPath = require2.resolve("graphiql/package.json").replace("/package.json", "");
const htmlForVite = `<link rel="stylesheet" href="${graphiqlPath}/src/style.css" />
<script type="module">
import React from 'react';
import ReactDOM from 'react-dom/client';
import GraphiQL from '${graphiqlPath}/src/cdn';
import * as GraphiQLPluginExplorer from './src';

Object.assign(globalThis, { React, ReactDOM, GraphiQL, GraphiQLPluginExplorer });
</script>`;
return {
name: "html-replace-umd-with-src",
transformIndexHtml: {
order: "pre",
handler(html) {
const start = "</style>";
const end = "<body>";
const contentToReplace = html.slice(
html.indexOf(start) + start.length,
html.indexOf(end)
);
return html.replace(contentToReplace, htmlForVite);
}
}
};
}
export {
vite_config_default as default
};
//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsidml0ZS5jb25maWcubXRzIiwgInBhY2thZ2UuanNvbiJdLAogICJzb3VyY2VzQ29udGVudCI6IFsiY29uc3QgX192aXRlX2luamVjdGVkX29yaWdpbmFsX2Rpcm5hbWUgPSBcIi9ob21lL3Jpa2tpL3Byb2plY3RzL2dyYXBoaXFsL3BhY2thZ2VzL2dyYXBoaXFsLXBsdWdpbi1leHBsb3JlclwiO2NvbnN0IF9fdml0ZV9pbmplY3RlZF9vcmlnaW5hbF9maWxlbmFtZSA9IFwiL2hvbWUvcmlra2kvcHJvamVjdHMvZ3JhcGhpcWwvcGFja2FnZXMvZ3JhcGhpcWwtcGx1Z2luLWV4cGxvcmVyL3ZpdGUuY29uZmlnLm10c1wiO2NvbnN0IF9fdml0ZV9pbmplY3RlZF9vcmlnaW5hbF9pbXBvcnRfbWV0YV91cmwgPSBcImZpbGU6Ly8vaG9tZS9yaWtraS9wcm9qZWN0cy9ncmFwaGlxbC9wYWNrYWdlcy9ncmFwaGlxbC1wbHVnaW4tZXhwbG9yZXIvdml0ZS5jb25maWcubXRzXCI7aW1wb3J0IHsgY3JlYXRlUmVxdWlyZSB9IGZyb20gJ25vZGU6b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Y7IiwKICAibmFtZXMiOiBbInJlcXVpcmUiXQp9Cg==
3 changes: 2 additions & 1 deletion packages/graphiql-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@
"get-value": "^3.0.1",
"graphql-language-service": "^5.3.0",
"markdown-it": "^14.1.0",
"set-value": "^4.1.0"
"set-value": "^4.1.0",
"zustand": "^4.5.5"
},
"devDependencies": {
"@babel/helper-string-parser": "^7.19.4",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { StorageAPI } from '@graphiql/toolkit';
import { StorageAPI, getDefaultTabState } from '@graphiql/toolkit';
import {
createTab,
fuzzyExtractOperationName,
getDefaultTabState,
clearHeadersFromTabs,
STORAGE_KEY,
} from '../tabs';

// TODO: move to toolkit

describe('createTab', () => {
it('creates with default title', () => {
expect(createTab({})).toEqual(
Expand Down
3 changes: 2 additions & 1 deletion packages/graphiql-react/src/editor/completion.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Editor, EditorChange } from 'codemirror';

Check failure on line 1 in packages/graphiql-react/src/editor/completion.ts

View workflow job for this annotation

GitHub Actions / ESLint

'Editor' is defined but never used. Allowed unused vars must match /^React$/u
import type { IHint } from 'codemirror-graphql/hint';
import {
GraphQLNamedType,
Expand All @@ -12,13 +12,14 @@
import { markdown } from '../markdown';
import { DOC_EXPLORER_PLUGIN, PluginContextType } from '../plugin';
import { importCodeMirror } from './common';
import { CodeMirrorEditor } from '@graphiql/toolkit';

/**
* Render a custom UI for CodeMirror's hint which includes additional info
* about the type and description for the selected context.
*/
export function onHasCompletion(
_cm: Editor,
_cm: CodeMirrorEditor,
data: EditorChange | undefined,
schema: GraphQLSchema | null | undefined,
explorer: ExplorerContextType | null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@ type HeaderEditorProps = UseHeaderEditorArgs & {
};

export function HeaderEditor({ isHidden, ...hookArgs }: HeaderEditorProps) {
const { headerEditor } = useEditorContext({
nonNull: true,
caller: HeaderEditor,
});
const { headerEditor } = useEditorContext();
const ref = useHeaderEditor(hookArgs, HeaderEditor);

useEffect(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@ type VariableEditorProps = UseVariableEditorArgs & {
};

export function VariableEditor({ isHidden, ...hookArgs }: VariableEditorProps) {
const { variableEditor } = useEditorContext({
nonNull: true,
caller: VariableEditor,
});
const { variableEditor } = useEditorContext();
const ref = useVariableEditor(hookArgs, VariableEditor);

useEffect(() => {
Expand Down
Loading
Loading