Skip to content

Commit

Permalink
Merge branch 'staging' into greenkeeper/karma-jasmine-html-reporter-1…
Browse files Browse the repository at this point in the history
….5.0
  • Loading branch information
imolorhe committed Dec 28, 2019
2 parents 730d91c + d7ed0f6 commit 2e9aa9c
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 19 deletions.
11 changes: 7 additions & 4 deletions src/app/effects/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import { debug } from '../utils/logger';
import { generateCurl } from 'app/utils/curl';

interface EffectResponseData {
state: fromRoot.State;
data: fromRoot.PerWindowState;
windowId: string;
action: any;
Expand All @@ -53,7 +54,7 @@ export class QueryEffects {
.pipe(
ofType(queryActions.SEND_QUERY_REQUEST, queryActions.CANCEL_QUERY_REQUEST),
withLatestFrom(this.store, (action: queryActions.Action, state: fromRoot.State) => {
return { data: state.windows[action.windowId], windowId: action.windowId, action };
return { state, data: state.windows[action.windowId], windowId: action.windowId, action };
}),
switchMap(response => {

Expand Down Expand Up @@ -179,6 +180,7 @@ export class QueryEffects {
method: response.data.query.httpVerb,
selectedOperation,
files: response.data.variables.files,
withCredentials: response.state.settings['request.withCredentials'],
})
.pipe(
map(res => {
Expand Down Expand Up @@ -302,7 +304,7 @@ export class QueryEffects {
.pipe(
ofType(queryActions.SEND_INTROSPECTION_QUERY_REQUEST),
withLatestFrom(this.store, (action: queryActions.Action, state: fromRoot.State) => {
return { data: state.windows[action.windowId], windowId: action.windowId, action };
return { state, data: state.windows[action.windowId], windowId: action.windowId, action };
}),
switchMap(response => {
return this.getPrerequestTransformedData$(response);
Expand Down Expand Up @@ -332,7 +334,8 @@ export class QueryEffects {
return this.gqlService
.getIntrospectionRequest(url, {
method: response.data.query.httpVerb,
headers
headers,
withCredentials: response.state.settings['request.withCredentials'],
})
.pipe(
catchError((err: any) => {
Expand Down Expand Up @@ -430,7 +433,7 @@ export class QueryEffects {
.pipe(
ofType(queryActions.START_SUBSCRIPTION),
withLatestFrom(this.store, (action: queryActions.Action, state: fromRoot.State) => {
return { data: state.windows[action.windowId], windowId: action.windowId, action };
return { state, data: state.windows[action.windowId], windowId: action.windowId, action };
}),
switchMap(response => {
return this.getPrerequestTransformedData$(response);
Expand Down
3 changes: 2 additions & 1 deletion src/app/reducers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,10 @@ export const keySerializer = (key: string) => `${getAltairInstanceStorageNamespa

export function localStorageSyncReducer(_reducer: ActionReducer<any>): ActionReducer<any> {
return localStorageSync({
keys: ['windows', 'windowsMeta', 'settings', 'environments'],
keys: [ 'windows', 'windowsMeta', 'settings', 'environments' ],
rehydrate: true,
storage: performantLocalStorage,
restoreDates: false,
// syncCondition: (state) => console.log(state),
storageKeySerializer: keySerializer
})(_reducer);
Expand Down
5 changes: 5 additions & 0 deletions src/app/reducers/settings/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ export interface State {
* Specifies a list of enabled plugins (requires enableExperimental to be true)
*/
'plugin.list'?: string[];

/**
* Specifies if requests should be sent with credentials (with cookies) or not
*/
'request.withCredentials'?: boolean;
}

export const getInitialState = (): State => {
Expand Down
34 changes: 28 additions & 6 deletions src/app/services/gql/gql.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ import { SelectedOperation } from 'app/reducers/query/query';
interface SendRequestOptions {
query: string;
method: string;
withCredentials?: boolean;
variables?: string;
headers?: fromHeaders.Header[];
files?: fromVariables.FileVariable[];
Expand Down Expand Up @@ -100,7 +101,14 @@ export class GqlService {
* @param query
* @param vars
*/
_send(query: string, vars?: string, selectedOperation?: SelectedOperation, files?: fromVariables.FileVariable[]) {
_send({
query,
variables,
selectedOperation,
files,
withCredentials,
}: Omit<SendRequestOptions, 'method'>,
) {
const data = { query, variables: {}, operationName: (null as SelectedOperation) };
let body: FormData | string | undefined;
let params: HttpParams | undefined;
Expand All @@ -111,9 +119,9 @@ export class GqlService {
}

// If there is a variables option, add it to the data
if (vars) {
if (variables) {
try {
data.variables = JSON.parse(vars);
data.variables = JSON.parse(variables);
} catch (err) {
// Notify the user about badly written variables.
debug.error(err);
Expand Down Expand Up @@ -153,6 +161,7 @@ export class GqlService {
params,
headers,
observe: 'response',
withCredentials,
})
.pipe(
catchError((err: HttpErrorResponse) => {
Expand Down Expand Up @@ -185,8 +194,14 @@ export class GqlService {
* @param query
* @param vars
*/
send(query: string, vars?: string, selectedOperation?: string, files?: fromVariables.FileVariable[]) {
return this._send(query, vars, selectedOperation, files).pipe(map(res => res.body));
send(query: string, vars?: string, selectedOperation?: string, files?: fromVariables.FileVariable[], withCredentials?: boolean) {
return this._send({
query,
variables: vars,
selectedOperation,
files,
withCredentials,
}).pipe(map(res => res.body));
}

sendRequest(url: string, opts: SendRequestOptions) {
Expand All @@ -197,7 +212,13 @@ export class GqlService {
// Skip json default headers for files
.setHeaders(opts.headers, { skipDefaults: this.isGETRequest(opts.method) || !!(files && files.length) });

return this._send(opts.query, opts.variables, opts.selectedOperation, files);
return this._send({
query: opts.query,
variables: opts.variables,
selectedOperation: opts.selectedOperation,
files: opts.files,
withCredentials: opts.withCredentials,
});
}

isGETRequest(method = this.method) {
Expand Down Expand Up @@ -251,6 +272,7 @@ export class GqlService {
query: getIntrospectionQuery(),
headers: opts.headers,
method: opts.method,
withCredentials: opts.withCredentials,
variables: '{}',
};
return this.sendRequest(url, requestOpts).pipe(
Expand Down
21 changes: 13 additions & 8 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4661,7 +4661,7 @@ commander@2.9.0:
dependencies:
graceful-readlink ">= 1.0.0"

commander@^2.11.0, commander@^2.20.0, commander@~2.20.0:
commander@^2.11.0, commander@^2.20.0:
version "2.20.0"
resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.0.tgz#d58bb2b5c1ee8f87b0d340027e9e94e222c5a422"
integrity sha512-7j2y+40w61zy6YC2iRNpUe/NwhNyoXrYpHMrSunaMG64nRnaf96zO/KMQR4OyN/UnE5KLyEBnKHd4aG3rskjpQ==
Expand All @@ -4674,6 +4674,11 @@ commander@^2.19.0:
version "2.19.0"
resolved "https://registry.yarnpkg.com/commander/-/commander-2.19.0.tgz#f6198aa84e5b83c46054b94ddedbfed5ee9ff12a"

commander@~2.20.3:
version "2.20.3"
resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33"
integrity sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==

comment-regex@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/comment-regex/-/comment-regex-1.0.1.tgz#e070d2c4db33231955d0979d27c918fcb6f93565"
Expand Down Expand Up @@ -7350,9 +7355,9 @@ handle-thing@^2.0.0:
integrity sha512-d4sze1JNC454Wdo2fkuyzCr6aHcbL6PGGuFAz0Li/NcOm1tCHGnWDRmJP85dh9IhQErTc2svWFEX5xHIOo//kQ==

handlebars@^4.1.0, handlebars@^4.1.2:
version "4.1.2"
resolved "https://registry.yarnpkg.com/handlebars/-/handlebars-4.1.2.tgz#b6b37c1ced0306b221e094fc7aca3ec23b131b67"
integrity sha512-nvfrjqvt9xQ8Z/w0ijewdD/vvWDTOweBUm96NTr66Wfvo1mJenBLwcYmPs3TIBP5ruzYGD7Hx/DaM9RmhroGPw==
version "4.5.3"
resolved "https://registry.yarnpkg.com/handlebars/-/handlebars-4.5.3.tgz#5cf75bd8714f7605713511a56be7c349becb0482"
integrity sha512-3yPecJoJHK/4c6aZhSvxOyG4vJKDshV36VHp0iVCDVh7o9w2vwi3NSnL2MMPj3YdduqaBcu7cGbggJQM0br9xA==
dependencies:
neo-async "^2.6.0"
optimist "^0.6.1"
Expand Down Expand Up @@ -13684,11 +13689,11 @@ typescript@^3.4.5:
integrity sha512-YycBxUb49UUhdNMU5aJ7z5Ej2XGmaIBL0x34vZ82fn3hGvD+bgrMrVDpatgz2f7YxUMJxMkbWxJZeAvDxVe7Vw==

uglify-js@^3.1.4:
version "3.6.0"
resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.6.0.tgz#704681345c53a8b2079fb6cec294b05ead242ff5"
integrity sha512-W+jrUHJr3DXKhrsS7NUVxn3zqMOFn0hL/Ei6v0anCIMoKC93TjcflTagwIHLW7SfMFfiQuktQyFVCFHGUE0+yg==
version "3.7.3"
resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.7.3.tgz#f918fce9182f466d5140f24bb0ff35c2d32dcc6a"
integrity sha512-7tINm46/3puUA4hCkKYo4Xdts+JDaVC9ZPRcG8Xw9R4nhO/gZgUM3TENq8IF4Vatk8qCig4MzP/c8G4u2BkVQg==
dependencies:
commander "~2.20.0"
commander "~2.20.3"
source-map "~0.6.1"

uid-number@0.0.6:
Expand Down

0 comments on commit 2e9aa9c

Please sign in to comment.