mirror of
https://github.com/supabase/supabase.git
synced 2026-09-06 18:11:51 +08:00
## Before Search results ignored if they are CLI references. ## After Search results returned for CLI references.
47 lines
1.4 KiB
TypeScript
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,
|
|
],
|
|
})
|