这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
26e4eb6
cache remote schema's introspection query, fix #1679
rakeshkky Apr 29, 2019
e976fc1
add 'reload_remote_schema' metadata api
rakeshkky Apr 29, 2019
d5c48e8
add remote schema metadata api reference docs
rakeshkky Apr 29, 2019
e8d9f18
Merge branch 'master' into issue-1679-cache-remote-introspection
rakeshkky May 2, 2019
6fd7e4f
build and stitch schemas only at the end of RQL query
rakeshkky May 2, 2019
cd6b659
Merge branch 'master' into issue-1679-cache-remote-introspection
rakeshkky May 6, 2019
a452f07
Merge branch 'master' into issue-1679-cache-remote-introspection
rakeshkky May 13, 2019
ac480f9
Merge branch 'master' into issue-1679-cache-remote-introspection
rakeshkky May 20, 2019
b71c704
rename build graphql context functions
rakeshkky May 27, 2019
5d96397
Merge branch 'master' into issue-1679-cache-remote-introspection
rakeshkky May 27, 2019
3f2afae
Merge branch 'master' into issue-1679-cache-remote-introspection
karthikvt26 May 28, 2019
e3c57e6
Add console changes to support change in the reload remote schema met…
karthikvt26 May 28, 2019
34d4cf4
Load inconsistent objects when trying to reload a particular remote s…
karthikvt26 May 30, 2019
8ae1fb6
simplify API response when remote server returns not 200 status code
rakeshkky Jun 4, 2019
b7d486d
Merge branch 'master' into issue-1679-cache-remote-introspection
rakeshkky Jun 4, 2019
8740c01
Merge branch 'master' into issue-1679-cache-remote-introspection
rakeshkky Jun 11, 2019
8615355
comment `runQueryM'` and improve `httpExceptToJSON` functions
rakeshkky Jun 19, 2019
fe02498
remove invalid commented code
rakeshkky Jun 20, 2019
3ba9f02
Fix lint error
karthikvt26 Jun 20, 2019
c01e34a
Merge branch 'issue-1679-cache-remote-introspection' of github.com:ra…
karthikvt26 Jun 20, 2019
de6ed72
Merge remote-tracking branch 'main/master' into issue-1679-cache-remo…
karthikvt26 Jun 20, 2019
777ce5b
Merge branch 'master' into issue-1679-cache-remote-introspection
rakeshkky Jul 2, 2019
e95345d
add a note in docs and comment why 500 thrown in SchemaCache.hs
rakeshkky Jul 2, 2019
451abd7
Merge branch 'master' into issue-1679-cache-remote-introspection
rakeshkky Jul 3, 2019
92ff224
improved naming of runQueryM function
rakeshkky Jul 3, 2019
fe1ab51
revert the logic of building graphql context at the end of the bulk
rakeshkky Jul 3, 2019
6d7039b
update docs
rikinsk Jul 4, 2019
543ba03
refactor handling inconsistent objects
rikinsk Jul 5, 2019
dc4c026
show reload remote schema error
rikinsk Jul 5, 2019
963ea49
handle inconsistent remote schemas
rikinsk Jul 5, 2019
6e42362
Merge branch 'master' into issue-1679-cache-remote-introspection
rikinsk Jul 5, 2019
bfba275
revert style change
rikinsk Jul 5, 2019
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
35 changes: 19 additions & 16 deletions console/src/components/Services/CustomResolver/Edit/View.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
} from '../Add/addResolverReducer';

import { VIEW_RESOLVER } from '../customActions';
import ReloadMetadata from '../../Metadata/MetadataOptions/ReloadMetadata';
import ReloadRemoteSchema from '../../Metadata/MetadataOptions/ReloadRemoteSchema';

import { appPrefix } from '../constants';

Expand Down Expand Up @@ -117,6 +117,23 @@ class ViewStitchedSchema extends React.Component {
</Tooltip>
);

const showReloadRemoteSchema =
resolverName && resolverName.length > 0 ? (
<div className={styles.commonBtn + ' ' + styles.detailsRefreshButton}>
<span>
<ReloadRemoteSchema
{...this.props}
remoteSchemaName={resolverName}
/>
</span>
<span>
<OverlayTrigger placement="right" overlay={refresh}>
<i className="fa fa-question-circle" aria-hidden="true" />
</OverlayTrigger>
</span>
</div>
) : null;

return (
<div
className={styles.view_stitch_schema_wrapper + ' ' + styles.addWrapper}
Expand Down Expand Up @@ -169,21 +186,7 @@ class ViewStitchedSchema extends React.Component {
</tbody>
</table>
</div>
<div className={styles.commonBtn + ' ' + styles.detailsRefreshButton}>
<span>
<ReloadMetadata
{...this.props}
btnText={'Refresh schema'}
btnTextChanging={'Refreshing schema...'}
bsClass={styles.yellow_button}
/>
</span>
<span>
<OverlayTrigger placement="right" overlay={refresh}>
<i className="fa fa-question-circle" aria-hidden="true" />
</OverlayTrigger>
</span>
</div>
{showReloadRemoteSchema}
</div>
<br />
<br />
Expand Down
36 changes: 34 additions & 2 deletions console/src/components/Services/CustomResolver/customActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { loadMigrationStatus } from '../../Main/Actions';
import { handleMigrationErrors } from '../EventTrigger/EventActions';

import { showSuccessNotification } from '../Common/Notification';
import { filterInconsistentMetadataObjects } from '../Metadata/utils';

/* Action constants */

Expand All @@ -20,6 +21,7 @@ const RESOLVERS_FETCH_SUCCESS = '@customResolver/RESOLVERS_FETCH_SUCCESS';
const FILTER_RESOLVER = '@customResolver/FILTER_RESOLVER';
const RESOLVERS_FETCH_FAIL = '@customResolver/RESOLVERS_FETCH_FAIL';
const RESET = '@customResolver/RESET';
const SET_CONSISTENT_RESOLVERS = '@customResolver/SET_CONSISTENT_RESOLVERS';

const VIEW_RESOLVER = '@customResolver/VIEW_RESOLVER';

Expand Down Expand Up @@ -47,7 +49,21 @@ const fetchResolvers = () => {
dispatch({ type: FETCH_RESOLVERS });
return dispatch(requestAction(url, options)).then(
data => {
dispatch({ type: RESOLVERS_FETCH_SUCCESS, data: data });
let consistentRemoteSchemas = data;
const { inconsistentObjects } = getState().metadata;

if (inconsistentObjects.length > 0) {
consistentRemoteSchemas = filterInconsistentMetadataObjects(
data,
inconsistentObjects,
'remote_schemas'
);
}

dispatch({
type: RESOLVERS_FETCH_SUCCESS,
data: consistentRemoteSchemas,
});
return Promise.resolve();
},
error => {
Expand All @@ -59,6 +75,11 @@ const fetchResolvers = () => {
};
};

const setConsistentRemoteSchemas = data => ({
type: SET_CONSISTENT_RESOLVERS,
data,
});

const listReducer = (state = listState, action) => {
switch (action.type) {
case FETCH_RESOLVERS:
Expand Down Expand Up @@ -97,6 +118,11 @@ const listReducer = (state = listState, action) => {
...state,
viewResolver: action.data,
};
case SET_CONSISTENT_RESOLVERS:
return {
...state,
resolvers: action.data,
};
default:
return {
...state,
Expand Down Expand Up @@ -172,5 +198,11 @@ const makeRequest = (
};
/* */

export { fetchResolvers, FILTER_RESOLVER, VIEW_RESOLVER, makeRequest };
export {
fetchResolvers,
FILTER_RESOLVER,
VIEW_RESOLVER,
makeRequest,
setConsistentRemoteSchemas,
};
export default listReducer;
12 changes: 5 additions & 7 deletions console/src/components/Services/Data/DataActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@ import {
import dataHeaders from './Common/Headers';
import { loadMigrationStatus } from '../../Main/Actions';
import returnMigrateUrl from './Common/getMigrateUrl';
import {
filterInconsistentMetadata,
loadInconsistentObjects,
} from '../Metadata/Actions';
import { loadInconsistentObjects } from '../Metadata/Actions';
import { filterInconsistentMetadataObjects } from '../Metadata/utils';
import globals from '../../../Globals';

import {
Expand Down Expand Up @@ -193,7 +191,7 @@ const fetchTrackedFunctions = () => {
const { inconsistentObjects } = getState().metadata;

if (inconsistentObjects.length > 0) {
consistentFunctions = filterInconsistentMetadata(
consistentFunctions = filterInconsistentMetadataObjects(
data,
inconsistentObjects,
'functions'
Expand Down Expand Up @@ -291,7 +289,7 @@ const loadSchema = configOptions => {

let consistentSchemas;
if (inconsistentObjects.length > 0) {
consistentSchemas = filterInconsistentMetadata(
consistentSchemas = filterInconsistentMetadataObjects(
maybeInconsistentSchemas,
inconsistentObjects,
'tables'
Expand Down Expand Up @@ -384,7 +382,7 @@ const fetchFunctionInit = () => (dispatch, getState) => {
let consistentFunctions = data[2];
const { inconsistentObjects } = getState().metadata;
if (inconsistentObjects.length > 0) {
consistentFunctions = filterInconsistentMetadata(
consistentFunctions = filterInconsistentMetadataObjects(
consistentFunctions,
inconsistentObjects,
'functions'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@ import { loadMigrationStatus } from '../../Main/Actions';
import returnMigrateUrl from './Common/getMigrateUrl';
import globals from '../../../Globals';
import push from './push';
import {
filterInconsistentMetadata,
loadInconsistentObjects,
} from '../Metadata/Actions';
import { loadInconsistentObjects } from '../Metadata/Actions';
import { filterInconsistentMetadataObjects } from '../Metadata/utils';
import { replace } from 'react-router-redux';
import { getEventTriggersQuery } from './utils';

Expand Down Expand Up @@ -73,7 +71,7 @@ const loadTriggers = triggerNames => (dispatch, getState) => {
const { inconsistentObjects } = getState().metadata;
let consistentTriggers;
if (inconsistentObjects.length > 1) {
consistentTriggers = filterInconsistentMetadata(
consistentTriggers = filterInconsistentMetadataObjects(
triggerData,
inconsistentObjects,
'events'
Expand Down
138 changes: 102 additions & 36 deletions console/src/components/Services/Metadata/Actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ import { push } from 'react-router-redux';
import globals from '../../../Globals';
import endpoints from '../../../Endpoints';
import defaultState from './State';
import { filterSchema } from './utils';
import { filterInconsistentMetadataObjects } from './utils';
import { RELOAD_METADATA_API_CHANGE } from '../../../helpers/versionUtils';
import {
setConsistentSchema,
setConsistentFunctions,
} from '../Data/DataActions';
import { setConsistentRemoteSchemas } from '../CustomResolver/customActions';
import {
showSuccessNotification,
showErrorNotification,
Expand Down Expand Up @@ -37,6 +39,25 @@ const reloadCacheQuery = {
args: {},
};

const reloadRemoteSchemaCacheQuery = remoteSchemaName => {
return {
type: 'reload_remote_schema',
args: {
name: remoteSchemaName,
},
};
};

const reloadRemoteSchemaCacheAndGetInconsistentObjectsQuery = remoteSchemaName => {
return {
type: 'bulk',
args: [
reloadRemoteSchemaCacheQuery(remoteSchemaName),
getInconsistentObjectsQuery,
],
};
};

const reloadCacheAndGetInconsistentObjectsQuery = {
type: 'bulk',
args: [reloadCacheQuery, getInconsistentObjectsQuery],
Expand All @@ -47,17 +68,39 @@ const dropInconsistentObjectsQuery = {
args: {},
};

export const filterInconsistentMetadata = (
metadata,
inconsistentObjects,
type
) => {
let filtered = JSON.parse(JSON.stringify(metadata));
inconsistentObjects.forEach(object => {
const partiallyFiltered = filterSchema(filtered, object, type);
filtered = partiallyFiltered;
});
return filtered;
const handleInconsistentObjects = inconsistentObjects => {
return (dispatch, getState) => {
const allSchemas = getState().tables.allSchemas;
const functions = getState().tables.trackedFunctions;
const remoteSchemas = getState().customResolverData.listData.resolvers;

dispatch({
type: LOAD_INCONSISTENT_OBJECTS,
data: inconsistentObjects,
});

if (inconsistentObjects.length > 0) {
const filteredSchema = filterInconsistentMetadataObjects(
allSchemas,
inconsistentObjects,
'tables'
);
const filteredFunctions = filterInconsistentMetadataObjects(
functions,
inconsistentObjects,
'functions'
);
const filteredRemoteSchemas = filterInconsistentMetadataObjects(
remoteSchemas,
inconsistentObjects,
'remote_schemas'
);

dispatch(setConsistentSchema(filteredSchema));
dispatch(setConsistentFunctions(filteredFunctions));
dispatch(setConsistentRemoteSchemas(filteredRemoteSchemas));
}
};
};

export const loadInconsistentObjects = (
Expand All @@ -67,42 +110,65 @@ export const loadInconsistentObjects = (
) => {
return (dispatch, getState) => {
const headers = getState().tables.dataHeaders;

const loadQuery = shouldReloadCache
? reloadCacheAndGetInconsistentObjectsQuery
: getInconsistentObjectsQuery;

dispatch({ type: LOADING_METADATA });
return dispatch(
requestAction(endpoints.query, {
method: 'POST',
headers,
body: JSON.stringify(
shouldReloadCache
? reloadCacheAndGetInconsistentObjectsQuery
: getInconsistentObjectsQuery
),
body: JSON.stringify(loadQuery),
})
).then(
data => {
const allSchemas = getState().tables.allSchemas;
const functions = getState().tables.trackedFunctions;
const inconsistentObjects = shouldReloadCache
? data[1].inconsistent_objects
: data.inconsistent_objects;
dispatch({
type: LOAD_INCONSISTENT_OBJECTS,
data: inconsistentObjects,
});
if (inconsistentObjects.length > 0) {
const filteredSchema = filterInconsistentMetadata(
allSchemas,
inconsistentObjects,
'tables'
);
const filteredFunctions = filterInconsistentMetadata(
functions,
inconsistentObjects,
'functions'
);
dispatch(setConsistentSchema(filteredSchema));
dispatch(setConsistentFunctions(filteredFunctions));

dispatch(handleInconsistentObjects(inconsistentObjects));

if (successCb) {
successCb();
}
},
error => {
console.error(error);
dispatch({ type: LOAD_METADATA_ERROR });
if (failureCb) {
failureCb(error);
}
}
);
};
};

/* Reloads only remote schema metadata */

export const reloadRemoteSchema = (remoteSchemaName, successCb, failureCb) => {
return (dispatch, getState) => {
const headers = getState().tables.dataHeaders;
const { featuresCompatibility } = getState().main;

const reloadQuery = featuresCompatibility[RELOAD_METADATA_API_CHANGE]
? reloadRemoteSchemaCacheAndGetInconsistentObjectsQuery(remoteSchemaName)
: reloadCacheAndGetInconsistentObjectsQuery;

dispatch({ type: LOADING_METADATA });
return dispatch(
requestAction(endpoints.query, {
method: 'POST',
headers,
body: JSON.stringify(reloadQuery),
})
).then(
data => {
const inconsistentObjects = data[1].inconsistent_objects;

dispatch(handleInconsistentObjects(inconsistentObjects));

if (successCb) {
successCb();
}
Expand Down
Loading