mirror of
https://github.com/supabase/supabase.git
synced 2026-05-11 02:20:29 +08:00
* feat(content api): add client library api reference search results Allow searchDocs results to also return function references from the client library APIs * fix(content api): refine language enum handling
42 lines
1.4 KiB
TypeScript
42 lines
1.4 KiB
TypeScript
import { GraphQLEnumType, GraphQLNonNull, GraphQLObjectType, GraphQLString } from 'graphql'
|
|
import { GraphQLInterfaceTypeSearchResult } from '../globalSearch/globalSearchSchema'
|
|
import { ReferenceSDKFunctionModel, SDKLanguages } from './referenceSDKModel'
|
|
|
|
const GraphQLEnumLanguage = new GraphQLEnumType({
|
|
name: 'Language',
|
|
values: Object.keys(SDKLanguages).reduce((acc, key) => {
|
|
acc[key] = { value: SDKLanguages[key].value }
|
|
return acc
|
|
}, {}),
|
|
})
|
|
|
|
export const GraphQLObjectTypeReferenceSDKFunction = new GraphQLObjectType({
|
|
name: 'ClientLibraryFunctionReference',
|
|
interfaces: [GraphQLInterfaceTypeSearchResult],
|
|
isTypeOf: (value: unknown) => value instanceof ReferenceSDKFunctionModel,
|
|
description:
|
|
'A reference document containing a description of a function from a Supabase client library',
|
|
fields: {
|
|
title: {
|
|
type: GraphQLString,
|
|
description: 'The title of the document',
|
|
},
|
|
href: {
|
|
type: GraphQLString,
|
|
description: 'The URL of the document',
|
|
},
|
|
content: {
|
|
type: GraphQLString,
|
|
description: 'The content of the reference document, as text',
|
|
},
|
|
language: {
|
|
type: new GraphQLNonNull(GraphQLEnumLanguage),
|
|
description: 'The programming language for which the function is written',
|
|
},
|
|
methodName: {
|
|
type: GraphQLString,
|
|
description: 'The name of the function or method',
|
|
},
|
|
},
|
|
})
|