mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-04-23 00:58:32 +02:00
Tweak schema menu
This commit is contained in:
@@ -65,11 +65,7 @@ export function GraphQLEditor({ body, onChange, baseRequest, ...extraEditorProps
|
|||||||
const actions = useMemo<EditorProps['actions']>(
|
const actions = useMemo<EditorProps['actions']>(
|
||||||
() => [
|
() => [
|
||||||
<div key="introspection" className="!opacity-100">
|
<div key="introspection" className="!opacity-100">
|
||||||
{isLoading ? (
|
{schema === undefined ? null /* Initializing */ : !error ? (
|
||||||
<Button size="sm" variant="border" onClick={refetch} isLoading>
|
|
||||||
{isLoading ? 'Introspecting' : 'Schema'}
|
|
||||||
</Button>
|
|
||||||
) : !error ? (
|
|
||||||
<Dropdown
|
<Dropdown
|
||||||
items={[
|
items={[
|
||||||
{
|
{
|
||||||
@@ -86,7 +82,7 @@ export function GraphQLEditor({ body, onChange, baseRequest, ...extraEditorProps
|
|||||||
variant: 'danger',
|
variant: 'danger',
|
||||||
leftSlot: <Icon icon="trash" />,
|
leftSlot: <Icon icon="trash" />,
|
||||||
},
|
},
|
||||||
{type: 'separator', label: 'Setting'},
|
{ type: 'separator', label: 'Setting' },
|
||||||
{
|
{
|
||||||
key: 'auto_fetch',
|
key: 'auto_fetch',
|
||||||
label: 'Automatic Introspection',
|
label: 'Automatic Introspection',
|
||||||
@@ -112,9 +108,10 @@ export function GraphQLEditor({ body, onChange, baseRequest, ...extraEditorProps
|
|||||||
size="sm"
|
size="sm"
|
||||||
variant="border"
|
variant="border"
|
||||||
title="Refetch Schema"
|
title="Refetch Schema"
|
||||||
color={schema ? 'default' : 'warning'}
|
isLoading={isLoading}
|
||||||
|
color={isLoading || schema ? 'default' : 'warning'}
|
||||||
>
|
>
|
||||||
{schema ? 'Schema' : 'No Schema'}
|
{isLoading ? 'Introspecting' : schema ? 'Schema' : 'No Schema'}
|
||||||
</Button>
|
</Button>
|
||||||
</Dropdown>
|
</Dropdown>
|
||||||
) : (
|
) : (
|
||||||
|
|||||||
@@ -85,8 +85,11 @@ export function useIntrospectGraphQL(
|
|||||||
}, [setIntrospection]);
|
}, [setIntrospection]);
|
||||||
|
|
||||||
const schema = useMemo(() => {
|
const schema = useMemo(() => {
|
||||||
|
if (introspection == null) {
|
||||||
|
return introspection;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
return introspection ? buildClientSchema(introspection) : undefined;
|
return buildClientSchema(introspection);
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
setError('message' in e ? e.message : String(e));
|
setError('message' in e ? e.message : String(e));
|
||||||
|
|||||||
Reference in New Issue
Block a user