Skip to content

Added combined Vars for prepareGqlIntrospectionRequest for all interp… #4661

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 31 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
2de7ba0
Added combined Vars for prepareGqlIntrospectionRequest for all interp…
devendra-bruno May 13, 2025
ad3f5de
Added combined variable object for gqlIntrospectionRequest
devendra-bruno May 13, 2025
9927424
Added mergeEnvironmentVariables method in electron common utils
devendra-bruno May 14, 2025
5000bb8
Added testcases for mergeEnvironmentVariables method
devendra-bruno May 14, 2025
0ca2891
Added mergeEnvironmentVariables method in electron common utils export
devendra-bruno May 14, 2025
8e91640
Added mergeEnvironmentVariables method for gql prep method
devendra-bruno May 14, 2025
62595c5
Added lodash merge for combining vars before interpolateVars
devendra-bruno May 15, 2025
c834366
Remove mergeEnvironmnetVariables from common utils
devendra-bruno May 15, 2025
6598d23
Removed mergeEnvrionmentVariables tests from common.spec.js
devendra-bruno May 15, 2025
0f318c2
Updated precedence in combinedVars object
devendra-bruno May 15, 2025
9d3e42b
Update prepareGqlIntrospectionRequest change assignment sequence
devendra-bruno May 15, 2025
3cd18d1
Added testcases for prepare-gql-introspection-request
devendra-bruno May 15, 2025
5567e1b
Fixed typo in prepareGqlIntrospectionRequest
devendra-bruno May 15, 2025
52662f0
Updated testcases in prepare-gql-introspection spec
devendra-bruno May 19, 2025
8f06889
Remove mergeEnvironmnetVariable method from spec file
devendra-bruno May 21, 2025
6cde453
Added test for prepareGqlIntrospectionRequest
devendra-bruno May 21, 2025
9c9afaf
Extracted fetchGqlSchema handler seperate from ipc handler
devendra-bruno May 21, 2025
548a6b4
Rename combinedVars to resolvedVars
devendra-bruno May 21, 2025
b0c7490
Updated argument request object for useGraphqlSchema hook
devendra-bruno May 21, 2025
b924e15
Added testcases for fetch-gql-schema-handler
devendra-bruno May 21, 2025
f2e9a6a
Added folder level variable support
devendra-bruno May 21, 2025
3e714ab
Updated handler fetch-gql-schema
devendra-bruno May 21, 2025
0948964
Revert changes to common.spec.js
devendra-bruno May 26, 2025
c293cee
Refactored fetch-gql-schema-handler.spec.js
devendra-bruno May 26, 2025
91397ea
Renamed fetchGqlSchema to fetchGqlSchemaHandler
devendra-bruno May 26, 2025
788569a
Added testcases for prepare-gql-introspection-request.spec.js
devendra-bruno May 26, 2025
ce1110b
Added interpolate for header values
devendra-bruno May 26, 2025
9f1aed3
Refactored fetch-gql-schema-handler.spec.js
devendra-bruno May 26, 2025
afb2d3d
Updated resolved variable assignment and testcases
devendra-bruno May 26, 2025
8d5d952
Added runtimeVars in prepareGqlIntrospectionRequest
devendra-bruno May 27, 2025
6f9daad
Update index.js Removed duplicate variable
devendra-bruno May 27, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions packages/bruno-electron/src/ipc/network/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const contentDispositionParser = require('content-disposition');
const mime = require('mime-types');
const FormData = require('form-data');
const { ipcMain } = require('electron');
const { each, get, extend, cloneDeep } = require('lodash');
const { each, get, extend, cloneDeep, merge } = require('lodash');
const { NtlmClient } = require('axios-ntlm');
const { VarsRuntime, AssertRuntime, ScriptRuntime, TestRuntime } = require('@usebruno/js');
const { interpolateString } = require('./interpolate-string');
Expand Down Expand Up @@ -800,9 +800,19 @@ const registerNetworkIpc = (mainWindow) => {

ipcMain.handle('fetch-gql-schema', async (event, endpoint, environment, _request, collection) => {
try {
// selected environment variables on collection level
const envVars = getEnvVars(environment);

const collectionRunTimeVars = collection.runtimeVariables;
const globalEnvironmentVars = collection.globalEnvironmentVariables;
const requestRunTimeVars = _request.vars;

//NOTE: precedence is requestRunTimeVars < collectionRunTimeVars < envVars < globalEnvironmentVars
//NOTE: for more details https://www.geeksforgeeks.org/lodash-_-merge-method/
const combinedVars = merge(requestRunTimeVars, collectionRunTimeVars, envVars, globalEnvironmentVars);

const collectionRoot = get(collection, 'root', {});
const request = prepareGqlIntrospectionRequest(endpoint, envVars, _request, collectionRoot);
const request = prepareGqlIntrospectionRequest(endpoint, combinedVars, _request, collectionRoot);

request.timeout = preferencesUtil.getRequestTimeout();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ const { interpolate } = require('@usebruno/common');
const { getIntrospectionQuery } = require('graphql');
const { setAuthHeaders } = require('./prepare-request');

const prepareGqlIntrospectionRequest = (endpoint, envVars, request, collectionRoot) => {
const prepareGqlIntrospectionRequest = (endpoint, combinedVars, request, collectionRoot) => {
if (endpoint && endpoint.length) {
endpoint = interpolate(endpoint, envVars);
endpoint = interpolate(endpoint, combinedVars);
}

const queryParams = {
Expand Down
2 changes: 1 addition & 1 deletion packages/bruno-electron/tests/utils/common.spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { flattenDataForDotNotation } = require('../../src/utils/common');
const { flattenDataForDotNotation, mergeEnvironmentVariables } = require('../../src/utils/common');

describe('utils: flattenDataForDotNotation', () => {
test('Flatten a simple object with dot notation', () => {
Expand Down