Files
supabase/apps/docs/resources/rootSchema.ts
Charis 03dcd51700 feat(content api): search result for cli reference (#35488)
## Before

Search results ignored if they are CLI references.

## After

Search results returned for CLI references.
2025-05-06 19:23:40 -04:00

47 lines
1.4 KiB
TypeScript

import {
GraphQLNonNull,
GraphQLObjectType,
GraphQLSchema,
GraphQLString,
printSchema,
} from 'graphql'
import { RootQueryTypeResolvers } from '~/__generated__/graphql'
import { searchRoot } from './globalSearch/globalSearchResolver'
import { GraphQLObjectTypeGuide } from './guide/guideSchema'
import { GraphQLObjectTypeReferenceCLICommand } from './reference/referenceCLISchema'
import { GraphQLObjectTypeReferenceSDKFunction } from './reference/referenceSDKSchema'
import { GraphQLObjectTypeTroubleshooting } from './troubleshooting/troubleshootingSchema'
const GRAPHQL_FIELD_INTROSPECT = 'schema' as const
type IntrospectResolver = RootQueryTypeResolvers[typeof GRAPHQL_FIELD_INTROSPECT]
const resolveIntrospect: IntrospectResolver = async () => {
const schema = printSchema(rootGraphQLSchema)
return schema
}
const introspectRoot = {
[GRAPHQL_FIELD_INTROSPECT]: {
description: 'Get the GraphQL schema for this endpoint',
type: new GraphQLNonNull(GraphQLString),
resolve: resolveIntrospect,
},
}
export const rootGraphQLSchema = new GraphQLSchema({
query: new GraphQLObjectType({
name: 'RootQueryType',
fields: {
...introspectRoot,
...searchRoot,
},
}),
types: [
GraphQLObjectTypeGuide,
GraphQLObjectTypeReferenceCLICommand,
GraphQLObjectTypeReferenceSDKFunction,
GraphQLObjectTypeTroubleshooting,
],
})