Commit d35eea3d authored by Fernando Arias's avatar Fernando Arias

Hit graphql mutation for corpus creation

parent 13ebe8bf
......@@ -74,7 +74,11 @@ export default {
addCorpus() {
this.$apollo.mutate({
mutation: addCorpusMutation,
variables: { name: this.$options.i18n.newCorpus, projectPath: this.projectFullPath },
variables: {
name: this.$options.i18n.newCorpus,
projectPath: this.projectFullPath,
packageId: this.states.uploadState.uploadedPackageId,
},
});
},
resetCorpus() {
......
......@@ -30,7 +30,7 @@ export default {
corpusName: s__('CorpusManagement|Corpus name'),
uploadButtonText: __('Choose File...'),
uploadMessage: s__(
'CorpusManagement|New corpus needs to be a upload in *.zip format. Maximum 10GB',
'CorpusManagement|New corpus needs to be a upload in *.zip format. Maximum 5GB',
),
},
data() {
......
mutation addCorpus($projectPath: ID!, $name: String!) {
addCorpus(projectPath: $projectPath, name: $name) @client {
mutation addCorpus($projectPath: ID!, $name: String!, $packageId: Int!) {
addCorpus(projectPath: $projectPath, name: $name, packageId: $packageId) @client {
errors
}
}
mutation CorpusCreate($input: CorpusCreateInput!) {
corpusCreate(input: $input) {
errors
}
}
......@@ -5,6 +5,7 @@ import axios from '~/lib/utils/axios_utils';
import getCorpusesQuery from '../queries/get_corpuses.query.graphql';
import updateProgress from '../mutations/update_progress.mutation.graphql';
import uploadComplete from '../mutations/upload_complete.mutation.graphql';
import corpusCreate from '../mutations/corpus_create.mutation.graphql';
export default {
Query: {
......@@ -29,7 +30,7 @@ export default {
},
},
Mutation: {
addCorpus: (_, { name, projectPath }, { cache }) => {
addCorpus: (_, { name, projectPath, packageId }, { cache, client }) => {
const sourceData = cache.readQuery({
query: getCorpusesQuery,
variables: { projectPath },
......@@ -56,6 +57,11 @@ export default {
});
cache.writeQuery({ query: getCorpusesQuery, data, variables: { projectPath } });
client.mutate({
mutation: corpusCreate,
variables: { fullPath: projectPath, packageId },
});
},
deleteCorpus: (_, { name, projectPath }, { cache }) => {
const sourceData = cache.readQuery({
......@@ -99,7 +105,7 @@ export default {
uploadState.cancelSource = source;
});
cache.writeQuery({ query: getCorpusesQuery, targetData, variables: { projectPath } });
cache.writeQuery({ query: getCorpusesQuery, data: targetData, variables: { projectPath } });
publishPackage(
{ projectPath, name, version: 0, fileName: name, files },
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment