feat(content api): add troubleshooting guide search results (#35487)

This commit is contained in:
Charis
2025-05-06 19:07:44 -04:00
committed by GitHub
parent 5923b60f11
commit f57cde2cea
5 changed files with 62 additions and 1 deletions

View File

@@ -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!

View File

@@ -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
}

View File

@@ -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,
],
})

View 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
}
}

View 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',
},
},
})