mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-09-08 00:03:07 +00:00
fix: handle graphql invalid response (#2582)
This commit is contained in:
@@ -205,9 +205,16 @@ GROUP BY table_name".replace('{dataset.id}', dataset.id)
|
||||
publicOnly: !!schema.public || !!schema.PUBLIC
|
||||
}
|
||||
} else {
|
||||
$dbSchemas[resourcePath] = {
|
||||
lang: 'graphql',
|
||||
schema: testResult.result
|
||||
if (typeof testResult.result !== 'object' || !('__schema' in testResult.result)) {
|
||||
console.error('Invalid GraphQL schema')
|
||||
if (drawer?.isOpen()) {
|
||||
sendUserToast('Invalid GraphQL schema', true)
|
||||
}
|
||||
} else {
|
||||
$dbSchemas[resourcePath] = {
|
||||
lang: 'graphql',
|
||||
schema: testResult.result
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { JobService, Preview } from '$lib/gen'
|
||||
import { CompletedJob, JobService, Preview } from '$lib/gen'
|
||||
|
||||
import { Database, Loader2 } from 'lucide-svelte'
|
||||
import Button from './common/button/Button.svelte'
|
||||
@@ -15,6 +15,7 @@
|
||||
code: string
|
||||
lang: string
|
||||
argName: string
|
||||
additionalCheck?: (testResult: CompletedJob) => CompletedJob
|
||||
}
|
||||
} = {
|
||||
postgresql: {
|
||||
@@ -40,7 +41,25 @@
|
||||
graphql: {
|
||||
code: '{ __typename }',
|
||||
lang: 'graphql',
|
||||
argName: 'api'
|
||||
argName: 'api',
|
||||
additionalCheck: (testResult: CompletedJob) => {
|
||||
if (
|
||||
testResult.success &&
|
||||
(typeof testResult.result !== 'object' || !('__typename' in testResult.result))
|
||||
) {
|
||||
return {
|
||||
...testResult,
|
||||
result: {
|
||||
error: {
|
||||
message: 'Invalid GraphQL API response'
|
||||
}
|
||||
},
|
||||
success: false
|
||||
}
|
||||
} else {
|
||||
return testResult
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,13 +83,18 @@
|
||||
|
||||
tryEvery({
|
||||
tryCode: async () => {
|
||||
const testResult = await JobService.getCompletedJob({
|
||||
let testResult = await JobService.getCompletedJob({
|
||||
workspace: $workspaceStore!,
|
||||
id: job
|
||||
})
|
||||
if (resourceScript.additionalCheck) {
|
||||
testResult = resourceScript.additionalCheck(testResult)
|
||||
}
|
||||
loading = false
|
||||
sendUserToast(
|
||||
testResult.success ? 'Connection successful' : testResult.result?.['error']?.['message'],
|
||||
testResult.success
|
||||
? 'Connection successful'
|
||||
: 'Connection error: ' + testResult.result?.['error']?.['message'],
|
||||
!testResult.success
|
||||
)
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user