feat: graphql request history and collection restore

This commit is contained in:
Andrew Bastin
2021-08-12 16:14:41 +05:30
parent 55bcb34fd5
commit a1dc224007
6 changed files with 94 additions and 52 deletions

View File

@@ -55,6 +55,7 @@ import {
editGraphqlRequest,
saveGraphqlRequestAs,
} from "~/newstore/collections"
import { getGQLSession, useGQLRequestName } from "~/newstore/GQLSession"
import { getRESTRequest, useRESTRequestName } from "~/newstore/RESTSession"
export default defineComponent({
@@ -63,9 +64,10 @@ export default defineComponent({
mode: { type: String, default: "rest" },
show: Boolean,
},
setup() {
setup(props) {
return {
requestName: useRESTRequestName(),
requestName:
props.mode === "rest" ? useRESTRequestName() : useGQLRequestName(),
}
},
data() {
@@ -118,7 +120,8 @@ export default defineComponent({
return
}
const requestUpdated = getRESTRequest()
const requestUpdated =
this.mode === "rest" ? getRESTRequest() : getGQLSession()
// Filter out all REST file inputs
if (this.mode === "rest" && requestUpdated.bodyParams) {

View File

@@ -92,6 +92,7 @@
<script lang="ts">
import Vue from "vue"
import { removeGraphqlRequest } from "~/newstore/collections"
import { setGQLSession } from "~/newstore/GQLSession"
export default Vue.extend({
props: {
@@ -133,6 +134,16 @@ export default Vue.extend({
selectRequest() {
if (this.savingMode) {
this.pick()
} else {
setGQLSession({
name: this.$props.request.name,
url: this.$props.request.url,
query: this.$props.request.query,
headers: this.$props.request.headers,
variables: this.$props.request.variables,
schema: "",
response: "",
})
}
},
dragStart({ dataTransfer }: any) {