chore: add fallback url and add reqIndex for graphql saving
This commit is contained in:
@@ -193,6 +193,7 @@ import { PersistedOAuthConfig } from "~/services/oauth/oauth.service"
|
||||
import { GQLOptionTabs } from "~/components/graphql/RequestOptions.vue"
|
||||
import { EditingProperties } from "../Properties.vue"
|
||||
import { defineActionHandler } from "~/helpers/actions"
|
||||
import { getDefaultGQLRequest } from "~/helpers/graphql/default"
|
||||
|
||||
const t = useI18n()
|
||||
const toast = useToast()
|
||||
@@ -380,32 +381,26 @@ const editCollection = (
|
||||
displayModalEdit(true)
|
||||
}
|
||||
|
||||
const onAddRequest = ({
|
||||
name,
|
||||
path,
|
||||
index,
|
||||
}: {
|
||||
name: string
|
||||
path: string
|
||||
index: number
|
||||
}) => {
|
||||
const onAddRequest = ({ name, path }: { name: string; path: string }) => {
|
||||
const newRequest = {
|
||||
...tabs.currentActiveTab.value.document.request,
|
||||
name,
|
||||
url:
|
||||
tabs.currentActiveTab.value.document.request.url ||
|
||||
getDefaultGQLRequest().url,
|
||||
}
|
||||
|
||||
saveGraphqlRequestAs(path, newRequest)
|
||||
const insertionIndex = saveGraphqlRequestAs(path, newRequest)
|
||||
|
||||
const { auth, headers } = cascadeParentCollectionForHeaderAuth(
|
||||
path,
|
||||
"graphql"
|
||||
)
|
||||
|
||||
tabs.createNewTab({
|
||||
saveContext: {
|
||||
originLocation: "user-collection",
|
||||
folderPath: path,
|
||||
requestIndex: index,
|
||||
requestIndex: insertionIndex,
|
||||
},
|
||||
request: newRequest,
|
||||
isDirty: false,
|
||||
|
||||
@@ -254,6 +254,7 @@ import { PersistenceService } from "~/services/persistence"
|
||||
import { PersistedOAuthConfig } from "~/services/oauth/oauth.service"
|
||||
import { RESTOptionTabs } from "../http/RequestOptions.vue"
|
||||
import { EditingProperties } from "./Properties.vue"
|
||||
import { getDefaultRESTRequest } from "~/helpers/rest/default"
|
||||
|
||||
const t = useI18n()
|
||||
const toast = useToast()
|
||||
@@ -790,6 +791,9 @@ const onAddRequest = (requestName: string) => {
|
||||
const newRequest = {
|
||||
...cloneDeep(tabs.currentActiveTab.value.document.request),
|
||||
name: requestName,
|
||||
endpoint:
|
||||
tabs.currentActiveTab.value.document.request.endpoint ||
|
||||
getDefaultRESTRequest().endpoint,
|
||||
}
|
||||
|
||||
const path = editingFolderPath.value
|
||||
|
||||
@@ -120,7 +120,9 @@ const request = useVModel(props, "modelValue", emit)
|
||||
|
||||
const url = computedWithControl(
|
||||
() => tabs.currentActiveTab.value,
|
||||
() => tabs.currentActiveTab.value.document.request.url
|
||||
() =>
|
||||
tabs.currentActiveTab.value.document.request.url ||
|
||||
getDefaultGQLRequest().url
|
||||
)
|
||||
|
||||
const activeGQLHeadersCount = computed(
|
||||
|
||||
@@ -1393,6 +1393,14 @@ export function editGraphqlRequest(
|
||||
}
|
||||
|
||||
export function saveGraphqlRequestAs(path: string, request: HoppGQLRequest) {
|
||||
// For calculating the insertion request index
|
||||
const targetLocation = navigateToFolderWithIndexPath(
|
||||
graphqlCollectionStore.value.state,
|
||||
path.split("/").map((x) => parseInt(x))
|
||||
)
|
||||
|
||||
const insertionIndex = targetLocation!.requests.length
|
||||
|
||||
graphqlCollectionStore.dispatch({
|
||||
dispatcher: "saveRequestAs",
|
||||
payload: {
|
||||
@@ -1400,6 +1408,8 @@ export function saveGraphqlRequestAs(path: string, request: HoppGQLRequest) {
|
||||
request,
|
||||
},
|
||||
})
|
||||
|
||||
return insertionIndex
|
||||
}
|
||||
|
||||
export function removeGraphqlRequest(
|
||||
|
||||
Reference in New Issue
Block a user