exposed field loading state (#5704)

* remove thunk for receivedOpenApiSchema and use RTK query instead. add loading state for exposed fields

* clean up

* ignore any

* fix(ui): do not log on canceled openapi.json queries

- Rely on RTK Query for the `loadSchema` query by providing a custom `jsonReplacer` in our `dynamicBaseQuery`, so we don't need to manage error state.
- Detect when the query was canceled and do not log the error message in those situations.

* feat(ui): `utilitiesApi.endpoints.loadSchema` -> `appInfoApi.endpoints.getOpenAPISchema`

- Utilities is for server actions, move this to `appInfo` bc it fits better there.
- Rename to match convention for HTTP GET queries.
- Fix inverted logic in the `matchRejected` listener (typo'd this)

---------

Co-authored-by: Mary Hipp <maryhipp@Marys-MacBook-Air.local>
Co-authored-by: psychedelicious <4822129+psychedelicious@users.noreply.github.com>
This commit is contained in:
Mary Hipp Rogers
2024-02-12 18:48:32 -05:00
committed by GitHub
parent 1dd07fb1eb
commit 25ce505628
12 changed files with 77 additions and 90 deletions

View File

@ -1,3 +1,5 @@
import { $openAPISchemaUrl } from 'app/store/nanostores/openAPISchemaUrl';
import type { OpenAPIV3_1 } from 'openapi-types';
import type { paths } from 'services/api/schema';
import type { AppConfig, AppDependencyVersions, AppVersion } from 'services/api/types';
@ -57,6 +59,14 @@ export const appInfoApi = api.injectEndpoints({
}),
invalidatesTags: ['InvocationCacheStatus'],
}),
getOpenAPISchema: build.query<OpenAPIV3_1.Document, void>({
query: () => {
const openAPISchemaUrl = $openAPISchemaUrl.get();
const url = openAPISchemaUrl ? openAPISchemaUrl : `${window.location.href.replace(/\/$/, '')}/openapi.json`;
return url;
},
providesTags: ['Schema'],
}),
}),
});
@ -68,4 +78,6 @@ export const {
useDisableInvocationCacheMutation,
useEnableInvocationCacheMutation,
useGetInvocationCacheStatusQuery,
useGetOpenAPISchemaQuery,
useLazyGetOpenAPISchemaQuery,
} = appInfoApi;