()
| 82 | }); |
| 83 | |
| 84 | export default function Editor(): ReactElement { |
| 85 | const operationsRef = useRef<HTMLDivElement>(null); |
| 86 | const variablesRef = useRef<HTMLDivElement>(null); |
| 87 | const responseRef = useRef<HTMLDivElement>(null); |
| 88 | const typescriptRef = useRef<HTMLDivElement>(null); |
| 89 | const [operationsEditor, setOperationsEditor] = |
| 90 | useState<editor.IStandaloneCodeEditor>(); |
| 91 | const [variablesEditor, setVariablesEditor] = |
| 92 | useState<editor.IStandaloneCodeEditor>(); |
| 93 | const [responseEditor, setResponseEditor] = |
| 94 | useState<editor.IStandaloneCodeEditor>(); |
| 95 | const [typescriptEditor, setTypescriptEditor] = |
| 96 | useState<editor.IStandaloneCodeEditor>(); |
| 97 | const [schema, setSchema] = useState<IntrospectionQuery>(); |
| 98 | const [loading, setLoading] = useState(false); |
| 99 | /** |
| 100 | * Create the models & editors |
| 101 | */ |
| 102 | useEffect(() => { |
| 103 | if (!operationsEditor) { |
| 104 | const codeEditor = editor.create(operationsRef.current!, { |
| 105 | model: MODEL.operations, |
| 106 | ...DEFAULT_EDITOR_OPTIONS, |
| 107 | }); |
| 108 | codeEditor.addAction(queryAction); |
| 109 | MODEL.operations.onDidChangeContent( |
| 110 | debounce(300, () => { |
| 111 | localStorage.setItem( |
| 112 | STORAGE_KEY.operations, |
| 113 | MODEL.operations.getValue(), |
| 114 | ); |
| 115 | }), |
| 116 | ); |
| 117 | setOperationsEditor(codeEditor); |
| 118 | } |
| 119 | if (!variablesEditor) { |
| 120 | const codeEditor = editor.create(variablesRef.current!, { |
| 121 | model: MODEL.variables, |
| 122 | ...DEFAULT_EDITOR_OPTIONS, |
| 123 | }); |
| 124 | codeEditor.addAction(queryAction); |
| 125 | MODEL.variables.onDidChangeContent( |
| 126 | debounce(300, () => { |
| 127 | localStorage.setItem( |
| 128 | STORAGE_KEY.variables, |
| 129 | MODEL.variables.getValue(), |
| 130 | ); |
| 131 | }), |
| 132 | ); |
| 133 | setVariablesEditor(codeEditor); |
| 134 | } |
| 135 | if (!responseEditor) { |
| 136 | setResponseEditor( |
| 137 | editor.create(responseRef.current!, { |
| 138 | model: MODEL.response, |
| 139 | ...DEFAULT_EDITOR_OPTIONS, |
| 140 | readOnly: true, |
| 141 | smoothScrolling: true, |
nothing calls this directly
no test coverage detected
searching dependent graphs…