feat: use client certificates and proxy for fetching graphql schema

This commit is contained in:
Max Heidinger 2023-10-18 15:51:19 +02:00
parent 2ce5a6eacb
commit 82abda85fe
4 changed files with 17 additions and 10 deletions

2
package-lock.json generated
View File

@ -16717,7 +16717,7 @@
}, },
"packages/bruno-electron": { "packages/bruno-electron": {
"name": "bruno", "name": "bruno",
"version": "v0.24.0", "version": "v0.25.0",
"dependencies": { "dependencies": {
"@aws-sdk/credential-providers": "^3.425.0", "@aws-sdk/credential-providers": "^3.425.0",
"@usebruno/js": "0.8.0", "@usebruno/js": "0.8.0",

View File

@ -36,12 +36,7 @@ const GraphQLRequestPane = ({ item, collection, leftPaneWidth, onSchemaLoad, tog
const request = item.draft ? item.draft.request : item.request; const request = item.draft ? item.draft.request : item.request;
let { let { schema, loadSchema, isLoading: isSchemaLoading } = useGraphqlSchema(url, environment, request, collection);
schema,
loadSchema,
isLoading: isSchemaLoading,
error: schemaError
} = useGraphqlSchema(url, environment, request, collection);
const loadGqlSchema = () => { const loadGqlSchema = () => {
if (!isSchemaLoading) { if (!isSchemaLoading) {

View File

@ -26,7 +26,12 @@ const useGraphqlSchema = (endpoint, environment, request, collection) => {
const loadSchema = () => { const loadSchema = () => {
setIsLoading(true); setIsLoading(true);
fetchGqlSchema(endpoint, environment, request, collection) fetchGqlSchema(endpoint, environment, request, collection)
.then((res) => res.data) .then((res) => {
if (!res || res.status !== 200) {
return Promise.reject(new Error(res.statusText));
}
return res.data;
})
.then((s) => { .then((s) => {
if (s && s.data) { if (s && s.data) {
setSchema(buildClientSchema(s.data)); setSchema(buildClientSchema(s.data));
@ -40,7 +45,7 @@ const useGraphqlSchema = (endpoint, environment, request, collection) => {
.catch((err) => { .catch((err) => {
setIsLoading(false); setIsLoading(false);
setError(err); setError(err);
toast.error('Error occurred while loading GraphQL Schema'); toast.error(`Error occurred while loading GraphQL Schema: ${err.message}`);
}); });
}; };

View File

@ -486,7 +486,14 @@ const registerNetworkIpc = (mainWindow) => {
const processEnvVars = getProcessEnvVars(collection.uid); const processEnvVars = getProcessEnvVars(collection.uid);
interpolateVars(preparedRequest, envVars, collection.collectionVariables, processEnvVars); interpolateVars(preparedRequest, envVars, collection.collectionVariables, processEnvVars);
const response = await axios(preparedRequest); const axiosInstance = await configureRequest(
collection.uid,
preparedRequest,
envVars,
collection.collectionVariables,
processEnvVars
);
const response = await axiosInstance(preparedRequest);
return { return {
status: response.status, status: response.status,