diff --git a/backend/windmill-worker/src/graphql_executor.rs b/backend/windmill-worker/src/graphql_executor.rs
index 1663b69edd..4aae597a4b 100644
--- a/backend/windmill-worker/src/graphql_executor.rs
+++ b/backend/windmill-worker/src/graphql_executor.rs
@@ -80,7 +80,9 @@ pub async fn do_graphql(
}));
if let Some(token) = &api.bearer_token {
- request = request.bearer_auth(token.as_str());
+ if token.len() > 0 {
+ request = request.bearer_auth(token.as_str());
+ }
}
if let Some(headers) = &api.custom_headers {
diff --git a/frontend/src/lib/components/DBSchemaExplorer.svelte b/frontend/src/lib/components/DBSchemaExplorer.svelte
index 0a3c18e22b..463df5cbc5 100644
--- a/frontend/src/lib/components/DBSchemaExplorer.svelte
+++ b/frontend/src/lib/components/DBSchemaExplorer.svelte
@@ -93,7 +93,7 @@
{/if}
{#if dbSchema.lang === 'graphql'}
-
+
{:else}
{/if}
diff --git a/frontend/src/lib/components/apps/components/display/dbtable/utils.ts b/frontend/src/lib/components/apps/components/display/dbtable/utils.ts
index 9a21a4d3a7..8d8a046434 100644
--- a/frontend/src/lib/components/apps/components/display/dbtable/utils.ts
+++ b/frontend/src/lib/components/apps/components/display/dbtable/utils.ts
@@ -1,7 +1,13 @@
import { JobService, Preview } from '$lib/gen'
import type { DBSchema, DBSchemas, GraphqlSchema, SQLSchema } from '$lib/stores'
-import { buildClientSchema, getIntrospectionQuery, printSchema } from 'graphql'
+import {
+ buildClientSchema,
+ getIntrospectionQuery,
+ printSchema,
+ type IntrospectionQuery
+} from 'graphql'
import { tryEvery } from '$lib/utils'
+import { stringifySchema } from '$lib/components/copilot/lib'
export enum ColumnIdentity {
ByDefault = 'By Default',
@@ -442,21 +448,29 @@ export async function getDbSchemas(
const schema =
processingFn !== undefined ? processingFn(testResult.result) : testResult.result
- dbSchemas[resourcePath] = {
+ const dbSchema = {
lang: resourceTypeToLang(resourceType) as SQLSchema['lang'],
schema,
publicOnly: !!schema.public || !!schema.PUBLIC || !!schema.dbo
}
+ dbSchemas[resourcePath] = {
+ ...dbSchema,
+ stringified: stringifySchema(dbSchema)
+ }
} else {
if (typeof testResult.result !== 'object' || !('__schema' in testResult.result)) {
console.error('Invalid GraphQL schema')
errorCallback('Invalid GraphQL schema')
} else {
- dbSchemas[resourcePath] = {
- lang: 'graphql',
+ const dbSchema = {
+ lang: 'graphql' as GraphqlSchema['lang'],
schema: testResult.result
}
+ dbSchemas[resourcePath] = {
+ ...dbSchema,
+ stringified: stringifySchema(dbSchema)
+ }
}
}
}
@@ -486,18 +500,20 @@ export async function getDbSchemas(
})
}
-export function formatSchema(dbSchema: DBSchema) {
- if (dbSchema.lang !== 'graphql' && dbSchema.publicOnly) {
+export function formatSchema(dbSchema: {
+ lang: SQLSchema['lang']
+ schema: SQLSchema['schema']
+ publicOnly: SQLSchema['publicOnly']
+}) {
+ if (dbSchema.publicOnly) {
return dbSchema.schema.public || dbSchema.schema.PUBLIC || dbSchema.schema.dbo || dbSchema
- } else if (dbSchema.lang === 'mysql' && Object.keys(dbSchema.schema).length === 1) {
- return dbSchema.schema[Object.keys(dbSchema.schema)[0]]
} else {
return dbSchema.schema
}
}
-export function formatGraphqlSchema(dbSchema: GraphqlSchema): string {
- return printSchema(buildClientSchema(dbSchema.schema))
+export function formatGraphqlSchema(schema: IntrospectionQuery): string {
+ return printSchema(buildClientSchema(schema))
}
export function getFieldType(type: string, databaseType: DbType) {
diff --git a/frontend/src/lib/components/copilot/ScriptGen.svelte b/frontend/src/lib/components/copilot/ScriptGen.svelte
index 2f2146c817..bf0fea92c1 100644
--- a/frontend/src/lib/components/copilot/ScriptGen.svelte
+++ b/frontend/src/lib/components/copilot/ScriptGen.svelte
@@ -1,7 +1,7 @@