mirror of
https://github.com/supabase/supabase.git
synced 2026-06-09 11:38:49 +08:00
feat(content api): add troubleshooting guide search results (#35487)
This commit is contained in:
@@ -99,6 +99,18 @@ enum Language {
|
||||
PYTHON
|
||||
}
|
||||
|
||||
"""A document describing how to troubleshoot an issue when using Supabase"""
|
||||
type TroubleshootingGuide implements SearchResult {
|
||||
"""The title of the troubleshooting guide"""
|
||||
title: String
|
||||
|
||||
"""The URL of the troubleshooting guide"""
|
||||
href: String
|
||||
|
||||
"""The full content of the troubleshooting guide"""
|
||||
content: String
|
||||
}
|
||||
|
||||
type RootQueryType {
|
||||
"""Get the GraphQL schema for this endpoint"""
|
||||
schema: String!
|
||||
|
||||
@@ -6,6 +6,7 @@ import { supabase, type DatabaseCorrected } from '~/lib/supabase'
|
||||
import { GuideModel } from '../guide/guideModel'
|
||||
import { ReferenceSDKFunctionModel, SDKLanguageValues } from '../reference/referenceSDKModel'
|
||||
import { SearchResultInterface } from './globalSearchInterface'
|
||||
import { TroubleshootingModel } from '../troubleshooting/troubleshootingModel'
|
||||
|
||||
export abstract class SearchResultModel {
|
||||
static async search(
|
||||
@@ -59,6 +60,12 @@ function createModelFromMatch({
|
||||
methodName: metadata.methodName,
|
||||
})
|
||||
}
|
||||
case 'github-discussions':
|
||||
return new TroubleshootingModel({
|
||||
title: page_title,
|
||||
href,
|
||||
content,
|
||||
})
|
||||
default:
|
||||
return null
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import { RootQueryTypeResolvers } from '~/__generated__/graphql'
|
||||
import { searchRoot } from './globalSearch/globalSearchResolver'
|
||||
import { GraphQLObjectTypeGuide } from './guide/guideSchema'
|
||||
import { GraphQLObjectTypeReferenceSDKFunction } from './reference/referenceSDKSchema'
|
||||
import { GraphQLObjectTypeTroubleshooting } from './troubleshooting/troubleshootingSchema'
|
||||
|
||||
const GRAPHQL_FIELD_INTROSPECT = 'schema' as const
|
||||
|
||||
@@ -35,5 +36,9 @@ export const rootGraphQLSchema = new GraphQLSchema({
|
||||
...searchRoot,
|
||||
},
|
||||
}),
|
||||
types: [GraphQLObjectTypeGuide, GraphQLObjectTypeReferenceSDKFunction],
|
||||
types: [
|
||||
GraphQLObjectTypeGuide,
|
||||
GraphQLObjectTypeReferenceSDKFunction,
|
||||
GraphQLObjectTypeTroubleshooting,
|
||||
],
|
||||
})
|
||||
|
||||
13
apps/docs/resources/troubleshooting/troubleshootingModel.ts
Normal file
13
apps/docs/resources/troubleshooting/troubleshootingModel.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import { type SearchResultInterface } from '../globalSearch/globalSearchInterface'
|
||||
|
||||
export class TroubleshootingModel implements SearchResultInterface {
|
||||
public title?: string
|
||||
public href?: string
|
||||
public content?: string
|
||||
|
||||
constructor({ title, href, content }: { title?: string; href?: string; content?: string }) {
|
||||
this.title = title
|
||||
this.href = href
|
||||
this.content = content
|
||||
}
|
||||
}
|
||||
24
apps/docs/resources/troubleshooting/troubleshootingSchema.ts
Normal file
24
apps/docs/resources/troubleshooting/troubleshootingSchema.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import { GraphQLNonNull, GraphQLObjectType, GraphQLString } from 'graphql'
|
||||
import { GraphQLInterfaceTypeSearchResult } from '../globalSearch/globalSearchSchema'
|
||||
import { TroubleshootingModel } from './troubleshootingModel'
|
||||
|
||||
export const GraphQLObjectTypeTroubleshooting = new GraphQLObjectType({
|
||||
name: 'TroubleshootingGuide',
|
||||
interfaces: [GraphQLInterfaceTypeSearchResult],
|
||||
isTypeOf: (value: unknown) => value instanceof TroubleshootingModel,
|
||||
description: 'A document describing how to troubleshoot an issue when using Supabase',
|
||||
fields: {
|
||||
title: {
|
||||
type: GraphQLString,
|
||||
description: 'The title of the troubleshooting guide',
|
||||
},
|
||||
href: {
|
||||
type: GraphQLString,
|
||||
description: 'The URL of the troubleshooting guide',
|
||||
},
|
||||
content: {
|
||||
type: GraphQLString,
|
||||
description: 'The full content of the troubleshooting guide',
|
||||
},
|
||||
},
|
||||
})
|
||||
Reference in New Issue
Block a user