Skip to content

Commit

Permalink
add missing caller arguments (#2526)
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasheyenbrock authored Jun 30, 2022
1 parent 718755d commit 26e4412
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changeset/short-gifts-heal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@graphiql/react': patch
---

Add missing `caller` arguments to hook calls so that the error message printed when a context provider is missing is more accurate about the component or hook that caused the error
2 changes: 1 addition & 1 deletion packages/graphiql-react/src/editor/header-editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export function useHeaderEditor({
useHeaderEditor,
);

useCompletion(headerEditor);
useCompletion(headerEditor, useHeaderEditor);

useKeyMap(headerEditor, ['Cmd-Enter', 'Ctrl-Enter'], executionContext?.run);
useKeyMap(headerEditor, ['Shift-Ctrl-P'], prettify);
Expand Down
7 changes: 5 additions & 2 deletions packages/graphiql-react/src/editor/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,11 @@ export function useChangeHandler(
]);
}

export function useCompletion(editor: CodeMirrorEditor | null) {
const { schema } = useSchemaContext({ nonNull: true, caller: useCompletion });
export function useCompletion(
editor: CodeMirrorEditor | null,
caller: Function,
) {
const { schema } = useSchemaContext({ nonNull: true, caller });
const explorer = useExplorerContext();
useEffect(() => {
if (!editor) {
Expand Down
2 changes: 1 addition & 1 deletion packages/graphiql-react/src/editor/query-editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ export function useQueryEditor({
codeMirrorRef,
);

useCompletion(queryEditor);
useCompletion(queryEditor, useQueryEditor);

useKeyMap(queryEditor, ['Cmd-Enter', 'Ctrl-Enter'], executionContext?.run);
useKeyMap(queryEditor, ['Shift-Ctrl-C'], copy);
Expand Down
2 changes: 1 addition & 1 deletion packages/graphiql-react/src/editor/variable-editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ export function useVariableEditor({
useVariableEditor,
);

useCompletion(variableEditor);
useCompletion(variableEditor, useVariableEditor);

useKeyMap(variableEditor, ['Cmd-Enter', 'Ctrl-Enter'], executionContext?.run);
useKeyMap(variableEditor, ['Shift-Ctrl-P'], prettify);
Expand Down
4 changes: 3 additions & 1 deletion packages/graphiql-react/src/execution.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ export function ExecutionContextProvider(props: ExecutionContextProviderProps) {
updateActiveTabValues,
} = useEditorContext({ nonNull: true, caller: ExecutionContextProvider });
const history = useHistoryContext();
const autoCompleteLeafs = useAutoCompleteLeafs();
const autoCompleteLeafs = useAutoCompleteLeafs({
caller: ExecutionContextProvider,
});
const [isFetching, setIsFetching] = useState(false);
const [subscription, setSubscription] = useState<Unsubscribable | null>(null);
const queryIdRef = useRef(0);
Expand Down

0 comments on commit 26e4412

Please sign in to comment.