Skip to content
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
2 changes: 1 addition & 1 deletion packages/graphiql-plugin-doc-explorer/src/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ import {
} from 'graphql';
import { FC, ReactElement, ReactNode, useEffect } from 'react';
import {
createBoundedUseStore,
SchemaContextType,
useSchemaStore,
createBoundedUseStore,
} from '@graphiql/react';
import { createStore } from 'zustand';

Expand Down
8 changes: 4 additions & 4 deletions packages/graphiql-plugin-explorer/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React, { CSSProperties, FC, useCallback } from 'react';
import {
GraphiQLPlugin,
useEditorContext,
useExecutionContext,
useEditorStore,
useExecutionStore,
useSchemaStore,
useOperationsEditorState,
useOptimisticState,
Expand Down Expand Up @@ -62,9 +62,9 @@ export type GraphiQLExplorerPluginProps = Omit<
>;

const ExplorerPlugin: FC<GraphiQLExplorerPluginProps> = props => {
const { setOperationName } = useEditorContext({ nonNull: true });
const { setOperationName } = useEditorStore();
const { schema } = useSchemaStore();
const { run } = useExecutionContext({ nonNull: true });
const { run } = useExecutionStore();

// handle running the current operation from the plugin
const handleRunOperation = useCallback(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { ComponentProps } from 'react';
import { formatQuery, HistoryItem } from '../components';
import { HistoryContextProvider } from '../context';
import {
useEditorContext,
useEditorStore,
Tooltip,
StorageContextProvider,
} from '@graphiql/react';
Expand All @@ -16,15 +16,15 @@ vi.mock('@graphiql/react', async () => {
const mockedSetHeaderEditor = vi.fn();
return {
...originalModule,
useEditorContext() {
useEditorStore() {
return {
queryEditor: { setValue: mockedSetQueryEditor },
variableEditor: { setValue: mockedSetVariableEditor },
headerEditor: { setValue: mockedSetHeaderEditor },
tabs: [],
};
},
useExecutionContext() {
useExecutionStore() {
return {};
},
};
Expand Down Expand Up @@ -78,12 +78,10 @@ function getMockProps(
}

describe('QueryHistoryItem', () => {
const mockedSetQueryEditor = useEditorContext()!.queryEditor!
.setValue as Mock;
const mockedSetVariableEditor = useEditorContext()!.variableEditor!
.setValue as Mock;
const mockedSetHeaderEditor = useEditorContext()!.headerEditor!
.setValue as Mock;
const store = useEditorStore();
const mockedSetQueryEditor = store.queryEditor!.setValue as Mock;
const mockedSetVariableEditor = store.variableEditor!.setValue as Mock;
const mockedSetHeaderEditor = store.headerEditor!.setValue as Mock;
beforeEach(() => {
mockedSetQueryEditor.mockClear();
mockedSetVariableEditor.mockClear();
Expand Down
7 changes: 2 additions & 5 deletions packages/graphiql-plugin-history/src/components.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
StarFilledIcon,
StarIcon,
TrashIcon,
useEditorContext,
useEditorStore,
Button,
Tooltip,
UnStyledButton,
Expand Down Expand Up @@ -112,10 +112,7 @@ type QueryHistoryItemProps = {
export const HistoryItem: FC<QueryHistoryItemProps> = props => {
const { editLabel, toggleFavorite, deleteFromHistory, setActive } =
useHistoryActions();
const { headerEditor, queryEditor, variableEditor } = useEditorContext({
nonNull: true,
caller: HistoryItem,
});
const { headerEditor, queryEditor, variableEditor } = useEditorStore();
const inputRef = useRef<HTMLInputElement>(null);
const buttonRef = useRef<HTMLButtonElement>(null);
const [isEditable, setIsEditable] = useState(false);
Expand Down
8 changes: 4 additions & 4 deletions packages/graphiql-plugin-history/src/context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { FC, ReactElement, ReactNode, useEffect } from 'react';
import { createStore } from 'zustand';
import { HistoryStore, QueryStoreItem } from '@graphiql/toolkit';
import {
useExecutionContext,
useEditorContext,
useExecutionStore,
useEditorStore,
useStorage,
createBoundedUseStore,
} from '@graphiql/react';
Expand Down Expand Up @@ -119,8 +119,8 @@ export const HistoryContextProvider: FC<HistoryContextProviderProps> = ({
maxHistoryLength = 20,
children,
}) => {
const { isFetching } = useExecutionContext({ nonNull: true });
const { tabs, activeTabIndex } = useEditorContext({ nonNull: true });
const { isFetching } = useExecutionStore();
const { tabs, activeTabIndex } = useEditorStore();
const activeTab = tabs[activeTabIndex];
const storage = useStorage();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { FC, useEffect } from 'react';
import { clsx } from 'clsx';
import { useEditorContext } from '../context';
import { useEditorStore } from '../context';
import { useHeaderEditor, UseHeaderEditorArgs } from '../header-editor';
import '../style/codemirror.css';
import '../style/fold.css';
Expand All @@ -18,11 +18,8 @@ export const HeaderEditor: FC<HeaderEditorProps> = ({
isHidden,
...hookArgs
}) => {
const { headerEditor } = useEditorContext({
nonNull: true,
caller: HeaderEditor,
});
const ref = useHeaderEditor(hookArgs, HeaderEditor);
const headerEditor = useEditorStore(store => store.headerEditor);
const ref = useHeaderEditor(hookArgs);

useEffect(() => {
if (!isHidden) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import '../style/info.css';
import '../style/editor.css';

export const ResponseEditor: FC<UseResponseEditorArgs> = props => {
const ref = useResponseEditor(props, ResponseEditor);
const ref = useResponseEditor(props);
return (
<section
className="result-window"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { FC, useEffect } from 'react';
import { clsx } from 'clsx';

import { useEditorContext } from '../context';
import { useEditorStore } from '../context';
import { useVariableEditor, UseVariableEditorArgs } from '../variable-editor';

import '../style/codemirror.css';
Expand All @@ -22,11 +22,8 @@ export const VariableEditor: FC<VariableEditorProps> = ({
isHidden,
...hookArgs
}) => {
const { variableEditor } = useEditorContext({
nonNull: true,
caller: VariableEditor,
});
const ref = useVariableEditor(hookArgs, VariableEditor);
const variableEditor = useEditorStore(store => store.variableEditor);
const ref = useVariableEditor(hookArgs);

useEffect(() => {
if (!isHidden) {
Expand Down
Loading
Loading