@@ -12,9 +12,10 @@ import { settingsAtom } from '@yaakapp-internal/models';
1212import type { EditorLanguage , TemplateFunction } from '@yaakapp-internal/plugins' ;
1313import { parseTemplate } from '@yaakapp-internal/templates' ;
1414import classNames from 'classnames' ;
15+ import type { GraphQLSchema } from 'graphql' ;
1516import { useAtomValue } from 'jotai' ;
1617import { md5 } from 'js-md5' ;
17- import type { MutableRefObject , ReactNode } from 'react' ;
18+ import type { ReactNode , RefObject } from 'react' ;
1819import {
1920 Children ,
2021 cloneElement ,
@@ -77,6 +78,7 @@ export interface EditorProps {
7778 hideGutter ?: boolean ;
7879 id ?: string ;
7980 language ?: EditorLanguage | 'pairs' | 'url' ;
81+ graphQLSchema ?: GraphQLSchema | null ;
8082 onBlur ?: ( ) => void ;
8183 onChange ?: ( value : string ) => void ;
8284 onFocus ?: ( ) => void ;
@@ -115,6 +117,7 @@ export const Editor = forwardRef<EditorView | undefined, EditorProps>(function E
115117 format,
116118 heightMode,
117119 hideGutter,
120+ graphQLSchema,
118121 language,
119122 onBlur,
120123 onChange,
@@ -374,6 +377,7 @@ export const Editor = forwardRef<EditorView | undefined, EditorProps>(function E
374377 onClickVariable,
375378 onClickMissingVariable,
376379 onClickPathParameter,
380+ graphQLSchema : graphQLSchema ?? null ,
377381 } ) ;
378382 view . dispatch ( { effects : languageCompartment . reconfigure ( ext ) } ) ;
379383 } , [
@@ -386,6 +390,7 @@ export const Editor = forwardRef<EditorView | undefined, EditorProps>(function E
386390 onClickPathParameter ,
387391 completionOptions ,
388392 useTemplating ,
393+ graphQLSchema ,
389394 ] ) ;
390395
391396 // Initialize the editor when ref mounts
@@ -408,6 +413,7 @@ export const Editor = forwardRef<EditorView | undefined, EditorProps>(function E
408413 onClickVariable,
409414 onClickMissingVariable,
410415 onClickPathParameter,
416+ graphQLSchema : graphQLSchema ?? null ,
411417 } ) ;
412418 const extensions = [
413419 languageCompartment . of ( langExt ) ,
@@ -595,12 +601,12 @@ function getExtensions({
595601} : Pick < EditorProps , 'singleLine' | 'readOnly' | 'hideGutter' > & {
596602 stateKey : EditorProps [ 'stateKey' ] ;
597603 container : HTMLDivElement | null ;
598- onChange : MutableRefObject < EditorProps [ 'onChange' ] > ;
599- onPaste : MutableRefObject < EditorProps [ 'onPaste' ] > ;
600- onPasteOverwrite : MutableRefObject < EditorProps [ 'onPasteOverwrite' ] > ;
601- onFocus : MutableRefObject < EditorProps [ 'onFocus' ] > ;
602- onBlur : MutableRefObject < EditorProps [ 'onBlur' ] > ;
603- onKeyDown : MutableRefObject < EditorProps [ 'onKeyDown' ] > ;
604+ onChange : RefObject < EditorProps [ 'onChange' ] > ;
605+ onPaste : RefObject < EditorProps [ 'onPaste' ] > ;
606+ onPasteOverwrite : RefObject < EditorProps [ 'onPasteOverwrite' ] > ;
607+ onFocus : RefObject < EditorProps [ 'onFocus' ] > ;
608+ onBlur : RefObject < EditorProps [ 'onBlur' ] > ;
609+ onKeyDown : RefObject < EditorProps [ 'onKeyDown' ] > ;
604610} ) {
605611 // TODO: Ensure tooltips render inside the dialog if we are in one.
606612 const parent =
0 commit comments