Merge branch 'master' into feat/chrome-extension

This commit is contained in:
Andrew Bastin
2020-01-21 21:09:15 -05:00
committed by GitHub
3 changed files with 43 additions and 11 deletions

View File

@@ -33,7 +33,8 @@ export default {
data() { data() {
return { return {
editor: null, editor: null,
cacheValue: "" cacheValue: "",
validationSchema: null
}; };
}, },
@@ -87,19 +88,42 @@ export default {
); );
} }
}, },
setValidationSchema(schema) {
this.validationSchema = schema;
this.parseContents(this.cacheValue);
},
parseContents: debounce(function(content) { parseContents: debounce(function(content) {
try { if (content !== "") {
gql.parse(content); try {
} catch (e) { const doc = gql.parse(content);
this.editor.session.setAnnotations([
{ if (this.validationSchema) {
row: e.locations[0].line - 1, this.editor.session.setAnnotations(
column: e.locations[0].column - 1, gql.validate(this.validationSchema, doc)
text: e.message, .map((err) => {
type: "error" return {
row: err.locations[0].line - 1,
column: err.locations[0].column - 1,
text: err.message,
type: "error"
}
})
)
} }
]); } catch (e) {
this.editor.session.setAnnotations([
{
row: e.locations[0].line - 1,
column: e.locations[0].column - 1,
text: e.message,
type: "error"
}
]);
}
} else {
this.editor.session.setAnnotations([]);
} }
}, 2000) }, 2000)
}, },

View File

@@ -812,6 +812,8 @@ export default {
} }
} }
this.gqlTypes = types; this.gqlTypes = types;
this.$refs.queryEditor.setValidationSchema(schema);
this.$nuxt.$loading.finish(); this.$nuxt.$loading.finish();
const duration = Date.now() - startTime; const duration = Date.now() - startTime;

View File

@@ -111,6 +111,12 @@ export const mutations = {
}, },
addNewCollection({ collections }, collection) { addNewCollection({ collections }, collection) {
const { name } = collection
const duplicateCollection = collections.some(item => item.name === name)
if (duplicateCollection) {
this.$toast.info('Duplicate collection');
return;
}
collections.push({ collections.push({
name: "", name: "",
folders: [], folders: [],