Merge pull request #656 from mheidinger/gql-schema-clientcert-proxy

feat: use client certificates and proxy for fetching graphql schema
This commit is contained in:
Anoop M D 2023-10-18 21:07:52 +05:30 committed by GitHub
commit 2c9b1b801a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 10 deletions

2
package-lock.json generated
View File

@ -16717,7 +16717,7 @@
},
"packages/bruno-electron": {
"name": "bruno",
"version": "v0.24.0",
"version": "v0.25.0",
"dependencies": {
"@aws-sdk/credential-providers": "^3.425.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;
let {
schema,
loadSchema,
isLoading: isSchemaLoading,
error: schemaError
} = useGraphqlSchema(url, environment, request, collection);
let { schema, loadSchema, isLoading: isSchemaLoading } = useGraphqlSchema(url, environment, request, collection);
const loadGqlSchema = () => {
if (!isSchemaLoading) {

View File

@ -26,7 +26,12 @@ const useGraphqlSchema = (endpoint, environment, request, collection) => {
const loadSchema = () => {
setIsLoading(true);
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) => {
if (s && s.data) {
setSchema(buildClientSchema(s.data));
@ -40,7 +45,7 @@ const useGraphqlSchema = (endpoint, environment, request, collection) => {
.catch((err) => {
setIsLoading(false);
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);
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 {
status: response.status,