@graphiql/react
Advanced tools
Comparing version 0.5.0-canary-e719c66a.0 to 0.5.0-canary-e7d3c23c.0
{ | ||
"name": "@graphiql/react", | ||
"version": "0.5.0-canary-e719c66a.0", | ||
"version": "0.5.0-canary-e7d3c23c.0", | ||
"repository": { | ||
@@ -5,0 +5,0 @@ "type": "git", |
import type { Editor, EditorChange } from 'codemirror'; | ||
import type { IHint } from 'codemirror-graphql/hint'; | ||
import { GraphQLSchema, GraphQLType, isListType, isNonNullType } from 'graphql'; | ||
import { | ||
GraphQLNamedType, | ||
GraphQLSchema, | ||
GraphQLType, | ||
isListType, | ||
isNonNullType, | ||
} from 'graphql'; | ||
@@ -18,2 +24,3 @@ import { ExplorerContextType } from '../explorer'; | ||
explorer: ExplorerContextType | null, | ||
callback: (type: GraphQLNamedType) => void, | ||
) { | ||
@@ -193,4 +200,5 @@ importCodeMirror([], { useCommonAddons: false }).then(CodeMirror => { | ||
explorer.push({ name: type.name, def: type }); | ||
callback?.(type); | ||
} | ||
} | ||
} |
import { fillLeafs, GetDefaultFieldNamesFn, mergeAst } from '@graphiql/toolkit'; | ||
import { EditorChange } from 'codemirror'; | ||
import copyToClipboard from 'copy-to-clipboard'; | ||
@@ -7,7 +6,5 @@ import { parse, print } from 'graphql'; | ||
import { useExplorerContext } from '../explorer'; | ||
import { useSchemaContext } from '../schema'; | ||
import { useStorageContext } from '../storage'; | ||
import debounce from '../utility/debounce'; | ||
import { onHasCompletion } from './completion'; | ||
import { useEditorContext } from './context'; | ||
@@ -73,30 +70,2 @@ import { CodeMirrorEditor } from './types'; | ||
export function useCompletion(editor: CodeMirrorEditor | null) { | ||
const { schema } = useSchemaContext({ nonNull: true, caller: useCompletion }); | ||
const explorer = useExplorerContext(); | ||
useEffect(() => { | ||
if (!editor) { | ||
return; | ||
} | ||
const handleCompletion = ( | ||
instance: CodeMirrorEditor, | ||
changeObj?: EditorChange, | ||
) => { | ||
onHasCompletion(instance, changeObj, schema, explorer); | ||
}; | ||
editor.on( | ||
// @ts-expect-error @TODO additional args for hasCompletion event | ||
'hasCompletion', | ||
handleCompletion, | ||
); | ||
return () => | ||
editor.off( | ||
// @ts-expect-error @TODO additional args for hasCompletion event | ||
'hasCompletion', | ||
handleCompletion, | ||
); | ||
}, [editor, explorer, schema]); | ||
} | ||
type EmptyCallback = () => void; | ||
@@ -103,0 +72,0 @@ |
import type { Editor, EditorChange } from 'codemirror'; | ||
import { GraphQLSchema } from 'graphql'; | ||
import { GraphQLNamedType, GraphQLSchema } from 'graphql'; | ||
import { ExplorerContextType } from '../explorer'; | ||
@@ -8,2 +8,2 @@ /** | ||
*/ | ||
export declare function onHasCompletion(_cm: Editor, data: EditorChange | undefined, schema: GraphQLSchema | null | undefined, explorer: ExplorerContextType | null): void; | ||
export declare function onHasCompletion(_cm: Editor, data: EditorChange | undefined, schema: GraphQLSchema | null | undefined, explorer: ExplorerContextType | null, callback: (type: GraphQLNamedType) => void): void; |
@@ -6,3 +6,2 @@ import { GetDefaultFieldNamesFn } from '@graphiql/toolkit'; | ||
export declare function useChangeHandler(editor: CodeMirrorEditor | null, callback: EditCallback | undefined, storageKey: string | null, tabProperty: 'variables' | 'headers', caller: Function): void; | ||
export declare function useCompletion(editor: CodeMirrorEditor | null): void; | ||
declare type EmptyCallback = () => void; | ||
@@ -9,0 +8,0 @@ export declare function useKeyMap(editor: CodeMirrorEditor | null, keys: string[], callback: EmptyCallback | undefined): void; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2391929
46111