2020-04-22 19:07:51 +05:30
|
|
|
import GetSnippetQuery from '../queries/snippet.query.graphql';
|
|
|
|
|
2020-07-28 23:09:34 +05:30
|
|
|
const blobsDefault = [];
|
|
|
|
|
2020-04-22 19:07:51 +05:30
|
|
|
export const getSnippetMixin = {
|
|
|
|
apollo: {
|
|
|
|
snippet: {
|
|
|
|
query: GetSnippetQuery,
|
|
|
|
variables() {
|
|
|
|
return {
|
|
|
|
ids: this.snippetGid,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
update: data => data.snippets.edges[0]?.node,
|
|
|
|
result(res) {
|
2020-07-28 23:09:34 +05:30
|
|
|
this.blobs = res.data.snippets.edges[0]?.node?.blobs || blobsDefault;
|
2020-04-22 19:07:51 +05:30
|
|
|
if (this.onSnippetFetch) {
|
|
|
|
this.onSnippetFetch(res);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
props: {
|
|
|
|
snippetGid: {
|
|
|
|
type: String,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
snippet: {},
|
|
|
|
newSnippet: false,
|
2020-07-28 23:09:34 +05:30
|
|
|
blobs: blobsDefault,
|
2020-04-22 19:07:51 +05:30
|
|
|
};
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
isLoading() {
|
|
|
|
return this.$apollo.queries.snippet.loading;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|