File tree Expand file tree Collapse file tree 4 files changed +23
-7
lines changed
packages/graphiql-react/src Expand file tree Collapse file tree 4 files changed +23
-7
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ ' graphiql ' : patch
3
+ ' @graphiql/react ' : patch
4
+ ---
5
+
6
+ fix can't access property "jsonDefaults"
Original file line number Diff line number Diff line change @@ -27,9 +27,11 @@ import {
27
27
import {
28
28
DEFAULT_PRETTIFY_QUERY ,
29
29
DEFAULT_QUERY ,
30
+ JSON_DIAGNOSTIC_OPTIONS ,
30
31
STORAGE_KEY ,
31
32
} from '../constants' ;
32
33
import { getDefaultTabState } from '../utility/tabs' ;
34
+ import { languages } from '../monaco-editor' ;
33
35
34
36
interface InnerGraphiQLProviderProps
35
37
extends EditorProps ,
@@ -328,6 +330,16 @@ const InnerGraphiQLProvider: FC<InnerGraphiQLProviderProps> = ({
328
330
} ;
329
331
} , [ ] ) ;
330
332
333
+ useEffect ( ( ) => {
334
+ /**
335
+ * Set diagnostics options for JSON
336
+ *
337
+ * Setting it on mount fix Uncaught TypeError: Cannot read properties of undefined (reading 'jsonDefaults')
338
+ * @see https://github.com/graphql/graphiql/pull/4042#issuecomment-3017167375
339
+ */
340
+ languages . json . jsonDefaults . setDiagnosticsOptions ( JSON_DIAGNOSTIC_OPTIONS ) ;
341
+ } , [ ] ) ;
342
+
331
343
return (
332
344
< GraphiQLContext . Provider value = { storeRef } >
333
345
{ children }
Original file line number Diff line number Diff line change @@ -126,16 +126,13 @@ export const URI_NAME = {
126
126
} as const ;
127
127
128
128
// set these early on so that initial variables with comments don't flash an error
129
- const JSON_DIAGNOSTIC_OPTIONS : languages . json . DiagnosticsOptions = {
129
+ export const JSON_DIAGNOSTIC_OPTIONS : languages . json . DiagnosticsOptions = {
130
130
// Fixes Comments are not permitted in JSON.(521)
131
131
allowComments : true ,
132
132
// Fixes Trailing comma json(519)
133
133
trailingCommas : 'ignore' ,
134
134
} ;
135
135
136
- // Set diagnostics options for JSON
137
- languages . json . jsonDefaults . setDiagnosticsOptions ( JSON_DIAGNOSTIC_OPTIONS ) ;
138
-
139
136
export const MONACO_GRAPHQL_DIAGNOSTIC_SETTINGS : DiagnosticSettings = {
140
137
validateVariablesJSON : { } ,
141
138
jsonDiagnosticSettings : {
Original file line number Diff line number Diff line change @@ -25,15 +25,16 @@ import { MouseTargetFactory } from 'monaco-editor/esm/vs/editor/browser/controll
25
25
if ( navigator . userAgent . includes ( 'Firefox/' ) ) {
26
26
const originalFn = MouseTargetFactory . _doHitTestWithCaretPositionFromPoint ;
27
27
28
- // @ts -expect-error -- internal override of Monaco method
29
- MouseTargetFactory . _doHitTestWithCaretPositionFromPoint = ( ...args ) => {
28
+ MouseTargetFactory . _doHitTestWithCaretPositionFromPoint = (
29
+ ...args : any [ ]
30
+ ) => {
30
31
const [ ctx , coords ] = args ;
31
32
const hitResult = ctx . viewDomNode . ownerDocument . caretPositionFromPoint (
32
33
coords . clientX ,
33
34
coords . clientY ,
34
35
) ;
35
36
if ( hitResult ) {
36
- // Delegate to original function if hitResult is valid
37
+ // Delegate to the original function if hitResult is valid
37
38
const result = originalFn ( ...args ) ;
38
39
return result ;
39
40
}
You can’t perform that action at this time.
0 commit comments