Introspection tweak

This commit is contained in:
Gregory Schier
2024-02-26 17:24:44 -08:00
parent e1ffc387ea
commit 89793ebe2f
3 changed files with 12 additions and 4 deletions

View File

@@ -22,7 +22,7 @@ export function useIntrospectGraphQL(baseRequest: HttpRequest) {
const [refetchKey, setRefetchKey] = useState<number>(0);
const [isLoading, setIsLoading] = useState<boolean>(false);
const [error, setError] = useState<string>();
const [introspection, setIntrospection] = useLocalStorage<IntrospectionQuery>(
const [introspection, setIntrospection] = useLocalStorage<IntrospectionQuery | null>(
`introspection:${baseRequest.id}`,
);
@@ -61,7 +61,10 @@ export function useIntrospectGraphQL(baseRequest: HttpRequest) {
const runIntrospection = () => {
fetchIntrospection()
.catch((e) => setError(e.message))
.catch((e) => {
setIntrospection(null);
setError(e.message);
})
.finally(() => setIsLoading(false));
};
@@ -82,5 +85,6 @@ export function useIntrospectGraphQL(baseRequest: HttpRequest) {
[introspection],
);
console.log('SCHEMA', introspection);
return { schema, isLoading, error, refetch };
}