fix: clicking on run query without connecting connects without docs polling (#4516)

This commit is contained in:
Andrew Bastin
2024-11-07 12:28:04 +05:30
committed by GitHub
parent e87ec8c026
commit 80dbe8c8fe
2 changed files with 8 additions and 7 deletions

View File

@@ -1,10 +1,10 @@
/* eslint-disable */ /* eslint-disable */
/* prettier-ignore */
// @ts-nocheck // @ts-nocheck
// Generated by unplugin-vue-components // Generated by unplugin-vue-components
// Read more: https://github.com/vuejs/core/pull/3399 // Read more: https://github.com/vuejs/core/pull/3399
export {} export {}
/* prettier-ignore */
declare module 'vue' { declare module 'vue' {
export interface GlobalComponents { export interface GlobalComponents {
AccessTokens: typeof import('./components/accessTokens/index.vue')['default'] AccessTokens: typeof import('./components/accessTokens/index.vue')['default']

View File

@@ -159,7 +159,7 @@ export const graphqlTypes = computed(() => {
let timeoutSubscription: any let timeoutSubscription: any
export const connect = (url: string, headers: GQLHeader[]) => { export const connect = async (url: string, headers: GQLHeader[]) => {
if (connection.state === "CONNECTED") { if (connection.state === "CONNECTED") {
throw new Error( throw new Error(
"A connection is already running. Close it before starting another." "A connection is already running. Close it before starting another."
@@ -175,7 +175,8 @@ export const connect = (url: string, headers: GQLHeader[]) => {
poll() poll()
}, GQL_SCHEMA_POLL_INTERVAL) }, GQL_SCHEMA_POLL_INTERVAL)
} }
poll()
await poll()
} }
export const disconnect = () => { export const disconnect = () => {
@@ -256,6 +257,10 @@ const getSchema = async (url: string, headers: GQLHeader[]) => {
} }
export const runGQLOperation = async (options: RunQueryOptions) => { export const runGQLOperation = async (options: RunQueryOptions) => {
if (connection.state !== "CONNECTED") {
await connect(options.url, options.headers)
}
const { url, headers, query, variables, auth, operationName, operationType } = const { url, headers, query, variables, auth, operationName, operationType } =
options options
@@ -379,10 +384,6 @@ export const runGQLOperation = async (options: RunQueryOptions) => {
operationType, operationType,
} }
if (connection.state !== "CONNECTED") {
connection.state = "CONNECTED"
}
addQueryToHistory(options, responseText) addQueryToHistory(options, responseText)
return responseText return responseText