2020-11-12 15:09:09 +00:00
|
|
|
import produce from 'immer';
|
2021-02-14 18:09:20 +00:00
|
|
|
import Vue from 'vue';
|
2020-11-12 15:09:09 +00:00
|
|
|
import VueApollo from 'vue-apollo';
|
|
|
|
import createDefaultClient from '~/lib/graphql';
|
|
|
|
import getCurrentIntegrationQuery from './graphql/queries/get_current_integration.query.graphql';
|
|
|
|
|
|
|
|
Vue.use(VueApollo);
|
|
|
|
|
|
|
|
const resolvers = {
|
|
|
|
Mutation: {
|
|
|
|
updateCurrentIntegration: (
|
|
|
|
_,
|
2021-02-23 21:10:44 +00:00
|
|
|
{
|
|
|
|
id = null,
|
|
|
|
name,
|
|
|
|
active,
|
|
|
|
token,
|
|
|
|
type,
|
|
|
|
url,
|
|
|
|
apiUrl,
|
|
|
|
payloadExample,
|
|
|
|
payloadAttributeMappings,
|
|
|
|
payloadAlertFields,
|
|
|
|
},
|
2020-11-12 15:09:09 +00:00
|
|
|
{ cache },
|
|
|
|
) => {
|
|
|
|
const sourceData = cache.readQuery({ query: getCurrentIntegrationQuery });
|
2020-12-23 21:10:24 +00:00
|
|
|
const data = produce(sourceData, (draftData) => {
|
2020-11-12 15:09:09 +00:00
|
|
|
if (id === null) {
|
|
|
|
draftData.currentIntegration = null;
|
|
|
|
} else {
|
|
|
|
draftData.currentIntegration = {
|
|
|
|
id,
|
|
|
|
name,
|
|
|
|
active,
|
|
|
|
token,
|
|
|
|
type,
|
|
|
|
url,
|
|
|
|
apiUrl,
|
2021-02-23 21:10:44 +00:00
|
|
|
payloadExample,
|
|
|
|
payloadAttributeMappings,
|
|
|
|
payloadAlertFields,
|
2020-11-12 15:09:09 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
});
|
|
|
|
cache.writeQuery({ query: getCurrentIntegrationQuery, data });
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
export default new VueApollo({
|
|
|
|
defaultClient: createDefaultClient(resolvers, {
|
|
|
|
cacheConfig: {},
|
|
|
|
assumeImmutableResults: true,
|
|
|
|
}),
|
|
|
|
});
|